Skip to content

Commit da242b1

Browse files
committed
FIX: Fix minors
1 parent 1294707 commit da242b1

File tree

6 files changed

+48
-63
lines changed

6 files changed

+48
-63
lines changed

src/complex/matrix.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1904,7 +1904,7 @@ impl LinearAlgebra<ComplexMatrix> for ComplexMatrix {
19041904
PQLU { p, q, l, u }
19051905
}
19061906

1907-
fn waz(&self, d_form: Form) -> Option<WAZD<ComplexMatrix>> {
1907+
fn waz(&self, _d_form: Form) -> Option<WAZD<ComplexMatrix>> {
19081908
unimplemented!()
19091909
}
19101910

src/fuga/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ pub use crate::traits::{
173173
};
174174

175175
#[cfg(feature = "complex")]
176+
#[allow(unused_imports)]
176177
pub use crate::complex::{
177178
C64,
178179
matrix::*,
180+
integral::*,
181+
vector::*,
179182
};
180183

181184
#[allow(unused_imports)]
@@ -186,7 +189,6 @@ pub use crate::structure::{
186189
vector::*,
187190
dataframe::*,
188191
ad::*,
189-
//complex::C64,
190192
};
191193

192194
pub use crate::util::{api::*, low_level::*, non_macro::*, print::*, useful::*, wrapper::*};

src/prelude/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ pub use crate::structure::{
177177
dataframe::{
178178
DataFrame, DType, DTypeArray, DTypeValue, Series, Scalar, TypedScalar, TypedVector
179179
},
180-
//complex::C64,
181180
};
182181
#[cfg(feature="csv")]
183182
pub use crate::structure::dataframe::WithCSV;
@@ -187,6 +186,7 @@ pub use crate::structure::dataframe::WithNetCDF;
187186

188187
#[cfg(feature = "complex")]
189188
#[allow(ambiguous_glob_reexports)]
189+
#[allow(unused_imports)]
190190
pub use crate::complex::{
191191
C64,
192192
matrix::*,

src/structure/dataframe.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@
187187
//!
188188
//! * `nc` feature should be required
189189
//! * `libnetcdf` dependency should be required
190-
//! * `Char`, `Bool` are saved as `U8` type. Thus, for reading `Char` or `Bool` type nc file,
191-
//! explicit type casting is required.
190+
//! * `Char`, `Bool` are saved as `U8` type. Thus, for reading `Char` or `Bool` type nc file, explicit type casting is required.
192191
//!
193192
//! ```
194193
//! #[macro_use]
@@ -226,8 +225,7 @@
226225
//! ```
227226
//!
228227
//! * `parquet` feature should be required
229-
//! * `Char` is saved with `String` type. Thus, for reading `Char` type parquet file,
230-
//! the output type is `String`.
228+
//! * `Char` is saved with `String` type. Thus, for reading `Char` type parquet file, the output type is `String`.
231229
//! * **Caution** : For different length `Bool` type column, missing values are filled with `false`.
232230
//! ```
233231
//! #[macro_use]
@@ -1398,7 +1396,7 @@ impl DataFrame {
13981396

13991397
/// Push new pair of head, Series to DataFrame
14001398
pub fn push(&mut self, name: &str, series: Series) {
1401-
if self.ics.len() > 0 {
1399+
if !self.ics.is_empty() {
14021400
assert_eq!(self.ics.iter().find(|x| x.as_str() == name), None, "Repetitive index!");
14031401
}
14041402
self.ics.push(name.to_string());
@@ -1466,8 +1464,7 @@ impl DataFrame {
14661464
result.push('\n');
14671465
}
14681466
result.push_str(&tab("...", lc1));
1469-
for j in 0 .. self.data.len() {
1470-
let space = space_vec[j];
1467+
for &space in space_vec.iter() {
14711468
result.push_str(&tab("...", space));
14721469
}
14731470
result.push('\n');

src/structure/matrix.rs

+38-52
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@
462462
//!
463463
//! ## Tips for LU, Det, Inverse
464464
//!
465-
//! * If you save `self.lu()` rather than the direct use of `self.det()` or `self.lu()` then you
466-
//! can get better performance (via memoization)
465+
//! * If you save `self.lu()` rather than the direct use of `self.det()` or `self.lu()` then you can get better performance (via memoization)
467466
//!
468467
//! ```rust
469468
//! use peroxide::fuga::*;
@@ -2754,12 +2753,10 @@ impl FPMatrix for Matrix {
27542753
/// ```rust
27552754
/// use peroxide::fuga::*;
27562755
///
2757-
/// fn main() {
2758-
/// let x = ml_matrix("1 2;3 4;5 6");
2759-
/// let y = x.col_map(|c| c.fmap(|t| t - c.mean()));
2756+
/// let x = ml_matrix("1 2;3 4;5 6");
2757+
/// let y = x.col_map(|c| c.fmap(|t| t - c.mean()));
27602758
///
2761-
/// assert_eq!(y, ml_matrix("-2 -2;0 0;2 2"));
2762-
/// }
2759+
/// assert_eq!(y, ml_matrix("-2 -2;0 0;2 2"));
27632760
/// ```
27642761
fn col_map<F>(&self, f: F) -> Matrix
27652762
where
@@ -2780,12 +2777,10 @@ impl FPMatrix for Matrix {
27802777
/// ```rust
27812778
/// use peroxide::fuga::*;
27822779
///
2783-
/// fn main() {
2784-
/// let x = ml_matrix("1 2 3;4 5 6");
2785-
/// let y = x.row_map(|r| r.fmap(|t| t - r.mean()));
2780+
/// let x = ml_matrix("1 2 3;4 5 6");
2781+
/// let y = x.row_map(|r| r.fmap(|t| t - r.mean()));
27862782
///
2787-
/// assert_eq!(y, ml_matrix("-1 0 1;-1 0 1"));
2788-
/// }
2783+
/// assert_eq!(y, ml_matrix("-1 0 1;-1 0 1"));
27892784
/// ```
27902785
fn row_map<F>(&self, f: F) -> Matrix
27912786
where
@@ -3035,23 +3030,21 @@ impl LinearAlgebra<Matrix> for Matrix {
30353030
///
30363031
/// # Caution
30373032
/// It returns `Option<PQLU>` - You should unwrap to obtain real value.
3038-
/// `PQLU` has four field - `p`, `q`, `l`, `u`.
3039-
/// `p`, `q` are permutations.
3040-
/// `l`, `u` are matrices.
3033+
/// - `PQLU` has four field - `p`, `q`, `l`, `u`.
3034+
/// - `p`, `q` are permutations.
3035+
/// - `l`, `u` are matrices.
30413036
///
30423037
/// # Examples
30433038
/// ```
30443039
/// use peroxide::fuga::*;
30453040
///
3046-
/// fn main() {
3047-
/// let a = matrix(vec![1,2,3,4], 2, 2, Row);
3048-
/// let pqlu = a.lu();
3049-
/// let (p,q,l,u) = (pqlu.p, pqlu.q, pqlu.l, pqlu.u);
3050-
/// assert_eq!(p, vec![1]); // swap 0 & 1 (Row)
3051-
/// assert_eq!(q, vec![1]); // swap 0 & 1 (Col)
3052-
/// assert_eq!(l, matrix(vec![1.0,0.0,0.5,1.0],2,2,Row));
3053-
/// assert_eq!(u, matrix(vec![4.0,3.0,0.0,-0.5],2,2,Row));
3054-
/// }
3041+
/// let a = matrix(vec![1,2,3,4], 2, 2, Row);
3042+
/// let pqlu = a.lu();
3043+
/// let (p,q,l,u) = (pqlu.p, pqlu.q, pqlu.l, pqlu.u);
3044+
/// assert_eq!(p, vec![1]); // swap 0 & 1 (Row)
3045+
/// assert_eq!(q, vec![1]); // swap 0 & 1 (Col)
3046+
/// assert_eq!(l, matrix(vec![1.0,0.0,0.5,1.0],2,2,Row));
3047+
/// assert_eq!(u, matrix(vec![4.0,3.0,0.0,-0.5],2,2,Row));
30553048
/// ```
30563049
fn lu(&self) -> PQLU<Matrix> {
30573050
assert_eq!(self.col, self.row);
@@ -3155,16 +3148,14 @@ impl LinearAlgebra<Matrix> for Matrix {
31553148
/// ```
31563149
/// use peroxide::fuga::*;
31573150
///
3158-
/// fn main() {
3159-
/// let a = ml_matrix("12 -51 4;6 167 -68; -4 24 -41");
3160-
/// let qr = a.qr();
3161-
/// let r = ml_matrix("-14 -21 14; 0 -175 70; 0 0 -35");
3162-
/// #[cfg(feature="O3")]
3163-
/// {
3164-
/// assert_eq!(r, qr.r);
3165-
/// }
3166-
/// qr.r.print();
3151+
/// let a = ml_matrix("12 -51 4;6 167 -68; -4 24 -41");
3152+
/// let qr = a.qr();
3153+
/// let r = ml_matrix("-14 -21 14; 0 -175 70; 0 0 -35");
3154+
/// #[cfg(feature="O3")]
3155+
/// {
3156+
/// assert_eq!(r, qr.r);
31673157
/// }
3158+
/// qr.r.print();
31683159
/// ```
31693160
#[allow(non_snake_case)]
31703161
fn qr(&self) -> QR<Matrix> {
@@ -3211,15 +3202,13 @@ impl LinearAlgebra<Matrix> for Matrix {
32113202
/// ```
32123203
/// use peroxide::fuga::*;
32133204
///
3214-
/// fn main() {
3215-
/// let a = ml_matrix("3 2 2;2 3 -2");
3216-
/// #[cfg(feature="O3")]
3217-
/// {
3218-
/// let svd = a.svd();
3219-
/// assert!(eq_vec(&vec![5f64, 3f64], &svd.s, 1e-7));
3220-
/// }
3221-
/// a.print();
3205+
/// let a = ml_matrix("3 2 2;2 3 -2");
3206+
/// #[cfg(feature="O3")]
3207+
/// {
3208+
/// let svd = a.svd();
3209+
/// assert!(eq_vec(&vec![5f64, 3f64], &svd.s, 1e-7));
32223210
/// }
3211+
/// a.print();
32233212
/// ```
32243213
fn svd(&self) -> SVD<Matrix> {
32253214
match () {
@@ -3250,21 +3239,18 @@ impl LinearAlgebra<Matrix> for Matrix {
32503239
///
32513240
/// # Examples
32523241
/// ```
3253-
/// extern crate peroxide;
32543242
/// use peroxide::fuga::*;
32553243
///
3256-
/// fn main() {
3257-
/// let a = ml_matrix("1 2;2 5");
3258-
/// #[cfg(feature = "O3")]
3259-
/// {
3260-
/// let u = a.cholesky(Upper);
3261-
/// let l = a.cholesky(Lower);
3244+
/// let a = ml_matrix("1 2;2 5");
3245+
/// #[cfg(feature = "O3")]
3246+
/// {
3247+
/// let u = a.cholesky(Upper);
3248+
/// let l = a.cholesky(Lower);
32623249
///
3263-
/// assert_eq!(u, ml_matrix("1 2;0 1"));
3264-
/// assert_eq!(l, ml_matrix("1 0;2 1"));
3265-
/// }
3266-
/// a.print();
3250+
/// assert_eq!(u, ml_matrix("1 2;0 1"));
3251+
/// assert_eq!(l, ml_matrix("1 0;2 1"));
32673252
/// }
3253+
/// a.print();
32683254
/// ```
32693255
#[cfg(feature = "O3")]
32703256
fn cholesky(&self, uplo: UPLO) -> Matrix {

src/structure/polynomial.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl fmt::Display for Polynomial {
5151
let coef_0 = self.coef[1];
5252

5353
if coef_1 == 1. {
54-
result.push_str("x");
54+
result.push('x');
5555
} else if coef_1 == -1. {
5656
result.push_str("-x");
5757
} else {

0 commit comments

Comments
 (0)