Ejemplo n.º 1
0
    def _get_algorithms(self, category = None, attribute = None):
        """Get optimization algorithms."""
        algorithms = self._buffer['algorithms'].get(attribute, None)
        if not algorithms:
            algorithms = entity.get_methods(self, key = 'name', val = attribute,
                groupby = 'category')
            self._buffer['algorithms'][attribute] = algorithms
        if category:
            if category not in algorithms: return {}
            algorithms = algorithms[category]

        return algorithms
Ejemplo n.º 2
0
    def _get_setter(self) -> list:
        """Get sorted list of keys, which are accepted by the 'set' method.

        The class method 'set' wraps given keys to private getter methods of
        the class instance, which are identified by an initial prefix '_set_'
        in the method name.

        Returns:
            Sorted list of keys, which are accepted by the 'set' method.

        """
        sdict = entity.get_methods(self, pattern='_set_*')
        slist = sorted(ndict.crop(sdict, '_set_'))

        return slist
Ejemplo n.º 3
0
    def _get_setter(self) -> list:
        """Get sorted list of keys, which are accepted by the 'set' method.

        The class method 'set' wraps given keys to private getter methods of
        the class instance, which are identified by an initial prefix '_set_'
        in the method name.

        Returns:
            Sorted list of keys, which are accepted by the 'set' method.

        """
        sdict = entity.get_methods(self, pattern='_set_*')
        slist = sorted(ndict.crop(sdict, '_set_'))

        return slist
Ejemplo n.º 4
0
 def test_get_methods(self) -> None:
     obj = self.get_test_object()
     names = entity.get_methods(obj, pattern='get*').keys()
     self.assertEqual(names, {'geta', 'getb'})
     names = entity.get_methods(obj, pattern='*b').keys()
     self.assertEqual(names, {'getb', 'setb'})
Ejemplo n.º 5
0
 def test_get_methods(self) -> None:
     obj = self.get_test_object()
     names = entity.get_methods(obj, pattern='get*').keys()
     self.assertEqual(names, {'geta', 'getb'})
     names = entity.get_methods(obj, pattern='*b').keys()
     self.assertEqual(names, {'getb', 'setb'})