| Total Complexity | 7 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | """Utilities for benchmarks.""" |
||
| 8 | class Utility(object): |
||
| 9 | |||
| 10 | @staticmethod |
||
| 11 | def get_benchmark(benchmark): |
||
| 12 | if not isinstance(benchmark, ''.__class__): |
||
| 13 | return benchmark |
||
| 14 | else: |
||
| 15 | if benchmark == 'rastrigin': |
||
| 16 | return Rastrigin() |
||
| 17 | elif benchmark == 'rosenbrock': |
||
| 18 | return Rosenbrock() |
||
| 19 | elif benchmark == 'griewank': |
||
| 20 | return Griewank() |
||
| 21 | elif benchmark == 'sphere': |
||
| 22 | return Sphere() |
||
| 23 | elif benchmark == 'ackley': |
||
| 24 | return Ackley() |
||
| 25 | else: |
||
| 26 | raise TypeError('Passed benchmark is not defined!') |
||
| 27 |