11# SPDX-License-Identifier: BSD-3-Clause
22# Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
33from datetime import UTC , datetime
4+ from pathlib import Path
45
56import pytest
67import scipp as sc
78import scippnexus as snx
89from scipp .testing import assert_identical
910
10- from ess .reduce import data
1111from ess .reduce .nexus import compute_component_position , workflow
1212from ess .reduce .nexus .types import (
1313 BackgroundRun ,
@@ -176,11 +176,11 @@ def test_to_transform_raises_if_interval_does_not_yield_unique_value(
176176 )
177177
178178
179- def test_given_no_sample_load_nexus_sample_returns_group_with_origin_depends_on () -> (
180- None
181- ):
179+ def test_given_no_sample_load_nexus_sample_returns_group_with_origin_depends_on (
180+ loki_tutorial_sample_run_60250 : Path ,
181+ ) -> None :
182182 filespec = workflow .file_path_to_file_spec (
183- data . loki_tutorial_sample_run_60250 () , preopen = True
183+ loki_tutorial_sample_run_60250 , preopen = True
184184 )
185185 spec = workflow .unique_component_spec (filespec )
186186 assert spec .filename ['/entry' ][snx .NXsample ] == {}
@@ -549,9 +549,9 @@ def test_assemble_monitor_preserves_masks(calibrated_monitor, monitor_event_data
549549 assert 'mymask' in monitor_data .masks
550550
551551
552- def test_load_event_monitor_workflow () -> None :
552+ def test_load_event_monitor_workflow (loki_tutorial_sample_run_60250 : Path ) -> None :
553553 wf = LoadMonitorWorkflow (run_types = [SampleRun ], monitor_types = [FrameMonitor1 ])
554- wf [Filename [SampleRun ]] = data . loki_tutorial_sample_run_60250 ()
554+ wf [Filename [SampleRun ]] = loki_tutorial_sample_run_60250
555555 wf [NeXusName [FrameMonitor1 ]] = 'monitor_1'
556556 da = wf .compute (MonitorData [SampleRun , FrameMonitor1 ])
557557 assert 'position' in da .coords
@@ -561,9 +561,9 @@ def test_load_event_monitor_workflow() -> None:
561561 assert da .bins .constituents ['data' ].variances is not None
562562
563563
564- def test_load_histogram_monitor_workflow () -> None :
564+ def test_load_histogram_monitor_workflow (dream_coda_test_file : Path ) -> None :
565565 wf = LoadMonitorWorkflow (run_types = [SampleRun ], monitor_types = [FrameMonitor1 ])
566- wf [Filename [SampleRun ]] = data . dream_coda_test_file ()
566+ wf [Filename [SampleRun ]] = dream_coda_test_file
567567 wf [NeXusName [FrameMonitor1 ]] = 'monitor_bunker'
568568 da = wf .compute (MonitorData [SampleRun , FrameMonitor1 ])
569569 assert 'position' in da .coords
@@ -575,9 +575,9 @@ def test_load_histogram_monitor_workflow() -> None:
575575 assert da .variances is not None
576576
577577
578- def test_load_detector_workflow () -> None :
578+ def test_load_detector_workflow (loki_tutorial_sample_run_60250 : Path ) -> None :
579579 wf = LoadDetectorWorkflow (run_types = [SampleRun ], monitor_types = [])
580- wf [Filename [SampleRun ]] = data . loki_tutorial_sample_run_60250 ()
580+ wf [Filename [SampleRun ]] = loki_tutorial_sample_run_60250
581581 wf [NeXusName [snx .NXdetector ]] = 'larmor_detector'
582582 da = wf .compute (DetectorData [SampleRun ])
583583 assert 'position' in da .coords
@@ -588,9 +588,11 @@ def test_load_detector_workflow() -> None:
588588
589589
590590@pytest .mark .parametrize ('preopen' , [True , False ])
591- def test_generic_nexus_workflow (preopen : bool ) -> None :
591+ def test_generic_nexus_workflow (
592+ preopen : bool , loki_tutorial_sample_run_60250 : Path
593+ ) -> None :
592594 wf = GenericNeXusWorkflow (run_types = [SampleRun ], monitor_types = [FrameMonitor1 ])
593- wf [Filename [SampleRun ]] = data . loki_tutorial_sample_run_60250 ()
595+ wf [Filename [SampleRun ]] = loki_tutorial_sample_run_60250
594596 wf [NeXusName [FrameMonitor1 ]] = 'monitor_1'
595597 wf [NeXusName [snx .NXdetector ]] = 'larmor_detector'
596598 wf [PreopenNeXusFile ] = preopen
@@ -607,9 +609,9 @@ def test_generic_nexus_workflow(preopen: bool) -> None:
607609 assert da .dims == ('event_time_zero' ,)
608610
609611
610- def test_generic_nexus_workflow_load_choppers () -> None :
612+ def test_generic_nexus_workflow_load_choppers (bifrost_simulated_elastic : Path ) -> None :
611613 wf = GenericNeXusWorkflow (run_types = [SampleRun ], monitor_types = [])
612- wf [Filename [SampleRun ]] = data . bifrost_simulated_elastic ()
614+ wf [Filename [SampleRun ]] = bifrost_simulated_elastic
613615 choppers = wf .compute (RawChoppers [SampleRun ])
614616
615617 assert choppers .keys () == {
@@ -626,20 +628,24 @@ def test_generic_nexus_workflow_load_choppers() -> None:
626628 assert chopper ['slit_edges' ].shape == (2 ,)
627629
628630
629- def test_generic_nexus_workflow_load_beamline_metadata () -> None :
631+ def test_generic_nexus_workflow_load_beamline_metadata (
632+ bifrost_simulated_elastic : Path ,
633+ ) -> None :
630634 wf = GenericNeXusWorkflow (run_types = [SampleRun ], monitor_types = [])
631- wf [Filename [SampleRun ]] = data . bifrost_simulated_elastic ()
635+ wf [Filename [SampleRun ]] = bifrost_simulated_elastic
632636 beamline = wf .compute (Beamline )
633637
634638 assert beamline .name == 'BIFROST'
635639 assert beamline .facility == 'ESS'
636640 assert beamline .site == 'ESS'
637641
638642
639- def test_generic_nexus_workflow_load_measurement_metadata () -> None :
643+ def test_generic_nexus_workflow_load_measurement_metadata (
644+ loki_tutorial_sample_run_60250 : Path , loki_tutorial_background_run_60248 : Path
645+ ) -> None :
640646 wf = GenericNeXusWorkflow (run_types = [SampleRun ], monitor_types = [])
641- wf [Filename [SampleRun ]] = data . loki_tutorial_sample_run_60250 ()
642- wf [Filename [BackgroundRun ]] = data . loki_tutorial_background_run_60248 ()
647+ wf [Filename [SampleRun ]] = loki_tutorial_sample_run_60250
648+ wf [Filename [BackgroundRun ]] = loki_tutorial_background_run_60248
643649 measurement = wf .compute (Measurement )
644650
645651 assert measurement .title == 'My experiment'
0 commit comments