提交 e212ff03 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Thomas Wiecki

Fix nan comparison in Scalar.filter

上级 9f540975
...@@ -360,7 +360,7 @@ class Scalar(CType): ...@@ -360,7 +360,7 @@ class Scalar(CType):
and isinstance(data, (float, np.floating)) and isinstance(data, (float, np.floating))
and self.dtype == config.floatX and self.dtype == config.floatX
) )
or data == converted_data or np.array_equal(data, converted_data, equal_nan=True)
): ):
return py_type(data) return py_type(data)
else: else:
......
...@@ -51,3 +51,7 @@ def test_filter_float_subclass(): ...@@ -51,3 +51,7 @@ def test_filter_float_subclass():
filtered_nan = test_type.filter(nan) filtered_nan = test_type.filter(nan)
assert isinstance(filtered_nan, np.floating) assert isinstance(filtered_nan, np.floating)
with config.change_flags(floatX="float64"):
filtered_nan = test_type.filter(nan)
assert isinstance(filtered_nan, np.floating)
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论