`from_collections` optimized for a single collection
(cls, name, layer, collection)
| 449 | |
| 450 | @classmethod |
| 451 | def _from_collection(cls, name, layer, collection): |
| 452 | """`from_collections` optimized for a single collection""" |
| 453 | if not is_dask_collection(collection): |
| 454 | raise TypeError(type(collection)) |
| 455 | |
| 456 | graph = collection.__dask_graph__() |
| 457 | if isinstance(graph, HighLevelGraph): |
| 458 | layers = ensure_dict(graph.layers, copy=True) |
| 459 | layers[name] = layer |
| 460 | deps = ensure_dict(graph.dependencies, copy=True) |
| 461 | deps[name] = set(collection.__dask_layers__()) |
| 462 | else: |
| 463 | key = _get_some_layer_name(collection) |
| 464 | layers = {name: layer, key: graph} |
| 465 | deps = {name: {key}, key: set()} |
| 466 | |
| 467 | return cls(layers, deps) |
| 468 | |
| 469 | @classmethod |
| 470 | def from_collections( |
no test coverage detected