improve robustness of pcolor_grid creation
@@ -29,8 +29,10 @@ import numpy as np
def pcolormesh_grid(x, y, grid_resolution=None):
if grid_resolution is None:
- grid_resolution = x[1] - x[0]
- assert grid_resolution == y[1] - y[0]
+ diffs = np.hstack([np.diff(x), np.diff(y)])
+ assert np.all(np.abs(diffs - diffs[0]) < 10**-12)
+
+ grid_resolution = diffs[0]
new_x = np.concatenate(
[x - grid_resolution/2, [x[-1] + grid_resolution/2]])
