Skip to content
This repository was archived by the owner on Dec 9, 2018. It is now read-only.

Commit 8d6f127

Browse files
author
Jorge Aparicio
committed
Merge pull request #10 from japaric/fix
fix(lib): fix fallout of numeric reform
2 parents 7f8c117 + 866762f commit 8d6f127

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ name = "simplot"
44
version = "0.0.0"
55
authors = ["Jorge Aparicio <[email protected]>"]
66

7-
[dev-dependencies.num]
8-
git = "https://github.com/rust-lang/num"
7+
[dev-dependencies.complex]
8+
git = "https://github.com/japaric/complex.rs"

src/lib.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
use std::collections::TreeMap;
77
use std::io::{Command, File, IoResult, Process};
8-
use std::num;
8+
use std::num::{Float, mod};
99
use std::str::{MaybeOwned, mod};
1010

1111
use data::Matrix;
@@ -177,18 +177,19 @@ impl Figure {
177177
/// ![Plot](multiaxis.svg)
178178
///
179179
/// ```
180-
/// # extern crate num;
180+
/// # extern crate complex;
181181
/// # extern crate simplot;
182182
/// # fn main() {
183183
/// # use std::io::{fs, USER_RWX};
184-
/// use num::Complex;
184+
/// use complex::Complex;
185185
/// use simplot::axis::{BottomX, LeftY, Logarithmic, RightY};
186186
/// use simplot::color::{DarkViolet, Rgb};
187187
/// use simplot::curve::Lines;
188188
/// use simplot::grid::Major;
189189
/// use simplot::key::{Center, Inside, Top};
190190
/// use simplot::{BottomXRightY, Figure, logspace};
191191
/// use std::f64::consts::PI;
192+
/// use std::num::Float;
192193
///
193194
/// fn tf(x: f64) -> Complex<f64> {
194195
/// Complex::new(0., x) / Complex::new(10., x) / Complex::new(1., x / 10_000.)
@@ -197,7 +198,7 @@ impl Figure {
197198
/// let (start, end) = (1.1, 90_000.);
198199
/// let xs = logspace(start, end, 101);
199200
/// let phase = xs.map(|x| tf(x).arg() * 180. / PI);
200-
/// let magnitude = xs.map(|x| tf(x).norm());
201+
/// let magnitude = xs.map(|x| tf(x).abs());
201202
///
202203
/// # fs::mkdir_recursive(&Path::new("target/doc/simplot"), USER_RWX).unwrap();
203204
/// # assert_eq!(Some(String::new()),
@@ -351,6 +352,7 @@ impl Figure {
351352
/// use simplot::curve::{Impulses, LinesPoints, Steps};
352353
/// use simplot::key::{Inside, Left, Top};
353354
/// use simplot::{Circle, Dash, Figure, linspace};
355+
/// use std::num::FloatMath;
354356
///
355357
/// let xs = linspace::<f64>(-10., 10., 51);
356358
///
@@ -429,6 +431,7 @@ impl Figure {
429431
/// use simplot::key::{Outside, Right, Top};
430432
/// use simplot::{Figure, FilledCircle, linspace};
431433
/// use std::f64::consts::PI;
434+
/// use std::num::FloatMath;
432435
/// use std::rand::{Rng, mod};
433436
///
434437
/// fn sinc(mut x: f64) -> f64 {
@@ -510,6 +513,7 @@ impl Figure {
510513
/// use simplot::{Figure, linspace};
511514
/// use std::f64::consts::PI;
512515
/// use std::iter;
516+
/// use std::num::Float;
513517
///
514518
/// let (start, end) = (-5., 5.);
515519
/// let xs = linspace(start, end, 101);
@@ -757,7 +761,7 @@ trait Script {
757761
pub fn linspace<T>(start: T, end: T, n: uint) -> Linspace<T> where T: Float {
758762
let step = if n < 2 {
759763
// NB The value of `step` doesn't matter in these cases
760-
num::zero()
764+
Float::zero()
761765
} else {
762766
(end - start) / num::cast(n - 1).unwrap()
763767
};
@@ -771,13 +775,13 @@ pub fn linspace<T>(start: T, end: T, n: uint) -> Linspace<T> where T: Float {
771775
}
772776

773777
pub fn logspace<T>(start: T, end: T, n: uint) -> Logspace<T> where T: Float {
774-
assert!(start > num::zero() && end > num::zero());
778+
assert!(start > Float::zero() && end > Float::zero());
775779

776780
let (start, end) = (start.ln(), end.ln());
777781

778782
let step = if n < 2 {
779783
// NB The value of `step` doesn't matter in these cases
780-
num::zero()
784+
Float::zero()
781785
} else {
782786
(end - start) / num::cast(n - 1).unwrap()
783787
};

0 commit comments

Comments
 (0)