-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from TomMonks/dev
v0.5.0
- Loading branch information
Showing
12 changed files
with
3,141 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
period,arrival_rate | ||
6AM-7AM,2.36666666666667 | ||
7AM-8AM,2.8 | ||
8AM-9AM,8.83333333333333 | ||
9AM-10AM,10.4333333333333 | ||
10AM-11AM,14.8 | ||
11AM-12PM,26.2666666666667 | ||
12PM-1PM,31.4 | ||
1PM-2PM,18.0666666666667 | ||
2PM-3PM,16.4666666666667 | ||
3PM-4PM,12.0333333333333 | ||
4PM-5PM,11.6 | ||
5PM-6PM,28.8666666666667 | ||
6PM-7PM,18.0333333333333 | ||
7PM-8PM,11.5 | ||
8PM-9PM,5.3 | ||
9PM-10PM,4.06666666666667 | ||
10PM-11PM,2.2 | ||
11PM-12AM,2.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Mean waiting time (mins) | ||
Triage | ||
Registation | ||
Examination | ||
Non-trauma treatment | ||
Trauma stabilisation | ||
Trauma treatment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
\begin{table} | ||
\tbl{Simulation results that can be verified by our example reproducible pipeline.} | ||
\label{tab:table3} | ||
\begin{tabular}{lrrrrr} | ||
\toprule | ||
Mean waiting time (mins) & base & triage+1 & exam+1 & treat+1 & triage+exam \\ | ||
\midrule | ||
Triage & 32.560000 & 1.260000 & 32.560000 & 32.560000 & 1.260000 \\ | ||
Registation & 104.690000 & 131.820000 & 104.690000 & 104.690000 & 131.820000 \\ | ||
Examination & 23.360000 & 24.440000 & 0.140000 & 23.360000 & 0.140000 \\ | ||
Non-trauma treatment & 130.730000 & 133.090000 & 144.500000 & 2.150000 & 147.810000 \\ | ||
Trauma stabilisation & 166.980000 & 189.670000 & 166.980000 & 166.980000 & 189.670000 \\ | ||
Trauma treatment & 14.390000 & 14.770000 & 14.390000 & 14.390000 & 14.770000 \\ | ||
\bottomrule | ||
\end{tabular} | ||
\end{table} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
__version__ = '0.4.0' | ||
__version__ = '0.5.0' | ||
__author__ = 'Thomas Monks' | ||
|
||
from . import datasets, distributions, time_dependent, ovs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
""" | ||
Simple functionality aiming to enhanced a users a | ||
ability to trace and debug simulation models. | ||
""" | ||
|
||
from abc import ABC | ||
from rich.console import Console | ||
|
||
DEFAULT_DEBUG = False | ||
|
||
CONFIG_ERROR = ("Your trace has not been initialised. " | ||
"Call super__init__(debug=True) in class initialiser" | ||
"or omit debug for default of no trace.") | ||
|
||
|
||
## single rich console - module level. | ||
_console = Console() | ||
|
||
class Traceable(ABC): | ||
'''Provides basic trace functionality for a process to subclass | ||
Abstract base class Traceable | ||
Subclasses must call | ||
super().__init__(debug=True) in their __init__() method to | ||
initialise trace. | ||
Subclasses inherit the following methods: | ||
trace() - use this function print out a traceable event | ||
_trace_config(): use this function to return a dict containing | ||
the trace configuration for the class. | ||
''' | ||
def __init__(self, debug=DEFAULT_DEBUG): | ||
self.debug = debug | ||
self._config = self._default_config() | ||
|
||
def _default_config(self): | ||
"""Returns a default trace configuration""" | ||
config = { | ||
"name":None, | ||
"name_colour":"bold blue", | ||
"time_colour":'bold blue', | ||
"time_dp":2, | ||
"message_colour":'black', | ||
"tracked":None | ||
} | ||
return config | ||
|
||
|
||
def _trace_config(self): | ||
config = { | ||
"name":None, | ||
"name_colour":"bold blue", | ||
"time_colour":'bold blue', | ||
"time_dp":2, | ||
"message_colour":'black', | ||
"tracked":None | ||
} | ||
return config | ||
|
||
|
||
def trace(self, time, msg=None, process_id=None): | ||
''' | ||
Display a trace of an event | ||
''' | ||
|
||
if not hasattr(self, '_config'): | ||
raise AttributeError(CONFIG_ERROR) | ||
|
||
# if in debug mode | ||
if self.debug: | ||
|
||
# check for override to default configs | ||
process_config = self._trace_config() | ||
self._config.update(process_config) | ||
|
||
# conditional logic to limit tracking to specific processes/entities | ||
if self._config['tracked'] is None or process_id in self._config['tracked']: | ||
|
||
# display and format time stamp | ||
out = f"[{self._config['time_colour']}][{time:.{self._config['time_dp']}f}]:[/{self._config['time_colour']}]" | ||
|
||
# if provided display and format a process ID | ||
if self._config['name'] is not None and process_id is not None: | ||
out += f"[{self._config['name_colour']}]<{self._config['name']} {process_id}>: [/{self._config['name_colour']}]" | ||
|
||
# format traced event message | ||
out += f"[{self._config['message_colour']}]{msg}[/{self._config['message_colour']}]" | ||
|
||
# print to rich console | ||
_console.print(out) | ||
|