Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_reduced_intensity_profile_init(RedIntData):
ri = ReducedIntensityProfile(RedIntData)
assert isinstance(ri, ReducedIntensityProfile)
def test_damp_exponential(RedIntData):
ri = ReducedIntensityProfile(RedIntData)
ri.damp_exponential(b=1)
compare = np.array([[[0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00,
0.00000000e+00, 0.00000000e+00],
[1.00000000e+00, 3.67879441e-01, 1.83156389e-02, 1.23409804e-04,
1.12535175e-07, 1.38879439e-11, 2.31952283e-16, 5.24288566e-22,
1.60381089e-28, 6.63967720e-36]],
[[2.00000000e+00, 7.35758882e-01, 3.66312778e-02, 2.46819608e-04,
2.25070349e-07, 2.77758877e-11, 4.63904566e-16, 1.04857713e-21,
3.20762178e-28, 1.32793544e-35],
[3.00000000e+00, 1.10363832e+00, 5.49469167e-02, 3.70229412e-04,
3.37605524e-07, 4.16638316e-11, 6.95856849e-16, 1.57286570e-21,
4.81143267e-28, 1.99190316e-35]]])
assert np.allclose(ri, compare)
return
def test_get_reduced_intensity(red_int_generator):
elements = ['Cu']
fracs = [1]
red_int_generator.fit_atomic_scattering(elements=elements, fracs=fracs)
ri = red_int_generator.get_reduced_intensity()
assert isinstance(ri, ReducedIntensityProfile)
ri = red_int_generator.get_reduced_intensity(cutoff=[0,8])
assert isinstance(ri, ReducedIntensityProfile)
# better test needed here, an assert allclose or such at least
return
def test_signal_size():
spectrum = np.array([5., 4., 3., 2., 2., 1., 1., 1., 0., 0.])
ri = ReducedIntensityProfile(spectrum)
pdfgen = PDFGenerator(ri)
pdf = pdfgen.get_pdf(s_cutoff=[0, 10])
assert isinstance(pdf, PDFProfile)
ri = ReducedIntensityProfile([spectrum])
pdfgen = PDFGenerator(ri)
pdf = pdfgen.get_pdf(s_cutoff=[0, 10])
assert isinstance(pdf, PDFProfile)
ri = ReducedIntensityProfile([[spectrum]])
pdfgen = PDFGenerator(ri)
pdf = pdfgen.get_pdf(s_cutoff=[0, 10])
assert isinstance(pdf, PDFProfile)
ri = ReducedIntensityProfile([[[spectrum]]])
pdfgen = PDFGenerator(ri)
def test_get_reduced_intensity(red_int_generator):
elements = ['Cu']
fracs = [1]
red_int_generator.fit_atomic_scattering(elements=elements, fracs=fracs)
ri = red_int_generator.get_reduced_intensity()
assert isinstance(ri, ReducedIntensityProfile)
ri = red_int_generator.get_reduced_intensity(cutoff=[0,8])
assert isinstance(ri, ReducedIntensityProfile)
# better test needed here, an assert allclose or such at least
return
def reduced_intensity_profile():
data = np.ones((1, 10)) * np.arange(4).reshape(4, 1)
data = data.reshape(2, 2, 10)
ri = ReducedIntensityProfile(data)
return ri
def ri_model(request):
ri = ReducedIntensityProfile(request.param)
m = ri.create_model()
return m
def test_signal_size():
spectrum = np.array([5., 4., 3., 2., 2., 1., 1., 1., 0., 0.])
ri = ReducedIntensityProfile(spectrum)
pdfgen = PDFGenerator(ri)
pdf = pdfgen.get_pdf(s_cutoff=[0, 10])
assert isinstance(pdf, PDFProfile)
ri = ReducedIntensityProfile([spectrum])
pdfgen = PDFGenerator(ri)
pdf = pdfgen.get_pdf(s_cutoff=[0, 10])
assert isinstance(pdf, PDFProfile)
ri = ReducedIntensityProfile([[spectrum]])
pdfgen = PDFGenerator(ri)
pdf = pdfgen.get_pdf(s_cutoff=[0, 10])
assert isinstance(pdf, PDFProfile)
ri = ReducedIntensityProfile([[[spectrum]]])
pdfgen = PDFGenerator(ri)
pdf = pdfgen.get_pdf(s_cutoff=[0, 10])
assert pdf is None
def test_damp_low_q_region_erfc(RedIntData):
ri = ReducedIntensityProfile(RedIntData)
ri.damp_low_q_region_erfc(scale=20, offset=1.3)
compare = np.array([[[0., 0., 0., 0., 0.,
0., 0., 0., 0., 0.],
[0.03299603, 1., 1., 1., 1.,
1., 1., 1., 1., 1.]],
[[0.06599206, 2., 2., 2., 2.,
2., 2., 2., 2., 2.],
[0.09898808, 3., 3., 3., 3.,
3., 3., 3., 3., 3.]]])
assert np.allclose(ri, compare)
return