@@ -163,12 +163,20 @@ def test_diffraction_objects_equality(inputs1, inputs2, expected):
163
163
assert (do_1 == do_2 ) == expected
164
164
165
165
166
- def test_on_xtype ():
167
- do = DiffractionObject (wavelength = 2 * np .pi , xarray = np .array ([30 , 60 ]), yarray = np .array ([1 , 2 ]), xtype = "tth" )
168
- assert np .allclose (do .on_xtype ("tth" ), [np .array ([30 , 60 ]), np .array ([1 , 2 ])])
169
- assert np .allclose (do .on_xtype ("2theta" ), [np .array ([30 , 60 ]), np .array ([1 , 2 ])])
170
- assert np .allclose (do .on_xtype ("q" ), [np .array ([0.51764 , 1 ]), np .array ([1 , 2 ])])
171
- assert np .allclose (do .on_xtype ("d" ), [np .array ([12.13818 , 6.28319 ]), np .array ([1 , 2 ])])
166
+ @pytest .mark .parametrize (
167
+ "xtype, expected_xarray" ,
168
+ [
169
+ ("tth" , np .array ([30 , 60 ])),
170
+ ("2theta" , np .array ([30 , 60 ])),
171
+ ("q" , np .array ([0.51764 , 1 ])),
172
+ ("d" , np .array ([12.13818 , 6.28319 ])),
173
+ ],
174
+ )
175
+ def test_on_xtype (xtype , expected_xarray , do_minimal_tth ):
176
+ do = do_minimal_tth
177
+ actual_xrray , actual_yarray = do .on_xtype (xtype )
178
+ assert np .allclose (actual_xrray , expected_xarray )
179
+ assert np .allclose (actual_yarray , np .array ([1 , 2 ]))
172
180
173
181
174
182
def test_init_invalid_xtype ():
0 commit comments