MCPcopy
hub / github.com/dask/dask / isnonzero

Function isnonzero

dask/array/routines.py:2129–2138  ·  view source on GitHub ↗

Handle special cases where conversion to bool does not work correctly. xref: https://github.com/numpy/numpy/issues/9479

(a)

Source from the content-addressed store, hash-verified

2127
2128
2129def isnonzero(a):
2130 """Handle special cases where conversion to bool does not work correctly.
2131 xref: https://github.com/numpy/numpy/issues/9479
2132 """
2133 try:
2134 np.zeros([], dtype=a.dtype).astype(bool)
2135 except ValueError:
2136 return a.map_blocks(_isnonzero, dtype=bool)
2137 else:
2138 return a.astype(bool)
2139
2140
2141@derived_from(np)

Callers 2

argwhereFunction · 0.85
count_nonzeroFunction · 0.85

Calls 3

astypeMethod · 0.45
zerosMethod · 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…