-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Support mixin columns for group aggregation operations #12825
Conversation
cc871f8
to
41999e6
Compare
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.
Wow, what a nice demonstration of how well .info
can be used! I've only minimal comments, really more questions, so will approve now (failures seem due to new pytest version).
docs/table/operations.rst
Outdated
@@ -278,7 +278,7 @@ For the example grouped table ``obs_by_name`` from above, we compute the group | |||
means with the :meth:`~astropy.table.groups.TableGroups.aggregate` method:: | |||
|
|||
>>> obs_mean = obs_by_name.groups.aggregate(np.mean) # doctest: +SHOW_WARNINGS | |||
AstropyUserWarning: Cannot aggregate column 'obs_date' with type '<U10' | |||
WARNING: Cannot aggregate column 'obs_date' with type '<U10': cannot perform reduceat with flexible type [astropy.table.groups] |
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.
Maybe better for this to remain an AstropyUserWarning
? Though I'm actually not sure why this changed! Anyway, definitely not a big deal.
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.
Weird, I didn't notice that change. Looks like RTD was OK on this. It failed but for an unrelated reason. Hmm.
@taldcroft - looks all good. I guess we'll see after the pytest fixes plus rebase whether the change in warning remains... But definitely all OK. p.s. The info setting is indeed strange; turning, say, a |
41999e6
to
93c9e45
Compare
@taldcroft it looks like |
@nstarman - done, hopefully that will do the trick. |
The test suite doesn't appear to be running. Rebase? |
Actions going through maintenance. Try again in a few hours, maybe. |
@pllim - actions still look stuck. What's the easiest way to restart? |
Lemme close/re-open |
OK running now |
Dang, I figured out what is happening with the numpy=1.19 test failure. It looks like there was a bug in numpy that got fixed in numpy 1.20. In numpy 1.18 and 1.19:
In numpy 1.20:
It isn't immediately clear what's the best path forward given this problem for numpy < 1.20. Maybe only allow Quantity mixins for aggregation in that case? |
Restating the problem to make sure I understand. The proposed solution is to check the numpy version and allow only aggregation of Quantity mixins for numpy < 1.20? |
Correct.
Correct, with the caveat that "works" means that it correctly fails in some case (where it will generate a warning and drop the column from the aggregation output).
Correct. I haven't evaluated the code required for this special-casing but I'm guessing it is not too bad. Based on NEP 29 it looks like astropy 5.2 could support only numpy 1.20+ and we can back out the special-case code. |
a0352c6
to
cca0400
Compare
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.
This is looking really good! CI failure appears real from a reduction on a flexible type.
I think the failure is just a sphinx doctests question (@plim?). The specific error message from numpy changes depending on version:
Can I do a
|
Yes, you can use the ellipsis directive. |
cca0400
to
b18f4c9
Compare
@taldcroft - Could you rebase to see if it fixes the dev job ? (Failure is probably unrelated ?) |
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.
Looks good to me! Hopefully the CI errors can be resolved by a rebase.
The failures are unrelated, so merging. Thanks! |
Description
This pull request adds support for using mixin columns in group aggregation operations when the mixin supports the specified operation (e.g.
np.sum
works forQuantity
but notTime
). In cases where the operation is not supported the code now issues a warning and drops the column instead of raising an exception.Notes:
groups
attribute was added to theinfo
property. ForColumn
this is taken from the parent, while for mixins this is a distinct new attribute.Quantity
column in most grouping tests.Fixes #12249
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CI
label.no-changelog-entry-needed
label. If this is a manual backport, use theskip-changelog-checks
label unless special changelog handling is necessary.astropy-bot
check might be missing; do not let the green checkmark fool you.backport-X.Y.x
label(s) before merge.