示例#1
0
def test1():
    q = Quantity(1, 'km')
    assert_eq(q.SI, Quantity(1000, 'm'))

    q = Quantity(1, 'm')
    assert_eq(q, q.tounit('m'))
    q2 = q.copy()
    q.inunit('m')
    assert_eq(q, q2)
示例#2
0
def test3():
    q = Quantity(1, 'km')
    q.inunit('m')
    assert_quantity(q, 1000, 'm')
示例#3
0
def test_derived_units2():
    a = Quantity(4., 'Jy/detector', {'detector': Quantity(2,'arcsec^2')})
    a.inunit(a.unit + ' / arcsec^2 * detector')
    assert_quantity(a, 2, 'Jy / arcsec^2')
示例#4
0
def test_conversion_error():
    a = Quantity(1., 'kloug')
    assert_raises(UnitError, lambda: a.inunit('notakloug'))
    assert_raises(UnitError, lambda: a.inunit('kloug^2'))