@@ -232,34 +232,38 @@ def test_diffraction_objects_equality(inputs1, inputs2, expected):
232232
233233
234234def test_q_to_tth ():
235- actual = Diffraction_object (wavelength = 0.71 )
236- setattr (actual , "on_q" , [[0 , 4.58087 ], [1 , 1 ]])
235+ actual = Diffraction_object (wavelength = 4 * np . pi )
236+ setattr (actual , "on_q" , [[0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ], [1 , 2 , 3 , 4 , 5 , 6 ]])
237237 actual_tth = actual .q_to_tth ()
238- expected_tth = [0 , 30 ]
238+ # expected tth values are 2 * arcsin(q)
239+ expected_tth = [0 , 23.07392 , 47.15636 , 73.73980 , 106.26020 , 180 ]
239240 assert np .allclose (actual_tth , expected_tth )
240241
241242
242243def test_tth_to_q ():
243- actual = Diffraction_object (wavelength = 0.71 )
244- setattr (actual , "on_tth" , [[0 , 30 ], [1 , 1 ]])
244+ actual = Diffraction_object (wavelength = 4 * np . pi )
245+ setattr (actual , "on_tth" , [[0 , 30 , 60 , 90 , 120 , 180 ], [1 , 2 , 3 , 4 , 5 , 6 ]])
245246 actual_q = actual .tth_to_q ()
246- expected_q = [0 , 4.58087 ]
247+ # expected q vales are sin15, sin30, sin45, sin60, sin90
248+ expected_q = [0 , 0.258819 , 0.5 , 0.707107 , 0.866025 , 1 ]
247249 assert np .allclose (actual_q , expected_q )
248250
249251
250252def test_q_to_d ():
251253 actual = Diffraction_object (wavelength = 0.71 )
252- setattr (actual , "on_q" , [[0 , 4.58087 ], [1 , 1 ]])
254+ setattr (actual , "on_q" , [[0 , np . pi , 2 * np . pi , 3 * np . pi , 4 * np . pi , 5 * np . pi ], [1 , 2 , 3 , 4 , 5 , 6 ]])
253255 actual_d = actual .q_to_d ()
254- expected_d = [62831853071.8 , 1.37161 ]
256+ # expected d values are DMAX=100, 2/1, 2/2, 2/3, 2/4, 2/5, and in reverse order
257+ expected_d = [0.4 , 0.5 , 0.66667 , 1 , 2 , 100 ]
255258 assert np .allclose (actual_d , expected_d )
256259
257260
258261def test_d_to_q ():
259- actual = Diffraction_object (wavelength = 0.71 )
260- setattr (actual , "on_d" , [[1e10 , 1.37161 ], [1 , 1 ]])
262+ actual = Diffraction_object (wavelength = 1 )
263+ setattr (actual , "on_d" , [[0 , np . pi , 2 * np . pi , 3 * np . pi , 4 * np . pi , 5 * np . pi ], [1 , 2 , 3 , 4 , 5 , 6 ]])
261264 actual_q = actual .d_to_q ()
262- expected_q = [0 , 4.58087 ]
265+ # expected q values are QMAX=40, 2/1, 2/2, 2/3, 2/4, 2/5, and in reverse order
266+ expected_q = [0.4 , 0.5 , 0.66667 , 1 , 2 , 40 ]
263267 assert np .allclose (actual_q , expected_q )
264268
265269
0 commit comments