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

Function unpack_singleton

dask/array/core.py:4431–4444  ·  view source on GitHub ↗

>>> unpack_singleton([[[[1]]]]) 1 >>> unpack_singleton(np.array(np.datetime64('2000-01-01'))) array('2000-01-01', dtype='datetime64[D]')

(x)

Source from the content-addressed store, hash-verified

4429
4430
4431def unpack_singleton(x):
4432 """
4433
4434 >>> unpack_singleton([[[[1]]]])
4435 1
4436 >>> unpack_singleton(np.array(np.datetime64('2000-01-01')))
4437 array('2000-01-01', dtype='datetime64[D]')
4438 """
4439 while isinstance(x, (list, tuple)):
4440 try:
4441 x = x[0]
4442 except (IndexError, TypeError, KeyError):
4443 break
4444 return x
4445
4446
4447def block(arrays, allow_unknown_chunksizes=False):

Callers 2

finalizeFunction · 0.85
concatenate3Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected