|
1 | 1 | import os
|
2 |
| -import pathlib |
3 |
| -import warnings |
4 | 2 | from glob import glob
|
5 | 3 | from io import BytesIO
|
6 | 4 | from numbers import Number
|
@@ -151,7 +149,7 @@ def _get_default_engine(path: str, allow_remote: bool = False):
|
151 | 149 | def _autodetect_engine(filename_or_obj):
|
152 | 150 | if isinstance(filename_or_obj, AbstractDataStore):
|
153 | 151 | engine = "store"
|
154 |
| - elif isinstance(filename_or_obj, (str, pathlib.Path)): |
| 152 | + elif isinstance(filename_or_obj, (str, Path)): |
155 | 153 | engine = _get_default_engine(str(filename_or_obj), allow_remote=True)
|
156 | 154 | else:
|
157 | 155 | engine = _get_engine_from_magic_number(filename_or_obj)
|
@@ -312,7 +310,6 @@ def open_dataset(
|
312 | 310 | decode_cf=True,
|
313 | 311 | mask_and_scale=None,
|
314 | 312 | decode_times=True,
|
315 |
| - autoclose=None, |
316 | 313 | concat_characters=True,
|
317 | 314 | decode_coords=True,
|
318 | 315 | engine=None,
|
@@ -352,10 +349,6 @@ def open_dataset(
|
352 | 349 | decode_times : bool, optional
|
353 | 350 | If True, decode times encoded in the standard NetCDF datetime format
|
354 | 351 | into datetime objects. Otherwise, leave them encoded as numbers.
|
355 |
| - autoclose : bool, optional |
356 |
| - If True, automatically close files to avoid OS Error of too many files |
357 |
| - being open. However, this option doesn't work with streams, e.g., |
358 |
| - BytesIO. |
359 | 352 | concat_characters : bool, optional
|
360 | 353 | If True, concatenate along the last dimension of character arrays to
|
361 | 354 | form string arrays. Dimensions will only be concatenated over (and
|
@@ -435,17 +428,6 @@ def open_dataset(
|
435 | 428 |
|
436 | 429 | return apiv2.open_dataset(**kwargs)
|
437 | 430 |
|
438 |
| - if autoclose is not None: |
439 |
| - warnings.warn( |
440 |
| - "The autoclose argument is no longer used by " |
441 |
| - "xarray.open_dataset() and is now ignored; it will be removed in " |
442 |
| - "a future version of xarray. If necessary, you can control the " |
443 |
| - "maximum number of simultaneous open files with " |
444 |
| - "xarray.set_options(file_cache_maxsize=...).", |
445 |
| - FutureWarning, |
446 |
| - stacklevel=2, |
447 |
| - ) |
448 |
| - |
449 | 431 | if mask_and_scale is None:
|
450 | 432 | mask_and_scale = not engine == "pseudonetcdf"
|
451 | 433 |
|
@@ -583,7 +565,6 @@ def open_dataarray(
|
583 | 565 | decode_cf=True,
|
584 | 566 | mask_and_scale=None,
|
585 | 567 | decode_times=True,
|
586 |
| - autoclose=None, |
587 | 568 | concat_characters=True,
|
588 | 569 | decode_coords=True,
|
589 | 570 | engine=None,
|
@@ -699,7 +680,6 @@ def open_dataarray(
|
699 | 680 | decode_cf=decode_cf,
|
700 | 681 | mask_and_scale=mask_and_scale,
|
701 | 682 | decode_times=decode_times,
|
702 |
| - autoclose=autoclose, |
703 | 683 | concat_characters=concat_characters,
|
704 | 684 | decode_coords=decode_coords,
|
705 | 685 | engine=engine,
|
@@ -757,7 +737,6 @@ def open_mfdataset(
|
757 | 737 | data_vars="all",
|
758 | 738 | coords="different",
|
759 | 739 | combine="by_coords",
|
760 |
| - autoclose=None, |
761 | 740 | parallel=False,
|
762 | 741 | join="outer",
|
763 | 742 | attrs_file=None,
|
@@ -924,9 +903,7 @@ def open_mfdataset(
|
924 | 903 | combined_ids_paths = _infer_concat_order_from_positions(paths)
|
925 | 904 | ids, paths = (list(combined_ids_paths.keys()), list(combined_ids_paths.values()))
|
926 | 905 |
|
927 |
| - open_kwargs = dict( |
928 |
| - engine=engine, chunks=chunks or {}, lock=lock, autoclose=autoclose, **kwargs |
929 |
| - ) |
| 906 | + open_kwargs = dict(engine=engine, chunks=chunks or {}, lock=lock, **kwargs) |
930 | 907 |
|
931 | 908 | if parallel:
|
932 | 909 | import dask
|
|
0 commit comments