Skip to content

Commit 46dfb77

Browse files
max-sixtydcherian
authored andcommitted
remove DataArray and Dataset constructor deprecations for 0.15 (#3560)
* remove 0.15 deprecations * whatsnew
1 parent 3955c37 commit 46dfb77

File tree

3 files changed

+7
-28
lines changed

3 files changed

+7
-28
lines changed

doc/whats-new.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ v0.15.0 (unreleased)
2222
Breaking changes
2323
~~~~~~~~~~~~~~~~
2424

25+
- Remove ``compat`` and ``encoding`` kwargs from ``DataArray``, which
26+
have been deprecated since 0.12. (:pull:`3650`).
27+
Instead, specify the encoding when writing to disk or set
28+
the ``encoding`` attribute directly.
29+
By `Maximilian Roos <https://github.com/max-sixty>`_
2530

2631
New Features
2732
~~~~~~~~~~~~

xarray/core/dataarray.py

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,6 @@ def __init__(
267267
dims: Union[Hashable, Sequence[Hashable], None] = None,
268268
name: Hashable = None,
269269
attrs: Mapping = None,
270-
# deprecated parameters
271-
encoding=None,
272270
# internal parameters
273271
indexes: Dict[Hashable, pd.Index] = None,
274272
fastpath: bool = False,
@@ -313,20 +311,10 @@ def __init__(
313311
Attributes to assign to the new instance. By default, an empty
314312
attribute dictionary is initialized.
315313
"""
316-
if encoding is not None:
317-
warnings.warn(
318-
"The `encoding` argument to `DataArray` is deprecated, and . "
319-
"will be removed in 0.15. "
320-
"Instead, specify the encoding when writing to disk or "
321-
"set the `encoding` attribute directly.",
322-
FutureWarning,
323-
stacklevel=2,
324-
)
325314
if fastpath:
326315
variable = data
327316
assert dims is None
328317
assert attrs is None
329-
assert encoding is None
330318
else:
331319
# try to fill in arguments from data if they weren't supplied
332320
if coords is None:
@@ -348,13 +336,11 @@ def __init__(
348336
name = getattr(data, "name", None)
349337
if attrs is None and not isinstance(data, PANDAS_TYPES):
350338
attrs = getattr(data, "attrs", None)
351-
if encoding is None:
352-
encoding = getattr(data, "encoding", None)
353339

354340
data = _check_data_shape(data, coords, dims)
355341
data = as_compatible_data(data)
356342
coords, dims = _infer_coords_and_dims(data.shape, coords, dims)
357-
variable = Variable(dims, data, attrs, encoding, fastpath=True)
343+
variable = Variable(dims, data, attrs, fastpath=True)
358344
indexes = dict(
359345
_extract_indexes_from_coords(coords)
360346
) # needed for to_dataset

xarray/core/dataset.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,6 @@ def __init__(
463463
data_vars: Mapping[Hashable, Any] = None,
464464
coords: Mapping[Hashable, Any] = None,
465465
attrs: Mapping[Hashable, Any] = None,
466-
compat=None,
467466
):
468467
"""To load data from a file or file-like object, use the `open_dataset`
469468
function.
@@ -513,18 +512,7 @@ def __init__(
513512
514513
attrs : dict-like, optional
515514
Global attributes to save on this dataset.
516-
compat : deprecated
517515
"""
518-
if compat is not None:
519-
warnings.warn(
520-
"The `compat` argument to Dataset is deprecated and will be "
521-
"removed in 0.15."
522-
"Instead, use `merge` to control how variables are combined",
523-
FutureWarning,
524-
stacklevel=2,
525-
)
526-
else:
527-
compat = "broadcast_equals"
528516

529517
# TODO(shoyer): expose indexes as a public argument in __init__
530518

@@ -544,7 +532,7 @@ def __init__(
544532
coords = coords.variables
545533

546534
variables, coord_names, dims, indexes = merge_data_and_coords(
547-
data_vars, coords, compat=compat
535+
data_vars, coords, compat="broadcast_equals"
548536
)
549537

550538
self._attrs = dict(attrs) if attrs is not None else None

0 commit comments

Comments
 (0)