Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
maroba committed Feb 1, 2021
1 parent 4cb2d7b commit 9cbcb7a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 2 additions & 3 deletions findiff/coefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ def coefficients(deriv, acc=None, offsets=None, symbolic=False):
"""

_validate_deriv(deriv)
_validate_acc(acc)

if acc and offsets:
raise ValueError('acc and offsets cannot both be given')

if offsets:
return calc_coefs(deriv, offsets, symbolic)

_validate_acc(acc)
ret = {}

# Determine central coefficients
Expand Down Expand Up @@ -65,11 +65,10 @@ def calc_coefs(deriv, offsets, symbolic=False):
if symbolic:
coefs = sympy.linsolve((matrix, rhs))
coefs = list(tuple(coefs)[0])
acc = _calc_accuracy(offsets, coefs, deriv, symbolic)

return {
"coefficients": coefs,
"offsets": offsets,
"accuracy": acc
}

else:
Expand Down
5 changes: 0 additions & 5 deletions test/test_coefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,6 @@ def test_calc_accuracy_left0_right3_deriv1_acc3(self):

self.assertEqual(3, coefs["accuracy"])

def test_calc_accuracy_left0_right3_deriv1_acc3_symbolic(self):
coefs = calc_coefs(1, [0, 1, 2, 3], symbolic=True)

self.assertEqual(3, coefs["accuracy"])

def test_calc_coefs_from_offsets(self):
coefs = calc_coefs(1, [-2, 0, 1])
np.testing.assert_array_almost_equal(coefs["coefficients"], [-1./6, -0.5, 2./3])
Expand Down

0 comments on commit 9cbcb7a

Please sign in to comment.