Skip to content

Commit d58add3

Browse files
committed
Drop deprecations introduced in version 0.17.0.
1 parent 0a99920 commit d58add3

File tree

4 files changed

+2
-83
lines changed

4 files changed

+2
-83
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
- Unreleased
4+
- Drop deprecated `PyArray::from_exact_iter` as it does not provide any benefits over `PyArray::from_iter`. ([#370](https://github.com/PyO3/rust-numpy/pull/370))
45

56
- v0.18.0
67
- Add conversions from and to datatypes provided by the [`nalgebra` crate](https://nalgebra.org/). ([#347](https://github.com/PyO3/rust-numpy/pull/347))

benches/array.rs

+1-44
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ fn downcast_failure(bencher: &mut Bencher) {
5151
});
5252
});
5353
}
54+
5455
struct Iter(Range<usize>);
5556

5657
impl Iterator for Iter {
@@ -84,50 +85,6 @@ fn from_iter_large(bencher: &mut Bencher) {
8485
from_iter(bencher, 2_usize.pow(15));
8586
}
8687

87-
struct ExactIter(Range<usize>);
88-
89-
impl Iterator for ExactIter {
90-
type Item = usize;
91-
92-
fn next(&mut self) -> Option<Self::Item> {
93-
self.0.next()
94-
}
95-
96-
fn size_hint(&self) -> (usize, Option<usize>) {
97-
self.0.size_hint()
98-
}
99-
}
100-
101-
impl ExactSizeIterator for ExactIter {
102-
fn len(&self) -> usize {
103-
self.0.len()
104-
}
105-
}
106-
107-
fn from_exact_iter(bencher: &mut Bencher, size: usize) {
108-
iter_with_gil(bencher, |py| {
109-
let iter = black_box(ExactIter(0..size));
110-
111-
#[allow(deprecated)]
112-
PyArray1::from_exact_iter(py, iter);
113-
});
114-
}
115-
116-
#[bench]
117-
fn from_exact_iter_small(bencher: &mut Bencher) {
118-
from_exact_iter(bencher, 2_usize.pow(5));
119-
}
120-
121-
#[bench]
122-
fn from_exact_iter_medium(bencher: &mut Bencher) {
123-
from_exact_iter(bencher, 2_usize.pow(10));
124-
}
125-
126-
#[bench]
127-
fn from_exact_iter_large(bencher: &mut Bencher) {
128-
from_exact_iter(bencher, 2_usize.pow(15));
129-
}
130-
13188
fn from_slice(bencher: &mut Bencher, size: usize) {
13289
let vec = (0..size).collect::<Vec<_>>();
13390

src/array.rs

-26
Original file line numberDiff line numberDiff line change
@@ -1248,32 +1248,6 @@ impl<T: Element> PyArray<T, Ix1> {
12481248
vec.into_pyarray(py)
12491249
}
12501250

1251-
/// Construct a one-dimensional array from an [`ExactSizeIterator`].
1252-
///
1253-
/// # Example
1254-
///
1255-
/// ```
1256-
/// use numpy::PyArray;
1257-
/// use pyo3::Python;
1258-
///
1259-
/// Python::with_gil(|py| {
1260-
/// let pyarray = PyArray::from_exact_iter(py, [1, 2, 3, 4, 5].into_iter().copied());
1261-
/// assert_eq!(pyarray.readonly().as_slice().unwrap(), &[1, 2, 3, 4, 5]);
1262-
/// });
1263-
/// ```
1264-
#[deprecated(
1265-
since = "0.17.0",
1266-
note = "`from_exact_iter` is deprecated as it does not provide any benefit over `from_iter`."
1267-
)]
1268-
#[inline(always)]
1269-
pub fn from_exact_iter<I>(py: Python<'_>, iter: I) -> &Self
1270-
where
1271-
I: IntoIterator<Item = T>,
1272-
I::IntoIter: ExactSizeIterator,
1273-
{
1274-
Self::from_iter(py, iter)
1275-
}
1276-
12771251
/// Construct a one-dimensional array from an [`Iterator`].
12781252
///
12791253
/// If no reliable [`size_hint`][Iterator::size_hint] is available,

tests/to_py.rs

-13
Original file line numberDiff line numberDiff line change
@@ -72,19 +72,6 @@ fn long_iter_to_pyarray() {
7272
});
7373
}
7474

75-
#[test]
76-
fn exact_iter_to_pyarray() {
77-
Python::with_gil(|py| {
78-
#[allow(deprecated)]
79-
let arr = PyArray::from_exact_iter(py, 0_u32..512);
80-
81-
assert_eq!(
82-
arr.readonly().as_slice().unwrap(),
83-
(0_u32..512).collect::<Vec<_>>(),
84-
);
85-
});
86-
}
87-
8875
#[test]
8976
fn from_small_array() {
9077
macro_rules! small_array_test {

0 commit comments

Comments
 (0)