From a9b96b96c5a1af6768259bebf2f9fc786c59603d Mon Sep 17 00:00:00 2001 From: Vecko <36369090+VeckoTheGecko@users.noreply.github.com> Date: Wed, 23 Oct 2024 17:25:02 +0200 Subject: [PATCH] refactor cleanup_remove_files contributes to #1620 --- parcels/kernel.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/parcels/kernel.py b/parcels/kernel.py index d21592716..0d9cf4401 100644 --- a/parcels/kernel.py +++ b/parcels/kernel.py @@ -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) @staticmethod def cleanup_unload_lib(lib): @@ -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") if not g.depth.flags.c_contiguous: g._depth = np.array(g.depth, order="C") if not g.lon.flags.c_contiguous: