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 |
|---|---|---|---|---|---|---|---|
631afa6b18292c2ec2095710f213f24f58c31a69 | Adam Reichold | 2022-03-19T10:50:15 | Enable cloning of shared borrows into NumPy arrays. | diff --git a/src/borrow.rs b/src/borrow.rs
index 76a13e36..e27256b1 100644
--- a/src/borrow.rs
+++ b/src/borrow.rs
@@ -275,6 +275,16 @@ where
}
}
+impl<'a, T, D> Clone for PyReadonlyArray<'a, T, D>
+where
+ T: Element,
+ D: Dimension,
+{
+ fn clone(&self) -> Self {
+ Self::try_new(self.0).unwrap... | 2 | 23 | 0 |
34394f07ce2ab54f266e66879a4a2625d8b36307 | Adam Reichold | 2022-03-20T20:10:37 | Expose fallible variants of the array borrowing methods. | diff --git a/src/array.rs b/src/array.rs
index 4ee5279c..f2661689 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -23,7 +23,7 @@ use crate::borrow::{PyReadonlyArray, PyReadwriteArray};
use crate::cold;
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
use crate::dtype::{Element, PyArrayDes... | 1 | 23 | 3 |
3102b3186390faa832b9612b575c2ee5e302a1a4 | Adam Reichold | 2022-03-10T11:21:19 | Extend integration tests to include the scalar cases for dot and inner. | diff --git a/tests/sum_products.rs b/tests/sum_products.rs
index 352a0f9f..ab336ebc 100644
--- a/tests/sum_products.rs
+++ b/tests/sum_products.rs
@@ -12,6 +12,18 @@ fn test_dot() {
let a = pyarray![py, 1, 2, 3];
let err = dot::<_, _, _, &PyArray2<_>>(a, b).unwrap_err();
assert!(err.to_string... | 1 | 21 | 5 |
3324bc7fe969fdac88e4bd918798ebedfd38dda3 | Adam Reichold | 2022-03-16T18:45:01 | Add a example benchmark for zipped iteration. | diff --git a/benches/iter.rs b/benches/iter.rs
new file mode 100644
index 00000000..76db9490
--- /dev/null
+++ b/benches/iter.rs
@@ -0,0 +1,85 @@
+#![feature(test)]
+#![allow(deprecated)]
+
+extern crate test;
+use test::{black_box, Bencher};
+
+use ndarray::Zip;
+use numpy::{npyiter::NpyMultiIterBuilder, PyArray};
+us... | 1 | 85 | 0 |
0b3a83e56bc4ca2ad481296329c0344fcc433698 | Adam Reichold | 2022-03-17T18:27:28 | Recover lost coverage. | diff --git a/tests/array.rs b/tests/array.rs
index 3bc077c5..92b85dd5 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -461,7 +461,7 @@ fn to_owned_works() {
#[test]
fn copy_to_works() {
- pyo3::Python::with_gil(|py| {
+ Python::with_gil(|py| {
let arr1 = PyArray::arange(py, 2.0, 5.0, 1.0);
... | 2 | 40 | 2 |
a80e9c7475ab2fbcd3589426177e6abf1c1daca4 | Adam Reichold | 2022-03-17T16:05:51 | Tweak code generation of PyArray::from_vec(2/3). | diff --git a/src/array.rs b/src/array.rs
index afbdcb10..786fa0c8 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -19,6 +19,7 @@ use pyo3::{
Python, ToPyObject,
};
+use crate::cold;
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
use crate::dtype::{Element, PyArrayDescr};
use cra... | 2 | 9 | 0 |
0a6c3a4e23ac20e711d1ba2b7772c8831c192006 | Adam Reichold | 2022-03-17T16:05:27 | Factor common code for clone elements into a given data pointer and use it in PyArray::from_slice/vec2/vec3. | diff --git a/src/array.rs b/src/array.rs
index d0b27b5e..afbdcb10 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -954,15 +954,8 @@ impl<T: Element> PyArray<T, Ix1> {
pub fn from_slice<'py>(py: Python<'py>, slice: &[T]) -> &'py Self {
unsafe {
let array = PyArray::new(py, [slice.len()], false... | 1 | 16 | 27 |
6864a8a37ebec5c2078d3aa7d60d5ff9ee64d01f | Adam Reichold | 2022-03-12T15:06:11 | Do not pessimize from_vec2/3 towards rejecting ragged arrays. | diff --git a/src/array.rs b/src/array.rs
index bd00ef83..d0b27b5e 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1097,16 +1097,15 @@ impl<T: Element> PyArray<T, Ix2> {
/// ```
pub fn from_vec2<'py>(py: Python<'py>, v: &[Vec<T>]) -> Result<&'py Self, FromVecError> {
let len2 = v.first().map_or(0, |v... | 1 | 11 | 17 |
a8815fd2dcafa7c1b0e7da2449ba709516ea55dd | Adam Reichold | 2022-03-12T13:49:23 | Avoid enumerating the iterators in PyArray1::from_slice and ArrayBase::to_pyarray. | diff --git a/src/array.rs b/src/array.rs
index d302bdfb..bd00ef83 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -957,9 +957,10 @@ impl<T: Element> PyArray<T, Ix1> {
if T::IS_COPY {
ptr::copy_nonoverlapping(slice.as_ptr(), array.data(), slice.len());
} else {
- ... | 2 | 8 | 6 |
b6c86d0ecc5d8fb493abe11c29678e9bad484e89 | Adam Reichold | 2022-03-12T12:07:37 | Copy the contiguous rows if the element type allows it in from_vec2/3. | diff --git a/src/array.rs b/src/array.rs
index ab98850b..d302bdfb 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1106,9 +1106,14 @@ impl<T: Element> PyArray<T, Ix2> {
let array = Self::new(py, dims, false);
let mut data_ptr = array.data();
for v in v {
- for v in ... | 1 | 16 | 6 |
2d042cb78f1112153272a5343c95ce64f47d3ba0 | Adam Reichold | 2022-03-12T12:05:21 | Avoid the repeated index computations when copying into a contiguous array for from_vec2/3. | diff --git a/src/array.rs b/src/array.rs
index 4d2c1b36..ab98850b 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1095,18 +1095,20 @@ impl<T: Element> PyArray<T, Ix2> {
/// });
/// ```
pub fn from_vec2<'py>(py: Python<'py>, v: &[Vec<T>]) -> Result<&'py Self, FromVecError> {
- let last_len = v.las... | 2 | 51 | 24 |
2c16606944e321b3c0e1cf974b2dbf98baa92b14 | Adam Reichold | 2022-03-12T11:53:50 | Add benchmarks for PyArray2/3::from_vec2/3. | diff --git a/benches/array.rs b/benches/array.rs
index dade7703..f6255a5c 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -5,7 +5,7 @@ use test::{black_box, Bencher};
use std::ops::Range;
-use numpy::PyArray1;
+use numpy::{PyArray1, PyArray2, PyArray3};
use pyo3::{Python, ToPyObject};
struct Iter(Range... | 1 | 51 | 1 |
eb8e2c0a30d5e35420243b99eceb54aec91953d2 | Adam Reichold | 2022-03-13T18:53:54 | Avoid taking the GIL for each benchmark iteration, but also do not leak like a siv. | diff --git a/benches/array.rs b/benches/array.rs
index e2707986..dade7703 100644
--- a/benches/array.rs
+++ b/benches/array.rs
@@ -19,12 +19,10 @@ impl Iterator for Iter {
}
fn from_iter(bencher: &mut Bencher, size: usize) {
- bencher.iter(|| {
+ iter_with_gil(bencher, |py| {
let iter = black_box(Ite... | 1 | 18 | 16 |
065c357f3dee8d3641c87c8f90aaa87fee585d1a | Adam Reichold | 2022-03-12T11:41:35 | Back out of the change to PyArray::from_slice for now as we cannot make this efficient without additional API surface in PyO3. | diff --git a/src/array.rs b/src/array.rs
index 3dc7c82d..4d2c1b36 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -952,8 +952,18 @@ impl<T: Element> PyArray<T, Ix1> {
/// });
/// ```
pub fn from_slice<'py>(py: Python<'py>, slice: &[T]) -> &'py Self {
- let data = slice.to_vec();
- data.into... | 1 | 13 | 3 |
3b80ff547a64c28b3be1f85017812a5366b319e1 | Adam Reichold | 2022-03-11T10:44:23 | Try to recover some of the coverage lost (due to reducing the number of lines overall by reducing the set of covered lines). | diff --git a/tests/array.rs b/tests/array.rs
index 078a329c..9ccb2af7 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -8,7 +8,7 @@ use numpy::{
use pyo3::{
py_run, pyclass, pymethods,
types::{IntoPyDict, PyDict, PyList},
- Py, PyAny, PyCell, PyResult, Python,
+ IntoPy, Py, PyAny, PyCell, PyResult, ... | 1 | 73 | 2 |
b1bd336e62e127e83d4834ba5a743fd0bfd9a764 | Adam Reichold | 2022-03-11T10:01:43 | Switch constructors for one-dimensional arrays to collect Rust-side data structures which then back the NumPy arrays as base objects. | diff --git a/src/array.rs b/src/array.rs
index 9d80e513..3dc7c82d 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -952,18 +952,8 @@ impl<T: Element> PyArray<T, Ix1> {
/// });
/// ```
pub fn from_slice<'py>(py: Python<'py>, slice: &[T]) -> &'py Self {
- unsafe {
- let array = PyArray::ne... | 2 | 18 | 83 |
e4c32d450427e939770b03ee5351940f18c2bebb | Adam Reichold | 2022-03-11T12:46:16 | Add benchmarks for creating one-dimensional arrays. | diff --git a/benches/array.rs b/benches/array.rs
new file mode 100644
index 00000000..e2707986
--- /dev/null
+++ b/benches/array.rs
@@ -0,0 +1,143 @@
+#![feature(test)]
+
+extern crate test;
+use test::{black_box, Bencher};
+
+use std::ops::Range;
+
+use numpy::PyArray1;
+use pyo3::{Python, ToPyObject};
+
+struct Iter(... | 1 | 143 | 0 |
c35b5cd166f85306058be3b33889222d2313f0af | Adam Reichold | 2022-03-11T09:52:20 | Drop PyArray::copy_ptr is somewhat obscures what is happening at the call sites. | diff --git a/src/array.rs b/src/array.rs
index f16dae46..9d80e513 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -356,10 +356,6 @@ impl<T, D> PyArray<T, D> {
let ptr = self.as_array_ptr();
(*ptr).data as *mut _
}
-
- pub(crate) unsafe fn copy_ptr(&self, other: *const T, len: usize) {
- ... | 2 | 4 | 8 |
25d2fdc9fc452efd7fa692fd83aa1028bb8a6cb4 | Adam Reichold | 2022-03-16T13:39:55 | Simplify trait sealing and copy-edit the convert module. | diff --git a/src/array.rs b/src/array.rs
index 9f5297a0..f16dae46 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -401,7 +401,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
let mut inverted_axes = InvertedAxes::new(strides.len());
for i in 0..strides.len() {
- // TODO(kngwyu): Replac... | 4 | 95 | 88 |
a0ce9d71f070c453105f1b89b12244d5dab632d4 | Adam Reichold | 2022-02-23T13:34:11 | Copy-edit the integration tests for simplicity | diff --git a/src/array.rs b/src/array.rs
index 565f027d..3b76f7c5 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1133,8 +1133,10 @@ impl<T: Element> PyArray<T, Ix2> {
/// ```
pub fn from_vec2<'py>(py: Python<'py>, v: &[Vec<T>]) -> Result<&'py Self, FromVecError> {
let last_len = v.last().map_or(0, ... | 5 | 385 | 329 |
b3be43a52ffd5548bc479938042d5c07ae72c9c8 | Adam Reichold | 2022-02-25T16:26:22 | Fix incorrect impl of Iterator::size_hint and add impl of ExactSizeIterator the NumPy iterator wrappers. | diff --git a/src/npyiter.rs b/src/npyiter.rs
index 30d102f5..4d460197 100644
--- a/src/npyiter.rs
+++ b/src/npyiter.rs
@@ -285,7 +285,6 @@ impl<'py, T: Element, I: IterMode> NpySingleIterBuilder<'py, T, I> {
pub struct NpySingleIter<'py, T, I> {
iterator: ptr::NonNull<NpyIter>,
iternext: unsafe extern "C" fn... | 2 | 78 | 13 |
a863dbdf6b685a00e3196375e5378df08dbab244 | Adam Reichold | 2022-02-25T16:17:39 | Give the npyiter module a once-over apply intra-doc links. | diff --git a/src/npyiter.rs b/src/npyiter.rs
index 3866134d..30d102f5 100644
--- a/src/npyiter.rs
+++ b/src/npyiter.rs
@@ -1,14 +1,31 @@
-//! Wrapper of [Array Iterator API](https://numpy.org/doc/stable/reference/c-api/iterator.html).
+//! Wrapper of the [array iterator API][iterator].
//!
-//! This module exposes two... | 1 | 109 | 98 |
ea410caee5873cf5c5ed56db56baf2f51b208e6e | Adam Reichold | 2022-03-03T20:32:51 | Remove the PyArray_* allocation functions again, but give users a hint where to find the underlying PyO3 functions.
This reverts commit 712626b6070226df1e2f460d28028cddd9b3bbff. | diff --git a/Cargo.toml b/Cargo.toml
index ef172c3c..f7f42e1c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,9 +21,6 @@ num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
pyo3 = { version = "0.16", default-features = false }
-[build-dependencies]
-pyo3-build-config = "0.16"
-
[dev-dependencies]
pyo3 = { version = "0... | 3 | 6 | 16 |
712626b6070226df1e2f460d28028cddd9b3bbff | Adam Reichold | 2022-03-01T09:26:42 | Bring the PyArray_* allocation functions back conditionally based on the enabled PyO3 features. | diff --git a/Cargo.toml b/Cargo.toml
index f7f42e1c..ef172c3c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -21,6 +21,9 @@ num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
pyo3 = { version = "0.16", default-features = false }
+[build-dependencies]
+pyo3-build-config = "0.16"
+
[dev-dependencies]
pyo3 = { version = "0... | 3 | 15 | 0 |
990c392e6998e72a689512ac0c27c67e179daa85 | Adam Reichold | 2022-03-01T08:59:28 | Drop the re-exports of PyMem_Raw* calls as those are not available using the limited API. | diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml
index 1adc0243..9c77bffd 100644
--- a/examples/simple/Cargo.toml
+++ b/examples/simple/Cargo.toml
@@ -9,5 +9,5 @@ name = "rust_ext"
crate-type = ["cdylib"]
[dependencies]
-pyo3 = { version = "0.16", features = ["extension-module"] }
+pyo3 = { vers... | 2 | 1 | 7 |
7f8853c85fff2b51c207d3a386e61cef83957961 | Adam Reichold | 2022-02-16T09:00:31 | Do some copy-editing and start making use of intra doc links | diff --git a/src/array.rs b/src/array.rs
index 5f41b041..279b33c2 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1,4 +1,5 @@
-//! Safe interface for NumPy ndarray
+//! Safe interface for NumPy's ndarray class
+
use std::{
marker::PhantomData,
mem,
@@ -22,6 +23,7 @@ use crate::convert::{ArrayExt, IntoPyArra... | 5 | 200 | 138 |
7852fbce8c054f1d5b0cc9f5d0c396356aa7e819 | Adam Reichold | 2022-02-14T20:37:22 | NpyStrides does not require SBO as the upper limit is statically known. | diff --git a/src/convert.rs b/src/convert.rs
index b66020a5..5b520140 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -134,7 +134,12 @@ where
_ => {
// if the array is not contiguous, copy all elements by `ArrayBase::iter`.
let dim = self.raw_dim();
- le... | 1 | 23 | 34 |
35e0bf2c7680252049211b6e9408ddaa6cc0d3cb | Adam Reichold | 2022-02-14T10:03:52 | There seems to be need to support dimensionalities of more than 32 for InvertedAxes as NumPy does not support it in the first place. | diff --git a/src/array.rs b/src/array.rs
index 09dc5799..5f41b041 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -358,46 +358,25 @@ impl<T, D> PyArray<T, D> {
}
}
-enum InvertedAxes {
- Short(u32),
- Long(Vec<usize>),
-}
+struct InvertedAxes(u32);
impl InvertedAxes {
fn new(len: usize) -> Self {
... | 1 | 11 | 32 |
ca4a49e01dc428dabc7f3edb0166e5a57cd9ba6a | Adam Reichold | 2022-02-13T20:27:39 | Small buffer optimization for InvertedAxes
Since InvertedAxes is basically a set of small integers, we can avoid dynamic
allocations by using a word-sized bitmap in the common case of up to 32 axes.
This should also not unduly increase code slice as there is no dynamic spilling
into the large representation, but the ... | diff --git a/src/array.rs b/src/array.rs
index 76846dcd..09dc5799 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -358,12 +358,46 @@ impl<T, D> PyArray<T, D> {
}
}
-struct InvertedAxises(Vec<Axis>);
+enum InvertedAxes {
+ Short(u32),
+ Long(Vec<usize>),
+}
+
+impl InvertedAxes {
+ fn new(len: usize) ->... | 1 | 62 | 25 |
e751b2b4eb3b1478e2c0c5db3646c1934387a231 | Adam Reichold | 2022-02-10T15:07:09 | Re-export PyO3 to make it easier for dependent crates to end up with matching PyO3 versions. | diff --git a/src/lib.rs b/src/lib.rs
index a1bbcac8..3b049cef 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -40,6 +40,7 @@ mod slice_container;
mod sum_products;
pub use ndarray;
+pub use pyo3;
pub use crate::array::{
get_array_module, PyArray, PyArray0, PyArray1, PyArray2, PyArray3, PyArray4, PyArray5, | 1 | 1 | 0 |
8ae263487c675b0041d1ec40aadcbd4a704d5148 | Adam Reichold | 2022-01-26T20:50:49 | Instead of slowing everything down via atomics, utilize that we already hold the GIL when accessing PY_ARRAY_API and PY_UFUNC_API. | diff --git a/src/array.rs b/src/array.rs
index 11bca335..76846dcd 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -120,8 +120,8 @@ unsafe impl<T: Element, D: Dimension> PyTypeInfo for PyArray<T, D> {
const MODULE: ::std::option::Option<&'static str> = Some("numpy");
#[inline]
- fn type_object_raw(_py: Py... | 7 | 135 | 108 |
52782230c0f5c79045a3e4eeb957f71cc91fe08a | Ivan Smirnov | 2022-01-25T12:28:13 | Fix a typo in `PyArray_ArrayDescr` name in npyffi | diff --git a/src/npyffi/objects.rs b/src/npyffi/objects.rs
index 58e35c3f..6b252bcb 100644
--- a/src/npyffi/objects.rs
+++ b/src/npyffi/objects.rs
@@ -35,7 +35,7 @@ pub struct PyArray_Descr {
pub type_num: c_int,
pub elsize: c_int,
pub alignment: c_int,
- pub subarray: *mut PyArrray_ArrayDescr,
+ p... | 1 | 2 | 2 |
61e6363f5d30c08973ee2ba6b3d95109ef8c7a1b | Ivan Smirnov | 2022-01-23T21:16:01 | Add `PyArrayDescr::new()` constructor | diff --git a/src/dtype.rs b/src/dtype.rs
index 0bbeee22..f407d474 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -2,6 +2,7 @@ use std::mem::size_of;
use std::os::raw::{
c_char, c_int, c_long, c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort,
};
+use std::ptr;
use num_traits::{Bounded, Zero};
use ... | 1 | 31 | 0 |
fdb366ef6ff767d9bf7b83baff25bf797e6fc1f0 | Adam Reichold | 2022-01-15T18:48:43 | Provide an efficient way to go from Array<Py<T>, D> to PyArray<PyObject, D>.
The base way to construct a PyArray containing objects in a strongly typed
manner is to crate a ndarray::Array<Py<T>, D> instead of converting it into a
PyArray without copying using this method. | diff --git a/src/array.rs b/src/array.rs
index c94ff85f..58d1b87e 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -629,23 +629,25 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
}
}
- /// Construct PyArray from
- /// [`ndarray::Array`](https://docs.rs/ndarray/latest/ndarray/type.Array.html).
+ ... | 4 | 54 | 12 |
10a0e68c43dc1bdae936a206565f80ded51dd09b | Adam Reichold | 2022-01-09T18:28:49 | Remove unsound custom element example.
While we do check the array data element during extract, we do not check the
type of the individual elements and hence there is no guarantee that they are of
type T or even of uniform type.
But if we did check each element, Python code having a reference the (base)
array could c... | diff --git a/src/dtype.rs b/src/dtype.rs
index 2691433f..dc674ca4 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -292,7 +292,7 @@ impl PyArrayDescr {
/// Represents that a type can be an element of `PyArray`.
///
-/// Currently, only integer/float/complex types are supported.
+/// Currently, only integer/float/com... | 1 | 5 | 33 |
a4a4016fcc94c814ae04c0ff1cc41849eb3780c6 | Ivan Smirnov | 2022-01-22T14:21:29 | `PyArrayDescr::shape` returns empty vec if scalar | diff --git a/src/dtype.rs b/src/dtype.rs
index 74accb71..2691433f 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -190,21 +190,22 @@ impl PyArrayDescr {
}
}
- /// Returns shape tuple of the sub-array if this dtype is a sub-array, and `None` otherwise.
+ /// Returns the shape of the sub-array.
+ ... | 1 | 11 | 10 |
5abc6767de55a0753325192820833f3e718cb157 | Ivan Smirnov | 2022-01-22T03:23:59 | Add tests for all new `PyArrayDescr` methods | diff --git a/src/dtype.rs b/src/dtype.rs
index c00c9fb3..74accb71 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -441,7 +441,12 @@ unsafe impl Element for PyObject {
#[cfg(test)]
mod tests {
- use super::{dtype, Complex32, Complex64, Element};
+ use std::os::raw::c_int;
+
+ use pyo3::{py_run, types::PyDic... | 1 | 112 | 1 |
67e47191b1bf8d97b2e3946572084ce87541eda5 | Ivan Smirnov | 2022-01-22T03:23:19 | Remove `PyArrayDescr::is_unsized` (also redundant) | diff --git a/src/dtype.rs b/src/dtype.rs
index ab174891..c00c9fb3 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -236,12 +236,6 @@ impl PyArrayDescr {
unsafe { !(*self.as_dtype_ptr()).names.is_null() }
}
- /// Returns true if the data type is unsized.
- pub fn is_unsized(&self) -> bool {
- ... | 1 | 0 | 6 |
853117d8fb1423e46f743b775373dd640155fc89 | Ivan Smirnov | 2022-01-22T03:13:04 | Fix in behaviour of `PyArrayDescr::base` | diff --git a/src/dtype.rs b/src/dtype.rs
index ce8422e7..ab174891 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -177,12 +177,17 @@ impl PyArrayDescr {
/// Returns dtype for the base element of subarrays, regardless of their dimension or shape.
///
+ /// If the dtype is not a subarray, returns self.
+ ... | 1 | 8 | 3 |
a9228d4103c41da8a1ca740442a2d1e73bedbe4a | Ivan Smirnov | 2022-01-22T03:11:33 | Remove `PyArrayDescr::subdtype` (redundant) | diff --git a/src/dtype.rs b/src/dtype.rs
index f91b9f12..ce8422e7 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -202,20 +202,6 @@ impl PyArrayDescr {
)
}
- /// Returns `(item_dtype, shape)` if this dtype describes a sub-array, and `None` otherwise.
- ///
- /// The `shape` is the fixed shape o... | 1 | 0 | 14 |
46de0e1dff30638b254081fc1fb81e0ec89f9935 | Ivan Smirnov | 2022-01-21T23:41:03 | (Clarify why `NPY_TYPEKINDCHAR` had to be created) | diff --git a/src/npyffi/types.rs b/src/npyffi/types.rs
index 23c8ed37..e147576f 100644
--- a/src/npyffi/types.rs
+++ b/src/npyffi/types.rs
@@ -235,10 +235,12 @@ pub enum NPY_TYPECHAR {
NPY_UINTPLTR = b'P',
}
+// Note: NPY_TYPEKINDCHAR doesn't exist in the header and has been created here artificially
+// becaus... | 1 | 4 | 2 |
96831e47d07d87c72b6c76fdf23d33969ae90d57 | Ivan Smirnov | 2022-01-21T23:35:45 | Add `PyArrayDescr::get_type()` back as deprecated | diff --git a/src/dtype.rs b/src/dtype.rs
index 9568ab3d..f91b9f12 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -101,6 +101,12 @@ impl PyArrayDescr {
unsafe { PyType::from_type_ptr(self.py(), dtype_type_ptr) }
}
+ #[doc(hidden)]
+ #[deprecated(note = "`get_type()` is deprecated, please use `type... | 1 | 6 | 0 |
8f7ebda93fa058bc3fc71e4e702d90c5bc4d4185 | Ivan Smirnov | 2022-01-21T23:32:17 | (Cleanup of `PyArrayDescr` method docstrings) | diff --git a/src/dtype.rs b/src/dtype.rs
index 58b0ba0f..9568ab3d 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -118,7 +118,7 @@ impl PyArrayDescr {
unsafe { *self.as_dtype_ptr() }.elsize.max(0) as _
}
- /// Returns the required alignment (bytes) of this data-type according to the compiler
+ ///... | 1 | 10 | 10 |
56e6f6f2e28c902d64d3f48190369e4995af4dda | Ivan Smirnov | 2022-01-21T22:28:53 | Replace `PyArrayDescr::fields()` -> `get_field()` | diff --git a/src/dtype.rs b/src/dtype.rs
index 979a2322..58b0ba0f 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -18,6 +18,7 @@ use crate::npyffi::{
};
pub use num_complex::{Complex32, Complex64};
+use pyo3::exceptions::{PyIndexError, PyValueError};
/// Binding of [`numpy.dtype`](https://numpy.org/doc/stable/re... | 1 | 20 | 15 |
96b816ad016aea36e4b68034e68e4084dc8835d0 | Adam Reichold | 2022-01-21T22:27:02 | Add tests for insincere implementations of ExactSizeIterator
https://github.com/PyO3/rust-numpy/pull/262#issuecomment-1018902149 | diff --git a/src/array.rs b/src/array.rs
index f47c453e..ae26f6f0 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1238,7 +1238,9 @@ impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
#[cfg(test)]
mod tests {
- use super::PyArray;
+ use super::*;
+
+ use std::ops::Range;
#[test]
fn test_get_... | 1 | 35 | 1 |
eb37647414850dfd39c13db3332d173adb98a9f2 | Adam Reichold | 2022-01-17T19:29:00 | Add accessors as raw views as an alternative to as_cell_slice when the absence of aliasing views cannot be guaranteed. | diff --git a/src/array.rs b/src/array.rs
index bcb8e828..876a6163 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -8,7 +8,8 @@ use std::{
use ndarray::{
Array, ArrayBase, ArrayView, ArrayViewMut, Axis, Data, Dim, Dimension, IntoDimension, Ix0, Ix1,
- Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn, RawData, Shape, ShapeBuild... | 2 | 30 | 2 |
9a8c376e6e0a5acb8c0f0c717e4e382015f4806c | Ivan Smirnov | 2022-01-20T11:38:26 | `PyArrayDescr::get_type` -> `typeobj` + fix docs | diff --git a/src/dtype.rs b/src/dtype.rs
index af754fc2..979a2322 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -68,21 +68,6 @@ impl PyArrayDescr {
self.into_ptr() as _
}
- /// Returns the internal `PyType` that this `dtype` holds.
- ///
- /// # Example
- /// ```
- /// pyo3::Python::wit... | 1 | 11 | 16 |
1ec6e0dae14638c1b49d9077683905a211cca25c | Ivan Smirnov | 2022-01-19T20:46:53 | A few fixes and simplifications in the new dtype | diff --git a/src/dtype.rs b/src/dtype.rs
index ac0204a8..af754fc2 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -1,4 +1,3 @@
-use std::collections::BTreeMap;
use std::mem::size_of;
use std::os::raw::{
c_char, c_int, c_long, c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort,
@@ -10,7 +9,7 @@ use pyo3:... | 1 | 17 | 23 |
45f6d4a30a2e0f4be7ba7480b00dc149e863ba62 | Ivan Smirnov | 2022-01-19T16:28:19 | Add many `PyArrayDescr` methods like in `np.dtype` | diff --git a/src/dtype.rs b/src/dtype.rs
index 3116237d..ac0204a8 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -1,10 +1,22 @@
+use std::collections::BTreeMap;
use std::mem::size_of;
-use std::os::raw::{c_int, c_long, c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort};
+use std::os::raw::{
+ c_char, c_i... | 1 | 202 | 3 |
5a1a91deb212b6232f8ce6833e4d0ddedaf05269 | Ivan Smirnov | 2022-01-19T16:23:33 | Derive PartialOrd/Ord for NPY_TYPES | diff --git a/src/npyffi/types.rs b/src/npyffi/types.rs
index b889b0cb..23c8ed37 100644
--- a/src/npyffi/types.rs
+++ b/src/npyffi/types.rs
@@ -115,7 +115,7 @@ pub enum NPY_DATETIMEUNIT {
}
#[repr(u32)]
-#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
+#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, PartialOrd,... | 1 | 1 | 1 |
b30701c7293c65a55466a77f78bcc150d08c7c86 | Ivan Smirnov | 2022-01-19T15:48:27 | Rename `PyArrayDescr::get_typenum` -> `num` | diff --git a/src/array.rs b/src/array.rs
index ca09032a..129dadc4 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1219,7 +1219,7 @@ impl<T: Element + AsPrimitive<f64>> PyArray<T, Ix1> {
start.as_(),
stop.as_(),
step.as_(),
- T::get_dtype(py).get_typenum... | 2 | 8 | 5 |
38c42821af20454fd05a753a26f4c9993932658f | Ivan Smirnov | 2022-01-19T14:42:15 | fixup pub type char enums | diff --git a/src/npyffi/types.rs b/src/npyffi/types.rs
index 1afb59b5..b889b0cb 100644
--- a/src/npyffi/types.rs
+++ b/src/npyffi/types.rs
@@ -204,7 +204,7 @@ pub struct npy_stride_sort_item {
#[repr(u8)]
#[derive(Debug, Clone, Copy)]
-enum NPY_TYPECHAR {
+pub enum NPY_TYPECHAR {
NPY_BOOLLTR = b'?',
NPY_B... | 1 | 2 | 2 |
5a78a87c57a958ff3698fe95716bee637f9f4ac8 | Ivan Smirnov | 2022-01-19T12:18:05 | ffi: add descriptor-related flags | diff --git a/src/npyffi/flags.rs b/src/npyffi/flags.rs
index ec842a86..08a1b8f3 100644
--- a/src/npyffi/flags.rs
+++ b/src/npyffi/flags.rs
@@ -1,4 +1,4 @@
-use super::npy_uint32;
+use super::{npy_char, npy_uint32};
use std::os::raw::c_int;
pub const NPY_ARRAY_C_CONTIGUOUS: c_int = 0x0001;
@@ -62,3 +62,21 @@ pub con... | 1 | 19 | 1 |
730867ccd583528adaec29391201240d5a06e14a | Ivan Smirnov | 2022-01-19T12:17:54 | ffi: add two datetime-metadata-related structs | diff --git a/src/npyffi/objects.rs b/src/npyffi/objects.rs
index de3dad03..58e35c3f 100644
--- a/src/npyffi/objects.rs
+++ b/src/npyffi/objects.rs
@@ -398,3 +398,17 @@ pub struct NpyAuxData {
pub type NpyAuxData_FreeFunc = Option<unsafe extern "C" fn(*mut NpyAuxData)>;
pub type NpyAuxData_CloneFunc = Option<unsafe ... | 1 | 14 | 0 |
7d913d6d504d855d079998471785709fe1b855e6 | Ivan Smirnov | 2022-01-19T12:17:41 | ffi: add a few char-like enums | diff --git a/src/npyffi/types.rs b/src/npyffi/types.rs
index 1220f5a1..1afb59b5 100644
--- a/src/npyffi/types.rs
+++ b/src/npyffi/types.rs
@@ -201,3 +201,70 @@ pub struct npy_stride_sort_item {
pub perm: npy_intp,
pub stride: npy_intp,
}
+
+#[repr(u8)]
+#[derive(Debug, Clone, Copy)]
+enum NPY_TYPECHAR {
+ ... | 1 | 67 | 0 |
46d7318437003ca7c21672b4557465d0f0052ff4 | Ivan Smirnov | 2022-01-19T12:17:26 | ffi: add PyArray_{malloc,realloc,free} re-exports | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index f2edcb15..6b23eea5 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -394,6 +394,12 @@ pub unsafe fn PyArray_CheckExact(op: *mut PyObject) -> c_int {
(ffi::Py_TYPE(op) == PY_ARRAY_API.get_type_object(NpyTypes::PyArray_Type)) as _
}
+// the... | 1 | 6 | 0 |
28183f1c513679648aeb5833dfd53d5a6d44e8c7 | Adam Reichold | 2022-01-10T19:29:25 | Limit the scope of allowing clippy::missing_safety_doc to the FFI module. | diff --git a/src/array.rs b/src/array.rs
index 3463b0c3..ca09032a 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -244,13 +244,24 @@ impl<T, D> PyArray<T, D> {
unsafe { Py::from_borrowed_ptr(self.py(), self.as_ptr()) }
}
- /// Constructs `PyArray` from raw python object without incrementing reference... | 3 | 33 | 8 |
fee612df9cc0b3205f3406d1b63e3be19a0e6526 | Ivan Smirnov | 2022-01-10T12:49:58 | (Use `cfg` instead of `size_of::<usize>` in tests) | diff --git a/src/dtype.rs b/src/dtype.rs
index 7218748a..e7b74491 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -254,8 +254,6 @@ unsafe impl Element for PyObject {
#[cfg(test)]
mod tests {
- use std::mem::size_of;
-
use super::{dtype, Complex32, Complex64, Element};
#[test]
@@ -277,16 +275,15 @@ mo... | 1 | 9 | 12 |
c3d0a538885b7ab415c9e9eba6c8e3b0261b2fde | Ivan Smirnov | 2022-01-10T12:32:03 | Add `dtype()` top-level function for convenience | diff --git a/src/array.rs b/src/array.rs
index de6e20e0..3463b0c3 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -168,7 +168,7 @@ impl<T, D> PyArray<T, D> {
/// pyo3::Python::with_gil(|py| {
/// let array = numpy::PyArray::from_vec(py, vec![1, 2, 3i32]);
/// let dtype = array.dtype();
- /// ... | 4 | 12 | 7 |
f08d6e094391fad3fa8dae304a0d057997fa4e0c | Ivan Smirnov | 2022-01-10T12:26:03 | Remove `cfg_if` dependency, clean up dtype macro | diff --git a/Cargo.toml b/Cargo.toml
index 8981aba5..6bcb761e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,7 +15,6 @@ keywords = ["python", "numpy", "ffi", "pyo3"]
license = "BSD-2-Clause"
[dependencies]
-cfg-if = "1.0"
libc = "0.2"
num-complex = ">= 0.2, <= 0.4"
num-traits = "0.2"
diff --git a/src/dtype.rs b... | 2 | 12 | 24 |
61ce229e3d0d81c1bb52c077fd4eaafd2e428842 | Ivan Smirnov | 2022-01-10T12:18:45 | Update the docstring for `Element` | diff --git a/src/dtype.rs b/src/dtype.rs
index f4d501a0..d9068746 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -107,11 +107,14 @@ impl PyArrayDescr {
///
/// # Safety
///
-/// A type `T` that implements this trait should be safe when managed in numpy array,
-/// thus implementing this trait is marked unsafe.
-///... | 1 | 8 | 5 |
2e2b5763997708f534996876bf9a1e4932f09e60 | Ivan Smirnov | 2022-01-10T12:18:36 | Goodbye `DataType` (and update the tests) | diff --git a/src/array.rs b/src/array.rs
index 7b1e07e0..de6e20e0 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -168,7 +168,7 @@ impl<T, D> PyArray<T, D> {
/// pyo3::Python::with_gil(|py| {
/// let array = numpy::PyArray::from_vec(py, vec![1, 2, 3i32]);
/// let dtype = array.dtype();
- /// ... | 4 | 5 | 129 |
fee3283d99391b364d0ce823f8d8f6fd7fff12ce | Ivan Smirnov | 2022-01-10T10:29:40 | Map scalar types directly, bypassing `DataType` | diff --git a/src/dtype.rs b/src/dtype.rs
index 84ce8a9a..d35608d8 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -285,39 +285,89 @@ pub unsafe trait Element: Clone + Send {
fn get_dtype(py: Python) -> &PyArrayDescr;
}
-macro_rules! impl_num_element {
- ($ty:ty, $data_type:expr $(,#[$meta:meta])*) => {
+fn n... | 1 | 69 | 19 |
147775d72150d10aa5bf9cd54e7d1439aeb99881 | Ivan Smirnov | 2022-01-10T09:59:57 | Rename `c*` aliases to `Complex*`, add docstrings | diff --git a/examples/simple-extension/src/lib.rs b/examples/simple-extension/src/lib.rs
index 32137713..9bfa847e 100644
--- a/examples/simple-extension/src/lib.rs
+++ b/examples/simple-extension/src/lib.rs
@@ -1,5 +1,5 @@
use numpy::ndarray::{ArrayD, ArrayViewD, ArrayViewMutD};
-use numpy::{c64, IntoPyArray, PyArrayD... | 3 | 17 | 12 |
8e7c58322ef781431b95df88806a602b49646541 | Ivan Smirnov | 2022-01-10T08:53:26 | Add a test verifying that `hasobject` flag is set | diff --git a/src/array.rs b/src/array.rs
index cc67f20e..7b1e07e0 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1225,4 +1225,16 @@ mod tests {
array.to_dyn().to_owned_array();
})
}
+
+ #[test]
+ fn test_hasobject_flag() {
+ use super::ToPyArray;
+ use pyo3::{py_run, typ... | 1 | 12 | 0 |
6688d79f0642655d19da4334365e26a5240bf42e | Ivan Smirnov | 2022-01-09T22:49:04 | Implement `Element` for `isize` | diff --git a/src/dtype.rs b/src/dtype.rs
index 9ac5eb96..4ff97f8e 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -313,10 +313,9 @@ impl_num_element!(c32, DataType::Complex32);
impl_num_element!(c64, DataType::Complex64);
cfg_if! {
- if #[cfg(target_pointer_width = "64")] {
- impl_num_element!(usize, Data... | 1 | 13 | 10 |
c454a5eae5e6358aad2a21a676e04338d01e6217 | Ivan Smirnov | 2022-01-09T22:34:21 | Replace `Element::DATA_TYPE` with `IS_COPY` | diff --git a/src/array.rs b/src/array.rs
index 75ac8c8c..cc67f20e 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -15,7 +15,7 @@ use std::{
use std::{iter::ExactSizeIterator, marker::PhantomData};
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
-use crate::dtype::{DataType, Element};
+u... | 3 | 16 | 10 |
cf25192c170523cd50269e7ac89ebdfac360cd43 | Ivan Smirnov | 2022-01-09T22:28:58 | `ShapeError` -> `DimensionalityError`/`TypeError` | diff --git a/src/array.rs b/src/array.rs
index f9968ce5..75ac8c8c 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -16,7 +16,7 @@ use std::{iter::ExactSizeIterator, marker::PhantomData};
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
use crate::dtype::{DataType, Element};
-use crate::er... | 3 | 68 | 63 |
fdc389e8165b0636c3a30735bd7a49669e047662 | Ivan Smirnov | 2022-01-09T22:03:46 | Remove `Element::is_same_type()` | diff --git a/src/dtype.rs b/src/dtype.rs
index 51293501..61d444bd 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -259,10 +259,6 @@ impl DataType {
/// unsafe impl Element for Wrapper {
/// const DATA_TYPE: DataType = DataType::Object;
///
-/// fn is_same_type(dtype: &PyArrayDescr) -> bool {
-/// dty... | 1 | 0 | 15 |
5d55c70ea9547c0dd7d1fa44c54731beee84deaa | Ivan Smirnov | 2022-01-09T22:02:49 | Use `is_equiv_to()` in `FromPyObject::extract()` | diff --git a/src/array.rs b/src/array.rs
index 64229607..f9968ce5 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -136,12 +136,13 @@ impl<'a, T: Element, D: Dimension> FromPyObject<'a> for &'a PyArray<T, D> {
}
&*(ob as *const PyAny as *const PyArray<T, D>)
};
- let dtype = arr... | 1 | 8 | 7 |
612e8671ec4f73539bf89eb21ee1933e5b053e40 | Ivan Smirnov | 2022-01-09T22:01:51 | Add `PyArrayDescr::is_equiv_to()` | diff --git a/src/dtype.rs b/src/dtype.rs
index f160a379..51293501 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -84,6 +84,11 @@ impl PyArrayDescr {
T::get_dtype(py)
}
+ /// Returns true if two type descriptors are equivalent.
+ pub fn is_equiv_to(&self, other: &Self) -> bool {
+ unsafe { ... | 1 | 5 | 0 |
5f1b3b68e88e959fccce206dcda6c0edcc05661a | Ivan Smirnov | 2022-01-09T21:48:34 | Clean up typenums, add `DataType::into_typenum()` | diff --git a/src/dtype.rs b/src/dtype.rs
index 20f2b40a..f160a379 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -1,11 +1,12 @@
use std::mem::size_of;
use std::os::raw::{c_int, c_long, c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort};
-use crate::npyffi::{NpyTypes, PyArray_Descr, NPY_TYPES, PY_ARRAY_AP... | 1 | 34 | 26 |
e9cc2a61597315d7506c3268488c26cc44fb986b | Ivan Smirnov | 2022-01-09T21:23:09 | Rework dtype integer type mapping to match numpy | diff --git a/src/dtype.rs b/src/dtype.rs
index c38805a7..20f2b40a 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -1,7 +1,10 @@
+use std::mem::size_of;
+use std::os::raw::{c_int, c_long, c_longlong, c_short, c_uint, c_ulong, c_ulonglong, c_ushort};
+
use crate::npyffi::{NpyTypes, PyArray_Descr, NPY_TYPES, PY_ARRAY_API... | 1 | 85 | 68 |
a2ba3fb63708d528b959ca2452393929b1ae87d1 | Ivan Smirnov | 2022-01-09T21:21:15 | Add tests for dtype names (currently failing) | diff --git a/src/dtype.rs b/src/dtype.rs
index eecb5b89..c38805a7 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -306,3 +306,39 @@ unsafe impl Element for PyObject {
PyArrayDescr::object(py)
}
}
+
+#[cfg(test)]
+mod tests {
+ use cfg_if::cfg_if;
+
+ use super::{c32, c64, Element, PyArrayDescr};
+
... | 1 | 36 | 0 |
2067f837a4086cef71f0cd15312d537070ddaeb2 | Ivan Smirnov | 2022-01-09T21:22:22 | Add `PyArrayDescr::of<T>()` | diff --git a/src/dtype.rs b/src/dtype.rs
index d64e51fa..eecb5b89 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -75,6 +75,11 @@ impl PyArrayDescr {
Self::from_npy_type(py, NPY_TYPES::NPY_OBJECT)
}
+ /// Returns the type descriptor for a registered type.
+ pub fn of<T: Element>(py: Python) -> &Se... | 1 | 5 | 0 |
d1ca21a61a98cc173378ebcda231dfe1bbcc25e2 | Ivan Smirnov | 2022-01-09T19:33:45 | Add `PyArrayDescr::into_dtype_ptr()` | diff --git a/src/array.rs b/src/array.rs
index ecaf4238..64229607 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -430,7 +430,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
let dims = dims.into_dimension();
let ptr = PY_ARRAY_API.PyArray_NewFromDescr(
PY_ARRAY_API.get_type_object(npy... | 2 | 11 | 6 |
82e641bdae26b93817f7b9caac4eb65aa14c1f36 | Ivan Smirnov | 2022-01-09T19:14:54 | Use `PyArray_NewFromDescr`, remove `npy_type()` | diff --git a/src/array.rs b/src/array.rs
index bb740bc9..ecaf4238 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -428,14 +428,13 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
ID: IntoDimension<Dim = D>,
{
let dims = dims.into_dimension();
- let ptr = PY_ARRAY_API.PyArray_New(
+ ... | 2 | 22 | 18 |
9548c5b44fddd0c5993f6083deea2867435af8ef | Yuji Kanagawa | 2022-01-09T04:21:14 | Update metadata in Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 1799d98d..f57d797a 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -2,15 +2,16 @@
name = "numpy"
version = "0.15.1"
authors = [
- "Toshiki Teramura <toshiki.teramura@gmail.com>",
- "Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>",
+ "The rust-numpy Project Developers",... | 1 | 6 | 5 |
6ddec5a7144ea9b68a1b2f6874c019dc31521a4f | David Hewitt | 2022-01-09T08:32:09 | bump version to 0.15.1 | diff --git a/Cargo.toml b/Cargo.toml
index 09a6e855..1799d98d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "numpy"
-version = "0.15.0"
+version = "0.15.1"
authors = [
"Toshiki Teramura <toshiki.teramura@gmail.com>",
"Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>", | 1 | 1 | 1 |
7c63a12e3ca93995392e6062fbf0a4c5e0fc18c4 | Adam Reichold | 2022-01-08T17:40:08 | Fix typo in PY_ARRAY_API docs. | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 6d2e18fd..f2edcb15 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -13,7 +13,7 @@ const CAPSULE_NAME: &str = "_ARRAY_API";
/// A global variable which stores a ['capsule'](https://docs.python.org/3/c-api/capsule.html)
/// pointer to [Numpy Arr... | 1 | 1 | 1 |
c91e2dcd85161cfe9252e8c77c409e5ac51ff3dd | Adam Reichold | 2022-01-06T11:58:53 | Only inlcude the examples from the README for doctesting. | diff --git a/src/lib.rs b/src/lib.rs
index 2e370aa8..3b762941 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -59,9 +59,8 @@ pub use crate::readonly::{
pub use crate::sum_products::{dot, einsum_impl, inner};
pub use ndarray::{array, Ix1, Ix2, Ix3, Ix4, Ix5, Ix6, IxDyn};
-/// Test readme
-#[doc(hidden)]
-pub mod doc_tes... | 1 | 2 | 3 |
99bffc875508c1c12370441a41c0bc08af7f20f7 | Adam Reichold | 2022-01-06T11:52:51 | Remove macro_use directives which are not necessary with Rust edition 2018. | diff --git a/src/array.rs b/src/array.rs
index 40faec1e..bb740bc9 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -3,8 +3,8 @@ use crate::npyffi::{self, npy_intp, NPY_ORDER, PY_ARRAY_API};
use ndarray::*;
use num_traits::AsPrimitive;
use pyo3::{
- ffi, prelude::*, type_object, types::PyAny, AsPyPointer, PyDowncas... | 3 | 6 | 13 |
f91d8aed89dbf5a6ac80a6201a8cc4cc74945399 | Adam Reichold | 2022-01-05T12:34:52 | Bump dependency on cfg-if so that we do not pull in the pre-1.0 version into other crates dependency tree. | diff --git a/Cargo.toml b/Cargo.toml
index 006c0900..b013c84c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ keywords = ["numpy", "python", "binding"]
license = "BSD-2-Clause"
[dependencies]
-cfg-if = "0.1"
+cfg-if = "1.0"
libc = "0.2"
num-complex = ">= 0.2, <= 0.4"
num-traits = "0.2" | 1 | 1 | 1 |
7176bcec47b34319ea069fa4dc58817e6e61bf57 | Adam Reichold | 2022-01-06T09:38:37 | Use a more specific name for the Owner type, i.e. PySliceContainer. | diff --git a/src/array.rs b/src/array.rs
index c2776dd2..40faec1e 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -17,7 +17,7 @@ use std::{iter::ExactSizeIterator, marker::PhantomData};
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
use crate::dtype::{DataType, Element};
use crate::erro... | 3 | 37 | 27 |
dd675ba37a572181b2c0ca1af3fa390789e863df | Adam Reichold | 2021-12-30T08:35:20 | Unify implemenation of Array::from_raw_parts and ::borrow_from_array
Both create an array from existing data, they just differ w.r.t. how
the how the owner on the Python heap is handled. | diff --git a/src/array.rs b/src/array.rs
index ad15a6dd..c2776dd2 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -432,31 +432,26 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
PY_ARRAY_API.get_type_object(npyffi::NpyTypes::PyArray_Type),
dims.ndim_cint(),
dims.as_dims_ptr(),
-... | 1 | 33 | 31 |
f24bbdcc17fc4563ebafe2b468cedb68ebe02343 | Adam Reichold | 2021-12-30T11:14:23 | Extend SliceBox into Owner which can hold onto both Box<[T]> and Vec<T>
By providing type erasure for both Box<[T]> and Vec<T> we can avoid having to
transform Vec<T> and Array<A, D> into boxed slices which can potentially re-allocate. | diff --git a/src/array.rs b/src/array.rs
index 5121ef64..ad15a6dd 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -17,7 +17,7 @@ use std::{iter::ExactSizeIterator, marker::PhantomData};
use crate::convert::{ArrayExt, IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
use crate::dtype::{DataType, Element};
use crate::erro... | 5 | 139 | 93 |
baddc20dd62d394d4d5c746b9168935cc5a6f3e3 | Adam Reichold | 2022-01-05T12:31:14 | Make stable Clippy happy.
It seems preferable to have a clean CI based on stable Clippy,
than to accomodate a not-yet-released version. | diff --git a/src/array.rs b/src/array.rs
index 4b5294dd..16bf7e46 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -448,7 +448,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
ID: IntoDimension<Dim = D>,
{
let dims = dims.into_dimension();
- let data_ptr = data_ptr.unwrap_or(boxed_slice.... | 1 | 1 | 1 |
f828e481b61b1cd61ee0873a1ab9bf77e0c19c63 | Adam Reichold | 2021-12-29T18:49:38 | Add PyArray::borrow_from_array | diff --git a/src/array.rs b/src/array.rs
index 4b5294dd..4030f934 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -6,10 +6,15 @@ use pyo3::{
ffi, prelude::*, type_object, types::PyAny, AsPyPointer, PyDowncastError, PyNativeType,
PyResult,
};
-use std::{cell::Cell, mem, os::raw::c_int, ptr, slice};
+use std::... | 3 | 107 | 6 |
83c8e1956a28ec7a804d058381b1eb0ed4923892 | Adam Reichold | 2021-12-30T10:36:50 | Fix SliceBox-induced type confusion by manually performing type erasure. | diff --git a/src/slice_box.rs b/src/slice_box.rs
index 3db96f48..6be4621d 100644
--- a/src/slice_box.rs
+++ b/src/slice_box.rs
@@ -4,29 +4,41 @@ use pyo3::pyclass_slots::PyClassDummySlot;
use pyo3::type_object::{LazyStaticType, PyTypeInfo};
use pyo3::{ffi, types::PyAny, PyCell};
-pub(crate) struct SliceBox<T> {
- ... | 2 | 30 | 17 |
daa317caa46113aac9fe02c006f800a5edab666b | Adam Reichold | 2021-12-30T10:29:03 | Make SliceBox hide its internals and add a test case for SliceBox-induced type confusion. | diff --git a/src/array.rs b/src/array.rs
index 08f694dd..4b5294dd 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -448,8 +448,8 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
ID: IntoDimension<Dim = D>,
{
let dims = dims.into_dimension();
+ let data_ptr = data_ptr.unwrap_or(boxed_slice.... | 3 | 25 | 5 |
dc72f137f88ff05e0c94812544f481b1be9ae374 | Adam Reichold | 2021-12-29T18:32:39 | Make Clippy happy | diff --git a/src/array.rs b/src/array.rs
index 578ee50e..08f694dd 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -449,7 +449,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
{
let dims = dims.into_dimension();
let container = SliceBox::new(boxed_slice);
- let data_ptr = data_ptr.unwrap... | 2 | 3 | 1 |
209a0cafd88c9561e4e12ce4f885b9ffc9874baa | Adam Reichold | 2021-12-17T18:03:11 | Fix typo in IntoPyArray docs. | diff --git a/src/convert.rs b/src/convert.rs
index dd6825a0..d545579d 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -10,7 +10,7 @@ use crate::{
DataType, Element, PyArray,
};
-/// Covnersion trait from some rust types to `PyArray`.
+/// Conversion trait from some rust types to `PyArray`.
///
/// This tr... | 1 | 1 | 1 |
a0ecc3f3df82d2e5590a2be52ac6c0382aca72d8 | Adam Reichold | 2021-11-23T18:12:55 | Make API globals thread safe using atomics
While the GIL is held when the API pointer is updated, this can still race with
other threads checking the current value of the API pointer (without holding the
GIL) and should therefore using atomics.
The loads and stores are performed using acquire-release semantics as we ... | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 2c91a217..6d2e18fd 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -2,7 +2,8 @@
use libc::FILE;
use pyo3::ffi::{self, PyObject, PyTypeObject};
use std::os::raw::*;
-use std::{cell::Cell, ptr};
+use std::ptr::null_mut;
+use std::sync::atomic::... | 2 | 41 | 25 |
11182ec85b0cb6330c92f1b8b890128c07602f90 | Adam Reichold | 2021-11-10T13:05:21 | Make the PyArray::new method unsafe and document what can and cannot be done with its return value. | diff --git a/src/array.rs b/src/array.rs
index fd13a86a..3565e01d 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -249,7 +249,7 @@ impl<T, D> PyArray<T, D> {
/// ```
/// use numpy::PyArray3;
/// pyo3::Python::with_gil(|py| {
- /// let arr = PyArray3::<f64>::new(py, [4, 5, 6], false);
+ /// ... | 2 | 70 | 36 |
e4e33ab2b0a3c40ce8357afdab6b1a9317a512ab | Adam Reichold | 2021-11-10T12:27:20 | No need to explicitly request zero objects (which would yield valid non-null pointers to the None object). | diff --git a/src/array.rs b/src/array.rs
index a6706064..fd13a86a 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -447,6 +447,9 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
/// If `is_fortran` is true, then
/// a fortran order array is created, otherwise a C-order array is created.
///
+ /// For ... | 1 | 9 | 16 |
534deee7f6116c0e620ffbb1ed57337e7c045014 | Adam Reichold | 2021-11-07T12:55:05 | Extend trait Element's doc comment to include an example for a custom element type. | diff --git a/src/dtype.rs b/src/dtype.rs
index 0aad9da8..4ee013bc 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -182,6 +182,41 @@ impl DataType {
/// This means that all data types except for `DataType::Object` are assumed to be trivially copyable.
/// Furthermore, it is assumed that for `DataType::Object` the elem... | 3 | 37 | 2 |
b6e58e26b1b37ea44c934ab9f61f8e2b758cb763 | Adam Reichold | 2021-11-07T13:43:08 | Add a test for the ToPyArray impl for ArrayBase. | diff --git a/tests/to_py.rs b/tests/to_py.rs
index f87825c0..da08424b 100644
--- a/tests/to_py.rs
+++ b/tests/to_py.rs
@@ -192,3 +192,33 @@ fn to_pyarray_object_vec() {
}
})
}
+
+#[test]
+fn to_pyarray_object_array() {
+ use ndarray::Array2;
+ use pyo3::{
+ types::{PyDict, PyString},
+ ... | 1 | 30 | 0 |
f5fe2badd473bee11186b1e9769498ec0c004dc6 | Adam Reichold | 2021-11-07T12:16:10 | Make PyArray::from_(exact_)iter sound by avoiding to free uninitialized memory if the iterator panics. | diff --git a/src/array.rs b/src/array.rs
index b767fe7c..a6706064 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -776,7 +776,14 @@ impl<T: Element> PyArray<T, Ix1> {
/// });
/// ```
pub fn from_exact_iter(py: Python<'_>, iter: impl ExactSizeIterator<Item = T>) -> &Self {
- let array = Self::new(p... | 1 | 16 | 2 |
c8a2d8cf91809a630f64ebf8340d905f2e9053c4 | Adam Reichold | 2021-11-07T12:13:19 | Do not assume trivally copyable types for Element impls using DataType::Object. | diff --git a/src/array.rs b/src/array.rs
index ab91fe74..b767fe7c 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -10,7 +10,7 @@ use std::{cell::Cell, mem, os::raw::c_int, ptr, slice};
use std::{iter::ExactSizeIterator, marker::PhantomData};
use crate::convert::{IntoPyArray, NpyIndex, ToNpyDims, ToPyArray};
-use cr... | 2 | 34 | 21 |
9c6244b3972c0519a30e86c9eeb5500ae9223b27 | Adam Reichold | 2021-11-06T11:56:23 | Give PyArray<PyObject> another try. | diff --git a/src/dtype.rs b/src/dtype.rs
index 051a6cd9..0aad9da8 100644
--- a/src/dtype.rs
+++ b/src/dtype.rs
@@ -179,8 +179,9 @@ impl DataType {
///
/// A type `T` that implements this trait should be safe when managed in numpy array,
/// thus implementing this trait is marked unsafe.
-/// For example, we don't su... | 2 | 33 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.