-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix[next]: Allow np.bool scalar in gtfn backend #1870
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a simple solution that just works.
@@ -34,6 +35,8 @@ def convert_arg(arg: Any) -> Any: | |||
arr = arg.ndarray | |||
origin = getattr(arg, "__gt_origin__", tuple([0] * len(arg.domain))) | |||
return arr, origin | |||
if isinstance(arg, np.bool_): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance(arg, np.bool_): | |
if isinstance(arg, np.bool_): |
Could you leave a comment why this is needed? Does numpy.float64
and python float
work? If so, why does bool
not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree about adding a comment here and would also suggest to use a ternary operator:
return bool(arg) if isinstance(arg, np.bool_) else arg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a switch-like if
therefore I wouldn't do the ternary, like in the other cases.
@@ -34,6 +35,9 @@ def convert_arg(arg: Any) -> Any: | |||
arr = arg.ndarray | |||
origin = getattr(arg, "__gt_origin__", tuple([0] * len(arg.domain))) | |||
return arr, origin | |||
if isinstance(arg, np.bool_): | |||
# nanobind does not support implicit conversion of `np.bool` to `bool`# nanobind does not support implicit conversion of `np.bool` to `bool` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# nanobind does not support implicit conversion of `np.bool` to `bool`# nanobind does not support implicit conversion of `np.bool` to `bool` | |
# nanobind does not support implicit conversion of `np.bool` to `bool` |
Fixes #1861.
Additional changes:
all-next
uv extra (to install dace-next)