Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ArcArray1 and ArcArray2 aliases #741

Merged
merged 1 commit into from
Oct 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions serialization-tests/tests/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern crate rmp_serde;
#[cfg(feature = "ron")]
extern crate ron;

use ndarray::{arr0, arr1, arr2, s, ArcArray, ArrayD, Ix2, IxDyn};
use ndarray::{arr0, arr1, arr2, s, ArcArray, ArcArray2, ArrayD, IxDyn};

#[test]
fn serial_many_dim_serde() {
Expand Down Expand Up @@ -98,13 +98,13 @@ fn serial_ixdyn_serde() {
fn serial_wrong_count_serde() {
// one element too few
let text = r##"{"v":1,"dim":[2,3],"data":[3,1,2.2,3.1,4]}"##;
let arr = serde_json::from_str::<ArcArray<f32, Ix2>>(text);
let arr = serde_json::from_str::<ArcArray2<f32>>(text);
println!("{:?}", arr);
assert!(arr.is_err());

// future version
let text = r##"{"v":200,"dim":[2,3],"data":[3,1,2.2,3.1,4,7]}"##;
let arr = serde_json::from_str::<ArcArray<f32, Ix2>>(text);
let arr = serde_json::from_str::<ArcArray2<f32>>(text);
println!("{:?}", arr);
assert!(arr.is_err());
}
Expand Down
7 changes: 6 additions & 1 deletion src/aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use crate::dimension::Dim;
#[allow(deprecated)]
use crate::{Array, ArrayView, ArrayViewMut, Ix, IxDynImpl, RcArray};
use crate::{ArcArray, Array, ArrayView, ArrayViewMut, Ix, IxDynImpl, RcArray};

/// Create a zero-dimensional index
#[allow(non_snake_case)]
Expand Down Expand Up @@ -158,3 +158,8 @@ pub type RcArray1<A> = RcArray<A, Ix1>;
#[allow(deprecated)]
#[deprecated(note = "`RcArray` has been renamed to `ArcArray`")]
pub type RcArray2<A> = RcArray<A, Ix2>;

/// one-dimensional shared ownership array
pub type ArcArray1<A> = ArcArray<A, Ix1>;
/// two-dimensional shared ownership array
pub type ArcArray2<A> = ArcArray<A, Ix2>;
6 changes: 3 additions & 3 deletions src/free_functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use std::mem::{forget, size_of};
use std::slice;

use crate::dimension;
use crate::imp_prelude::*;
use crate::{dimension, ArcArray1, ArcArray2};

/// Create an [**`Array`**](type.Array.html) with one, two or
/// three dimensions.
Expand Down Expand Up @@ -63,7 +63,7 @@ pub fn arr1<A: Clone>(xs: &[A]) -> Array1<A> {
}

/// Create a one-dimensional array with elements from `xs`.
pub fn rcarr1<A: Clone>(xs: &[A]) -> ArcArray<A, Ix1> {
pub fn rcarr1<A: Clone>(xs: &[A]) -> ArcArray1<A> {
arr1(xs).into_shared()
}

Expand Down Expand Up @@ -289,7 +289,7 @@ where

/// Create a two-dimensional array with elements from `xs`.
///
pub fn rcarr2<A: Clone, V: Clone + FixedInitializer<Elem = A>>(xs: &[V]) -> ArcArray<A, Ix2> {
pub fn rcarr2<A: Clone, V: Clone + FixedInitializer<Elem = A>>(xs: &[V]) -> ArcArray2<A> {
arr2(xs).into_shared()
}

Expand Down