Skip to content

Expressions unification#177

Open
DaanVanVugt wants to merge 6 commits into
iterorganization:developfrom
DaanVanVugt:expressions-unification
Open

Expressions unification#177
DaanVanVugt wants to merge 6 commits into
iterorganization:developfrom
DaanVanVugt:expressions-unification

Conversation

@DaanVanVugt

Copy link
Copy Markdown
Contributor

After #176

@@ -0,0 +1,135 @@
import ast

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update docs?

Comment on lines 86 to 89
# Derived waveforms are parsed as YAML block strings
elif "'" in editor_text or '"' in editor_text:
indented_text = textwrap.indent(editor_text, " ")
waveform_yaml = f"{name}: |\n{indented_text}"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think this will work anymore with the new expressions.

Comment on lines +9 to +12
# Configuration schema version. Bumped to 2 when bare-string values became literal
# string constants instead of derived-waveform expressions.
CURRENT_SCHEMA_VERSION = 2

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to have YAML schema versions, should we use semantic versioning instead?

Comment thread tests/test_yaml/example.yaml Outdated
- Rename is_string -> is_categorical so booleans are treated like strings
  (held as a zero-order-hold step rather than coerced to float and interpolated)
- Reject mixing categorical (string/boolean) and numeric values within a single
  waveform, since the gaps between them cannot be interpolated
- Document the constant tendency value types (float/int/categorical) in the docs
np.full preserved int dtype for integer constants, so get_value() (the
time=None path) returned an int64 array while the explicit-time path
upcast to float. Force float for numeric values; categorical values
(str/bool) keep their native dtype.
A piecewise-constant tendency that holds each value from its breakpoint until the
next, supporting non-numeric (string/boolean) values. Registered as 'steps'.

- start is inferred from the first breakpoint; an explicit end/duration may be
  given so the final value is held for a real duration (defaults to the last time)
- shared time/value validation and start/end resolution are factored out of
  PiecewiseLinearTendency via overridable _coerce_value / _resolve_time_bounds
  hooks, so the steps tendency only overrides what genuinely differs
Replace DerivedWaveform with an ExpressionTendency on the single Waveform
class, integrated with develop's import/static waveforms. Bare scalars are
now classified by content: a number is a constant, a string that references
another waveform or uses an operator/function is an expression, and a plain
word is a literal string constant. Explicit {value:}/{expression:} override
the heuristic. Example config uses the compact bare form.
@DaanVanVugt
DaanVanVugt force-pushed the expressions-unification branch from ffb652f to 166b751 Compare July 10, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants