From b5af0ed9b2b0802568d09bee5f09843d9323539e Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Tue, 3 Oct 2023 11:28:26 +0200 Subject: [PATCH] Add missing zero-dimensional type aliases for array borrows. --- src/borrow/mod.rs | 8 +++++++- src/lib.rs | 8 ++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/borrow/mod.rs b/src/borrow/mod.rs index 6f48c757e..fe2c685d1 100644 --- a/src/borrow/mod.rs +++ b/src/borrow/mod.rs @@ -167,7 +167,7 @@ use std::fmt; use std::ops::Deref; use ndarray::{ - ArrayView, ArrayViewMut, Dimension, IntoDimension, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, + ArrayView, ArrayViewMut, Dimension, IntoDimension, Ix0, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, }; use pyo3::{FromPyObject, PyAny, PyResult}; @@ -193,6 +193,9 @@ where array: &'py PyArray, } +/// Read-only borrow of a zero-dimensional array. +pub type PyReadonlyArray0<'py, T> = PyReadonlyArray<'py, T, Ix0>; + /// Read-only borrow of a one-dimensional array. pub type PyReadonlyArray1<'py, T> = PyReadonlyArray<'py, T, Ix1>; @@ -374,6 +377,9 @@ where array: &'py PyArray, } +/// Read-write borrow of a zero-dimensional array. +pub type PyReadwriteArray0<'py, T> = PyReadwriteArray<'py, T, Ix0>; + /// Read-write borrow of a one-dimensional array. pub type PyReadwriteArray1<'py, T> = PyReadwriteArray<'py, T, Ix1>; diff --git a/src/lib.rs b/src/lib.rs index 064226f17..1c8cec0cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -95,10 +95,10 @@ pub use crate::array::{ PyArray6, PyArrayDyn, }; pub use crate::borrow::{ - PyReadonlyArray, PyReadonlyArray1, PyReadonlyArray2, PyReadonlyArray3, PyReadonlyArray4, - PyReadonlyArray5, PyReadonlyArray6, PyReadonlyArrayDyn, PyReadwriteArray, PyReadwriteArray1, - PyReadwriteArray2, PyReadwriteArray3, PyReadwriteArray4, PyReadwriteArray5, PyReadwriteArray6, - PyReadwriteArrayDyn, + PyReadonlyArray, PyReadonlyArray0, PyReadonlyArray1, PyReadonlyArray2, PyReadonlyArray3, + PyReadonlyArray4, PyReadonlyArray5, PyReadonlyArray6, PyReadonlyArrayDyn, PyReadwriteArray, + PyReadwriteArray0, PyReadwriteArray1, PyReadwriteArray2, PyReadwriteArray3, PyReadwriteArray4, + PyReadwriteArray5, PyReadwriteArray6, PyReadwriteArrayDyn, }; pub use crate::convert::{IntoPyArray, NpyIndex, ToNpyDims, ToPyArray}; pub use crate::dtype::{dtype, Complex32, Complex64, Element, PyArrayDescr};