def test_distance_is_quantity(): """ test that distance behaves like a proper 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 # regression test against #2261 d = Distance([2 * u.kpc, 250. * u.pc]) assert d.unit is u.kpc assert np.all(d.value == np.array([2., 0.25]))