示例#1
0
def test_curve():
    s = Symbol("s")
    z = Symbol("z")

    # this curve is independent of the indicated parameter
    C = Curve([2 * s, s ** 2], (z, 0, 2))

    assert C.parameter == z
    assert C.functions == (2 * s, s ** 2)
    assert C.arbitrary_point() == Point(2 * s, s ** 2)
    assert C.arbitrary_point(z) == Point(2 * s, s ** 2)

    # this is how it is normally used
    C = Curve([2 * s, s ** 2], (s, 0, 2))

    assert C.parameter == s
    assert C.functions == (2 * s, s ** 2)
    t = Symbol("t")
    assert C.arbitrary_point() != Point(2 * t, t ** 2)  # the t returned as assumptions
    t = Symbol("t", real=True)  # now t has the same assumptions so the test passes
    assert C.arbitrary_point() == Point(2 * t, t ** 2)
    assert C.arbitrary_point(z) == Point(2 * z, z ** 2)
    assert C.arbitrary_point(C.parameter) == Point(2 * s, s ** 2)

    raises(ValueError, "Curve((s, s + t), (s, 1, 2)).arbitrary_point()")
    raises(ValueError, "Curve((s, s + t), (t, 1, 2)).arbitrary_point(s)")
示例#2
0
def test_curve():
    s = Symbol('s')
    z = Symbol('z')

    # this curve is independent of the indicated parameter
    C = Curve([2*s, s**2], (z, 0, 2))

    assert C.parameter == z
    assert C.functions == (2*s, s**2)
    assert C.arbitrary_point() == Point(2*s, s**2)
    assert C.arbitrary_point(z) == Point(2*s, s**2)

    # this is how it is normally used
    C = Curve([2*s, s**2], (s, 0, 2))

    assert C.parameter == s
    assert C.functions == (2*s, s**2)
    t = Symbol('t')
    assert C.arbitrary_point() != Point(2*t, t**2) # the t returned as assumptions
    t = Symbol('t', real=True) # now t has the same assumptions so the test passes
    assert C.arbitrary_point() == Point(2*t, t**2)
    assert C.arbitrary_point(z) == Point(2*z, z**2)
    assert C.arbitrary_point(C.parameter) == Point(2*s, s**2)

    raises(ValueError, 'Curve((s, s + t), (s, 1, 2)).arbitrary_point()')
    raises(ValueError, 'Curve((s, s + t), (t, 1, 2)).arbitrary_point(s)')