Skip to content

Model the documented PALS root node properties - #82

Merged
EZoni merged 1 commit into
pals-project:mainfrom
ax3l:topic-palsroot-properties
Jul 30, 2026
Merged

Model the documented PALS root node properties#82
EZoni merged 1 commit into
pals-project:mainfrom
ax3l:topic-palsroot-properties

Conversation

@ax3l

@ax3l ax3l commented Jul 30, 2026

Copy link
Copy Markdown
Member

Summary

First PR of the series working down tests/standard_examples_known_failures.txt: PALSroot now models the root keys documented in the standard's Fundamental Structure chapter.

  • authors: list of Author (name required; orcid, affiliation, email optional). The standard's one-key - author: entry form is unwrapped on load and restored on dump.
  • notes and reminders: lists of strings.
  • phase_space_coordinates: accepted as a string. The standard documents four values (ANGLE_AND_ENERGY, ANGLE_AND_MOMENTUM, KINETIC_AND_ENERGY, KINETIC_AND_MOMENTUM), but its own root_keys example writes standard, so the value is not restricted for now.
  • extension_labels: either the registered ExtensionLabels form (names/prefixes/suffixes sections, extra="forbid" so it cannot swallow the other form) or the flat label → description dict used by the standard's loading examples.
  • load: list of file names (with the literal SELF). Entries are modeled so the documents read and round-trip; resolving them into a combined document is left for a follow-up PR.
  • facility is now optional, since joiner and settings-only files carry none.
  • version also accepts bare numbers (version: 1), as written by the standard's root_keys example.

The facility item unpacking moved into a reusable unpack_element_items() helper so PALSroot no longer routes through the one-key-name unwrapping that only applies to named containers; BeamLine/UnionEle/Lattice behavior is unchanged. PALSroot.model_dump() keeps version visible even when unset (as before) and drops unset optional keys.

21 files leave the known-failures list; the remaining entries are facility-level include resolution and the sequence variables / compact sets forms.

Known limitations (follow-up material)

  • A facility element dict that fails element validation silently falls back to PlaceholderName in the element union (pre-existing). Combined with Quadrupole's stricter-than-standard "at least one multipole group" check, the standard's root_keys q1 loads as a name reference rather than a Quadrupole. Worth a dedicated PR.
  • load and include entries are parsed, not resolved.

Testing

  • pytest tests/ — 49 passed.
  • tests/validate_standard_examples.py against the pinned standard commit (5c39fde): 65 files checked, 0 unexpected results.
  • New tests/test_root.py covers the root keys, version forms, facility-less files, both extension_labels forms, YAML/JSON round-trips, and the serialized document shape.

🤖 Generated with Claude Code

@ax3l
ax3l requested a review from EZoni July 30, 2026 22:22
@ax3l ax3l added the element parameters element parameters (properties, attributes) label Jul 30, 2026
Extend PALSroot with the root keys documented in the standard's
Fundamental Structure chapter: authors (with the one-key `author:`
entry form), notes, reminders, phase_space_coordinates,
extension_labels (both the registered names/prefixes/suffixes form
and the flat label -> description form used by the standard's loading
examples), and the load file list. facility becomes optional, since
joiner and settings-only files carry none, and version also accepts
bare numbers as written by the standard's root_keys example.

Load resolution (combining files named in `load`) is not part of this
change; the entries are modeled so the documents read and round-trip.

21 files leave the standard-examples known-failures list.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ax3l
ax3l force-pushed the topic-palsroot-properties branch from ef8290c to dfd5c67 Compare July 30, 2026 22:23
Comment thread src/pals/PALS.py
@ax3l ax3l mentioned this pull request Jul 30, 2026
1 task
@EZoni
EZoni merged commit 2d6a803 into pals-project:main Jul 30, 2026
16 checks passed
@EZoni
EZoni deleted the topic-palsroot-properties branch July 30, 2026 22:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

element parameters element parameters (properties, attributes)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants