MCPcopy Create free account
hub / github.com/5ocworkshop/bgraph / sample_f32

Function sample_f32

src/functions/fnc_sample.rs:12–15  ·  view source on GitHub ↗

Sample a data source safely. Panics are caught and non-finite values become 0.0.

(data: &dyn DataSource, x: f32)

Source from the content-addressed store, hash-verified

10
11/// Sample a data source safely. Panics are caught and non-finite values become 0.0.
12pub(crate) fn sample_f32(data: &dyn DataSource, x: f32) -> f32 {
13 let value = catch_unwind(AssertUnwindSafe(|| data.sample(x))).unwrap_or(0.0);
14 sanitize_value(value)
15}
16
17// <FILE>src/functions/fnc_sample.rs</FILE> - <DESC>Safe sampling helpers for DataSource</DESC>
18// <VERS>END OF VERSION: 1.0.0</VERS>

Callers 2

render_brailleFunction · 0.85
render_blockFunction · 0.85

Calls 2

sanitize_valueFunction · 0.85
sampleMethod · 0.45

Tested by

no test coverage detected