Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

BUG: Fix calling ufuncs with a positional output argument.#10479

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
mhvk merged 1 commit intonumpy:masterfromeric-wieser:masked-array-out-fix
Jan 26, 2018

Conversation

@eric-wieser
Copy link
Member

@eric-wiesereric-wieser commentedJan 26, 2018
edited by charris
Loading

Currently, this causes the result to inherit the output's mask.

This bringsnp.add(a, b, out) in line withnp.add(a, b, out=out).
These previously differed becausegh-10459 causes them to callarray_wrap in different ways (with and without the output argument in the context tuple, respectively).

Since the data in theout argument is never used by ufuncs, it seems consistent that the mask should not be either.

…lt to inherit the output's maskThis brings `np.add(a, b, out)` in line with  `np.add(a, b, out=out)`.These previously differed becausenumpygh-10459 causes them to call __array_wrap__ in different ways (with and without the output argument in the context tuple, respectively).Since the data in the `out` argument is never used by ufuncs, it seems consistent that the mask should not be either.
Copy link
Contributor

@mhvkmhvk left a comment

Choose a reason for hiding this comment

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

The changes are OK, though see my comment. I'd argue to remove the stanza that never can get called, since I don't see how it can be correct. But also fine to do it in follow-up, since I guess it is more MAINT than BUG

ifdomainisnotNone:
# Take the domain, and make sure it's a ndarray
iflen(args)>2:
iflen(input_args)>2:
Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly related, but this is very strange -- there are no ufuncs with more than two input arguments, so this path will never get taken... And before this would only be taken if there was an output argument, for which the domain would then be checked. Which makes no sense at all!

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

there are no ufuncs with more than two input arguments, so this path will never get taken

There's nothing to stop a third party (or scipy?) adding one like this, so it's nice to try to support it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then they also have to update the domain dict -- not impossible, I guess, but why are they then forced to calculate the domain by reduction rather than just by getting all the arguments? This is definitely not what I would expect... for most operations, the masking depends very differently on each argument (think division...).

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

You're right, this doesn't make sense as is - expanding the tuple arguments is the right thing to do every time. I can fix this much later today, either in this PR or a separate one.

Doing it in a separate one means that I can also rebase the__array_prepare__ PR on top of this tonight.

@mhvk
Copy link
Contributor

The circleci error seems unrelated -- the whole installation failed.

@mhvkmhvk added this to the1.15.0 release milestoneJan 26, 2018
@mhvkmhvk added the 09 - Backport-CandidatePRs tagged should be backported labelJan 26, 2018
@mhvk
Copy link
Contributor

OK, let's do the fix tolen(input_args) > 2 in a separate PR; I think that makes perhaps more sense asMAINT instead ofBUG anyway.

So, I'll merge this one now.

@mhvkmhvk merged commit390d797 intonumpy:masterJan 26, 2018
@charrischarris modified the milestones:1.15.0 release,1.14.1 releaseFeb 9, 2018
@charrischarris changed the titleBUG: Calling ufuncs with a positional output argument causes the result to inherit the output's maskBUG: Fix calling ufuncs with a positional output argument. causes the result to inherit the output's maskFeb 9, 2018
@charrischarris changed the titleBUG: Fix calling ufuncs with a positional output argument. causes the result to inherit the output's maskBUG: Fix calling ufuncs with a positional output argument.Feb 9, 2018
@charrischarris removed the 09 - Backport-CandidatePRs tagged should be backported labelFeb 9, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@mhvkmhvkmhvk approved these changes

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@eric-wieser@mhvk@charris

[8]ページ先頭

©2009-2025 Movatter.jp