MCPcopy Create free account
hub / github.com/dask/dask / _get_dt_meta_computed

Function _get_dt_meta_computed

dask/array/utils.py:260–296  ·  view source on GitHub ↗
(
    x,
    check_shape=True,
    check_graph=True,
    check_chunks=True,
    check_ndim=True,
    scheduler=None,
)

Source from the content-addressed store, hash-verified

258
259
260def _get_dt_meta_computed(
261 x,
262 check_shape=True,
263 check_graph=True,
264 check_chunks=True,
265 check_ndim=True,
266 scheduler=None,
267):
268 x_original = x
269 x_meta = None
270 x_computed = None
271
272 if is_dask_collection(x) and is_arraylike(x):
273 assert x.dtype is not None
274 adt = x.dtype
275 if check_graph:
276 _check_dsk(x.dask)
277 x_meta = getattr(x, "_meta", None)
278 if check_chunks:
279 # Replace x with persisted version to avoid computing it twice.
280 x = _check_chunks(x, check_ndim=check_ndim, scheduler=scheduler)
281 x = x.compute(scheduler=scheduler)
282 x_computed = x
283 if hasattr(x, "todense"):
284 x = x.todense()
285 if not hasattr(x, "dtype"):
286 x = np.array(x, dtype="O")
287 if _not_empty(x):
288 assert x.dtype == x_original.dtype
289 if check_shape:
290 assert_eq_shape(x_original.shape, x.shape, check_nan=False)
291 else:
292 if not hasattr(x, "dtype"):
293 x = np.array(x, dtype="O")
294 adt = getattr(x, "dtype", None)
295
296 return x, adt, x_meta, x_computed
297
298
299def assert_eq(

Callers 1

assert_eqFunction · 0.85

Calls 7

is_dask_collectionFunction · 0.90
is_arraylikeFunction · 0.90
_check_dskFunction · 0.85
_check_chunksFunction · 0.85
_not_emptyFunction · 0.85
assert_eq_shapeFunction · 0.85
computeMethod · 0.45

Tested by

no test coverage detected