(self)
| 93 | return self.operand("asarray") |
| 94 | |
| 95 | def _layer(self): |
| 96 | lock = self.operand("lock") |
| 97 | if lock is True: |
| 98 | lock = SerializableLock() |
| 99 | |
| 100 | is_ndarray = type(self.array) in (np.ndarray, np.ma.core.MaskedArray) |
| 101 | is_single_block = all(len(c) == 1 for c in self.chunks) |
| 102 | # Always use the getter for h5py etc. Not using isinstance(x, np.ndarray) |
| 103 | # because np.matrix is a subclass of np.ndarray. |
| 104 | if is_ndarray and not is_single_block and not lock: |
| 105 | # eagerly slice numpy arrays to prevent memory blowup |
| 106 | # GH5367, GH5601 |
| 107 | slices = slices_from_chunks(self.chunks) |
| 108 | keys = product([self._name], *(range(len(bds)) for bds in self.chunks)) |
| 109 | values = [self.array[slc] for slc in slices] |
| 110 | dsk = dict(zip(keys, values)) |
| 111 | elif is_ndarray and is_single_block: |
| 112 | # No slicing needed |
| 113 | dsk = {(self._name,) + (0,) * self.array.ndim: self.array} |
| 114 | else: |
| 115 | getitem = self.operand("getitem") |
| 116 | if getitem is None: |
| 117 | if self.operand("fancy"): |
| 118 | getitem = getter |
| 119 | else: |
| 120 | getitem = getter_nofancy |
| 121 | |
| 122 | dsk = graph_from_arraylike( |
| 123 | self.array, |
| 124 | chunks=self.chunks, |
| 125 | shape=self.array.shape, |
| 126 | name=self._name, |
| 127 | lock=lock, |
| 128 | getitem=getitem, |
| 129 | asarray=self.asarray_arg, |
| 130 | inline_array=self.inline_array, |
| 131 | dtype=self.array.dtype, |
| 132 | ) |
| 133 | return dict(dsk) # this comes as a legacy HLG for now |
| 134 | |
| 135 | def __str__(self): |
| 136 | return "FromArray(...)" |
nothing calls this directly
no test coverage detected