Merge branch 'main' into date_utils

This commit is contained in:
Palash Tyagi 2025-05-03 01:32:47 +01:00 committed by GitHub
commit e2db5eb315
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 705 additions and 200 deletions

1
.gitignore vendored
View File

@ -12,5 +12,6 @@ data/
*.info *.info
.venv/ .venv/
.vscode/
tarpaulin-report.* tarpaulin-report.*

View File

@ -76,17 +76,26 @@ let total: f64 = result.sum_vertical().iter().sum::<f64>();
assert_eq!(total, 184.0); assert_eq!(total, 184.0);
// broadcast & reduce // broadcast & reduce
let result: Matrix<f64> = &ma + 1.0; // add scalar let result: Matrix<f64> = ma.clone() + 1.0; // add scalar
let result: Matrix<f64> = &result - 1.0; // subtract scalar let result: Matrix<f64> = result + &ma - &ma; // add matrix
let result: Matrix<f64> = &result * 2.0; // multiply by scalar let result: Matrix<f64> = result - 1.0; // subtract scalar
let result: Matrix<f64> = &result / 2.0; // divide by scalar let result: Matrix<f64> = result * 2.0; // multiply by scalar
let result: Matrix<f64> = result / 2.0; // divide by scalar
let check: bool = result.eq_elementwise(ma.clone()).all(); let check: bool = result.eq_elem(ma.clone()).all();
assert!(check); assert!(check);
// The above math can also be written as: // The above math can also be written as:
let check: bool = (&(&(&(&ma + 1.0) - 1.0) * 2.0) / 2.0) let check: bool = (&(&(&(&ma + 1.0) - 1.0) * 2.0) / 2.0)
.eq_elementwise(ma) .eq_elem(ma.clone())
.all(); .all();
assert!(check); assert!(check);
// The above math can also be written as:
let check: bool = ((((ma.clone() + 1.0) - 1.0) * 2.0) / 2.0)
.eq_elem(ma)
.all();
assert!(check);
``` ```

View File

@ -96,9 +96,10 @@ impl BoolOps for Frame<bool> {
// } // }
// } // }
#[cfg(test)]
mod tests { mod tests {
use crate::frame::*; use super::*;
use crate::matrix::*; use crate::matrix::Matrix;
#[test] #[test]
fn test_series_ops() { fn test_series_ops() {

File diff suppressed because it is too large Load Diff