-
Notifications
You must be signed in to change notification settings - Fork 228
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
Session.virtualfile_in: Deprecate the parameter 'extra_arrays. Prepare and pass a dictionary of arrays instead (will be removed in v0.20.0) #3823
Open
seisman
wants to merge
14
commits into
main
Choose a base branch
from
refactor/virtualfile_in_extra_arrays
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
df88e02
Figure.plot/plot3d/text: Pass a dict of vectors rather than x/y/extra…
seisman ce57c59
Check if a dict of vectors contain None
seisman 2cb9295
clib.virtualfile_in: Remove the 'extra_arrays' parameter
seisman 362e5bd
Figure.plot3d: Add one more test to increase code coverage
seisman 8f72e4c
Clarify that dictionary will be recognized as vectors
seisman f017adb
Merge branch 'main' into refactor/virtualfile_in_extra_arrays
seisman c199dbf
Clarify that the data parameter can accept dicts
seisman 07924ca
Merge branch 'main' into refactor/virtualfile_in_extra_arrays
seisman 1d0d0dc
Fix a typo
seisman a7ee253
Merge branch 'main' into refactor/virtualfile_in_extra_arrays
seisman 5cd8275
Merge branch 'main' into refactor/virtualfile_in_extra_arrays
seisman e44e712
Improve docstrings for the new test
seisman 5330d0a
Raise warnings when extra_arrays is used
seisman 0a63ef0
Add TODO comments
seisman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ | |
import time | ||
import webbrowser | ||
from collections.abc import Iterable, Mapping, Sequence | ||
from itertools import islice | ||
from pathlib import Path | ||
from typing import Any, Literal | ||
|
||
|
@@ -41,7 +42,7 @@ | |
] | ||
|
||
|
||
def _validate_data_input( | ||
def _validate_data_input( # noqa: PLR0912 | ||
data=None, x=None, y=None, z=None, required_z=False, required_data=True, kind=None | ||
) -> None: | ||
""" | ||
|
@@ -143,6 +144,15 @@ def _validate_data_input( | |
raise GMTInvalidInput(msg) | ||
if hasattr(data, "data_vars") and len(data.data_vars) < 3: # xr.Dataset | ||
raise GMTInvalidInput(msg) | ||
if kind == "vectors" and isinstance(data, dict): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please note that, these new codes in |
||
# Iterator over the up-to-3 first elements. | ||
arrays = list(islice(data.values(), 3)) | ||
if len(arrays) < 2 or any(v is None for v in arrays[:2]): # Check x/y | ||
msg = "Must provide x and y." | ||
raise GMTInvalidInput(msg) | ||
if required_z and (len(arrays) < 3 or arrays[2] is None): # Check z | ||
msg = "Must provide x, y, and z." | ||
raise GMTInvalidInput(msg) | ||
|
||
|
||
def _is_printable_ascii(argstr: str) -> bool: | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to break compatibility of
virtualfile_in
for 4 minor versions, maybe it's a good time to rethink the parameter ordering (ties in with potential changes in #3369). Would it make sense for the signature to be something like:? We could also mark some of those parameters as keyword only (https://peps.python.org/pep-0570/#keyword-only-arguments) to ensure future compatibility (i.e. prevent positional-only parameters/arguments in case we decide to change the order again).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see #3836 for my thoughts on the
Session.virtualfile_in
method.