-
Notifications
You must be signed in to change notification settings - Fork 224
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
Raise GMTInvalidInput exception when required z is missing #1478
Raise GMTInvalidInput exception when required z is missing #1478
Conversation
Where should I add tests for not providing the |
I think the test should go in |
I added the test. If we decide to go the route of |
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.
I recommend adding required_z
to the appropriate functions in this PR.
It would be good to raise the same exception if the data kind is matrix
(L78) and data.shape[1] < 3
when required_z
is set. Would you be able to add this to the PR and add another pytest.raises(GMTInvalidInput)
check to the new test?
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
/format |
I am making a list of functions that should pass
|
Should we remove the tests of the relevant functions that test the passing of pygmt/pygmt/tests/test_contour.py Lines 42 to 56 in cd822ca
if so we shuld extend the test to be similar to the above. |
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.
Nice work, thank you! 🎉
As you have seen, we leave approved pull requests up for at least a day so other maintainers have a final opportunity to check it out. In the meantime, please apply the two minor grammatical suggestions.
Co-authored-by: Meghan Jones <meghanj@alum.mit.edu>
Actually, when writing the test for the case of a 2d array data with less than three columns when z is required, I noticed that we do not check that 2d array data have at least 2 columns in the general case, should we raise an error if a 2d matrix of a shape |
It's more complicated, because for some modules (e.g., |
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
I think this PR is good for merge and we can deal with the 2-column data check in another issue/PR. |
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.
I agree with @seisman that more changes aren't needed. Great work, thanks!
@@ -78,6 +80,8 @@ def data_kind(data, x=None, y=None, z=None): | |||
elif hasattr(data, "__geo_interface__"): | |||
kind = "geojson" | |||
elif data is not None: | |||
if required_z and data.shape[1] < 3: |
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.
Checking for data.shape[1]
fails for xarray.Dataset inputs with AttributeError: 'Dataset' object has no attribute 'shape'
. The shape
attribute is valid only for numpy.ndarray
, pandas.DataFrame
, and maybe a few other PyData objects. Will need to create a bugfix and add some extra tests for xarray.Dataset
inputs.
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.
I can submit a PR fix since I think that I suggested this. But I feel that we should not label it as a bug since this code has not yet been included in a release, so it might be confusing to list on the changelog as a bugfix relative to v0.4.1.
Edit: Just noticed the comment on the other PR that @weiji14 would fix this. That's also fine.
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.
Ok, I've submitted a bugfix PR at #1523. Have put on the skip-changelog
label so it won't show up in the changelog :)
…ppingTools#1478) Co-authored-by: Meghan Jones <meghanj@alum.mit.edu> Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
adding an additional if statement to the data_kind utils function that is based on a new parameter
requierd_z
and checks if z vector is provided alongside x and y.Fixes #1447
Reminders
make format
andmake check
to make sure the code follows the style guide.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version