>>> unpack_singleton([[[[1]]]]) 1 >>> unpack_singleton(np.array(np.datetime64('2000-01-01'))) array('2000-01-01', dtype='datetime64[D]')
(x)
| 4429 | |
| 4430 | |
| 4431 | def 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 | |
| 4447 | def block(arrays, allow_unknown_chunksizes=False): |
no outgoing calls
no test coverage detected