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

Function test_compute_total_spectrum2

pyxrf/core/tests/test_map_processing.py:526–543  ·  view source on GitHub ↗

Create an instance of Dask client in the 'compute_total_spectrum' function to test if it works

(tmpdir)

Source from the content-addressed store, hash-verified

524
525
526def test_compute_total_spectrum2(tmpdir):
527 """Create an instance of Dask client in the 'compute_total_spectrum' function to test if it works"""
528
529 # Start with dask array
530 data_shape = (7, 12, 20)
531 data_dask = da.random.random(data_shape, chunks=(2, 3, 4))
532
533 data_numpy = data_dask.compute()
534 total_spectrum_expected = np.sum(np.sum(data_numpy, axis=0), axis=0)
535
536 data = _create_xrf_data(data_dask, "dask_array", tmpdir=tmpdir)
537
538 # Run computations without the progress bar
539 total_spectrum = compute_total_spectrum(data, chunk_pixels=12)
540
541 npt.assert_array_almost_equal(
542 total_spectrum, total_spectrum_expected, err_msg="Total spectrum was computed incorrectly"
543 )
544
545
546# fmt: off

Callers

nothing calls this directly

Calls 2

compute_total_spectrumFunction · 0.90
_create_xrf_dataFunction · 0.85

Tested by

no test coverage detected