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

Skip to content

MAINT: avoid setting non-existing gufunc strides for keepdims=True. #11176

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
May 30, 2018

Conversation

mhvk
Copy link
Contributor

@mhvk mhvk commented May 28, 2018

Corrects an overzealous change in #11098 from the fixed core dimensions to the ones expanded for keepdims=True. Since arrays were allocated, this wrong change caused no problems, but it was not needed and confused the heck out of myself...

@charris: since this is a correction to stuff slated for 1.15, I set the milestone as such.

cc @mattip

Corrects an overzealous change from the fixed core dimensions
to the ones expanded for keepdims=True.
@mattip
Copy link
Member

mattip commented May 29, 2018

Would be nice if there were a test proving this is necessary.

@eric-wieser
Copy link
Member

I don't think core_num_dims is a suitable variable name any more, if it's not a universal replacement for ufunc->core_num_dims

@mhvk
Copy link
Contributor Author

mhvk commented May 29, 2018

@mattip - I cannot test this, as it doesn't cause any problems - just a bit of extra memory allocated that may get an irrelevant value in it. But it was good to find it, as it showed that your n_dims_used variable, which was a copy of the core_num_dims that I had introduced for keepdims, was not necessary.

@eric-wieser - the name is a bit beyond the scope of this PR, but how I see it is that the names not attached to the ufunc are explicitly meant for changes that are useful within the routine. In the frozen-dimension addition, ufunc->core_dim_sizes is used similarly as initial values, and core_dim_sizes for the actual ones. In fact, I've been thinking that it might be useful for the implementation if upon entry a light copy of the ufunc gets made in which such changes can be kept together. This could then be used also to address the linalg problems: one could have a signature that means an external routine gets called that can adjust the indices, etc., in-place.

Anyway, probably the wrong place to put this idea, since not relevant to this PR - which really is just a correction for a mistake I made in #11098.

@mattip
Copy link
Member

mattip commented May 30, 2018

Still a bit stymied on this one, I admit. Even though I dived deeply into the code I only have an intuitive feel for when we use ufunc->core_num_dims and when just core_num_dims. Perhaps a name change would make it clear, or an explanatory comment next to the changes in this PR.

@mhvk
Copy link
Contributor Author

mhvk commented May 30, 2018

The underlying logic is that if one wants to access information in the ufunc (basically, core_dim_ixs), the it always should be ufunc->core_num_dims.

Agreed that a name change may be useful, but perhaps as part of #11175 - this PR is really just meant as a correction for #11098 (and I'd like to have it in to avoid yet more rebases...).

Copy link
Member

@mattip mattip left a comment

Choose a reason for hiding this comment

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

Fixes a problem with PR #11098

@mattip mattip merged commit 9e2dd68 into numpy:master May 30, 2018
@mattip
Copy link
Member

mattip commented May 30, 2018

Thanks Marten

@mhvk mhvk deleted the gufunc-keepdims-iter-alloc branch May 30, 2018 19:05
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