diff --git a/src/scippneutron/atoms/__init__.py b/src/scippneutron/atoms/__init__.py index 154081904..988a0bc95 100644 --- a/src/scippneutron/atoms/__init__.py +++ b/src/scippneutron/atoms/__init__.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2023 Scipp contributors (https://github.com/scipp) """Parameters for neutron interactions with atoms.""" + from __future__ import annotations import dataclasses diff --git a/src/scippneutron/data_streaming/_data_buffer.py b/src/scippneutron/data_streaming/_data_buffer.py index 21373ad02..2298f9e15 100644 --- a/src/scippneutron/data_streaming/_data_buffer.py +++ b/src/scippneutron/data_streaming/_data_buffer.py @@ -337,20 +337,20 @@ def init_metadata_buffers(self, stream_info: List[StreamInfo]): """ for stream in stream_info: if stream.flatbuffer_id == SLOW_FB_ID: - self._metadata_buffers[stream.flatbuffer_id][ - stream.source_name - ] = _SlowMetadataBuffer(stream, self._slow_metadata_buffer_size) + self._metadata_buffers[stream.flatbuffer_id][stream.source_name] = ( + _SlowMetadataBuffer(stream, self._slow_metadata_buffer_size) + ) elif stream.flatbuffer_id == FAST_FB_ID: - self._metadata_buffers[stream.flatbuffer_id][ - stream.source_name - ] = _FastMetadataBuffer( - stream, self._fast_metadata_buffer_size, self._emit_queue + self._metadata_buffers[stream.flatbuffer_id][stream.source_name] = ( + _FastMetadataBuffer( + stream, self._fast_metadata_buffer_size, self._emit_queue + ) ) elif stream.flatbuffer_id == CHOPPER_FB_ID: - self._metadata_buffers[stream.flatbuffer_id][ - stream.source_name - ] = _ChopperMetadataBuffer( - stream, self._chopper_buffer_size, self._emit_queue + self._metadata_buffers[stream.flatbuffer_id][stream.source_name] = ( + _ChopperMetadataBuffer( + stream, self._chopper_buffer_size, self._emit_queue + ) ) elif stream.flatbuffer_id == EVENT_FB_ID: pass # detection events, not metadata @@ -430,10 +430,9 @@ def _handled_event_data(self, new_data: bytes) -> bool: ] frame.coords['detector_id'].values = deserialised_data.detector_id frame.coords['tof'].values = deserialised_data.time_of_flight - frame.coords[ - 'pulse_time' - ].values = deserialised_data.pulse_time * np.ones_like( - deserialised_data.time_of_flight + frame.coords['pulse_time'].values = ( + deserialised_data.pulse_time + * np.ones_like(deserialised_data.time_of_flight) ) self._current_event += message_size except WrongSchemaException: diff --git a/src/scippneutron/io/cif.py b/src/scippneutron/io/cif.py index ff947a1d5..430da3597 100644 --- a/src/scippneutron/io/cif.py +++ b/src/scippneutron/io/cif.py @@ -481,7 +481,7 @@ def write(self, f: io.TextIOBase) -> None: def _convert_input_content( - content: Iterable[Union[Mapping[str, Any], Loop, Chunk]] + content: Iterable[Union[Mapping[str, Any], Loop, Chunk]], ) -> list[Union[Loop, Chunk]]: return [ item if isinstance(item, (Loop, Chunk)) else Chunk(item) for item in content @@ -498,7 +498,7 @@ def _open(fname: Union[str, Path, io.TextIOBase]): def _preprocess_schema( - schema: Optional[Union[CIFSchema, Iterable[CIFSchema]]] + schema: Optional[Union[CIFSchema, Iterable[CIFSchema]]], ) -> set[CIFSchema]: if schema is None: return set() diff --git a/src/scippneutron/tof/chopper_cascade.py b/src/scippneutron/tof/chopper_cascade.py index 2d6964a37..9a065495e 100644 --- a/src/scippneutron/tof/chopper_cascade.py +++ b/src/scippneutron/tof/chopper_cascade.py @@ -7,6 +7,7 @@ See :py:class:`FrameSequence` for the main entry point. """ + from __future__ import annotations from dataclasses import dataclass diff --git a/src/scippneutron/tof/fakes.py b/src/scippneutron/tof/fakes.py index 540d34d7e..0ddbdd28b 100644 --- a/src/scippneutron/tof/fakes.py +++ b/src/scippneutron/tof/fakes.py @@ -10,6 +10,7 @@ - Monitor event data including event_time_offset and event_time_zero - Chopper timestamps """ + from __future__ import annotations from typing import Optional diff --git a/src/scippneutron/tof/unwrap.py b/src/scippneutron/tof/unwrap.py index 6bb597d2a..e6ab788ce 100644 --- a/src/scippneutron/tof/unwrap.py +++ b/src/scippneutron/tof/unwrap.py @@ -10,6 +10,7 @@ functions defined here are meant to be used as providers for a Sciline pipeline. See https://scipp.github.io/sciline/ on how to use Sciline. """ + import math from dataclasses import dataclass from typing import Callable, Mapping, NewType, Optional, Tuple, Union diff --git a/tests/atoms/test_atoms.py b/tests/atoms/test_atoms.py index bd9153dfb..6d865e391 100644 --- a/tests/atoms/test_atoms.py +++ b/tests/atoms/test_atoms.py @@ -37,9 +37,7 @@ def test_scattering_params_157gd(): incoherent_scattering_cross_section=sc.scalar( 394.0, variance=7.0**2, unit='barn' ), - total_scattering_cross_section=sc.scalar( - 1044.0, variance=8.0**2, unit='barn' - ), + total_scattering_cross_section=sc.scalar(1044.0, variance=8.0**2, unit='barn'), absorption_cross_section=sc.scalar(259000.0, variance=700.0**2, unit='barn'), ) assert params == expected diff --git a/tests/data_stream_test.py b/tests/data_stream_test.py index d94cc1905..00cfbe65e 100644 --- a/tests/data_stream_test.py +++ b/tests/data_stream_test.py @@ -40,8 +40,10 @@ from streaming_data_types.timestamps_tdct import serialise_tdct from scippneutron.data_streaming._consumer import RunStartError - from scippneutron.data_streaming.data_stream import _data_stream # noqa: E402 - from scippneutron.data_streaming.data_stream import StopTime + from scippneutron.data_streaming.data_stream import ( + StopTime, + _data_stream, # noqa: E402 + ) except ImportError: pytest.skip("Kafka or Serialisation module is unavailable", allow_module_level=True)