def test_distance_is_quantity():
 Distance((2 * u.kpc))
 d = Distance([2, 3.1], u.kpc)
 assert (d.shape == (2,))
 a = d.view(np.ndarray)
 q = d.view(u.Quantity)
 a[0] = 1.2
 q.value[1] = 5.4
 assert (d[0].value == 1.2)
 assert (d[1].value == 5.4)
 q = u.Quantity(d, copy=True)
 q.value[1] = 0
 assert (q.value[1] == 0)
 assert (d.value[1] != 0)
 d = Distance([(2 * u.kpc), (250.0 * u.pc)])
 assert (d.unit is u.kpc)
 assert np.all((d.value == np.array([2.0, 0.25])))

def test_distance_is_quantity ( ) : Distance ( ( 2 * u . kpc ) ) d = Distance ( [ 2 , 3.1 ] , u . kpc ) assert ( d . shape == ( 2 , ) ) a = d . view ( np . ndarray ) q = d . view ( u . Quantity ) a [ 0 ] = 1.2 q . value [ 1 ] = 5.4 assert ( d [ 0 ] . value == 1.2 ) assert ( d [ 1 ] . value == 5.4 ) q = u . Quantity ( d , copy = True ) q . value [ 1 ] = 0 assert ( q . value [ 1 ] == 0 ) assert ( d . value [ 1 ] != 0 ) d = Distance ( [ ( 2 * u . kpc ) , ( 250.0 * u . pc ) ] ) assert ( d . unit is u . kpc ) assert np . all ( ( d . value == np . array ( [ 2.0 , 0.25 ] ) ) )
test that distance behaves like a proper quantity .