MCPcopy
hub / github.com/dask/dask / full_like

Function full_like

dask/array/creation.py:232–289  ·  view source on GitHub ↗

Return a full array with the same shape and type as a given array. Parameters ---------- a : array_like The shape and data-type of `a` define these same attributes of the returned array. fill_value : scalar Fill value. dtype : data-type, optional

(a, fill_value, order="C", dtype=None, chunks=None, name=None, shape=None)

Source from the content-addressed store, hash-verified

230
231
232def full_like(a, fill_value, order="C", dtype=None, chunks=None, name=None, shape=None):
233 """
234 Return a full array with the same shape and type as a given array.
235
236 Parameters
237 ----------
238 a : array_like
239 The shape and data-type of `a` define these same attributes of
240 the returned array.
241 fill_value : scalar
242 Fill value.
243 dtype : data-type, optional
244 Overrides the data type of the result.
245 order : {'C', 'F'}, optional
246 Whether to store multidimensional data in C- or Fortran-contiguous
247 (row- or column-wise) order in memory.
248 chunks : sequence of ints
249 The number of samples on each block. Note that the last block will have
250 fewer samples if ``len(array) % chunks != 0``.
251 name : str, optional
252 An optional keyname for the array. Defaults to hashing the input
253 keyword arguments.
254 shape : int or sequence of ints, optional.
255 Overrides the shape of the result.
256
257 Returns
258 -------
259 out : ndarray
260 Array of `fill_value` with the same shape and type as `a`.
261
262 See Also
263 --------
264 zeros_like : Return an array of zeros with shape and type of input.
265 ones_like : Return an array of ones with shape and type of input.
266 empty_like : Return an empty array with shape and type of input.
267 zeros : Return a new array setting values to zero.
268 ones : Return a new array setting values to one.
269 empty : Return a new uninitialized array.
270 full : Fill a new array.
271 """
272
273 a = asarray(a, name=False)
274 shape, chunks = _get_like_function_shapes_chunks(a, chunks, shape)
275
276 # if shape is nan we cannot rely on regular full function, we use
277 # generic map_blocks.
278 if np.isnan(shape).any():
279 return a.map_blocks(partial(np.full_like, dtype=(dtype or a.dtype)), fill_value)
280
281 return full(
282 shape,
283 fill_value,
284 dtype=(dtype or a.dtype),
285 order=order,
286 chunks=chunks,
287 name=name,
288 meta=a._meta,
289 )

Callers 1

constantFunction · 0.90

Calls 5

asarrayFunction · 0.90
fullFunction · 0.90
anyMethod · 0.45
map_blocksMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…