Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG: dot/matmul 'out' arg should accept any ndarray subclass #9672

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

Merged
merged 1 commit into from
Sep 28, 2017

Conversation

ahaldane
Copy link
Member

@ahaldane ahaldane commented Sep 9, 2017

Fixes #9641

@eric-wieser
Copy link
Member

Error messages need fixing too

@ahaldane ahaldane force-pushed the fix_cblas_ndarray_check branch from fa21c6e to 786a8c0 Compare September 10, 2017 14:53
@ahaldane
Copy link
Member Author

Error messages updated

@eric-wieser
Copy link
Member

eric-wieser commented Sep 10, 2017

The /* Choose which subtype to return */ stuff, and declaration of prior1 and prior2, can move within the out == NULL branch now too

@eric-wieser
Copy link
Member

Do you want to wait on #9209 before finishing this off?

@ahaldane
Copy link
Member Author

yeah let's wait

@ahaldane ahaldane force-pushed the fix_cblas_ndarray_check branch from 786a8c0 to 0e4faaa Compare September 22, 2017 03:46
@ahaldane
Copy link
Member Author

Rebased, and updated to use the recently defined PyArray_GetSubType.

I moved PyArray_GetSubType to ctors.c and added a declaration in ctors.h so it is visible across numpy C files.

(One slight difference in the new code is that I no longer use one of the input arrays as the "template" argument used in __array_finalize__ (last arg of PyArray_New/FromDescr). I think it is more correct now).

@eric-wieser
Copy link
Member

eric-wieser commented Sep 22, 2017

A little worried that not using one of the arrays as a template argument is a compatibility break, even if it wasn't necessarily good design before. Otherwise looks good.

Does this affect masked arrays in anyway, as the only built in subclass?

@eric-wieser
Copy link
Member

Yeah, I suspect this stops working:

>>> a = np.ma.array(np.eye(3))
>>> a._optinfo['x'] = 1
>>> np.dot(a, a)._optinfo
{'x': 1}

Which it seems people care about (#9279)

@ahaldane ahaldane force-pushed the fix_cblas_ndarray_check branch from 0e4faaa to d4387da Compare September 22, 2017 14:16
@ahaldane
Copy link
Member Author

Yeah, you're right. I removed the last commit. (We also lose all the other info like the fillvalue).

The PR summary is now:

  • Removed check for subtype of out argument
  • moved (cut-n-paste) the subtype calculation into an else statement

@eric-wieser eric-wieser merged commit eb5dd41 into numpy:master Sep 28, 2017
@eric-wieser
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants