(
x,
check_shape=True,
check_graph=True,
check_chunks=True,
check_ndim=True,
scheduler=None,
)
| 258 | |
| 259 | |
| 260 | def _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 | |
| 299 | def assert_eq( |
no test coverage detected