-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Labels
potential bugautomated label to indicate issue reportsautomated label to indicate issue reports
Description
High-level problem description
When iterating over the rows of an Ephem table, a QTable length=1 object is returned, Accessing a particular field/column of the row then results in a single element array, not a scalar
What did you do?
qt = QTable()
qt["Obstime"] = Time("2000-01-01 00:00")
qt["RA"] = 0 * u.hourangle
qt["DEC"] = 0 * u.degree
qt.add_row([ Time("2026-01-01"), 10*u.hourangle, 12.34*u.deg ])
qt.add_row([ Time("2026-01-02"), 12*u.hourangle, -56.78*u.deg ])
ic(qt)
ic(qt["RA"][0])
for row in qt:
ic(row)
ic(row["RA"])
eph = Ephem.from_table(qt)
ic(eph)
ic(eph["RA"][0])
for row in eph:
ic(row)
ic(row["RA"])
What did you expect?
Output of the underlying table (qt or eph._table):
ic| qt: <QTable length=2>
Obstime RA DEC
hourangle deg
Time float64 float64
----------------------- --------- -------
2026-01-01 00:00:00.000 10.0 12.34
2026-01-02 00:00:00.000 12.0 -56.78
ic| qt["RA"][0]: <Quantity 10. hourangle>
ic| row: <Row index=0>
Obstime RA DEC
hourangle deg
Time float64 float64
----------------------- --------- -------
2026-01-01 00:00:00.000 10.0 12.34
ic| row["RA"]: <Quantity 10. hourangle>
ic| row: <Row index=1>
Obstime RA DEC
hourangle deg
Time float64 float64
----------------------- --------- -------
2026-01-02 00:00:00.000 12.0 -56.78
ic| row["RA"]: <Quantity 12. hourangle>
What did really happen?
Output for Ephem:
ic| eph: <QTable length=2>
Obstime RA DEC
hourangle deg
Time float64 float64
----------------------- --------- -------
2026-01-01 00:00:00.000 10.0 12.34
2026-01-02 00:00:00.000 12.0 -56.78
ic| eph["RA"][0]: <Quantity 10. hourangle>
ic| row: <QTable length=1>
Obstime RA DEC
hourangle deg
Time float64 float64
----------------------- --------- -------
2026-01-01 00:00:00.000 10.0 12.34
ic| row["RA"]: <Quantity [10.] hourangle>
ic| row: <QTable length=1>
Obstime RA DEC
hourangle deg
Time float64 float64
----------------------- --------- -------
2026-01-02 00:00:00.000 12.0 -56.78
ic| row["RA"]: <Quantity [12.] hourangle>
When directly accessing a column/row like ["RA"][0] a scalar is returned as expected.
Provide information on your environment:
Windows 10, Python 3.12.3
sbpy version: 0.5.0
astropy version: 7.1.1
numpy version: 2.3.4
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
potential bugautomated label to indicate issue reportsautomated label to indicate issue reports