Passed
Push — master ( 90fac4...b39ade )
by Grega
51s
created

Utility   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
dl 0
loc 17
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B itialize_benchmark() 0 15 6
1
"""Utilities for benchmarks."""
2
3
from . import Rastrigin, Rosenbrock, Griewank, Sphere
4
5
__all__ = ['Utility']
6
7
8
class Utility(object):
9
10
    @staticmethod
11
    def itialize_benchmark(function):
12
        if callable(function):
13
            return function
14
        else:
15
            if function == 'rastrigin':
16
                return Rastrigin.function()
17
            elif function == 'rosenbrock':
18
                return Rosenbrock.function()
19
            elif function == 'griewank':
20
                return Griewank.function()
21
            elif function == 'sphere':
22
                return Sphere.function()
23
            else:
24
                raise TypeError('Passed benchmark is not defined!')
25