Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/stratocaster/base/strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def weights(self) -> dict[GufeKey, float | None]:

def resolve(self) -> dict[GufeKey, float | None]:
"""Normalize the proposal weights relative to all non-None Transformation weights."""
weights = self.weights
weights = dict(self.weights)
weight_sum = sum([weight for weight in weights.values() if weight is not None])
modified_weights = {
key: weight / weight_sum
Expand Down
10 changes: 10 additions & 0 deletions src/stratocaster/tests/test_strategy_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ class TestStrategyResult:
def test_dict_roundtrip(self):
assert StrategyResult.from_dict(self.result.to_dict()) == self.result

def test_resolve_does_not_mutate_weights(self):
original_weights = dict(self.result.weights)
self.result.resolve()
assert self.result.weights == original_weights

def test_resolve_is_idempotent(self):
first = self.result.resolve()
second = self.result.resolve()
assert first == second


class DummyStrategySettings(StrategySettings):
pass
Expand Down
Loading