Passed
Pull Request — master (#17)
by Grega
53s
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
class Utility(object):
8
9
    @staticmethod
10
    def itialize_benchmark(function):
11
        if callable(function):
12
            return function
13
        else:
14
            if function == 'rastrigin':
15
                return Rastrigin.function()
16
            elif function == 'rosenbrock':
17
                return Rosenbrock.function()
18
            elif function == 'griewank':
19
                return Griewank.function()
20
            elif function == 'sphere':
21
                return Sphere.function()
22
            else:
23
                raise TypeError('Passed benchmark is not defined!')
24