def test_quantity_from_table():
 from ...table import Table
 t = Table(data=[np.arange(5), np.arange(5)], names=[u'a', u'b'])
 t[u'a'].unit = u.kpc
 qa = u.Quantity(t[u'a'])
 assert (qa.unit == u.kpc)
 assert_array_equal(qa.value, t[u'a'])
 qb = u.Quantity(t[u'b'])
 assert (qb.unit == u.dimensionless_unscaled)
 assert_array_equal(qb.value, t[u'b'])
 qap = u.Quantity(t[u'a'], u.pc)
 assert (qap.unit == u.pc)
 assert_array_equal(qap.value, (t[u'a'] * 1000))
 qbp = u.Quantity(t[u'b'], u.pc)
 assert (qbp.unit == u.pc)
 assert_array_equal(qbp.value, t[u'b'])

def test_quantity_from_table ( ) : from ... table import Table t = Table ( data = [ np . arange ( 5 ) , np . arange ( 5 ) ] , names = [ u'a' , u'b' ] ) t [ u'a' ] . unit = u . kpc qa = u . Quantity ( t [ u'a' ] ) assert ( qa . unit == u . kpc ) assert_array_equal ( qa . value , t [ u'a' ] ) qb = u . Quantity ( t [ u'b' ] ) assert ( qb . unit == u . dimensionless_unscaled ) assert_array_equal ( qb . value , t [ u'b' ] ) qap = u . Quantity ( t [ u'a' ] , u . pc ) assert ( qap . unit == u . pc ) assert_array_equal ( qap . value , ( t [ u'a' ] * 1000 ) ) qbp = u . Quantity ( t [ u'b' ] , u . pc ) assert ( qbp . unit == u . pc ) assert_array_equal ( qbp . value , t [ u'b' ] )
checks that units from tables are respected when converted to a quantity .