def test_ra_equality_operator(): ra = NumCpp.Ra() assert ra randDegrees = np.random.rand(1).item() * 360 ra2 = NumCpp.Ra(randDegrees) assert ra != ra2
def test_ra_degrees_constructor(): randDegrees = np.random.rand(1).item() * 360 ra = NumCpp.Ra(randDegrees) raPy = Longitude(randDegrees, unit=u.deg) # noqa assert round(ra.degrees(), 9) == round(randDegrees, 9) assert ra.hours() == raPy.hms.h assert ra.minutes() == raPy.hms.m assert round(ra.seconds(), 9) == round(raPy.hms.s, 9) assert round(ra.radians(), 9) == round(np.deg2rad(randDegrees), 9)
def test_ra_hms_constructor(): hours = np.random.randint(0, 24, [1, ], dtype=np.uint8).item() minutes = np.random.randint(0, 60, [1, ], dtype=np.uint8).item() seconds = np.random.rand(1).astype(np.double).item() * 60 ra = NumCpp.Ra(hours, minutes, seconds) degreesPy = (hours + minutes / 60 + seconds / 3600) * 15 assert round(ra.degrees(), 9) == round(degreesPy, 9) assert ra.hours() == hours assert ra.minutes() == minutes assert round(ra.seconds(), 9) == round(seconds, 9) assert round(ra.radians(), 9) == round(np.deg2rad(degreesPy), 9)
def test_coord_cartesian_constructor(): raDegrees = np.random.rand(1).item() * 360 ra = NumCpp.Ra(raDegrees) decDegrees = np.random.rand(1).item() * 180 - 90 dec = NumCpp.Dec(decDegrees) pyCoord = SkyCoord(raDegrees, decDegrees, unit=u.deg) # noqa cCoord = NumCpp.Coordinate(pyCoord.cartesian.x.value, pyCoord.cartesian.y.value, pyCoord.cartesian.z.value) assert round(cCoord.ra().degrees(), 9) == round(ra.degrees(), 9) assert round(cCoord.dec().degrees(), 9) == round(dec.degrees(), 9) assert round(cCoord.x(), 9) == round(pyCoord.cartesian.x.value, 9) assert round(cCoord.y(), 9) == round(pyCoord.cartesian.y.value, 9) assert round(cCoord.z(), 9) == round(pyCoord.cartesian.z.value, 9)
def test_coord_radec_constructor(): raDegrees = np.random.rand(1).item() * 360 ra = NumCpp.Ra(raDegrees) decDegrees = np.random.rand(1).item() * 180 - 90 dec = NumCpp.Dec(decDegrees) pyCoord = SkyCoord(raDegrees, decDegrees, unit=u.deg) # noqa cCoord = NumCpp.Coordinate(ra, dec) assert cCoord.ra() == ra assert cCoord.dec() == dec assert round(cCoord.x(), 10) == round(pyCoord.cartesian.x.value, 10) assert round(cCoord.y(), 10) == round(pyCoord.cartesian.y.value, 10) assert round(cCoord.z(), 10) == round(pyCoord.cartesian.z.value, 10)
def test_coord_cartesian_vector_constructor(): raDegrees = np.random.rand(1).item() * 360 ra = NumCpp.Ra(raDegrees) decDegrees = np.random.rand(1).item() * 180 - 90 dec = NumCpp.Dec(decDegrees) pyCoord = SkyCoord(raDegrees, decDegrees, unit=u.deg) # noqa vec = np.asarray([pyCoord.cartesian.x.value, pyCoord.cartesian.y.value, pyCoord.cartesian.z.value]) cVec = NumCpp.NdArray(1, 3) cVec.setArray(vec) cCoord = NumCpp.Coordinate(cVec) assert round(cCoord.ra().degrees(), 9) == round(ra.degrees(), 9) assert round(cCoord.dec().degrees(), 9) == round(dec.degrees(), 9) assert round(cCoord.x(), 9) == round(pyCoord.cartesian.x.value, 9) assert round(cCoord.y(), 9) == round(pyCoord.cartesian.y.value, 9) assert round(cCoord.z(), 9) == round(pyCoord.cartesian.z.value, 9)
def test_ra_print(): ra = NumCpp.Ra() ra.print()
def test_ra_copy_constructor(): ra = NumCpp.Ra() assert ra ra2 = NumCpp.Ra(ra) assert ra == ra2
def test_ra_default_constructor(): ra = NumCpp.Ra() assert ra