Skip to content

Commit

Permalink
Remove copy_with_addtional_key method from RandomnessStream (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
collijk committed Jan 18, 2023
1 parent 677e798 commit 6651e86
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 29 deletions.
1 change: 0 additions & 1 deletion src/vivarium/framework/randomness/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def _get_randomness_stream(
clock=self._clock,
seed=self._seed,
index_map=self._key_mapping,
manager=self,
for_initialization=for_initialization,
)
self._decision_points[decision_point] = stream
Expand Down
28 changes: 0 additions & 28 deletions src/vivarium/framework/randomness/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@
import pandas as pd

from vivarium.framework.randomness.core import choice, filter_for_probability, random
from vivarium.framework.randomness.exceptions import RandomnessError
from vivarium.framework.randomness.index_map import IndexMap
from vivarium.framework.utilities import rate_to_probability

if TYPE_CHECKING:
from vivarium.framework.randomness.manager import RandomnessManager


class RandomnessStream:
"""A stream for producing common random numbers.
Expand Down Expand Up @@ -55,38 +51,14 @@ def __init__(
clock: Callable,
seed: Any,
index_map: IndexMap = None,
manager: "RandomnessManager" = None,
for_initialization: bool = False,
):
self.key = key
self.clock = clock
self.seed = seed
self.index_map = index_map
self._manager = manager
self._for_initialization = for_initialization

def copy_with_additional_key(self, key: Any) -> "RandomnessStream":
"""Creates a copy of this stream with a permutation of it's random seed.
Parameters
----------
key
The additional key to describe the new stream with.
Returns
-------
RandomnessStream
A new RandomnessStream with a combined key.
"""
copy_key = "_".join([self.key, key])
if self._for_initialization:
raise RandomnessError("Initialization streams cannot be copied.")
elif self._manager:
return self._manager.get_randomness_stream(copy_key)
else:
return RandomnessStream(copy_key, self.clock, self.seed, self.index_map)

@property
def name(self):
return f"randomness_stream_{self.key}"
Expand Down

0 comments on commit 6651e86

Please sign in to comment.