Exemple #1
0
def test_clamped_keeps_values_within_limits():
    p = Point5D(x=100, y=200, z=300, t=400, c=500)
    assert p.clamped(maximum=Point5D.inf(y=50, c=600)).to_tuple("yc") == (50, 500)
    assert p.clamped(minimum=Point5D.ninf(y=300, x=90)).to_tuple("yx") == (300, 100)

    min_pt = Point5D(x=10, y=20, z=30, t=40, c=1000)
    assert p.clamped(minimum=min_pt).to_tuple("xyztc") == (100, 200, 300, 400, 1000)

    max_pt = Point5D(x=1, y=2, z=3, t=4, c=1000)
    assert p.clamped(maximum=max_pt).to_tuple("xyztc") == (1, 2, 3, 4, 500)

    clamped_pt = p.clamped(minimum=Point5D.ninf(x=20, t=50), maximum=Point5D.inf(x=120, t=500))
    assert clamped_pt.to_tuple("xt") == (100, 400)
Exemple #2
0
def test_ininf_factory_method_defaults_coords_to_ninf():
    p = Point5D.ninf(c=123, y=456)
    assert p.x == Point5D.NINF
    assert p.y == 456
    assert p.z == Point5D.NINF
    assert p.t == Point5D.NINF
    assert p.c == 123