Trajectory maker
BetaCompletionTime
Bases: DistributionCompletionTime
Source code in june/epidemiology/infection/trajectory_maker.py
109 110 111 112 |
|
CompletionTime
Bases: ABC
Source code in june/epidemiology/infection/trajectory_maker.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
__call__()
abstractmethod
Compute the time a given stage should take to complete
Source code in june/epidemiology/infection/trajectory_maker.py
18 19 20 21 22 |
|
class_for_type(type_string)
staticmethod
Get a CompletionTime class from a string in configuration
Parameters:
Name | Type | Description | Default |
---|---|---|---|
type_string
|
str
|
The type of CompletionTime |
required |
e.g. constant/exponential/beta
Returns:
Type | Description |
---|---|
type
|
The corresponding class: |
Raises:
Type | Description |
---|---|
AssertionError
|
If the type string is not recognised |
Source code in june/epidemiology/infection/trajectory_maker.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
|
from_dict(variation_type_dict)
classmethod
Parameters:
Name | Type | Description | Default |
---|---|---|---|
variation_type_dict
|
|
required |
Source code in june/epidemiology/infection/trajectory_maker.py
54 55 56 57 58 59 60 61 62 63 |
|
ConstantCompletionTime
Bases: CompletionTime
Source code in june/epidemiology/infection/trajectory_maker.py
66 67 68 69 70 71 72 |
|
DistributionCompletionTime
Bases: CompletionTime
, ABC
Source code in june/epidemiology/infection/trajectory_maker.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
distribution
property
ExponentialCompletionTime
Bases: DistributionCompletionTime
Source code in june/epidemiology/infection/trajectory_maker.py
101 102 103 104 |
|
ExponweibCompletionTime
Bases: DistributionCompletionTime
Source code in june/epidemiology/infection/trajectory_maker.py
136 137 138 139 |
|
LognormalCompletionTime
Bases: DistributionCompletionTime
Source code in june/epidemiology/infection/trajectory_maker.py
119 120 121 122 |
|
NormalCompletionTime
Bases: DistributionCompletionTime
Source code in june/epidemiology/infection/trajectory_maker.py
128 129 130 131 |
|
Stage
Source code in june/epidemiology/infection/trajectory_maker.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
__init__(*, symptoms_tag, completion_time=ConstantCompletionTime)
A stage on an illness,
Parameters
symptoms_tag What symptoms does the person have at this stage? completion_time Function that returns value for how long this stage takes to complete.
Source code in june/epidemiology/infection/trajectory_maker.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
from_dict(stage_dict, dynamic_tags=None)
classmethod
Create a Stage instance from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stage_dict
|
dict
|
Dictionary containing stage information. |
required |
dynamic_tags
|
(dict, optional)
|
Mapping of symptom tag names to their integer values. (Default value = None) |
None
|
Returns:
Name | Type | Description |
---|---|---|
Stage |
|
Source code in june/epidemiology/infection/trajectory_maker.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
|
TrajectoryMaker
Source code in june/epidemiology/infection/trajectory_maker.py
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
most_severe_symptoms
property
The most severe symptoms experienced at any stage in this trajectory
__init__(*stages)
Generate trajectories of a particular kind.
This defines how a given person moves through a series of symptoms.
Parameters
stages A list of stages through which the person progresses
Source code in june/epidemiology/infection/trajectory_maker.py
200 201 202 203 204 205 206 207 208 209 210 211 |
|
from_dict(trajectory_dict, dynamic_tags=None)
classmethod
Create a TrajectoryMaker instance from a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trajectory_dict
|
dict
|
Dictionary containing trajectory information, including |
required |
dynamic_tags
|
(dict, optional)
|
Mapping of symptom tag names to their integer values. (Default value = None) |
None
|
Returns:
Name | Type | Description |
---|---|---|
TrajectoryMaker |
|
Source code in june/epidemiology/infection/trajectory_maker.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
generate_trajectory()
Generate a trajectory for a person. This is a list of tuples describing what symptoms the person should display at a given time.
Source code in june/epidemiology/infection/trajectory_maker.py
225 226 227 228 229 230 231 232 233 234 235 236 237 |
|
TrajectoryMakers
The various trajectories should depend on external data, and may depend on age & gender of the patient. This would lead to a table of tons of trajectories, with lots of mean values/deviations and an instruction on how to vary them. For this first simple implementation I will choose everything to be fixed (constant)
The trajectories will count "backwards" with zero time being the moment of infection.
Source code in june/epidemiology/infection/trajectory_maker.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|
__getitem__(tag)
Generate a trajectory from a tag.
It might be better to have this return the Trajectory class rather than generating the trajectory itself. I feel the getitem syntax disguises the fact that something new is being created.
I've removed the person (patient) argument because it was not being used. It can be passed to the generate_trajectory class.
Parameters
tag A tag describing the symptoms being experienced by a patient.
Returns
A list describing the symptoms experienced by the patient at given times.
Source code in june/epidemiology/infection/trajectory_maker.py
332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 |
|
__init__(trajectories)
Trajectories and their stages should be parsed from configuration. I've removed params for now as they weren't being used but it will be trivial to reintroduce them when we are ready for configurable trajectories.
Source code in june/epidemiology/infection/trajectory_maker.py
272 273 274 275 276 277 278 279 280 |
|
from_disease_config(disease_config)
classmethod
Load trajectories using a DiseaseConfig instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
disease_config
|
DiseaseConfig
|
The configuration object for the disease. |
required |
Returns:
Name | Type | Description |
---|---|---|
TrajectoryMakers |
TrajectoryMakers
|
|
Source code in june/epidemiology/infection/trajectory_maker.py
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
|
from_file(disease_name)
classmethod
Load trajectories from a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
disease_name
|
str
|
Name of the disease to load configurations for. |
required |
Returns:
Name | Type | Description |
---|---|---|
TrajectoryMakers |
TrajectoryMakers
|
|
Source code in june/epidemiology/infection/trajectory_maker.py
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
from_list(trajectory_dicts, dynamic_tags=None)
classmethod
Create a TrajectoryMakers instance from a list of trajectory dictionaries.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
trajectory_dicts
|
list of dict
|
List of dictionaries containing trajectory information. |
required |
dynamic_tags
|
(dict, optional)
|
Mapping of symptom tag names to their integer values. (Default value = None) |
None
|
Returns:
Name | Type | Description |
---|---|---|
TrajectoryMakers |
|
Source code in june/epidemiology/infection/trajectory_maker.py
356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|