def test_filter_by_level(self): ados = HierarchyADOs(self.mk_exponents([2, 3]), max_depth=2) assert ados.filter(level=0) == [ (0, 0), ] assert ados.filter(level=1) == [ (0, 1), (1, 0), ] assert ados.filter(level=2) == [ (0, 2), (1, 1), ] assert ados.filter(level=3) == []
def test_filter_by_nothing(self): ados = HierarchyADOs(self.mk_exponents([2, 3]), max_depth=2) assert ados.filter() == [ (0, 0), (0, 1), (0, 2), (1, 0), (1, 1), ]
def test_filter_by_exponents(self): ados = HierarchyADOs(self.mk_exponents([2, 3]), max_depth=2) assert ados.filter(dims=[]) == [ (0, 0), ] assert ados.filter(dims=[2]) == [ (1, 0), ] assert ados.filter(level=1, dims=[2]) == [ (1, 0), ] assert ados.filter(dims=[3]) == [ (0, 1), ] assert ados.filter(dims=[2, 3]) == [ (1, 1), ] assert ados.filter(level=2, dims=[2, 3]) == [ (1, 1), ] assert ados.filter(dims=[3, 3]) == [ (0, 2), ] assert ados.filter(types=["I"]) == [ (0, 1), (1, 0), ] assert ados.filter(types=["I", "I"]) == [ (0, 2), (1, 1), ] with pytest.raises(ValueError) as err: ados.filter(types=[], dims=[2]) assert str(err.value) == ( "The tags, dims and types filters must all be the same length.") with pytest.raises(ValueError) as err: ados.filter(dims=[2, 2, 2]) assert str(err.value) == ( "The maximum depth for the hierarchy is 2 but 3 levels of" " excitation filters were given.") with pytest.raises(ValueError) as err: ados.filter(level=0, dims=[2]) assert str(err.value) == ( "The level parameter is 0 but 1 levels of excitation filters" " were given.")