Skip to content

Commit 933b0a3

Browse files
improve speed of bootstrap tests
1 parent e7301ce commit 933b0a3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

src/scores/processing/block_bootstrap.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
"""
66

77
import math
8+
import os
89
from collections import OrderedDict
910
from itertools import chain, cycle, islice
10-
from typing import Dict, Iterable, List, Tuple, Union
11+
from typing import Dict, List, Tuple, Union
1112

1213
import numpy as np
1314
import xarray as xr
@@ -212,12 +213,12 @@ def _block_bootstrap( # pylint: disable=too-many-locals
212213
"arrays containing lists of dimensions to exclude for each array"
213214
)
214215
renames = []
216+
215217
for i, (obj, exclude) in enumerate(zip(array_list, exclude_dims)):
216218
array_list[i] = obj.rename(
217219
{d: f"dim{ii}" for ii, d in enumerate(exclude)},
218220
)
219221
renames.append({f"dim{ii}": d for ii, d in enumerate(exclude)})
220-
221222
dim = list(blocks.keys())
222223

223224
# Ensure bootstrapped dimensions have consistent sizes across arrays_list

tests/processing/test_block_bootstrap.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -286,32 +286,32 @@ def test_block_bootstrap(objects, blocks, n_iteration, exclude_dims, circular, e
286286
),
287287
# Dask arrays to meet block_size < 1
288288
(
289-
[xr.DataArray(da.random.random((1000, 1000, 30), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"])],
289+
[xr.DataArray(da.random.random((110, 110, 30), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"])],
290290
{"dim1": 2, "dim2": 2},
291291
2,
292292
None,
293293
True,
294-
(30, 1000, 1000, 2),
294+
(30, 110, 110, 2),
295295
),
296296
# Dask arrays for a case with leftover != 0
297297
(
298-
[xr.DataArray(da.random.random((1000, 1000, 10), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"])],
298+
[xr.DataArray(da.random.random((110, 110, 10), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"])],
299299
{"dim1": 2, "dim2": 2},
300300
3,
301301
None,
302302
True,
303-
(10, 1000, 1000, 3),
303+
(10, 110, 110, 3),
304304
),
305305
# Dataset with dask arrays
306306
(
307307
[
308308
xr.Dataset(
309309
{
310310
"var1": xr.DataArray(
311-
da.random.random((1000, 1000, 30), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"]
311+
da.random.random((110, 110, 30), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"]
312312
),
313313
"var2": xr.DataArray(
314-
da.random.random((1000, 1000, 30), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"]
314+
da.random.random((110, 110, 30), chunks=dict(dim1=-1)), dims=["dim1", "dim2", "dim3"]
315315
),
316316
}
317317
)
@@ -320,7 +320,7 @@ def test_block_bootstrap(objects, blocks, n_iteration, exclude_dims, circular, e
320320
3,
321321
None,
322322
True,
323-
(30, 1000, 1000, 3),
323+
(30, 110, 110, 3),
324324
),
325325
],
326326
)

0 commit comments

Comments
 (0)