@@ -43,16 +43,52 @@ def testInit(self):
4343 self .assertEqual (profile .meta , {})
4444 return
4545
46+ def test_set_observed_profile (self ):
47+ """Test the set_observed_profile method."""
48+ # Make a profile with defined dy
49+
50+ x = arange (0 , 10 , 0.1 )
51+ y = x
52+ dy = x
53+
54+ prof = self .profile
55+ prof .set_observed_profile (x , y , dy )
56+
57+ self .assertTrue (array_equal (x , prof .xobs ))
58+ self .assertTrue (array_equal (y , prof .yobs ))
59+ self .assertTrue (array_equal (dy , prof .dyobs ))
60+
61+ # Make a profile with undefined dy
62+ x = arange (0 , 10 , 0.1 )
63+ y = x
64+ dy = None
65+
66+ self .profile .set_observed_profile (x , y , dy )
67+
68+ self .assertTrue (array_equal (x , prof .xobs ))
69+ self .assertTrue (array_equal (y , prof .yobs ))
70+ self .assertTrue (array_equal (ones_like (prof .xobs ), prof .dyobs ))
71+
72+ # Get the ranged profile to make sure its the same
73+ self .assertTrue (array_equal (x , prof .x ))
74+ self .assertTrue (array_equal (y , prof .y ))
75+ self .assertTrue (array_equal (ones_like (prof .xobs ), prof .dy ))
76+
77+ return
78+
4679 def testSetObservedProfile (self ):
47- """Test the setObservedProfile method."""
80+ """Test the deprecated setObservedProfile method.
81+
82+ Remove this test when setObservedProfile is removed in 4.0.0.
83+ """
4884 # Make a profile with defined dy
4985
5086 x = arange (0 , 10 , 0.1 )
5187 y = x
5288 dy = x
5389
5490 prof = self .profile
55- prof .setObservedProfile (x , y , dy )
91+ prof .set_observed_profile (x , y , dy )
5692
5793 self .assertTrue (array_equal (x , prof .xobs ))
5894 self .assertTrue (array_equal (y , prof .yobs ))
@@ -88,7 +124,7 @@ def testSetCalculationRange(self):
88124 self .assertRaises (AttributeError , prof .setCalculationRange , 0 , 5 )
89125 self .assertRaises (AttributeError , prof .setCalculationRange , 0 , 5 , 0.2 )
90126 # assign data
91- prof .setObservedProfile (x , y , dy )
127+ prof .set_observed_profile (x , y , dy )
92128 # Test normal execution w/o arguments
93129 self .assertTrue (array_equal (x , prof .x ))
94130 self .assertTrue (array_equal (y , prof .y ))
@@ -172,7 +208,7 @@ def testSetCalculationPoints(self):
172208 self .assertTrue (array_equal (xcalc , prof .x ))
173209
174210 # Add the data. This should change the bounds of the calculation array.
175- prof .setObservedProfile (x , y , dy )
211+ prof .set_observed_profile (x , y , dy )
176212 self .assertTrue (array_equal (arange (3 , 10.1 , 0.2 ), prof .x ))
177213
178214 return
@@ -183,7 +219,7 @@ def test_savetxt(self):
183219 self .assertRaises (SrFitError , prof .savetxt , "foo" )
184220 xobs = arange (- 2 , 3.01 , 0.25 )
185221 yobs = xobs ** 2
186- prof .setObservedProfile (xobs , yobs )
222+ prof .set_observed_profile (xobs , yobs )
187223 prof .ycalc = yobs .copy ()
188224 fp = io .BytesIO ()
189225 prof .savetxt (fp )
0 commit comments