Beispiel #1
0
assert(t1 * 3 == 31.5 and isinstance(t1 * 3, LIGOTimeGPS))
assert(t2 / 2.5 == 2 and isinstance(t2 / 2.5, LIGOTimeGPS))
assert(t1 + t2 == 15.5 and isinstance(t1 + t2, LIGOTimeGPS))
assert(t1 - t2 == 5.5 and isinstance(t1 - t2, LIGOTimeGPS))
assert(t1 * t2 == 52.5 and isinstance(t1 * t2, LIGOTimeGPS))
assert(t2 * t1 == 52.5 and isinstance(t2 * t1, LIGOTimeGPS))
assert(t1 / t2 == 2.1 and isinstance(t1 / t2, LIGOTimeGPS))
assert(t1 % t2 == 0.5 and isinstance(t1 % t2, LIGOTimeGPS))
assert(t1 > t2 and t2 < t1 and t1 >= t2 and t2 <= t1)
assert(LIGOTimeGPS(333333333,333333333) == LIGOTimeGPS(1000000000) / 3)
assert(LIGOTimeGPS(666666666,666666667) == LIGOTimeGPS(2000000000) / 3)
t1 += 812345667.75
assert(str(t1) == "812345678.250000000")
assert(LIGOTimeGPS(repr(t1)) == t1)
assert(long(t1) == 812345678)
assert(t1.ns() == 812345678250000000L)
assert(hash(t1) == 1049484238)
t4struct = lal.swig_lal_test_gps()
t4struct.t = 1234.5
assert(t4struct.t == 1234.5)
t5 = LIGOTimeGPS("1000")
assert(t5 == 1000)
try:
    t5 = LIGOTimeGPS("abc1000")
    expected_exception = True
except:
    pass
assert(not expected_exception)
try:
    t5 = LIGOTimeGPS("1000abc")
    expected_exception = True
assert (LIGOTimeGPS(666666666, 666666667) == LIGOTimeGPS(2000000000) / 3)
assert (
    LIGOTimeGPS("-62997760.825036067") == LIGOTimeGPS("-47044285.062262587") -
    LIGOTimeGPS("15953475.76277348"))
assert (LIGOTimeGPS("-6542354.389038577") == LIGOTimeGPS("-914984.929117316") *
        7.1502318572066237)
assert (LIGOTimeGPS("-6542354.389038577") == 7.1502318572066237 *
        LIGOTimeGPS("-914984.929117316"))
assert (LIGOTimeGPS("-127965.770535834") == LIGOTimeGPS("-914984.929117316") /
        7.1502318572066237)
t1 += 812345667.75
assert (str(t1) == "812345678.25")
assert (type(eval(repr(t1))) is type(t1))
assert (eval(repr(t1)) == t1)
assert (int(t1) == 812345678)
assert (t1.ns() == 812345678250000000)
assert (hash(t1) == 1049484238)
t4struct = lal.swig_lal_test_gps()
t4struct.t = 1234.5
assert (t4struct.t == 1234.5)
t5 = LIGOTimeGPS("1000")
assert (t5 == 1000)
print("*** below should be error messages from LIGOTimeGPS constructor ***")
try:
    t5 = LIGOTimeGPS("abc1000")
    expected_exception = True
except:
    pass
assert (not expected_exception)
try:
    t5 = LIGOTimeGPS("1000abc")