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

Function test_prepare_xrf_data

pyxrf/core/tests/test_map_processing.py:375–390  ·  view source on GitHub ↗
(tmpdir, data_representation)

Source from the content-addressed store, hash-verified

373@pytest.mark.parametrize("data_representation", ["numpy_array", "dask_array", "hdf5_file_dset"])
374# fmt: on
375def test_prepare_xrf_data(tmpdir, data_representation):
376 # Start with dask array
377 data_shape = (7, 12, 20)
378 data_dask = da.random.random(data_shape, chunks=(2, 3, 4))
379 data_numpy = data_dask.compute()
380
381 data = _create_xrf_data(data_dask, data_representation, tmpdir)
382 data, file_obj = prepare_xrf_map(data, chunk_pixels=12, n_chunks_min=4)
383
384 assert (
385 data.chunksize[0] * data.chunksize[1] == 12
386 ), f"Dataset was not properly chunked: data.chunksize={data.chunksize}"
387
388 npt.assert_array_almost_equal(
389 data.compute(), data_numpy, err_msg="Prepared dataset is different from the original"
390 )
391
392
393def test_prepare_xrf_data_hdf5_not_chunked(tmpdir):

Callers

nothing calls this directly

Calls 2

prepare_xrf_mapFunction · 0.90
_create_xrf_dataFunction · 0.85

Tested by

no test coverage detected