Skip to content

v0.20.0

@g5t g5t tagged this 16 Mar 12:07
* Add Coords accessor and improve ScanOutput/RunOutput API

- Add Coords(Mapping) class in range.py for xarray-like axis access:
  - coords['a'] and coords.a both return MRange/EList/Singular
  - __repr__ shows each axis name, type, and range/len summary
- Fix _make_scanned_parameter to handle bracket-string notation
  e.g. '[100,200,1000]' now correctly parses to EList([100,200,1000])
- ScanOutput gains:
  - axes: dict[str, Any] field (normalized ParameterValues per parameter)
  - coords property → Coords(self.axes)
  - shape property → (len_a, len_b,...) for grid; (n,) for zip
  - ndim property → len(axes) for grid; 1 for zip
  - __len__ and __iter__ delegating to points
- RunOutput gains coords property wrapping parameters as Singular values
  for a consistent interface with ScanOutput.coords
- simulation.scan() now returns ScanOutput instead of bare list;
  return type annotation updated; docstring updated
- Export Coords, RunOutput, ScanOutput, MRange, EList, Singular from
  run/__init__.py
- Update test_simulation_api.py to use new RunOutput/ScanOutput API
  instead of tuple unpacking
- Add tests/test_run_output.py: 29 tests covering Coords, bracket
  parsing, ScanOutput.coords/shape/ndim, RunOutput.coords, exports

Refactor DatFile classes to use scipp; add RunOutput/ScanOutput monitor access

- Replace numpy array storage in DatFile0D/1D/2D with scipp Dataset as
  primary representation: I with variances=I_err², N as named variables,
  bin positions as labelled scipp coordinates with physical units
- Add src/mccode_antlr/loader/_units.py: McCode → scipp unit mapping
  (AA→angstrom, AA^-1→1/angstrom, \gms/microseconds→us, etc.)
- Backward-compat .data and .variables properties preserved on DatFileCommon
- __add__ now uses scipp arithmetic for correct error-in-quadrature propagation
- Add RunOutput.dats property and __getitem__ passthrough to SimulationOutput
- Add ScanOutput.__getitem__(str) dispatching to _concat_monitor, which
  uses sc.concat + sc.fold to build a labelled Dataset across scan points
- Fix simulation.scan() to wrap raw results as RunOutput objects with
  per-point parameter dicts; handle empty-parameter edge case
- Update test_simulation_api.py to use new RunOutput API instead of
  old (result, SimulationOutput) tuple-unpacking
- Add tests/test_datfile_scipp.py: 33 tests covering DatFile0D/1D/2D
  structure, coords, units, backward compat, __add__, and unit mapping
- Add scipp as [scipp] optional extra in pyproject.toml

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

[Fix] the DatFile.data property previously held a 3xN array; but should be deprecated

* [Fix] deprecated from typing_extensions for pre-3.13 Python
Assets 2
Loading