diff --git a/solventmapcreator/polynomialanalysis/polynomialvaluecalculator.py b/solventmapcreator/polynomialanalysis/polynomialvaluecalculator.py index d02cb2e4f87b5a3fa1ee2da0e0fab1ac733e83a5..c247b766e9f7b11ffabba97a8a593cc8e8edf4dc 100644 --- a/solventmapcreator/polynomialanalysis/polynomialvaluecalculator.py +++ b/solventmapcreator/polynomialanalysis/polynomialvaluecalculator.py @@ -24,7 +24,11 @@ def calculate_polynomial_values(x_values, polynomial_coefficients): was given. """ if type(polynomial_coefficients) is dict: - return calculate_poly_value_for_array_from_dict(x_values, polynomial_coefficients) + if type(x_values) is float or type(x_values) is np.float64: + return calculate_poly_value_from_dict(x_values, polynomial_coefficients) + else: + return calculate_poly_value_for_array_from_dict(x_values, polynomial_coefficients) + else: return calculate_polynomial_value(x_values, polynomial_coefficients) diff --git a/solventmapcreator/test/polynomialanalysistest/polynomialvaluecalculatortest.py b/solventmapcreator/test/polynomialanalysistest/polynomialvaluecalculatortest.py index 5035ffba1368f8e6a602c206e7cf12b2aca54973..21cb44aaa5ca8a11680bc1e00ab3788f83ffdbd5 100644 --- a/solventmapcreator/test/polynomialanalysistest/polynomialvaluecalculatortest.py +++ b/solventmapcreator/test/polynomialanalysistest/polynomialvaluecalculatortest.py @@ -37,6 +37,9 @@ class PolynomialValueCalculatorTestCase(unittest.TestCase): expected_array2 = np.array([4.5, 1.5, 0.5, 1.5, 4.5]) actual_array2 = polyvalcalc.calculate_polynomial_values(self.input_array, self.poly_coeff_dict["positive"]) np.testing.assert_array_almost_equal(expected_array2, actual_array2) + expected_value = -0.5 + actual_value = polyvalcalc.calculate_polynomial_values(-1.0, self.poly_coeff_dict) + self.assertAlmostEqual(expected_value, actual_value) def test_calculate_poly_value_for_array_from_dict(self): """Test to see if expected array iss produced. """