def test_map_by_substring_with_map_values(self): np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=True, match_beginning=False, map_values=None), [0, 1, 2, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=True, match_beginning=False, map_values=[0, 1, 2, 3]), [0, 1, 2, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=True, match_beginning=False, map_values=[1, 0, 3, 2]), [1, 0, 3, 1, 2]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=True, match_beginning=False, map_values=[1, 1, 0, 0]), [1, 1, 0, 1, 0])
def test_map_by_substring(self): np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=True, match_beginning=False), [0, 1, 2, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "Bc", ""], case_sensitive=True, match_beginning=False), [0, 1, 3, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "Bc", ""], case_sensitive=False, match_beginning=False), [0, 1, 2, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=False, match_beginning=True), [0, 1, 2, 3, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["", ""], False, False), 0) self.assertTrue(np.all(np.isnan( map_by_substring(self.arr, [], False, False))))
def test_map_by_substring(self): np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=True, match_beginning=False), [0, 1, 2, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "Bc", ""], case_sensitive=True, match_beginning=False), [0, 1, 3, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "Bc", ""], case_sensitive=False, match_beginning=False), [0, 1, 2, 0, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["abc", "a", "bc", ""], case_sensitive=False, match_beginning=True), [0, 1, 2, 3, 3]) np.testing.assert_equal( map_by_substring(self.arr, ["", ""], False, False), 0) self.assertTrue(np.all(np.isnan( map_by_substring(self.arr, [], False, False))))