Skip to content

Commit

Permalink
Rollback _initialised Simulation object
Browse files Browse the repository at this point in the history
  • Loading branch information
thewati committed Oct 23, 2024
1 parent bb1ddd8 commit 1ce601b
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/tlo/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class Simulation:
:ivar modules: A dictionary of the disease modules used in this simulation, keyed
by the module name.
:ivar population: The population being simulated.
:ivar rng: The simulation-level random number generator.
:ivar rng: The simulation-level random number generator.
.. note::
Individual modules also have their own random number generator with independent
state.
Expand All @@ -80,7 +80,7 @@ def __init__(
:param seed: The seed for random number generator. class will create one if not
supplied
:param log_config: Dictionary specifying logging configuration for this
simulation. Can have entries: `filename` - prefix for log file name, final
simulation. Can have entries: `filename` - prefix for log file name, final
file name will have a date time appended, if not present default is to not
output log to a file; `directory` - path to output directory to write log
file to, default if not specified is to output to the `outputs` folder;
Expand All @@ -89,9 +89,9 @@ def __init__(
logging to standard output stream (default is `False`).
:param show_progress_bar: Whether to show a progress bar instead of the logger
output during the simulation.
:param resourcefilepath: Path to resource files folder. Assign ``None` if no
:param resourcefilepath: Path to resource files folder. Assign ``None` if no
path is provided.
.. note::
The `custom_levels` entry in `log_config` argument can be used to disable
logging on all disease modules by setting a high level to `*`, and then
Expand All @@ -114,7 +114,7 @@ def __init__(
log_config = {}
self._custom_log_levels = None
self._log_filepath = self._configure_logging(**log_config)


# random number generator
seed_from = "auto" if seed is None else "user"
Expand All @@ -126,16 +126,18 @@ def __init__(
)
self.rng = np.random.RandomState(np.random.MT19937(self._seed_seq))

self._initialised = False


def _configure_logging(
self,
filename: Optional[str] = None,
filename: Optional[str] = None,
directory: Path | str = "./outputs",
custom_levels: Optional[dict[str, LogLevel]] = None,
suppress_stdout: bool = False
):
"""Configure logging of simulation outputs.
Can write log output to a file in addition the default of `stdout`. Mnimum
custom levels for each logger can be specified for filtering out messages.
Expand Down Expand Up @@ -208,7 +210,7 @@ def register(
modules to be registered. A :py:exc:`.ModuleDependencyError` exception will
be raised if there are missing dependencies.
:param auto_register_dependencies: Whether to register missing module dependencies
or not. If this argument is set to True, all module dependencies will be
or not. If this argument is set to True, all module dependencies will be
automatically registered.
"""
if auto_register_dependencies:
Expand Down Expand Up @@ -422,7 +424,7 @@ def do_birth(self, mother_id: int) -> int:

def find_events_for_person(self, person_id: int) -> list[tuple[Date, Event]]:
"""Find the events in the queue for a particular person.
:param person_id: The row index of the person of interest.
:return: List of tuples `(date_of_event, event)` for that `person_id` in the
queue.
Expand Down Expand Up @@ -462,7 +464,7 @@ def load_from_pickle(
:param pickle_path: File path to load simulation state from.
:param log_config: New log configuration to override previous configuration. If
`None` previous configuration (including output file) will be retained.
`None` previous configuration (including output file) will be retained.
:returns: Loaded :py:class:`Simulation` object.
"""
Expand Down

0 comments on commit 1ce601b

Please sign in to comment.