Skip to content

Commit 9fa4571

Browse files
committed
Remove Element for PyObject
1 parent 29cedec commit 9fa4571

File tree

3 files changed

+2
-25
lines changed

3 files changed

+2
-25
lines changed

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
- `PyArray::as_slice`, `PyArray::as_slice_mut`, `PyArray::as_array`, and `PyArray::as_array_mut` is now unsafe.
55
- Introduce `PyArray::as_cell_slice`, `PyArray::to_vec`, and `PyArray::to_owned_array`
66
- Rename `TypeNum` trait `Element`, and `NpyDataType` `DataType`
7-
- Enables `PyArray<PyObject>`
87

98
- v0.9.0
109
- Update PyO3 to 0.10.0

src/types.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ impl DataType {
6767
None
6868
}
6969
}
70+
#[inline]
7071
pub fn into_ffi_dtype(self) -> NPY_TYPES {
7172
match self {
7273
DataType::Bool => NPY_TYPES::NPY_BOOL,
@@ -91,6 +92,7 @@ impl DataType {
9192
pub trait Element: Clone {
9293
const DATA_TYPE: DataType;
9394
fn is_same_type(other: i32) -> bool;
95+
#[inline]
9496
fn ffi_dtype() -> NPY_TYPES {
9597
Self::DATA_TYPE.into_ffi_dtype()
9698
}
@@ -141,10 +143,3 @@ cfg_if! {
141143
impl_num_element!(u64, Uint64, NPY_ULONG, NPY_ULONGLONG);
142144
}
143145
}
144-
145-
impl Element for pyo3::PyObject {
146-
const DATA_TYPE: DataType = DataType::Object;
147-
fn is_same_type(other: i32) -> bool {
148-
other == Self::DATA_TYPE as i32
149-
}
150-
}

tests/to_py.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,6 @@ fn to_pyarray_vec() {
1212
assert_eq!(arr.as_slice().unwrap(), &[1, 2, 3])
1313
}
1414

15-
#[test]
16-
fn to_pyarray_object_vec() {
17-
use pyo3::{AsPyRef, ToPyObject};
18-
let gil = pyo3::Python::acquire_gil();
19-
let py = gil.python();
20-
let dict = pyo3::types::PyDict::new(py);
21-
let list = pyo3::types::PyString::new(py, "Hello:)");
22-
let a = vec![dict.to_object(py), list.to_object(py)];
23-
let arr = a.to_pyarray(gil.python()).readonly();
24-
for (a, b) in a.iter().zip(arr.as_slice().unwrap().iter()) {
25-
assert_eq!(
26-
a.as_ref(py).compare(b).map_err(|e| e.print(py)).unwrap(),
27-
std::cmp::Ordering::Equal
28-
);
29-
}
30-
}
31-
3215
#[test]
3316
fn to_pyarray_array() {
3417
let gil = pyo3::Python::acquire_gil();

0 commit comments

Comments
 (0)