Skip to content

Commit 0a7ad55

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 865ef2e commit 0a7ad55

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

virtualizarr/common.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ def replace_virtual_with_loadable_vars(
6060
decode_times=decode_times,
6161
) as loadable_ds:
6262
var_names_to_load = get_loadable_variables(
63-
dataset=loadable_ds,
64-
loadable_variables=loadable_variables
63+
dataset=loadable_ds, loadable_variables=loadable_variables
6564
)
6665
# this will automatically keep any IndexVariables needed for loadable 1D coordinates
6766
loadable_var_names_to_drop = set(loadable_ds.variables).difference(
@@ -83,8 +82,9 @@ def replace_virtual_with_loadable_vars(
8382
],
8483
)
8584

86-
def get_loadable_variables(
87-
dataset: xr.Dataset,
85+
86+
def get_loadable_variables(
87+
dataset: xr.Dataset,
8888
loadable_variables: Iterable[Hashable] | None = None,
8989
) -> Iterable[Hashable]:
9090
var_names_to_load: list[Hashable]
@@ -97,18 +97,14 @@ def get_loadable_variables(
9797
# coordinate variables. We already have all the indexes and variables
9898
# we should be keeping - we just need to distinguish them.
9999
var_names_to_load = [
100-
name
101-
for name, var in dataset.variables.items()
102-
if var.dims == (name,)
100+
name for name, var in dataset.variables.items() if var.dims == (name,)
103101
]
104102
else:
105103
raise ValueError(
106104
"loadable_variables must be an iterable of string variable names,"
107105
f" or None, but got type {type(loadable_variables)}"
108106
)
109-
non_loadable_vars = set(dataset.variables).difference(
110-
var_names_to_load
111-
)
107+
non_loadable_vars = set(dataset.variables).difference(var_names_to_load)
112108
return var_names_to_load
113109

114110

virtualizarr/readers/hdf/hdf.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
from __future__ import annotations
22

33
import math
4-
from pathlib import Path
54
from typing import (
65
TYPE_CHECKING,
7-
Any,
86
Dict,
97
Hashable,
108
Iterable,
@@ -30,7 +28,6 @@
3028
ManifestGroup,
3129
ManifestStore,
3230
)
33-
from virtualizarr.manifests.manifest import validate_and_normalize_path_to_uri
3431
from virtualizarr.manifests.utils import create_v3_array_metadata
3532
from virtualizarr.readers.api import VirtualBackend
3633
from virtualizarr.readers.hdf.filters import cfcodec_from_dataset, codecs_from_dataset
@@ -151,7 +148,7 @@ def _construct_manifest_group(
151148
if variable is not None:
152149
manifest_dict[key] = variable
153150
return ManifestGroup(arrays=manifest_dict, attributes=attrs)
154-
151+
155152
@staticmethod
156153
def _create_manifest_store(
157154
filepath: str,
@@ -163,7 +160,10 @@ def _create_manifest_store(
163160
) -> ManifestStore:
164161
# Create a group containing dataset level metadata and all the manifest arrays
165162
manifest_group = HDFVirtualBackend._construct_manifest_group(
166-
store=store, filepath=filepath, group=group, drop_variables=drop_variables,
163+
store=store,
164+
filepath=filepath,
165+
group=group,
166+
drop_variables=drop_variables,
167167
)
168168
# Convert to a manifest store
169169
return ManifestStore(stores={prefix: store}, group=manifest_group)
@@ -187,13 +187,14 @@ def open_virtual_dataset(
187187
)
188188

189189
# filepath = validate_and_normalize_path_to_uri(
190-
# filepath, fs_root=Path.cwd().as_uri()
190+
# filepath, fs_root=Path.cwd().as_uri()
191191
# )
192192

193193
_drop_vars: list[Hashable] = (
194194
[] if drop_variables is None else list(drop_variables)
195195
)
196196
from obstore.store import LocalStore
197+
197198
manifest_store = HDFVirtualBackend._create_manifest_store(
198199
filepath=filepath,
199200
store=LocalStore(),
@@ -208,12 +209,15 @@ def open_virtual_dataset(
208209
)
209210
non_loadable_vars = set(ds_virtual.variables).difference(_loadable_vars)
210211
ds_loadable = xr.open_zarr(
211-
manifest_store, consolidated=False, zarr_format=3, drop_variables=non_loadable_vars
212+
manifest_store,
213+
consolidated=False,
214+
zarr_format=3,
215+
drop_variables=non_loadable_vars,
212216
)
213217
ds_virtual = ds_virtual.drop_vars(_loadable_vars)
214218
ds = xr.merge([ds_virtual, ds_loadable])
215219
return ds
216-
220+
217221
@staticmethod
218222
def _dataset_chunk_manifest(
219223
path: str,

0 commit comments

Comments
 (0)