def test_tab_verb_ranges_with_default_negative_vectorized(): mapping = [ (-1, 0, "minus_one_to_zero"), (-3, -2, "minus_three_minus_two"), (-7, -4, "minus_seven_to_minus_four"), (-17, -14, "minus_seventeen_minus_fourteen"), (-99, -18, "minus_ninetynine_minus_eigteen"), (-100, -100, "minus_hundred"), (-101, -101, "minus_hundredone"), (-102, -102, "minus_hundredtwo"), (-103, -103, "minus_hundredthree"), (-104, -104, "minus_hundredfour"), (-105, -105, "minus_hundredfive"), ] default = "out of range value" tvr = functions.LookupTableWithRanges(mapping, default=default, dtype=int) xs = [0, -6, -45, -100, -105, 1, -106, -10] ys = [ "minus_one_to_zero", "minus_seven_to_minus_four", "minus_ninetynine_minus_eigteen", "minus_hundred", "minus_hundredfive", "out of range value", "out of range value", "out of range value", ] assert np.array_equal(tvr.int_to_physical(xs), ys)
def test_tab_verb_ranges_inverse_vectorized(): mapping = [ (0, 1, "Zero_to_one"), (2, 3, "two_to_three"), (4, 7, "four_to_seven"), (14, 17, "fourteen_to_seventeen"), (18, 99, "eigteen_to_ninetynine"), (100, 100, "hundred"), (101, 101, "hundredone"), (102, 102, "hundredtwo"), (103, 103, "hundredthree"), (104, 104, "hundredfour"), (105, 105, "hundredfive"), ] default = "out of range value" tvr = functions.LookupTableWithRanges(mapping, default=default, dtype=int) xs = [ "Zero_to_one", "four_to_seven", "eigteen_to_ninetynine", "hundred", "hundredfive", ] ys = [0, 4, 18, 100, 105] assert np.array_equal(tvr.physical_to_int(xs), ys)
def test_tab_verb_ranges_with_default(): mapping = [(0, 1, "Zero_to_one"), (2, 3, "two_to_three"), (4, 7, "four_to_seven"), (14, 17, "fourteen_to_seventeen"), (18, 99, "eigteen_to_ninetynine"), (100, 100, "hundred"), (101, 101, "hundredone"), (102, 102, "hundredtwo"), (103, 103, "hundredthree"), (104, 104, "hundredfour"), (105, 105, "hundredfive")] default = "out of range value" tvr = functions.LookupTableWithRanges(mapping, default=default, dtype=int) assert tvr(0) == "Zero_to_one" assert tvr(6) == "four_to_seven" assert tvr(45) == "eigteen_to_ninetynine" assert tvr(100) == "hundred" assert tvr(105) == "hundredfive" assert tvr(-1) == "out of range value" assert tvr(106) == "out of range value" assert tvr(10) == "out of range value"
def test_tab_verb_ranges_with_default_negative(): mapping = [(-1, 0, "minus_one_to_zero"), (-3, -2, "minus_three_minus_two"), (-7, -4, "minus_seven_to_minus_four"), (-17, -14, "minus_seventeen_minus_fourteen"), (-99, -18, "minus_ninetynine_minus_eigteen"), (-100, -100, "minus_hundred"), (-101, -101, "minus_hundredone"), (-102, -102, "minus_hundredtwo"), (-103, -103, "minus_hundredthree"), (-104, -104, "minus_hundredfour"), (-105, -105, "minus_hundredfive")] default = "out of range value" tvr = functions.LookupTableWithRanges(mapping, default=default, dtype=int) assert tvr(0) == "minus_one_to_zero" assert tvr(-6) == "minus_seven_to_minus_four" assert tvr(-45) == "minus_ninetynine_minus_eigteen" assert tvr(-100) == "minus_hundred" assert tvr(-105) == "minus_hundredfive" assert tvr(1) == "out of range value" assert tvr(-106) == "out of range value" assert tvr(-10) == "out of range value"
def test_tab_verb_ranges_inverse(): mapping = [ (0, 1, "Zero_to_one"), (2, 3, "two_to_three"), (4, 7, "four_to_seven"), (14, 17, "fourteen_to_seventeen"), (18, 99, "eigteen_to_ninetynine"), (100, 100, "hundred"), (101, 101, "hundredone"), (102, 102, "hundredtwo"), (103, 103, "hundredthree"), (104, 104, "hundredfour"), (105, 105, "hundredfive") ] default = "out of range value" tvr = functions.LookupTableWithRanges(mapping, default = default, dtype = int) assert tvr.inv("Zero_to_one") == 0 assert tvr.inv("four_to_seven") == 4 assert tvr.inv("eigteen_to_ninetynine") == 18 assert tvr.inv("hundred") == 100 assert tvr.inv("hundredfive") == 105