Skip to content

Use default_factory for WeightedEnsemble.metadata - #48

Merged
braceal merged 1 commit into
mainfrom
fix/ensemble-metadata-default-factory
Aug 11, 2026
Merged

Use default_factory for WeightedEnsemble.metadata#48
braceal merged 1 commit into
mainfrom
fix/ensemble-metadata-default-factory

Conversation

@braceal

@braceal braceal commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

WeightedEnsemble.metadata was declared as:

metadata: IterationMetadata = Field(
    default=IterationMetadata,
    ...
)

default= assigns the class object as the default value rather than constructing an instance, so any WeightedEnsemble created without an explicit metadata argument carries IterationMetadata the class. self.metadata.iteration_id then reads an attribute off the class instead of a real iteration id, and the iteration property returns something that is not an int.

Switched to default_factory=IterationMetadata, matching how cur_sims and next_sims are already declared in the same model.

Also tightened the iteration docstring to note the value is 1-indexed.

Extracted from #40 so it can land on its own.

🤖 Generated with Claude Code

The field was declared with default=IterationMetadata, which assigns the
class object itself as the default rather than constructing an instance.
Any WeightedEnsemble built without an explicit metadata argument carried
the class, so attribute access such as .iteration returned the field
descriptor instead of the current iteration id.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@braceal
braceal merged commit 93b03fc into main Aug 11, 2026
@braceal
braceal deleted the fix/ensemble-metadata-default-factory branch August 11, 2026 21:45
@braceal braceal mentioned this pull request Aug 11, 2026
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