Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
bertiqwerty committed Jul 26, 2024
1 parent 2c71ffd commit 79bc9e4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rormula-rs/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
roerr, timing,
};

pub trait MemOrder : Default + Debug + Clone + PartialEq {
pub trait MemOrder: Default + Debug + Clone + PartialEq {
fn get(data: &[f64], row_idx: usize, col_idx: usize, n_rows: usize, n_cols: usize) -> f64;
fn set(
data: &mut [f64],
Expand Down
1 change: 0 additions & 1 deletion rormula-rs/src/expression/expr_arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ where

const ROW_CHANGE_OPS: [&str; 1] = ["|"];


pub fn has_row_change_op(expr: &ExprArithmetic) -> bool {
expr.operator_reprs()
.iter()
Expand Down
1 change: 0 additions & 1 deletion rormula-rs/src/expression/expr_wilkinson.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ fn names_equal(names: &[String], expected: &[&str]) {
use crate::array::ColMajor;
#[cfg(test)]
fn array_almost_equal(a1: Array2d<ColMajor>, a2: Array2d<ColMajor>) {

assert_eq!(a1.n_cols(), a2.n_cols());
assert_eq!(a1.n_rows(), a2.n_rows());
println!("{a1:?}");
Expand Down
12 changes: 10 additions & 2 deletions rormula-rs/src/expression/ops_common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
use crate::{array::{Array2d, MemOrder}, result::RoResult, roerr};
use crate::{
array::{Array2d, MemOrder},
result::RoResult,
roerr,
};
use std::mem;

use super::Value;
Expand Down Expand Up @@ -36,7 +40,11 @@ pub fn op_componentwise_array<M: MemOrder>(
a.componentwise(b, op)
}

pub fn op_scalar<M: MemOrder + Default>(a: Value<M>, b: Value<M>, op: &impl Fn(f64, f64) -> f64) -> Value<M> {
pub fn op_scalar<M: MemOrder + Default>(
a: Value<M>,
b: Value<M>,
op: &impl Fn(f64, f64) -> f64,
) -> Value<M> {
let arr_vs_sc = |arr: &mut Array2d<M>, sc| {
arr.elt_mutate(&|elt| op(elt, sc));
Value::Array(mem::take(arr))
Expand Down
4 changes: 3 additions & 1 deletion rormula-rs/tests/test_rormula.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ fn test_arithmetic() {
let res = expr.eval_vec(vars).unwrap();
let s_ref = "x * -2.0";
let expr_ref = ExprArithmetic::parse(s_ref).unwrap();
let rev_val = expr_ref.eval(&[Value::Array(Array2d::<O>::ones(5, 1))]).unwrap();
let rev_val = expr_ref
.eval(&[Value::Array(Array2d::<O>::ones(5, 1))])
.unwrap();
assert_eq!(res, rev_val);
let s = "4*3";
let expr = ExprArithmetic::<O>::parse(s).unwrap();
Expand Down

0 comments on commit 79bc9e4

Please sign in to comment.