Skip to content

Commit

Permalink
refactor cleanup_remove_files
Browse files Browse the repository at this point in the history
contributes to #1620
  • Loading branch information
VeckoTheGecko committed Oct 23, 2024
1 parent 7ae8bb7 commit a9b96b9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions parcels/kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,9 +561,11 @@ def from_list(cls, fieldset, ptype, pyfunc_list, *args, **kwargs):
def cleanup_remove_files(lib_file, all_files_array, delete_cfiles):
if lib_file is not None:
if os.path.isfile(lib_file): # and delete_cfiles
[os.remove(s) for s in [lib_file] if os.path is not None and os.path.exists(s)]
if delete_cfiles and len(all_files_array) > 0:
[os.remove(s) for s in all_files_array if os.path is not None and os.path.exists(s)]
os.remove(lib_file)
if delete_cfiles:
for s in all_files_array:
if os.path.exists(s):
os.remove(s)

Check warning on line 568 in parcels/kernel.py

View check run for this annotation

Codecov / codecov/patch

parcels/kernel.py#L564-L568

Added lines #L564 - L568 were not covered by tests

@staticmethod
def cleanup_unload_lib(lib):
Expand Down Expand Up @@ -600,8 +602,7 @@ def load_fieldset_jit(self, pset):
g._load_chunk == g._chunk_loading_requested, g._chunk_loaded_touched, g._load_chunk
)
if len(g._load_chunk) > g._chunk_not_loaded: # not the case if a field in not called in the kernel
if not g._load_chunk.flags["C_CONTIGUOUS"]:
g._load_chunk = np.array(g._load_chunk, order="C")
g._load_chunk = np.array(g._load_chunk, order="C")

Check warning on line 605 in parcels/kernel.py

View check run for this annotation

Codecov / codecov/patch

parcels/kernel.py#L605

Added line #L605 was not covered by tests
if not g.depth.flags.c_contiguous:
g._depth = np.array(g.depth, order="C")
if not g.lon.flags.c_contiguous:
Expand Down

0 comments on commit a9b96b9

Please sign in to comment.