|
1 | 1 | # SPDX-License-Identifier: BSD-3-Clause |
2 | 2 | # Copyright (c) 2023 Scipp contributors (https://github.com/scipp) |
3 | 3 | from datetime import datetime |
| 4 | +from math import isnan |
4 | 5 |
|
5 | 6 | import sciline |
| 7 | +import scipp as sc |
6 | 8 | from orsopy import fileio |
7 | 9 |
|
8 | 10 | from ess import amor, reflectometry |
9 | 11 | from ess.amor import data # noqa: F401 |
10 | 12 | from ess.reflectometry import orso |
11 | | -from ess.reflectometry.types import Filename, ReferenceRun, SampleRun |
| 13 | +from ess.reflectometry.types import Filename, ReducibleData, ReferenceRun, SampleRun |
12 | 14 |
|
13 | 15 |
|
14 | 16 | def test_build_orso_data_source(): |
@@ -54,3 +56,23 @@ def test_build_orso_reduction_with_creator(): |
54 | 56 | assert reduction.software.name == "ess.reflectometry" |
55 | 57 | assert reduction.software.version == str(reflectometry.__version__) |
56 | 58 | assert reduction.creator == creator |
| 59 | + |
| 60 | + |
| 61 | +def test_build_orso_aggregates_are_not_nan(): |
| 62 | + events = sc.DataArray( |
| 63 | + sc.array(dims='x', values=[1, 2, 3, 4]), |
| 64 | + coords={ |
| 65 | + 'theta': sc.array(dims='x', values=[0, 0.5, 1, float('nan')]), |
| 66 | + 'wavelength': sc.array(dims='x', values=[0, 0.5, 1, float('nan')]), |
| 67 | + }, |
| 68 | + ) |
| 69 | + pipeline = sciline.Pipeline( |
| 70 | + orso.providers, params={ReducibleData[SampleRun]: events} |
| 71 | + ) |
| 72 | + instrument = pipeline.compute(orso.OrsoInstrument) |
| 73 | + assert not any( |
| 74 | + isnan(getattr(instrument.incident_angle, attr)) for attr in ('min', 'max') |
| 75 | + ) |
| 76 | + assert not any( |
| 77 | + isnan(getattr(instrument.wavelength, attr)) for attr in ('min', 'max') |
| 78 | + ) |
0 commit comments