Skip to content

Commit

Permalink
Merge pull request #244 from scipp/remove-warn-tdc
Browse files Browse the repository at this point in the history
fix: nxlog use time field as signal if missing
  • Loading branch information
jokasimr authored Oct 15, 2024
2 parents b1bf148 + 0e64b44 commit 23656d1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/scippnexus/nxdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def __init__(self, attrs: dict[str, Any], children: dict[str, Field | Group]):
attrs=attrs,
children=children,
fallback_dims=('time',),
fallback_signal_name='value',
fallback_signal_name='value' if 'value' in children else 'time',
)

def read_children(self, sel: ScippIndex) -> sc.DataGroup:
Expand Down
6 changes: 2 additions & 4 deletions tests/nxlog_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,14 @@ def test_nxobject_log(h5root):
assert sc.identical(log[...], da)


@pytest.mark.filterwarnings("ignore:Failed to load /entry/log:UserWarning")
def test_nxlog_with_missing_value_triggers_fallback(nxroot):
def test_nxlog_with_missing_value_uses_time_as_value(nxroot):
time = sc.epoch(unit='ns') + sc.array(
dims=['time'], unit='s', values=[4.4, 5.5, 6.6]
).to(unit='ns', dtype='int64')
log = nxroot['entry'].create_class('log', NXlog)
log['time'] = time - sc.epoch(unit='ns')
loaded = log[()]
# Fallback to DataGroup, but we still have partial info from NXlog: dim is time
assert_identical(loaded, sc.DataGroup(time=time))
assert_identical(loaded, sc.DataArray(data=time))


def test_nxlog_length_1(h5root):
Expand Down

0 comments on commit 23656d1

Please sign in to comment.