Skip to content

Commit 748bc4b

Browse files
committed
fix(lint): resolve Rust 1.100 clippy manual_checked_ops and cloned_ref_to_slice_refs
1 parent 3ee20f9 commit 748bc4b

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎crates/oxideon-core/src/optim_extra.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ pub fn sparse_adam_step(
16821682
let mut m = exp_avg.to_vec::<f64>()?;
16831683
let mut v = exp_avg_sq.to_vec::<f64>()?;
16841684
let rows = if shape.is_empty() { 1 } else { shape[0] };
1685-
let row_len = if rows == 0 { 0 } else { p.len() / rows };
1685+
let row_len = p.len().checked_div(rows).unwrap_or(0);
16861686
let bc1 = 1.0 - beta1.powi(step as i32);
16871687
let bc2 = 1.0 - beta2.powi(step as i32);
16881688
let step_size = lr * bc2.sqrt() / bc1;

‎crates/oxideon-core/src/optim_kernels.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ mod tests {
320320
assert!((sq[0] - 0.025).abs() < 1e-15);
321321
let want = 1.0 - 0.1 * 0.5 / (0.025f64.sqrt() + 1e-8);
322322
assert!((np.to_vec::<f64>().unwrap()[0] - want).abs() < 1e-12);
323-
assert!(optim_step("rmsprop", &p, &g, &[z.clone()], &h(&[("lr", 0.1)])).is_err());
323+
assert!(optim_step("rmsprop", &p, &g, std::slice::from_ref(&z), &h(&[("lr", 0.1)])).is_err());
324324
assert!(optim_step("nope", &p, &g, &[], &h(&[])).is_err());
325325
}
326326

0 commit comments

Comments
 (0)