Skip to content

Commit

Permalink
raise ValueError when resolution negative
Browse files Browse the repository at this point in the history
more informative error than the previous numpy error
  • Loading branch information
njwilson23 committed Feb 4, 2017
1 parent 7208c38 commit ca7c4e5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions karta/raster/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,10 @@ def resample(self, dx, dy, method='nearest'):
method : str, optional
interpolation method, currently 'nearest' and 'linear' supported
"""
if dx <= 0 or dy <= 0:
raise ValueError("resolution must be positive "
"(got {0}, {1})".format(dx, dy))

xmin, xmax, ymin, ymax = self.get_extent()
if method == 'nearest':
X, Y = np.meshgrid(np.arange(xmin, xmax, dx),
Expand Down

0 comments on commit ca7c4e5

Please sign in to comment.