Skip to content

Commit

Permalink
Merge pull request #557 from rust-ndarray/remove-rustc-serialize
Browse files Browse the repository at this point in the history
Remove rustc-serialize crate feature
  • Loading branch information
bluss committed Nov 27, 2018
2 parents e1a6db8 + df7ba4f commit 29617e9
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 182 deletions.
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ test = true
[dependencies]
num-traits = "0.2"
num-complex = "0.2"
rustc-serialize = { version = "0.3.20", optional = true }
itertools = { version = "0.7.0", default-features = false }

# Use via the `blas` crate feature!
Expand Down Expand Up @@ -58,7 +57,7 @@ test-blas-openblas-sys = ["blas"]
test = ["test-blas-openblas-sys"]

# This feature is used for docs
docs = ["rustc-serialize", "serde-1"]
docs = ["serde-1"]

[profile.release]
[profile.bench]
Expand Down
5 changes: 0 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ Crate Feature Flags
The following crate feature flags are available. They are configured in
your `Cargo.toml`.

- ``rustc-serialize``

- Optional, compatible with Rust stable
- Enables serialization support for rustc-serialize 0.3

- ``serde-1``

- Optional, compatible with Rust stable
Expand Down
5 changes: 1 addition & 4 deletions serialization-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ publish = false
test = false

[dependencies]
ndarray = { path = "../", features = ["serde-1", "rustc-serialize"] }
ndarray = { path = "../", features = ["serde-1"] }

[features]
default = ["ron"]

[dev-dependencies.rustc-serialize]
version = "0.3.21"

[dev-dependencies.serde]
version = "1.0"

Expand Down
66 changes: 0 additions & 66 deletions serialization-tests/tests/serialize.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
extern crate rustc_serialize as serialize;

extern crate ndarray;

extern crate serde;
Expand All @@ -11,73 +9,9 @@ extern crate rmp_serde;
#[cfg(feature = "ron")]
extern crate ron;

use serialize::json;


use ndarray::{arr0, arr1, arr2, s, RcArray, RcArray1, RcArray2, ArrayD, IxDyn};

#[test]
fn serial_many_dim()
{
{
let a = arr0::<f32>(2.72);
let serial = json::encode(&a).unwrap();
println!("Encode {:?} => {:?}", a, serial);
let res = json::decode::<RcArray<f32, _>>(&serial);
println!("{:?}", res);
assert_eq!(a, res.unwrap());
}

{
let a = arr1::<f32>(&[2.72, 1., 2.]);
let serial = json::encode(&a).unwrap();
println!("Encode {:?} => {:?}", a, serial);
let res = json::decode::<RcArray1<f32>>(&serial);
println!("{:?}", res);
assert_eq!(a, res.unwrap());
}

{
let a = arr2(&[[3., 1., 2.2], [3.1, 4., 7.]]);
let serial = json::encode(&a).unwrap();
println!("Encode {:?} => {:?}", a, serial);
let res = json::decode::<RcArray2<f32>>(&serial);
println!("{:?}", res);
assert_eq!(a, res.unwrap());
let text = r##"{"v":1,"dim":[2,3],"data":[3,1,2.2,3.1,4,7]}"##;
let b = json::decode::<RcArray2<f32>>(text);
assert_eq!(a, b.unwrap());
}


{
// Test a sliced array.
let mut a = RcArray::linspace(0., 31., 32).reshape((2, 2, 2, 4));
a.slice_collapse(s![..;-1, .., .., ..2]);
let serial = json::encode(&a).unwrap();
println!("Encode {:?} => {:?}", a, serial);
let res = json::decode::<RcArray<f32, _>>(&serial);
println!("{:?}", res);
assert_eq!(a, res.unwrap());
}
}

#[test]
fn serial_wrong_count()
{
// one element too few
let text = r##"{"v":1,"dim":[2,3],"data":[3,1,2.2,3.1,4]}"##;
let arr = json::decode::<RcArray2<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 = json::decode::<RcArray2<f32>>(text);
println!("{:?}", arr);
assert!(arr.is_err());
}

#[test]
fn serial_many_dim_serde()
{
Expand Down
97 changes: 0 additions & 97 deletions src/array_serialize.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/arraytraits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ unsafe impl<S, D> Send for ArrayBase<S, D>
where S: Send + Data, D: Send
{ }

#[cfg(any(feature = "rustc-serialize", feature = "serde"))]
#[cfg(any(feature = "serde"))]
// Use version number so we can add a packed format later.
pub const ARRAY_FORMAT_VERSION: u8 = 1u8;

Expand Down
7 changes: 0 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@
//! The following crate feature flags are available. They are configured in your
//! `Cargo.toml`.
//!
//! - `rustc-serialize`
//! - Optional, compatible with Rust stable
//! - Enables serialization support for rustc-serialize 0.3
//! - `serde-1`
//! - Optional, compatible with Rust stable
//! - Enables serialization support for serde 1.0
Expand All @@ -89,8 +86,6 @@

#[cfg(feature = "serde-1")]
extern crate serde;
#[cfg(feature = "rustc-serialize")]
extern crate rustc_serialize as serialize;

#[cfg(feature="blas")]
extern crate cblas_sys;
Expand Down Expand Up @@ -143,8 +138,6 @@ mod aliases;
mod arraytraits;
#[cfg(feature = "serde-1")]
mod array_serde;
#[cfg(feature = "rustc-serialize")]
mod array_serialize;
mod arrayformat;
mod data_traits;

Expand Down

0 comments on commit 29617e9

Please sign in to comment.