예제 #1
0
파일: base.py 프로젝트: fishroot/nemoa
    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
예제 #2
0
파일: nbase.py 프로젝트: fishroot/nemoa
    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
예제 #3
0
파일: nbase.py 프로젝트: fishroot/nemoa
    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
예제 #4
0
파일: __test__.py 프로젝트: fishroot/nemoa
 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'})
예제 #5
0
파일: __test__.py 프로젝트: fishroot/nemoa
 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'})