Skip to content

feat(core): move the beat pattern parser into tilia_core.timemap - #739

Merged
azfoo merged 2 commits into
v1-prereleasefrom
v1/270-beat-pattern
Oct 14, 2026
Merged

azfoo merged 2 commits into
v1-prereleasefrom
v1/270-beat-pattern

Conversation

@azfoo

@azfoo azfoo commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

🤖 Claude

Moves #621 (beat units and time signatures)'s beat pattern parser into the core, for the beat importer and for adding a beat timeline.

What changed

  • packages/tilia-core/src/tilia_core/timemap/pattern.py: tilia/timelines/beat/pattern.py from feat: beat patterns, beat units, time signatures and quarter stamps #621, unchanged (the same blob, 236c76e5, at feat/beat-unit's head 0ee8ea45, at 07cb6d4f and at a17bbd83). It sits next to units.py, the other module from feat: beat patterns, beat units, time signatures and quarter stamps #621: the beat importer and adding a beat timeline will call it, and so will the app's beat timeline, its validators and the beat pattern dialog once the app imports the core's copy. It imports nothing from the app and doesn't log, so nothing had to change. The app keeps its own copy until it switches to the core's.
  • packages/tilia-core/tests/timemap/test_timemap_pattern.py: feat: beat patterns, beat units, time signatures and quarter stamps #621's tests/timelines/beat/test_pattern.py, with only the import changed (first commit), plus a TestFormatBars class (second commit): runs collapsed, nested groups not recovered, and parse(format_bars(bars)) giving the same bars back. The moved tests cover parse and group_runs only.

Tests

  • uv run --package tilia-core pytest packages/tilia-core -q, on the current v1-prerelease: 794 passed, 21 skipped, 8 xfailed (Python 3.11), 55 of them in test_timemap_pattern.py.
  • The pattern tests on Python 3.10: 55 passed.
  • python scripts/check_packages.py: all package checks passed (both wheels, fresh installs without PySide6 or the app, both test suites), on the current v1-prerelease.
  • ruff check and black --check on both files: clean.

Guards: what removing each one does

Each check neutralised in turn, the pattern tests run, the file restored (its blob checked afterwards). Run on the module and tests as they are here:

Guard Without it
MAX_BARS, after each item (parse_items) 1 failed, 54 passed
MAX_BARS, before a group is repeated (parse_item) 55 passed: untested, see below
MAX_DEPTH 3 failed, 52 passed
MAX_DIGITS 2 failed, 53 passed
ASCII digits only (_DIGITS, not str.isdigit) 4 failed, 51 passed
repeat count at least 1 1 failed, 54 passed
bar length at least 1 2 failed, 53 passed
leading zeros not counted as digits 1 failed, 54 passed
format_bars collapsing runs 6 failed, 49 passed

Untested: the check before a group is repeated, the one that keeps 999999[999999[4]] from exhausting memory. Without it, 999999999[999999999[4]] is still refused by the check after each item, but only once the list of 999,999,999 bars is built (22 s and several GB here), so every test passes. The same holds for #621's own tests. A cheap test that fails without it is TimeLineAnnotator/project-management#301 (test the large-group guard); it isn't in this PR, which moves the code and its tests as they are.

Part of TimeLineAnnotator/project-management#270

🤖 Generated with Claude Code

@azfoo azfoo changed the title feat(core): move the beat pattern parser into tilia_core.importers feat(core): move the beat pattern parser into tilia_core.timemap Oct 14, 2026
azfoo and others added 2 commits October 14, 2026 19:40
Moved from tilia/timelines/beat/pattern.py (desktop#621), unchanged: the
file is the same blob as at 0ee8ea4, 07cb6d4 and a17bbd8. It sits next
to units.py, the other module from #621. The beat importer and adding a
beat timeline will call it, and so will the app's beat timeline, its
validators and the beat pattern dialog once the app uses the core's copy.
Its tests move to test_timemap_pattern.py with only the import changed.

Part of TimeLineAnnotator/project-management#270

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The moved tests cover parse and group_runs only. format_bars is what the
beat importer stores as a timeline's beat pattern, so its runs, its
flattening of nested groups and its round trip through parse are tested
here.

Part of TimeLineAnnotator/project-management#270

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@azfoo
azfoo force-pushed the v1/270-beat-pattern branch from 71a890e to 775e203 Compare October 14, 2026 17:42
@azfoo
azfoo merged commit d4c0a94 into v1-prerelease Oct 14, 2026
26 checks passed
@azfoo
azfoo deleted the v1/270-beat-pattern branch October 14, 2026 18:15
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.

1 participant