Skip to content

Commit

Permalink
numpy 1.10+ linspace nan fix (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjlittle authored and marqh committed Oct 19, 2016
1 parent d20e2d1 commit c6ed547
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/cartopy/img_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ def mesh_projection(projection, nx, ny,
y, ystep = np.linspace(y_lower, y_upper, ny, retstep=True,
endpoint=False)

# Deal with single point corner case and the difference
# between np.linspace v1.9 and v1.10+ retstep nan result.
if nx == 1 and np.isnan(xstep):
xstep = x_upper - x_lower

if ny == 1 and np.isnan(ystep):
ystep = y_upper - y_lower

# Offset the sample points to be within the extent range.
x += 0.5 * xstep
y += 0.5 * ystep
Expand Down

0 comments on commit c6ed547

Please sign in to comment.