MCPcopy Create free account
hub / github.com/PyO3/rust-numpy / arange

Method arange

src/array.rs:696–707  ·  view source on GitHub ↗

Return evenly spaced values within a given interval. See [numpy.arange][numpy.arange] for the Python API and [PyArray_Arange][PyArray_Arange] for the C API. # Example ``` use numpy::{PyArray, PyArrayMethods}; use pyo3::Python; Python::attach(|py| { let pyarray = PyArray::arange(py, 2.0, 4.0, 0.5); assert_eq!(pyarray.readonly().as_slice().unwrap(), &[2.0, 2.5, 3.0, 3.5]); let pyarray = PyArray

(py: Python<'py>, start: T, stop: T, step: T)

Source from the content-addressed store, hash-verified

694 /// [numpy.arange]: https://numpy.org/doc/stable/reference/generated/numpy.arange.html
695 /// [PyArray_Arange]: https://numpy.org/doc/stable/reference/c-api/array.html#c.PyArray_Arange
696 pub fn arange<'py>(py: Python<'py>, start: T, stop: T, step: T) -> Bound<'py, Self> {
697 unsafe {
698 let ptr = PY_ARRAY_API.PyArray_Arange(
699 py,
700 start.as_(),
701 stop.as_(),
702 step.as_(),
703 T::get_dtype(py).num(),
704 );
705 Bound::from_owned_ptr(py, ptr).cast_into_unchecked()
706 }
707 }
708}
709
710unsafe fn clone_elements<T: Element>(py: Python<'_>, elems: &[T], data_ptr: &mut *mut T) {

Callers 1

test_extractFunction · 0.80

Calls 1

numMethod · 0.80

Tested by 1

test_extractFunction · 0.64