Skip to content
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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

havogt
Copy link
Contributor

@havogt havogt commented Feb 17, 2025

Fixes #1861.

Additional changes:

  • introduces all-next uv extra (to install dace-next)

Copy link
Contributor

@tehrengruber tehrengruber left a 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_):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Copy link
Contributor

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

Copy link
Contributor Author

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.

@havogt havogt requested review from tehrengruber and removed request for edopao February 28, 2025 13:41
@@ -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`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

next: np.bool_ argument handling broken in gtfn backend
3 participants