def test_coord_init_representation():
 coord = SphericalRepresentation(lon=(8 * u.deg), lat=(5 * u.deg), distance=(1 * u.kpc))
 sc = SkyCoord(coord, u'icrs')
 assert allclose(sc.ra, coord.lon)
 assert allclose(sc.dec, coord.lat)
 assert allclose(sc.distance, coord.distance)
 with pytest.raises(ValueError) as err:
  SkyCoord(coord, u'icrs', ra=u'1d')
 assert (u"conflicts with keyword argument 'ra'" in str(err))
 coord = CartesianRepresentation((1 * u.one), (2 * u.one), (3 * u.one))
 sc = SkyCoord(coord, u'icrs')
 sc_cart = sc.represent_as(CartesianRepresentation)
 assert allclose(sc_cart.x, 1.0)
 assert allclose(sc_cart.y, 2.0)
 assert allclose(sc_cart.z, 3.0)

def test_coord_init_representation ( ) : coord = SphericalRepresentation ( lon = ( 8 * u . deg ) , lat = ( 5 * u . deg ) , distance = ( 1 * u . kpc ) ) sc = SkyCoord ( coord , u'icrs' ) assert allclose ( sc . ra , coord . lon ) assert allclose ( sc . dec , coord . lat ) assert allclose ( sc . distance , coord . distance ) with pytest . raises ( ValueError ) as err : SkyCoord ( coord , u'icrs' , ra = u'1d' ) assert ( u"conflicts with keyword argument 'ra'" in str ( err ) ) coord = CartesianRepresentation ( ( 1 * u . one ) , ( 2 * u . one ) , ( 3 * u . one ) ) sc = SkyCoord ( coord , u'icrs' ) sc_cart = sc . represent_as ( CartesianRepresentation ) assert allclose ( sc_cart . x , 1.0 ) assert allclose ( sc_cart . y , 2.0 ) assert allclose ( sc_cart . z , 3.0 )
spherical or cartesian represenation input coordinates .