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'])
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'))
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'))
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'])
def norms() -> StrList: """Get sorted list of vector norms.""" return sorted(catalog.search(Norm).get('name'))
def distances() -> StrList: """Get sorted list of vector distances.""" return sorted(catalog.search(Distance).get('name'))
def errors() -> StrList: """Get sorted list of implemented regression errors.""" return sorted(catalog.search(Error).get('name'))