You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TST: Table data type comparison fails with numpy-dev #11291
I don't understand... When I run the test line-by-line in an interactive Python session, I cannot reproduce the error, but it errors out if I run the test file with pytest. 🤯
Very weird. I tried setting up a new venv with numpy-dev and then pip install -e .[test] - I don't get any test failures...
I do reproduce it with test-devdeps, and that one goes away if instead I install numpy's master, so I suspect this will just disappear when numpy's nightly is up to date...
I got to the point where if I copy out that test function and run it outside of astropy repo, everything passes with the same numpy from night wheel! But it starts to fail if I put it inside astropy repo. I was starting to suspect that one of the test fixtures in our many conftest.py is messing with the test.
Unfortunately, my machine couldn't build numpy from source, so I guess I'll wait and see... Thanks for checking!
from astropy.table import Table, MaskedColumn
astropy/table/__init__.py:4: in <module>
from .column import Column, MaskedColumn, StringTruncateWarning, ColumnInfo
astropy/table/column.py:22: in <module>
from ._column_mixins import _ColumnGetitemShim, _MaskedColumnGetitemShim
astropy/table/_column_mixins.pyx:46: in init astropy.table._column_mixins
ctypedef class numpy.ndarray [object PyArrayObject]:
E RuntimeWarning: numpy.ndarray size changed, may indicate binary incompatibility. Expected 80 from C header, got 88 from PyObject
Perhaps as a result of this warning, the dtype is O instead of S or U, as expected. But I still don't understand why the test pass if I move the test code outside of astropy repo.
I haven't dug into the implications or fix, but I think this is our root cause here. When running in pytest then this warning turns into an exception and causes numpy to output an object type. I think this accounts for the different behavior seen running within pytest vs. doing diagnostics within python. Older versions of numpy don't give this warning.
(test-devdeps) (astropy) ➜ astropy git:(master) python -Walways
Python 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.ma.array(['val', np.ma.masked])
/Users/aldcroft/git/astropy/.tox/test-devdeps/lib/python3.7/site-packages/numpy/ma/core.py:2826: FutureWarning: Promotion of numbers and bools to strings is deprecated. In the future, code such as `np.concatenate((['string'], [0]))` will raise an error, while `np.asarray(['string', 0])` will return an array with `dtype=object`. To avoid the warning while retaining a string result use `dtype='U'` (or 'S'). To get an array of Python objects use `dtype=object`. (Warning added in NumPy 1.21)
order=order, subok=True, ndmin=ndmin)
masked_array(data=['val', --],
mask=[False, True],
fill_value='N/A',
dtype='<U32')
>>>
(test-devdeps) (astropy) ➜ astropy git:(master) python -Werror
Python 3.7.9 (default, Aug 31 2020, 07:22:35)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy as np
>>> np.ma.array(['val', np.ma.masked])
masked_array(data=['val', --],
mask=[False, True],
fill_value='?',
dtype=object)
See numpy/numpy#18425. I'm marking this as upstream fix needed. If they can't fix it then we will need to do some deeper changes to Table code. I'd suggest closing #11318.
Activity
mhvk commentedon Feb 1, 2021
Seems like a change in behaviour that we need to account for... (or possibly warn numpy about).
pllim commentedon Feb 1, 2021
I don't understand... When I run the test line-by-line in an interactive Python session, I cannot reproduce the error, but it errors out if I run the test file with
pytest. 🤯mhvk commentedon Feb 1, 2021
Very weird. I tried setting up a new venv with
numpy-devand thenpip install -e .[test]- I don't get any test failures...I do reproduce it with
test-devdeps, and that one goes away if instead I install numpy's master, so I suspect this will just disappear when numpy's nightly is up to date...pllim commentedon Feb 1, 2021
I got to the point where if I copy out that test function and run it outside of
astropyrepo, everything passes with the same numpy from night wheel! But it starts to fail if I put it insideastropyrepo. I was starting to suspect that one of the test fixtures in our manyconftest.pyis messing with the test.Unfortunately, my machine couldn't build numpy from source, so I guess I'll wait and see... Thanks for checking!
mhvk commentedon Feb 1, 2021
Very weird indeed! Hopefully it will auto-fix in a week or so...
pllim commentedon Feb 10, 2021
Failure is still there...
pllim commentedon Feb 10, 2021
I think it has something to do with this warning that we are ignoring.
astropy/setup.cfg
Line 122 in 74d445c
When I un-ignore the warning, I get this:
Perhaps as a result of this warning, the
dtypeisOinstead ofSorU, as expected. But I still don't understand why the test pass if I move the test code outside ofastropyrepo.taldcroft commentedon Feb 12, 2021
From what I understand, that warning should be benign. But honestly I have no insight beyond a quick scan of that SO thread.
pllim commentedon Feb 15, 2021
It should have been benign, that's why we are ignoring it.
astropy/setup.cfg
Line 122 in 1641661
But then now we see this failure. I am stumped.
taldcroft commentedon Feb 16, 2021
I haven't dug into the implications or fix, but I think this is our root cause here. When running in pytest then this warning turns into an exception and causes numpy to output an
objecttype. I think this accounts for the different behavior seen running withinpytestvs. doing diagnostics withinpython. Older versions of numpy don't give this warning.taldcroft commentedon Feb 16, 2021
See numpy/numpy#18425. I'm marking this as upstream fix needed. If they can't fix it then we will need to do some deeper changes to Table code. I'd suggest closing #11318.
mhvk commentedon Feb 16, 2021
Nice sleuthing! Most definitely an unintended consequence of what in itself was a good fix on the numpy side.