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

Support numpy size() and array.size #1777

Merged
merged 4 commits into from
May 11, 2023
Merged

Conversation

Shaikh-Ubaid
Copy link
Collaborator

fixes #1773

@Shaikh-Ubaid Shaikh-Ubaid changed the title Support numpy array.size Support numpy size and array.size May 11, 2023
@Shaikh-Ubaid Shaikh-Ubaid marked this pull request as ready for review May 11, 2023 00:58
@Shaikh-Ubaid Shaikh-Ubaid requested a review from certik May 11, 2023 00:58
@Shaikh-Ubaid Shaikh-Ubaid changed the title Support numpy size and array.size Support numpy size() and array.size May 11, 2023
@Shaikh-Ubaid
Copy link
Collaborator Author

This is ready.

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

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

Thank you! This PR is good to merge.

Since we are doing it, in a new PR can you also please add a test like:

from numpy import size
a = empty((2, 3))
assert size(a) == 2*3
assert size(a, 0) == 2
assert size(a, 1) == 3

It will probably already work, but just in case. I usually use the size function like this, just like in Fortran.

@certik certik merged commit ff38f75 into lcompilers:main May 11, 2023
@Shaikh-Ubaid Shaikh-Ubaid deleted the numpy_size branch May 11, 2023 14:36
@Shaikh-Ubaid
Copy link
Collaborator Author

Since we are doing it, in a new PR can you also please add a test like:

Sure, thank you for the guidance. It seems the backends expect dimension value to start from 1, where as the axis attribute of numpy size() starts from 0. I fixed it by adding a constant 1 to the user provided dimension and added the test case in #1780.

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.

Implement numpy.size()
2 participants