Construct a one-dimensional array from an [`Iterator`]. If no reliable [`size_hint`][Iterator::size_hint] is available, this method can allocate memory multiple times, which can hurt performance. # Example ``` use numpy::{PyArray, PyArrayMethods}; use pyo3::Python; Python::attach(|py| { let pyarray = PyArray::from_iter(py, "abcde".chars().map(u32::from)); assert_eq!(pyarray.readonly().as_slice
(py: Python<'_>, iter: I)
| 562 | /// }); |
| 563 | /// ``` |
| 564 | pub fn from_iter<I>(py: Python<'_>, iter: I) -> Bound<'_, Self> |
| 565 | where |
| 566 | I: IntoIterator<Item = T>, |
| 567 | { |
| 568 | let data = iter.into_iter().collect::<Vec<_>>(); |
| 569 | data.into_pyarray(py) |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | impl<T: Element> PyArray<T, Ix2> { |
nothing calls this directly
no test coverage detected