@@ -18,40 +18,32 @@ class AaEModel(Model):
1818
1919 Implementation of the Model for Accident and Emergency attendances.
2020
21- :param params: the parameters to run the model with, or the path to a params file to load
22- :type params: dict or string
23- :param data: a Data class ready to be constructed
24- :type data: Data
25- :param hsa: An instance of the HealthStatusAdjustment class. If left as None an instance is
26- created
27- :type hsa: HealthStatusAdjustment, optional
28- :param run_params: the parameters to use for each model run. generated automatically if left as
29- None
30- :type run_params: dict
31- :param save_full_model_results: whether to save the full model results or not
32- :type save_full_model_results: bool, optional
21+ Args:
22+ params: The parameters to run the model with, or the path to a params file to load.
23+ data: A callable that creates a Data instance.
24+ hsa: An instance of the HealthStatusAdjustment class. If left as None an instance is
25+ created. Defaults to None.
26+ run_params: The parameters to use for each model run. Generated automatically if left as
27+ None. Defaults to None.
28+ save_full_model_results: Whether to save the full model results or not. Defaults to False.
3329 """
3430
3531 def __init__ (
3632 self ,
37- params : dict ,
33+ params : dict | str ,
3834 data : Callable [[int , str ], Data ],
3935 hsa : Any = None ,
4036 run_params : dict | None = None ,
4137 save_full_model_results : bool = False ,
4238 ) -> None :
4339 """Initialise the A&E Model.
4440
45- :param params: the parameters to use
46- :type params: dict
47- :param data: a method to create a Data instance
48- :type data: Callable[[int, str], Data]
49- :param hsa: _Health Status Adjustment object, defaults to None
50- :type hsa: Any, optional
51- :param run_params: the run parameters to use, defaults to None
52- :type run_params: dict | None, optional
53- :param save_full_model_results: whether to save full model results, defaults to False
54- :type save_full_model_results: bool, optional
41+ Args:
42+ params: The parameters to use.
43+ data: A method to create a Data instance.
44+ hsa: Health Status Adjustment object. Defaults to None.
45+ run_params: The run parameters to use. Defaults to None.
46+ save_full_model_results: Whether to save full model results. Defaults to False.
5547 """
5648 # call the parent init function
5749 super ().__init__ (
@@ -70,10 +62,11 @@ def _get_data(self, data_loader: Data) -> pd.DataFrame:
7062 def get_data_counts (self , data : pd .DataFrame ) -> np .ndarray :
7163 """Get row counts of data.
7264
73- :param data: the data to get the counts of
74- :type data: pd.DataFrame
75- :return: the counts of the data, required for activity avoidance steps
76- :rtype: np.ndarray
65+ Args:
66+ data: The data to get the counts of.
67+
68+ Returns:
69+ The counts of the data, required for activity avoidance steps.
7770 """
7871 return np .array ([data ["arrivals" ]]).astype (float )
7972
@@ -99,15 +92,15 @@ def _load_strategies(self, data_loader: Data) -> None:
9992 def apply_resampling (self , row_samples : np .ndarray , data : pd .DataFrame ) -> pd .DataFrame :
10093 """Apply row resampling.
10194
102- Called from within `model.activity_resampling.ActivityResampling.apply_resampling`
95+ Called from within `model.activity_resampling.ActivityResampling.apply_resampling`.
96+
97+ Args:
98+ row_samples: [1xn] array, where n is the number of rows in `data`, containing the new
99+ values for `data["arrivals"]`.
100+ data: The data that we want to update.
103101
104- :param row_samples: [1xn] array, where n is the number of rows in `data`, containing the new
105- values for `data["arrivals"]`
106- :type row_samples: np.ndarray
107- :param data: the data that we want to update
108- :type data: pd.DataFrame
109- :return: the updated data
110- :rtype: pd.DataFrame
102+ Returns:
103+ The updated data.
111104 """
112105 data ["arrivals" ] = row_samples [0 ]
113106 # return the altered data
@@ -118,18 +111,25 @@ def efficiencies(
118111 ) -> tuple [pd .DataFrame , pd .DataFrame | None ]:
119112 """Run the efficiencies steps of the model.
120113
121- :param model_iteration: an instance of the ModelIteration class
122- :type model_iteration: model.model_iteration.ModelIteration
114+ Args:
115+ data: The data to apply efficiencies to.
116+ model_iteration: An instance of the ModelIteration class.
117+
118+ Returns:
119+ Tuple containing the updated data and step counts (None for A&E).
123120 """
124121 # A&E doesn't have any efficiencies steps
125122 return data , None
126123
127124 @staticmethod
128125 def process_results (data : pd .DataFrame ) -> pd .DataFrame :
129- """Processes the data into a format suitable for aggregation in results files.
126+ """Process the data into a format suitable for aggregation in results files.
130127
131- :param data: Data to be processed. Format should be similar to Model.data
132- :type data: pd.DataFrame
128+ Args:
129+ data: Data to be processed. Format should be similar to Model.data.
130+
131+ Returns:
132+ Processed results.
133133 """
134134 data ["measure" ] = "walk-in"
135135 data .loc [data ["is_ambulance" ], "measure" ] = "ambulance"
@@ -161,10 +161,11 @@ def process_results(data: pd.DataFrame) -> pd.DataFrame:
161161 def specific_aggregations (self , model_results : pd .DataFrame ) -> dict [str , pd .Series ]:
162162 """Create other aggregations specific to the model type.
163163
164- :param model_results: the results of a model run
165- :type model_results: pd.DataFrame
166- :return: dictionary containing the specific aggregations
167- :rtype: dict[str, pd.Series]
164+ Args:
165+ model_results: The results of a model run.
166+
167+ Returns:
168+ Dictionary containing the specific aggregations.
168169 """
169170 return {
170171 "acuity" : self .get_agg (model_results , "acuity" ),
@@ -176,10 +177,12 @@ def calculate_avoided_activity(
176177 ) -> pd .DataFrame :
177178 """Calculate the rows that have been avoided.
178179
179- :param data: The data before the binomial thinning step
180- :type data: pd.DataFrame
181- :return: The data that was avoided in the binomial thinning step
182- :rtype: pd.DataFrame
180+ Args:
181+ data: The data before the binomial thinning step.
182+ data_resampled: The data after the binomial thinning step.
183+
184+ Returns:
185+ The data that was avoided in the binomial thinning step.
183186 """
184187 avoided = data ["arrivals" ] - data_resampled ["arrivals" ]
185188 data ["arrivals" ] = avoided
@@ -192,10 +195,9 @@ def save_results(self, model_iteration: ModelIteration, path_fn: Callable[[str],
192195 It saves just the `rn` (row number) column and the `arrivals`, with the intention that
193196 you rejoin to the original data.
194197
195- :param model_iteration: an instance of the `ModelIteration` class
196- :type model_iteration: model.model_iteration.ModelIteration
197- :param path_fn: a function which takes the activity type and returns a path
198- :type path_fn: Callable[[str], str]
198+ Args:
199+ model_iteration: An instance of the ModelIteration class.
200+ path_fn: A function which takes the activity type and returns a path.
199201 """
200202 model_iteration .get_model_results ().set_index (["rn" ])[["arrivals" ]].to_parquet (
201203 f"{ path_fn ('aae' )} /0.parquet"
0 commit comments