Passed
Pull Request — master (#110)
by
unknown
01:30
created

hyperactive.experiment.toy._parabola   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A Parabola.__init__() 0 5 1
A Parabola._paramnames() 0 2 1
A Parabola._score() 0 5 1
1
"""2D parabola."""
2
3
from hyperactive.base import BaseExperiment
4
5
6
class Parabola(BaseExperiment):
7
    """2D parabola.
8
9
    Parameters
10
    ----------
11
    a : float, default=1.0
12
        Coefficient of the parabola.
13
    b : float, default=0.0
14
        Coefficient of the parabola.
15
    c : float, default=0.0
16
        Coefficient of the parabola.
17
    """
18
19
    def __init__(self, a=1.0, b=0.0, c=0.0):
20
        self.a = a
21
        self.b = b
22
        self.c = c
23
        super().__init__()
24
25
    def _paramnames(self):
26
        return ["x", "y"]
27
28
    def _score(self, params):
29
        x = params["x"]
30
        y = params["y"]
31
32
        return self.a * (x**2 + y**2) + self.b * x + self.c * y, {}
33