def test_PESCoreLineShape_shirley(): core_line = PESCoreLineShape(A=10, FWHM=1.5, origin=0.5) core_line.Shirley = True core_line.shirley.value = 0.01 x = np.linspace(-5, 15, 10) np.testing.assert_allclose( core_line.function(x), np.array([ 0.144159014, 0.504843825, 7.16330182, 6.57790840, 0.290720786, 6.13260758e-04, 6.17204245e-08, 2.96359844e-13, 6.78916184e-20, 7.42026292e-28 ])) np.testing.assert_allclose(core_line.function(x), core_line.function_nd(x))
def test_PESCoreLineShape_function_nd(Shirley): A, FWHM, origin = 10, 1.5, 0. core_line = PESCoreLineShape(A=A, FWHM=FWHM, origin=origin) core_line.Shirley = Shirley core_line.shirley.value = 0.01 if Shirley else 0.0 x = np.linspace(-5, 15, 1000) s = hs.signals.Signal1D(np.array([x] * 2)) # Manually set to test function_nd core_line._axes_manager = s.axes_manager core_line._create_arrays() core_line.A.map['values'] = [A] * 2 core_line.FWHM.map['values'] = [FWHM] * 2 core_line.origin.map['values'] = [origin] * 2 core_line.shirley.map['values'] = [core_line.shirley.value] * 2 values = core_line.function_nd(x) assert values.shape == (2, len(x)) for v in values: np.testing.assert_allclose(v, core_line.function(x), rtol=0.5)