Skip to content

Commit fa7f543

Browse files
committed
Added several 'int's in grid.py to prevent slices with floats.
This threw an error for me.
1 parent e2289fa commit fa7f543

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/py_eddy_tracker/dataset/grid.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ def bbox_indice(self, vertices):
618618
dist, idx = self.index_interp.query(vertices, k=1)
619619
i_y = idx % self.x_c.shape[1]
620620
i_x = int_((idx - i_y) / self.x_c.shape[1])
621-
return slice(i_x.min() - self.N, i_x.max() + self.N + 1), slice(i_y.min() - self.N, i_y.max() + self.N + 1)
621+
return slice(int(i_x.min() - self.N), int(i_x.max() + self.N + 1)), slice(int(i_y.min() - self.N), int(i_y.max() + self.N + 1))
622622

623623
def get_pixels_in(self, contour):
624624
slice_x, slice_y = self.bbox_indice(contour.vertices)
@@ -628,13 +628,13 @@ def get_pixels_in(self, contour):
628628
i_x, i_y = where(mask)
629629
i_x += slice_x.start
630630
i_y += slice_y.start
631-
return i_x, i_y
631+
return int(i_x), int(i_y)
632632

633633
def nearest_grd_indice(self, x, y):
634634
dist, idx = self.index_interp.query((x, y), k=1)
635635
i_y = idx % self.x_c.shape[1]
636636
i_x = int_((idx - i_y) / self.x_c.shape[1])
637-
return i_x, i_y
637+
return int(i_x), int(i_y)
638638

639639
def compute_pixel_path(self, x0, y0, x1, y1):
640640
pass
@@ -719,8 +719,8 @@ def bbox_indice(self, vertices):
719719
lat_min, lat_max = lat.min(), lat.max()
720720
i_x0, i_y0 = self.nearest_grd_indice(lon_min, lat_min)
721721
i_x1, i_y1 = self.nearest_grd_indice(lon_max, lat_max)
722-
slice_x = slice(i_x0 - self.N, i_x1 + self.N + 1)
723-
slice_y = slice(i_y0 - self.N, i_y1 + self.N + 1)
722+
slice_x = slice(int(i_x0 - self.N), int(i_x1 + self.N + 1))
723+
slice_y = slice(int(i_y0 - self.N), int(i_y1 + self.N + 1))
724724
return slice_x, slice_y
725725

726726
def get_pixels_in(self, contour):

0 commit comments

Comments
 (0)