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

[array API] support copy argument to jnp.asarray #19186

Merged
merged 1 commit into from
Jan 4, 2024

Conversation

jakevdp
Copy link
Collaborator

@jakevdp jakevdp commented Jan 3, 2024

Part of #18353

The semantics of copy follow the specification here: https://data-apis.org/array-api/2022.12/API_specification/generated/array_api.asarray.html

@jakevdp jakevdp mentioned this pull request Jan 3, 2024
38 tasks
@jakevdp jakevdp self-assigned this Jan 3, 2024
@jakevdp jakevdp added the pull ready Ready for copybara import and testing label Jan 3, 2024
view = memoryview(obj)
except TypeError:
return False
else:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of else, can you return True in the try block directly?

Copy link
Collaborator Author

@jakevdp jakevdp Jan 4, 2024

Choose a reason for hiding this comment

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

The principle I'm following here is to put as little as possible in the try: block to avoid catching unexpected exceptions. But admittedly I think it's very unlikely that return True would raise an exception 😁 ... still style-wise I marginally prefer the else block anyway. What do you think?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure, sounds good. For me the else is very confusing and I have to look it up everytime ;)

@copybara-service copybara-service bot merged commit c06c292 into jax-ml:main Jan 4, 2024
13 checks passed
@jakevdp jakevdp deleted the asarray-copy branch January 4, 2024 01:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants