Skip to content

Commit

Permalink
remove prange and give pathway to feed regions in
Browse files Browse the repository at this point in the history
  • Loading branch information
MaceKuailv committed Mar 17, 2024
1 parent f1dc0d1 commit ee98296
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
5 changes: 3 additions & 2 deletions seaduck/lagrangian.py
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,7 @@ def to_list_of_time(
update_stops="default",
return_in_between=True,
dump_filename=False,
store_kwarg={},
):
"""Integrate the particles to a list of time.
Expand Down Expand Up @@ -881,12 +882,12 @@ def to_list_of_time(
self.get_u_du()
if return_in_between:
if dump_filename:
store_lists(self, dump_filename + timestr)
store_lists(self, dump_filename + timestr, **store_kwarg)

Check warning on line 885 in seaduck/lagrangian.py

View check run for this annotation

Codecov / codecov/patch

seaduck/lagrangian.py#L885

Added line #L885 was not covered by tests
else:
to_return.append(self.deepcopy())
else:
if dump_filename:
store_lists(self, dump_filename + timestr)
store_lists(self, dump_filename + timestr, **store_kwarg)

Check warning on line 890 in seaduck/lagrangian.py

View check run for this annotation

Codecov / codecov/patch

seaduck/lagrangian.py#L890

Added line #L890 was not covered by tests
else:
to_return.append(self.deepcopy())
if self.save_raw:
Expand Down
9 changes: 0 additions & 9 deletions seaduck/runtime_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
}

try: # pragma: no cover
import numba
from numba import njit

rcParam["compilable"] = True
Expand All @@ -26,11 +25,3 @@ def compileable_parallel(func): # pragma: no cover
return njit(func, parallel=True)
else:
return func


def prange(*arg): # pragma: no cover
"""Decorate function to compile them (parallel) using numba when available."""
if rcParam["compilable"]:
return numba.prange(*arg)
else:
return range(*arg)
6 changes: 3 additions & 3 deletions seaduck/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import xarray as xr
from scipy import spatial

from seaduck.runtime_conf import compileable, compileable_parallel, prange
from seaduck.runtime_conf import compileable, compileable_parallel

try:
import pooch
Expand Down Expand Up @@ -726,7 +726,7 @@ def pointinpolygon(x, y, poly):
p2y = 0.0
xints = 0.0
p1x, p1y = poly[0]
for i in prange(n + 1):
for i in range(n + 1):
p2x, p2y = poly[i % n]
if y > min(p1y, p2y):
if y <= max(p1y, p2y):
Expand All @@ -743,7 +743,7 @@ def pointinpolygon(x, y, poly):
@compileable_parallel
def parallelpointinpolygon(xs, ys, poly):
D = np.empty(len(xs), dtype=bool)
for i in prange(0, len(D)):
for i in range(0, len(D)):
D[i] = pointinpolygon(xs[i], ys[i], poly)
return D

Expand Down

0 comments on commit ee98296

Please sign in to comment.