Skip to content

FPM-588: Autogenerate flag values#70

Merged
richjam merged 2 commits intomainfrom
feature/FPM-588-autogenerate-flag-values
Mar 27, 2026
Merged

FPM-588: Autogenerate flag values#70
richjam merged 2 commits intomainfrom
feature/FPM-588-autogenerate-flag-values

Conversation

@richjam
Copy link
Copy Markdown
Collaborator

@richjam richjam commented Mar 26, 2026

Background

Previously, registering a flag system required supplying explicit power-of-2 integers for each category, e.g:

tf.register_flag_system("qc", {"OUT_OF_RANGE": 1, "SPIKE": 2, "LOW_BATTERY": 4})

This PR allows a list of strings to be passed instead, with bit values assigned automatically:

tf.register_flag_system("qc", ["OUT_OF_RANGE", "SPIKE", "LOW_BATTERY"])

The list is sorted before values are assigned, ensuring the same set of names always produces the same mapping regardless of input order. Passing None (now the default) or an empty list produces a minimal flag system with a single FLAGGED member at value 1.

Main changes

  • flag_manager.py - extended FlagSystemType and added list/None handling in register_flag_system
  • base.py - updated TimeFrame.register_flag_system signature and docstring to match
  • test_flag_manager.py - tests for list input, sort consistency, empty list default, None default, and duplicate name error

Note

  • Documentation will be modified in another PR

@richjam richjam mentioned this pull request Mar 27, 2026
@richjam richjam merged commit 2b9f8db into main Mar 27, 2026
3 checks passed
@richjam richjam deleted the feature/FPM-588-autogenerate-flag-values branch March 27, 2026 16:47
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