-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Adding test for TimeSeries join #9287
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
Conversation
astropy/table/operations.py
Outdated
| left_mask = ~right_mask | ||
| if np.any(left_mask): | ||
| out[out_name][left_mask] = left[left_name].take(left_out) | ||
| left_mixin_mask = ~right_mask |
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 in fact a bug fix, so I'm happy to resubmit it as a separate PR to be backported.
(I couldn't really come up with a nice failing examples as I was running into errors (or was using Time columns as key what is a new thing)
ValueError: NumPy boolean array indexing assignment cannot assign 6 input values to the 4 output values where the mask is true
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.
It probably makes sense to split this out so it can be backported, and it would be worthwhile adding a regression test. Here's a minimal test that triggers the error:
from astropy import units as u
from astropy.table import QTable, join
tab1 = QTable()
tab1['index'] = [1, 2, 3, 4, 5]
tab1['flux1'] = [2, 3, 2, 1, 1] * u.Jy
tab1['flux2'] = [2, 3, 2, 1, 1] * u.Jy
tab2 = QTable()
tab2['index'] = [3, 4, 5, 6]
tab2['flux1'] = [2, 1, 1, 3] * u.Jy
tab2['flux2'] = [2, 1, 1, 3] * u.Jy
join(tab1, tab2, keys=('index', 'flux1', 'flux2'), join_type='outer')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.
Hmm, this example still doesn't work. But, then it seems that np.where now seems to work nicely with Quantities, so no need to go into this branch of the code.
55cde32 to
7ea52df
Compare
|
Let me know if you prefer the changelog to be in the timeseries section |
astrofrog
left a comment
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 looks good, but I think it'd indeed be good to split out the bug fix and add a regression test.
astropy/table/operations.py
Outdated
| left_mask = ~right_mask | ||
| if np.any(left_mask): | ||
| out[out_name][left_mask] = left[left_name].take(left_out) | ||
| left_mixin_mask = ~right_mask |
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.
It probably makes sense to split this out so it can be backported, and it would be worthwhile adding a regression test. Here's a minimal test that triggers the error:
from astropy import units as u
from astropy.table import QTable, join
tab1 = QTable()
tab1['index'] = [1, 2, 3, 4, 5]
tab1['flux1'] = [2, 3, 2, 1, 1] * u.Jy
tab1['flux2'] = [2, 3, 2, 1, 1] * u.Jy
tab2 = QTable()
tab2['index'] = [3, 4, 5, 6]
tab2['flux1'] = [2, 1, 1, 3] * u.Jy
tab2['flux2'] = [2, 1, 1, 3] * u.Jy
join(tab1, tab2, keys=('index', 'flux1', 'flux2'), join_type='outer')|
Wohooho, actually I think that branch of the code is not needed any more as all mixins seems to work (except SkyCoords, but those are failing much sooner than that part). Currently everything is pushed to this branch to see how much CI likes it. I have a suspicion that this may very much build upon the recent changes in masking, so might not work in the bugfix branch anyway. |
|
Hmm, interesting. Backporting this (well, the table.opeartions parts) to 3.2.x gives me a UnitConversionError, the same we see on 32bit. |
|
OK, so the straight backport would need #8808, as well as the currently failing builds that use numpy 1.16. It's a pity. |
52c8f3b to
9e44b3c
Compare
9e44b3c to
f0c0aa6
Compare
|
rebased now and ready for final review. |
|
@bsipocz - this does appear to work, but there is a hidden issue in that they key array that gets created for sorting is an object array of individual So if you have a time series with a million entries then memory might blow up. |
|
I think that the trick used in Line 1454 in 0812f6b
It just requires a little juggling to replace the 1-column time key with a 2-column version with |
|
After #9340 this works out of the box. Do we still want to add test for the TimeSeries? |
| out[out_name] = col_cls.info.new_like(cols, n_out, metadata_conflicts, out_name) | ||
|
|
||
| if issubclass(col_cls, Column): | ||
| if not NUMPY_LT_1_17 or issubclass(col_cls, (Column, Time)): |
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.
Is the NUMPY_L_1_17 stuff still useful?
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.
yes, I'll definitely keep that in here. I'm not sure about the usefulness of the tests though?
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.
Well I don't know enough about the time series code to know. But maybe it's a good idea as a regression to ensure future changes in Table or TimeSeries don't break things.
f0c0aa6 to
5b09597
Compare
|
OK. This one is now gutted out, the test is what remained, and the change that |
taldcroft
left a comment
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.
LGTM
To address #8586
I think #7728 might be also fixed, but I can still generate cases that raise a an error in case of QTables, so would not claim that issue just yet.