diff --git a/.copier-answers.yml b/.copier-answers.yml index b2d9f271..2411a117 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: 8484c9e +_commit: 7afbc9a _src_path: gh:scipp/copier_template description: Diffraction data reduction for the European Spallation Source max_python: '3.12' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4b1d1114..44266a23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ jobs: run: | echo "min_python=$(cat .github/workflows/python-version-ci)" >> $GITHUB_OUTPUT echo "min_tox_env=py$(cat .github/workflows/python-version-ci | sed 's/\.//g')" >> $GITHUB_OUTPUT - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: '.github/workflows/python-version-ci' - uses: pre-commit/action@v3.0.1 diff --git a/.github/workflows/copier.yml b/.github/workflows/copier.yml new file mode 100644 index 00000000..b1fe6ce4 --- /dev/null +++ b/.github/workflows/copier.yml @@ -0,0 +1,25 @@ +name: Copier template sync + +on: + workflow_dispatch: + schedule: + - cron: '0 1 * * 1' + +jobs: + update: + name: Sync with copier template + runs-on: 'ubuntu-latest' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 + with: + python-version: '3.X' + - run: pip install copier + - run: copier update --skip-answered --vcs-ref=HEAD --conflict=rej + - name: Create Pull Request + uses: peter-evans/create-pull-request@v6 + with: + title: '[CRON] Sync with copier template' + body: | + This PR updates the project to the latest version of scipp's [copier-template](https://github.com/scipp/copier_template). + Remember to check for any conflicts and resolve them. diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d24932b1..7e5a7bc6 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -47,8 +47,9 @@ jobs: - uses: actions/checkout@v4 with: ref: ${{ inputs.branch == '' && github.ref_name || inputs.branch }} + repository: ${{ github.event.pull_request.head.repo.full_name }} fetch-depth: 0 # history required so cmake can determine version - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: '.github/workflows/python-version-ci' - run: python -m pip install --upgrade pip @@ -59,12 +60,12 @@ jobs: if: ${{ inputs.version == '' }} - run: tox -e linkcheck if: ${{ inputs.linkcheck }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: docs_html path: html/ - - uses: JamesIves/github-pages-deploy-action@v4.5.0 + - uses: JamesIves/github-pages-deploy-action@v4.6.0 if: ${{ inputs.publish }} with: branch: gh-pages diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2eec2f00..d1317a76 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,7 +28,7 @@ jobs: boa - run: conda mambabuild --channel conda-forge --channel scipp --no-anaconda-upload --override-channels --output-folder conda/package conda - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: conda-package-noarch path: conda/package/noarch/*.tar.bz2 @@ -42,7 +42,7 @@ jobs: with: fetch-depth: 0 # history required so setuptools_scm can determine version - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version-file: '.github/workflows/python-version-ci' @@ -53,7 +53,7 @@ jobs: run: python -m build - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: dist path: dist @@ -67,7 +67,7 @@ jobs: id-token: write if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 - uses: pypa/gh-action-pypi-publish@v1.8.14 upload_conda: @@ -77,7 +77,7 @@ jobs: if: github.event_name == 'release' && github.event.action == 'published' steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 - uses: mamba-org/setup-micromamba@v1 with: environment-name: upload-env @@ -101,7 +101,7 @@ jobs: permissions: contents: write # This is needed so that the action can upload the asset steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 - name: Zip documentation run: | mv docs_html documentation-${{ github.ref_name }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3638e922..5f56a069 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -54,7 +54,7 @@ jobs: - run: python -m pip install --upgrade pip - run: python -m pip install -r ${{ inputs.pip-recipe }} - run: tox -e ${{ inputs.tox-env }} - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 if: ${{ inputs.coverage-report }} with: name: CoverageReport diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 19830db7..508073fe 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,15 +13,6 @@ repos: - id: trailing-whitespace args: [ --markdown-linebreak-ext=md ] exclude: '\.svg' - - repo: https://github.com/pycqa/isort - rev: 5.12.0 - hooks: - - id: isort - name: isort (python) - - repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.11.0 - hooks: - - id: black - repo: https://github.com/kynan/nbstripout rev: 0.6.0 hooks: @@ -29,18 +20,14 @@ repos: types: [ "jupyter" ] args: [ "--drop-empty-cells", "--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'" ] - - repo: https://github.com/pycqa/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - types: ["python"] - additional_dependencies: ["flake8-bugbear==23.9.16"] - - repo: https://github.com/pycqa/bandit - rev: 1.7.5 - hooks: - - id: bandit - additional_dependencies: ["bandit[toml]"] - args: ["-c", "pyproject.toml"] + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.4.1 + hooks: + - id: ruff + args: [ --fix ] + types_or: [ python, pyi, jupyter ] + - id: ruff-format + types_or: [ python, pyi ] - repo: https://github.com/codespell-project/codespell rev: v2.2.6 hooks: diff --git a/conda/meta.yaml b/conda/meta.yaml index 8065e193..593981f5 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -6,6 +6,11 @@ package: source: path: .. + +{% set pyproject = load_file_data('pyproject.toml') %} +{% set dependencies = pyproject.get('project', {}).get('dependencies', {}) %} + + requirements: build: - setuptools @@ -23,6 +28,11 @@ requirements: - scippnexus>=23.12.0 - python>=3.10 + {% for package in dependencies %} + - {% if package == "graphviz" %}python-graphviz{% else %}{{ package }}{% endif %} + {% endfor %} + + test: imports: - ess.diffraction diff --git a/docs/conf.py b/docs/conf.py index 5ae0e872..17b45932 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -3,15 +3,14 @@ import doctest import os import sys - -from ess import diffraction +from importlib.metadata import version as get_version sys.path.insert(0, os.path.abspath('.')) # General information about the project. -project = u'ESSdiffraction' -copyright = u'2024 Scipp contributors' -author = u'Scipp contributors' +project = 'ESSdiffraction' +copyright = '2024 Scipp contributors' +author = 'Scipp contributors' html_show_sourcelink = True @@ -112,10 +111,8 @@ # built documents. # -# The short X.Y version. -version = diffraction.__version__ -# The full version, including alpha/beta/rc tags. -release = diffraction.__version__ +release = get_version("essdiffraction") +version = ".".join(release.split('.')[:3]) # CalVer warning_is_error = True diff --git a/docs/developer/coding-conventions.md b/docs/developer/coding-conventions.md index b23c0eb4..4fafc18d 100644 --- a/docs/developer/coding-conventions.md +++ b/docs/developer/coding-conventions.md @@ -2,7 +2,7 @@ ## Code formatting -There are no explicit code formatting conventions since we use `black` to enforce a format. +There are no explicit code formatting conventions since we use `ruff` to enforce a format. ## Docstring format diff --git a/docs/user-guide/dream/dream-data-reduction.ipynb b/docs/user-guide/dream/dream-data-reduction.ipynb index 91095402..06cd8586 100644 --- a/docs/user-guide/dream/dream-data-reduction.ipynb +++ b/docs/user-guide/dream/dream-data-reduction.ipynb @@ -15,8 +15,6 @@ "metadata": {}, "outputs": [], "source": [ - "from pathlib import Path\n", - "\n", "import scipp as sc\n", "import scippneutron as scn\n", "import sciline\n", diff --git a/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb b/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb index dbdd7dbd..f7853190 100644 --- a/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb +++ b/docs/user-guide/sns-instruments/POWGEN_data_reduction.ipynb @@ -26,7 +26,6 @@ "import scippneutron as scn\n", "import sciline\n", "\n", - "import ess.diffraction\n", "from ess import powder\n", "from ess.powder.external import powgen\n", "from ess.powder.types import *" diff --git a/pyproject.toml b/pyproject.toml index ab54e69f..6d99d653 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,17 +67,43 @@ filterwarnings = [ 'ignore:\s*Pyarrow will become a required dependency of pandas:DeprecationWarning', ] -[tool.bandit] -# Excluding tests because bandit doesn't like `assert`. -exclude_dirs = ["docs/conf.py", "tests"] +[tool.ruff] +line-length = 88 +extend-include = ["*.ipynb"] +extend-exclude = [ + ".*", "__pycache__", "build", "dist", "install", +] + +[tool.ruff.lint] +# See https://docs.astral.sh/ruff/rules/ +select = ["B", "C4", "DTZ", "E", "F", "G", "I", "PERF", "PGH", "PT", "PYI", "RUF", "S", "T20", "W"] +ignore = [ + # Conflict with ruff format, see + # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules + "COM812", "COM819", "D206", "D300", "E111", "E114", "E117", "ISC001", "ISC002", "Q000", "Q001", "Q002", "Q003", "W191", +] +fixable = ["I001", "B010"] +isort.known-first-party = ["essdiffraction"] +pydocstyle.convention = "numpy" -[tool.black] -skip-string-normalization = true +[tool.ruff.lint.per-file-ignores] +# those files have an increased risk of relying on import order +"__init__.py" = ["I"] +"tests/*" = [ + "S101", # asserts are fine in tests + "B018", # 'useless expressions' are ok because some tests just check for exceptions +] +"*.ipynb" = [ + "E501", # longer lines are sometimes more readable + "F403", # *-imports used with domain types + "F405", # linter may fail to find names because of *-imports + "I", # we don't collect imports at the top + "S101", # asserts are used for demonstration and are safe in notebooks + "T201", # printing is ok for demonstration purposes +] -[tool.isort] -skip_gitignore = true -profile = "black" -known_first_party = ["essdiffraction"] +[tool.ruff.format] +quote-style = "preserve" [tool.mypy] strict = true @@ -87,5 +113,4 @@ enable_error_code = [ "redundant-expr", "truthy-bool", ] -show_error_codes = true warn_unreachable = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 1ba190c5..00000000 --- a/setup.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -# See https://black.readthedocs.io/en/stable/the_black_code_style/current_style.html#line-length -max-line-length = 88 -extend-ignore = E203 diff --git a/src/ess/diffraction/__init__.py b/src/ess/diffraction/__init__.py index f101246f..c42366fc 100644 --- a/src/ess/diffraction/__init__.py +++ b/src/ess/diffraction/__init__.py @@ -1,5 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2024 Scipp contributors (https://github.com/scipp) +# ruff: noqa: E402, F401 """ Components for diffraction experiments (powder and single crystal). diff --git a/src/ess/dream/__init__.py b/src/ess/dream/__init__.py index 55445452..bb50dc01 100644 --- a/src/ess/dream/__init__.py +++ b/src/ess/dream/__init__.py @@ -4,6 +4,7 @@ """ Components for DREAM """ + import importlib.metadata from . import beamline, data diff --git a/src/ess/dream/instrument_view.py b/src/ess/dream/instrument_view.py index 06294535..fedb9bde 100644 --- a/src/ess/dream/instrument_view.py +++ b/src/ess/dream/instrument_view.py @@ -116,9 +116,9 @@ def _add_module_control(self): self.fig = self.scatter[0] self.cutting_tool = self.scatter[1] - self.artist_mapping = { - name: key for name, key in zip(self.data.keys(), self.fig.artists.keys()) - } + self.artist_mapping = dict( + zip(self.data.keys(), self.fig.artists.keys(), strict=True) + ) self.checkboxes = { key: ipw.Checkbox( value=True, @@ -130,8 +130,10 @@ def _add_module_control(self): } self.modules_widget = ipw.HBox( - [ipw.HTML(value="Modules:     ")] - + list(self.checkboxes.values()) + [ + ipw.HTML(value="Modules:     "), + *self.checkboxes.values(), + ] ) for key, ch in self.checkboxes.items(): ch.key = key diff --git a/src/ess/dream/io/geant4.py b/src/ess/dream/io/geant4.py index 63a5dbcd..6a671697 100644 --- a/src/ess/dream/io/geant4.py +++ b/src/ess/dream/io/geant4.py @@ -8,8 +8,6 @@ import numpy as np import sciline import scipp as sc -from ess.reduce.nexus import extract_detector_data - from ess.powder.types import ( DetectorName, FilePath, @@ -17,6 +15,7 @@ RawDetectorData, RunType, ) +from ess.reduce.nexus import extract_detector_data MANTLE_DETECTOR_ID = sc.index(7) HIGH_RES_DETECTOR_ID = sc.index(8) @@ -28,7 +27,7 @@ class AllRawDetectors(sciline.Scope[RunType, sc.DataGroup], sc.DataGroup): def load_geant4_csv( - file_path: Union[FilePath[RunType], str, StringIO, BytesIO] + file_path: Union[FilePath[RunType], str, StringIO, BytesIO], ) -> AllRawDetectors[RunType]: """Load a GEANT4 CSV file for DREAM. @@ -73,7 +72,7 @@ def extract_geant4_detector_data( def _load_raw_events( - file_path: Union[str, os.PathLike, StringIO, BytesIO] + file_path: Union[str, os.PathLike, StringIO, BytesIO], ) -> sc.DataArray: table = sc.io.load_csv( file_path, sep='\t', header_parser='bracket', data_columns=[] diff --git a/src/ess/powder/__init__.py b/src/ess/powder/__init__.py index e0f404c2..e2c69c75 100644 --- a/src/ess/powder/__init__.py +++ b/src/ess/powder/__init__.py @@ -4,6 +4,7 @@ """ Components for powder diffraction experiments. """ + import importlib.metadata from . import conversion, correction, filtering, grouping, smoothing, uncertainty diff --git a/src/ess/powder/correction.py b/src/ess/powder/correction.py index 2fae36c8..d950f993 100644 --- a/src/ess/powder/correction.py +++ b/src/ess/powder/correction.py @@ -1,6 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2023 Scipp contributors (https://github.com/scipp) """Correction algorithms for powder diffraction.""" + from typing import Any, Dict, Optional import scipp as sc diff --git a/src/ess/powder/external/__init__.py b/src/ess/powder/external/__init__.py index 339a5635..71c147b0 100644 --- a/src/ess/powder/external/__init__.py +++ b/src/ess/powder/external/__init__.py @@ -7,6 +7,7 @@ It only serves as helpers to develop workflows until it is determined, which mechanisms and interfaces will be used at ESS. """ + from pathlib import Path from typing import Dict, Optional, Union diff --git a/src/ess/powder/filtering.py b/src/ess/powder/filtering.py index 272d97be..45f9e247 100644 --- a/src/ess/powder/filtering.py +++ b/src/ess/powder/filtering.py @@ -6,6 +6,7 @@ IMPORTANT Will be moved to a different place and potentially modified. """ + from contextlib import contextmanager from numbers import Real diff --git a/tests/dream/instrument_view_test.py b/tests/dream/instrument_view_test.py index d67bde6c..9cd9aa01 100644 --- a/tests/dream/instrument_view_test.py +++ b/tests/dream/instrument_view_test.py @@ -4,11 +4,10 @@ import numpy as np import pytest import scipp as sc - from ess.dream.instrument_view import InstrumentView -@pytest.fixture +@pytest.fixture() def fake_instrument_data(modules=('bank1', 'bank2', 'bank3', 'bank4', 'bank5')): rng = np.random.default_rng() @@ -16,7 +15,7 @@ def fake_instrument_data(modules=('bank1', 'bank2', 'bank3', 'bank4', 'bank5')): npix = 300 ntof = 100 locations = range(len(modules)) - for name, loc in zip(modules, locations): + for name, loc in zip(modules, locations, strict=True): position = rng.normal(loc=[0, 0, loc], scale=[0.2, 0.2, 0.05], size=[npix, 3]) tof = sc.linspace('tof', 0, 1.0e5, ntof + 1, unit='us') values = rng.normal(loc=5.0e4, scale=2.0e4, size=[npix, ntof]) diff --git a/tests/dream/io/geant4_test.py b/tests/dream/io/geant4_test.py index 44549c5c..db216eb6 100644 --- a/tests/dream/io/geant4_test.py +++ b/tests/dream/io/geant4_test.py @@ -10,7 +10,6 @@ import sciline import scipp as sc import scipp.testing - from ess.dream import data, load_geant4_csv from ess.powder.types import DetectorName, FilePath, RawDetectorData, SampleRun @@ -27,7 +26,7 @@ def load_file(file_path): return archive.read(archive.namelist()[0]) -@pytest.fixture(scope='function') +@pytest.fixture() def file(load_file): return BytesIO(load_file) @@ -58,7 +57,7 @@ def test_load_geant4_csv_loads_expected_structure(file): @pytest.mark.parametrize( - 'key', ('mantle', 'high_resolution', 'endcap_forward', 'endcap_backward') + 'key', ['mantle', 'high_resolution', 'endcap_forward', 'endcap_backward'] ) def test_load_gean4_csv_set_weights_to_one(file, key): detector = load_geant4_csv(file)['instrument'][key]['events'] diff --git a/tests/dream/io/nexus_test.py b/tests/dream/io/nexus_test.py index 71ba2695..6f7fe5f9 100644 --- a/tests/dream/io/nexus_test.py +++ b/tests/dream/io/nexus_test.py @@ -1,11 +1,10 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2023 Scipp contributors (https://github.com/scipp) import pytest - from ess import dream -@pytest.fixture +@pytest.fixture() def filename(): return dream.data.get_path('DREAM_nexus_sorted-2023-12-07.nxs') diff --git a/tests/powder/conversion_test.py b/tests/powder/conversion_test.py index 3ba3d3dc..08af8a77 100644 --- a/tests/powder/conversion_test.py +++ b/tests/powder/conversion_test.py @@ -5,7 +5,6 @@ import scipp as sc import scipp.testing import scippneutron as scn - from ess.powder.conversion import ( to_dspacing_with_calibration, to_dspacing_with_positions, diff --git a/tests/powder/correction_test.py b/tests/powder/correction_test.py index ea3f697e..0f731529 100644 --- a/tests/powder/correction_test.py +++ b/tests/powder/correction_test.py @@ -4,11 +4,10 @@ import pytest import scipp as sc import scipp.testing - from ess.powder.correction import apply_lorentz_correction, merge_calibration -@pytest.fixture +@pytest.fixture() def calibration(): rng = np.random.default_rng(789236) n = 30 @@ -58,7 +57,7 @@ def test_merge_calibration_raises_if_spectrum_mismatch(calibration): ) }, ) - with pytest.raises(ValueError): + with pytest.raises(ValueError, match='spectrum of calibration and target'): merge_calibration(into=da, calibration=calibration) @@ -70,7 +69,9 @@ def test_merge_calibration_raises_if_difa_exists(calibration): 'difa': sc.ones(sizes={'spectrum': calibration.sizes['spectrum']}), }, ) - with pytest.raises(ValueError): + with pytest.raises( + ValueError, match='there already is metadata with the same name' + ): merge_calibration(into=da, calibration=calibration) @@ -82,7 +83,9 @@ def test_merge_calibration_raises_if_difc_exists(calibration): 'difc': sc.ones(sizes={'spectrum': calibration.sizes['spectrum']}), }, ) - with pytest.raises(ValueError): + with pytest.raises( + ValueError, match='there already is metadata with the same name' + ): merge_calibration(into=da, calibration=calibration) @@ -94,7 +97,9 @@ def test_merge_calibration_raises_if_tzero_exists(calibration): 'tzero': sc.ones(sizes={'spectrum': calibration.sizes['spectrum']}), }, ) - with pytest.raises(ValueError): + with pytest.raises( + ValueError, match='there already is metadata with the same name' + ): merge_calibration(into=da, calibration=calibration) @@ -108,13 +113,13 @@ def test_merge_calibration_raises_if_mask_exists(calibration): 'calibration': sc.ones(sizes={'spectrum': calibration.sizes['spectrum']}) }, ) - with pytest.raises(ValueError): + with pytest.raises(ValueError, match='there already is a mask with the same name'): merge_calibration(into=da, calibration=calibration) -@pytest.mark.parametrize('data_dtype', ('float32', 'float64')) -@pytest.mark.parametrize('dspacing_dtype', ('float32', 'float64')) -@pytest.mark.parametrize('two_theta_dtype', ('float32', 'float64')) +@pytest.mark.parametrize('data_dtype', ['float32', 'float64']) +@pytest.mark.parametrize('dspacing_dtype', ['float32', 'float64']) +@pytest.mark.parametrize('two_theta_dtype', ['float32', 'float64']) def test_lorentz_correction_dense_1d_coords( data_dtype, dspacing_dtype, two_theta_dtype ): @@ -204,9 +209,9 @@ def test_apply_lorentz_correction_dense_2d_coord(): sc.testing.assert_identical(da.coords[key], original.coords[key]) -@pytest.mark.parametrize('data_dtype', ('float32', 'float64')) -@pytest.mark.parametrize('dspacing_dtype', ('float32', 'float64')) -@pytest.mark.parametrize('two_theta_dtype', ('float32', 'float64')) +@pytest.mark.parametrize('data_dtype', ['float32', 'float64']) +@pytest.mark.parametrize('dspacing_dtype', ['float32', 'float64']) +@pytest.mark.parametrize('two_theta_dtype', ['float32', 'float64']) def test_apply_lorentz_correction_event_coords( data_dtype, dspacing_dtype, two_theta_dtype ): diff --git a/tests/powder/external/powgen/powgen_reduction_test.py b/tests/powder/external/powgen/powgen_reduction_test.py index 96f59248..64bba88f 100644 --- a/tests/powder/external/powgen/powgen_reduction_test.py +++ b/tests/powder/external/powgen/powgen_reduction_test.py @@ -4,7 +4,6 @@ import pytest import sciline import scipp as sc - from ess.powder.types import ( CalibrationFilename, DspacingBins, diff --git a/tests/powder/filtering_test.py b/tests/powder/filtering_test.py index 3c4b9604..ff357138 100644 --- a/tests/powder/filtering_test.py +++ b/tests/powder/filtering_test.py @@ -6,7 +6,6 @@ import numpy as np import scipp as sc - from ess.powder import filtering diff --git a/tests/powder/load_test.py b/tests/powder/load_test.py index 069322d6..c93716e9 100644 --- a/tests/powder/load_test.py +++ b/tests/powder/load_test.py @@ -1,7 +1,6 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright (c) 2023 Scipp contributors (https://github.com/scipp) import pytest - from ess.powder.external import load_calibration from ess.powder.external.powgen import data @@ -26,7 +25,7 @@ def test_load_calibration_loads_required_data(): reason='mantid.LoadDiffCal causes SEGFAULT on CI but seems to work fine elsewhere' ) def test_load_calibration_requires_instrument_definition(): - with pytest.raises(ValueError): + with pytest.raises(ValueError, match='calibration'): load_calibration(data.calibration_file()) @@ -34,7 +33,7 @@ def test_load_calibration_requires_instrument_definition(): reason='mantid.LoadDiffCal causes SEGFAULT on CI but seems to work fine elsewhere' ) def test_load_calibration_can_only_have_1_instrument_definition(): - with pytest.raises(ValueError): + with pytest.raises(ValueError, match='instrument_name'): load_calibration( data.calibration_file(), instrument_name='POWGEN', diff --git a/tox.ini b/tox.ini index 0a5226eb..87e882ee 100644 --- a/tox.ini +++ b/tox.ini @@ -10,14 +10,14 @@ commands = pytest {posargs} [testenv:nightly] deps = -r requirements/nightly.txt -commands = pytest +commands = pytest {posargs} [testenv:unpinned] description = Test with unpinned dependencies, as a user would install now. deps = -r requirements/basetest.txt essdiffraction -commands = pytest +commands = pytest {posargs} [testenv:docs] description = invoke sphinx-build to build the HTML docs