Skip to content

Commit 31a6a37

Browse files
Moving ErrorsToThrow to module level constant
1 parent 6da3dc0 commit 31a6a37

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

parcels/kernel.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@
3030
__all__ = ["Kernel"]
3131

3232

33+
ErrorsToThrow = {
34+
StatusCode.ErrorTimeExtrapolation: _raise_time_extrapolation_error,
35+
StatusCode.ErrorOutOfBounds: _raise_field_out_of_bound_error,
36+
StatusCode.ErrorThroughSurface: _raise_field_out_of_bound_surface_error,
37+
StatusCode.ErrorInterpolation: _raise_field_interpolation_error,
38+
StatusCode.ErrorGridSearching: _raise_grid_searching_error,
39+
StatusCode.Error: _raise_general_error,
40+
}
41+
42+
3343
class Kernel:
3444
"""Kernel object that encapsulates auto-generated code.
3545
@@ -272,16 +282,7 @@ def execute(self, pset, endtime, dt):
272282
if np.any(pset.state == StatusCode.StopAllExecution):
273283
return StatusCode.StopAllExecution
274284

275-
errors_to_throw = {
276-
StatusCode.ErrorTimeExtrapolation: _raise_time_extrapolation_error,
277-
StatusCode.ErrorOutOfBounds: _raise_field_out_of_bound_error,
278-
StatusCode.ErrorThroughSurface: _raise_field_out_of_bound_surface_error,
279-
StatusCode.ErrorInterpolation: _raise_field_interpolation_error,
280-
StatusCode.ErrorGridSearching: _raise_grid_searching_error,
281-
StatusCode.Error: _raise_general_error,
282-
}
283-
284-
for error_code, error_func in errors_to_throw.items():
285+
for error_code, error_func in ErrorsToThrow.items():
285286
if np.any(pset.state == error_code):
286287
inds = pset.state == error_code
287288
if error_code == StatusCode.ErrorTimeExtrapolation:

0 commit comments

Comments
 (0)