MCPcopy Create free account
hub / github.com/ciphermodelabs/ciphercore / pwl_array_test

Function pwl_array_test

ciphercore-base/src/ops/pwl/approx_pointwise.rs:321–347  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

319
320 #[test]
321 fn pwl_array_test() -> Result<()> {
322 let mut xs = vec![];
323 for i in 0..50 {
324 let x = ((i - 25) as f32) * 0.1;
325 xs.push(x);
326 }
327 let ys = array_helper(
328 xs.clone(),
329 vec![xs.len() as u64],
330 PWLConfig {
331 log_buckets: 4,
332 flatten_left: false,
333 flatten_right: false,
334 },
335 )?;
336 for (x, y) in xs.iter().zip(ys.iter()) {
337 let expected = *x * *x;
338 if *x < -2.0 || *x > 2.0 {
339 // Edges.
340 assert!((expected - *y).abs() < 0.2);
341 } else {
342 // Inner stuff.
343 assert!((expected - *y).abs() < 0.02);
344 }
345 }
346 Ok(())
347 }
348
349 #[test]
350 fn pwl_array2d_test() -> Result<()> {

Callers

nothing calls this directly

Calls 4

cloneMethod · 0.80
array_helperFunction · 0.70
pushMethod · 0.45
zipMethod · 0.45

Tested by

no test coverage detected