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 |
|---|---|---|---|---|---|---|---|
964b320e656c47bc93fab9e59f9c5da39dc44b80 | kngwyu | 2018-10-09T13:48:28 | Refactor documentation | diff --git a/src/array.rs b/src/array.rs
index 0b1f8284..95e41ab4 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1,6 +1,6 @@
//! Safe interface for NumPy ndarray
use ndarray::*;
-use npyffi::{self, npy_intp, PY_ARRAY_API};
+use npyffi::{self, npy_intp, PY_ARRAY_API, NPY_ORDER};
use num_traits::AsPrimitive;
use py... | 4 | 83 | 17 |
6b19b6de64180e74fbf92ae3786de341e0879394 | kngwyu | 2018-10-09T07:55:12 | Expose resize as public API | diff --git a/src/array.rs b/src/array.rs
index c1cc91ec..0b1f8284 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -530,19 +530,35 @@ impl<T: TypeNum> PyArray<T, Ix1> {
if length >= capacity {
capacity *= 2;
array
- .resize_([capacity], 0,... | 1 | 19 | 3 |
9c4dcecd98298e908e304205b46b387250f3f85e | kngwyu | 2018-10-07T06:21:56 | Expose PyArray::get and uget | diff --git a/src/array.rs b/src/array.rs
index 7ed580ec..a1bc866f 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -9,7 +9,7 @@ use std::mem;
use std::os::raw::c_int;
use std::ptr;
-use convert::ToNpyDims;
+use convert::{NpyIndex, ToNpyDims};
use error::{ErrorKind, IntoPyErr};
use types::{NpyDataType, TypeNum, NPY... | 3 | 118 | 24 |
dfabc95d1b025315a4be2af9812653622799baeb | kngwyu | 2018-10-06T11:48:19 | Modify ToNpyDims to inherit Dimension
so that we can take impl IntoDimension as argument | diff --git a/src/array.rs b/src/array.rs
index 0e812a02..7ed580ec 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -415,15 +415,14 @@ impl<T: TypeNum> PyArray<T> {
S: Data<Elem = T>,
D: Dimension,
{
- let dims: Vec<_> = arr.shape().iter().cloned().collect();
- let len = dims.iter().f... | 4 | 41 | 51 |
d80f2a3d444ba3fd9868edc9989ddc8b128aac7e | kngwyu | 2018-10-06T11:18:08 | Modify docs | diff --git a/src/array.rs b/src/array.rs
index 4f424b86..0e812a02 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -443,13 +443,26 @@ impl<T: TypeNum> PyArray<T> {
}
}
- /// Get data as a ndarray::ArrayView
+ /// Get the immutable view of the internal data of `PyArray`, as `ndarray::ArrayView`.
+ ... | 2 | 22 | 8 |
8485d97e8b018d05d1eba760b9c34218275e3da6 | kngwyu | 2018-10-06T10:40:42 | Modify arange to take T as start&end&step | diff --git a/Cargo.toml b/Cargo.toml
index fef6a667..61bb9b83 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,5 +13,6 @@ license-file = "LICENSE"
cfg-if = "0.1.5"
libc = "0.2"
num-complex = "0.2"
+num-traits = "0.2.6"
ndarray = "0.12"
pyo3 = "0.4.1"
diff --git a/src/array.rs b/src/array.rs
index daa8b5fe..4f424b86... | 4 | 52 | 26 |
2ed632a1f233efaf376c23fd88326d5957bd7627 | kngwyu | 2018-10-06T07:34:20 | Re-Implement PyArray::from_iter and PyArray::from_exact_iter | diff --git a/src/array.rs b/src/array.rs
index 60e05067..4a8fc2db 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1,5 +1,4 @@
//! Safe interface for NumPy ndarray
-
use ndarray::*;
use npyffi::{self, npy_intp, PY_ARRAY_API};
use pyo3::*;
@@ -111,7 +110,7 @@ impl<T> PyArray<T> {
/// # extern crate pyo3; extern... | 2 | 93 | 23 |
fb71b3e0c15e881f5fb696470e018e4d8ed60569 | kngwyu | 2018-10-06T05:04:04 | Remove IntoPyObject in favour of ToPyObject(&self, py) -> &PyArray | diff --git a/src/array.rs b/src/array.rs
index 52717a25..60e05067 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1,14 +1,17 @@
//! Safe interface for NumPy ndarray
use ndarray::*;
-use npyffi::{self, PY_ARRAY_API};
+use npyffi::{self, npy_intp, PY_ARRAY_API};
use pyo3::*;
+use std::iter::ExactSizeIterator;
use ... | 4 | 167 | 151 |
e372f0bdd61073abbbb48b08b21da5dfa4907b42 | kngwyu | 2018-10-02T05:16:14 | Update ndarray and num-complex | diff --git a/Cargo.toml b/Cargo.toml
index dfefa5ed..fef6a667 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,6 +12,6 @@ license-file = "LICENSE"
[dependencies]
cfg-if = "0.1.5"
libc = "0.2"
-num-complex = ">= 0.1"
-ndarray = ">= 0.11"
+num-complex = "0.2"
+ndarray = "0.12"
pyo3 = "0.4.1"
diff --git a/src/lib.rs b/... | 2 | 2 | 3 |
dc1cc3c9f5f7e40f08780f9ba69068bfaf71e2c8 | kngwyu | 2018-10-02T03:44:44 | Rename ArrayCastError to ErrorKind
To support more numpy operations | diff --git a/src/array.rs b/src/array.rs
index 628e97b2..52717a25 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -7,7 +7,7 @@ use std::marker::PhantomData;
use std::os::raw::c_void;
use std::ptr::null_mut;
-use super::error::ArrayCastError;
+use super::error::ErrorKind;
use super::*;
/// Interface for [NumPy n... | 2 | 55 | 47 |
f113a8e6782fdbe61b398d1aafa1c2aaf5b35170 | kngwyu | 2018-10-02T02:49:38 | Remove some ToNpyDims implementation
We treat only &[usize] or [usize; N] as dimension | diff --git a/src/array.rs b/src/array.rs
index c2eb22cb..628e97b2 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -126,7 +126,7 @@ impl<T> PyArray<T> {
/// # extern crate pyo3; extern crate numpy; fn main() {
/// use numpy::PyArray;
/// let gil = pyo3::Python::acquire_gil();
- /// let arr = PyArray::<... | 3 | 10 | 46 |
75dee30981ea6c045df3bc3345a1bf8cdd05bc44 | kngwyu | 2018-10-01T10:13:42 | Implement PyArray::reshape | diff --git a/src/array.rs b/src/array.rs
index b824ad96..c2eb22cb 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -481,10 +481,7 @@ impl<T: TypeNum> PyArray<T> {
let other_ptr = other.as_array_ptr();
let result = unsafe { PY_ARRAY_API.PyArray_CopyInto(other_ptr, self_ptr) };
if result == -1 {... | 4 | 126 | 25 |
55f7b1d34633265222816eca6cbcd2cd759ce6b6 | kngwyu | 2018-09-30T08:55:59 | Introduce ToNpyDims trait
So that we can use both &[2, 3] and [2, 3] to specify array dims | diff --git a/src/array.rs b/src/array.rs
index 7a936348..b824ad96 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -77,7 +77,7 @@ impl<T> PyArray<T> {
/// use numpy::PyArray;
/// fn return_py_array() -> PyArray<i32> {
/// let gil = Python::acquire_gil();
- /// let array = PyArray::zeros(gil.pytho... | 3 | 91 | 24 |
0fa3bd16225ff0572dc31a064b777129d4669f06 | kngwyu | 2018-09-30T06:25:48 | Add document about PyArray::to_owned | diff --git a/src/array.rs b/src/array.rs
index a06d547b..7a936348 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -62,6 +62,28 @@ impl<T> PyArray<T> {
self.as_ptr() as _
}
+ /// Get `PyArray` from `&PyArray`, by increasing ref counts.
+ ///
+ /// You can use this method when you have to avoid l... | 1 | 22 | 0 |
cd8229908fb2b90ac285613cb523d99da9e3cb87 | kngwyu | 2018-09-30T03:23:37 | Use Once to ensure thread safety of initializing Numpy API | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 83bded72..3ce4d42f 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -4,6 +4,7 @@ use pyo3::ffi::{self, PyObject, PyTypeObject};
use std::ops::Deref;
use std::os::raw::*;
use std::ptr;
+use std::sync::{Once, ONCE_INIT};
use npyffi::*;
@@ -... | 2 | 12 | 5 |
149de74b0099943541b7df929a364972d03c31fb | kngwyu | 2018-09-29T10:24:55 | Fix all tests | diff --git a/src/array.rs b/src/array.rs
index 30838d44..b3c53e7e 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -13,6 +13,10 @@ use super::*;
/// Interface for [NumPy ndarray](https://docs.scipy.org/doc/numpy/reference/arrays.ndarray.html).
pub struct PyArray<T>(PyObject, PhantomData<T>);
+pub fn get_array_module... | 7 | 101 | 120 |
e9ab6bdcb007b67cc7cdfd4354179cccb2310bb1 | kngwyu | 2018-09-29T07:48:27 | Return &PyArray instead of PyArray, in all APIs | diff --git a/src/array.rs b/src/array.rs
index b465e779..b2f6cb0d 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -59,15 +59,13 @@ impl<T> PyArray<T> {
}
/// Constructs `PyArray` from raw python object without incrementing reference counts.
- pub unsafe fn from_owned_ptr(py: Python, ptr: *mut pyo3::ffi::... | 2 | 53 | 26 |
d4a7610c259786c9e4ef4adff9ca07e3a1dcda79 | kngwyu | 2018-09-29T07:37:15 | Remove PyArrayModule in favour of PyArrayAPI | diff --git a/src/array.rs b/src/array.rs
index d83392d2..b465e779 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1,7 +1,7 @@
//! Safe interface for NumPy ndarray
use ndarray::*;
-use npyffi;
+use npyffi::{self, PyArrayAPI};
use pyo3::*;
use std::marker::PhantomData;
use std::os::raw::c_void;
@@ -15,7 +15,7 @@ ... | 4 | 96 | 161 |
4df8836df84507557a09a9dca91ac5e47c5c2da5 | kngwyu | 2018-09-25T04:42:13 | Add array_cast test for 2 dimentional array | diff --git a/tests/array.rs b/tests/array.rs
index 34921e06..e4758abf 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -181,3 +181,17 @@ macro_rules! small_array_test {
}
small_array_test!(i8 u8 i16 u16 i32 u32 i64 u64);
+
+#[test]
+fn array_cast() {
+ let gil = pyo3::Python::acquire_gil();
+ let py = gil.... | 1 | 14 | 0 |
7357a1e887fea5aa867574387488e60e1109bb50 | kngwyu | 2018-09-25T04:06:27 | Implement PyArray::cast | diff --git a/src/array.rs b/src/array.rs
index 75757c09..d83392d2 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -515,4 +515,35 @@ impl<T: TypeNum> PyArray<T> {
Ok(())
}
}
+
+ /// Cast the `PyArray<T>` to `PyArray<U>`, by allocating a new array.
+ /// # Example
+ /// ```
+ /// # ... | 1 | 31 | 0 |
cd3f15637a927cb16e623bafee477f5dc2977f50 | kngwyu | 2018-09-21T10:27:41 | Implement PyArray::copy_to, move_to | diff --git a/src/array.rs b/src/array.rs
index f2047e0a..75757c09 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -455,4 +455,64 @@ impl<T: TypeNum> PyArray<T> {
Self::from_owned_ptr(py, ptr)
}
}
+
+ /// Copies self into `other`, performing a data-type conversion if necessary.
+ /// # E... | 2 | 72 | 8 |
0b941e481714df305109cc60ae9b3dcf65bdcdac | kngwyu | 2018-09-06T07:58:50 | Bump version to 0.3.2 | diff --git a/Cargo.toml b/Cargo.toml
index feaefcf8..dfefa5ed 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "numpy"
-version = "0.3.1"
+version = "0.3.2"
authors = ["Toshiki Teramura <toshiki.teramura@gmail.com>"]
description = "Rust binding of NumPy C-API"
@@ -12,6 +12,6 @@ license-fi... | 1 | 2 | 2 |
a837c63db01e55f4a5d6fffb9f4dd2ac90bad907 | kngwyu | 2018-09-06T03:07:46 | Use inequality requirements for ndarray | diff --git a/Cargo.toml b/Cargo.toml
index c43bc36d..feaefcf8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "numpy"
-version = "0.3.0"
+version = "0.3.1"
authors = ["Toshiki Teramura <toshiki.teramura@gmail.com>"]
description = "Rust binding of NumPy C-API"
@@ -13,5 +13,5 @@ license-fi... | 2 | 3 | 3 |
c838ba03fc58a0a61c0986ce41bf55f4d22c3503 | kngwyu | 2018-09-06T03:02:23 | Update ndarray | diff --git a/Cargo.toml b/Cargo.toml
index 2261c27a..c43bc36d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,5 +13,5 @@ license-file = "LICENSE"
cfg-if = "0.1.5"
libc = "0.2"
num-complex = "0.1"
-ndarray = "0.11"
+ndarray = "0.12"
pyo3 = "0.4.1" | 1 | 1 | 1 |
cb16390b058dc9bd050ec4280d6fdaa3317f6736 | kngwyu | 2018-08-22T05:41:38 | Add module/crate level docs | diff --git a/src/convert.rs b/src/convert.rs
index 53530795..8ae55da9 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -1,3 +1,5 @@
+//! Defines conversion trait between rust types and numpy data types.
+
use ndarray::*;
use pyo3::Python;
diff --git a/src/error.rs b/src/error.rs
index 10452f29..14964e6f 100644
-... | 4 | 37 | 1 |
c4979f148d0e9c5cc1496c429457f13b6e09c1cd | kngwyu | 2018-08-21T04:22:14 | update pyo3 | diff --git a/Cargo.toml b/Cargo.toml
index 1e4b992c..8686003f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,4 +14,4 @@ cfg-if = "0.1.5"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
-pyo3 = { git = "https://github.com/kngwyu/pyo3.git", branch = "upd" }
+pyo3 = "0.4.1"
diff --git a/example/extensions/Cargo.toml... | 2 | 2 | 3 |
e4cda62b2587a4c9f11a46bbf81418eca5b6f39a | kngwyu | 2018-08-18T09:46:39 | Refactor | diff --git a/src/types.rs b/src/types.rs
index 49299c2c..32cc5b94 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -35,24 +35,12 @@ impl NpyDataType {
x if x == NPY_TYPES::NPY_BYTE as i32 => NpyDataType::Int8,
x if x == NPY_TYPES::NPY_SHORT as i32 => NpyDataType::Int16,
x if x == N... | 1 | 23 | 17 |
2f929943e468b580e30963266bc624e1c3c899ee | kngwyu | 2018-08-18T06:47:27 | Add test for all integers
+ Fix bug in array -> PyArray | diff --git a/src/convert.rs b/src/convert.rs
index ee568815..53530795 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -63,9 +63,9 @@ macro_rules! array_impls {
$(
impl<T: TypeNum> IntoPyArray for [T; $N] {
type Item = T;
- fn into_pyarray(mut self, py: Python, n... | 2 | 25 | 12 |
977b25617ad32d35b63667e44ab62ec5a535e3d3 | kngwyu | 2018-08-18T06:15:06 | Remove debug output for appveyor | diff --git a/src/array.rs b/src/array.rs
index 9894cc95..f2047e0a 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -35,15 +35,14 @@ impl<'a, T: TypeNum> FromPyObject<'a> for &'a PyArray<T> {
fn extract(ob: &'a PyObjectRef) -> PyResult<Self> {
let array = unsafe {
if npyffi::PyArray_Check(ob.as... | 1 | 4 | 5 |
173145abcaa487b8d30041cabc41c92d964e9190 | kngwyu | 2018-08-18T05:50:33 | Fix doctest
In case PyArray::new() returns not zero-filled array | diff --git a/src/array.rs b/src/array.rs
index 806c3828..9894cc95 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -397,8 +397,8 @@ impl<T: TypeNum> PyArray<T> {
/// use numpy::{PyArray, PyArrayModule};
/// let gil = pyo3::Python::acquire_gil();
/// let np = PyArrayModule::import(gil.python()).unwrap();
-... | 1 | 2 | 2 |
9fcfaeb8f6b19b380c95f7a7aa6af2d161a8ed77 | kngwyu | 2018-08-18T05:43:05 | Now rust type can have multiple scalar types | diff --git a/Cargo.toml b/Cargo.toml
index 0fcdeff8..1e4b992c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,6 +10,7 @@ keywords = ["numpy", "python", "binding"]
license-file = "LICENSE"
[dependencies]
+cfg-if = "0.1.5"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
diff --git a/src/array.rs b/src/array.rs
i... | 5 | 44 | 34 |
aa25757e21d010c05e5855a9fc0b808d5f7e4abd | kngwyu | 2018-08-18T05:01:24 | Add debug Output for appveyor | diff --git a/src/array.rs b/src/array.rs
index 960c928e..fa4035ec 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -35,14 +35,15 @@ impl<'a, T: TypeNum> FromPyObject<'a> for &'a PyArray<T> {
fn extract(ob: &'a PyObjectRef) -> PyResult<Self> {
let array = unsafe {
if npyffi::PyArray_Check(ob.as... | 1 | 5 | 4 |
ff87dcf79b4d5f93536cc95dc763ed480deed226 | kngwyu | 2018-08-17T06:35:50 | Add i8/u8/i16/u16 support | diff --git a/src/types.rs b/src/types.rs
index 7694a076..00b24e9d 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -13,8 +13,12 @@ use super::npyffi::NPY_TYPES;
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum NpyDataType {
Bool,
+ Int8,
+ Int16,
Int32,
Int64,
+ Uint8,
+ Uint16,
Uint32,
... | 1 | 31 | 4 |
51c4860b9ddaede27120db2177fb20b434f4f388 | kngwyu | 2018-08-17T03:52:06 | Use git version of pyo3 temporary | diff --git a/Cargo.toml b/Cargo.toml
index 22387738..0fcdeff8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,4 +13,4 @@ license-file = "LICENSE"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
-pyo3 = "0.4.0"
+pyo3 = { git = "https://github.com/kngwyu/pyo3.git", branch = "upd" }
diff --git a/example/extensions/Ca... | 2 | 6 | 2 |
76c7b67cbed1a6e0719090a69071107bf274a55a | kngwyu | 2018-08-14T03:37:50 | Fix tests | diff --git a/tests/array.rs b/tests/array.rs
index bc0e2892..5413f882 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -24,12 +24,12 @@ fn zeros() {
let np = PyArrayModule::import(gil.python()).unwrap();
let n = 3;
let m = 5;
- let arr = PyArray::<f64>::zeros(gil.python(), &np, &[n, m], NPY_CORDER)... | 1 | 3 | 3 |
d97371a3a60439bb09e4257ae8dedd026eb6924b | kngwyu | 2018-08-14T03:36:26 | Minor fixes | diff --git a/src/array.rs b/src/array.rs
index fbf51f3d..0a346a5a 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -10,7 +10,7 @@ use std::ptr::null_mut;
use super::error::ArrayCastError;
use super::*;
-/// Untyped safe interface for NumPy ndarray.
+/// Interface for [NumPy ndarray](https://docs.scipy.org/doc/numpy/... | 3 | 11 | 17 |
9339ff0a9386235ad8de1794589b22abf3013a89 | kngwyu | 2018-08-14T03:27:05 | Add some api docs | diff --git a/src/array.rs b/src/array.rs
index 163a8425..fbf51f3d 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -58,11 +58,13 @@ impl<T> PyArray<T> {
self.as_ptr() as _
}
+ /// Construct PyArray from raw python object(not increment reference count).
pub unsafe fn from_owned_ptr(py: Python, ptr... | 3 | 71 | 8 |
0fc37494aed46098ca6e32dcc86b91bd9e3d2d1b | konstin | 2018-08-04T21:51:12 | Make the example an extension module
This fixes and the build for python3.5 for me and would also be required for publishing on pypi | diff --git a/Cargo.toml b/Cargo.toml
index fbf716ec..22387738 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,4 +14,3 @@ libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
pyo3 = "0.4.0"
-
diff --git a/example/extensions/Cargo.toml b/example/extensions/Cargo.toml
index 8d51cf31..bc05249a 100644
--- a/example/extensio... | 2 | 1 | 2 |
b98efb6c352b5a978c0d8a58c5aafd6fb2f3d66a | kngwyu | 2018-08-03T08:04:52 | Remove ToPyArray and Add PyArray::from_iter | diff --git a/src/array.rs b/src/array.rs
index 67021204..163a8425 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -166,6 +166,24 @@ impl<T: TypeNum> PyArray<T> {
IntoPyArray::into_pyarray(v, py, np)
}
+ /// Construct one-dimension PyArray from `impl IntoIterator`.
+ ///
+ /// # Example
+ ///... | 4 | 21 | 21 |
e9fbabbae6e2ea8042f5bf546274e48aa2fd8067 | kngwyu | 2018-08-03T07:40:52 | Update pyo3 | diff --git a/Cargo.toml b/Cargo.toml
index ddfd8e4f..fbf716ec 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,5 +13,5 @@ license-file = "LICENSE"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
-pyo3 = { git = "https://github.com/pyo3/pyo3", rev = "547fa35604a61d2d750390940ed5a0d34ed09821"}
+pyo3 = "0.4.0"
diff... | 2 | 2 | 2 |
4e5a8fecb93c7c792b3372f698fc45b3152bb7e2 | kngwyu | 2018-07-29T08:23:03 | Refactor | diff --git a/src/array.rs b/src/array.rs
index c1abfe83..67021204 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -29,18 +29,20 @@ impl<'a, T> ::std::convert::From<&'a PyArray<T>> for &'a PyObjectRef {
}
impl<'a, T: TypeNum> FromPyObject<'a> for &'a PyArray<T> {
+ // here we do type-check twice
+ // 1. Checks... | 3 | 35 | 28 |
5b8092518db3aeed44384a8add355a0d595d4b34 | kngwyu | 2018-07-29T08:09:20 | Update pyo3 dependency | diff --git a/Cargo.toml b/Cargo.toml
index e5d9313e..ddfd8e4f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,5 +13,5 @@ license-file = "LICENSE"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
-pyo3 = { git = "https://github.com/kngwyu/pyo3", branch = "native-type-with-generics"}
+pyo3 = { git = "https://github... | 2 | 2 | 2 |
41eea5ff1e46b9bacfc0a2359a106894d33a07ef | kngwyu | 2018-07-28T15:53:03 | Introduce NpyDataTypes for better error message | diff --git a/src/array.rs b/src/array.rs
index 9b7e765e..c1abfe83 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -13,13 +13,37 @@ use super::*;
/// Untyped safe interface for NumPy ndarray.
pub struct PyArray<T>(PyObject, PhantomData<T>);
-pyobject_native_type!(
+pyobject_native_type_convert!(
PyArray<T>,
... | 5 | 107 | 23 |
283530115876ab8135707fa119cd5437ea584949 | kngwyu | 2018-07-28T13:55:50 | Add PyArrayModule::as_pymodule and eval test | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 3ab740f5..06d24417 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -60,6 +60,32 @@ impl<'py> PyArrayModule<'py> {
Ok(mod_)
}
+ /// Returns internal `PyModule` type, which includes `numpy.core.multiarray`,
+ /// so that you ... | 3 | 46 | 0 |
ef3db8b7a1b559dd94cf26e4c7207de295e4cfd9 | kngwyu | 2018-07-28T06:02:22 | Static type checking with PhantomData | diff --git a/Cargo.toml b/Cargo.toml
index 11bbac89..bed73166 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,4 +13,8 @@ license-file = "LICENSE"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.11"
-pyo3 = "0.3.1"
+pyo3 = { git = "https://github.com/kngwyu/pyo3", branch = "native-type-with-generics"}
+
+[features]
+d... | 7 | 197 | 199 |
5ed39ab27618ccde371fde3099c6efc89996b370 | kngwyu | 2018-07-28T04:24:54 | Implement IntoPyArray for small array types | diff --git a/src/convert.rs b/src/convert.rs
index 0deedaeb..85b8fbdc 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -41,6 +41,30 @@ impl<A: TypeNum, D: Dimension> IntoPyArray for Array<A, D> {
}
}
+macro_rules! array_impls {
+ ($($N: expr)+) => {
+ $(
+ impl<T: TypeNum> IntoPyArray fo... | 2 | 34 | 0 |
415a7cc87809e34e26fd91024283f26aa7c37fdb | kngwyu | 2018-07-27T03:53:02 | Change from_vec2/3 to take &Vec instead of consuming | diff --git a/src/array.rs b/src/array.rs
index 6279a107..434a6c59 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -71,22 +71,22 @@ impl PyArray {
/// let gil = pyo3::Python::acquire_gil();
/// let np = PyArrayModule::import(gil.python()).unwrap();
/// let vec2 = vec![vec![1, 2, 3]; 2];
- /// let pyarr... | 3 | 12 | 12 |
89f248c26f61f15621976a6ebbd093575ad28810 | kngwyu | 2018-07-26T02:41:55 | Fix tests | diff --git a/src/array.rs b/src/array.rs
index 2fd17340..6279a107 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -104,11 +104,11 @@ impl PyArray {
/// use numpy::{PyArray, PyArrayModule};
/// let gil = pyo3::Python::acquire_gil();
/// let np = PyArrayModule::import(gil.python()).unwrap();
- /// let v... | 2 | 16 | 8 |
f75b13e027748864367107ceae8888d43ef3d6e9 | kngwyu | 2018-07-25T15:59:50 | Add from_vec3 and from_boxed_slice | diff --git a/src/array.rs b/src/array.rs
index 17de5e60..2fd17340 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -26,6 +26,23 @@ impl PyArray {
self.as_ptr() as _
}
+ /// Construct one-dimension PyArray from boxed slice.
+ ///
+ /// # Example
+ /// ```
+ /// # extern crate pyo3; extern c... | 1 | 60 | 3 |
c0792a10965ad053d74fdd784883e3d8e472af95 | kngwyu | 2018-07-25T15:30:24 | Simplify code | diff --git a/src/array.rs b/src/array.rs
index 9b6edaad..17de5e60 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -65,22 +65,12 @@ impl PyArray {
v: Vec<Vec<T>>,
) -> Result<PyArray, ArrayCastError>
{
- let mut flattend = Vec::new();
- let mut size = None;
- let len = v.len();
- ... | 1 | 4 | 14 |
cf36b2e5433f19004c797edc12910b76b901c4a2 | kngwyu | 2018-07-25T09:29:54 | Rename ArrayCastError::IntoArray to ToRust | diff --git a/src/array.rs b/src/array.rs
index 187553e9..9b6edaad 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -224,7 +224,7 @@ impl PyArray {
if A::typenum() == self.typenum() {
Ok(())
} else {
- Err(ArrayCastError::into_array(test, truth))
+ Err(ArrayCastError::... | 2 | 7 | 7 |
e1e901a215ca6cea5c22c90b8bd32a3de0197c0f | kngwyu | 2018-07-25T08:53:26 | Add PyArray::from_vec2 | diff --git a/src/array.rs b/src/array.rs
index 4c03a7bf..187553e9 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -42,6 +42,51 @@ impl PyArray {
IntoPyArray::into_pyarray(v, py, np)
}
+ /// Construct two-dimension PyArray from `Vec<Vec<T>>`.
+ ///
+ /// This function checks all dimension of inn... | 4 | 87 | 31 |
948c3b93bfabf20503ec58e0cd73c143ce77f299 | kngwyu | 2018-07-25T06:15:14 | Implement IntoPyArray for Vec<Vec<T>> | diff --git a/src/convert.rs b/src/convert.rs
index f5551dde..f5706c97 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -12,6 +12,14 @@ pub trait IntoPyArray {
fn into_pyarray(self, Python, &PyArrayModule) -> PyArray;
}
+impl<T: TypeNum> IntoPyArray for Box<[T]> {
+ fn into_pyarray(self, py: Python, np: &P... | 1 | 29 | 2 |
cee8a9f4ae5ed1f14466b2757ee2f8aed6116acb | kngwyu | 2018-07-25T06:27:18 | Fix doc comment | diff --git a/src/array.rs b/src/array.rs
index 0528b1c7..4c03a7bf 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -42,13 +42,12 @@ impl PyArray {
IntoPyArray::into_pyarray(v, py, np)
}
- /// Construct one-dimension PyArray from ndarray::Array.
+ /// Construct PyArray from ndarray::Array.
///
... | 1 | 1 | 2 |
01e8012a71e6708494476a426790acb8995b2008 | kngwyu | 2018-07-25T03:53:16 | Simplify doc test with `into_dyn` method | diff --git a/src/array.rs b/src/array.rs
index 157bc410..0528b1c7 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -52,10 +52,7 @@ impl PyArray {
/// let gil = pyo3::Python::acquire_gil();
/// let np = PyArrayModule::import(gil.python()).unwrap();
/// let pyarray = PyArray::from_ndarray::<u32, _>(gil.pyth... | 1 | 1 | 4 |
b8833799be4eb5163e12ce221cab6de89b3a4498 | kngwyu | 2018-07-24T09:36:48 | Add PyArray::from_vec and PyArray::from_ndarray | diff --git a/src/array.rs b/src/array.rs
index 44b2754d..157bc410 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -26,6 +26,46 @@ impl PyArray {
self.as_ptr() as _
}
+ /// Construct one-dimension PyArray from Vec.
+ ///
+ /// # Example
+ /// ```
+ /// # extern crate pyo3; extern crate num... | 2 | 42 | 2 |
8999c9da188384a023b0bb13002a9aabb8ef6896 | kngwyu | 2018-07-19T05:59:20 | Update ndarray to 0.11 | diff --git a/Cargo.toml b/Cargo.toml
index 730d3d15..11bbac89 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,5 +12,5 @@ license-file = "LICENSE"
[dependencies]
libc = "0.2"
num-complex = "0.1"
-ndarray = "0.10"
+ndarray = "0.11"
pyo3 = "0.3.1"
diff --git a/example/extensions/Cargo.toml b/example/extensions/Cargo.t... | 2 | 2 | 2 |
d4abefe01de4ef2f3ea40625384b4079b4db3fd7 | kngwyu | 2018-07-19T03:29:16 | Modify PyArray::shape & PyArray::strides to return slice
To avoid allocation overhead | diff --git a/src/array.rs b/src/array.rs
index cc45b865..44b2754d 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -21,6 +21,7 @@ impl IntoPyObject for PyArray {
}
impl PyArray {
+ /// Get raw pointer for PyArrayObject
pub fn as_array_ptr(&self) -> *mut npyffi::PyArrayObject {
self.as_ptr() as _
... | 2 | 63 | 27 |
076e2d87e5cfe8cd04cdf2cba5ed79cbf1f03c51 | kngwyu | 2018-07-03T05:03:49 | Add is_instance test | diff --git a/tests/array.rs b/tests/array.rs
index 99e937ee..a05c0f81 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -104,3 +104,13 @@ fn iter_to_pyarray() {
println!("arr = {:?}", arr.as_slice::<i32>().unwrap());
assert_eq!(arr.shape(), [10]);
}
+
+#[test]
+fn is_instance() {
+ let gil = pyo3::Pytho... | 1 | 10 | 0 |
4b05393aff354ac64c3a5fc5e6164efc4f99c1f6 | kngwyu | 2018-07-03T02:10:41 | Make PyArray_Type_Ptr only visible in crate | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 2d4f328c..3ab740f5 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -26,7 +26,7 @@ pub struct PyArrayModule<'py> {
}
#[allow(non_upper_case_globals)]
-pub static mut PyArray_Type_Ptr: *mut PyTypeObject = null_mut();
+pub(crate) static mut PyA... | 1 | 1 | 1 |
3fcc5291df5e892f9096206b720d0c32017d0f94 | kngwyu | 2018-07-02T07:43:44 | Use pointer to have PyArray_Type in global scope
to avoid copy | diff --git a/Cargo.toml b/Cargo.toml
index 9f6c7b7d..2ff118f3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,5 +15,5 @@ num-complex = "0.1"
ndarray = "0.10"
[dependencies.pyo3]
-git = "https://github.com/PyO3/pyo3.git"
-rev = "c22bec6124ab68f47a7f28550931e3060f89071b"
+git = "https://github.com/PyO3/pyo3"
+rev = "... | 3 | 7 | 9 |
2628624c7470f0d732716c1ade50eb7d2d482deb | kngwyu | 2018-07-02T03:11:00 | Add PyArray_Type_Global
To adapt to PyO3 interface | diff --git a/Cargo.toml b/Cargo.toml
index a0af50c1..9f6c7b7d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -15,6 +15,5 @@ num-complex = "0.1"
ndarray = "0.10"
[dependencies.pyo3]
-git = "http://github.com/termoshtt/pyo3"
-branch = "pyobject_macros"
-version = "0.2"
+git = "https://github.com/PyO3/pyo3.git"
+rev = "c... | 3 | 17 | 14 |
2e1b06913855b51daed6628fd0cc13826fb8b747 | Toshiki Teramura | 2018-05-13T08:23:38 | Use pyobject_native_type macro exposed in https://github.com/PyO3/pyo3/pull/155 | diff --git a/Cargo.toml b/Cargo.toml
index d81a6d04..a0af50c1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,4 +13,8 @@ license-file = "LICENSE"
libc = "0.2"
num-complex = "0.1"
ndarray = "0.10"
-pyo3 = "0.2"
+
+[dependencies.pyo3]
+git = "http://github.com/termoshtt/pyo3"
+branch = "pyobject_macros"
+version = "0.... | 3 | 9 | 6 |
1958ae1ba8a0e4ba4c86421cca504f6febbef73c | Toshiki Teramura | 2018-05-04T08:18:54 | Update sample | diff --git a/example/extensions/Cargo.toml b/example/extensions/Cargo.toml
index 78b3e8a4..b8fd62d8 100644
--- a/example/extensions/Cargo.toml
+++ b/example/extensions/Cargo.toml
@@ -9,5 +9,8 @@ crate-type = ["cdylib"]
[dependencies]
numpy = { path = "../.." }
-cpython = "0.1"
ndarray = "0.10"
+
+[dependencies.pyo... | 2 | 39 | 43 |
4a9fbe32b15ff6381e6f27a1ea080e28cd732211 | Toshiki Teramura | 2018-05-04T07:18:39 | Drop unsupported traits from PyArray | diff --git a/src/array.rs b/src/array.rs
index 0b64d254..76063cdc 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -14,13 +14,15 @@ use super::*;
/// Untyped safe interface for NumPy ndarray.
pub struct PyArray(PyObject);
-impl PyArray {
- pub fn as_ptr(&self) -> *mut npyffi::PyArrayObject {
- self.0.as_pt... | 1 | 13 | 83 |
fadd273148eb674e26c22c9ff8f0789dbfb9b8cb | Toshiki Teramura | 2018-05-03T19:47:45 | Fix imports | diff --git a/example/extensions/src/lib.rs b/example/extensions/src/lib.rs
index 83dd0a48..5babdd42 100644
--- a/example/extensions/src/lib.rs
+++ b/example/extensions/src/lib.rs
@@ -1,12 +1,12 @@
#[macro_use]
-extern crate cpython;
+extern crate pyo3;
extern crate numpy;
extern crate ndarray;
use numpy::*;
us... | 10 | 31 | 31 |
cbbb4bf09461e89eaeaec7b759ebb675a9f44c50 | Toshiki Teramura | 2018-05-03T19:32:46 | Add PyO3 | diff --git a/Cargo.toml b/Cargo.toml
index a0bc4c7c..d81a6d04 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,7 +11,6 @@ license-file = "LICENSE"
[dependencies]
libc = "0.2"
-cpython = "0.1"
-python3-sys = "0.1"
num-complex = "0.1"
ndarray = "0.10"
+pyo3 = "0.2"
diff --git a/src/lib.rs b/src/lib.rs
index 0784be97... | 2 | 2 | 4 |
1c6f59c890c593963d5b740b3415b1d8010ee4a0 | Toshiki Teramura | 2017-07-18T06:29:45 | Use ndarray-0.10 #21 | diff --git a/Cargo.toml b/Cargo.toml
index 0fa654c0..a0bc4c7c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,4 +14,4 @@ libc = "0.2"
cpython = "0.1"
python3-sys = "0.1"
num-complex = "0.1"
-ndarray = "0.9"
+ndarray = "0.10"
diff --git a/example/extensions/Cargo.toml b/example/extensions/Cargo.toml
index cb777d0e..7... | 2 | 3 | 3 |
0e7e8fe83e47bada22617c300b77c375d877e5ff | Toshiki Teramura | 2017-05-16T03:43:08 | Add error conversion | diff --git a/example/extensions/src/lib.rs b/example/extensions/src/lib.rs
index 6d031294..83dd0a48 100644
--- a/example/extensions/src/lib.rs
+++ b/example/extensions/src/lib.rs
@@ -25,14 +25,14 @@ fn mult(a: f64, mut x: ArrayViewMutD<f64>) {
// wrapper of `axpy`
fn axpy_py(py: Python, a: f64, x: PyArray, y: PyArray... | 3 | 29 | 3 |
bf1c88cd13aed0a9e707b31b19cc3a0d43dc52b2 | Toshiki Teramura | 2017-05-16T02:52:22 | Re-add `mult` as mutable/no-return example | diff --git a/example/extensions/src/lib.rs b/example/extensions/src/lib.rs
index 27f8b585..6d031294 100644
--- a/example/extensions/src/lib.rs
+++ b/example/extensions/src/lib.rs
@@ -6,14 +6,23 @@ extern crate ndarray;
use numpy::*;
use ndarray::*;
-use cpython::{PyResult, Python};
+use cpython::{PyResult, Python, ... | 1 | 21 | 4 |
0ebb08ad0fbaaa968bc716ecb6f5d64626feb484 | Toshiki Teramura | 2017-05-15T17:21:25 | axpy example | diff --git a/example/extensions/src/lib.rs b/example/extensions/src/lib.rs
index 1d39dade..27f8b585 100644
--- a/example/extensions/src/lib.rs
+++ b/example/extensions/src/lib.rs
@@ -6,27 +6,26 @@ extern crate ndarray;
use numpy::*;
use ndarray::*;
-use cpython::{PyResult, Python, PyObject};
+use cpython::{PyResult... | 1 | 17 | 18 |
a47e30f182cbd41fd3d842c9e30864b0165c853c | Toshiki Teramura | 2017-05-14T08:08:43 | Add sample print function | diff --git a/example/extensions/Cargo.toml b/example/extensions/Cargo.toml
index 2483be18..cb777d0e 100644
--- a/example/extensions/Cargo.toml
+++ b/example/extensions/Cargo.toml
@@ -10,3 +10,4 @@ crate-type = ["cdylib"]
[dependencies]
numpy = { path = "../.." }
cpython = "*"
+ndarray = "*"
diff --git a/example/exte... | 3 | 27 | 1 |
35c3aa171062052f61a0d872a5f240165ac44a7e | Toshiki Teramura | 2017-05-13T09:35:18 | Revise type publication | diff --git a/src/lib.rs b/src/lib.rs
index b9ddb17e..a694d277 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -12,6 +12,6 @@ pub mod error;
pub mod convert;
pub use array::PyArray;
-pub use types::TypeNum;
+pub use types::*;
pub use convert::{IntoPyArray, ToPyArray};
-pub use npyffi::{PyArrayModule, PyUFuncModule, npy... | 2 | 7 | 3 |
242ec884c74bc993d4af0734251fc1aadae05f06 | Toshiki Teramura | 2017-05-13T09:34:40 | Use TypeNum also in zeros and arange | diff --git a/src/array.rs b/src/array.rs
index 169a0250..b2d994db 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -157,15 +157,14 @@ impl PyArray {
}
/// a wrapper of [PyArray_ZEROS](https://docs.scipy.org/doc/numpy/reference/c-api.array.html#c.PyArray_ZEROS)
- pub fn zeros(py: Python,
- ... | 2 | 18 | 36 |
815d615f51328e22ef27d000cbe16520592d9ff9 | Toshiki Teramura | 2017-05-13T09:22:44 | IntoPyArray for ndarray::Array | diff --git a/src/convert.rs b/src/convert.rs
index d5ee789f..8685d280 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -1,8 +1,11 @@
use cpython::Python;
+use ndarray::*;
+
use std::os::raw::c_void;
use std::ptr::null_mut;
use std::iter::Iterator;
+use std::mem::size_of;
use super::*;
@@ -13,14 +16,29 @@ ... | 2 | 41 | 4 |
8d1ea5bacc72717597ce712e8dd692f8b6fe9ff3 | Toshiki Teramura | 2017-05-13T08:36:55 | Add ToPyArray | diff --git a/src/convert.rs b/src/convert.rs
index 675ecfa2..d5ee789f 100644
--- a/src/convert.rs
+++ b/src/convert.rs
@@ -1,6 +1,8 @@
use cpython::Python;
use std::os::raw::c_void;
+use std::ptr::null_mut;
+use std::iter::Iterator;
use super::*;
@@ -10,20 +12,24 @@ pub trait IntoPyArray {
impl<T: TypeNum> ... | 3 | 29 | 12 |
3877fc08e483637ed5c1a05649111ea070b5ea49 | Toshiki Teramura | 2017-05-13T08:23:37 | Use type specification on PyArray::new | diff --git a/src/array.rs b/src/array.rs
index c3b00a77..169a0250 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -5,6 +5,9 @@ use pyffi;
use cpython::*;
use ndarray::*;
+use std::os::raw::c_void;
+use std::ptr::null_mut;
+
use super::*;
use super::error::ArrayCastError;
@@ -128,22 +131,29 @@ impl PyArray {
... | 2 | 21 | 11 |
5223b9049de4bc6f43c66ac6f52aadb5dd4c179e | Toshiki Teramura | 2017-05-12T08:31:17 | Remove panic | diff --git a/tests/array.rs b/tests/array.rs
index 1fb302fe..8dbce12b 100644
--- a/tests/array.rs
+++ b/tests/array.rs
@@ -88,5 +88,4 @@ fn into_pyarray() {
let arr = a.into_pyarray(gil.python(), &np);
println!("arr.shape = {:?}", arr.shape());
println!("arr = {:?}", arr.as_slice::<i32>().unwrap());
- ... | 1 | 0 | 1 |
dff27cb3135e284473b04e12c6aa4ce37b4a59d7 | Toshiki Teramura | 2017-05-12T08:26:00 | Implement IntoPyArray for Vec<T> | diff --git a/src/array.rs b/src/array.rs
index b94aa201..c3b00a77 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -136,11 +136,12 @@ impl PyArray {
dims.len() as i32,
dims.as_ptr() as *mut npy_intp,
typenum... | 4 | 50 | 5 |
8f70353c0319dd3309f701aad81b400dadc59cf8 | Toshiki Teramura | 2017-05-11T16:08:59 | Use isize for strides | diff --git a/src/array.rs b/src/array.rs
index 76ede9aa..b94aa201 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -64,14 +64,14 @@ impl PyArray {
///
/// - https://docs.scipy.org/doc/numpy/reference/c-api.array.html#c.PyArray_STRIDES
/// - https://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarra... | 2 | 7 | 7 |
d86039834deb47aefe636cd8dc7aecffa0c311a7 | Toshiki Teramura | 2017-05-11T14:23:19 | Define Error struct (remove moc) | diff --git a/src/array.rs b/src/array.rs
index caadd392..76ede9aa 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -95,10 +95,12 @@ impl PyArray {
}
fn type_check<A: types::TypeNum>(&self) -> Result<(), ArrayCastError> {
+ let test = A::typenum();
+ let truth = self.typenum();
if A::ty... | 2 | 30 | 2 |
36ff1fa4b4b812d9afcc0988e4ec52fde9893a49 | Toshiki Teramura | 2017-05-11T14:17:12 | Add error check | diff --git a/src/array.rs b/src/array.rs
index 7ce24be4..caadd392 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -87,31 +87,41 @@ impl PyArray {
shape.strides(Dim(st))
}
- fn type_check<A>(&self) -> Result<(), ArrayCastError> {
- // TODO type check
- Ok(())
+ pub fn typenum(&self) -... | 3 | 31 | 7 |
f0b67b256562caf9b3b2fb706f800af77c1dcccf | Toshiki Teramura | 2017-05-11T13:46:39 | Add as_array and related functions | diff --git a/Cargo.toml b/Cargo.toml
index 47a30ec9..50c5a372 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,3 +14,4 @@ libc = "0.2"
cpython = "0.1"
python3-sys = "0.1"
num-complex = "0.1"
+ndarray = "0.9"
diff --git a/src/array.rs b/src/array.rs
index e8e414f1..7ce24be4 100644
--- a/src/array.rs
+++ b/src/array.rs... | 5 | 68 | 21 |
4423d6e0ca81c24475b279731a8958aa6a74f1ff | Toshiki Teramura | 2017-05-11T07:03:51 | Fix import name (miss in rebase) | diff --git a/src/types.rs b/src/types.rs
index 38b37e70..8365667e 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -1,8 +1,9 @@
-pub use npffi::NPY_TYPES;
pub use num_complex::Complex32 as c32;
pub use num_complex::Complex64 as c64;
+pub use super::npyffi::NPY_TYPES;
+
pub trait TypeNum {
fn typenum_enum() -... | 1 | 2 | 1 |
17543192ba02fba6066ecc57670cf7031245cecc | Toshiki Teramura | 2017-05-11T07:03:03 | Fix typo | diff --git a/Cargo.toml b/Cargo.toml
index 66139df3..47a30ec9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,4 +13,4 @@ license-file = "LICENSE"
libc = "0.2"
cpython = "0.1"
python3-sys = "0.1"
-num-compelx = "0.1"
+num-complex = "0.1" | 1 | 1 | 1 |
b68cf0557240c5e7339ae0edf693e761991eaab3 | Toshiki Teramura | 2017-05-06T10:49:40 | Add TypeNum trait | diff --git a/Cargo.toml b/Cargo.toml
index 0171d5f4..66139df3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,3 +13,4 @@ license-file = "LICENSE"
libc = "0.2"
cpython = "0.1"
python3-sys = "0.1"
+num-compelx = "0.1"
diff --git a/src/lib.rs b/src/lib.rs
index 289f8a76..e870052a 100644
--- a/src/lib.rs
+++ b/src/lib.r... | 3 | 33 | 0 |
3c7d7872130b5b75985b3959385e71ffe4872592 | Toshiki Teramura | 2017-05-11T06:14:33 | Add document URL in Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 5e93cab0..0171d5f4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,9 +1,10 @@
[package]
name = "numpy"
-version = "0.1.0"
+version = "0.1.1"
authors = ["Toshiki Teramura <toshiki.teramura@gmail.com>"]
description = "Rust binding of NumPy C-API"
+documentation = "https://d... | 1 | 2 | 1 |
246f87c45b62098077cbfb1ac6cfe01eb12769b1 | Toshiki Teramura | 2017-05-11T06:10:59 | Update document of numpy::array | diff --git a/src/array.rs b/src/array.rs
index 5c745a0b..e8e414f1 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -1,3 +1,4 @@
+//! Untyped safe interface for NumPy ndarray
use npyffi;
use pyffi;
@@ -5,6 +6,7 @@ use cpython::*;
use npyffi::PyArrayModule;
use super::*;
+/// Untyped safe interface for NumPy ndarr... | 1 | 10 | 8 |
96dc966b03e63eea42b3c739a3563c2ca64bf5dd | Toshiki Teramura | 2017-05-11T06:03:32 | Add module document of npyffi | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index 27a33506..e1bb9f5a 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -1,3 +1,6 @@
+//! Low-Level binding for Array API
+//!
+//! https://docs.scipy.org/doc/numpy/reference/c-api.array.html
use std::os::raw::*;
use std::ptr::null_mut;
@@ -10,7 ... | 4 | 21 | 3 |
e04d2200b38c87e06e836b73b31f63ee7dac28ae | Toshiki Teramura | 2017-05-11T05:51:54 | Add documents on UFunc API | diff --git a/src/npyffi/ufunc.rs b/src/npyffi/ufunc.rs
index 3434baf8..9a65f438 100644
--- a/src/npyffi/ufunc.rs
+++ b/src/npyffi/ufunc.rs
@@ -11,6 +11,10 @@ use cpython::{Python, PythonObject, ObjectProtocol, PyResult, PyModule};
use super::types::*;
use super::objects::*;
+/// UFunc API
+/// https://docs.scipy.or... | 1 | 56 | 52 |
3771422e40d160690c99d0f6aa3fa462928b9096 | Toshiki Teramura | 2017-05-10T17:13:34 | Add info in Cargo.toml | diff --git a/Cargo.toml b/Cargo.toml
index 6b9d5662..5e93cab0 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,12 @@ name = "numpy"
version = "0.1.0"
authors = ["Toshiki Teramura <toshiki.teramura@gmail.com>"]
+description = "Rust binding of NumPy C-API"
+repository = "https://github.com/termoshtt/rust-numpy"
+k... | 1 | 6 | 1 |
6bae77e754e0b70f866f21180d9f55197841e04e | Toshiki Teramura | 2017-05-10T16:16:51 | Rename (s/MultiArray/PyArrayModule/g) also on test | diff --git a/numpy-example/src/lib.rs b/numpy-example/src/lib.rs
index a461291f..6a09d160 100644
--- a/numpy-example/src/lib.rs
+++ b/numpy-example/src/lib.rs
@@ -13,7 +13,7 @@ py_module_initializer!(librust2py, initlibrust2py, PyInit_librust2py, |py, m| {
});
fn get_arr_py(py: Python) -> PyResult<PyArray> {
- l... | 2 | 4 | 4 |
9454ba588149f1a65183614e192bf776e16de39e | Toshiki Teramura | 2017-05-10T16:13:43 | Update PyUFunc API | diff --git a/src/lib.rs b/src/lib.rs
index 43e19b23..289f8a76 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,4 +7,4 @@ pub mod array;
pub mod npyffi;
pub use array::PyArray;
-pub use npyffi::{PyArrayModule, npy_intp, NPY_TYPES, NPY_ORDER};
+pub use npyffi::{PyArrayModule, PyUFuncModule, npy_intp, NPY_TYPES, NPY_ORD... | 3 | 36 | 18 |
8a5a53b80089fddefea22a7945cd20e5e4b3b387 | Toshiki Teramura | 2017-05-10T16:06:33 | Rename MultiArray -> PyArrayModule | diff --git a/src/array.rs b/src/array.rs
index aadc6f20..bd99662b 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -2,7 +2,7 @@
use npyffi;
use pyffi;
use cpython::*;
-use npyffi::MultiArray;
+use npyffi::PyArrayModule;
use super::*;
pub struct PyArray(PyObject);
@@ -89,7 +89,7 @@ impl PyArray {
/// a wrap... | 4 | 18 | 18 |
21e853b11a98a3bd539840bfec8a461507695fe0 | Toshiki Teramura | 2017-05-10T16:04:22 | Merge objects into npyffi::object | diff --git a/src/npyffi/iterator.rs b/src/npyffi/iterator.rs
deleted file mode 100644
index 52436dd2..00000000
--- a/src/npyffi/iterator.rs
+++ /dev/null
@@ -1,211 +0,0 @@
-#![allow(non_camel_case_types)]
-
-use pyffi::*;
-use std::os::raw::*;
-use std::option::Option;
-
-use super::types::*;
-use super::array::*;
-
-#... | 4 | 180 | 288 |
72b490ddc09ae5cfcece251a1cde2046e5bdabd5 | Toshiki Teramura | 2017-05-10T14:57:18 | Update numpy-test | diff --git a/numpy-test/src/lib.rs b/numpy-test/src/lib.rs
index 39b59961..a461291f 100644
--- a/numpy-test/src/lib.rs
+++ b/numpy-test/src/lib.rs
@@ -8,17 +8,16 @@ use cpython::{PyResult, Python};
py_module_initializer!(librust2py, initlibrust2py, PyInit_librust2py, |py, m| {
try!(m.add(py, "__doc__", "This mo... | 1 | 6 | 7 |
9c8b6b80d3e0d4519ab049971b91c1cb29cfd0f1 | Toshiki Teramura | 2017-05-10T14:52:08 | Update test for array and fix bug | diff --git a/src/array.rs b/src/array.rs
index 86c2b7d8..aadc6f20 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -89,7 +89,7 @@ impl PyArray {
/// a wrapper of PyArray_SimpleNew
/// https://docs.scipy.org/doc/numpy/reference/c-api.array.html#c.PyArray_SimpleNew
- pub fn new(py: Python, np: MultiArray, d... | 4 | 21 | 16 |
ae5d535b6d317bdb42f4d6b056784bad2244485b | Toshiki Teramura | 2017-05-10T14:19:35 | Fix numpy::array to use MultiArray Python module | diff --git a/src/array.rs b/src/array.rs
index bce13e15..86c2b7d8 100644
--- a/src/array.rs
+++ b/src/array.rs
@@ -2,8 +2,8 @@
use npyffi;
use pyffi;
use cpython::*;
-use npyffi::types::npy_intp;
-use super::{NPY_TYPES, NPY_ORDER};
+use npyffi::MultiArray;
+use super::*;
pub struct PyArray(PyObject);
@@ -89,41 ... | 5 | 44 | 30 |
dfc297f2198979f4c08a42a3966b01d76b1c61bc | Toshiki Teramura | 2017-05-10T14:03:22 | Sort npyffi | diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs
index e06b4e74..5b37ae92 100644
--- a/src/npyffi/array.rs
+++ b/src/npyffi/array.rs
@@ -9,42 +9,17 @@ use super::types::*;
use super::iterator::*;
#[repr(C)]
-#[derive(Clone, Copy)]
-pub struct PyArrayFlagsObject {
- pub ob_base: PyObject,
- pub arr: *mut... | 2 | 198 | 481 |
43f63bb2da4ffa7d25043394f28a785cce690a0f | Toshiki Teramura | 2017-05-10T14:03:08 | Remove PyArrayDescr | diff --git a/src/descr.rs b/src/descr.rs
deleted file mode 100644
index c4bdb1d9..00000000
--- a/src/descr.rs
+++ /dev/null
@@ -1,65 +0,0 @@
-
-use npffi;
-use pyffi;
-
-use cpython::*;
-use super::NPY_TYPES;
-
-pub struct PyArrayDescr(PyObject);
-
-impl PyArrayDescr {
- pub fn as_ptr(&self) -> *mut npffi::PyArray_D... | 1 | 0 | 65 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.