essreduce 26.1.0__py3-none-any.whl → 26.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ess/reduce/streaming.py CHANGED
@@ -108,6 +108,14 @@ class Accumulator(ABC, Generic[T]):
108
108
  Clear the accumulator, resetting it to its initial state.
109
109
  """
110
110
 
111
+ def on_finalize(self) -> None:
112
+ """
113
+ Called after finalize retrieves value.
114
+
115
+ Override this method to perform custom cleanup after each finalize cycle.
116
+ The default implementation does nothing.
117
+ """
118
+
111
119
 
112
120
  class EternalAccumulator(Accumulator[T]):
113
121
  """
@@ -422,6 +430,9 @@ class StreamProcessor:
422
430
  needs_recompute |= self._context_key_to_cached_context_nodes_map[key]
423
431
  for key, value in context.items():
424
432
  self._context_workflow[key] = value
433
+ # Propagate context values to finalize workflow so providers that depend
434
+ # on context keys receive the updated values during finalize().
435
+ self._finalize_workflow[key] = value
425
436
  results = self._context_workflow.compute(needs_recompute)
426
437
  for key, value in results.items():
427
438
  if key in self._target_keys:
@@ -505,7 +516,10 @@ class StreamProcessor:
505
516
  """
506
517
  for key in self._accumulators:
507
518
  self._finalize_workflow[key] = self._accumulators[key].value
508
- return self._finalize_workflow.compute(self._target_keys)
519
+ result = self._finalize_workflow.compute(self._target_keys)
520
+ for acc in self._accumulators.values():
521
+ acc.on_finalize()
522
+ return result
509
523
 
510
524
  def clear(self) -> None:
511
525
  """
@@ -30,9 +30,6 @@ class SimulationResults:
30
30
  time_of_arrival:
31
31
  Time of arrival of the neutrons at the position where the events were recorded
32
32
  (1d array of size N).
33
- speed:
34
- Speed of the neutrons, typically derived from the wavelength of the neutrons
35
- (1d array of size N).
36
33
  wavelength:
37
34
  Wavelength of the neutrons (1d array of size N).
38
35
  weight:
@@ -48,12 +45,14 @@ class SimulationResults:
48
45
  """
49
46
 
50
47
  time_of_arrival: sc.Variable
51
- speed: sc.Variable
52
48
  wavelength: sc.Variable
53
49
  weight: sc.Variable
54
50
  distance: sc.Variable
55
51
  choppers: DiskChoppers[AnyRun] | None = None
56
52
 
53
+ def __post_init__(self):
54
+ self.speed = (sc.constants.h / sc.constants.m_n) / self.wavelength
55
+
57
56
 
58
57
  NumberOfSimulatedNeutrons = NewType("NumberOfSimulatedNeutrons", int)
59
58
  """
@@ -239,7 +238,7 @@ def make_tof_lookup_table(
239
238
  ----------
240
239
  simulation:
241
240
  Results of a time-of-flight simulation used to create a lookup table.
242
- The results should be a flat table with columns for time-of-arrival, speed,
241
+ The results should be a flat table with columns for time-of-arrival,
243
242
  wavelength, and weight.
244
243
  ltotal_range:
245
244
  Range of total flight path lengths from the source to the detector.
@@ -436,7 +435,6 @@ def simulate_chopper_cascade_using_tof(
436
435
  events = source.data.squeeze().flatten(to='event')
437
436
  return SimulationResults(
438
437
  time_of_arrival=events.coords["birth_time"],
439
- speed=events.coords["speed"],
440
438
  wavelength=events.coords["wavelength"],
441
439
  weight=events.data,
442
440
  distance=0.0 * sc.units.m,
@@ -451,7 +449,6 @@ def simulate_chopper_cascade_using_tof(
451
449
  ]
452
450
  return SimulationResults(
453
451
  time_of_arrival=events.coords["toa"],
454
- speed=events.coords["speed"],
455
452
  wavelength=events.coords["wavelength"],
456
453
  weight=events.data,
457
454
  distance=furthest_chopper.distance,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: essreduce
3
- Version: 26.1.0
3
+ Version: 26.1.1
4
4
  Summary: Common data reduction tools for the ESS facility
5
5
  Author: Scipp contributors
6
6
  License-Expression: BSD-3-Clause
@@ -3,7 +3,7 @@ ess/reduce/logging.py,sha256=6n8Czq4LZ3OK9ENlKsWSI1M3KvKv6_HSoUiV4__IUlU,357
3
3
  ess/reduce/normalization.py,sha256=r8H6SZgT94a1HE9qZ6Bx3N6c3VG3FzlJPzoCVMNI5-0,13081
4
4
  ess/reduce/parameter.py,sha256=4sCfoKOI2HuO_Q7JLH_jAXnEOFANSn5P3NdaOBzhJxc,4635
5
5
  ess/reduce/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- ess/reduce/streaming.py,sha256=zbqxQz5dASDq4ZVyx-TdbapBXMyBttImCYz_6WOj4pg,17978
6
+ ess/reduce/streaming.py,sha256=s-Pz6fhnaUPMjJ_lvSIdwF8WZjTK48lMDKQmCnqZf3c,18529
7
7
  ess/reduce/ui.py,sha256=zmorAbDwX1cU3ygDT--OP58o0qU7OBcmJz03jPeYSLA,10884
8
8
  ess/reduce/uncertainty.py,sha256=LR4O6ApB6Z-W9gC_XW0ajupl8yFG-du0eee1AX_R-gk,6990
9
9
  ess/reduce/workflow.py,sha256=738-lcdgsORYfQ4A0UTk2IgnbVxC3jBdpscpaOFIpdc,3114
@@ -25,7 +25,7 @@ ess/reduce/time_of_flight/eto_to_tof.py,sha256=imKuN7IARMqBjmi8kjAcsseTFg6OD8ORa
25
25
  ess/reduce/time_of_flight/fakes.py,sha256=BqpO56PQyO9ua7QlZw6xXMAPBrqjKZEM_jc-VB83CyE,4289
26
26
  ess/reduce/time_of_flight/interpolator_numba.py,sha256=wh2YS3j2rOu30v1Ok3xNHcwS7t8eEtZyZvbfXOCtgrQ,3835
27
27
  ess/reduce/time_of_flight/interpolator_scipy.py,sha256=_InoAPuMm2qhJKZQBAHOGRFqtvvuQ8TStoN7j_YgS4M,1853
28
- ess/reduce/time_of_flight/lut.py,sha256=8AupwtfB2983DoyzFgnRjWP3J3s_oPghi3XlXaaxxow,18768
28
+ ess/reduce/time_of_flight/lut.py,sha256=aFaP6CnbTVkScTfCkyvyKt7PCZcJjUNdlS9l-sLHr8c,18637
29
29
  ess/reduce/time_of_flight/resample.py,sha256=Opmi-JA4zNH725l9VB99U4O9UlM37f5ACTCGtwBcows,3718
30
30
  ess/reduce/time_of_flight/types.py,sha256=FsSueM6OjJdF80uJHj-TNuyVAci8ixFvMuRMt9oHKDQ,3310
31
31
  ess/reduce/time_of_flight/workflow.py,sha256=2jUxeSmP0KweQTctAzIFJLm7Odf_e7kZzAc8MAMKBEs,3084
@@ -41,9 +41,9 @@ ess/reduce/widgets/_spinner.py,sha256=2VY4Fhfa7HMXox2O7UbofcdKsYG-AJGrsgGJB85nDX
41
41
  ess/reduce/widgets/_string_widget.py,sha256=iPAdfANyXHf-nkfhgkyH6gQDklia0LebLTmwi3m-iYQ,1482
42
42
  ess/reduce/widgets/_switchable_widget.py,sha256=fjKz99SKLhIF1BLgGVBSKKn3Lu_jYBwDYGeAjbJY3Q8,2390
43
43
  ess/reduce/widgets/_vector_widget.py,sha256=aTaBqCFHZQhrIoX6-sSqFWCPePEW8HQt5kUio8jP1t8,1203
44
- essreduce-26.1.0.dist-info/licenses/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
45
- essreduce-26.1.0.dist-info/METADATA,sha256=WTZ9G8OVIHDjHsgeW9zgv-XJBv6mzYc5HAlxBY-5uXQ,1987
46
- essreduce-26.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
- essreduce-26.1.0.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
48
- essreduce-26.1.0.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
49
- essreduce-26.1.0.dist-info/RECORD,,
44
+ essreduce-26.1.1.dist-info/licenses/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
45
+ essreduce-26.1.1.dist-info/METADATA,sha256=fwMRSA5kTQ26OFwAM_7xjpvdcz-C3KMiC02MK153XTE,1987
46
+ essreduce-26.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
47
+ essreduce-26.1.1.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
48
+ essreduce-26.1.1.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
49
+ essreduce-26.1.1.dist-info/RECORD,,