Skip to content

Commit 4ad3ef9

Browse files
authored
Merge pull request #155 from scipp/pre-commit-in-ci
Use pre-commit in ci
2 parents e144cc9 + 131ce05 commit 4ad3ef9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+263
-187
lines changed

.github/workflows/pr_and_main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
python-version: 3.8
2929
- run: python -m pip install --upgrade pip
30-
- run: python -m pip install -r requirements/static.txt
30+
- run: python -m pip install -r requirements/ci.txt
3131
- run: tox -e static
3232
- uses: stefanzweifel/git-auto-commit-action@v4
3333
with:

.pre-commit-config.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.3.0
4+
hooks:
5+
- id: check-added-large-files
6+
- id: check-json
7+
exclude: asv.conf.json
8+
- id: check-toml
9+
- id: check-yaml
10+
exclude: conda/meta.yaml
11+
- id: detect-private-key
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
args: [ --markdown-linebreak-ext=md ]
15+
exclude: '\.svg'
16+
- repo: https://github.com/pycqa/isort
17+
rev: 5.10.1
18+
hooks:
19+
- id: isort
20+
name: isort (python)
21+
- repo: https://github.com/pre-commit/mirrors-yapf
22+
rev: v0.32.0
23+
hooks:
24+
- id: yapf
25+
args: [ "-i", "-r" ]
26+
types: [ "python" ]
27+
additional_dependencies: [ "toml" ]
28+
- repo: https://github.com/kynan/nbstripout
29+
rev: 0.6.0
30+
hooks:
31+
- id: nbstripout
32+
types: [ "jupyter" ]
33+
args: [ "--drop-empty-cells",
34+
"--extra-keys 'metadata.language_info.version cell.metadata.jp-MarkdownHeadingCollapsed cell.metadata.pycharm'" ]
35+
- repo: https://github.com/pycqa/flake8
36+
rev: 4.0.1
37+
hooks:
38+
- id: flake8
39+
types: ["python"]
40+
additional_dependencies: ["flake8-bugbear==22.10.27"]
41+
- repo: https://github.com/pycqa/bandit
42+
rev: 1.7.4
43+
hooks:
44+
- id: bandit
45+
additional_dependencies: ["bandit[toml]"]
46+
args: ["-c", "pyproject.toml"]
47+
- repo: https://github.com/codespell-project/codespell
48+
rev: v2.2.2
49+
hooks:
50+
- id: codespell
51+
additional_dependencies:
52+
- tomli
53+
- repo: https://github.com/pre-commit/pygrep-hooks
54+
rev: v1.9.0
55+
hooks:
56+
- id: python-no-eval
57+
exclude: "object_list.py"
58+
- id: python-no-log-warn
59+
- id: python-use-type-annotations
60+
- id: rst-backticks
61+
- id: rst-directive-colons
62+
- id: rst-inline-touching-normal
63+
- id: text-unicode-replacement-char

docs/about/release-notes.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ Breaking changes
154154
* A major rewrite of the reflectometry code was undertaken `#61 <https://github.com/scipp/ess/pull/61>`_:
155155

156156
* The reflectometry and Amor Data classes were removed in favour of a formalism consisting of free-functions that accept Scipp DataArrays and Datasets.
157-
* Moved the chopper class from the `wfm` submodule to free functions in its own ``choppers`` module.
157+
* Moved the chopper class from the ``wfm`` submodule to free functions in its own ``choppers`` module.
158158
* The unit conversion (computing wavelength and Q) now use ``transform_coords``.
159159
* The Amor reduction notebook from ``ess-notebooks`` has been imported into the ``ess`` repository.
160160

docs/conf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
33

44
import doctest
5-
from datetime import date
6-
import ess
7-
85
import os
96
import sys
10-
7+
from datetime import date
118
from typing import Any, Dict, Optional
9+
10+
import sphinx_book_theme
1211
from docutils.nodes import document
1312
from sphinx.application import Sphinx
14-
import sphinx_book_theme
13+
14+
import ess
1515

1616
sys.path.insert(0, os.path.abspath('.'))
1717

docs/instruments/amor/amor_reduction.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@
611611
"metadata": {},
612612
"source": [
613613
"The reference is assumed to be a perfect scatterer, therefore where there is no reflectivity in the reference measurement is it taken to be a region of `'Q'` space that cannot be accessed by the instrument. \n",
614-
"This leads to the number of detectors feeding data into each $Q$-bin being variable, this is particularly noticable at low-$Q$, there there are only a few pixels detecting neutrons. \n",
614+
"This leads to the number of detectors feeding data into each $Q$-bin being variable, this is particularly noticeable at low-$Q$, there there are only a few pixels detecting neutrons. \n",
615615
"Therefore, in order to account for this variability as a function of $Q$, we mask those pixels (performed in `normalize_by_supermirror`) where no neutrons were detected and perform an average over the remaining `'detector_id'` to reduce the data. "
616616
]
617617
},
@@ -630,7 +630,7 @@
630630
"id": "d5b8ab01-4924-451e-95fb-a04365373c54",
631631
"metadata": {},
632632
"source": [
633-
"To obtain the final resolution, the three components of the resolution function are combined and multipled by the midpoints of the $Q$-bins. "
633+
"To obtain the final resolution, the three components of the resolution function are combined and multiplied by the midpoints of the $Q$-bins. "
634634
]
635635
},
636636
{

docs/instruments/loki/sans2d_reduction.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
"# Custom SANS2D position offsets\n",
149149
"sample_pos_z_offset = 0.053 * sc.units.m\n",
150150
"bench_pos_y_offset = 0.001 * sc.units.m\n",
151-
"# There is some uncertainity here\n",
151+
"# There is some uncertainty here\n",
152152
"monitor4_pos_z_offset = -6.719 * sc.units.m\n",
153153
"\n",
154154
"# Geometry transformation\n",
@@ -189,7 +189,7 @@
189189
"The next step is to mask noisy and saturated pixels,\n",
190190
"as well as a time-of-flight range that contains spurious artifacts from the beamline components.\n",
191191
"\n",
192-
"**Note:** We use programatic masks here and not those stored in xml files.\n",
192+
"**Note:** We use programmatic masks here and not those stored in xml files.\n",
193193
"\n",
194194
"### Mask bad pixels\n",
195195
"\n",

docs/instruments/loki/sans2d_to_I_of_Q.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
"# Custom SANS2D position offsets\n",
175175
"sample_pos_z_offset = 0.053 * sc.units.m\n",
176176
"bench_pos_y_offset = 0.001 * sc.units.m\n",
177-
"# There is some uncertainity here\n",
177+
"# There is some uncertainty here\n",
178178
"monitor4_pos_z_offset = -6.719 * sc.units.m\n",
179179
"\n",
180180
"# Geometry transformation based on the found beam center position \n",
@@ -216,7 +216,7 @@
216216
"The next step is to mask noisy and saturated pixels,\n",
217217
"as well as a time-of-flight range that contains spurious artifacts from the beamline components.\n",
218218
"\n",
219-
"**Note:** We use programatic masks here and not those stored in xml files.\n",
219+
"**Note:** We use programmatic masks here and not those stored in xml files.\n",
220220
"\n",
221221
"### Mask bad pixels\n",
222222
"\n",

docs/techniques/reflectometry/reference.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Corrections
2121
corrections.normalize_by_counts
2222
corrections.beam_on_sample
2323

24-
IO
24+
IO
2525
--
2626

27-
.. autosummary::
27+
.. autosummary::
2828
:toctree: ../../generated
29-
30-
io.save_ort
29+
30+
io.save_ort

docs/techniques/wfm/reducing-wfm-data.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
"\n",
105105
"For the events in both `sample` and `vanadium`,\n",
106106
"we define a wavelength for the neutrons as well as a birth time,\n",
107-
"which will be a random time between the pulse $t_0$ and the end of the useable pulse $t_0$ + pulse_length."
107+
"which will be a random time between the pulse $t_0$ and the end of the usable pulse $t_0$ + pulse_length."
108108
]
109109
},
110110
{

docs/version.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# SPDX-License-Identifier: BSD-3-Clause
22
# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)
33

4-
import git
4+
import argparse
55
import sys
66
from typing import List
7-
from packaging.version import parse, Version, InvalidVersion
8-
import argparse
7+
8+
import git
9+
from packaging.version import InvalidVersion, Version, parse
910

1011

1112
def _get_releases() -> List[Version]:

0 commit comments

Comments
 (0)