Skip to content

Commit d4f9d53

Browse files
authored
Merge pull request #574 from scipp/avoid-tof-clash
Add missing tof dependency, avoid tof clash and fix failing test in conda build
2 parents 7263415 + 91a9fdf commit d4f9d53

File tree

5 files changed

+27
-10
lines changed

5 files changed

+27
-10
lines changed

conda/meta.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ test:
3434
{% for package in test_dependencies %}
3535
- {% if package == "graphviz" %}python-graphviz{% else %}{{ package|replace(" ", "") }}{% endif %}
3636
{% endfor %}
37+
# Note that we add tof here because it depends on plopp, and plopp should not be in
38+
# basetest.in because of the nightly dependencies
39+
- tof
3740

3841
source_files:
3942
- pyproject.toml

src/scippneutron/tof/chopper_cascade.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,20 @@ class Frame:
146146
distance: sc.Variable
147147
subframes: list[Subframe]
148148

149+
def __eq__(self, other: object) -> bool:
150+
if not isinstance(other, Frame):
151+
return NotImplemented
152+
# Note: we don't use sc.identical here because it can fail on the dtype even
153+
# if the values are equal.
154+
same_distance = (
155+
np.array_equal(self.distance.values, other.distance.values)
156+
and self.distance.unit == other.distance.unit
157+
)
158+
return same_distance and all(
159+
self_sub == other_sub
160+
for self_sub, other_sub in zip(self.subframes, other.subframes, strict=True)
161+
)
162+
149163
def propagate_to(self, distance: sc.Variable) -> Frame:
150164
"""
151165
Compute new frame by propagating to a distance.

src/scippneutron/tof/fakes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def __init__(
241241
):
242242
import math
243243

244-
import tof
244+
import tof as tof_pkg
245245
from tof.facilities.ess_pulse import pulse
246246

247247
self.frequency = pulse.frequency
@@ -250,7 +250,7 @@ def __init__(
250250

251251
# Create a source
252252
if source is None:
253-
self.source = tof.Source(
253+
self.source = tof_pkg.Source(
254254
facility='ess', neutrons=self.events_per_pulse, pulses=self.npulses
255255
)
256256
else:
@@ -260,7 +260,7 @@ def __init__(
260260
angular_speed = sc.constants.pi * (2.0 * sc.units.rad) * self.frequency
261261

262262
self.choppers = [
263-
tof.Chopper(
263+
tof_pkg.Chopper(
264264
frequency=pulse.frequency,
265265
open=ch.time_open * angular_speed,
266266
close=ch.time_close * angular_speed,
@@ -273,12 +273,12 @@ def __init__(
273273

274274
# Add detectors
275275
self.monitors = [
276-
tof.Detector(distance=distance, name=key)
276+
tof_pkg.Detector(distance=distance, name=key)
277277
for key, distance in monitors.items()
278278
]
279279

280280
# Propagate the neutrons
281-
self.model = tof.Model(
281+
self.model = tof_pkg.Model(
282282
source=self.source, choppers=self.choppers, detectors=self.monitors
283283
)
284284
self.model_result = self.model.run()

tests/tof/wfm_dream_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pytest
77
import scipp as sc
8-
import tof
8+
import tof as tof_pkg
99

1010
from scippneutron.chopper import DiskChopper
1111
from scippneutron.conversion.graph.beamline import beamline
@@ -143,7 +143,7 @@ def test_dream_wfm(disk_choppers, npulses, ltotal):
143143
run_length=sc.scalar(1 / 14, unit="s") * npulses,
144144
events_per_pulse=len(wavelengths),
145145
source=partial(
146-
tof.Source.from_neutrons,
146+
tof_pkg.Source.from_neutrons,
147147
birth_times=birth_times,
148148
wavelengths=wavelengths,
149149
frequency=sc.scalar(14.0, unit="Hz"),
@@ -256,7 +256,7 @@ def test_dream_wfm_with_subframe_time_overlap(overlap_choppers, npulses, ltotal)
256256
run_length=sc.scalar(1 / 14, unit="s") * npulses,
257257
events_per_pulse=len(wavelengths),
258258
source=partial(
259-
tof.Source.from_neutrons,
259+
tof_pkg.Source.from_neutrons,
260260
birth_times=birth_times,
261261
wavelengths=wavelengths,
262262
frequency=sc.scalar(14.0, unit="Hz"),

tests/tof/wfm_v20_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import numpy as np
77
import pytest
88
import scipp as sc
9-
import tof
9+
import tof as tof_pkg
1010

1111
from scippneutron.chopper import DiskChopper
1212
from scippneutron.conversion.graph.beamline import beamline
@@ -131,7 +131,7 @@ def test_v20_compute_wavelengths_from_wfm(disk_choppers, npulses, ltotal):
131131
run_length=sc.scalar(1 / 14, unit="s") * npulses,
132132
events_per_pulse=len(wavelengths),
133133
source=partial(
134-
tof.Source.from_neutrons,
134+
tof_pkg.Source.from_neutrons,
135135
birth_times=birth_times,
136136
wavelengths=wavelengths,
137137
frequency=sc.scalar(14.0, unit="Hz"),

0 commit comments

Comments
 (0)