Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions extra_data/keydata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import List, Optional, Tuple
from warnings import warn

import h5py
import numpy as np
Expand Down Expand Up @@ -301,7 +302,7 @@ def attributes(self):
if (not attrs) and dset.is_virtual:
# Virtual datasets were initially created without these attributes.
# Find a source file. Not using source_file_paths as it can give [].
_, filename, _, _ = dset.virtual_sources()[0]
filename = dset.id.get_create_plist().get_virtual_filename(0)
# Not using FileAccess: no need for train or source lists.
with h5py.File(filename, 'r') as f:
attrs = self._find_attributes(f[self.hdf5_data_path])
Expand Down Expand Up @@ -610,8 +611,11 @@ def _dim_name(idx):

# xarray attributes
attrs = {}
if (units := self.units):
attrs['units'] = units
try:
if (units := self.units):
attrs['units'] = units
except Exception as e:
warn(f"Exception fetching units: {e}")

if ndarr.dtype.names is not None:
# Structured dtype.
Expand Down
Loading