Skip to content

Commit

Permalink
fix: Assertion condition when value is 0 (#3401)
Browse files Browse the repository at this point in the history
* fix: Add assertion condition when value is 0

Signed-off-by: zlatan.el <zlatan.el@kakaomobility.com>

* chore: Add comment about zero value validation

Signed-off-by: zlatan.el <zlatan.el@kakaomobility.com>

* chore: Modifiy the comment

Signed-off-by: zlatan.el <zlatan.el@kakaomobility.com>

* chore: Add the comment

Signed-off-by: zlatan.el <zlatan.el@kakaomobility.com>

Signed-off-by: zlatan.el <zlatan.el@kakaomobility.com>
Co-authored-by: zlatan.el <zlatan.el@kakaomobility.com>
  • Loading branch information
kysersozelee and km-zlatan-el authored Dec 20, 2022
1 parent 0ab3942 commit 98a24a3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sdk/python/feast/type_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,12 @@ def _python_value_to_proto_value(
valid_scalar_types,
) = PYTHON_SCALAR_VALUE_TYPE_TO_PROTO_VALUE[feast_value_type]
if valid_scalar_types:
assert type(sample) in valid_scalar_types
if sample == 0 or sample == 0.0:
# Numpy convert 0 to int. However, in the feature view definition, the type of column may be a float.
# So, if value is 0, type validation must pass if scalar_types are either int or float.
assert type(sample) in [np.int64, int, np.float64, float]
else:
assert type(sample) in valid_scalar_types
if feast_value_type == ValueType.BOOL:
# ProtoValue does not support conversion of np.bool_ so we need to convert it to support np.bool_.
return [
Expand Down

0 comments on commit 98a24a3

Please sign in to comment.