Skip to content

Commit

Permalink
Merge pull request #54 from virocon-organization/issue#53
Browse files Browse the repository at this point in the history
Adapt tests to new asysmdecrease dependence function.
  • Loading branch information
ahaselsteiner committed Mar 2, 2020
2 parents 82e2c52 + 2b274e9 commit acef6d8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
12 changes: 4 additions & 8 deletions tests/test_fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,10 @@ def test_fit_asymdecrease3(self):

# Check whether the logarithmic square fit worked correctly.
dist1 = fit.mul_var_dist.distributions[1]
self.assertGreater(dist1.shape.a, -0.1) # Should be about 0
self.assertLess(dist1.shape.a, 0.1) # Should be about 0
self.assertGreater(dist1.shape.b, 1) # Should be about 1-2.5
self.assertLess(dist1.shape.b, 2.5) # Should be about 1-2.5
self.assertGreater(np.abs(dist1.shape.c), 1.5) # Should be about 1.5 - 4
self.assertLess(np.abs(dist1.shape.c), 4) # Should be about 1.1
self.assertGreater(dist1.shape(0), 0.25) # Should be about 0.35
self.assertLess(dist1.shape(0), 0.4) # Should be about 0.35
self.assertAlmostEqual(dist1.shape.a, 0, delta=0.1) # Should be about 0
self.assertAlmostEqual(dist1.shape.b, 0.35, delta=0.5) # Should be about 0.35
self.assertAlmostEqual(np.abs(dist1.shape.c), 2.5, delta=2) # Should be about 2.5
self.assertAlmostEquals(dist1.shape(0), 0.35, delta=0.2) # Should be about 0.35

def test_min_number_datapoints_for_fit(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ def test_FunctionParam_asymdecrease3(self):
Tests if function asymdecrease3 calculates the correct value.
"""

test_func = FunctionParam('asymdecrease3', 1, 4, 2)
self.assertEqual(test_func._value(0), 1.125)
test_func = FunctionParam('asymdecrease3', 1, 4, 3)
self.assertEqual(test_func._value(0), 2)
self.assertEqual(test_func.func_name, 'asymdecrease3')
self.assertEqual(str(test_func)[0:1], '1')

Expand Down
4 changes: 2 additions & 2 deletions viroconcom/fitting.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _powerdecrease3(x, a, b, c):

# 3-parameter function that asymptotically decreases (a dependence function).
def _asymdecrease3(x, a, b, c):
return a + 1 / (b * (x + np.abs(c)))
return a + b / (1 + x + np.abs(c))


# A 4-parameter logististics function (a dependence function).
Expand Down Expand Up @@ -565,7 +565,7 @@ def __init__(self, samples, dist_descriptions, timeout=None):
- :exp3: :math:`a + b * e^{x * c}`
- :lnsquare2: :math:`ln[a + b * sqrt(x / 9.81)`
- :powerdecrease3: :math:`a + 1 / (x + b)^c`
- :asymdecrease3: :math:`a + 1 / (b * (x + |c|))`
- :asymdecrease3: :math:`a + b / (1 + x + |c|)`
- :asymdecrease3: :math:`a + 1 / (b * (x + c))`
- :logistics4: :math:`a + b / [1 + e^{-c * (x - d)}]`
- remark : in case of Lognormal_SigmaMu it is (sigma, None, mu)
Expand Down
8 changes: 4 additions & 4 deletions viroconcom/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __init__(self, func_name, a, b, c, d=None,
:exp3: :math:`a + b * e^{x * c}`
:lnsquare2: :math:`\ln[a + b * \sqrt(x / 9.81)`
:powerdecrease3: :math:`a + 1 / (x + b)^c`
:asymdecrease3: :math:`a + 1 / (b * (x + c))`
:asymdecrease3: :math:`a + b / (1 + x + |c|)`
:logistics4: :math:`a + b / [1 + e^{-c * (x - d)}]`
a,b,c : float
The function parameters.
Expand Down Expand Up @@ -165,7 +165,7 @@ def _powerdecrease3(self, x):

# A 3-parameter function that asymptotically decreases (a dependence function).
def _asymdecrease3(self, x):
return self.a + 1.0 / (self.b * (x + np.abs(self.c)))
return self.a + self.b / (1 + x + np.abs(self.c))

# A 4-parameter logististics function (a dependence function).
def _logistics4(self, x, a=None, b=None, c=None, d=None):
Expand Down Expand Up @@ -198,8 +198,8 @@ def __str__(self):
function_string = "" + str(self.a) + " + 1 / (x + " + str(self.b) + \
")^" + str(self.c)
elif self.func_name == "asymdecrease3":
function_string = "" + str(self.a) + " + 1 / [" + str(self.b) + \
"(x + " + str(self.c) + ")]"
function_string = "" + str(self.a) + " + " + str(self.b) + \
"/ (1 + x + |" + str(self.c) + "|)"
elif self.func_name == "logistics4":
function_string = "" + str(self.a) + " + " + str(self.b) + \
" / {1 + e^[-" + str(self.c) + \
Expand Down
2 changes: 1 addition & 1 deletion viroconcom/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.3'
__version__ = '1.3.4'

0 comments on commit acef6d8

Please sign in to comment.