astropy / astropy/astropy

Issue with repr() for differential components on frames after set_representation_cls

Open
#7,001 2 comments 0 reactions 0 assignees View on GitHub
Bug coordinates needs-reconfirmation
Dominant language
Python
Stars
5.3k
Forks
2.2k
Avg merge
1d 19h
Merged PRs (30d)
75

Description

Found a bug in `BaseCoordinateFrame._data_repr()`. I haven't tracked down exactly what the issue is, but here's how to reproduce:

```python
>>> import astropy.coordinates as coord
>>> import astropy.units as u
>>> c = coord.ICRS(ra=150*u.deg, dec=-11*u.deg,
... pm_ra_cosdec=100*u.mas/u.yr,
... pm_dec=199*u.mas/u.yr)
>>> c

>>> c.set_representation_cls(s=coord.CartesianDifferential)
>>> c

```

After setting the differential class, the repr for the differential components reverts to the `UnitSphericalCosLatDifferential` component names. This has something to do with the
```python
if isinstance(dif_data, (r.UnitSphericalDifferential,
r.UnitSphericalCosLatDifferential,
r.RadialDifferential)):
```
in `_data_repr`.

cc @mhvk

Contributor guide

Open the contributing guide

Research direction

Start at BaseCoordinateFrame._data_repr and run the reproduction using ICRS, set_representation_cls, and CartesianDifferential. Trace the differential-type handling around the isinstance check; done means the repr preserves the selected differential component names instead of reverting to UnitSphericalCosLatDifferential names.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.