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

Test nb::int_(double). #793

Merged
merged 2 commits into from
Dec 17, 2024
Merged

Test nb::int_(double). #793

merged 2 commits into from
Dec 17, 2024

Conversation

1uc
Copy link
Contributor

@1uc 1uc commented Nov 20, 2024

This commit adds tests that demonstrate that nb::int_(x) does not create an integer, but instead it creates a float. There's three new tests:

  • test_21_f (f because float) that shows that when converting from nb::float_ the issue isn't present.
  • test_21_g (g is after f) that nb::int_(1.5) creates a Python float and not an int. The two Python drivers for the test fail as follows:
>       assert type(t.test_21_h()) is int
E       AssertionError: assert <class 'float'> is int
E        +  where <class 'float'> = type(1e+50)
E        +    where 1e+50 = <nanobind.nb_func object at 0x7a1c53febcd0>()
E        +      where <nanobind.nb_func object at 0x7a1c53febcd0> = t.test_21_h

>       assert type(t.test_21_g()) is int
E       AssertionError: assert <class 'float'> is int
E        +  where <class 'float'> = type(1.5)
E        +    where 1.5 = <nanobind.nb_func object at 0x756d659efbc0>()
E        +      where <nanobind.nb_func object at 0x756d659efbc0> = t.test_21_g
  • test_21_h (h for huge) that check of something like nb::int_((long) x) isn't an ideal workaround.

1uc added 2 commits November 20, 2024 11:26
This commit adds tests that demonstrate that `nb::int_(x)` does not
create an integer, but instead it creates a float.
@wjakob wjakob merged commit d7d9d90 into wjakob:master Dec 17, 2024
0 of 31 checks passed
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.

2 participants