def test_eq(self): input = gr.SeriesWeld( np.array(["aaaa", "bbb", "aa", "cccc"], dtype=str), gr.WeldVec(gr.WeldChar())) expected_output = [True, False, False, False] self.assertSequenceEqual(expected_output, list((input == "aaaa").evaluate(False)))
def test_slice(self): input = gr.SeriesWeld( np.array(["aaaaaa", "bbbbbb", "aaaaaaa", "cccccccc"], dtype=str), gr.WeldVec(gr.WeldChar())) expected_output = ["aaa", "bbb", "aaa", "ccc"] self.assertSequenceEqual(expected_output, list(input.str.slice(1, 3).evaluate(False)))
def test_filter(self): inp = gr.SeriesWeld(np.array(["aaaa", "bbb", "aa", "cccc"], dtype=str), gr.WeldVec(gr.WeldChar())) predicates = np.array([True, False, False, True], dtype=bool) expected_output = ["aaaa", "cccc"] self.assertSequenceEqual(expected_output, list(inp.filter(predicates).evaluate(False)))
def test_eq_and_mask(self): inp = gr.SeriesWeld(np.array(["aaaa", "bbb", "aa", "cccc"], dtype=str), gr.WeldVec(gr.WeldChar())) predicates = inp == "bbb" expected_output = ["aaaa", "eeee", "aa", "cccc"] self.assertSequenceEqual( expected_output, list(inp.mask(predicates, "eeee").evaluate(False)))
def test_eq_and_mask_grouped_strings(self): inp = gr.SeriesWeld(np.array(["aaaa", "bbb", "aa", "cccc"], dtype=str), gr.WeldVec(gr.WeldChar())) predicates = inp == "bbb" expected_output = ["aaaa", "eeee", "aa", "cccc"] output = gr.group([predicates, inp.mask(predicates, "eeee")]).evaluate(False) self.assertSequenceEqual([False, True, False, False], list(output[0])) self.assertSequenceEqual(["aaaa", "eeee", "aa", "cccc"], list(output[1]))
def test_unique(self): input = gr.SeriesWeld( np.array(["aaa", "bbb", "aaa", "ccc"], dtype=str), gr.WeldVec(gr.WeldChar())) self.assertItemsEqual(["aaa", "bbb", "ccc"], input.unique().evaluate(False))
def test_filter_self(self): input = gr.SeriesWeld( np.array(["False", "True", "True", "False"], dtype=str), gr.WeldVec(gr.WeldChar())) print input.lower().evaluate() print input.filter(input.lower() == "true").evaluate()