methods updated to reflect changes
This commit is contained in:
parent
b498e776f7
commit
d09d6f0ec8
3 changed files with 7 additions and 27 deletions
|
|
@ -1,5 +1,3 @@
|
|||
import typing
|
||||
|
||||
# ------------------ Default form values ----------------------
|
||||
|
||||
# Used to declare when an attribute of a class must have a value provided, and
|
||||
|
|
|
|||
|
|
@ -411,10 +411,9 @@ class VirusFormData(FormData):
|
|||
|
||||
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()
|
||||
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
|
|
@ -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.')
|
||||
|
|
|
|||
Loading…
Reference in a new issue