@@ -43,8 +43,8 @@ def __init__(
43
43
ignore_split_file_extensions : bool = True ,
44
44
allow_substring_split_file : bool = True ,
45
45
rgb_indices : list [int ] | None = None ,
46
- dataset_bands : list [HLSBands | int ] | None = None ,
47
- output_bands : list [HLSBands | int ] | None = None ,
46
+ dataset_bands : list [HLSBands | int | list [ int ] ] | None = None ,
47
+ output_bands : list [HLSBands | int | list [ int ] ] | None = None ,
48
48
constant_scale : float = 1 ,
49
49
transform : A .Compose | None = None ,
50
50
no_data_replace : float | None = None ,
@@ -179,16 +179,18 @@ def _load_file(self, path, nan_replace: int | float | None = None) -> xr.DataArr
179
179
def _generate_bands_intervals (self , bands_intervals :List [List [int ]] = None ):
180
180
bands = list ()
181
181
for b_interval in bands_intervals :
182
- b_interval [- 1 ] += 1
183
- bands_sublist = np .arange (* b_interval ).astype (int )
182
+ bands_sublist = np .arange (b_interval [0 ], b_interval [1 ] + 1 ).astype (int ).tolist ()
184
183
bands .append (bands_sublist )
185
184
return sorted (sum (bands , []))
186
185
187
- def _bands_defined_by_interval (self , bands_list : List [int ] | List [ List [int ]] = None ) -> bool :
186
+ def _bands_defined_by_interval (self , bands_list : list [int ] | list [ list [int ]] = None ) -> bool :
188
187
if all ([type (band )== int or isinstance (band , HLSBands ) for band in bands_list ]):
189
188
return False
190
- elif all ([isinstance (band , list ) for band in bands_list ]):
191
- return True
189
+ elif all ([isinstance (subinterval , list ) for subinterval in bands_list ]):
190
+ if all ([type (band )== int for band in sum (bands_list , [])]):
191
+ return True
192
+ else :
193
+ raise Exception (f"Whe using subintervals, the limits must be int." )
192
194
else :
193
195
raise Exception (f"Excpected List[int] or List[List[int]], but received { type (bands_list )} ." )
194
196
@@ -206,8 +208,8 @@ def __init__(
206
208
ignore_split_file_extensions : bool = True ,
207
209
allow_substring_split_file : bool = True ,
208
210
rgb_indices : list [str ] | None = None ,
209
- dataset_bands : list [HLSBands | int ] | None = None ,
210
- output_bands : list [HLSBands | int ] | None = None ,
211
+ dataset_bands : list [HLSBands | int | list [ int ] ] | None = None ,
212
+ output_bands : list [HLSBands | int | list [ int ] ] | None = None ,
211
213
class_names : list [str ] | None = None ,
212
214
constant_scale : float = 1 ,
213
215
transform : A .Compose | None = None ,
0 commit comments