commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
72ec0e29769f74da55566ae44b28757e782e45b9 | David Hewitt | 2024-09-23T20:41:26 | Apply suggestions from code review | diff --git a/src/npyffi/mod.rs b/src/npyffi/mod.rs
index 8691c5bf..8a75dff8 100644
--- a/src/npyffi/mod.rs
+++ b/src/npyffi/mod.rs
@@ -39,7 +39,8 @@ fn get_numpy_api<'py>(
Ok(api)
}
-fn is_numpy_2<'py>(py: Python<'py>) -> bool {
+/// Returns whether the runtime `numpy` version is 2.0 or greater.
+pub fn is_nump... | 1 | 2 | 1 |
f70a7f96de09dc78f0fc28d40f3a7fd7b5378100 | Matthew Neeley | 2024-09-20T19:02:14 | Fixes from review | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index a4ce9008..7074f61c 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -342,12 +342,7 @@ impl PyArrayAPI {
dst: *mut PyArrayObject,
src: *mut PyArrayObject,
) -> c_int {
- let api_version = *API_VERSION.get(py).expect("... | 3 | 33 | 49 |
4f5ea844a2411e86fd5dad405add8d1d94cca9a0 | Matthew Neeley | 2024-08-31T18:47:23 | Simplify impl_api macro | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 2e4192fc..a4ce9008 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -68,7 +68,7 @@ impl PyArrayAPI {
impl_api![47; PyArray_Zero(arr: *mut PyArrayObject) -> *mut c_char];
impl_api![48; PyArray_One(arr: *mut PyArrayObject) -> *mut c_char]... | 2 | 74 | 87 |
b05b66400d4335660d6f7cbafbe0ac586acc2c01 | Matthew Neeley | 2024-08-31T18:10:03 | Fixes from @adamreichold review | diff --git a/src/dtype.rs b/src/dtype.rs
index bb2dee2c..c3e924d1 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -254,7 +254,10 @@ impl PyArrayDescr {
///
/// Equivalent to [`numpy.dtype.flags`][dtype-flags].
///
+ /// In numpy 2 the flags field was widened to allow for more flags.
+ ///
/// ... | 2 | 29 | 38 |
b7456ea4de596e6a5c8b591ed47f980ce06463c3 | Matthew Neeley | 2024-08-31T16:32:34 | Make size and buf fields public in npy_static_string | diff --git a/src/npyffi/objects.rs b/src/npyffi/objects.rs
index 03c00c1a..7cbc4dbd 100644
--- a/src/npyffi/objects.rs
+++ b/src/npyffi/objects.rs
@@ -569,8 +569,8 @@ pub type PyArray_DTypeMeta = PyTypeObject;
#[repr(C)]
#[derive(Clone, Copy)]
pub struct npy_static_string {
- size: usize,
- buf: *const c_char,... | 1 | 2 | 2 |
4e9d8a52d786177fed27813c7bc094322b7c6744 | Adam Reichold | 2024-07-21T12:49:31 | Use explicit patterns so exhaustiveness checking works, but avoid open bounds for the MSRV build. | diff --git a/src/npyffi/mod.rs b/src/npyffi/mod.rs
index b945b4cc..68ccf361 100644
--- a/src/npyffi/mod.rs
+++ b/src/npyffi/mod.rs
@@ -47,7 +47,7 @@ fn get_numpy_api<'py>(
const fn api_version_to_numpy_version_range(api_version: c_uint) -> (&'static str, &'static str) {
match api_version {
- api_version ... | 1 | 2 | 2 |
25e6f2943a4f18d9c0109495099bd7869350c2ba | Adam Reichold | 2024-07-21T12:48:51 | Remove residual numpy-1/2 feature usage. | diff --git a/src/npyffi/objects.rs b/src/npyffi/objects.rs
index 980b4081..03c00c1a 100644
--- a/src/npyffi/objects.rs
+++ b/src/npyffi/objects.rs
@@ -378,10 +378,7 @@ pub struct PyUFuncObject {
pub type_resolver: PyUFunc_TypeResolutionFunc,
pub legacy_inner_loop_selector: PyUFunc_LegacyInnerLoopSelectionFunc... | 1 | 0 | 3 |
05bec37270a2ed05e162cef3e730b602b61eed4c | Adam Reichold | 2024-07-21T12:33:04 | Avoid half-open range patterns to appease our MSRV build. | diff --git a/src/npyffi/mod.rs b/src/npyffi/mod.rs
index cb23c0eb..b945b4cc 100644
--- a/src/npyffi/mod.rs
+++ b/src/npyffi/mod.rs
@@ -47,7 +47,7 @@ fn get_numpy_api<'py>(
const fn api_version_to_numpy_version_range(api_version: c_uint) -> (&'static str, &'static str) {
match api_version {
- ..=0x0000000... | 1 | 2 | 2 |
43af82beb17d10bd23e47c43248c6a0d638f9ade | Alexandre Marcireau | 2024-07-08T17:20:46 | Fix flags for Windows
Contributed by @stinodego | diff --git a/src/dtype.rs b/src/dtype.rs
index be684262..bb2dee2c 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -570,7 +570,7 @@ impl<'py> PyArrayDescrMethods<'py> for Bound<'py, PyArrayDescr> {
}
fn flags(&self) -> u64 {
- unsafe { PyDataType_FLAGS(self.py(), self.as_dtype_ptr()) }
+ unsafe... | 1 | 1 | 1 |
a0598f3cddb394a5c237da5f1365a5a8074f3dbf | Alexandre Marcireau | 2024-06-08T01:11:23 | Avoid API changes by using self.py() | diff --git a/src/dtype.rs b/src/dtype.rs
index 17a6b747..2ee0695e 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -204,8 +204,8 @@ impl PyArrayDescr {
/// Equivalent to [`numpy.dtype.itemsize`][dtype-itemsize].
///
/// [dtype-itemsiize]: https://numpy.org/doc/stable/reference/generated/numpy.dtype.itemsi... | 1 | 90 | 75 |
f9e0ae3b69f37b6963b190f527adb5ad77ba3579 | Alexandre Marcireau | 2024-06-04T07:03:18 | Fix runtime tests | diff --git a/src/npyffi/mod.rs b/src/npyffi/mod.rs
index 56a76bad..b4a27607 100644
--- a/src/npyffi/mod.rs
+++ b/src/npyffi/mod.rs
@@ -51,7 +51,7 @@ fn get_numpy_api<'py>(
(*PyArray_GetNDArrayCFeatureVersion)()
};
#[cfg(all(feature = "numpy-1", not(feature = "numpy-2")))]
- if api_... | 1 | 2 | 2 |
db0df1b9fa3f968751d822948e53d9be34b12704 | Alexandre Marcireau | 2024-06-03T23:57:39 | Use the new "universal" access functions | diff --git a/src/borrow/shared.rs b/src/borrow/shared.rs
index 1ff4344e..439ce161 100644
--- a/src/borrow/shared.rs
+++ b/src/borrow/shared.rs
@@ -12,7 +12,7 @@ use rustc_hash::FxHashMap;
use crate::array::get_array_module;
use crate::cold;
use crate::error::BorrowError;
-use crate::npyffi::{PyArrayObject, PyArray_C... | 4 | 32 | 25 |
50f4afd27605f2e00e30caea567cb655fcca4691 | Alexandre Marcireau | 2024-06-03T23:57:18 | Remove outdated 1.0 functions, add new 2.0 functions
Essentially a port of https://github.com/numpy/numpy/blob/97356bc6f0d6538389a9eef475d883a0f4024c2a/numpy/_core/include/numpy/npy_2_compat.h | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index b62c3b22..224b724f 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -68,8 +68,14 @@ impl PyArrayAPI {
impl_api![47; PyArray_Zero(arr: *mut PyArrayObject) -> *mut c_char];
impl_api![48; PyArray_One(arr: *mut PyArrayObject) -> *mut c_char... | 5 | 478 | 13 |
a36a122652bae258433a0232ed799d8b80e01f17 | Alexandre Marcireau | 2024-06-03T23:53:53 | Add feature flags for numpy 1 and 2
By default, the extension is compile with support for numpy 1 and 2 (with runtime checks to pick the right binary offset where needed). Features or fields that are specific to a version are hidden by default. Users can opt-out of numpy 1 + numpy 2 by disabling default features and s... | diff --git a/Cargo.toml b/Cargo.toml
index 4c71108a..0bf5f917 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -31,3 +31,8 @@ nalgebra = { version = "0.32", default-features = false, features = ["std"] }
[package.metadata.docs.rs]
all-features = true
+
+[features]
+default = ["numpy-1", "numpy-2"]
+numpy-1 = []
+numpy-2... | 1 | 5 | 0 |
2095cc57a9b308a0d512f652e40734f3774f5781 | Adam Reichold | 2024-07-21T13:14:33 | Fix doc comment formatting to appease Clippy. | diff --git a/src/array.rs b/src/array.rs
index dfc63072..276c9918 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -40,7 +40,7 @@ use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods};
/// # Memory location
///
/// - Allocated by Rust: Constructed via [`IntoPyArray`] or
-/// [`from_vec`][Self::from_vec] o... | 1 | 2 | 2 |
ca17e88669f72c68909689a7b6aa99ed65ca1f78 | Adam Reichold | 2024-04-14T09:56:05 | Resolve warnings on non-local definitions and legacy numerical constants. | diff --git a/tests/array.rs b/tests/array.rs
index b6bf22ea..5a0c4a87 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -399,23 +399,23 @@ fn dtype_via_python_attribute() {
});
}
-#[test]
-fn borrow_from_array_works() {
- #[pyclass]
- struct Owner {
- array: Array1<f64>,
- }
+#[pyclass]
+struc... | 3 | 25 | 25 |
0832b28bf84a3f6053ca647a43625d715831db00 | Adam Reichold | 2024-03-31T13:39:49 | Drop unnecessary usage of deprecated GILPool from array benchmark. | diff --git a/benches/array.rs b/benches/array.rs
index 7b7ed21d..56d4bd11 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -6,7 +6,7 @@ use test::{black_box, Bencher};
use std::ops::Range;
use numpy::{PyArray1, PyArray2, PyArray3};
-use pyo3::{types::PyAnyMethods, Python, ToPyObject};
+use pyo3::{types::PyAn... | 2 | 35 | 35 |
c37c1a4c891e3b1e7e59a70cb8671155ca78f1dd | Icxolu | 2024-03-08T21:18:51 | deprecate `pyarray!` | diff --git a/src/lib.rs b/src/lib.rs
index 80933918..cc218dd1 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -152,6 +152,27 @@ mod doctest {
#[inline(always)]
fn cold() {}
+/// Deprecated form of [`pyarray_bound`]
+#[deprecated(
+ since = "0.21.0",
+ note = "will be replace by `pyarray_bound` in the future"
+)]
... | 5 | 97 | 52 |
05b1b323e680af05fb54fafcf179b7fce8cd0b27 | Icxolu | 2024-03-08T20:58:02 | deprecate `inner`, `dot` and `einsum` | diff --git a/src/lib.rs b/src/lib.rs
index 79dbbf65..80933918 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -114,7 +114,9 @@ pub use crate::dtype::{
pub use crate::error::{BorrowError, FromVecError, NotContiguousError};
pub use crate::npyffi::{PY_ARRAY_API, PY_UFUNC_API};
pub use crate::strings::{PyFixedString, PyFixe... | 3 | 148 | 69 |
30f66f405a66c79da8956462c58b6d0830b8bd65 | Icxolu | 2024-03-28T19:56:22 | switch to pyo3's 0.21 release | diff --git a/Cargo.toml b/Cargo.toml
index 99cfe487..28b5b335 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,11 +22,11 @@ num-complex = ">= 0.2, < 0.5"
num-integer = "0.1"
num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
-pyo3 = { version = "0.21.0-beta", default-features = false, features = ["gil-refs", "macros"] }
... | 4 | 5 | 5 |
cd6bb7f9cd5153b3b7bde352a8dbbb45fa834396 | Icxolu | 2024-03-06T20:32:12 | deprecate `PyArray::from_vec` | diff --git a/benches/array.rs b/benches/array.rs
index 6619c4e2..7b7ed21d 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -141,7 +141,7 @@ fn from_vec2(bencher: &mut Bencher, size: usize) {
iter_with_gil(bencher, |py| {
let vec2 = black_box(&vec2);
- PyArray2::from_vec2(py, vec2).unwrap()... | 5 | 66 | 30 |
ee7823d422d02c38f2c7ed53a851202e42fc0639 | Icxolu | 2024-03-06T20:24:17 | deprecate `PyArray::from_array` | diff --git a/src/array.rs b/src/array.rs
index 7a837c97..34f8aaae 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -803,6 +803,18 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
self.as_borrowed().to_vec()
}
+ /// Deprecated form of [`PyArray<T, D>::from_array_bound`]
+ #[deprecated(
+ sin... | 2 | 17 | 5 |
6234a72e72e346269d5d2ba021989665a099eb46 | Icxolu | 2024-03-06T20:21:46 | deprecate `PyArray::from_iter` | diff --git a/benches/array.rs b/benches/array.rs
index 27ebe9e0..6619c4e2 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -66,7 +66,7 @@ fn from_iter(bencher: &mut Bencher, size: usize) {
iter_with_gil(bencher, |py| {
let iter = black_box(Iter(0..size));
- PyArray1::from_iter(py, iter);
+... | 4 | 24 | 10 |
c2a3c39ef3b2f3dcb7750c8bf66acbf0aa5dd2eb | Icxolu | 2024-03-06T20:12:18 | deprecate `PyArray::arange` | diff --git a/src/array.rs b/src/array.rs
index 3f188f5c..f6d01a0c 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -81,12 +81,12 @@ use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods};
/// # Example
///
/// ```
-/// use numpy::PyArray;
-/// use ndarray::array;
+/// use numpy::{PyArray, PyArrayMethods};
... | 6 | 74 | 64 |
31f1eef6a7ff1e4142db14aa2e153e9547c0c2ae | Icxolu | 2024-03-06T19:43:17 | deprecate `PyArray::from_slice` | diff --git a/benches/array.rs b/benches/array.rs
index d81939b5..27ebe9e0 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -91,7 +91,7 @@ fn from_slice(bencher: &mut Bencher, size: usize) {
iter_with_gil(bencher, |py| {
let slice = black_box(&vec);
- PyArray1::from_slice(py, slice);
+ ... | 6 | 30 | 20 |
345c6136053949ac6a8c1c8105587dd296eec928 | Adam Reichold | 2024-03-25T18:14:16 | Add a prelude to make the method traits easier to import | diff --git a/src/array.rs b/src/array.rs
index fc447808..4d68f7c2 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -326,7 +326,8 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
/// # Example
///
/// ```
- /// use numpy::{PyArray3, PyArrayMethods, PyUntypedArrayMethods};
+ /// use numpy::prelude::*... | 2 | 23 | 5 |
f61f4e2587e3445e7a4ef75fe54f66994f1f5905 | Adam Reichold | 2024-03-25T18:06:52 | Use a uniform approach to sealing traits | diff --git a/src/array_like.rs b/src/array_like.rs
index 86747d13..8a1e3bc4 100644
--- a/src/array_like.rs
+++ b/src/array_like.rs
@@ -10,13 +10,18 @@ use pyo3::{
};
use crate::array::PyArrayMethods;
-use crate::sealed::Sealed;
use crate::{get_array_module, Element, IntoPyArray, PyArray, PyReadonlyArray};
pub t... | 5 | 30 | 23 |
ea88df3fbca8884eab71a76d90f38ad4b99fe958 | Adam Reichold | 2024-03-25T18:06:18 | Fix use of deprecated constructors in benchmarks | diff --git a/benches/array.rs b/benches/array.rs
index d746e39f..d81939b5 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -6,15 +6,15 @@ use test::{black_box, Bencher};
use std::ops::Range;
use numpy::{PyArray1, PyArray2, PyArray3};
-use pyo3::{PyAny, Python, ToPyObject};
+use pyo3::{types::PyAnyMethods, Py... | 2 | 16 | 16 |
9d7882f4e834d37ba7534549717bab1564550506 | Icxolu | 2024-03-06T19:18:18 | deprecate `PyArray::zeros` | diff --git a/src/array.rs b/src/array.rs
index 97a78b3f..fc447808 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -214,15 +214,15 @@ impl<T, D> PyArray<T, D> {
/// # Example
///
/// ```
- /// use numpy::PyArray1;
+ /// use numpy::{PyArray1, PyArrayMethods};
/// use pyo3::{Py, Python};
///... | 7 | 188 | 168 |
f9799664cf7046e9b00ee249902d23b457004f94 | Icxolu | 2024-03-06T19:28:29 | deprecate `PyArray::from_owned_array` | diff --git a/src/array.rs b/src/array.rs
index 034b7734..97a78b3f 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -82,7 +82,7 @@ use crate::untyped_array::{PyUntypedArray, PyUntypedArrayMethods};
///
/// ```
/// use numpy::PyArray;
-/// use ndarray::{array, Array};
+/// use ndarray::array;
/// use pyo3::Python;
//... | 2 | 29 | 10 |
6244177b76ada1055d02fc52f8beecd68645e8fc | Icxolu | 2024-03-06T18:31:46 | deprecate `PyArray::borrow_from_array` | diff --git a/src/array.rs b/src/array.rs
index 25e01691..034b7734 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -20,7 +20,7 @@ use pyo3::{
ffi, pyobject_native_type_base,
types::{DerefToPyAny, PyAnyMethods, PyModule},
AsPyPointer, Bound, DowncastError, FromPyObject, IntoPy, Py, PyAny, PyErr, PyNativeTy... | 2 | 28 | 13 |
271b63486a20e718dd363c6cf1e8f00eea56ede3 | Icxolu | 2024-03-06T18:07:44 | deprecate `PyArray::new` | diff --git a/src/array.rs b/src/array.rs
index d9384696..25e01691 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -292,6 +292,21 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
D::from_dimension(&Dim(self.shape())).expect(DIMENSIONALITY_MISMATCH_ERR)
}
+ /// Deprecated form of [`PyArray<T, D>::new_... | 3 | 55 | 30 |
219cfdaa0a2c29ce9cbf1eced1c167d34d0f6dcd | Icxolu | 2024-03-23T16:57:12 | reexport `PyArray0Methods` | diff --git a/src/lib.rs b/src/lib.rs
index 753d65ca..a03e4479 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -92,8 +92,8 @@ pub use pyo3;
pub use nalgebra;
pub use crate::array::{
- get_array_module, PyArray, PyArray0, PyArray1, PyArray2, PyArray3, PyArray4, PyArray5,
- PyArray6, PyArrayDyn, PyArrayMethods,
+ ... | 1 | 2 | 2 |
5daf0e34ee4a8ee6c749f9bea1ca52afb3023db1 | Adam Reichold | 2024-03-23T08:34:03 | Extend the documentation of the nalgebra integration to discuss its likely surprising memory layout requirements. | diff --git a/src/array.rs b/src/array.rs
index f6345589..d9384696 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -879,6 +879,8 @@ where
{
/// Try to convert this array into a [`nalgebra::MatrixView`] using the given shape and strides.
///
+ /// See [`PyReadonlyArray::try_as_matrix`] for a discussion of t... | 4 | 64 | 1 |
6d38eafdc259547e02c4e1c49ea6ed31da8f9941 | Icxolu | 2024-03-05T20:22:49 | convert `PyArray` to `Bound` API | diff --git a/src/array.rs b/src/array.rs
index 11a11937..f6345589 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -225,6 +225,7 @@ impl<T, D> PyArray<T, D> {
/// assert_eq!(array.as_ref(py).readonly().as_slice().unwrap(), [0.0; 5]);
/// });
/// ```
+ #[deprecated(since = "0.21.0", note = "use Boun... | 5 | 933 | 227 |
5e0793e9ea7e17411c2e17578f3cadaba0716c9b | Icxolu | 2024-03-16T18:35:40 | convert `TypeError` | diff --git a/src/array.rs b/src/array.rs
index c4a1c953..11a11937 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -281,7 +281,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
let src_dtype = array.dtype();
let dst_dtype = T::get_dtype_bound(ob.py());
if !src_dtype.is_equiv_to(&dst_dtype) {... | 2 | 11 | 9 |
fad4e18c5210af86f18fb7aa5a3ba8918129d904 | Icxolu | 2024-03-05T18:50:44 | convert `PyArrayDescr` to `Bound` API | diff --git a/src/array.rs b/src/array.rs
index e000c920..c4a1c953 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -26,7 +26,7 @@ use pyo3::{
use crate::borrow::{PyReadonlyArray, PyReadwriteArray};
use crate::cold;
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
-use crate::dtype::Element... | 8 | 421 | 125 |
9517ed92520ad75d008f4deb30f64931ea858c6c | Icxolu | 2024-03-04T23:01:39 | convert `PyUntypedArray` to `Bound` API | diff --git a/src/array.rs b/src/array.rs
index a5756799..e000c920 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -33,7 +33,7 @@ use crate::error::{
};
use crate::npyffi::{self, npy_intp, NPY_ORDER, PY_ARRAY_API};
use crate::slice_container::PySliceContainer;
-use crate::untyped_array::PyUntypedArray;
+use crate::un... | 3 | 243 | 22 |
744a3f3d3f42ad1f5dfafee7702c36ed4da16ac7 | Icxolu | 2024-03-03T20:46:08 | migration to pyo3 0.21 beta using the new Bound API
This does still use GIL Refs in numpy's API but switches
our internals to use the Bound API where appropriate. | diff --git a/Cargo.toml b/Cargo.toml
index d0bc0b97..99cfe487 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,11 +22,11 @@ num-complex = ">= 0.2, < 0.5"
num-integer = "0.1"
num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
-pyo3 = { version = "0.20", default-features = false, features = ["macros"] }
+pyo3 = { version =... | 15 | 84 | 72 |
32740b33ec55ef0b7ebec726288665837722841d | Adam Reichold | 2023-11-11T11:28:48 | Add documentation on the consequences of NumPy matching C's integeer hierarchy. | diff --git a/src/dtype.rs b/src/dtype.rs
index 0c6f6b01..f8183c0c 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -368,6 +368,15 @@ impl PyArrayDescr {
/// Currently, only integer/float/complex/object types are supported. The [NumPy documentation][enumerated-types]
/// list the other built-in types which we are not y... | 1 | 10 | 0 |
b5af0ed9b2b0802568d09bee5f09843d9323539e | Adam Reichold | 2023-10-03T09:28:26 | Add missing zero-dimensional type aliases for array borrows. | diff --git a/src/borrow/mod.rs b/src/borrow/mod.rs
index 6f48c757..fe2c685d 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, ArrayV... | 2 | 11 | 5 |
652619d30b02645a591375a967b6a365b2369cc7 | Adam Reichold | 2023-09-08T14:21:47 | Adjust test expectation to latest PyO3 release. | diff --git a/tests/borrow.rs b/tests/borrow.rs
index 9a6e5587..466b0fa3 100644
--- a/tests/borrow.rs
+++ b/tests/borrow.rs
@@ -81,7 +81,7 @@ fn exclusive_borrow_requires_writeable() {
}
#[test]
-#[should_panic(expected = "Unwrapped panic from Python code")]
+#[should_panic(expected = "AlreadyBorrowed")]
fn borrows... | 1 | 1 | 1 |
3a18675158c5fa436bdabeb61861786306689faf | Hofer-Julian | 2023-09-08T13:59:43 | Remove unneeded lifetime annotations (#389) | diff --git a/examples/linalg/src/lib.rs b/examples/linalg/src/lib.rs
index 0ea9a635..7b0b20a5 100755
--- a/examples/linalg/src/lib.rs
+++ b/examples/linalg/src/lib.rs
@@ -3,9 +3,9 @@ use numpy::{IntoPyArray, PyArray2, PyReadonlyArray2};
use pyo3::{exceptions::PyRuntimeError, pymodule, types::PyModule, PyResult, Python... | 4 | 15 | 14 |
3843fa94c5b9e0b035a0b1cb8a70c164ef153a21 | Adam Reichold | 2023-07-08T19:43:25 | Use a transparent repr for PyReadonly/ReadwriteArray as this has become as single field struct.
Using `#[repr(C)]` was necessary when it had multiple fields so that the `Deref`
implementation from `PyReadwriteArray` to `PyReadonlyArray` is sound. | diff --git a/src/borrow/mod.rs b/src/borrow/mod.rs
index 24406269..9009072d 100644
--- a/src/borrow/mod.rs
+++ b/src/borrow/mod.rs
@@ -184,7 +184,7 @@ use shared::{acquire, acquire_mut, release, release_mut};
/// i.e. that only shared references into the interior of the array can be created safely.
///
/// See the [... | 1 | 2 | 2 |
7e6babe2a3bdb995a1fd63fffaf6bd463d46690c | Adam Reichold | 2023-03-26T14:15:10 | Bump PyO3 to the just released version 0.19.0. | diff --git a/Cargo.toml b/Cargo.toml
index fd2df6ac..9609e736 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,11 +22,11 @@ num-complex = ">= 0.2, < 0.5"
num-integer = "0.1"
num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
-pyo3 = { version = "0.18", default-features = false, features = ["macros"] }
+pyo3 = { version =... | 6 | 8 | 8 |
02566711f73408015ba0adf22e5767ca0feedda4 | Sammy Sidhu | 2023-05-16T23:47:05 | Correct Type for array.dims() | diff --git a/src/array.rs b/src/array.rs
index e5242b36..d286cb6c 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -281,7 +281,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
Ok(array)
}
- /// Same as [`shape`][PyUntypedArray::shape], but returns `D` insead of `&[usize]`.
+ /// Same as [`shape`... | 1 | 1 | 1 |
23229eaab77824f08b41e29bd0939187dbcaf3cc | Adam Reichold | 2023-03-26T14:16:19 | Use GILProtected to make it explicit where we depend on the GIL for synchronization. | diff --git a/src/datetime.rs b/src/datetime.rs
index 3b30b3f2..bd5ef54e 100644
--- a/src/datetime.rs
+++ b/src/datetime.rs
@@ -57,13 +57,13 @@
//! [scalars-datetime64]: https://numpy.org/doc/stable/reference/arrays.scalars.html#numpy.datetime64
//! [scalars-timedelta64]: https://numpy.org/doc/stable/reference/arrays.... | 2 | 10 | 16 |
d7fdc436278c91e9790bb2cbaf6e97f34b4ec1b7 | Adam Reichold | 2023-03-26T14:48:34 | Intentionally leak a reference to the NumPy capsule API | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 87495533..f6bbf698 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -48,7 +48,8 @@ impl PyArrayAPI {
unsafe fn get(&self, py: Python, offset: isize) -> *const *const c_void {
let api = self
.0
- .get_or_init(... | 3 | 22 | 16 |
f64d8ec6db87b7052dc52db0668bfd97b06c60e1 | Adam Reichold | 2023-03-26T14:38:34 | Use GILOnceCell when caching the dynamic borrow checking capsule API. | diff --git a/src/borrow/shared.rs b/src/borrow/shared.rs
index 06b2f7a1..fb26a1de 100644
--- a/src/borrow/shared.rs
+++ b/src/borrow/shared.rs
@@ -1,12 +1,14 @@
-use std::cell::Cell;
use std::collections::hash_map::Entry;
use std::ffi::{c_void, CString};
+use std::mem::forget;
use std::os::raw::{c_char, c_int};
-use... | 1 | 17 | 15 |
4bbadda3a390d6d2047ef935e0fdfe3daf6aa614 | dsgibbons | 2023-03-18T12:18:39 | Update lib.rs
fix typo | diff --git a/src/lib.rs b/src/lib.rs
index a6514a95..80a4a0db 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,7 +14,7 @@
//!
#![cfg_attr(
feature = "nalgebra",
- doc = "Integration with [`nalgebra`] is rovided via an implementation of [`ToPyArray`] for [`nalgebra::Matrix`] to convert nalgebra matrices into Nu... | 1 | 1 | 1 |
dabc7808e082ef52b56143accd24a9e4ebd4cbc5 | Adam Reichold | 2023-03-05T17:59:16 | Add an inherent method to access the untyped version of a given array which can be useful to guide type inference. | diff --git a/src/array.rs b/src/array.rs
index ef1c5ef6..e5242b36 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -151,7 +151,7 @@ impl<T, D> Deref for PyArray<T, D> {
#[inline]
fn deref(&self) -> &Self::Target {
- unsafe { &*(self as *const Self as *const PyUntypedArray) }
+ self.as_untyped()... | 1 | 7 | 1 |
0a99920a91163b1b67c34d25ec644151d2e7c170 | Adam Reichold | 2023-01-30T08:58:04 | Freeze the slice container pyclass as it does not need mutable access (or any access at all). | diff --git a/src/slice_container.rs b/src/slice_container.rs
index ba57e2e1..4350b4f7 100644
--- a/src/slice_container.rs
+++ b/src/slice_container.rs
@@ -4,7 +4,7 @@ use ndarray::{ArrayBase, Dimension, OwnedRepr};
use pyo3::pyclass;
/// Utility type to safely store `Box<[_]>` or `Vec<_>` on the Python heap
-#[pycl... | 1 | 1 | 1 |
a6c49d16ea301cacbb53daf7226c6dc3f0d3df6d | Adam Reichold | 2023-01-19T17:30:47 | Drop bespoke GILOnceCell implementation used to cache capsule API
While we do not strictly need all the capabilities and guarantees of PyO3's
GILOnceCell, reducing the amount of open-coded synchronization seems like it is
worth it to me. It also better centralizes GIL-based synchronization concerns in
the PyO3 crate w... | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 5be9e002..87495533 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -4,12 +4,13 @@
//! The reason is that they would be re-exports of the `PyMem_Raw{Malloc,Realloc,Free}` functions from PyO3,
//! but those are not unconditionally exported, i.e.... | 2 | 17 | 44 |
bf93c9dee69f1aad7f67fac14c3dd7d163159982 | Shatur | 2023-01-16T11:39:46 | Update to nalgebra 0.32 | diff --git a/Cargo.toml b/Cargo.toml
index adb03b1e..6e4a4382 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,7 +17,7 @@ license = "BSD-2-Clause"
[dependencies]
half = { version = "2.0", default-features = false, optional = true }
libc = "0.2"
-nalgebra = { version = "0.31", default-features = false, optional = true... | 4 | 30 | 34 |
cc7b1c971c9b52ae92d65e7f3e7e919663fb3429 | Adam Reichold | 2022-11-14T09:01:31 | Make the shared borrow checking API much narrower
This improves the changes of actually keeping it backwards compatible while
precluding the reuse of base address and borrow key for cloning and dropping. | diff --git a/src/borrow/mod.rs b/src/borrow/mod.rs
index 19037320..7f7b820a 100644
--- a/src/borrow/mod.rs
+++ b/src/borrow/mod.rs
@@ -164,22 +164,19 @@ mod shared;
use std::any::type_name;
use std::fmt;
-use std::mem::size_of;
use std::ops::Deref;
use ndarray::{
ArrayView, ArrayViewMut, Dimension, IntoDim... | 2 | 462 | 557 |
869d198229bde049ba6abc761f877fed4743683e | Adam Reichold | 2022-11-13T13:20:22 | Use a less grandiose name of the borrow checking API capsule to avoid misunderstands on its scope. | diff --git a/src/borrow/shared.rs b/src/borrow/shared.rs
index 79991b25..c8f71d21 100644
--- a/src/borrow/shared.rs
+++ b/src/borrow/shared.rs
@@ -15,7 +15,7 @@ use crate::error::BorrowError;
/// Defines the shared C API used for borrow checking
///
/// This structure will be placed into a capsule at
-/// `numpy.cor... | 1 | 5 | 5 |
f6e8192c7ed5a28df751678c940dae6fc8f7c6c6 | Adam Reichold | 2022-11-12T11:06:21 | Perform borrow checking through a capsule-based API
This places the global state required for dynamic borrow checking of NumPy
arrays into a capsule exposed as the numpy.core.multiarray._BORROW_CHECKING_API
attribute.
This has two benefits: First, all extensions built using rust-numpy will share
this global state and... | diff --git a/src/borrow/mod.rs b/src/borrow/mod.rs
index 211e5aa8..19037320 100644
--- a/src/borrow/mod.rs
+++ b/src/borrow/mod.rs
@@ -179,7 +179,7 @@ use crate::dtype::Element;
use crate::error::{BorrowError, NotContiguousError};
use crate::npyffi::{self, PyArrayObject, NPY_ARRAY_WRITEABLE};
-use shared::{BorrowKe... | 2 | 326 | 64 |
324b634f54ebda24b81671826c2d3841939a4aeb | Adam Reichold | 2022-11-12T09:16:39 | Split off the parts of borrow checking module which should be shared by all extensions. | diff --git a/src/borrow.rs b/src/borrow/mod.rs
similarity index 71%
rename from src/borrow.rs
rename to src/borrow/mod.rs
index 19ab0ba4..211e5aa8 100644
--- a/src/borrow.rs
+++ b/src/borrow/mod.rs
@@ -160,9 +160,9 @@
//!
//! [base]: https://numpy.org/doc/stable/reference/c-api/types-and-structures.html#c.NPY_AO.base... | 2 | 451 | 426 |
2f186194ae8f92920c9871b3fec088f2266d7c43 | Adam Reichold | 2022-11-12T08:55:47 | Replace AHash (DoS-resistant) by FxHash (simpler dependency)
In the datetime module, we hash a set of keys known at compile time and hence
are not subject to DoS issues.
In the borrow module, the keys include pointer addresses which means that even
if a program exposes its usage of NumPy arrays to remote user control... | diff --git a/Cargo.toml b/Cargo.toml
index 7fc1ea01..adb03b1e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,6 @@ keywords = ["python", "numpy", "ffi", "pyo3"]
license = "BSD-2-Clause"
[dependencies]
-ahash = "0.7"
half = { version = "2.0", default-features = false, optional = true }
libc = "0.2"
nalgebra... | 3 | 12 | 10 |
347888d23b8dec639d8424a6e5bcbff6562f35cc | Adam Reichold | 2022-11-12T08:48:28 | Fix unintended usage of global where self was intended. | diff --git a/src/borrow.rs b/src/borrow.rs
index de61e2a3..9f7d7f01 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -256,7 +256,7 @@ impl BorrowFlags {
fn acquire(&self, _py: Python, address: *mut u8, key: BorrowKey) -> Result<(), BorrowError> {
// SAFETY: Having `_py` implies holding the GIL and
... | 1 | 4 | 4 |
773656b6ae1548657a6b7fc716690238963f2b03 | Adam Reichold | 2022-09-17T13:36:36 | Bump half dependency to the current stable version
Bumping ahash is blocked by our MSRV policy. | diff --git a/Cargo.toml b/Cargo.toml
index c63b6066..7fc1ea01 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -16,7 +16,7 @@ license = "BSD-2-Clause"
[dependencies]
ahash = "0.7"
-half = { version = "1.8", default-features = false, optional = true }
+half = { version = "2.0", default-features = false, optional = true }... | 1 | 1 | 1 |
cde79062093b2e6320c42ae22b64256fbb376b2d | Adam Reichold | 2022-09-16T06:57:31 | Add tests for the various failure modes of PyArray::try_as_matrix_shape_strides. | diff --git a/tests/borrow.rs b/tests/borrow.rs
index a991ba20..aeb13e73 100644
--- a/tests/borrow.rs
+++ b/tests/borrow.rs
@@ -407,4 +407,76 @@ fn matrix_from_numpy() {
assert_eq!(matrix, nalgebra::Matrix3x1::new(0, 1, 2));
}
});
+
+ Python::with_gil(|py| {
+ let array = PyArray::<i... | 1 | 72 | 0 |
666e09a383b677c5d1aa4a2779d477a35f7b1cb3 | Adam Reichold | 2022-09-16T06:42:27 | Refine safety comments on aliasing of reference-based views into NumPy arrays. | diff --git a/src/array.rs b/src/array.rs
index d795e317..04f36799 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -991,7 +991,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
///
/// # Safety
///
- /// The existence of an exclusive reference to the internal data, e.g. `&mut [T]` or `ArrayViewMut`, ... | 1 | 4 | 4 |
937989353725ba0c67da4e27d273d343a0863d07 | Adam Reichold | 2022-09-14T06:36:04 | Document the Fortran memory layout of NumPy arrays created from nalgebra matrices and test the conversion of the naglebra vector aliases. | diff --git a/src/convert.rs b/src/convert.rs
index 67ac6279..60049d83 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -194,6 +194,10 @@ where
type Item = N;
type Dim = crate::Ix2;
+ /// Note that the NumPy array always has Fortran memory layout
+ /// matching the [memory layout][memory-layout] use... | 2 | 20 | 0 |
7eeff583444288a19bbef47196a0fe540c8b565e | Adam Reichold | 2022-09-11T09:20:08 | Add top-level documentation and examples to further improve discoverability of nalgebra support. | diff --git a/Cargo.toml b/Cargo.toml
index 4f3540ef..c63b6066 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -27,6 +27,7 @@ pyo3 = { version = "0.17", default-features = false, features = ["macros"] }
[dev-dependencies]
pyo3 = { version = "0.17", default-features = false, features = ["auto-initialize"] }
+nalgebra = {... | 2 | 40 | 1 |
ae60f4f9880291142108c00d6dbf702f845c938a | Adam Reichold | 2022-09-11T08:46:13 | Use documentation aliases to make the nalgebra support easier to discover. | diff --git a/src/array.rs b/src/array.rs
index 627bc0e6..d795e317 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1106,6 +1106,7 @@ where
/// # Safety
///
/// The existence of an exclusive reference to the internal data, e.g. `&mut [T]` or `ArrayViewMut`, implies undefined behavior.
+ #[doc(alias = "... | 2 | 8 | 0 |
6499ccaf3a08e5b50e6d2f969aadd5b5c01e1d65 | Adam Reichold | 2022-09-11T08:45:03 | Re-export nalgebra as we do for ndarray and pyo3 if the optional dependency is enabled. | diff --git a/src/lib.rs b/src/lib.rs
index 31c4cb5d..9edfcffb 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -49,6 +49,9 @@ mod sum_products;
pub use ndarray;
pub use pyo3;
+#[cfg(feature = "nalgebra")]
+pub use nalgebra;
+
pub use crate::array::{
get_array_module, PyArray, PyArray0, PyArray1, PyArray2, PyArray3... | 1 | 3 | 0 |
82b8507b696d7d64749cedb428ebc62dd7c5f51d | Adam Reichold | 2022-09-10T09:20:13 | Optimize copying nalgebra matrices into NumPy arrays. | diff --git a/src/convert.rs b/src/convert.rs
index 046d1fbe..67ac6279 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -189,17 +189,21 @@ where
N: nalgebra::Scalar + Element,
R: nalgebra::Dim,
C: nalgebra::Dim,
- S: nalgebra::storage::Storage<N, R, C>,
+ S: nalgebra::Storage<N, R, C>,
{
ty... | 2 | 19 | 5 |
81b807c9014be13399abccdbbf08a165bf2222ae | Adam Reichold | 2022-09-16T14:34:43 | Remove unnecessary generics from PyArray::from_raw_parts. | diff --git a/src/array.rs b/src/array.rs
index 9415180a..1128b427 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -512,16 +512,13 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
Self::from_owned_ptr(py, ptr)
}
- pub(crate) unsafe fn from_raw_parts<'py, ID>(
+ pub(crate) unsafe fn from_raw_parts<... | 2 | 6 | 9 |
bf66005e52ea24e0e36faa304e21c975e8af4a81 | Adam Reichold | 2022-09-16T14:31:32 | Derive data pointer only after dissolving Box to avoid unsound aliasing. | diff --git a/src/array.rs b/src/array.rs
index bba97c7f..9415180a 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -512,18 +512,17 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
Self::from_owned_ptr(py, ptr)
}
- pub(crate) unsafe fn from_raw_parts<'py, ID, C>(
+ pub(crate) unsafe fn from_raw_par... | 3 | 47 | 19 |
1bb9defb85a816258c652d213426be8468673b26 | Adam Reichold | 2022-09-16T14:13:45 | Use slice:as_mut_ptr instead of slice::as_ptr to enable modifications via the returned pointers. | diff --git a/src/array.rs b/src/array.rs
index b1464f92..bba97c7f 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -676,9 +676,9 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
/// assert_eq!(pyarray.readonly().as_array(), array![[1, 2], [3, 4]]);
/// });
/// ```
- pub fn from_owned_array<'py>(py... | 2 | 8 | 8 |
27d86c0ab53e44ddd8052efc0a6a45c43a8e1b85 | Adam Reichold | 2022-09-16T14:10:44 | Make nightly Clippy happy. | diff --git a/src/array.rs b/src/array.rs
index f42b2e16..b1464f92 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -451,7 +451,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
where
ID: IntoDimension<Dim = D>,
{
- let flags = if is_fortran { 1 } else { 0 };
+ let flags = c_int::from(i... | 2 | 3 | 3 |
f78b18b8f9b247e2fd01538baa8dccb801244ad4 | Michael Garbutt | 2022-07-29T10:09:19 | Fixing dead links in the documentation | diff --git a/src/array.rs b/src/array.rs
index ca1777cb..aab110fa 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -35,7 +35,7 @@ use crate::slice_container::PySliceContainer;
/// # Memory location
///
/// - Case1: Constructed via [`IntoPyArray`](../convert/trait.IntoPyArray.html) or
-/// [`from_vec`](#method.from_ve... | 2 | 4 | 4 |
5a4df5a44c04fdd846deadfb3582f9f1c864e5b5 | Adam Reichold | 2022-06-27T08:09:51 | Inline the layout-related methods as these basically change types and could benefit from cold branch removal. | diff --git a/src/array.rs b/src/array.rs
index 38342293..0c444669 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -151,6 +151,7 @@ impl<'py, T: Element, D: Dimension> FromPyObject<'py> for &'py PyArray<T, D> {
impl<T, D> PyArray<T, D> {
/// Returns a raw pointer to the underlying [`PyArrayObject`][npyffi::PyArr... | 1 | 4 | 0 |
14583d92893f4e0ed2014e5b29f9ee584402efc3 | Adam Reichold | 2022-06-23T18:59:30 | Hash pointers instead of addresses to avoid exposing the allocations backing NumPy arrays under strict provenance. | diff --git a/src/borrow.rs b/src/borrow.rs
index 80519d4c..d516a199 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -184,9 +184,9 @@ use crate::npyffi::{self, PyArrayObject, NPY_ARRAY_WRITEABLE};
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
struct BorrowKey {
/// exclusive range of lowest and highest address co... | 1 | 81 | 80 |
684194fa675a82550877d78def1e599d6f923a21 | Adam Reichold | 2022-05-17T19:36:33 | Fix intra-doc link to einsum macro. | diff --git a/src/sum_products.rs b/src/sum_products.rs
index 0bcb373d..e99225cf 100644
--- a/src/sum_products.rs
+++ b/src/sum_products.rs
@@ -132,7 +132,7 @@ where
/// Return the Einstein summation convention of given tensors.
///
-/// This is usually invoked via the the [`einsum!`] macro.
+/// This is usually inv... | 1 | 1 | 1 |
3795010ec0b1741cde71e39f56250b48bc5e505c | Adam Reichold | 2022-04-22T08:30:16 | Avoid overhead of creating a PyErr during downcasting. | diff --git a/src/array.rs b/src/array.rs
index f6907ea1..38342293 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -26,7 +26,7 @@ use crate::cold;
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
use crate::dtype::{Element, PyArrayDescr};
use crate::error::{
- BorrowError, Dimensionalit... | 2 | 48 | 26 |
fb8d706b52efedbd8ed879b4b7cb26286b9b1a76 | Adam Reichold | 2022-04-22T08:18:58 | Do not call into PyArray_EquivTypes if the descriptors are identical. | diff --git a/src/dtype.rs b/src/dtype.rs
index 9c008e21..7bbd257f 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -117,9 +117,12 @@ impl PyArrayDescr {
/// Returns true if two type descriptors are equivalent.
pub fn is_equiv_to(&self, other: &Self) -> bool {
+ let self_ptr = self.as_dtype_ptr();
+ ... | 1 | 7 | 3 |
7f5e79f30f7c303672e6f4505ec47c76c8653538 | Adam Reichold | 2022-04-22T08:06:24 | Add downcast to benchmarks, in addition to extract. | diff --git a/benches/array.rs b/benches/array.rs
index eed05afe..3102e4d8 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -30,6 +30,27 @@ fn extract_failure(bencher: &mut Bencher) {
});
}
+#[bench]
+fn downcast_success(bencher: &mut Bencher) {
+ Python::with_gil(|py| {
+ let any: &PyAny = PyAr... | 1 | 21 | 0 |
e1e5385ff76779bc5ba025db53e0f12df482f108 | Adam Reichold | 2022-04-21T09:02:23 | Some minor copy-editing of the FFI module. | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 1470f8aa..5be9e002 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -328,14 +328,15 @@ impl PyArrayAPI {
impl_api![303; PyArray_SetWritebackIfCopyBase(arr: *mut PyArrayObject, base: *mut PyArrayObject) -> c_int];
}
-// Define type objects... | 3 | 13 | 16 |
8599efcc417c51031f2e8e3e598b0edfd8a24289 | Adam Reichold | 2022-04-21T08:33:09 | Mark both PyArray and PyArrayDescr as repr(transparent) to make them strictly layout-compatible with PyAny. | diff --git a/src/array.rs b/src/array.rs
index 878c11ae..f6907ea1 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -16,9 +16,9 @@ use ndarray::{
};
use num_traits::AsPrimitive;
use pyo3::{
- ffi, pyobject_native_type_named, type_object, types::PyModule, AsPyPointer, FromPyObject,
- IntoPy, Py, PyAny, PyClassIni... | 2 | 6 | 13 |
2ef2bfdbd13fc4a0096d6c9ab4730a03d75a13de | Adam Reichold | 2022-04-13T17:44:39 | Flesh out the datetime module docs a bit. | diff --git a/src/datetime.rs b/src/datetime.rs
index 379d51a7..8aff3620 100644
--- a/src/datetime.rs
+++ b/src/datetime.rs
@@ -1,5 +1,10 @@
//! Support datetimes and timedeltas
//!
+//! This module provides wrappers for NumPy's [`datetime64`][scalars-datetime64] and [`timedelta64`][scalars-timedelta64] types
+//! whi... | 1 | 7 | 0 |
521d8abf7ed34ecf7c98b851a03bea230e97eff8 | Adam Reichold | 2022-04-06T20:01:13 | Memoize type descriptors for datetime/timedelta values on a per-unit basis. | diff --git a/src/datetime.rs b/src/datetime.rs
index eba22498..379d51a7 100644
--- a/src/datetime.rs
+++ b/src/datetime.rs
@@ -50,11 +50,14 @@
//!
//! [datetime]: https://numpy.org/doc/stable/reference/arrays.datetime.html
+use std::cell::UnsafeCell;
+use std::collections::hash_map::Entry;
use std::fmt;
use std::... | 1 | 51 | 19 |
32a552a86a4c679e5624e544af6a1412269f9e22 | Adam Reichold | 2022-04-09T18:38:33 | Add version information to all deprecations and update a FIXME comment with a conrete version. | diff --git a/src/array.rs b/src/array.rs
index 6ab7c0bf..c9d8e68e 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1040,6 +1040,7 @@ impl<T: Element> PyArray<T, Ix1> {
/// });
/// ```
#[deprecated(
+ since = "0.17.0",
note = "`from_exact_iter` is deprecated as it does not provide any bene... | 4 | 7 | 2 |
3173162892f5ea40816c177ae575b982bdd9bfbf | Adam Reichold | 2022-04-06T15:58:48 | Delay formatting type errors to improve performance of failed extractions. | diff --git a/benches/array.rs b/benches/array.rs
index 3f6c155b..eed05afe 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -6,7 +6,29 @@ use test::{black_box, Bencher};
use std::ops::Range;
use numpy::{PyArray1, PyArray2, PyArray3};
-use pyo3::{Python, ToPyObject};
+use pyo3::{PyAny, Python, ToPyObject};
+
+... | 2 | 59 | 18 |
16b1a304314cdea3d87dce85d487fd7e4c52e505 | Adam Reichold | 2022-04-05T19:13:21 | Consolidate deny-missing-docs and missing-debug-implementations lints. | diff --git a/src/array.rs b/src/array.rs
index a764d90e..1359858f 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -23,7 +23,10 @@ use crate::borrow::{PyReadonlyArray, PyReadwriteArray};
use crate::cold;
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
use crate::dtype::{Element, PyArrayDe... | 7 | 35 | 13 |
dfb7ba0cd794d9e64c7331992d19d93f23f6ca63 | Adam Reichold | 2022-04-01T18:06:44 | Fix missing re-export of BorrowError. | diff --git a/src/lib.rs b/src/lib.rs
index f3676aeb..cd4fa2c7 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -60,7 +60,9 @@ pub use crate::borrow::{
};
pub use crate::convert::{IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
pub use crate::dtype::{dtype, Complex32, Complex64, Element, PyArrayDescr};
-pub use crate::error... | 1 | 3 | 1 |
6b75cf940acfad65a150bbedfd25308054622c8c | Adam Reichold | 2022-03-31T17:28:26 | Fix a drop bug in PyReadwriteArray::resize and optimize borrowing by caching address and key. | diff --git a/src/borrow.rs b/src/borrow.rs
index aeb30fcc..ec6f7e61 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -180,7 +180,7 @@ use crate::dtype::Element;
use crate::error::{BorrowError, NotContiguousError};
use crate::npyffi::{self, PyArrayObject, NPY_ARRAY_WRITEABLE};
-#[derive(PartialEq, Eq, Hash)]
+#[der... | 1 | 90 | 40 |
457d013e3738674529e4078a43a1d77a635cd5e0 | Adam Reichold | 2022-03-31T17:09:36 | Further debloat borrow module by reducing unnecessary generics. | diff --git a/src/borrow.rs b/src/borrow.rs
index c176722f..aeb30fcc 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -199,7 +199,7 @@ impl BorrowKey {
let range = data_range(array);
let data_ptr = array.data() as usize;
- let gcd_strides = reduce(array.strides().iter().copied(), gcd).unwrap_... | 1 | 46 | 47 |
a6700acd0e0735ebecc0fb61cef279af17b21926 | Adam Reichold | 2022-03-31T05:50:17 | Factour out the non-generic parts of base_address and data_range to reduce code bloat. | diff --git a/src/borrow.rs b/src/borrow.rs
index 3f4c3eff..c176722f 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -171,7 +171,7 @@ use std::ops::Deref;
use ahash::AHashMap;
use ndarray::{ArrayView, ArrayViewMut, Dimension, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
use num_integer::gcd;
-use pyo3::{FromPyObject, PyAn... | 1 | 37 | 31 |
187ee53950f3a6ca93827b5b2d472b48b104f94d | Adam Reichold | 2022-03-25T13:40:43 | Use AHash for borrow checking hash tables. | diff --git a/Cargo.toml b/Cargo.toml
index dbeccc51..58e189e5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,6 +15,7 @@ keywords = ["python", "numpy", "ffi", "pyo3"]
license = "BSD-2-Clause"
[dependencies]
+ahash = "0.7"
libc = "0.2"
num-complex = ">= 0.2, < 0.5"
num-integer = "0.1"
@@ -23,7 +24,7 @@ ndarray = ... | 3 | 11 | 9 |
97aea61f8f7ce422e17636e464e2831c9aa888b5 | Adam Reichold | 2022-03-28T10:53:59 | Add missing implementations of the Debug trait for the borrow checking wrapper types. | diff --git a/src/borrow.rs b/src/borrow.rs
index 2f6317c4..53603ff4 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -161,8 +161,10 @@
//! [base]: https://numpy.org/doc/stable/reference/c-api/types-and-structures.html#c.NPY_AO.base
#![deny(missing_docs)]
+use std::any::type_name;
use std::cell::UnsafeCell;
use s... | 2 | 65 | 5 |
9e7bad3a4e534179be6c94c4644312107efff0bd | Adam Reichold | 2022-03-28T10:10:43 | Fix computation of data range of more-than-one-dimensional and zero-dimensional arrays. | diff --git a/src/borrow.rs b/src/borrow.rs
index 7886ba48..2f6317c4 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -146,22 +146,25 @@
//!
//! Note that the current implementation of this is an over-approximation: It will consider borrows
//! potentially conflicting if the initial arrays have the same object at th... | 1 | 130 | 99 |
1961c5f4c0f0ffb25c657d86583064dfa603ff30 | Adam Reichold | 2022-03-25T15:09:22 | Factor out parts of view creation code that do not depend on S, T and F to reduce code bloat. | diff --git a/src/array.rs b/src/array.rs
index d367d8a0..a764d90e 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -832,38 +832,48 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
where
F: FnOnce(StrideShape<D>, *mut T) -> ArrayBase<S, D>,
{
- let shape = D::from_dimension(&Dim(self.shape())).... | 1 | 38 | 28 |
3baef36118a23f6e29f57293879cb8e61de79d34 | Adam Reichold | 2022-03-24T20:55:32 | Drop Order and NpyStrides as there is really one place where it is used. | diff --git a/src/convert.rs b/src/convert.rs
index c107a126..9df6a579 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -144,12 +144,11 @@ where
fn to_pyarray<'py>(&self, py: Python<'py>) -> &'py PyArray<Self::Item, Self::Dim> {
let len = self.len();
match self.order() {
- Some(order... | 1 | 24 | 55 |
229cad782c6a411c207aad2443a10d90630f97cf | Adam Reichold | 2022-03-24T20:43:07 | Collect code for create ndarray views in a single place to make it easier to follow. | diff --git a/src/array.rs b/src/array.rs
index e186e30d..d367d8a0 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -9,7 +9,7 @@ use std::{
use ndarray::{
Array, ArrayBase, ArrayView, ArrayViewMut, Axis, Data, Dim, Dimension, IntoDimension, Ix0, Ix1,
- Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, RawArrayView, RawArrayView... | 2 | 62 | 77 |
f16696435835db52a72a92044b259f2d40a16940 | Adam Reichold | 2022-03-24T16:42:55 | Flesh out borrow checking examples and tests and remove unreachable case in implementation. | diff --git a/src/borrow.rs b/src/borrow.rs
index 9749547f..7886ba48 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -86,6 +86,30 @@
//! });
//! ```
//!
+//! The third example shows that some views are incorrectly rejected since the borrows are over-approximated.
+//!
+//! ```rust
+//! # use std::panic::{catch_unwi... | 2 | 290 | 8 |
028286f966c4375f69dfd4e59f870639a496d03b | Adam Reichold | 2022-03-22T21:43:27 | Use the GCD of the strides to check if two array views could alias. | diff --git a/Cargo.toml b/Cargo.toml
index 9f7d2262..dbeccc51 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -17,6 +17,7 @@ license = "BSD-2-Clause"
[dependencies]
libc = "0.2"
num-complex = ">= 0.2, < 0.5"
+num-integer = "0.1"
num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
pyo3 = { version = "0.16", default-feature... | 3 | 157 | 47 |
935aeb441623ccfdb1e2b3b9e6e87537d365f5c9 | Adam Reichold | 2022-03-18T16:58:51 | Refine dynamic borrow checking to track data ranges. | diff --git a/src/borrow.rs b/src/borrow.rs
index 1680c9d1..86120688 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -59,8 +59,9 @@
//! });
//! ```
//!
-//! The second example shows that non-overlapping and interleaved views which do not alias
-//! are currently not supported due to over-approximating which borrows... | 2 | 273 | 57 |
542ebb94d6fe414b3e296b174a6b1bbaf3b36d81 | Adam Reichold | 2022-03-22T21:58:54 | Make the internal PyArray::data function safe
While doing anything with the resulting pointer requires unsafe,
producing the pointer should not. (Dereferencing `self.as_array_ptr()`
should be safe for the same reasons that dereferencing it in say `PyArray::shape` is,
i.e. we ensure that `PyArray<T,D>` is only construc... | diff --git a/src/array.rs b/src/array.rs
index b5aed2b4..ff15c5a2 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -340,9 +340,9 @@ impl<T, D> PyArray<T, D> {
}
/// Returns the pointer to the first element of the inner array.
- pub(crate) unsafe fn data(&self) -> *mut T {
+ pub(crate) fn data(&self) ->... | 1 | 3 | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.