예제 #1
0
    def test_search(self) -> None:

        @catalog.category
        class Func:
            name: str

        @catalog.category
        class Const(Func):
            name: str

        @catalog.register(Const, name='1')
        def a_1() -> int:
            return 1

        @catalog.register(Const, name='2')
        def a_2() -> int:
            return 2

        @catalog.register(Const, name='3')
        def b_1() -> int:
            return 3

        @catalog.register(Func, name='4')
        def b_2() -> int:
            return 4

        with self.subTest(path='*.a_*'):
            names = sorted(catalog.search(path='*.a_*').get('name'))
            self.assertEqual(names, ['1', '2'])

        with self.subTest(path='*.b_*'):
            names = catalog.search(path='*.b_*').get('name')
            self.assertEqual(names, ['3', '4'])

        with self.subTest(cat=Const):
            names = sorted(catalog.search(Const).get('name'))
            self.assertEqual(names, ['1', '2', '3'])

        with self.subTest(cat=Func):
            names = sorted(catalog.search(Func).get('name'))
            self.assertEqual(names, ['1', '2', '3', '4'])

        with self.subTest(name='1'):
            names = sorted(catalog.search(name='1').get('name'))
            self.assertEqual(names, ['1'])
예제 #2
0
def sigmoids() -> StrList:
    """Get sorted list of sigmoid functions.

    Returns:
        Sorted list of all sigmoid functions, that are implemented within the
        module.

    """
    return sorted(catalog.search(Sigmoid).get('name'))
예제 #3
0
def bells() -> StrList:
    """Get sorted list of bell shaped functions.

    Returns:
        Sorted list of all bell shaped functions, that are implemented within
        the module.

    """
    return sorted(catalog.search(Bell).get('name'))
예제 #4
0
    def test_Results(self) -> None:
        @catalog.category
        class C:
            name: str

        @catalog.register(C, name='f')
        def f() -> None:
            pass

        @catalog.register(C, name='g')
        def g() -> None:
            pass

        @catalog.register(C, name='h')
        def h() -> None:
            pass

        names = sorted(catalog.search(C).get('name'))
        self.assertEqual(names, ['f', 'g', 'h'])
예제 #5
0
파일: vector.py 프로젝트: fd0livar/rian
def norms() -> StrList:
    """Get sorted list of vector norms."""
    return sorted(catalog.search(Norm).get('name'))
예제 #6
0
파일: vector.py 프로젝트: fd0livar/rian
def distances() -> StrList:
    """Get sorted list of vector distances."""
    return sorted(catalog.search(Distance).get('name'))
예제 #7
0
파일: regress.py 프로젝트: fd0livar/rian
def errors() -> StrList:
    """Get sorted list of implemented regression errors."""
    return sorted(catalog.search(Error).get('name'))