@@ -185,8 +185,8 @@ def dataset(
185
185
root , split , bands , num_classes , transforms , download = True , checksum = True
186
186
)
187
187
188
- def test_getitem_s2 (self , dataset : BigEarthNetV2 ) -> None :
189
- """Test loading S2 or combined data."""
188
+ def test_getitem (self , dataset : BigEarthNetV2 ) -> None :
189
+ """Test loading data."""
190
190
x = dataset [0 ]
191
191
192
192
if dataset .bands in ['s2' , 'all' ]:
@@ -222,11 +222,52 @@ def test_len(self, dataset: BigEarthNetV2) -> None:
222
222
else :
223
223
assert len (dataset ) == 1
224
224
225
+ def test_already_downloaded (self , dataset : BigEarthNetV2 , tmp_path : Path ) -> None :
226
+ BigEarthNetV2 (
227
+ root = tmp_path ,
228
+ bands = dataset .bands ,
229
+ split = dataset .split ,
230
+ num_classes = dataset .num_classes ,
231
+ download = True ,
232
+ )
233
+
225
234
def test_not_downloaded (self , tmp_path : Path ) -> None :
226
235
"""Test error handling when data not present."""
227
236
with pytest .raises (DatasetNotFoundError , match = 'Dataset not found' ):
228
237
BigEarthNetV2 (tmp_path )
229
238
239
+ def test_already_downloaded_not_extracted (
240
+ self , dataset : BigEarthNetV2 , tmp_path : Path
241
+ ) -> None :
242
+ shutil .copy (dataset .metadata_locs ['metadata' ]['url' ], tmp_path )
243
+ if dataset .bands == 'all' :
244
+ shutil .rmtree (
245
+ os .path .join (dataset .root , dataset .metadata_locs ['s1' ]['directory' ])
246
+ )
247
+ shutil .rmtree (
248
+ os .path .join (dataset .root , dataset .metadata_locs ['s2' ]['directory' ])
249
+ )
250
+ shutil .copy (dataset .metadata_locs ['s1' ]['url' ], tmp_path )
251
+ shutil .copy (dataset .metadata_locs ['s2' ]['url' ], tmp_path )
252
+ elif dataset .bands == 's1' :
253
+ shutil .rmtree (
254
+ os .path .join (dataset .root , dataset .metadata_locs ['s1' ]['directory' ])
255
+ )
256
+ shutil .copy (dataset .metadata_locs ['s1' ]['url' ], tmp_path )
257
+ else :
258
+ shutil .rmtree (
259
+ os .path .join (dataset .root , dataset .metadata_locs ['s2' ]['directory' ])
260
+ )
261
+ shutil .copy (dataset .metadata_locs ['s2' ]['url' ], tmp_path )
262
+
263
+ BigEarthNetV2 (
264
+ root = tmp_path ,
265
+ bands = dataset .bands ,
266
+ split = dataset .split ,
267
+ num_classes = dataset .num_classes ,
268
+ download = False ,
269
+ )
270
+
230
271
def test_invalid_split (self , tmp_path : Path ) -> None :
231
272
"""Test error on invalid split."""
232
273
with pytest .raises (AssertionError , match = 'split must be one of' ):
0 commit comments