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

Failure of unicode sandwich for multi-dimensional columns #9614

Open
mhvk opened this issue Nov 17, 2019 · 2 comments
Open

Failure of unicode sandwich for multi-dimensional columns #9614

mhvk opened this issue Nov 17, 2019 · 2 comments

Comments

@mhvk
Copy link
Contributor

mhvk commented Nov 17, 2019

We allow comparisons of unicode with byte-valued columns using a unicode sandwich, but this fails in the corner-case where the column is multidimensional and we take a single element from it:

from astropy.table import Column
c = Column([[b'a', b'b'], [b'c', b'd']], name='c')
print(c == ['a', 'b'])
# [[ True  True]
#  [False False]]
print(c[0] == ['a', 'b'])
# False  # expected [True, True]

EDIT (2024-01-11): now gives [False, False] so still an issue.

The reason is that for multi-D columns, access of any given Column row just returns a plain ndarray, which does not know about the unicode sandwich: https://github.com/astropy/astropy/blob/master/astropy/table/_column_mixins.pyx#L54-L55

A fix might be to convert the result to unicode or to use an ndarray subclass that still contains the unicode sandwich (but is otherwise a plain ndarray).

cc @taldcroft

p.s. Found while trying a new Masked class for creating a new MaskedColumn.

@taldcroft
Copy link
Member

I suspect this is a bit of a rabbit hole... with new numpy dtypes is there hope for a single-byte character type anywhere on the horizon before I'm retired?

@mhvk
Copy link
Contributor Author

mhvk commented Apr 3, 2020

Yes, hope, but before you're retired... that may depend on how long you plan to continue working....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants