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

Raise specific error if no spacing nor shape is passed to rolling window #278

Closed
santisoler opened this issue Aug 3, 2020 · 0 comments · Fixed by #280
Closed

Raise specific error if no spacing nor shape is passed to rolling window #278

santisoler opened this issue Aug 3, 2020 · 0 comments · Fixed by #280
Labels
enhancement Idea or request for a new feature good first issue Good for newcomers (doesn’t require deep knowledge of the project)

Comments

@santisoler
Copy link
Member

Description of the desired feature

The verde.rolling_window function has two positional arguments: coordinates and size, but it also needs one of the spacing or shape default arguments, which are set to None by default.
If by accident, the user doesn't pass either one of them (never happened to me 🙄), they get a very strange error:

import verde as vd

coordinates = vd.grid_coordinates(region=(-10e3, 10e3, -10e3, 10e3), shape=(30, 30))
vd.rolling_window(coordinates, size=10e3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/santi/git/verde/verde/coordinates.py", line 1027, in rolling_window
    _check_rolling_window_overlap(window_region, size, shape, spacing)
  File "/home/santi/git/verde/verde/coordinates.py", line 1069, in _check_rolling_window_overlap
    if np.any(spacing > size):
TypeError: '>' not supported between instances of 'NoneType' and 'float'

Would be nice to check if one of them is not None, and raise an error otherwise, like vd.block_split does:

vd.block_split(coordinates)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/santi/git/verde/verde/coordinates.py", line 803, in block_split
    region, spacing=spacing, shape=shape, adjust=adjust, pixel_register=True
  File "/home/santi/git/verde/verde/coordinates.py", line 427, in grid_coordinates
    raise ValueError("Either a grid shape or a spacing must be provided.")
ValueError: Either a grid shape or a spacing must be provided.

Are you willing to help implement and maintain this feature? Yes

@santisoler santisoler added enhancement Idea or request for a new feature good first issue Good for newcomers (doesn’t require deep knowledge of the project) help wanted labels Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Idea or request for a new feature good first issue Good for newcomers (doesn’t require deep knowledge of the project)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant