1#![cfg_attr(
16 feature = "nalgebra",
17 doc = "Integration with [`nalgebra`] is provided via an implementation of [`ToPyArray`] for [`nalgebra::Matrix`] to convert nalgebra matrices into NumPy arrays
18as well as the [`PyReadonlyArray::try_as_matrix`] and [`PyReadwriteArray::try_as_matrix_mut`] methods to treat NumPy array as nalgebra matrix slices.
19"
20)]
21#![cfg_attr(feature = "nalgebra", doc = "```")]
39#![cfg_attr(not(feature = "nalgebra"), doc = "```rust,ignore")]
40#![doc = "```"]
69#![deny(missing_docs)]
73
74pub mod array;
75mod array_like;
76pub mod borrow;
77pub mod convert;
78pub mod datetime;
79mod dtype;
80mod error;
81pub mod npyffi;
82mod slice_container;
83mod strings;
84mod sum_products;
85mod untyped_array;
86
87pub use ndarray;
88pub use pyo3;
89
90#[cfg(feature = "nalgebra")]
91pub use nalgebra;
92
93pub use crate::array::{
94 get_array_module, PyArray, PyArray0, PyArray0Methods, PyArray1, PyArray2, PyArray3, PyArray4,
95 PyArray5, PyArray6, PyArrayDyn, PyArrayMethods,
96};
97pub use crate::array_like::{
98 AllowTypeChange, PyArrayLike, PyArrayLike0, PyArrayLike1, PyArrayLike2, PyArrayLike3,
99 PyArrayLike4, PyArrayLike5, PyArrayLike6, PyArrayLikeDyn, TypeMustMatch,
100};
101pub use crate::borrow::{
102 PyReadonlyArray, PyReadonlyArray0, PyReadonlyArray1, PyReadonlyArray2, PyReadonlyArray3,
103 PyReadonlyArray4, PyReadonlyArray5, PyReadonlyArray6, PyReadonlyArrayDyn, PyReadwriteArray,
104 PyReadwriteArray0, PyReadwriteArray1, PyReadwriteArray2, PyReadwriteArray3, PyReadwriteArray4,
105 PyReadwriteArray5, PyReadwriteArray6, PyReadwriteArrayDyn,
106};
107pub use crate::convert::{IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
108pub use crate::dtype::{dtype, Complex32, Complex64, Element, PyArrayDescr, PyArrayDescrMethods};
109pub use crate::error::{AsSliceError, BorrowError, FromVecError};
110pub use crate::npyffi::{PY_ARRAY_API, PY_UFUNC_API};
111pub use crate::strings::{PyFixedString, PyFixedUnicode};
112pub use crate::sum_products::{dot, einsum, inner};
113pub use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods};
114
115pub use ndarray::{array, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
116
117pub mod prelude {
127 pub use crate::array::{PyArray0Methods, PyArrayMethods};
128 pub use crate::convert::{IntoPyArray, ToPyArray};
129 pub use crate::dtype::PyArrayDescrMethods;
130 pub use crate::untyped_array::PyUntypedArrayMethods;
131}
132
133#[deprecated(note = "use AsSliceError instead", since = "0.28.0")]
136pub type NonContiguousError = AsSliceError;
137
138#[cfg(doctest)]
139mod doctest {
140 macro_rules! doc_comment {
141 ($doc_string:expr, $mod_name:ident) => {
142 #[doc = $doc_string]
143 mod $mod_name {}
144 };
145 }
146 doc_comment!(include_str!("../README.md"), readme);
147}
148
149#[cold]
150#[inline(always)]
151fn cold() {}
152
153#[macro_export]
173macro_rules! pyarray {
174 ($py: ident, $([$([$($x:expr),* $(,)*]),+ $(,)*]),+ $(,)*) => {{
175 $crate::IntoPyArray::into_pyarray($crate::array![$([$([$($x,)*],)*],)*], $py)
176 }};
177 ($py: ident, $([$($x:expr),* $(,)*]),+ $(,)*) => {{
178 $crate::IntoPyArray::into_pyarray($crate::array![$([$($x,)*],)*], $py)
179 }};
180 ($py: ident, $($x:expr),* $(,)*) => {{
181 $crate::IntoPyArray::into_pyarray($crate::array![$($x,)*], $py)
182 }};
183}