Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactors and bugfixes #1736

Merged
merged 13 commits into from
Oct 28, 2024
Merged

Refactors and bugfixes #1736

merged 13 commits into from
Oct 28, 2024

Conversation

VeckoTheGecko
Copy link
Contributor

@VeckoTheGecko VeckoTheGecko commented Oct 22, 2024

  • timedelta_to_float helper
  • patch raise statements
  • update var names to align with conventions
  • type annotations
  • Parcels cleanup #1620 related cleanups

@VeckoTheGecko
Copy link
Contributor Author

Wanting to wrap some more refactorings into here

@VeckoTheGecko VeckoTheGecko marked this pull request as draft October 22, 2024 11:31
@VeckoTheGecko VeckoTheGecko removed the request for review from erikvansebille October 22, 2024 12:58
@VeckoTheGecko VeckoTheGecko marked this pull request as ready for review October 23, 2024 15:33
@VeckoTheGecko
Copy link
Contributor Author

I didn't fix the #1738 into this. I wanted to do a bit of a deeper refactoring of .reltime and the TimeConverter class in general, but was running into some roadblocks

Comment on lines -565 to +568
[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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we need to check for os.path is not None here anymore? Was that old, redundant code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

os.path is a module of the os package, so it is never None.
A bit ago we had

from os import path

...
[... if path is not None ...]

so it wasn't imediately evident before

Comment on lines 604 to 605
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the if-statement not necessary anymore, here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was a mistake. Was doing some experimenting which slipped through

@@ -56,3 +59,13 @@ def deprecated_made_private(func: Callable) -> Callable:

def patch_docstring(obj: Callable, extra: str) -> None:
obj.__doc__ = f"{obj.__doc__ or ''}{extra}".strip()


@np.vectorize
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to vectorise this function? Is it really so compute-intense?
Or is this a start of more of these decorators?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. This decorator is an easy way to make functions numpy compatible, so that you can give it an array and it can apply to each element.

I was initially using this function in TimeConverter.reltime, however since removed it from this PR. Will remove this decorator for now until it is actually needed.

Re. performance, I don't think theres any drawbacks

Align with convention, avoid shadowing builtins
patch time=None particlefile.write
Fixes #1737

remove xfail test flag (fixes #1737)
contributes to #1620
Postpone typing to a future refactoring (particularly for reltime)
@VeckoTheGecko VeckoTheGecko merged commit 71629ad into master Oct 28, 2024
14 checks passed
@VeckoTheGecko VeckoTheGecko deleted the v/ref-checkpoint branch October 28, 2024 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants