Skip to content

Commit 9544243

Browse files
committed
add set_parsed_profile test with ProfileParser
1 parent 97cfc58 commit 9544243

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/diffpy/srfit/fitbase/profile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def load_parsed_data(self, parser):
159159
160160
This sets the xobs, yobs, dyobs arrays as well as the metadata.
161161
"""
162-
x, y, junk, dy = parser.get_data()
162+
x, y, dx, dy = parser.get_data()
163163
self.meta = dict(parser.get_metadata())
164164
self.set_observed_profile(x, y, dy)
165165
return

tests/test_profile.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from numpy import allclose, arange, array, array_equal, ones_like
2323

2424
from diffpy.srfit.exceptions import SrFitError
25+
from diffpy.srfit.fitbase import ProfileParser
2526
from diffpy.srfit.fitbase.profile import Profile
2627

2728

@@ -307,5 +308,20 @@ def _test(p):
307308
return
308309

309310

311+
def test_load_parsed_data(parser_datafiles):
312+
"""Test the load_parsed_data method."""
313+
prof = Profile()
314+
parser = ProfileParser()
315+
datafile = parser_datafiles / "four_col.gr"
316+
parser.parse_file(datafile)
317+
prof.load_parsed_data(parser)
318+
expected_xobs = [1.0, 1.1, 1.2]
319+
expected_yobs = [2.0, 2.1, 2.2]
320+
expected_dyobs = [0.2, 0.4, 0.6]
321+
assert prof.xobs.tolist() == expected_xobs
322+
assert prof.yobs.tolist() == expected_yobs
323+
assert prof.dyobs.tolist() == expected_dyobs
324+
325+
310326
if __name__ == "__main__":
311327
unittest.main()

0 commit comments

Comments
 (0)