Handle special cases where conversion to bool does not work correctly. xref: https://github.com/numpy/numpy/issues/9479
(a)
| 2127 | |
| 2128 | |
| 2129 | def 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) |
no test coverage detected
searching dependent graphs…