`DataClass.__setitem__` doesn't check column names
jianyangli opened this issue · 3 comments
High-level problem description
Looks like the current implementation of DataClass.__setitem__
simply refers to self.table.__setitem__
without checking the column names. This would potentially cause alternative volume names as defined in Conf.fieldnames_info
to be confused with each other.
What did you do?
import astropy.units as u
from sbpy.data import DataClass
d = DataClass.from_dict({'rh': [1, 2, 3] * u.au, 'delta': [1, 2, 3] * u.au})
assert d.field_names == ['rh', 'delta']
print(d['r']) # print out <Quantity [1., 2., 3.] AU>
d['r'] = [4, 5, 6] * u.au
print(d['r']) # print out <Quantity [4., 5., 6.] AU>
print(d['rh']) # print out <Quantity [1., 2., 3.] AU>
I suspect this should be fixed, so that the column names will be translated first before being passed to self.table.__setitem__
.
Provide information on your environment:
operating system and version: [Linux (which distribution?), MacOS, Win]
sbpy version: 0.3.1
astropy version:
numpy version:
Again, @mkelley , I didn't follow the development of DataClass
from the beginning, so I'm not sure if this should be fixed or it is an allowed behavior. Please advise. If a bug, I can work to fix it. Thanks.
Good find, that is a problem!
OK, it should be an easy fix, and I'll do it.