(
self,
name: str,
variable: Variable,
check_encoding: bool = False,
unlimited_dims: set[str] | None = None,
)
| 326 | return variable |
| 327 | |
| 328 | def prepare_variable( |
| 329 | self, |
| 330 | name: str, |
| 331 | variable: Variable, |
| 332 | check_encoding: bool = False, |
| 333 | unlimited_dims: set[str] | None = None, |
| 334 | ) -> tuple[ScipyArrayWrapper, Any]: |
| 335 | if ( |
| 336 | check_encoding |
| 337 | and variable.encoding |
| 338 | and variable.encoding != {"_FillValue": None} |
| 339 | ): |
| 340 | raise ValueError( |
| 341 | f"unexpected encoding for scipy backend: {list(variable.encoding)}" |
| 342 | ) |
| 343 | |
| 344 | data = variable.data |
| 345 | # nb. this still creates a numpy array in all memory, even though we |
| 346 | # don't write the data yet; scipy.io.netcdf does not support incremental |
| 347 | # writes. |
| 348 | if name not in self.ds.variables: |
| 349 | self.ds.createVariable(name, data.dtype, [str(v) for v in variable.dims]) |
| 350 | scipy_var = self.ds.variables[name] |
| 351 | for k, v in variable.attrs.items(): |
| 352 | self._validate_attr_key(k) |
| 353 | setattr(scipy_var, k, v) |
| 354 | |
| 355 | target = ScipyArrayWrapper(name, self) |
| 356 | |
| 357 | return target, data |
| 358 | |
| 359 | def sync(self) -> None: |
| 360 | self.ds.sync() |
nothing calls this directly
no test coverage detected