Skip to content

Commit

Permalink
pass all arguments to NaN constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfikl committed Sep 23, 2023
1 parent da3c0a1 commit a9b57f4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions loopy/target/c/codegen/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,8 @@ def map_constant(self, expr, type_context):
" The generated code will be equivalent with the added benefit"
" of sound pickling/unpickling of kernel objects.")
from pymbolic.primitives import NaN
if not isinstance(expr, np.generic):
return self.map_nan(NaN(), type_context)
else:
return self.map_nan(NaN(expr.dtype.type), type_context)
data_type = expr.dtype.type if isinstance(expr, np.generic) else None
return self.map_nan(NaN(data_type), type_context)
elif np.isneginf(expr):
return -p.Variable("INFINITY")
elif np.isinf(expr):
Expand Down
2 changes: 1 addition & 1 deletion test/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ def test_nan_support(ctx_factory, target):
lp.Assignment(parse("c"), parse("isnan(3.14)")),
lp.Assignment(parse("d"), parse("isnan(0.0)")),
lp.Assignment(parse("e"), NaN(np.float32)),
lp.Assignment(parse("f"), Variable("isnan")(NaN())),
lp.Assignment(parse("f"), Variable("isnan")(NaN(None))),
lp.Assignment(parse("g"), NaN(np.complex64)),
lp.Assignment(parse("h"), NaN(np.complex128)),
],
Expand Down

0 comments on commit a9b57f4

Please sign in to comment.