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 creation functions with builtin like kwarg #23

Merged
merged 7 commits into from
May 13, 2024
Merged

Conversation

dwierichs
Copy link
Contributor

This PR fixes #22 by making _maybe_inject_dtype_device fall back to the type of the provided like input if the attribute like.dtype does not exist.
Tests are added accordingly.

@pep8speaks
Copy link

pep8speaks commented May 13, 2024

Hello @dwierichs! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2024-05-13 19:11:15 UTC

@jcmgray
Copy link
Owner

jcmgray commented May 13, 2024

Hi @dwierichs, thanks for the issue and quick PR!

The test failure is genuine - and comes from the fact that the numpy default integer type on windows is int32 not int64... ( I think this is about to change with numpy v2.0).

You could change the type check to something softer, with e.g.:

assert "int" in ar.get_dtype_name(y)

for the integer case.

@dwierichs
Copy link
Contributor Author

Thanks for the context @jcmgray , that would have taken me way too much time to find out 😅

I went for

assert y.dtype in expected

and a list of expected=[np.int32, np.int64] for that test case. Hope that works :)

@jcmgray
Copy link
Owner

jcmgray commented May 13, 2024

Perfect thanks very much!

@jcmgray jcmgray merged commit 96b42b7 into jcmgray:main May 13, 2024
12 checks passed
erick-xanadu added a commit to PennyLaneAI/catalyst that referenced this pull request May 13, 2024
**Context:** Until a new version of autoray that uses PR
jcmgray/autoray#23, we will pin to less that
0.6.10 to allow CI/CD to pass.
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.

[Bug] _maybe_inject_dtype_device does not work with builtin inputs to like
3 participants