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;
82pub mod random;
83mod slice_container;
84mod strings;
85mod sum_products;
86mod untyped_array;
87
88pub use ndarray;
89pub use pyo3;
90
91#[cfg(feature = "nalgebra")]
92pub use nalgebra;
93
94pub use crate::array::{
95 get_array_module, PyArray, PyArray0, PyArray0Methods, PyArray1, PyArray2, PyArray3, PyArray4,
96 PyArray5, PyArray6, PyArrayDyn, PyArrayMethods,
97};
98pub use crate::array_like::{
99 AllowTypeChange, PyArrayLike, PyArrayLike0, PyArrayLike1, PyArrayLike2, PyArrayLike3,
100 PyArrayLike4, PyArrayLike5, PyArrayLike6, PyArrayLikeDyn, TypeMustMatch,
101};
102pub use crate::borrow::{
103 PyReadonlyArray, PyReadonlyArray0, PyReadonlyArray1, PyReadonlyArray2, PyReadonlyArray3,
104 PyReadonlyArray4, PyReadonlyArray5, PyReadonlyArray6, PyReadonlyArrayDyn, PyReadwriteArray,
105 PyReadwriteArray0, PyReadwriteArray1, PyReadwriteArray2, PyReadwriteArray3, PyReadwriteArray4,
106 PyReadwriteArray5, PyReadwriteArray6, PyReadwriteArrayDyn,
107};
108pub use crate::convert::{IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
109pub use crate::dtype::{dtype, Complex32, Complex64, Element, PyArrayDescr, PyArrayDescrMethods};
110pub use crate::error::{AsSliceError, BorrowError, FromVecError};
111pub use crate::npyffi::{PY_ARRAY_API, PY_UFUNC_API};
112pub use crate::strings::{PyFixedString, PyFixedUnicode};
113pub use crate::sum_products::{dot, einsum, inner};
114pub use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods};
115
116pub use ndarray::{array, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
117
118pub mod prelude {
128 pub use crate::array::{PyArray0Methods, PyArrayMethods};
129 pub use crate::convert::{IntoPyArray, ToPyArray};
130 pub use crate::dtype::PyArrayDescrMethods;
131 pub use crate::untyped_array::PyUntypedArrayMethods;
132}
133
134#[deprecated(note = "use AsSliceError instead", since = "0.28.0")]
137pub type NonContiguousError = AsSliceError;
138
139#[cfg(doctest)]
140mod doctest {
141 macro_rules! doc_comment {
142 ($doc_string:expr, $mod_name:ident) => {
143 #[doc = $doc_string]
144 mod $mod_name {}
145 };
146 }
147 doc_comment!(include_str!("../README.md"), readme);
148}
149
150#[cold]
151#[inline(always)]
152fn cold() {}
153
154#[macro_export]
174macro_rules! pyarray {
175 ($py: ident, $([$([$($x:expr),* $(,)*]),+ $(,)*]),+ $(,)*) => {{
176 $crate::IntoPyArray::into_pyarray($crate::array![$([$([$($x,)*],)*],)*], $py)
177 }};
178 ($py: ident, $([$($x:expr),* $(,)*]),+ $(,)*) => {{
179 $crate::IntoPyArray::into_pyarray($crate::array![$([$($x,)*],)*], $py)
180 }};
181 ($py: ident, $($x:expr),* $(,)*) => {{
182 $crate::IntoPyArray::into_pyarray($crate::array![$($x,)*], $py)
183 }};
184}
185
186#[cfg(all(not(Py_3_15), Py_GIL_DISABLED, target_pointer_width = "32"))]
187compile_error!("free-threaded Python on 32bit platforms is only supported from 3.15+");