-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* do not log imports * update ui * 2d parsing might be ready to try * WIP * csv working...gotta think about it * working on init * new years eve * 1d and 2d csv working * WIP * tests passing * ready to update docs * WIP * hrm maybe no need to track first x in watch? * only create file if needed * readme * improve logging on watch * improve new * csv2d tests passing * cleanup * add back csv1d * demo working * demo working * wip * some lints
- Loading branch information
Showing
67 changed files
with
1,123 additions
and
561 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
2.5,1.0 | ||
1.0,2.0 | ||
1.5,2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
#[cfg(test)] | ||
mod csv2d_tests { | ||
use hamcrest2::prelude::*; | ||
use num_rational::Rational64; | ||
|
||
use crate::{datagen::*, NameSet, NormalForm, PointOp}; | ||
|
||
#[test] | ||
fn test_get_data_2d() { | ||
let result = get_data2d("./src/datagen/2d_test_data.csv".to_string()).unwrap(); | ||
|
||
let expected = vec![vec![2.5, 1.0], vec![1.0, 2.0], vec![1.5, 2.0]]; | ||
|
||
assert_that!(&result, contains(expected).exactly()); | ||
} | ||
|
||
#[test] | ||
fn test_point_to_point_op() { | ||
let mut names = NameSet::new(); | ||
names.insert("2d_test_data.csv".to_string()); | ||
|
||
let result = point_to_point_op( | ||
&vec![1.0, 2.0], | ||
None, | ||
&vec![ | ||
Scale { | ||
axis: Axis::F, | ||
value: Rational64::new(2, 1), | ||
}, | ||
Scale { | ||
axis: Axis::L, | ||
value: Rational64::new(1, 2), | ||
}, | ||
], | ||
"2d_test_data.csv", | ||
); | ||
let expected = Term::Op(Op::Compose { | ||
operations: vec![ | ||
Term::Op(Op::TransposeA { | ||
a: Rational64::new(2, 1), | ||
}), | ||
Term::Op(Op::Length { | ||
m: Rational64::new(2, 1), | ||
}), | ||
], | ||
}); | ||
|
||
assert_eq!(result, expected); | ||
} | ||
|
||
#[test] | ||
fn test_csv_data_to_normal_form() { | ||
let csv_data = vec![vec![1.0, 1.0], vec![1.0, 1.0], vec![1.0, 1.0]]; | ||
|
||
let mut names = NameSet::new(); | ||
let filename = "2d_test_data.csv"; | ||
let scales = vec![ | ||
Scale { | ||
axis: Axis::F, | ||
value: Rational64::new(2, 1), | ||
}, | ||
Scale { | ||
axis: Axis::L, | ||
value: Rational64::new(1, 2), | ||
}, | ||
]; | ||
names.insert(filename.to_string()); | ||
|
||
let result = csv_data_to_normal_form(&csv_data, scales, "2d_test_data.csv"); | ||
let expected = Term::Op(Op::Sequence { | ||
operations: vec![ | ||
Term::Op(Op::Compose { | ||
operations: vec![ | ||
Term::Op(Op::TransposeA { | ||
a: Rational64::new(2, 1), | ||
}), | ||
Term::Op(Op::Length { | ||
m: Rational64::new(1, 1), | ||
}), | ||
], | ||
}), | ||
Term::Op(Op::Compose { | ||
operations: vec![ | ||
Term::Op(Op::TransposeA { | ||
a: Rational64::new(2, 1), | ||
}), | ||
Term::Op(Op::Length { | ||
m: Rational64::new(1, 1), | ||
}), | ||
], | ||
}), | ||
Term::Op(Op::Compose { | ||
operations: vec![ | ||
Term::Op(Op::TransposeA { | ||
a: Rational64::new(2, 1), | ||
}), | ||
Term::Op(Op::Length { | ||
m: Rational64::new(1, 1), | ||
}), | ||
], | ||
}), | ||
], | ||
}); | ||
|
||
assert_eq!(result, expected); | ||
} | ||
|
||
#[test] | ||
fn test_csv1d_to_normalform() { | ||
let scales = vec![ | ||
Scale { | ||
axis: Axis::F, | ||
value: Rational64::new(2, 1), | ||
}, | ||
Scale { | ||
axis: Axis::L, | ||
value: Rational64::new(1, 2), | ||
}, | ||
]; | ||
|
||
let result = csv2d_to_normalform("./src/datagen/2d_test_data.csv", scales).unwrap(); | ||
|
||
let mut names = NameSet::new(); | ||
names.insert("2d_test_data.csv".to_string()); | ||
let expected = Term::Op(Op::Sequence { | ||
operations: vec![ | ||
Term::Op(Op::Compose { | ||
operations: vec![ | ||
Term::Op(Op::TransposeA { | ||
a: Rational64::new(5, 1), | ||
}), | ||
Term::Op(Op::Length { | ||
m: Rational64::new(1, 1), | ||
}), | ||
], | ||
}), | ||
Term::Op(Op::Compose { | ||
operations: vec![ | ||
Term::Op(Op::TransposeA { | ||
a: Rational64::new(2, 1), | ||
}), | ||
Term::Op(Op::Length { | ||
m: Rational64::new(2, 1), | ||
}), | ||
], | ||
}), | ||
Term::Op(Op::Compose { | ||
operations: vec![ | ||
Term::Op(Op::TransposeA { | ||
a: Rational64::new(3, 1), | ||
}), | ||
Term::Op(Op::Length { | ||
m: Rational64::new(2, 1), | ||
}), | ||
], | ||
}), | ||
], | ||
}); | ||
assert_eq!(result, expected); | ||
} | ||
} |
Oops, something went wrong.