diff --git a/help.html b/help.html index 669fe51c..73966932 100644 --- a/help.html +++ b/help.html @@ -1 +1 @@ -
pub fn get_array_module<'py>(py: Python<'py>) -> PyResult<Bound<'py, PyModule>>
Returns a handle to NumPy’s multiarray module.
+pub fn get_array_module<'py>(py: Python<'py>) -> PyResult<Bound<'py, PyModule>>
Returns a handle to NumPy’s multiarray module.
Safe interface for NumPy’s N-dimensional arrays
+Safe interface for NumPy’s N-dimensional arrays
ndarray
class.PyArray0<T>
.PyArray<T, D>
.pub struct PyArray<T, D>(/* private fields */);
A safe, statically-typed wrapper for NumPy’s ndarray
class.
pub struct PyArray<T, D>(/* private fields */);
A safe, statically-typed wrapper for NumPy’s ndarray
class.
IntoPyArray
or
@@ -21,7 +21,7 @@ PyArray
has two type parametes T
and D
.
-T
represents the type of its elements, e.g. f32
or [PyObject
].
+T
represents the type of its elements, e.g. f32
or [PyObject
].
D
represents its dimensionality, e.g Ix2
or IxDyn
.
Element types are Rust types which implement the Element
trait.
Dimensions are represented by the ndarray::Dimension
trait.
Creates a new uninitialized NumPy array.
If is_fortran
is true, then it has Fortran/column-major order,
@@ -82,15 +82,15 @@
PyArray::new
PyArray::borrow_from_array
Construct a new NumPy array filled with zeros.
If is_fortran
is true, then it has Fortran/column-major order,
otherwise it has C/row-major order.
PyArray::zeros
Deprecated name for PyArray::zeros
.
Constructs a NumPy from an ndarray::Array
This method uses the internal Vec
of the ndarray::Array
as the base object of the NumPy array.
Constructs a NumPy from an ndarray::Array
This method uses the internal Vec
of the ndarray::Array
as the base object of the NumPy array.
use numpy::{PyArray, PyArrayMethods};
use ndarray::array;
@@ -158,11 +158,11 @@ §Example
assert_eq!(pyarray.readonly().as_array(), array![[1, 2], [3, 4]]);
});
PyArray::from_owned_array
Deprecated name for PyArray::from_owned_array
.
PyArray::from_array
Deprecated name for PyArray::from_array
.
Construct a NumPy array containing objects stored in a ndarray::Array
This method uses the internal Vec
of the ndarray::Array
as the base object of the NumPy array.
This method uses the internal Vec
of the ndarray::Array
as the base object of the NumPy array.
use ndarray::array;
use pyo3::{pyclass, Py, Python, types::PyAnyMethods};
@@ -216,11 +216,11 @@ §Example
assert!(pyarray.readonly().as_array().get(0).unwrap().bind(py).is_instance_of::<CustomElement>());
});
PyArray::from_owned_object_array
Deprecated name for PyArray::from_owned_object_array
.
Construct a one-dimensional array from a slice.
+PyArray::from_slice
Deprecated name for PyArray::from_slice
.
Construct a one-dimensional array from a Vec<T>
.
PyArray::from_slice
Deprecated name for PyArray::from_slice
.
PyArray::from_vec
Deprecated name for PyArray::from_vec
.
PyArray::from_vec
Deprecated name for PyArray::from_vec
.
Construct a one-dimensional array from an Iterator
.
If no reliable size_hint
is available,
this method can allocate memory multiple times, which can hurt performance.
use numpy::{PyArray, PyArrayMethods};
@@ -254,12 +254,12 @@ §Example
let pyarray = PyArray::from_iter(py, "abcde".chars().map(u32::from));
assert_eq!(pyarray.readonly().as_slice().unwrap(), &[97, 98, 99, 100, 101]);
});
PyArray::from_iter
Deprecated name for PyArray::from_iter
.
PyArray::from_iter
Deprecated name for PyArray::from_iter
.
Construct a two-dimension array from a Vec<Vec<T>>
.
Construct a two-dimension array from a Vec<Vec<T>>
.
This function checks all dimensions of the inner vectors and returns an error if they are not all equal.
PyArray::from_vec2
Deprecated name for PyArray::from_vec2
.
PyArray::from_vec2
Deprecated name for PyArray::from_vec2
.
Construct a three-dimensional array from a Vec<Vec<Vec<T>>>
.
Construct a three-dimensional array from a Vec<Vec<Vec<T>>>
.
This function checks all dimensions of the inner vectors and returns an error if they are not all equal.
PyArray::from_vec3
Deprecated name for PyArray::from_vec3
.
PyArray::from_vec3
Deprecated name for PyArray::from_vec3
.
PyArray::arange
Deprecated name for PyArray::arange
.
object
is an instance of this type or a subclass of this type.PyTypeInfo::type_object
PyTypeInfo::type_object
].PyTypeInfo::is_type_of
PyTypeInfo::is_type_of
].object
is an instance of this type.PyTypeInfo::is_exact_type_of
PyTypeInfo::is_exact_type_of
].object
is an instance of this type or a subclass of this type.PyTypeInfo::type_object
PyTypeInfo::type_object
].PyTypeInfo::is_type_of
PyTypeInfo::is_type_of
].object
is an instance of this type.PyTypeInfo::is_exact_type_of
PyTypeInfo::is_exact_type_of
].self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub trait PyArray0Methods<'py, T>: PyArrayMethods<'py, T, Ix0> {
+PyArray0Methods in numpy::array - Rust pub trait PyArray0Methods<'py, T>: PyArrayMethods<'py, T, Ix0> {
// Provided method
fn item(&self) -> T
- where T: Element + Copy { ... }
+ where T: Element + Copy { ... }
}
Expand description
Implementation of functionality for PyArray0<T>
.
-Provided Methods§
\ No newline at end of file
+
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
pub trait PyArrayMethods<'py, T, D>: PyUntypedArrayMethods<'py> {
+PyArrayMethods in numpy::array - Rust pub trait PyArrayMethods<'py, T, D>: PyUntypedArrayMethods<'py> {
Show 31 methods
// Required methods
fn as_untyped(&self) -> &Bound<'py, PyUntypedArray>;
- fn data(&self) -> *mut T;
- unsafe fn get(&self, index: impl NpyIndex<Dim = D>) -> Option<&T>
+ fn data(&self) -> *mut T;
+ unsafe fn get(&self, index: impl NpyIndex<Dim = D>) -> Option<&T>
where T: Element,
D: Dimension;
- unsafe fn get_mut(&self, index: impl NpyIndex<Dim = D>) -> Option<&mut T>
+ unsafe fn get_mut(&self, index: impl NpyIndex<Dim = D>) -> Option<&mut T>
where T: Element,
D: Dimension;
- fn get_owned<Idx>(&self, index: Idx) -> Option<T>
+ fn get_owned<Idx>(&self, index: Idx) -> Option<T>
where T: Element,
D: Dimension,
Idx: NpyIndex<Dim = D>;
fn to_dyn(&self) -> &Bound<'py, PyArray<T, IxDyn>>
where T: Element,
D: Dimension;
- fn to_vec(&self) -> Result<Vec<T>, NotContiguousError>
+ fn to_vec(&self) -> Result<Vec<T>, NotContiguousError>
where T: Element,
D: Dimension;
- fn try_readonly(&self) -> Result<PyReadonlyArray<'py, T, D>, BorrowError>
+ fn try_readonly(&self) -> Result<PyReadonlyArray<'py, T, D>, BorrowError>
where T: Element,
D: Dimension;
- fn try_readwrite(&self) -> Result<PyReadwriteArray<'py, T, D>, BorrowError>
+ fn try_readwrite(&self) -> Result<PyReadwriteArray<'py, T, D>, BorrowError>
where T: Element,
D: Dimension;
unsafe fn as_array(&self) -> ArrayView<'_, T, D>
@@ -42,16 +42,16 @@
fn copy_to<U: Element>(
&self,
other: &Bound<'py, PyArray<U, D>>,
- ) -> PyResult<()>
+ ) -> PyResult<()>
where T: Element;
fn cast<U: Element>(
&self,
- is_fortran: bool,
+ is_fortran: bool,
) -> PyResult<Bound<'py, PyArray<U, D>>>
where T: Element;
fn permute<ID: IntoDimension>(
&self,
- axes: Option<ID>,
+ axes: Option<ID>,
) -> PyResult<Bound<'py, PyArray<T, D>>>
where T: Element;
fn reshape_with_order<ID: IntoDimension>(
@@ -60,11 +60,11 @@
order: NPY_ORDER,
) -> PyResult<Bound<'py, PyArray<T, ID::Dim>>>
where T: Element;
- unsafe fn resize<ID: IntoDimension>(&self, newshape: ID) -> PyResult<()>
+ unsafe fn resize<ID: IntoDimension>(&self, newshape: ID) -> PyResult<()>
where T: Element;
unsafe fn try_as_matrix<R, C, RStride, CStride>(
&self,
- ) -> Option<MatrixView<'_, T, R, C, RStride, CStride>>
+ ) -> Option<MatrixView<'_, T, R, C, RStride, CStride>>
where T: Scalar + Element,
D: Dimension,
R: Dim,
@@ -73,7 +73,7 @@
CStride: Dim;
unsafe fn try_as_matrix_mut<R, C, RStride, CStride>(
&self,
- ) -> Option<MatrixViewMut<'_, T, R, C, RStride, CStride>>
+ ) -> Option<MatrixViewMut<'_, T, R, C, RStride, CStride>>
where T: Scalar + Element,
D: Dimension,
R: Dim,
@@ -84,21 +84,21 @@
// Provided methods
fn dims(&self) -> D
where D: Dimension { ... }
- unsafe fn as_slice(&self) -> Result<&[T], NotContiguousError>
+ unsafe fn as_slice(&self) -> Result<&[T], NotContiguousError>
where T: Element,
D: Dimension { ... }
- unsafe fn as_slice_mut(&self) -> Result<&mut [T], NotContiguousError>
+ unsafe fn as_slice_mut(&self) -> Result<&mut [T], NotContiguousError>
where T: Element,
D: Dimension { ... }
- unsafe fn uget<Idx>(&self, index: Idx) -> &T
+ unsafe fn uget<Idx>(&self, index: Idx) -> &T
where T: Element,
D: Dimension,
Idx: NpyIndex<Dim = D> { ... }
- unsafe fn uget_mut<Idx>(&self, index: Idx) -> &mut T
+ unsafe fn uget_mut<Idx>(&self, index: Idx) -> &mut T
where T: Element,
D: Dimension,
Idx: NpyIndex<Dim = D> { ... }
- unsafe fn uget_raw<Idx>(&self, index: Idx) -> *mut T
+ unsafe fn uget_raw<Idx>(&self, index: Idx) -> *mut T
where T: Element,
D: Dimension,
Idx: NpyIndex<Dim = D> { ... }
@@ -116,9 +116,9 @@
) -> PyResult<Bound<'py, PyArray<T, ID::Dim>>>
where T: Element { ... }
}
Expand description
Implementation of functionality for PyArray<T, D>
.
-Required Methods§
sourcefn as_untyped(&self) -> &Bound<'py, PyUntypedArray>
Access an untyped representation of this array.
-Required Methods§
Sourcefn as_untyped(&self) -> &Bound<'py, PyUntypedArray>
Access an untyped representation of this array.
+Sourcefn to_dyn(&self) -> &Bound<'py, PyArray<T, IxDyn>>
Turn an array with fixed dimensionality into one with dynamic dimensionality.
-sourcefn to_vec(&self) -> Result<Vec<T>, NotContiguousError>where
+
Returns a copy of the internal data of the array as a Vec
.
Fails if the internal array is not contiguous. See also as_slice
.
use numpy::{PyArray2, PyArrayMethods};
@@ -188,31 +188,31 @@ §Example
assert_eq!(pyarray.to_vec()?, vec![0, 1, 2, 3]);
})
Get an immutable borrow of the NumPy array
-Get a mutable borrow of the NumPy array
-Returns an ArrayView
of the internal array.
See also PyReadonlyArray::as_array
.
Calling this method invalidates all exclusive references to the internal data, e.g. &mut [T]
or ArrayViewMut
.
Returns an ArrayViewMut
of the internal array.
See also PyReadwriteArray::as_array_mut
.
Calling this method invalidates all other references to the internal data, e.g. ArrayView
or ArrayViewMut
.
Returns the internal array as RawArrayView
enabling element access via raw pointers
Returns the internal array as RawArrayViewMut
enabling element access via raw pointers
Get a copy of the array as an ndarray::Array
.
Copies self
into other
, performing a data type conversion if necessary.
See also PyArray_CopyInto
.
Cast the PyArray<T>
to PyArray<U>
, by allocating a new array.
See also PyArray_CastToType
.
A view of self
with a different order of axes determined by axes
.
If axes
is None
, the order of axes is reversed which corresponds to the standard matrix transpose.
Extends or truncates the dimensions of an array.
This method works only on contiguous arrays.
Missing elements will be initialized as if calling zeros
.
Try to convert this array into a nalgebra::MatrixView
using the given shape and strides.
Calling this method invalidates all exclusive references to the internal data, e.g. ArrayViewMut
or MatrixSliceMut
.
Try to convert this array into a nalgebra::MatrixViewMut
using the given shape and strides.
Calling this method invalidates all other references to the internal data, e.g. ArrayView
, MatrixSlice
, ArrayViewMut
or MatrixSliceMut
.
Same as [shape
][PyUntypedArray::shape], but returns D
instead of &[usize]
.
Returns an immutable view of the internal data as a slice.
PyArray
or concurrently modified by Python or other native code.
Please consider the safe alternative PyReadonlyArray::as_slice
.
Returns a mutable view of the internal data as a slice.
PyArray
or concurrently modified by Python or other native code.
Please consider the safe alternative PyReadwriteArray::as_slice_mut
.
Same as uget
, but returns &mut T
.
See PyReadwriteArray::get_mut
for a safe alternative.
Get an immutable borrow of the NumPy array
Panics if the allocation backing the array is currently mutably borrowed.
For a non-panicking variant, use try_readonly
.
Get a mutable borrow of the NumPy array
Panics if the allocation backing the array is currently borrowed or if the array is flagged as not writeable.
For a non-panicking variant, use try_readwrite
.
Special case of permute
which reverses the order the axes.
Special case of reshape_with_order
which keeps the memory order the same.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
pub type PyArray0<T> = PyArray<T, Ix0>;
Zero-dimensional array.
+pub type PyArray1<T> = PyArray<T, Ix1>;
One-dimensional array.
+pub type PyArray2<T> = PyArray<T, Ix2>;
Two-dimensional array.
+pub type PyArray3<T> = PyArray<T, Ix3>;
Three-dimensional array.
+pub type PyArray4<T> = PyArray<T, Ix4>;
Four-dimensional array.
+pub type PyArray5<T> = PyArray<T, Ix5>;
Five-dimensional array.
+pub type PyArray6<T> = PyArray<T, Ix6>;
Six-dimensional array.
+pub type PyArrayDyn<T> = PyArray<T, IxDyn>;
Dynamic-dimensional array.
+Types to safely create references into NumPy arrays
+Types to safely create references into NumPy arrays
It is assumed that unchecked code - which includes unsafe Rust and Python - is validated by its author which together with the dynamic borrow checking performed by this crate ensures that safe Rust code cannot cause undefined behaviour by creating references into NumPy arrays.
diff --git a/numpy/borrow/struct.PyReadonlyArray.html b/numpy/borrow/struct.PyReadonlyArray.html index 2b9be88e..41bd0239 100644 --- a/numpy/borrow/struct.PyReadonlyArray.html +++ b/numpy/borrow/struct.PyReadonlyArray.html @@ -1,20 +1,20 @@ -pub struct PyReadonlyArray<'py, T, D>where
+PyReadonlyArray in numpy::borrow - Rust pub struct PyReadonlyArray<'py, T, D>{ /* private fields */ }
Expand description
Read-only borrow of an array.
An instance of this type ensures that there are no instances of PyReadwriteArray
,
i.e. that only shared references into the interior of the array can be created safely.
See the module-level documentation for more.
-Implementations§
source§impl<'py, T, D> PyReadonlyArray<'py, T, D>where
+
Implementations§
Source§impl<'py, T, D> PyReadonlyArray<'py, T, D>
sourcepub fn as_array(&self) -> ArrayView<'_, T, D>
Provides an immutable array view of the interior of the NumPy array.
-sourcepub fn as_slice(&self) -> Result<&[T], NotContiguousError>
Provide an immutable slice view of the interior of the NumPy array if it is contiguous.
-sourcepub fn get<I>(&self, index: I) -> Option<&T>where
+ D: Dimension,
source§impl<'py, N, D> PyReadonlyArray<'py, N, D>where
+
Source§impl<'py, N, D> PyReadonlyArray<'py, N, D>
sourcepub fn try_as_matrix<R, C, RStride, CStride>(
+ D: Dimension,
Sourcepub fn try_as_matrix<R, C, RStride, CStride>(
&self,
-) -> Option<MatrixView<'_, N, R, C, RStride, CStride>>where
+) -> Option<MatrixView<'_, N, R, C, RStride, CStride>>
-
source§impl<'py, N> PyReadonlyArray<'py, N, Ix1>
sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this one-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
+Source§impl<'py, N> PyReadonlyArray<'py, N, Ix1>
Sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this one-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
§Panics
Panics if the array has negative strides.
-source§impl<'py, N> PyReadonlyArray<'py, N, Ix2>
sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this two-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
+Source§impl<'py, N> PyReadonlyArray<'py, N, Ix2>
Sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this two-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
§Panics
Panics if the array has negative strides.
-Methods from Deref<Target = Bound<'py, PyArray<T, D>>>§
pub fn borrow(&self) -> PyRef<'py, T>
Immutably borrows the value T
.
This borrow lasts while the returned [PyRef
] exists.
Multiple immutable borrows can be taken out at the same time.
For frozen classes, the simpler [get
][Self::get] is available.
@@ -98,17 +98,17 @@ §Examples
§Panics
Panics if the value is currently borrowed. For a non-panicking variant, use
try_borrow_mut
.
-pub fn try_borrow(&self) -> Result<PyRef<'py, T>, PyBorrowError>
Attempts to immutably borrow the value T
, returning an error if the value is currently mutably borrowed.
+pub fn try_borrow(&self) -> Result<PyRef<'py, T>, PyBorrowError>
Attempts to immutably borrow the value T
, returning an error if the value is currently mutably borrowed.
The borrow lasts while the returned [PyRef
] exists.
This is the non-panicking variant of borrow
.
For frozen classes, the simpler [get
][Self::get] is available.
-pub fn try_borrow_mut(&self) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
+
pub fn try_borrow_mut(&self) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
T: PyClass<Frozen = False>,
Attempts to mutably borrow the value T
, returning an error if the value is currently borrowed.
The borrow lasts while the returned [PyRefMut
] exists.
This is the non-panicking variant of borrow_mut
.
-pub fn get(&self) -> &Twhere
- T: PyClass<Frozen = True> + Sync,
Provide an immutable borrow of the value T
without acquiring the GIL.
-This is available if the class is [frozen
][macro@crate::pyclass] and Sync
.
+pub fn get(&self) -> &Twhere
+ T: PyClass<Frozen = True> + Sync,
Provide an immutable borrow of the value T
without acquiring the GIL.
+This is available if the class is [frozen
][macro@crate::pyclass] and Sync
.
§Examples
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -158,7 +158,7 @@ assert!(obj.as_super().pyrepr().is_ok());
})
pub fn py(&self) -> Python<'py>
Returns the GIL token associated with this object.
-pub fn as_borrowed<'a>(&'a self) -> Borrowed<'a, 'py, T>
Casts this Bound<T>
to a Borrowed<T>
smart pointer.
pub fn as_unbound(&self) -> &Py<T>
Removes the connection for this Bound<T>
from the GIL, allowing
it to cross thread boundaries, without transferring ownership.
-Trait Implementations§
source§impl<'py, T, D> Clone for PyReadonlyArray<'py, T, D>where
+
Trait Implementations§
Source§impl<'py, T, D> Clone for PyReadonlyArray<'py, T, D>
source§impl<'py, T, D> Debug for PyReadonlyArray<'py, T, D>where
+ D: Dimension,
Source§impl<'py, T, D> Debug for PyReadonlyArray<'py, T, D>
source§impl<'py, T, D> Deref for PyReadonlyArray<'py, T, D>where
+ D: Dimension,
Source§impl<'py, T, D> Deref for PyReadonlyArray<'py, T, D>
source§impl<'py, T, D> Drop for PyReadonlyArray<'py, T, D>where
+ D: Dimension,
Source§impl<'py, T, D> Drop for PyReadonlyArray<'py, T, D>
source§impl<'py, T, D> From<PyReadwriteArray<'py, T, D>> for PyReadonlyArray<'py, T, D>where
+ D: Dimension,
Source§impl<'py, T, D> From<PyReadwriteArray<'py, T, D>> for PyReadonlyArray<'py, T, D>
source§fn from(value: PyReadwriteArray<'py, T, D>) -> Self
Converts to this type from the input type.source§impl<'py, T: Element, D: Dimension> FromPyObject<'py> for PyReadonlyArray<'py, T, D>
source§fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult<Self>
Auto Trait Implementations§
§impl<'py, T, D> Freeze for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> !RefUnwindSafe for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> !Send for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> !Sync for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> Unpin for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> UnwindSafe for PyReadonlyArray<'py, T, D>where
- T: UnwindSafe,
- D: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
- T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T> CloneToUninit for Twhere
- T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (clone_to_uninit
)source§impl<T> From<T> for T
source§fn from(t: T) -> T
Returns the argument unchanged.
+ D: Dimension,Source§fn from(value: PyReadwriteArray<'py, T, D>) -> Self
Converts to this type from the input type.Source§impl<'py, T: Element, D: Dimension> FromPyObject<'py> for PyReadonlyArray<'py, T, D>
Source§fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult<Self>
Auto Trait Implementations§
§impl<'py, T, D> Freeze for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> !RefUnwindSafe for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> !Send for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> !Sync for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> Unpin for PyReadonlyArray<'py, T, D>
§impl<'py, T, D> UnwindSafe for PyReadonlyArray<'py, T, D>where
+ T: UnwindSafe,
+ D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
+ T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moreSource§impl<T> CloneToUninit for Twhere
+ T: Clone,
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
- T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
source§impl<T, U> Into<U> for Twhere
- U: From<T>,
source§fn into(self) -> U
Calls U::from(self)
.
+ T: FromPyObject<'py>,§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<SS, SP> SupersetOf<SS> for SPwhere
- SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
-superset. Read more§fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
\ No newline at end of file
+From<T> for U
chooses to do.
+§impl<SS, SP> SupersetOf<SS> for SPwhere
+ SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
+superset. Read more§fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
pub struct PyReadwriteArray<'py, T, D>where
+PyReadwriteArray in numpy::borrow - Rust pub struct PyReadwriteArray<'py, T, D>{ /* private fields */ }
Expand description
Read-write borrow of an array.
An instance of this type ensures that there are no instances of PyReadonlyArray
and no other instances of PyReadwriteArray
,
i.e. that only a single exclusive reference into the interior of the array can be created safely.
See the module-level documentation for more.
-Implementations§
source§impl<'py, T, D> PyReadwriteArray<'py, T, D>where
+
Implementations§
Source§impl<'py, T, D> PyReadwriteArray<'py, T, D>
sourcepub fn as_array_mut(&mut self) -> ArrayViewMut<'_, T, D>
Provides a mutable array view of the interior of the NumPy array.
-sourcepub fn as_slice_mut(&mut self) -> Result<&mut [T], NotContiguousError>
Provide a mutable slice view of the interior of the NumPy array if it is contiguous.
-sourcepub fn get_mut<I>(&mut self, index: I) -> Option<&mut T>where
+ D: Dimension,
Sourcepub fn as_array_mut(&mut self) -> ArrayViewMut<'_, T, D>
Provides a mutable array view of the interior of the NumPy array.
+Sourcepub fn as_slice_mut(&mut self) -> Result<&mut [T], NotContiguousError>
Provide a mutable slice view of the interior of the NumPy array if it is contiguous.
+Sourcepub fn get_mut<I>(&mut self, index: I) -> Option<&mut T>where
I: NpyIndex<Dim = D>,
Provide a mutable reference to an element of the NumPy array if the index is within bounds.
-sourcepub fn make_nonwriteable(self) -> PyReadonlyArray<'py, T, D>
Clear the WRITEABLE
flag from the underlying NumPy array.
+Sourcepub fn make_nonwriteable(self) -> PyReadonlyArray<'py, T, D>
Clear the WRITEABLE
flag from the underlying NumPy array.
Calling this will prevent any further PyReadwriteArrays from being taken out. Python
space can reset this flag, unless the additional flag OWNDATA
is unset. Such
an array can be created from Rust space by using PyArray::borrow_from_array_bound.
-source§impl<'py, N, D> PyReadwriteArray<'py, N, D>where
+
Source§impl<'py, N, D> PyReadwriteArray<'py, N, D>
sourcepub fn try_as_matrix_mut<R, C, RStride, CStride>(
+ D: Dimension,
Sourcepub fn try_as_matrix_mut<R, C, RStride, CStride>(
&self,
-) -> Option<MatrixViewMut<'_, N, R, C, RStride, CStride>>where
+) -> Option<MatrixViewMut<'_, N, R, C, RStride, CStride>>Try to convert this array into a nalgebra::MatrixViewMut
using the given shape and strides.
See PyReadonlyArray::try_as_matrix
for a discussion of the memory layout requirements.
-
source§impl<'py, N> PyReadwriteArray<'py, N, Ix1>
sourcepub fn as_matrix_mut(&self) -> DMatrixViewMut<'_, N, Dyn, Dyn>
Convert this one-dimensional array into a nalgebra::DMatrixViewMut
using dynamic strides.
+Source§impl<'py, N> PyReadwriteArray<'py, N, Ix1>
Sourcepub fn as_matrix_mut(&self) -> DMatrixViewMut<'_, N, Dyn, Dyn>
Convert this one-dimensional array into a nalgebra::DMatrixViewMut
using dynamic strides.
§Panics
Panics if the array has negative strides.
-source§impl<'py, N> PyReadwriteArray<'py, N, Ix2>
sourcepub fn as_matrix_mut(&self) -> DMatrixViewMut<'_, N, Dyn, Dyn>
Convert this two-dimensional array into a nalgebra::DMatrixViewMut
using dynamic strides.
+Source§impl<'py, N> PyReadwriteArray<'py, N, Ix2>
Sourcepub fn as_matrix_mut(&self) -> DMatrixViewMut<'_, N, Dyn, Dyn>
Convert this two-dimensional array into a nalgebra::DMatrixViewMut
using dynamic strides.
§Panics
Panics if the array has negative strides.
-source§impl<'py, T> PyReadwriteArray<'py, T, Ix1>where
- T: Element,
sourcepub fn resize<ID: IntoDimension>(self, dims: ID) -> PyResult<Self>
Extends or truncates the dimensions of an array.
+Source§impl<'py, T> PyReadwriteArray<'py, T, Ix1>where
+ T: Element,
Sourcepub fn resize<ID: IntoDimension>(self, dims: ID) -> PyResult<Self>
Methods from Deref<Target = PyReadonlyArray<'py, T, D>>§
Methods from Deref<Target = PyReadonlyArray<'py, T, D>>§
Sourcepub fn as_array(&self) -> ArrayView<'_, T, D>
Provides an immutable array view of the interior of the NumPy array.
+Sourcepub fn as_slice(&self) -> Result<&[T], NotContiguousError>
Provide an immutable slice view of the interior of the NumPy array if it is contiguous.
+Sourcepub fn get<I>(&self, index: I) -> Option<&T>where
I: NpyIndex<Dim = D>,
Provide an immutable reference to an element of the NumPy array if the index is within bounds.
-sourcepub fn try_as_matrix<R, C, RStride, CStride>(
+
Sourcepub fn try_as_matrix<R, C, RStride, CStride>(
&self,
-) -> Option<MatrixView<'_, N, R, C, RStride, CStride>>where
+) -> Option<MatrixView<'_, N, R, C, RStride, CStride>>
-
sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this one-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
+Sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this one-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
§Panics
Panics if the array has negative strides.
-sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this two-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
+Sourcepub fn as_matrix(&self) -> DMatrixView<'_, N, Dyn, Dyn>
Convert this two-dimensional array into a nalgebra::DMatrixView
using dynamic strides.
§Panics
Panics if the array has negative strides.
-Methods from Deref<Target = Bound<'py, PyArray<T, D>>>§
pub fn borrow(&self) -> PyRef<'py, T>
Immutably borrows the value T
.
+Methods from Deref<Target = Bound<'py, PyArray<T, D>>>§
pub fn borrow(&self) -> PyRef<'py, T>
Immutably borrows the value T
.
This borrow lasts while the returned [PyRef
] exists.
Multiple immutable borrows can be taken out at the same time.
For frozen classes, the simpler [get
][Self::get] is available.
@@ -135,17 +135,17 @@ §Examples
§Panics
Panics if the value is currently borrowed. For a non-panicking variant, use
try_borrow_mut
.
-pub fn try_borrow(&self) -> Result<PyRef<'py, T>, PyBorrowError>
Attempts to immutably borrow the value T
, returning an error if the value is currently mutably borrowed.
+pub fn try_borrow(&self) -> Result<PyRef<'py, T>, PyBorrowError>
Attempts to immutably borrow the value T
, returning an error if the value is currently mutably borrowed.
The borrow lasts while the returned [PyRef
] exists.
This is the non-panicking variant of borrow
.
For frozen classes, the simpler [get
][Self::get] is available.
-pub fn try_borrow_mut(&self) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
+
pub fn try_borrow_mut(&self) -> Result<PyRefMut<'py, T>, PyBorrowMutError>where
T: PyClass<Frozen = False>,
Attempts to mutably borrow the value T
, returning an error if the value is currently borrowed.
The borrow lasts while the returned [PyRefMut
] exists.
This is the non-panicking variant of borrow_mut
.
-pub fn get(&self) -> &Twhere
- T: PyClass<Frozen = True> + Sync,
Provide an immutable borrow of the value T
without acquiring the GIL.
-This is available if the class is [frozen
][macro@crate::pyclass] and Sync
.
+pub fn get(&self) -> &Twhere
+ T: PyClass<Frozen = True> + Sync,
Provide an immutable borrow of the value T
without acquiring the GIL.
+This is available if the class is [frozen
][macro@crate::pyclass] and Sync
.
§Examples
use std::sync::atomic::{AtomicUsize, Ordering};
@@ -195,7 +195,7 @@ assert!(obj.as_super().pyrepr().is_ok());
})
pub fn py(&self) -> Python<'py>
Returns the GIL token associated with this object.
-pub fn as_borrowed<'a>(&'a self) -> Borrowed<'a, 'py, T>
Casts this Bound<T>
to a Borrowed<T>
smart pointer.
pub fn as_unbound(&self) -> &Py<T>
Removes the connection for this Bound<T>
from the GIL, allowing
it to cross thread boundaries, without transferring ownership.
-Trait Implementations§
source§impl<'py, T, D> Debug for PyReadwriteArray<'py, T, D>where
+
Trait Implementations§
Source§impl<'py, T, D> Debug for PyReadwriteArray<'py, T, D>
source§impl<'py, T, D> Deref for PyReadwriteArray<'py, T, D>where
+ D: Dimension,
Source§impl<'py, T, D> Deref for PyReadwriteArray<'py, T, D>
source§impl<'py, T, D> Drop for PyReadwriteArray<'py, T, D>where
+ D: Dimension,
Source§impl<'py, T, D> Drop for PyReadwriteArray<'py, T, D>
source§impl<'py, T, D> From<PyReadwriteArray<'py, T, D>> for PyReadonlyArray<'py, T, D>where
+ D: Dimension,
Source§impl<'py, T, D> From<PyReadwriteArray<'py, T, D>> for PyReadonlyArray<'py, T, D>
source§fn from(value: PyReadwriteArray<'py, T, D>) -> Self
Converts to this type from the input type.source§impl<'py, T: Element, D: Dimension> FromPyObject<'py> for PyReadwriteArray<'py, T, D>
source§fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult<Self>
Auto Trait Implementations§
§impl<'py, T, D> Freeze for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> !RefUnwindSafe for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> !Send for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> !Sync for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> Unpin for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> UnwindSafe for PyReadwriteArray<'py, T, D>where
- T: UnwindSafe,
- D: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
- T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T> From<T> for T
source§fn from(t: T) -> T
Returns the argument unchanged.
+ D: Dimension,Source§fn from(value: PyReadwriteArray<'py, T, D>) -> Self
Converts to this type from the input type.Source§impl<'py, T: Element, D: Dimension> FromPyObject<'py> for PyReadwriteArray<'py, T, D>
Source§fn extract_bound(obj: &Bound<'py, PyAny>) -> PyResult<Self>
Auto Trait Implementations§
§impl<'py, T, D> Freeze for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> !RefUnwindSafe for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> !Send for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> !Sync for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> Unpin for PyReadwriteArray<'py, T, D>
§impl<'py, T, D> UnwindSafe for PyReadwriteArray<'py, T, D>where
+ T: UnwindSafe,
+ D: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
+ T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
- T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
source§impl<T, U> Into<U> for Twhere
- U: From<T>,
source§fn into(self) -> U
Calls U::from(self)
.
+ T: FromPyObject<'py>,§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<SS, SP> SupersetOf<SS> for SPwhere
- SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
-superset. Read more§fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
\ No newline at end of file
+From<T> for U
chooses to do.
+§impl<SS, SP> SupersetOf<SS> for SPwhere
+ SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
+superset. Read more§fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
pub type PyReadonlyArray0<'py, T> = PyReadonlyArray<'py, T, Ix0>;
Read-only borrow of a zero-dimensional array.
+pub type PyReadonlyArray0<'py, T> = PyReadonlyArray<'py, T, Ix0>;
Read-only borrow of a zero-dimensional array.
struct PyReadonlyArray0<'py, T> { /* private fields */ }
pub type PyReadonlyArray1<'py, T> = PyReadonlyArray<'py, T, Ix1>;
Read-only borrow of a one-dimensional array.
+pub type PyReadonlyArray1<'py, T> = PyReadonlyArray<'py, T, Ix1>;
Read-only borrow of a one-dimensional array.
struct PyReadonlyArray1<'py, T> { /* private fields */ }
pub type PyReadonlyArray2<'py, T> = PyReadonlyArray<'py, T, Ix2>;
Read-only borrow of a two-dimensional array.
+pub type PyReadonlyArray2<'py, T> = PyReadonlyArray<'py, T, Ix2>;
Read-only borrow of a two-dimensional array.
struct PyReadonlyArray2<'py, T> { /* private fields */ }
pub type PyReadonlyArray3<'py, T> = PyReadonlyArray<'py, T, Ix3>;
Read-only borrow of a three-dimensional array.
+pub type PyReadonlyArray3<'py, T> = PyReadonlyArray<'py, T, Ix3>;
Read-only borrow of a three-dimensional array.
struct PyReadonlyArray3<'py, T> { /* private fields */ }
pub type PyReadonlyArray4<'py, T> = PyReadonlyArray<'py, T, Ix4>;
Read-only borrow of a four-dimensional array.
+pub type PyReadonlyArray4<'py, T> = PyReadonlyArray<'py, T, Ix4>;
Read-only borrow of a four-dimensional array.
struct PyReadonlyArray4<'py, T> { /* private fields */ }
pub type PyReadonlyArray5<'py, T> = PyReadonlyArray<'py, T, Ix5>;
Read-only borrow of a five-dimensional array.
+pub type PyReadonlyArray5<'py, T> = PyReadonlyArray<'py, T, Ix5>;
Read-only borrow of a five-dimensional array.
struct PyReadonlyArray5<'py, T> { /* private fields */ }
pub type PyReadonlyArray6<'py, T> = PyReadonlyArray<'py, T, Ix6>;
Read-only borrow of a six-dimensional array.
+pub type PyReadonlyArray6<'py, T> = PyReadonlyArray<'py, T, Ix6>;
Read-only borrow of a six-dimensional array.
struct PyReadonlyArray6<'py, T> { /* private fields */ }
pub type PyReadonlyArrayDyn<'py, T> = PyReadonlyArray<'py, T, IxDyn>;
Read-only borrow of an array whose dimensionality is determined at runtime.
+pub type PyReadonlyArrayDyn<'py, T> = PyReadonlyArray<'py, T, IxDyn>;
Read-only borrow of an array whose dimensionality is determined at runtime.
struct PyReadonlyArrayDyn<'py, T> { /* private fields */ }
pub type PyReadwriteArray0<'py, T> = PyReadwriteArray<'py, T, Ix0>;
Read-write borrow of a zero-dimensional array.
+pub type PyReadwriteArray0<'py, T> = PyReadwriteArray<'py, T, Ix0>;
Read-write borrow of a zero-dimensional array.
struct PyReadwriteArray0<'py, T> { /* private fields */ }
pub type PyReadwriteArray1<'py, T> = PyReadwriteArray<'py, T, Ix1>;
Read-write borrow of a one-dimensional array.
+pub type PyReadwriteArray1<'py, T> = PyReadwriteArray<'py, T, Ix1>;
Read-write borrow of a one-dimensional array.
struct PyReadwriteArray1<'py, T> { /* private fields */ }
pub type PyReadwriteArray2<'py, T> = PyReadwriteArray<'py, T, Ix2>;
Read-write borrow of a two-dimensional array.
+pub type PyReadwriteArray2<'py, T> = PyReadwriteArray<'py, T, Ix2>;
Read-write borrow of a two-dimensional array.
struct PyReadwriteArray2<'py, T> { /* private fields */ }
pub type PyReadwriteArray3<'py, T> = PyReadwriteArray<'py, T, Ix3>;
Read-write borrow of a three-dimensional array.
+pub type PyReadwriteArray3<'py, T> = PyReadwriteArray<'py, T, Ix3>;
Read-write borrow of a three-dimensional array.
struct PyReadwriteArray3<'py, T> { /* private fields */ }
pub type PyReadwriteArray4<'py, T> = PyReadwriteArray<'py, T, Ix4>;
Read-write borrow of a four-dimensional array.
+pub type PyReadwriteArray4<'py, T> = PyReadwriteArray<'py, T, Ix4>;
Read-write borrow of a four-dimensional array.
struct PyReadwriteArray4<'py, T> { /* private fields */ }
pub type PyReadwriteArray5<'py, T> = PyReadwriteArray<'py, T, Ix5>;
Read-write borrow of a five-dimensional array.
+pub type PyReadwriteArray5<'py, T> = PyReadwriteArray<'py, T, Ix5>;
Read-write borrow of a five-dimensional array.
struct PyReadwriteArray5<'py, T> { /* private fields */ }
pub type PyReadwriteArray6<'py, T> = PyReadwriteArray<'py, T, Ix6>;
Read-write borrow of a six-dimensional array.
+pub type PyReadwriteArray6<'py, T> = PyReadwriteArray<'py, T, Ix6>;
Read-write borrow of a six-dimensional array.
struct PyReadwriteArray6<'py, T> { /* private fields */ }
pub type PyReadwriteArrayDyn<'py, T> = PyReadwriteArray<'py, T, IxDyn>;
Read-write borrow of an array whose dimensionality is determined at runtime.
+pub type PyReadwriteArrayDyn<'py, T> = PyReadwriteArray<'py, T, IxDyn>;
Read-write borrow of an array whose dimensionality is determined at runtime.
struct PyReadwriteArrayDyn<'py, T> { /* private fields */ }
Defines conversion traits between Rust types and NumPy data types.
+Defines conversion traits between Rust types and NumPy data types.
pub trait IntoPyArray: Sized {
+IntoPyArray in numpy::convert - Rust
-
Consumes self
and moves its data into a NumPy array.
IntoPyArray::into_pyarray
Deprecated name for IntoPyArray::into_pyarray
.
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
pub trait NpyIndex: IntoDimension + Sealed { }
Trait implemented by types that can be used to index an array.
+pub trait NpyIndex: IntoDimension + Sealed { }
Trait implemented by types that can be used to index an array.
This is equivalent to ndarray::NdIndex
but accounts for
NumPy strides being in units of bytes instead of elements.
All types which implement IntoDimension
implement this trait as well.
@@ -8,4 +8,4 @@
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
pub trait ToNpyDims: Dimension + Sealed { }
Utility trait to specify the dimensions of an array.
-pub trait ToNpyDims: Dimension + Sealed { }
Utility trait to specify the dimensions of an array.
+This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
pub trait ToPyArray {
+ToPyArray in numpy::convert - Rust
-
Copies the content pointed to by &self
into a newly allocated NumPy array.
Deprecated name for ToPyArray::to_pyarray`.
-Note that the NumPy array always has Fortran memory layout
matching the memory layout used by nalgebra
.
Support datetimes and timedeltas
+Support datetimes and timedeltas
This module provides wrappers for NumPy’s datetime64
and timedelta64
types
which are used for time keeping with with an emphasis on scientific applications.
This means that while these types differentiate absolute and relative quantities, they ignore calendars (a month is always 30.44 days) and time zones.
diff --git a/numpy/datetime/struct.Datetime.html b/numpy/datetime/struct.Datetime.html
index 72bca3fa..e2cde709 100644
--- a/numpy/datetime/struct.Datetime.html
+++ b/numpy/datetime/struct.Datetime.html
@@ -1,34 +1,34 @@
-
pub struct Datetime<U: Unit>(/* private fields */);
Corresponds to the datetime64
scalar type
pub struct Datetime<U: Unit>(/* private fields */);
Corresponds to the datetime64
scalar type
Element::get_dtype
Element::get_dtype
.clone_to_uninit
)Calls U::from(self)
.
Element::get_dtype
Element::get_dtype
.self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Timedelta<U: Unit>(/* private fields */);
Corresponds to the [timedelta64
][scalars-datetime64] scalar type
pub struct Timedelta<U: Unit>(/* private fields */);
Corresponds to the [timedelta64
][scalars-datetime64] scalar type
Element::get_dtype
Element::get_dtype
.clone_to_uninit
)Calls U::from(self)
.
Element::get_dtype
Element::get_dtype
.self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub trait Unit:
- Send
- + Sync
- + Clone
- + Copy
- + PartialEq
- + Eq
- + Hash
- + PartialOrd
- + Ord {
+Unit in numpy::datetime - Rust pub trait Unit:
+ Send
+ + Sync
+ + Clone
+ + Copy
+ + PartialEq
+ + Eq
+ + Hash
+ + PartialOrd
+ + Ord {
const UNIT: NPY_DATETIMEUNIT;
- const ABBREV: &'static str;
+ const ABBREV: &'static str;
}
Expand description
Represents the datetime units supported by NumPy
-Required Associated Constants§
sourceconst UNIT: NPY_DATETIMEUNIT
The matching NumPy datetime unit code
-Object Safety§
This trait is not object safe.Implementors§
source§impl Unit for Attoseconds
source§impl Unit for Femtoseconds
source§impl Unit for Microseconds
source§impl Unit for Milliseconds
source§impl Unit for Nanoseconds
source§impl Unit for Picoseconds
\ No newline at end of file
+
The matching NumPy datetime unit code
+This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Predefined implementors of the Unit
trait
Predefined implementors of the Unit
trait
pub struct Attoseconds;
Attoseconds, i.e. 10^-18 seconds
-source
. Read moreclone_to_uninit
)Calls U::from(self)
.
pub struct Attoseconds;
Attoseconds, i.e. 10^-18 seconds
+source
. Read moreself
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Days;
Days, i.e. 24 hours
-clone_to_uninit
)Calls U::from(self)
.
pub struct Days;
Days, i.e. 24 hours
+self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Femtoseconds;
Femtoseconds, i.e. 10^-15 seconds
-source
. Read moreclone_to_uninit
)Calls U::from(self)
.
pub struct Femtoseconds;
Femtoseconds, i.e. 10^-15 seconds
+source
. Read moreself
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Hours;
Hours, i.e. 60 minutes
-clone_to_uninit
)Calls U::from(self)
.
pub struct Hours;
Hours, i.e. 60 minutes
+self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Microseconds;
Microseconds, i.e. 10^-6 seconds
-source
. Read moreclone_to_uninit
)Calls U::from(self)
.
pub struct Microseconds;
Microseconds, i.e. 10^-6 seconds
+source
. Read moreself
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Milliseconds;
Milliseconds, i.e. 10^-3 seconds
-source
. Read moreclone_to_uninit
)Calls U::from(self)
.
pub struct Milliseconds;
Milliseconds, i.e. 10^-3 seconds
+source
. Read moreself
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Minutes;
Minutes, i.e. 60 seconds
-clone_to_uninit
)Calls U::from(self)
.
pub struct Minutes;
Minutes, i.e. 60 seconds
+self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Months;
Months, i.e. 30 days
-clone_to_uninit
)Calls U::from(self)
.
pub struct Months;
Months, i.e. 30 days
+self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Nanoseconds;
Nanoseconds, i.e. 10^-9 seconds
-source
. Read moreclone_to_uninit
)Calls U::from(self)
.
pub struct Nanoseconds;
Nanoseconds, i.e. 10^-9 seconds
+source
. Read moreself
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Picoseconds;
Picoseconds, i.e. 10^-12 seconds
-source
. Read moreclone_to_uninit
)Calls U::from(self)
.
pub struct Picoseconds;
Picoseconds, i.e. 10^-12 seconds
+source
. Read moreself
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Seconds;
Seconds
-clone_to_uninit
)Calls U::from(self)
.
pub struct Seconds;
Seconds
+self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Weeks;
Weeks, i.e. 7 days
-clone_to_uninit
)Calls U::from(self)
.
pub struct Weeks;
Weeks, i.e. 7 days
+self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub struct Years;
Years, i.e. 12 months
-clone_to_uninit
)Calls U::from(self)
.
pub struct Years;
Years, i.e. 12 months
+self
from the equivalent element of its
-superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.From<T> for U
chooses to do.
+self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.#[non_exhaustive]pub enum BorrowError {
+BorrowError in numpy - Rust #[non_exhaustive]pub enum BorrowError {
AlreadyBorrowed,
NotWriteable,
}
Expand description
Inidcates why borrowing an array failed.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.Trait Implementations§
source§impl Debug for BorrowError
source§impl Display for BorrowError
source§impl Error for BorrowError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more1.0.0 · source§fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()source§impl From<BorrowError> for PyErr
source§fn from(err: BorrowError) -> PyErr
Converts to this type from the input type.Auto Trait Implementations§
§impl Freeze for BorrowError
§impl RefUnwindSafe for BorrowError
§impl Send for BorrowError
§impl Sync for BorrowError
§impl Unpin for BorrowError
§impl UnwindSafe for BorrowError
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
- T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read moresource§impl<T, U> Into<U> for Twhere
- U: From<T>,
Trait Implementations§
Source§impl Debug for BorrowError
Source§impl Display for BorrowError
Source§impl Error for BorrowError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more1.0.0 · Source§fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()Source§impl From<BorrowError> for PyErr
Source§fn from(err: BorrowError) -> PyErr
Converts to this type from the input type.Auto Trait Implementations§
§impl Freeze for BorrowError
§impl RefUnwindSafe for BorrowError
§impl Send for BorrowError
§impl Sync for BorrowError
§impl Unpin for BorrowError
§impl UnwindSafe for BorrowError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
+ T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more§impl<SS, SP> SupersetOf<SS> for SPwhere
- SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
-superset. Read more§fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.§impl<T> Ungil for Twhere
- T: Send,
\ No newline at end of file
+From<T> for U
chooses to do.
+
self
from the equivalent element of its
+superset. Read moreself
is actually part of its subset T
(and can be converted to it).self.to_subset
but without any property checks. Always succeeds.self
to the equivalent element of its superset.pub const fn Ix1(i0: usize) -> Dim<[usize; 1]>
Create a one-dimensional index
+pub const fn Ix2(i0: usize, i1: usize) -> Dim<[usize; 2]>
Create a two-dimensional index
+pub const fn Ix3(i0: usize, i1: usize, i2: usize) -> Dim<[usize; 3]>
Create a three-dimensional index
+pub const fn Ix4(i0: usize, i1: usize, i2: usize, i3: usize) -> Dim<[usize; 4]>
Create a four-dimensional index
+pub const fn Ix5(
- i0: usize,
- i1: usize,
- i2: usize,
- i3: usize,
- i4: usize,
-) -> Dim<[usize; 5]>
Create a five-dimensional index
+pub const fn Ix6(
- i0: usize,
- i1: usize,
- i2: usize,
- i3: usize,
- i4: usize,
- i5: usize,
-) -> Dim<[usize; 6]>
Create a six-dimensional index
+pub fn IxDyn(ix: &[usize]) -> Dim<IxDynImpl>
Create a dynamic-dimensional index
+pub fn dot<'py, T, DIN1, DIN2, OUT>(
+dot in numpy - Rust pub fn dot<'py, T, DIN1, DIN2, OUT>(
array1: &Bound<'py, PyArray<T, DIN1>>,
array2: &Bound<'py, PyArray<T, DIN2>>,
) -> PyResult<OUT>where
diff --git a/numpy/fn.dot_bound.html b/numpy/fn.dot_bound.html
index 29927c1a..48cfeb25 100644
--- a/numpy/fn.dot_bound.html
+++ b/numpy/fn.dot_bound.html
@@ -1,4 +1,4 @@
-dot_bound in numpy - Rust pub fn dot_bound<'py, T, DIN1, DIN2, OUT>(
+dot_bound in numpy - Rust pub fn dot_bound<'py, T, DIN1, DIN2, OUT>(
array1: &Bound<'py, PyArray<T, DIN1>>,
array2: &Bound<'py, PyArray<T, DIN2>>,
) -> PyResult<OUT>where
diff --git a/numpy/fn.dtype.html b/numpy/fn.dtype.html
index 36da7444..7c0b1f7c 100644
--- a/numpy/fn.dtype.html
+++ b/numpy/fn.dtype.html
@@ -1,2 +1,2 @@
-dtype in numpy - Rust pub fn dtype<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr>
Expand description
Returns the type descriptor (“dtype”) for a registered type.
+dtype in numpy - Rust pub fn dtype<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr>
Expand description
Returns the type descriptor (“dtype”) for a registered type.
\ No newline at end of file
diff --git a/numpy/fn.dtype_bound.html b/numpy/fn.dtype_bound.html
index d9d57660..f3154e39 100644
--- a/numpy/fn.dtype_bound.html
+++ b/numpy/fn.dtype_bound.html
@@ -1,2 +1,2 @@
-dtype_bound in numpy - Rust pub fn dtype_bound<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr>
👎Deprecated since 0.23.0: renamed to dtype
Expand description
Deprecated name for dtype
.
+dtype_bound in numpy - Rust pub fn dtype_bound<'py, T: Element>(py: Python<'py>) -> Bound<'py, PyArrayDescr>
👎Deprecated since 0.23.0: renamed to dtype
Expand description
Deprecated name for dtype
.
\ No newline at end of file
diff --git a/numpy/fn.einsum.html b/numpy/fn.einsum.html
index 979f821c..7624f041 100644
--- a/numpy/fn.einsum.html
+++ b/numpy/fn.einsum.html
@@ -1,5 +1,5 @@
-einsum in numpy - Rust pub fn einsum<'py, T, OUT>(
- subscripts: &str,
+einsum in numpy - Rust pub fn einsum<'py, T, OUT>(
+ subscripts: &str,
arrays: &[Borrowed<'_, 'py, PyArray<T, IxDyn>>],
) -> PyResult<OUT>where
T: Element,
diff --git a/numpy/fn.einsum_bound.html b/numpy/fn.einsum_bound.html
index 1fa2f639..af7b95d9 100644
--- a/numpy/fn.einsum_bound.html
+++ b/numpy/fn.einsum_bound.html
@@ -1,5 +1,5 @@
-einsum_bound in numpy - Rust pub fn einsum_bound<'py, T, OUT>(
- subscripts: &str,
+einsum_bound in numpy - Rust pub fn einsum_bound<'py, T, OUT>(
+ subscripts: &str,
arrays: &[Borrowed<'_, 'py, PyArray<T, IxDyn>>],
) -> PyResult<OUT>where
T: Element,
diff --git a/numpy/fn.inner.html b/numpy/fn.inner.html
index 14dc0b97..b448b4dc 100644
--- a/numpy/fn.inner.html
+++ b/numpy/fn.inner.html
@@ -1,4 +1,4 @@
-inner in numpy - Rust pub fn inner<'py, T, DIN1, DIN2, OUT>(
+inner in numpy - Rust pub fn inner<'py, T, DIN1, DIN2, OUT>(
array1: &Bound<'py, PyArray<T, DIN1>>,
array2: &Bound<'py, PyArray<T, DIN2>>,
) -> PyResult<OUT>where
diff --git a/numpy/fn.inner_bound.html b/numpy/fn.inner_bound.html
index f39e2efe..c9b123c9 100644
--- a/numpy/fn.inner_bound.html
+++ b/numpy/fn.inner_bound.html
@@ -1,4 +1,4 @@
-inner_bound in numpy - Rust pub fn inner_bound<'py, T, DIN1, DIN2, OUT>(
+inner_bound in numpy - Rust pub fn inner_bound<'py, T, DIN1, DIN2, OUT>(
array1: &Bound<'py, PyArray<T, DIN1>>,
array2: &Bound<'py, PyArray<T, DIN2>>,
) -> PyResult<OUT>where
diff --git a/numpy/index.html b/numpy/index.html
index 69941c9e..0443262e 100644
--- a/numpy/index.html
+++ b/numpy/index.html
@@ -1,4 +1,4 @@
-numpy - Rust Expand description
This crate provides Rust interfaces for NumPy C APIs,
+
numpy - Rust