def test_distance_to_quantity_when_not_units_of_length():
 d = Distance((15 * u.kpc))
 twice = (2.0 * d)
 assert isinstance(twice, Distance)
 area = ((4.0 * np.pi) * (d ** 2))
 assert area.unit.is_equivalent((u.m ** 2))
 assert (not isinstance(area, Distance))
 assert (type(area) is u.Quantity)

def test_distance_to_quantity_when_not_units_of_length ( ) : d = Distance ( ( 15 * u . kpc ) ) twice = ( 2.0 * d ) assert isinstance ( twice , Distance ) area = ( ( 4.0 * np . pi ) * ( d ** 2 ) ) assert area . unit . is_equivalent ( ( u . m ** 2 ) ) assert ( not isinstance ( area , Distance ) ) assert ( type ( area ) is u . Quantity )
any operatation that leaves units other than those of length should turn a distance into a quantity .