pub trait ArrayProtocol:
Any
+ Send
+ Sync {
// Required methods
fn array_function(
&self,
func: &ArrayFunction,
_types: &[TypeId],
_args: &[Box<dyn Any>],
_kwargs: &HashMap<String, Box<dyn Any>>,
) -> Result<Box<dyn Any>, NotImplemented>;
fn as_any(&self) -> &dyn Any;
fn box_clone(&self) -> Box<dyn ArrayProtocol>;
// Provided methods
fn shape(&self) -> &[usize] { ... }
fn dtype(&self) -> TypeId { ... }
}
Expand description
Trait for objects that can handle the array protocol.
This is similar to NumPy
’s __array_function__
protocol.
Required Methods§
Sourcefn array_function(
&self,
func: &ArrayFunction,
_types: &[TypeId],
_args: &[Box<dyn Any>],
_kwargs: &HashMap<String, Box<dyn Any>>,
) -> Result<Box<dyn Any>, NotImplemented>
fn array_function( &self, func: &ArrayFunction, _types: &[TypeId], _args: &[Box<dyn Any>], _kwargs: &HashMap<String, Box<dyn Any>>, ) -> Result<Box<dyn Any>, NotImplemented>
Implementation of the array protocol.
func
- The function being calledtypes
- The types of all arguments that implementArrayProtocol
args
- The arguments to the functionkwargs
- Named arguments to the function
Returns Ok(result)
if the operation is successful, or Err(NotImplemented)
if the operation is not implemented for this type.
§Errors
Returns Err(NotImplemented)
if the operation is not supported by this array type.
Sourcefn box_clone(&self) -> Box<dyn ArrayProtocol>
fn box_clone(&self) -> Box<dyn ArrayProtocol>
Clone this array protocol object.
Provided Methods§
Trait Implementations§
Implementors§
impl<T, A> ArrayProtocol for JITEnabledArray<T, A>
impl<T, D> ArrayProtocol for AutoDevice<T, D>where
T: Clone + Send + Sync + 'static + Zero + Div<f64, Output = T> + Default + Mul<Output = T> + Add<Output = T>,
D: Dimension + RemoveAxis + 'static,
SliceInfo<[SliceInfoElem; 1], Dim<[usize; 1]>, Dim<[usize; 1]>>: SliceArg<D>,
SliceInfo<[SliceInfoElem; 2], Dim<[usize; 2]>, Dim<[usize; 2]>>: SliceArg<D>,
impl<T, D> ArrayProtocol for MixedPrecisionArray<T, D>
Implement ArrayProtocol for MixedPrecisionArray.