-
Notifications
You must be signed in to change notification settings - Fork 30
Implementation of squeeze function #790
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
Conversation
) | ||
else: | ||
new_shape = [axis for axis in X_shape if axis != 1] | ||
if new_shape == X.shape: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since new_shape
is of type list
, and X.shape
is of type tuple
the comparison is always going to return False
:
In [1]: x = (1,2,3)
In [2]: y = list(x)
In [3]: y == x
Out[3]: False
View rendered docs @ https://intelpython.github.io/dpctl/pulls/790/index.html |
"which has size not equal to one." | ||
) | ||
else: | ||
new_shape = [axis for axis in X_shape if axis != 1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new_shape = [axis for axis in X_shape if axis != 1] | |
new_shape = tuple(axis for axis in X_shape if axis != 1) |
raise ValueError( | ||
"Cannot select an axis to squeeze out " | ||
"which has size not equal to one." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At the conclusion of iteration, add the line new_shape = tuple(new_shape)
.
if new_shape == X.shape: | ||
return X | ||
else: | ||
return dpt.reshape(X, tuple(new_shape)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming the earlier changes to ensure new_shape
has type of tuple
, the tuple(new_shape)
becomes redundant, and can be replaced with value new_shape
to avoid extra copy.
0183179
to
31a960b
Compare
Deleted rendered PR docs from intelpython.github.com/dpctl, latest should be updated shortly. 🤞 |
This PR adds
squeeze
functions according to Python array API standard for usm_ndarray.