@@ -56,27 +56,29 @@ def test_set_muls_at_angle(inputs, expected):
56
56
assert actual_muls_sorted == pytest .approx (expected_muls_sorted , rel = 1e-4 , abs = 1e-6 )
57
57
58
58
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 ])
60
61
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 ,
66
67
"tth" ,
67
- scat_quantity = "x-ray" ,
68
- name = "test" ,
68
+ scat_quantity = scat_quantity ,
69
+ name = name ,
69
70
metadata = {"thing1" : 1 , "thing2" : "thing2" },
70
71
)
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 ]))
71
77
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 ]),
78
81
name = "absorption correction, cve, for test" ,
79
- wavelength = 1.54 ,
80
82
scat_quantity = "cve" ,
81
83
)
82
84
assert actual_abdo == expected_abdo
0 commit comments