Skip to content

Commit 22db2d7

Browse files
authored
Merge pull request #63 from ariostas/ariostas/repo-review-fixes
chore: apply a few fixes from `sp-repo-review`
2 parents 11738cf + 40bf069 commit 22db2d7

File tree

11 files changed

+76
-58
lines changed

11 files changed

+76
-58
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
groups:
9+
actions:
10+
patterns:
11+
- "*"

.github/workflows/cd.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ jobs:
2424

2525
- uses: hynek/build-and-inspect-python-package@v2
2626

27-
28-
2927
deploy:
3028
if: github.event_name == 'release' && github.event.action == 'published'
31-
needs: [ dist ]
29+
needs: [dist]
3230
runs-on: ubuntu-latest
3331
environment:
3432
name: pypi

.github/workflows/ci.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ jobs:
2121
fail-fast: false
2222
matrix:
2323
python-version:
24-
- '3.10'
25-
- '3.11'
26-
- '3.12'
27-
- '3.13'
28-
- '3.14'
24+
- "3.10"
25+
- "3.11"
26+
- "3.12"
27+
- "3.13"
28+
- "3.14"
2929
runs-on:
3030
- ubuntu-latest
3131
include:
32-
- python-version: '3.10'
32+
- python-version: "3.10"
3333
runs-on: macOS-13
34-
- python-version: '3.10'
34+
- python-version: "3.10"
3535
runs-on: macOS-14
36-
- python-version: '3.10'
36+
- python-version: "3.10"
3737
runs-on: windows-latest
3838
steps:
3939
- uses: actions/checkout@v5

.github/workflows/docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Set up Python
2727
uses: actions/setup-python@v4
2828
with:
29-
python-version: '3.x'
29+
python-version: "3.x"
3030

3131
- name: Install dependencies
3232
run: |
@@ -47,7 +47,7 @@ jobs:
4747
- name: Upload artifact
4848
uses: actions/upload-pages-artifact@v3
4949
with:
50-
path: 'docs/_build/html'
50+
path: "docs/_build/html"
5151

5252
deploy:
5353
name: Deploy docs to GitHub Pages

.pre-commit-config.yaml

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
ci:
2+
autoupdate_commit_msg: "chore: update pre-commit hooks"
3+
autofix_commit_msg: "style: pre-commit fixes"
4+
autoupdate_schedule: monthly
5+
16
repos:
27
- repo: https://github.com/pre-commit/pre-commit-hooks
38
rev: v5.0.0
@@ -17,7 +22,7 @@ repos:
1722
rev: "0.50"
1823
hooks:
1924
- id: check-manifest
20-
stages: [ manual ]
25+
stages: [manual]
2126

2227
- repo: https://github.com/pre-commit/pygrep-hooks
2328
rev: v1.10.0
@@ -33,36 +38,35 @@ repos:
3338
rev: v3.19.1
3439
hooks:
3540
- id: pyupgrade
36-
args: [ --py310-plus ]
41+
args: [--py310-plus]
3742

3843
- repo: https://github.com/asottile/setup-cfg-fmt
3944
rev: v2.8.0
4045
hooks:
4146
- id: setup-cfg-fmt
42-
args: [ --max-py-version=3.13, --include-version-classifiers ]
47+
args: [--max-py-version=3.13, --include-version-classifiers]
4348

4449
# Notebook formatting
4550
- repo: https://github.com/nbQA-dev/nbQA
4651
rev: 1.9.1
4752
hooks:
4853
- id: nbqa-isort
49-
additional_dependencies: [ isort ]
54+
additional_dependencies: [isort]
5055

5156
- id: nbqa-pyupgrade
52-
additional_dependencies: [ pyupgrade ]
53-
args: [ --py310-plus ]
54-
57+
additional_dependencies: [pyupgrade]
58+
args: [--py310-plus]
5559

5660
- repo: https://github.com/kynan/nbstripout
5761
rev: 0.8.1
5862
hooks:
5963
- id: nbstripout
6064

6165
- repo: https://github.com/sondrelg/pep585-upgrade
62-
rev: 'v1.0'
66+
rev: "v1.0"
6367
hooks:
6468
- id: upgrade-type-hints
65-
args: [ '--futures=true' ]
69+
args: ["--futures=true"]
6670

6771
- repo: https://github.com/MarcoGorelli/auto-walrus
6872
rev: 0.3.4
@@ -75,7 +79,6 @@ repos:
7579
# hooks:
7680
# - id: oxipng
7781

78-
7982
- repo: https://github.com/python-jsonschema/check-jsonschema
8083
rev: 0.33.0
8184
hooks:
@@ -84,26 +87,44 @@ repos:
8487
- id: check-dependabot
8588
- id: check-readthedocs
8689

87-
8890
- repo: https://github.com/dannysepler/rm_unneeded_f_str
8991
rev: v0.2.0
9092
hooks:
9193
- id: rm-unneeded-f-str
9294

93-
9495
- repo: https://github.com/astral-sh/ruff-pre-commit
9596
rev: "v0.11.10"
9697
hooks:
9798
- id: ruff
98-
types_or: [ python, pyi, jupyter ]
99-
args: [ --fix, --show-fixes , --line-length=120 ]
99+
types_or: [python, pyi, jupyter]
100+
args: [--fix, --show-fixes, --line-length=120]
100101
# Run the formatter.
101102
- id: ruff-format
102-
types_or: [ python, pyi, jupyter ]
103+
types_or: [python, pyi, jupyter]
103104

104105
- repo: https://github.com/pre-commit/mirrors-mypy
105106
rev: "v1.17.1"
106107
hooks:
107108
- id: mypy
108109
files: src
109110
args: []
111+
112+
- repo: https://github.com/adamchainz/blacken-docs
113+
rev: "1.20.0"
114+
hooks:
115+
- id: blacken-docs
116+
additional_dependencies: [black==24.*]
117+
118+
- repo: https://github.com/codespell-project/codespell
119+
rev: "v2.4.1"
120+
hooks:
121+
- id: codespell
122+
additional_dependencies:
123+
- tomli; python_version<'3.11'
124+
args: ["-L", "gaus"]
125+
126+
- repo: https://github.com/rbubley/mirrors-prettier
127+
rev: "v3.6.2"
128+
hooks:
129+
- id: prettier
130+
types_or: [yaml, markdown, html, css, scss, javascript, json]

.readthedocs.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,5 @@ python:
1616
extra_requirements:
1717
- docs
1818

19-
2019
sphinx:
2120
configuration: docs/conf.py

CHANGELOG.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
Changelog
2-
=========
1+
# Changelog
32

4-
1.0.1 (16 Oct. 2025)
5-
--------------------
3+
## 1.0.1 (16 Oct. 2025)
64

75
Complete overhaul of the parsing and conversion logic to improve reliability and maintainability.
86
TODO

README.md

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,15 @@
2626

2727
<!-- prettier-ignore-end -->
2828

29-
Formulate
30-
=========
29+
# Formulate
3130

3231
Easy conversions between different styles of expressions. Formulate
3332
currently supports converting between
3433
[ROOT](https://root.cern.ch/doc/master/classTFormula.html) and
3534
[numexpr](https://numexpr.readthedocs.io/en/latest/user_guide.html)
3635
style expressions.
3736

38-
39-
40-
Installation
41-
------------
37+
## Installation
4238

4339
Install formulate like any other Python package, ideally inside a virtual environment:
4440

@@ -54,33 +50,31 @@ conda install -c conda-forge formulate
5450

5551
(`-c conda-forge` is only needed if you don't have the `conda-forge` channel already configured)
5652

57-
Roadmap and releases
58-
----------------------
53+
## Roadmap and releases
5954

6055
For the roadmap, planned features, breaking changes and versioning please see the [roadmap](https://github.com/scikit-hep/formulate/discussions/61).
6156

62-
Usage
63-
-----
57+
## Usage
6458

6559
### API
6660

67-
6861
The most basic usage involves calling `from_$BACKEND` and then `to_$BACKEND`, for example when starting with a ROOT style expression:
6962

70-
```python
63+
```pycon
7164
>>> import formulate
72-
>>> momentum = formulate.from_root('TMath::Sqrt(X_PX**2 + X_PY**2 + X_PZ**2)')
65+
>>> momentum = formulate.from_root("TMath::Sqrt(X_PX**2 + X_PY**2 + X_PZ**2)")
7366
>>> momentum
7467
Call(function='sqrt', arguments=[BinaryOperator(operator='add', left=BinaryOperator(operator='add', left=BinaryOperator(operator='pow', left=Symbol(name='X_PX'), right=Literal(value=2)), right=BinaryOperator(operator='pow', left=Symbol(name='X_PY'), right=Literal(value=2))), right=BinaryOperator(operator='pow', left=Symbol(name='X_PZ'), right=Literal(value=2)))])
7568
>>> momentum.to_numexpr()
7669
'sqrt((((X_PX ** 2) + (X_PY ** 2)) + (X_PZ ** 2)))'
7770
>>> momentum.to_root()
7871
'TMath::Sqrt((((X_PX ** 2) + (X_PY ** 2)) + (X_PZ ** 2)))'
7972
```
73+
8074
Similarly, when starting with a `numexpr` style expression:
8175

82-
```python
83-
>>> my_selection = formulate.from_numexpr('(X_PT > 5) & ((Mu_NHits > 3) | (Mu_PT > 10))')
76+
```pycon
77+
>>> my_selection = formulate.from_numexpr("(X_PT > 5) & ((Mu_NHits > 3) | (Mu_PT > 10))")
8478
>>> my_selection.to_root()
8579
'((X_PT > 5) && ((Mu_NHits > 3) || (Mu_PT > 10)))'
8680
>>> my_selection.to_numexpr()

docs/quickstart/example.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ With numexpr:
7272

7373
# Create some sample data
7474
data = {
75-
'X_PT': np.array([3, 6, 9, 12]),
76-
'Mu_NHits': np.array([2, 4, 1, 5]),
77-
'Mu_PT': np.array([8, 5, 12, 7])
75+
"X_PT": np.array([3, 6, 9, 12]),
76+
"Mu_NHits": np.array([2, 4, 1, 5]),
77+
"Mu_PT": np.array([8, 5, 12, 7]),
7878
}
7979

8080
# Use the converted numexpr expression

docs/quickstart/installation.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ To verify that Formulate is installed correctly, you can run:
5454
.. jupyter-execute::
5555

5656
import formulate
57+
5758
print(formulate.__version__)

0 commit comments

Comments
 (0)