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

Quantity __array_function__ support for histograms, arraysetops functions and apply_{along, over}_axis #8900

Merged
merged 5 commits into from Jun 29, 2019

Conversation

mhvk
Copy link
Contributor

@mhvk mhvk commented Jun 21, 2019

fixes the regression noted by @StanczakDominik in #8825 (comment)

It is not completely clear how useful set operators are for multi-argument functions where units are converted, but I decided to include them anyway. User beware and all that.

Note that this includes #8884 and #8894 since otherwise I get failures. Just look at the last third-but-last commit only.

EDIT: I now also included coverage for the unrelated np.apply_along_axis (which worked anyway) and np.apply_over_axes - I did not want to make yet another PR on top of this stack of three...
EDIT: now includes updates also for histograms, so all the additions are together.

@mhvk mhvk added units Affects-dev PRs and issues that do not impact an existing Astropy release Enhancement numpy-dev labels Jun 21, 2019
@pllim

This comment has been minimized.

@mhvk mhvk added this to the v4.0 milestone Jun 21, 2019
@mhvk mhvk force-pushed the quantity-array-function-setops branch from fe7c5ae to 14aad50 Compare June 21, 2019 15:27
@mhvk
Copy link
Contributor Author

mhvk commented Jun 21, 2019

Oops.. fixed.

@mhvk mhvk force-pushed the quantity-array-function-setops branch from 14aad50 to 7e524b4 Compare June 21, 2019 17:00
@mhvk mhvk changed the title Quantity __array_function__ support for arraysetops functions Quantity __array_function__ support for arraysetops functions and apply_along_axis, apply_over_axes Jun 21, 2019
@mhvk
Copy link
Contributor Author

mhvk commented Jun 21, 2019

No idea what's up with the coverage - I checked locally and it looks OK.

@pllim
Copy link
Member

pllim commented Jun 22, 2019

@mhvk , did you rebase on the latest master?

@mhvk
Copy link
Contributor Author

mhvk commented Jun 22, 2019

No, I did not since this is a sequence of PRs; if I rebase one, I'll probably have to rebase all of them, even though they do not have merge conflicts.

@mhvk mhvk force-pushed the quantity-array-function-setops branch from 2eb5412 to 6432a5b Compare June 29, 2019 14:19
@mhvk mhvk changed the title Quantity __array_function__ support for arraysetops functions and apply_along_axis, apply_over_axes Quantity __array_function__ support for histograms, arraysetops functions and apply_{along, over}_axis Jun 29, 2019
@mhvk
Copy link
Contributor Author

mhvk commented Jun 29, 2019

Now included all further updates to __array_function__ in this PR: support for histograms, setops functions such as np.unique, and apply_{along|over}_axes. This essentially completes coverage of functions in the top-level numpy namespace.
@adrn, @astrofrog - if you have a chance...

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

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

Looks good to me!

I have a slight concern that given the amount of code we are copying from Numpy, it's not clear how we'll be able to easily keep track of fixes to bugs in the copied Numpy code, but I'm assuming that we can just cross that bridge if our users run into those bugs. Anyway, nothing to act on now, but just want to raise the point that we'll have to make sure this is reasonably easily maintainable in future.

assert_array_equal(outdd_h, expecteddd_h)
for o, e in zip(outdd_b, expecteddd_b):
assert_array_equal(o, e)
# Bit tired, so just copying the tests from histogram2d above.
Copy link
Member

Choose a reason for hiding this comment

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

Is this something you want to address before merging?

@mhvk
Copy link
Contributor Author

mhvk commented Jun 29, 2019

@astrofrog - thanks for the review. I agree about the implementation, and sort-of tried to have more in-depth testing for functions where we, effectively, forked. I don't really know what to do beyond that - in particular, added functionality over at numpy (new keyword arguments, new meanings) will need to be propagated. One possibility at least for new arguments could be to ensure not to use *args, **kwargs at all, but rather spell out the signature. With that, one could write an inspection tool that checks whether signatures still match. .. .. actually, that seems worth an issue, #8791

I'll look at factoring out the histogram tests. In the meantime, any idea about the circle-ci failures?

@bsipocz
Copy link
Member

bsipocz commented Jun 29, 2019

I'll look at factoring out the histogram tests. In the meantime, any idea about the circle-ci failures?

with a quick glance they look to be the same as in master, and I share @pllim's suspicion in #8934 that they are likely pytest5 related failure.

I'll try to find time to look into that during the weekend, unless someone else will be quicker :)

@mhvk
Copy link
Contributor Author

mhvk commented Jun 29, 2019

OK, if master has the same errors, I think it is safe to merge this one, so I'll go ahead and do that. Thanks, all.

@mhvk mhvk merged commit a0e7363 into astropy:master Jun 29, 2019
@mhvk mhvk deleted the quantity-array-function-setops branch June 29, 2019 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Affects-dev PRs and issues that do not impact an existing Astropy release Enhancement numpy-dev units
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants