Skip to content
forked from pydata/xarray

Commit 6bfe03a

Browse files
committed
Merge branch 'main' into grouper-public-api
* main: Enable pandas type checking (pydata#9213) Per-variable specification of boolean parameters in open_dataset (pydata#9218) test push Added a space to the documentation (pydata#9247) Fix typing for test_plot.py (pydata#9234) Allow mypy to run in vscode (pydata#9239) Revert "Test main push" Test main push Revert "Update _typing.py" Update _typing.py Add a `.drop_attrs` method (pydata#8258)
2 parents 7838d57 + 71fce9b commit 6bfe03a

40 files changed

+820
-545
lines changed

doc/api.rst

+2
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ Dataset contents
111111
Dataset.drop_duplicates
112112
Dataset.drop_dims
113113
Dataset.drop_encoding
114+
Dataset.drop_attrs
114115
Dataset.set_coords
115116
Dataset.reset_coords
116117
Dataset.convert_calendar
@@ -306,6 +307,7 @@ DataArray contents
306307
DataArray.drop_indexes
307308
DataArray.drop_duplicates
308309
DataArray.drop_encoding
310+
DataArray.drop_attrs
309311
DataArray.reset_coords
310312
DataArray.copy
311313
DataArray.convert_calendar

doc/user-guide/terminology.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ complete examples, please consult the relevant documentation.*
221221
combined_ds
222222
223223
lazy
224-
Lazily-evaluated operations do not load data into memory until necessary.Instead of doing calculations
224+
Lazily-evaluated operations do not load data into memory until necessary. Instead of doing calculations
225225
right away, xarray lets you plan what calculations you want to do, like finding the
226226
average temperature in a dataset.This planning is called "lazy evaluation." Later, when
227227
you're ready to see the final result, you tell xarray, "Okay, go ahead and do those calculations now!"

doc/whats-new.rst

+9
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,17 @@ v2024.06.1 (unreleased)
2222

2323
New Features
2424
~~~~~~~~~~~~
25+
- Allow per-variable specification of ``mask_and_scale``, ``decode_times``, ``decode_timedelta``
26+
``use_cftime`` and ``concat_characters`` params in :py:func:`~xarray.open_dataset` (:pull:`9218`).
27+
By `Mathijs Verhaegh <https://github.com/Ostheer>`_.
2528
- Allow chunking for arrays with duplicated dimension names (:issue:`8759`, :pull:`9099`).
2629
By `Martin Raspaud <https://github.com/mraspaud>`_.
2730
- Extract the source url from fsspec objects (:issue:`9142`, :pull:`8923`).
2831
By `Justus Magin <https://github.com/keewis>`_.
32+
- Add :py:meth:`DataArray.drop_attrs` & :py:meth:`Dataset.drop_attrs` methods,
33+
to return an object without ``attrs``. A ``deep`` parameter controls whether
34+
variables' ``attrs`` are also dropped.
35+
By `Maximilian Roos <https://github.com/max-sixty>`_. (:pull:`8288`)
2936

3037
Breaking changes
3138
~~~~~~~~~~~~~~~~
@@ -75,6 +82,8 @@ Documentation
7582
Internal Changes
7683
~~~~~~~~~~~~~~~~
7784

85+
- Enable typing checks of pandas (:pull:`9213`).
86+
By `Michael Niklas <https://github.com/headtr1ck>`_.
7887

7988
.. _whats-new.2024.06.0:
8089

properties/__init__.py

Whitespace-only changes.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ exclude_lines = ["pragma: no cover", "if TYPE_CHECKING"]
8787
[tool.mypy]
8888
enable_error_code = "redundant-self"
8989
exclude = [
90+
'build',
9091
'xarray/util/generate_.*\.py',
9192
'xarray/datatree_/doc/.*\.py',
9293
]
@@ -119,7 +120,6 @@ module = [
119120
"netCDF4.*",
120121
"netcdftime.*",
121122
"opt_einsum.*",
122-
"pandas.*",
123123
"pint.*",
124124
"pooch.*",
125125
"pyarrow.*",

xarray/backends/api.py

+22-12
Original file line numberDiff line numberDiff line change
@@ -398,11 +398,11 @@ def open_dataset(
398398
chunks: T_Chunks = None,
399399
cache: bool | None = None,
400400
decode_cf: bool | None = None,
401-
mask_and_scale: bool | None = None,
402-
decode_times: bool | None = None,
403-
decode_timedelta: bool | None = None,
404-
use_cftime: bool | None = None,
405-
concat_characters: bool | None = None,
401+
mask_and_scale: bool | Mapping[str, bool] | None = None,
402+
decode_times: bool | Mapping[str, bool] | None = None,
403+
decode_timedelta: bool | Mapping[str, bool] | None = None,
404+
use_cftime: bool | Mapping[str, bool] | None = None,
405+
concat_characters: bool | Mapping[str, bool] | None = None,
406406
decode_coords: Literal["coordinates", "all"] | bool | None = None,
407407
drop_variables: str | Iterable[str] | None = None,
408408
inline_array: bool = False,
@@ -451,25 +451,31 @@ def open_dataset(
451451
decode_cf : bool, optional
452452
Whether to decode these variables, assuming they were saved according
453453
to CF conventions.
454-
mask_and_scale : bool, optional
454+
mask_and_scale : bool or dict-like, optional
455455
If True, replace array values equal to `_FillValue` with NA and scale
456456
values according to the formula `original_values * scale_factor +
457457
add_offset`, where `_FillValue`, `scale_factor` and `add_offset` are
458458
taken from variable attributes (if they exist). If the `_FillValue` or
459459
`missing_value` attribute contains multiple values a warning will be
460460
issued and all array values matching one of the multiple values will
461-
be replaced by NA. This keyword may not be supported by all the backends.
462-
decode_times : bool, optional
461+
be replaced by NA. Pass a mapping, e.g. ``{"my_variable": False}``,
462+
to toggle this feature per-variable individually.
463+
This keyword may not be supported by all the backends.
464+
decode_times : bool or dict-like, optional
463465
If True, decode times encoded in the standard NetCDF datetime format
464466
into datetime objects. Otherwise, leave them encoded as numbers.
467+
Pass a mapping, e.g. ``{"my_variable": False}``,
468+
to toggle this feature per-variable individually.
465469
This keyword may not be supported by all the backends.
466-
decode_timedelta : bool, optional
470+
decode_timedelta : bool or dict-like, optional
467471
If True, decode variables and coordinates with time units in
468472
{"days", "hours", "minutes", "seconds", "milliseconds", "microseconds"}
469473
into timedelta objects. If False, leave them encoded as numbers.
470474
If None (default), assume the same value of decode_time.
475+
Pass a mapping, e.g. ``{"my_variable": False}``,
476+
to toggle this feature per-variable individually.
471477
This keyword may not be supported by all the backends.
472-
use_cftime: bool, optional
478+
use_cftime: bool or dict-like, optional
473479
Only relevant if encoded dates come from a standard calendar
474480
(e.g. "gregorian", "proleptic_gregorian", "standard", or not
475481
specified). If None (default), attempt to decode times to
@@ -478,12 +484,16 @@ def open_dataset(
478484
``cftime.datetime`` objects, regardless of whether or not they can be
479485
represented using ``np.datetime64[ns]`` objects. If False, always
480486
decode times to ``np.datetime64[ns]`` objects; if this is not possible
481-
raise an error. This keyword may not be supported by all the backends.
482-
concat_characters : bool, optional
487+
raise an error. Pass a mapping, e.g. ``{"my_variable": False}``,
488+
to toggle this feature per-variable individually.
489+
This keyword may not be supported by all the backends.
490+
concat_characters : bool or dict-like, optional
483491
If True, concatenate along the last dimension of character arrays to
484492
form string arrays. Dimensions will only be concatenated over (and
485493
removed) if they have no corresponding variable and if they are only
486494
used as the last dimension of character arrays.
495+
Pass a mapping, e.g. ``{"my_variable": False}``,
496+
to toggle this feature per-variable individually.
487497
This keyword may not be supported by all the backends.
488498
decode_coords : bool or {"coordinates", "all"}, optional
489499
Controls which variables are set as coordinate variables:

0 commit comments

Comments
 (0)