coveralls: ## Pull Request Test Coverage Report for [Build 1439](https://coveralls.io/builds/27962628)

* **3** of **3**   **(100.0%)**  changed or added relevant lines in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **90.967%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/27962628/badge)](https://coveralls.io/builds/27962628) |
| :-- | --: |
| Change from base [Build 1435](https://coveralls.io/builds/27961299): |  0.0% |
| Covered Lines: | 1722 |
| Relevant Lines: | 1893 |

---
##### 💛  - [Coveralls](https://coveralls.io)

diff --git a/HISTORY.rst b/HISTORY.rst
index 66f7cba4..556b131c 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -5,6 +5,7 @@ History
 0.13.x (2020-01-10)
 -------------------
 * Reverted #311, removing the `_rolling` util function. Added optimal keywords to `rolling()` calls.
+* Fixed `ensembles.create_ensemble` errors for builds against xarray master branch.
 
 0.12.x-beta (2019-11-18)
 ------------------------
diff --git a/xclim/ensembles.py b/xclim/ensembles.py
index ab602bc4..8080f212 100644
--- a/xclim/ensembles.py
+++ b/xclim/ensembles.py
@@ -7,7 +7,6 @@ from typing import Union
 
 import numpy as np
 import pandas as pd
-import scipy
 import scipy.stats
 import xarray as xr
 from sklearn.cluster import KMeans
@@ -314,15 +313,16 @@ def _ens_align_datasets(
 
         if time_flag:
 
-            ds["time"] = xr.decode_cf(ds).time
-
-            ds["time"].values = pd.to_datetime(
+            cal1 = xr.decode_cf(ds).time
+            ds.drop_vars("time")
+            ds["time"] = pd.to_datetime(
                 {
-                    "year": ds.time.dt.year,
-                    "month": ds.time.dt.month,
-                    "day": ds.time.dt.day,
+                    "year": cal1.time.dt.year,
+                    "month": cal1.time.dt.month,
+                    "day": cal1.time.dt.day,
                 }
-            )
+            ).values
+
             # if dataset does not have the same time steps pad with nans
             if ds.time.min() > time_all.min() or ds.time.max() < time_all.max():
                 coords = {}

build failing against xarray master
ensembles creation tests seems to be failing with the travis build w/ xarray@master

We might want to take a minute to try to see why and try to get ahead of this... 
diff --git a/tests/test_ensembles.py b/tests/test_ensembles.py
index 55d11020..3bd9d27f 100644
--- a/tests/test_ensembles.py
+++ b/tests/test_ensembles.py
@@ -58,6 +58,7 @@ class TestEnsembleStats:
     def test_create_ensemble(self):
         ens = ensembles.create_ensemble(self.nc_files_simple)
         assert len(ens.realization) == len(self.nc_files_simple)
+        assert len(ens.time) == 151
 
         # create again using xr.Dataset objects
         ds_all = []
@@ -94,6 +95,7 @@ class TestEnsembleStats:
         assert len(ens.realization) == len(self.nc_files)
         assert ens.time.dt.year.min() == 1950
         assert ens.time.dt.year.max() == 2100
+        assert len(ens.time) == 151
 
         ii = [i for i, s in enumerate(self.nc_files) if "1970-2050" in s]
         # assert padded with nans

pip install -e .[dev]
parse_log_pytest
requirements.txt
pytest pytest-cov flake8
apt-get update apt-get install -y gcc
3.6
requirements_dev.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
attrs==22.2.0
bleach==4.1.0
bokeh==2.3.3
boltons==23.1.1
Bottleneck==1.3.8
bump2version==1.0.1
certifi==2021.5.30
cffi==1.15.1
cfgv==3.3.1
cftime==1.6.0
charset-normalizer==2.0.12
click==8.0.4
click-plugins==1.1.1
cligj==0.7.2
cloudpickle==2.2.1
colorama==0.4.5
contextvars==2.4
coverage==6.2
cryptography==40.0.2
dask==2021.3.0
distlib==0.3.9
distributed==2021.3.0
docutils==0.18.1
filelock==3.4.1
Fiona==1.8.22
flake8==5.0.4
fsspec==2022.1.0
geojson==2.5.0
geopandas==0.9.0
HeapDict==1.0.1
identify==2.4.4
idna==3.10
immutables==0.19
importlib-metadata==4.2.0
importlib-resources==5.2.3
iniconfig==1.1.1
jeepney==0.7.1
Jinja2==3.0.3
joblib==1.1.1
keyring==23.4.1
locket==1.0.0
MarkupSafe==2.0.1
mccabe==0.7.0
msgpack==1.0.5
munch==4.0.0
netCDF4==1.6.1
nodeenv==1.6.0
numpy==1.19.5
packaging==21.3
pandas==1.1.5
partd==1.2.0
Pillow==8.4.0
Pint==0.9
pkginfo==1.10.0
platformdirs==2.4.0
pluggy==1.0.0
pre-commit==2.17.0
psutil==7.0.0
py==1.11.0
pycodestyle==2.9.1
pycparser==2.21
pyflakes==2.5.0
Pygments==2.14.0
pyparsing==3.1.4
pyproj==3.0.1
pytest==7.0.1
pytest-cov==4.0.0
pytest-runner==5.3.2
python-dateutil==2.9.0.post0
pytz==2025.2
PyYAML==6.0.1
readme-renderer==34.0
requests==2.27.1
requests-toolbelt==1.0.0
rfc3986==1.5.0
Rtree==0.9.7
scikit-learn==0.24.2
scipy==1.5.4
SecretStorage==3.3.3
Shapely==1.8.5.post1
six==1.17.0
sortedcontainers==2.4.0
tblib==1.7.0
threadpoolctl==3.1.0
toml==0.10.2
tomli==1.2.3
toolz==0.12.0
tornado==6.1
tox==3.28.0
tqdm==4.64.1
twine==3.8.0
typing_extensions==4.1.1
urllib3==1.26.20
virtualenv==20.16.2
watchdog==2.3.1
webencodings==0.5.1
xarray==0.16.2
-e git+https://github.com/Ouranosinc/xclim.git@26d99831e33e989da59b0a7e2471e66231111784#egg=xclim
zict==2.1.0
zipp==3.6.0

name: xclim
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - attrs==22.2.0
      - bleach==4.1.0
      - bokeh==2.3.3
      - boltons==23.1.1
      - bottleneck==1.3.8
      - bump2version==1.0.1
      - cffi==1.15.1
      - cfgv==3.3.1
      - cftime==1.6.0
      - charset-normalizer==2.0.12
      - click==8.0.4
      - click-plugins==1.1.1
      - cligj==0.7.2
      - cloudpickle==2.2.1
      - colorama==0.4.5
      - contextvars==2.4
      - coverage==6.2
      - cryptography==40.0.2
      - dask==2021.3.0
      - distlib==0.3.9
      - distributed==2021.3.0
      - docutils==0.18.1
      - filelock==3.4.1
      - fiona==1.8.22
      - flake8==5.0.4
      - fsspec==2022.1.0
      - geojson==2.5.0
      - geopandas==0.9.0
      - heapdict==1.0.1
      - identify==2.4.4
      - idna==3.10
      - immutables==0.19
      - importlib-metadata==4.2.0
      - importlib-resources==5.2.3
      - iniconfig==1.1.1
      - jeepney==0.7.1
      - jinja2==3.0.3
      - joblib==1.1.1
      - keyring==23.4.1
      - locket==1.0.0
      - markupsafe==2.0.1
      - mccabe==0.7.0
      - msgpack==1.0.5
      - munch==4.0.0
      - netcdf4==1.6.1
      - nodeenv==1.6.0
      - numpy==1.19.5
      - packaging==21.3
      - pandas==1.1.5
      - partd==1.2.0
      - pillow==8.4.0
      - pint==0.9
      - pkginfo==1.10.0
      - platformdirs==2.4.0
      - pluggy==1.0.0
      - pre-commit==2.17.0
      - psutil==7.0.0
      - py==1.11.0
      - pycodestyle==2.9.1
      - pycparser==2.21
      - pyflakes==2.5.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pyproj==3.0.1
      - pytest==7.0.1
      - pytest-cov==4.0.0
      - pytest-runner==5.3.2
      - python-dateutil==2.9.0.post0
      - pytz==2025.2
      - pyyaml==6.0.1
      - readme-renderer==34.0
      - requests==2.27.1
      - requests-toolbelt==1.0.0
      - rfc3986==1.5.0
      - rtree==0.9.7
      - scikit-learn==0.24.2
      - scipy==1.5.4
      - secretstorage==3.3.3
      - shapely==1.8.5.post1
      - six==1.17.0
      - sortedcontainers==2.4.0
      - tblib==1.7.0
      - threadpoolctl==3.1.0
      - toml==0.10.2
      - tomli==1.2.3
      - toolz==0.12.0
      - tornado==6.1
      - tox==3.28.0
      - tqdm==4.64.1
      - twine==3.8.0
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - virtualenv==20.16.2
      - watchdog==2.3.1
      - webencodings==0.5.1
      - xarray==0.16.2
      - zict==2.1.0
      - zipp==3.6.0
prefix: /opt/conda/envs/xclim

tests/test_ensembles.py::TestEnsembleStats::test_create_ensemble tests/test_ensembles.py::TestEnsembleStats::test_create_unequal_times tests/test_ensembles.py::TestEnsembleStats::test_calc_perc[False] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc[True] tests/test_ensembles.py::TestEnsembleStats::test_calc_perc_blocks tests/test_ensembles.py::TestEnsembleStats::test_calc_perc_nans tests/test_ensembles.py::TestEnsembleStats::test_calc_mean_std_min_max
tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_rsqcutoff tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_rsqopt tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_variweights
tests/test_ensembles.py::TestEnsembleStats::test_checktimes tests/test_ensembles.py::TestEnsembleStats::test_no_time tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_nclust tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_sampleweights tests/test_ensembles.py::TestEnsembleReduction::test_kmeans_modelweights
HISTORY.rst xclim/ensembles.py
HISTORY.rst xclim/ensembles.py