File tree 3 files changed +10
-10
lines changed
3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -585,7 +585,7 @@ def _run_cupy_jenks_matrices(data, n_classes):
585
585
nl = data .shape [0 ] + 1
586
586
variance = 0.0
587
587
588
- for l in range (2 , nl ): # noqa
588
+ for l in range (2 , nl ): # noqa
589
589
sum = 0.0
590
590
sum_squares = 0.0
591
591
w = 0.0
Original file line number Diff line number Diff line change @@ -129,6 +129,12 @@ def validate_arrays(*arrays):
129
129
if not isinstance (first_array .data , type (arrays [i ].data )):
130
130
raise ValueError ("input arrays must have same type" )
131
131
132
+ # ensure dask chunksizes of all arrays are the same
133
+ if isinstance (first_array .data , da .Array ):
134
+ for i in range (1 , len (arrays )):
135
+ if first_array .chunks != arrays [i ].chunks :
136
+ arrays [i ].data = arrays [i ].data .rechunk (first_array .chunks )
137
+
132
138
133
139
def get_xy_range (raster , xdim = None , ydim = None ):
134
140
"""
Original file line number Diff line number Diff line change 10
10
import dask .dataframe as dd
11
11
from dask import delayed
12
12
13
- from xrspatial .utils import ngjit
13
+ from xrspatial .utils import ngjit , validate_arrays
14
14
15
15
16
16
def _stats_count (data ):
@@ -472,14 +472,13 @@ def stats(
472
472
3 30 3850
473
473
"""
474
474
475
- if zones .shape != values .shape :
476
- raise ValueError ("`zones` and `values` must have same shape." )
475
+ validate_arrays (zones , values )
477
476
478
477
if not (
479
478
issubclass (zones .data .dtype .type , np .integer )
480
479
or issubclass (zones .data .dtype .type , np .floating )
481
480
):
482
- raise ValueError ("`zones` must be an array of integers." )
481
+ raise ValueError ("`zones` must be an array of integers or floats ." )
483
482
484
483
if not (
485
484
issubclass (values .data .dtype .type , np .integer )
@@ -521,11 +520,6 @@ def stats(
521
520
)
522
521
else :
523
522
# dask case
524
-
525
- # make sure chunksizes of `zones` and `values` are matching
526
- if zones .chunks != values .chunks :
527
- values .data = values .data .rechunk (zones .chunks )
528
-
529
523
stats_df = _stats_dask_numpy (
530
524
zones .data ,
531
525
values .data ,
You can’t perform that action at this time.
0 commit comments