>>> unpack_singleton([[[[1]]]]) 1 >>> unpack_singleton(np.array(np.datetime64('2000-01-01'))) array('2000-01-01', dtype='datetime64[D]')
(x)
| 4434 | |
| 4435 | |
| 4436 | def unpack_singleton(x): |
| 4437 | """ |
| 4438 | |
| 4439 | >>> unpack_singleton([[[[1]]]]) |
| 4440 | 1 |
| 4441 | >>> unpack_singleton(np.array(np.datetime64('2000-01-01'))) |
| 4442 | array('2000-01-01', dtype='datetime64[D]') |
| 4443 | """ |
| 4444 | while isinstance(x, (list, tuple)): |
| 4445 | try: |
| 4446 | x = x[0] |
| 4447 | except (IndexError, TypeError, KeyError): |
| 4448 | break |
| 4449 | return x |
| 4450 | |
| 4451 | |
| 4452 | def block(arrays, allow_unknown_chunksizes=False): |
no outgoing calls
no test coverage detected
searching dependent graphs…