Skip to content

Commit 5df8a42

Browse files
rabernatshoyer
authored andcommitted
Allow other tutorial filename extensions (#3121)
* switching out examples to use nbsphinx * added jupyter_client to doc env * allow non netcdf tutorial files
1 parent 92cd3c4 commit 5df8a42

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

xarray/tutorial.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ def open_dataset(name, cache=True, cache_dir=_default_cache_dir,
3333
Parameters
3434
----------
3535
name : str
36-
Name of the netcdf file containing the dataset
37-
ie. 'air_temperature'
36+
Name of the file containing the dataset. If no suffix is given, assumed
37+
to be netCDF ('.nc' is appended)
38+
e.g. 'air_temperature'
3839
cache_dir : string, optional
3940
The directory in which to search for and write cached data.
4041
cache : boolean, optional
@@ -51,10 +52,13 @@ def open_dataset(name, cache=True, cache_dir=_default_cache_dir,
5152
xarray.open_dataset
5253
5354
"""
55+
root, ext = _os.path.splitext(name)
56+
if not ext:
57+
ext = '.nc'
58+
fullname = root + ext
5459
longdir = _os.path.expanduser(cache_dir)
55-
fullname = name + '.nc'
5660
localfile = _os.sep.join((longdir, fullname))
57-
md5name = name + '.md5'
61+
md5name = fullname + '.md5'
5862
md5file = _os.sep.join((longdir, md5name))
5963

6064
if not _os.path.exists(localfile):

0 commit comments

Comments
 (0)