MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / test_fitting_admm_fail

Function test_fitting_admm_fail

pyxrf/core/tests/test_fitting.py:396–415  ·  view source on GitHub ↗

r""" Test _fit_nnls for supported cases of failure

()

Source from the content-addressed store, hash-verified

394
395
396def test_fitting_admm_fail():
397 r"""
398 Test _fit_nnls for supported cases of failure
399 """
400 n_pts, n_refs, n_pixels = 10, 3, 5
401
402 spectra = np.zeros(shape=[n_pts]) # 1D instead of 2D
403 data_input = np.zeros(shape=[n_pts, n_refs])
404 with pytest.raises(AssertionError, match="Data array 'data' must have 2 dimensions"):
405 _fitting_admm(spectra, data_input)
406
407 spectra = np.zeros(shape=[n_pts, n_pixels])
408 data_input = np.zeros(shape=[n_pts]) # 1D instead of 2D
409 with pytest.raises(AssertionError, match="Data array 'ref_spectra' must have 2 dimensions"):
410 _fitting_admm(spectra, data_input)
411
412 spectra = np.zeros(shape=[n_pts - 1, n_pixels]) # Wrong number of data points
413 data_input = np.zeros(shape=[n_pts, n_refs])
414 with pytest.raises(AssertionError, match="number of spectrum points in data .+ do not match"):
415 _fitting_admm(spectra, data_input)
416
417
418# fmt: off

Callers

nothing calls this directly

Calls 1

_fitting_admmFunction · 0.90

Tested by

no test coverage detected