@@ -56,27 +56,29 @@ def test_set_muls_at_angle(inputs, expected):
5656 assert actual_muls_sorted == pytest .approx (expected_muls_sorted , rel = 1e-4 , abs = 1e-6 )
5757
5858
59- def test_compute_cve (mocker ):
59+ def _instantiate_test_do (mocker , yarray , name = "test" , scat_quantity = "x-ray" ):
60+ mocker_xarray = np .array ([90 , 90.1 , 90.2 ])
6061 mocker .patch ("diffpy.labpdfproc.functions.N_POINTS_ON_DIAMETER" , 4 )
61- mocker .patch ("diffpy.labpdfproc.functions.TTH_GRID" , np . array ([ 45 , 60 , 90 ]) )
62- input_pattern = Diffraction_object (wavelength = 1.54 )
63- input_pattern .insert_scattering_quantity (
64- np . array ([ 45 , 60 , 90 ]) ,
65- np . array ([ 2.2 , 3 , 4 ]) ,
62+ mocker .patch ("diffpy.labpdfproc.functions.TTH_GRID" , mocker_xarray )
63+ test_do = Diffraction_object (wavelength = 1.54 )
64+ test_do .insert_scattering_quantity (
65+ mocker_xarray ,
66+ yarray ,
6667 "tth" ,
67- scat_quantity = "x-ray" ,
68- name = "test" ,
68+ scat_quantity = scat_quantity ,
69+ name = name ,
6970 metadata = {"thing1" : 1 , "thing2" : "thing2" },
7071 )
72+ return test_do
73+
74+
75+ def test_compute_cve (mocker ):
76+ input_pattern = _instantiate_test_do (mocker , yarray = np .array ([1 , 1 , 1 ]))
7177 actual_abdo = compute_cve (input_pattern , mud = 1 , wavelength = 1.54 )
72- expected_abdo = Diffraction_object ()
73- expected_abdo .insert_scattering_quantity (
74- np .array ([45 , 60 , 90 ]),
75- np .array ([2.54253 , 2.52852 , 2.49717 ]),
76- "tth" ,
77- metadata = {"thing1" : 1 , "thing2" : "thing2" },
78+ expected_abdo = _instantiate_test_do (
79+ mocker ,
80+ yarray = np .array ([2.49717 , 2.49706 , 2.49695 ]),
7881 name = "absorption correction, cve, for test" ,
79- wavelength = 1.54 ,
8082 scat_quantity = "cve" ,
8183 )
8284 assert actual_abdo == expected_abdo
0 commit comments