Passed
Pull Request — master (#22)
by
unknown
01:08
created

Utility   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 21
rs 10
wmc 8

1 Method

Rating   Name   Duplication   Size   Complexity  
C get_benchmark() 0 19 8
1
"""Utilities for benchmarks."""
2
3
from . import Rastrigin, Rosenbrock, Griewank, Sphere, Ackley, Schwefel
4
5
__all__ = ['Utility']
6
7
8
class Utility(object):
9
10
    @staticmethod
11
    def get_benchmark(benchmark):
0 ignored issues
show
best-practice introduced by
Too many return statements (7/6)
Loading history...
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
            elif benchmark == 'schwefel':
26
                return Schwefel()
27
            else:
28
                raise TypeError('Passed benchmark is not defined!')
29