Skip to content

Commit 5c56acf

Browse files
committed
Remove default values in private functions
1 parent 84e81bc commit 5c56acf

File tree

4 files changed

+63
-40
lines changed

4 files changed

+63
-40
lines changed

xarray/backends/api.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
)
3535
from xarray.backends.locks import _get_scheduler
3636
from xarray.coders import CFDatetimeCoder, CFTimedeltaCoder
37-
from xarray.core import indexing
37+
from xarray.core import dtypes, indexing
3838
from xarray.core.combine import (
3939
_infer_concat_order_from_positions,
4040
_nested_combine,
@@ -1654,6 +1654,7 @@ def open_mfdataset(
16541654
ids=ids,
16551655
join=join,
16561656
combine_attrs=combine_attrs,
1657+
fill_value=dtypes.NA,
16571658
)
16581659
elif combine == "by_coords":
16591660
# Redo ordering from coordinates, ignoring how they were ordered

xarray/core/combine.py

+32-25
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,12 @@ def _check_shape_tile_ids(combined_tile_ids):
200200
def _combine_nd(
201201
combined_ids,
202202
concat_dims,
203-
data_vars="all",
204-
coords="different",
205-
compat: CompatOptions = "no_conflicts",
206-
fill_value=dtypes.NA,
207-
join: JoinOptions = "outer",
208-
combine_attrs: CombineAttrsOptions = "drop",
203+
data_vars,
204+
coords,
205+
compat: CompatOptions,
206+
fill_value,
207+
join: JoinOptions,
208+
combine_attrs: CombineAttrsOptions,
209209
):
210210
"""
211211
Combines an N-dimensional structure of datasets into one by applying a
@@ -263,9 +263,9 @@ def _combine_all_along_first_dim(
263263
data_vars,
264264
coords,
265265
compat: CompatOptions,
266-
fill_value=dtypes.NA,
267-
join: JoinOptions = "outer",
268-
combine_attrs: CombineAttrsOptions = "drop",
266+
fill_value,
267+
join: JoinOptions,
268+
combine_attrs: CombineAttrsOptions,
269269
):
270270
# Group into lines of datasets which must be combined along dim
271271
grouped = groupby_defaultdict(list(combined_ids.items()), key=_new_tile_id)
@@ -276,20 +276,27 @@ def _combine_all_along_first_dim(
276276
combined_ids = dict(sorted(group))
277277
datasets = combined_ids.values()
278278
new_combined_ids[new_id] = _combine_1d(
279-
datasets, dim, compat, data_vars, coords, fill_value, join, combine_attrs
279+
datasets,
280+
concat_dim=dim,
281+
compat=compat,
282+
data_vars=data_vars,
283+
coords=coords,
284+
fill_value=fill_value,
285+
join=join,
286+
combine_attrs=combine_attrs,
280287
)
281288
return new_combined_ids
282289

283290

284291
def _combine_1d(
285292
datasets,
286293
concat_dim,
287-
compat: CompatOptions = "no_conflicts",
288-
data_vars="all",
289-
coords="different",
290-
fill_value=dtypes.NA,
291-
join: JoinOptions = "outer",
292-
combine_attrs: CombineAttrsOptions = "drop",
294+
compat: CompatOptions,
295+
data_vars,
296+
coords,
297+
fill_value,
298+
join: JoinOptions,
299+
combine_attrs: CombineAttrsOptions,
293300
):
294301
"""
295302
Applies either concat or merge to 1D list of datasets depending on value
@@ -343,9 +350,9 @@ def _nested_combine(
343350
data_vars,
344351
coords,
345352
ids,
346-
fill_value=dtypes.NA,
347-
join: JoinOptions = "outer",
348-
combine_attrs: CombineAttrsOptions = "drop",
353+
fill_value,
354+
join: JoinOptions,
355+
combine_attrs: CombineAttrsOptions,
349356
):
350357
if len(datasets) == 0:
351358
return Dataset()
@@ -619,12 +626,12 @@ def groupby_defaultdict(
619626

620627
def _combine_single_variable_hypercube(
621628
datasets,
622-
fill_value=dtypes.NA,
623-
data_vars="all",
624-
coords="different",
625-
compat: CompatOptions = "no_conflicts",
626-
join: JoinOptions = "outer",
627-
combine_attrs: CombineAttrsOptions = "no_conflicts",
629+
fill_value,
630+
data_vars,
631+
coords,
632+
compat: CompatOptions,
633+
join: JoinOptions,
634+
combine_attrs: CombineAttrsOptions,
628635
):
629636
"""
630637
Attempt to combine a list of Datasets into a hypercube using their

xarray/core/concat.py

+13-13
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,10 @@ def _dataset_concat(
483483
coords: str | list[str],
484484
compat: CompatOptions,
485485
positions: Iterable[Iterable[int]] | None,
486-
fill_value: Any = dtypes.NA,
487-
join: JoinOptions = "outer",
488-
combine_attrs: CombineAttrsOptions = "override",
489-
create_index_for_new_dim: bool = True,
486+
fill_value: Any,
487+
join: JoinOptions,
488+
combine_attrs: CombineAttrsOptions,
489+
create_index_for_new_dim: bool,
490490
) -> T_Dataset:
491491
"""
492492
Concatenate a sequence of datasets along a new or existing dimension
@@ -722,10 +722,10 @@ def _dataarray_concat(
722722
coords: str | list[str],
723723
compat: CompatOptions,
724724
positions: Iterable[Iterable[int]] | None,
725-
fill_value: object = dtypes.NA,
726-
join: JoinOptions = "outer",
727-
combine_attrs: CombineAttrsOptions = "override",
728-
create_index_for_new_dim: bool = True,
725+
fill_value: object,
726+
join: JoinOptions,
727+
combine_attrs: CombineAttrsOptions,
728+
create_index_for_new_dim: bool,
729729
) -> T_DataArray:
730730
from xarray.core.dataarray import DataArray
731731

@@ -754,11 +754,11 @@ def _dataarray_concat(
754754

755755
ds = _dataset_concat(
756756
datasets,
757-
dim,
758-
data_vars,
759-
coords,
760-
compat,
761-
positions,
757+
dim=dim,
758+
data_vars=data_vars,
759+
coords=coords,
760+
compat=compat,
761+
positions=positions,
762762
fill_value=fill_value,
763763
join=join,
764764
combine_attrs=combine_attrs,

xarray/tests/test_combine.py

+16-1
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,9 @@ def test_concat_once(self, create_combined_ids, concat_dim):
290290
data_vars="all",
291291
coords="different",
292292
compat="no_conflicts",
293+
fill_value=dtypes.NA,
294+
join="outer",
295+
combine_attrs="drop",
293296
)
294297

295298
expected_ds = concat([ds(0), ds(1)], dim=concat_dim)
@@ -304,6 +307,9 @@ def test_concat_only_first_dim(self, create_combined_ids):
304307
data_vars="all",
305308
coords="different",
306309
compat="no_conflicts",
310+
fill_value=dtypes.NA,
311+
join="outer",
312+
combine_attrs="drop",
307313
)
308314

309315
ds = create_test_data
@@ -319,7 +325,16 @@ def test_concat_only_first_dim(self, create_combined_ids):
319325
def test_concat_twice(self, create_combined_ids, concat_dim):
320326
shape = (2, 3)
321327
combined_ids = create_combined_ids(shape)
322-
result = _combine_nd(combined_ids, concat_dims=["dim1", concat_dim])
328+
result = _combine_nd(
329+
combined_ids,
330+
concat_dims=["dim1", concat_dim],
331+
data_vars="all",
332+
coords="different",
333+
compat="no_conflicts",
334+
fill_value=dtypes.NA,
335+
join="outer",
336+
combine_attrs="drop",
337+
)
323338

324339
ds = create_test_data
325340
partway1 = concat([ds(0), ds(3)], dim="dim1")

0 commit comments

Comments
 (0)