MCPcopy
hub / github.com/pydata/xarray / test_dataarray_pickle

Method test_dataarray_pickle

xarray/tests/test_dask.py:728–744  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

726 assert kernel_call_count == 0 # should not evaluate dask array
727
728 def test_dataarray_pickle(self):
729 # Test that pickling/unpickling converts the dask backend
730 # to numpy in neither the data variable nor the non-index coords
731 data = build_dask_array("data")
732 nonindex_coord = build_dask_array("coord")
733 a1 = DataArray(data, dims=["x"], coords={"y": ("x", nonindex_coord)})
734 a1.compute()
735 assert not a1._in_memory
736 assert not a1.coords["y"]._in_memory
737 assert kernel_call_count == 2
738 a2 = pickle.loads(pickle.dumps(a1))
739 assert kernel_call_count == 2
740 assert_identical(a1, a2)
741 assert not a1._in_memory
742 assert not a2._in_memory
743 assert not a1.coords["y"]._in_memory
744 assert not a2.coords["y"]._in_memory
745
746 def test_dataset_pickle(self):
747 # Test that pickling/unpickling converts the dask backend

Callers

nothing calls this directly

Calls 4

computeMethod · 0.95
DataArrayClass · 0.90
assert_identicalFunction · 0.90
build_dask_arrayFunction · 0.85

Tested by

no test coverage detected