예제 #1
0
def test_tab_verb_with_default_inv():
    mapping = [
        (1, "SawTooth"),
        (2, "Square"),
        (3, "Sinus"),
    ]
    default = "unknown signal type"
    tv = functions.LookupTable(mapping, default = default)
    assert tv.inv("Square") == 2
    assert tv.inv(default) is None
예제 #2
0
def test_tab_verb_with_default():
    mapping = [
        (1, "SawTooth"),
        (2, "Square"),
        (3, "Sinus"),
    ]
    default = "unknown signal type"
    tv = functions.LookupTable(mapping, default = default)
    assert tv(2) == "Square"
    assert tv(5) == default
예제 #3
0
def test_tab_verb_with_default_inv_vectorized():
    mapping = [
        (1, "SawTooth"),
        (2, "Square"),
        (3, "Sinus"),
    ]
    default = "unknown signal type"
    xs = [1, 2, 3]
    ys = ["SawTooth", "Square", "Sinus"]
    tv = functions.LookupTable(mapping, default = default)
    assert np.array_equal(tv.inv(ys), xs)