From 9d3af2199d9f7c6fd0cb8435108d3b6d9d5b1648 Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Tue, 3 Mar 2026 11:16:13 +0100 Subject: [PATCH 1/2] fix: make sure coord remains after binnning --- src/ess/beer/clustering.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ess/beer/clustering.py b/src/ess/beer/clustering.py index e37395dc..405ef4e8 100644 --- a/src/ess/beer/clustering.py +++ b/src/ess/beer/clustering.py @@ -22,6 +22,9 @@ def cluster_events_by_streak( # adding them to the binned data coords achieves this. for coord in ('two_theta', 'Ltotal'): da.bins.coords[coord] = sc.bins_like(da, da.coords[coord]) + # Making them scalar also keeps them after binning, + # but without having to store them for each event. + da.coords['tc'] = da.coords['tc'].mean() h = da.bins.concat().hist(coarse_d=1000) i_peaks, _ = find_peaks( From e525a3ba86ce135c76881416b2ec1f6a549f1adf Mon Sep 17 00:00:00 2001 From: Johannes Kasimir Date: Tue, 3 Mar 2026 13:30:12 +0100 Subject: [PATCH 2/2] test: skip if cif-db not reachable --- tests/diffraction/test_peaks.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/diffraction/test_peaks.py b/tests/diffraction/test_peaks.py index c77b47a3..b58e9026 100644 --- a/tests/diffraction/test_peaks.py +++ b/tests/diffraction/test_peaks.py @@ -1,8 +1,23 @@ +import urllib.request + +import pytest import scipp as sc from ess.diffraction.peaks import dspacing_peaks_from_cif +def _cifdb_is_reachable(timeout=5): + try: + req = urllib.request.Request('http://cod.ibt.lt', method="HEAD") + with urllib.request.urlopen(req, timeout=timeout): # noqa: S310 + return True + except Exception: + return False + + +@pytest.mark.skipif( + not _cifdb_is_reachable(), reason='The CIF database can not be reached.' +) def test_retreived_peak_list_has_expected_units(): d = dspacing_peaks_from_cif( 'codid::9011998', @@ -12,6 +27,9 @@ def test_retreived_peak_list_has_expected_units(): assert d.unit == 'barn' +@pytest.mark.skipif( + not _cifdb_is_reachable(), reason='The CIF database can not be reached.' +) def test_intensity_threshold_is_taken_into_account(): d = dspacing_peaks_from_cif( 'codid::9011998', @@ -26,6 +44,9 @@ def test_intensity_threshold_is_taken_into_account(): assert len(d) == 0 +@pytest.mark.skipif( + not _cifdb_is_reachable(), reason='The CIF database can not be reached.' +) def test_retreived_peak_list_with_temperature_kwarg(): d = dspacing_peaks_from_cif( 'codid::9011998', sc.scalar(50, unit='barn'), uiso_temperature=300