Improve weather data handling#198
Draft
kabarmaz wants to merge 4 commits into
Draft
Conversation
….py. Added Cache class in ship.py which handles the lookup table.
kdemmich
reviewed
Jun 10, 2026
| self._cache[key] = value | ||
| self._order.append(key) | ||
| # evict oldest if necessary | ||
| while len(self._order) > self.max_entries: |
Collaborator
There was a problem hiding this comment.
Please drop the while, as every time the function is called only one entry needs to be deleted.
kdemmich
reviewed
Jun 10, 2026
| if max_entries <= 0: | ||
| raise ValueError("max_entries must be > 0") | ||
| self.max_entries = int(max_entries) | ||
| self._cache = dict() |
Collaborator
There was a problem hiding this comment.
Please check whether the deletion of self._order and the replacement of self._cache by an OrderedDict increases the run-time performance. You can then use the command 'popitem(last=False)' to delete the first entry of _order.
kdemmich
reviewed
Jun 10, 2026
|
|
||
| def cached_lookup(var_key, da, lat, lon, t, height=None, depth=None): | ||
| key = ( | ||
| var_key, |
Collaborator
There was a problem hiding this comment.
Please convert the latitude, longitude and time values into indices and use these as keys to refer to the data in the lookup table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue / Discussion:
Issue #13
Changes:
Please list the central functionalities that have been changed:
Further Details:
Summary:
Please mention the relevant motivation and context of your changes and shortly describe the behaviour before and after your modifications.
Dependencies:
Please list new dependencies that are required for this modification.
PR Checklist:
In the context of this PR, I:
Please consider that PRs which do not meet the requirements specified in the checklist will not be evaluated. Also, PRs with no activities will be closed after a reasonable amount of time.