How to use the pynq.providers.partition_algorithm.EquivalenceClassSetPartition.partition function in pynq

To help you get started, we’ve selected a few pynq examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heynemann / pynq / tests / unit / test_equivalence_classes_algo.py View on Github external
def test_algorithm_returns_a_list_for_given_equivalence_class(self):
        col = [10]
        r = lambda item: item * item
        
        partitioned = EquivalenceClassSetPartition.partition(col, r)
        
        assert isinstance(partitioned[100], list)
github heynemann / pynq / tests / unit / test_equivalence_classes_algo.py View on Github external
def test_algorithm_returns_the_item_in_the_list_for_given_equivalence_class(self):
        col = [10]
        r = lambda item: item * item
        
        partitioned = EquivalenceClassSetPartition.partition(col, r)
        
        assert partitioned[100][0] == 10
github heynemann / pynq / tests / unit / test_equivalence_classes_algo.py View on Github external
def test_algorithm_returns_proper_equivalence_class(self):
        col = [10]
        r = lambda item: item * item
        
        partitioned = EquivalenceClassSetPartition.partition(col, r)
        
        assert partitioned.has_key(100)
github heynemann / pynq / tests / unit / test_equivalence_classes_algo.py View on Github external
def test_algorithm_returns_a_dictionary(self):
        partitioned = EquivalenceClassSetPartition.partition([1], lambda item: item)
        assert isinstance(partitioned, dict)
github heynemann / pynq / pynq / providers / __init__.py View on Github external
def __group_collection(self, collection, group_expression):
        if isinstance(group_expression, NameExpression):
            expr_name = group_expression.name
            if "." in expr_name:
                rel = lambda item: reduce(getattr, expr_name, item)
            else:
                rel = lambda item: getattr(item, expr_name)
        else:
            rel = lambda item: eval(str(query.group_expression))

        return EquivalenceClassSetPartition.partition(collection, rel)