Qu

to_digital

Builtin index · Signal processing

result = to_digital(x, threshold)

Input: x, threshold · Output: result

What it is

x: a length-N real vector or Signal; threshold: a number, positional and required.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = to_digital(x, threshold)
x vector or Signalx: a length-N real vector or Signal.
threshold numberthreshold: a number, positional and required.
result Model
Returns a Digital value (a Model, kind "digital") remembering x and threshold together, so edges/rising_edges/falling_edges/high_time/low_time/duty_cycle below can be called on it without repeating the threshold.

Examples

No documentation example calls this form yet. The Signal processing chapter is where one belongs.

How it works

to_digital(x, threshold) -- §8 of toolkit-signal.md. Wraps a signal and a digitizing threshold into a Digital value (a Model tagged "digital", same general shape find_edges's own "edges" result already uses -- this codebase's Value::Model was never ML-exclusive, see its own doc comment) so .edges()/.rising_edges()/ .falling_edges()/.high_time()/.low_time()/ .duty_cycle() all read naturally via UFCS (d.edges() desugars to edges(d)) without repeating the threshold at every call site the way find_edges(x, level=...) requires today. Deliberately NOT a new engine concept: it is the same find_edges/find_trigger/ duty_cycle math already shipped, just remembering the threshold on the caller's behalf.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.