Skip to content

fix(spec): stop to_dict dropping stated number starts and titles - #569

Merged
Alpha9463 merged 1 commit into
mainfrom
fix/533-fix-to-dict
Oct 2, 2026
Merged

Alpha9463 merged 1 commit into
mainfrom
fix/533-fix-to-dict

Conversation

@Alpha9463

Copy link
Copy Markdown
Owner

Summary

Stops to_dict() from silently changing a sheet on the way to a file. A float number start drew S1.0 and read back as S1; a falsy annotation title was dropped and the box came back re-measured. Number starts now accept integers only, and a stated annotation title is written as stated, so reading back a non-text title fails loudly instead of silently.

Related Issues

Closes #533

Changes

  • Number starts: Flowsheet.stream_number_start, line_number_start and loop_number_start become validated properties. A float (even 1.0), Decimal, string or bool raises TypeError naming the attribute, at construction and on assignment. Any integer type, including numpy.int64, is stored as an int. to_dict() compares with the default exactly as before, which is now exact because the values are always integers.
  • Annotation titles: _write_annotation writes the title whenever it differs from the default "", rather than only when truthy. A title of 0, False or None is written as stated and refused by from_dict() with a SpecError naming annotations[N].title. Rendering is unchanged.
  • Tests: tests/test_stated_values.py (27 tests) covers both halves, for Annotation and TableBox.
  • Docs: one sentence in docs/api.md on integer number starts, plus [Unreleased] entries in CHANGELOG.md.

A correction to the issue text: Annotation(title=0) never drew a "0" title. The band is drawn only for a truthy title while the box is sized from str(title), so it drew an untitled box sized as if titled. That rendering is unchanged here; the round trip now refuses it instead of silently resizing the box.

How to Test

python3 -m pytest -q tests/test_stated_values.py tests/test_spec.py tests/test_loops.py tests/test_stream_numbering.py
python3 -c "from pandid import Flowsheet; Flowsheet('x', stream_number_start=1.0)"   # TypeError
python3 -m pytest -q
python3 -m ruff check .
python3 -m ruff format --check tests
python3 -m mypy pandid
python3 -m pyright pandid

Evidence

  • Full suite: 11,521 passed, 188 skipped.
  • Lint and types: ruff, test formatting, mypy and git diff --check are clean. Pyright reports 0 errors plus the existing __all__ warning, and 0 errors on the new test file.
  • Drawings unchanged: frames, routes and validation findings are identical to main for 46 drawings (the 21 examples as authored and with placement stripped, plus four benchmark sheets).

Checklist

  • Base branch is main and the branch is mergeable
  • Commit subjects follow Conventional Commits; tracked work links its issue
  • Self-reviewed the full diff on the Files changed tab
  • Relevant local checks pass; all CI jobs pass before merge
  • Documentation and examples updated if behaviour changed
  • Before/after drawings included if rendered output changed (no rendered output changed)
  • Blocking review feedback resolved, if review was requested

🤖 Generated with Claude Code

@Alpha9463
Alpha9463 merged commit dc504f2 into main Oct 2, 2026
7 checks passed
@Alpha9463
Alpha9463 deleted the fix/533-fix-to-dict branch October 2, 2026 01:36
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.

to_dict() silently drops a stated value and the sheet is redrawn differently: a fractional number-start, and a falsey annotation title

1 participant