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
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
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)