def test_match(self): t = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}} pos_match_equal = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}} pos_match_subset = {'a': {'b': 1}, 'd': {'e': 3}} neg_match_diff = {'a': {'b': 2}, 'c': 2, 'd': {'e': 3}} neg_match_superset = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}, 'f': 3} tree = Tree(t) self.assertTrue(tree.match(pos_match_equal)) self.assertTrue(tree.match(pos_match_subset)) self.assertFalse(tree.match(neg_match_diff)) self.assertFalse(tree.match(neg_match_superset))
def test_match(self): t = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}} pos_match_equal = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}} pos_match_subset = {'a': {'b': 1}, 'd': {'e': 3}} neg_match_diff = {'a': {'b': 2}, 'c': 2, 'd': {'e': 3}} neg_match_superset = {'a': {'b': 1}, 'c': 2, 'd': {'e': 3}, 'f': 3} tree = Tree(t) assert tree.match(pos_match_equal) assert tree.match(pos_match_subset) assert not tree.match(neg_match_diff) assert not tree.match(neg_match_superset)
def test_match(self): t = {"a": {"b": 1}, "c": 2, "d": {"e": 3}} pos_match_equal = {"a": {"b": 1}, "c": 2, "d": {"e": 3}} pos_match_subset = {"a": {"b": 1}, "d": {"e": 3}} neg_match_diff = {"a": {"b": 2}, "c": 2, "d": {"e": 3}} neg_match_superset = {"a": {"b": 1}, "c": 2, "d": {"e": 3}, "f": 3} tree = Tree(t) assert tree.match(pos_match_equal) assert tree.match(pos_match_subset) assert not tree.match(neg_match_diff) assert not tree.match(neg_match_superset)
def filter(self, condition): """Return subset of results matching specific conditions Parameters ---------- condition : dict Dictionary listing all parameters and values to be matched in the results set. Each parameter, i.e., each key of the dictionary must be an iterable object containing the path in the parameters tree to the required parameter metrics : dict, optional List of metrics to be reported Returns ------- filtered_results : ResultSet List of 2-tuples of filtered results, where the first element is a tree of all experiment parameters and the second value is a tree with experiment results. """ filtered_resultset = ResultSet() for parameters, results in self._results: parameters = Tree(parameters) if parameters.match(condition): filtered_resultset.add(parameters, results) return filtered_resultset
def test_match_empty_tree(self): tree = Tree() self.assertFalse(tree.match({'a': 1}))
def test_match_empty_tree(self): tree = Tree() assert not tree.match({'a': 1})