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

add_index on multi-dimensional masked column failing with index error #13292

Open
jdtsmith opened this issue Jun 1, 2022 · 0 comments · May be fixed by #16360
Open

add_index on multi-dimensional masked column failing with index error #13292

jdtsmith opened this issue Jun 1, 2022 · 0 comments · May be fixed by #16360

Comments

@jdtsmith
Copy link

jdtsmith commented Jun 1, 2022

Description

Masked columns with multi-dimensional arrays do not work correctly:

In [127]: t=Table(); t.add_column(np.ma.masked_inside(np.arange(0,6),2,4).reshape((3,-1) ), name='arr')

In [128]: t
Out[128]: 
<Table length=3>
  arr   
int64[2]
--------
  0 .. 1
-- .. --
 -- .. 5

In [129]: t.add_index('arr')
/Users/jdsmith/code/python/astropy/astropy/table/index.py:92: MaskedArrayFutureWarning: In the future the default for argsort will be axis=-1, not the current None, to match its documentation and np.argsort. Explicitly pass -1 or None to silence this warning.
  row_index = Column(col.argsort())
Traceback (most recent call last):
  Input In [129] in <cell line: 1>
    t.add_index('arr')
  File ~/code/python/astropy/astropy/table/table.py:1016 in add_index
    index = Index(columns, engine=engine, unique=unique)
  File ~/code/python/astropy/astropy/table/index.py:93 in __init__
    data = Table([col[row_index]])
  File astropy/table/_column_mixins.pyx:87 in astropy.table._column_mixins._MaskedColumnGetitemShim.__getitem__
  File astropy/table/_column_mixins.pyx:57 in astropy.table._column_mixins.base_getitem
  File astropy/table/_column_mixins.pyx:81 in astropy.table._column_mixins.masked_column_getitem
  File /usr/local/lib/python3.10/site-packages/numpy/ma/core.py:3222 in __getitem__
    dout = self.data[indx]
  File /usr/local/lib/python3.10/site-packages/numpy/ma/core.py:3222 in __getitem__
    dout = self.data[indx]
IndexError: index 5 is out of bounds for axis 0 with size 3

System Details

macOS-12.3.1-x86_64-i386-64bit
Python 3.10.4 (main, Apr 26 2022, 19:42:59) [Clang 13.1.6 (clang-1316.0.21.2)]
Numpy 1.22.3
pyerfa 2.0.0.1
astropy 5.2.dev92+gf0e2129aa
Scipy 1.7.3
Matplotlib 3.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants