Skip to content

Use str Enums for categorical options (algorithm, init, compat_mode) #91

@jc-macdonald

Description

@jc-macdonald

Summary

Replace raw string values for categorical options with str-inheriting Enums.

Current pattern

"algorithm": "vb",
"init": "random",
"compat_mode": "strict_legacy",
"explained_var_solver": "auto",

Manual string comparisons scattered throughout _pca_full.py, _full_update.py, etc.

Proposed change

from enum import Enum

class Algorithm(str, Enum):
    VB = "vb"
    MAP = "map"

class InitMethod(str, Enum):
    RANDOM = "random"
    CUSTOM = "custom"

str inheritance makes this non-breaking — existing string arguments coerce automatically and == comparisons still work.

Benefits

  • IDE autocomplete and type-checking for option values
  • Invalid values caught at construction time
  • mypy can verify exhaustive match

Scope

~40 lines of Enum definitions + validators. Non-breaking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or capability

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions