Skip to content

Commit

Permalink
methods updated to reflect changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lrdossan committed Jan 26, 2024
1 parent b498e77 commit d09d6f0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 27 deletions.
2 changes: 0 additions & 2 deletions caimira/apps/calculator/defaults.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import typing

# ------------------ Default form values ----------------------

# Used to declare when an attribute of a class must have a value provided, and
Expand Down
3 changes: 1 addition & 2 deletions caimira/apps/calculator/model_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,10 +411,9 @@ def infected_population(self) -> mc.InfectedPopulation:

activity_defn = self.data_registry.population_scenario_activity[self.activity_type]['activity']
expiration_defn = self.data_registry.population_scenario_activity[self.activity_type]['expiration']

if (self.activity_type == 'smallmeeting'):
# Conversation of N people is approximately 1/N% of the time speaking.
expiration_defn = {'Speaking': 1, 'Breathing': self.total_people - 1}
expiration_defn['Breathing'] = self.total_people - 1
elif (self.activity_type == 'precise'):
activity_defn, expiration_defn = self.generate_precise_activity_expiration()

Expand Down
29 changes: 6 additions & 23 deletions caimira/monte_carlo/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,6 @@ def custom_distribution_lookup(dict: dict, key_part: str) -> typing.Any:
return f"Key '{key_part}' not found."


def evaluate_reference(reference_variable: str) -> typing.Any:
"""
Evaluate a reference variable.
Args:
reference_variable (str): The variable to evaluate.
Returns:
Any: The evaluated value or an error message if the variable is not defined.
"""
try:
return eval(reference_variable)
except NameError:
return f"Variable '{reference_variable}' is not defined."


def evaluate_custom_distribution(dist: str, params: typing.Dict) -> typing.Any:
"""
Evaluate a custom distribution.
Expand All @@ -92,13 +75,13 @@ def evaluate_custom_distribution(dist: str, params: typing.Dict) -> typing.Any:
ValueError: If the distribution type is not recognized.
"""
if dist == 'Numpy Linear Space (linspace)':
if dist == 'Linear Space':
return np.linspace(params['start'], params['stop'], params['num'])
elif dist == 'Numpy Normal Distribution (random.normal)':
return Normal(params['mean_gaussian'], params['standard_deviation_gaussian'])
elif dist == 'Numpy Log-normal Distribution (random.lognormal)':
return LogNormal(params['mean_gaussian'], params['standard_deviation_gaussian'])
elif dist == 'Numpy Uniform Distribution (random.uniform)':
elif dist == 'Normal':
return Normal(params['normal_mean_gaussian'], params['normal_standard_deviation_gaussian'])
elif dist == 'Log-normal':
return LogNormal(params['lognormal_mean_gaussian'], params['lognormal_standard_deviation_gaussian'])
elif dist == 'Uniform':
return Uniform(params['low'], params['high'])
else:
raise ValueError('Bad request - distribution not found.')
Expand Down

0 comments on commit d09d6f0

Please sign in to comment.