Skip to content

Commit

Permalink
Remove unnecessary new lines; simplify _maybe_cast_to_cftimeindex
Browse files Browse the repository at this point in the history
  • Loading branch information
spencerkclark committed May 1, 2018
1 parent 7e9bb20 commit 247c9eb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
1 change: 1 addition & 0 deletions xarray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
save_mfdataset)
from .backends.rasterio_ import open_rasterio
from .backends.zarr import open_zarr

from .conventions import decode_cf, SerializationWarning

try:
Expand Down
1 change: 1 addition & 0 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def encode_zarr_variable(var, needs_copy=True, name=None):
out : xarray.Variable
A variable which has been encoded as described above.
"""

var = conventions.encode_cf_variable(var, name=name)

# zarr allows unicode, but not variable-length strings, so it's both
Expand Down
17 changes: 6 additions & 11 deletions xarray/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,13 @@ def _maybe_cast_to_cftimeindex(index):
if not OPTIONS['enable_cftimeindex']:
return index
else:
try:
import cftime # noqa: F401
except ImportError:
return index
else:
if index.dtype == 'O':
try:
return CFTimeIndex(index)
except TypeError:
return index
else:
if index.dtype == 'O':
try:
return CFTimeIndex(index)
except (ImportError, TypeError):
return index
else:
return index


def safe_cast_to_index(array):
Expand Down

0 comments on commit 247c9eb

Please sign in to comment.