FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 74364580 authored by M.D. Driver's avatar M.D. Driver
Browse files

add methods to read in files with split fitting.

parent 17be5336
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,14 @@ def parse_polynomial_data_file(filename):
data_in = read_polynomial_data_file(filename)
for line_list in data_in[1:]:
polynomial_data = read_polynomial_data_line(line_list)
polynomial_data_dict[polynomial_data["order"]] = polynomial_data
if "fit_range" in polynomial_data:
fit_range = polynomial_data.pop("fit_range")
if polynomial_data["order"] in polynomial_data_dict:
polynomial_data_dict[polynomial_data["order"]][fit_range] = polynomial_data
else:
polynomial_data_dict[polynomial_data["order"]] = {fit_range:polynomial_data}
else:
polynomial_data_dict[polynomial_data["order"]] = polynomial_data
return polynomial_data_dict
def read_polynomial_data_file(filename):
......
......@@ -75,6 +75,29 @@ class PolynomialDataReaderTestCase(unittest.TestCase):
self.assertEqual(expected_dictionary[key], actual_dictionary[key])
else:
np.testing.assert_array_almost_equal(expected_dictionary[key], actual_dictionary[key])
expected_poly_dict2 = {1:{"positive":self.expected_data_by_solvent_id["expected,poly,fit"][1],
"negative":self.expected_data_by_solvent_id["expected,poly,fit"][1]}}
actual_poly_dict2 = polynomialdatareader.parse_polynomial_data_file("resources/expected_poly_fit2.csv")
for poly_order in expected_poly_dict2.keys():
expected_mix_dictionary = expected_poly_dict2[poly_order]
actual_mix_dictionary = actual_poly_dict2[poly_order]
self.assertListEqual(sorted(expected_mix_dictionary.keys()),
sorted(actual_mix_dictionary.keys()))
for key in expected_mix_dictionary.keys():
actual_dictionary = actual_mix_dictionary[key]
expected_dictionary = expected_mix_dictionary[key]
self.assertListEqual(sorted(expected_dictionary.keys()),
sorted(actual_dictionary.keys()))
for key in expected_dictionary.keys():
if key == "RMSE":
self.assertAlmostEqual(expected_dictionary[key],
actual_dictionary[key])
elif key == "order":
self.assertEqual(expected_dictionary[key],
actual_dictionary[key])
else:
np.testing.assert_array_almost_equal(expected_dictionary[key],
actual_dictionary[key])
def test_read_polynomial_data_file(self):
"""Test to see if file is read as expected.
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment