pub struct WasmArray { /* private fields */ }Expand description
A wrapper around ndarray for JavaScript interop
Implementations§
Source§impl WasmArray
impl WasmArray
Sourcepub fn new(data: &JsValue) -> Result<WasmArray, JsValue>
pub fn new(data: &JsValue) -> Result<WasmArray, JsValue>
Create a 1D array from a JavaScript array or typed array
Sourcepub fn from_shape(shape: &JsValue, data: &JsValue) -> Result<WasmArray, JsValue>
pub fn from_shape(shape: &JsValue, data: &JsValue) -> Result<WasmArray, JsValue>
Create an array with a specific shape from flat data
Sourcepub fn zeros(shape: &JsValue) -> Result<WasmArray, JsValue>
pub fn zeros(shape: &JsValue) -> Result<WasmArray, JsValue>
Create an array of zeros with the given shape
Sourcepub fn ones(shape: &JsValue) -> Result<WasmArray, JsValue>
pub fn ones(shape: &JsValue) -> Result<WasmArray, JsValue>
Create an array of ones with the given shape
Sourcepub fn full(shape: &JsValue, value: f64) -> Result<WasmArray, JsValue>
pub fn full(shape: &JsValue, value: f64) -> Result<WasmArray, JsValue>
Create an array filled with a constant value
Sourcepub fn linspace(start: f64, end: f64, num: usize) -> Result<WasmArray, JsValue>
pub fn linspace(start: f64, end: f64, num: usize) -> Result<WasmArray, JsValue>
Create an evenly spaced array (like numpy.linspace)
Sourcepub fn arange(start: f64, end: f64, step: f64) -> Result<WasmArray, JsValue>
pub fn arange(start: f64, end: f64, step: f64) -> Result<WasmArray, JsValue>
Create an array with evenly spaced values (like numpy.arange)
Sourcepub fn to_array(&self) -> Float64Array
pub fn to_array(&self) -> Float64Array
Convert to a flat JavaScript Float64Array
Sourcepub fn to_nested_array(&self) -> JsValue
pub fn to_nested_array(&self) -> JsValue
Convert to a JavaScript array (nested for multi-dimensional arrays)
Sourcepub fn get(&self, index: usize) -> Result<f64, JsValue>
pub fn get(&self, index: usize) -> Result<f64, JsValue>
Get a value at the specified index (flat indexing)
Trait Implementations§
Source§impl FromWasmAbi for WasmArray
impl FromWasmAbi for WasmArray
Source§impl IntoWasmAbi for WasmArray
impl IntoWasmAbi for WasmArray
Source§impl LongRefFromWasmAbi for WasmArray
impl LongRefFromWasmAbi for WasmArray
Source§impl OptionFromWasmAbi for WasmArray
impl OptionFromWasmAbi for WasmArray
Source§impl OptionIntoWasmAbi for WasmArray
impl OptionIntoWasmAbi for WasmArray
Source§impl RefFromWasmAbi for WasmArray
impl RefFromWasmAbi for WasmArray
Source§impl RefMutFromWasmAbi for WasmArray
impl RefMutFromWasmAbi for WasmArray
Source§impl TryFromJsValue for WasmArray
impl TryFromJsValue for WasmArray
Source§impl VectorFromWasmAbi for WasmArray
impl VectorFromWasmAbi for WasmArray
Source§impl VectorIntoWasmAbi for WasmArray
impl VectorIntoWasmAbi for WasmArray
impl SupportsConstructor for WasmArray
impl SupportsInstanceProperty for WasmArray
impl SupportsStaticProperty for WasmArray
Auto Trait Implementations§
impl Freeze for WasmArray
impl RefUnwindSafe for WasmArray
impl Send for WasmArray
impl Sync for WasmArray
impl Unpin for WasmArray
impl UnsafeUnpin for WasmArray
impl UnwindSafe for WasmArray
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.