Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use
ensure_ndarray
in a few more places (#506)
* Use `ensure_ndarray` to check `chunk`'s type Instead of checking to see if `chunk` is an `ndarray`, use `ensure_ndarray` to get an `ndarray` viewing the underlying data in `chunk`. This way we know attributes like `dtype` are available and can be checked easily. Also makes this a bit more friendly with other array-like types. * Use `ensure_ndarray` on `out` Since we are interested in getting an `ndarray` representing the buffer within `out` for writing into, go ahead and use `ensure_ndarray` to coerce the underlying buffer into an `ndarray`. This way we can avoid a needless check and just write into any array-like value for `out` that is provided. * Handle `out` when it doesn't supply a buffer Appears that `out` can also be a Zarr `Array` or any other array-like that does not expose a buffer, but does allow writing into. In these cases `ensure_ndarray` will fail as there is not an underlying buffer that can be used with an `ndarray`. To also handle this case, catch the `TypeError` that `ensure_ndarray` will raise in this case and use that to indicate whether `out` is now an `ndarray` or not. This allows us to continue to write into arbitrary buffers, but also correctly handle objects that do not expose buffers. * Adds release notes entry
- Loading branch information