Skip to content

Commit

Permalink
Merge pull request #175 from scipp/remove-unused
Browse files Browse the repository at this point in the history
Remove unused helper function
  • Loading branch information
SimonHeybrock authored Nov 2, 2023
2 parents a4e8aef + 3288293 commit efb6e55
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 38 deletions.
1 change: 0 additions & 1 deletion src/scippnexus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
from .field import Attrs, Field
from .file import File
from .nexus_classes import *
from .nxdata import group_events_by_detector_number
38 changes: 1 addition & 37 deletions src/scippnexus/nxdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import uuid
from functools import cached_property
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
from typing import Any, Dict, Iterable, Optional, Tuple, Union

import numpy as np
import scipp as sc
Expand Down Expand Up @@ -668,42 +668,6 @@ def _group_events(
return event_data.fold(dim='event_id', sizes=grouping.sizes)


def _find_event_entries(dg: sc.DataGroup) -> List[str]:
event_entries = []
for name, value in dg.items():
if (
isinstance(value, sc.DataArray)
and 'event_time_zero' in value.coords
and value.bins is not None
):
event_entries.append(name)
return event_entries


def group_events_by_detector_number(
dg: sc.DataGroup,
) -> Union[sc.DataArray, sc.Dataset]:
dg = dg.copy(deep=False)
grouping_key = None
for key in NXdetector._detector_number_fields:
if (grouping := dg.get(key)) is not None:
grouping_key = key
break
grouping = None if grouping_key is None else asvariable(dg.pop(grouping_key))
grouped_events = sc.DataGroup()
for event_entry in _find_event_entries(dg):
events = dg.pop(event_entry)
grouped_events[event_entry] = _group_events(
event_data=events, grouping=grouping
)
if len(grouped_events) == 1:
out = next(iter(grouped_events.values()))
else:
out = sc.Dataset(grouped_events)
out.coords.update(dg)
return out


base_definitions_dict['NXdata'] = NXdata
base_definitions_dict['NXlog'] = NXlog
base_definitions_dict['NXdetector'] = NXdetector
Expand Down

0 comments on commit efb6e55

Please sign in to comment.