Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove non-generic nexus components #112

Merged
merged 8 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
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
36 changes: 13 additions & 23 deletions src/ess/reduce/nexus/_nexus_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@
import scippnexus as snx

from ..logging import get_logger
from .types import (
AnyRunFilename,
AnyRunPulseSelection,
NeXusEntryName,
NeXusGroup,
NeXusLocationSpec,
)
from .types import FilePath, NeXusEntryName, NeXusFile, NeXusGroup, NeXusLocationSpec


class NoNewDefinitionsType: ...
Expand Down Expand Up @@ -69,7 +63,7 @@ def compute_component_position(dg: sc.DataGroup) -> sc.DataGroup:


def _open_nexus_file(
file_path: AnyRunFilename,
file_path: FilePath | NeXusFile | NeXusGroup,
definitions: Mapping | None | NoNewDefinitionsType = NoNewDefinitions,
) -> AbstractContextManager:
if isinstance(file_path, getattr(NeXusGroup, '__supertype__', type(None))):
Expand Down Expand Up @@ -169,23 +163,19 @@ def _select_unique_array(
return next(iter(arrays.values()))


def _to_snx_selection(
selection: snx.typing.ScippIndex | AnyRunPulseSelection, *, for_events: bool
) -> snx.typing.ScippIndex:
match selection:
case AnyRunPulseSelection(slice(start=None, stop=None)):
return ()
case AnyRunPulseSelection(sel):
if for_events:
return {'event_time_zero': sel}
return {'time': sel}
case _:
return selection
def _to_snx_selection(selection, *, for_events: bool) -> snx.typing.ScippIndex:
if selection == slice(None, None):
return ()
if isinstance(selection, slice):
if for_events:
return {'event_time_zero': selection}
return {'time': selection}
return selection


def load_data(
file_path: AnyRunFilename,
selection: snx.typing.ScippIndex | AnyRunPulseSelection = (),
file_path: FilePath | NeXusFile | NeXusGroup,
selection: snx.typing.ScippIndex | slice = (),
*,
entry_name: NeXusEntryName | None = None,
component_name: str,
Expand Down Expand Up @@ -422,7 +412,7 @@ def _parse_monitor(group: snx.Group) -> NeXusMonitorInfo:
)


def read_nexus_file_info(file_path: AnyRunFilename) -> NeXusFileInfo:
def read_nexus_file_info(file_path: FilePath | NeXusFile | NeXusGroup) -> NeXusFileInfo:
"""Opens and inspects a NeXus file, returning a summary of its contents."""
with _open_nexus_file(file_path) as f:
entry = _unique_child_group(f, snx.NXentry, None)
Expand Down
204 changes: 0 additions & 204 deletions src/ess/reduce/nexus/generic_types.py

This file was deleted.

Loading