Skip to content

Commit ab82474

Browse files
PritishCtaldcroft
authored andcommitted
Added first few tests.
Testing <FrameObject>.representation getter and setter.
1 parent 28cfac9 commit ab82474

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎astropy/coordinates/tests/test_frames.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,24 @@ def test_altaz_attributes():
310310
aa3 = AltAz(1*u.deg, 2*u.deg, location=EarthLocation(0*u.deg,0*u.deg, 0*u.m))
311311
assert isinstance(aa3.location, EarthLocation)
312312

313+
def test_preferred_representation():
314+
"""
315+
Test the getter and setter properties for `preferred_representation`
316+
"""
317+
from ..builtin_frames import ICRS
318+
319+
icrs = ICRS(ra=1*u.deg, dec=1*u.deg)
320+
321+
assert icrs.representation == representation.SphericalRepresentation
322+
assert repr(icrs) == '<ICRS Coordinate: ra=1.0 deg, dec=1.0 deg>'
323+
324+
icrs.representation = representation.CartesianRepresentation
325+
326+
assert icrs.representation == representation.CartesianRepresentation
327+
assert repr(icrs) == '<ICRS Coordinate: x=0.99969541351 , y=0.0174497483513 , z=0.0174524064373 >'
328+
329+
icrs.representation = 'spherical'
330+
331+
assert icrs.representation == representation.SphericalRepresentation
332+
assert repr(icrs) == '<ICRS Coordinate: ra=1.0 deg, dec=1.0 deg>'
333+

0 commit comments

Comments
 (0)