|
7 | 7 | import traceback
|
8 | 8 | import contextlib
|
9 | 9 | from collections import Mapping
|
10 |
| -from distutils.version import LooseVersion |
| 10 | +import warnings |
11 | 11 |
|
12 | 12 | from ..conventions import cf_encoder
|
13 | 13 | from ..core import indexing
|
@@ -133,24 +133,25 @@ def load(self):
|
133 | 133 |
|
134 | 134 | @property
|
135 | 135 | def variables(self):
|
136 |
| - # Because encoding/decoding might happen which may require both the |
137 |
| - # attributes and the variables, and because a store may be updated |
138 |
| - # we need to load both the attributes and variables |
139 |
| - # anytime either one is requested. |
| 136 | + warnings.warn('The ``variables`` property has been deprecated and ' |
| 137 | + 'will be removed in xarray v0.11.', |
| 138 | + FutureWarning, stacklevel=2) |
140 | 139 | variables, _ = self.load()
|
141 | 140 | return variables
|
142 | 141 |
|
143 | 142 | @property
|
144 | 143 | def attrs(self):
|
145 |
| - # Because encoding/decoding might happen which may require both the |
146 |
| - # attributes and the variables, and because a store may be updated |
147 |
| - # we need to load both the attributes and variables |
148 |
| - # anytime either one is requested. |
149 |
| - _, attributes = self.load() |
150 |
| - return attributes |
| 144 | + warnings.warn('The ``attrs`` property has been deprecated and ' |
| 145 | + 'will be removed in xarray v0.11.', |
| 146 | + FutureWarning, stacklevel=2) |
| 147 | + _, attrs = self.load() |
| 148 | + return attrs |
151 | 149 |
|
152 | 150 | @property
|
153 | 151 | def dimensions(self):
|
| 152 | + warnings.warn('The ``dimensions`` property has been deprecated and ' |
| 153 | + 'will be removed in xarray v0.11.', |
| 154 | + FutureWarning, stacklevel=2) |
154 | 155 | return self.get_dimensions()
|
155 | 156 |
|
156 | 157 | def close(self):
|
@@ -183,11 +184,7 @@ def add(self, source, target):
|
183 | 184 | def sync(self):
|
184 | 185 | if self.sources:
|
185 | 186 | import dask.array as da
|
186 |
| - import dask |
187 |
| - if LooseVersion(dask.__version__) > LooseVersion('0.8.1'): |
188 |
| - da.store(self.sources, self.targets, lock=self.lock) |
189 |
| - else: |
190 |
| - da.store(self.sources, self.targets) |
| 187 | + da.store(self.sources, self.targets, lock=self.lock) |
191 | 188 | self.sources = []
|
192 | 189 | self.targets = []
|
193 | 190 |
|
@@ -232,19 +229,17 @@ def set_variables(self, variables, check_encoding_set,
|
232 | 229 | for vn, v in iteritems(variables):
|
233 | 230 | name = _encode_variable_name(vn)
|
234 | 231 | check = vn in check_encoding_set
|
235 |
| - if vn not in self.variables: |
236 |
| - target, source = self.prepare_variable( |
237 |
| - name, v, check, unlimited_dims=unlimited_dims) |
238 |
| - else: |
239 |
| - target, source = self.ds.variables[name], v.data |
| 232 | + target, source = self.prepare_variable( |
| 233 | + name, v, check, unlimited_dims=unlimited_dims) |
240 | 234 |
|
241 | 235 | self.writer.add(source, target)
|
242 | 236 |
|
243 | 237 | def set_necessary_dimensions(self, variable, unlimited_dims=None):
|
244 | 238 | if unlimited_dims is None:
|
245 | 239 | unlimited_dims = set()
|
| 240 | + dims = self.get_dimensions() |
246 | 241 | for d, l in zip(variable.dims, variable.shape):
|
247 |
| - if d not in self.dimensions: |
| 242 | + if d not in dims: |
248 | 243 | is_unlimited = d in unlimited_dims
|
249 | 244 | self.set_dimension(d, l, is_unlimited)
|
250 | 245 |
|
|
0 commit comments