コード例 #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'})