Skip to content

Commit f89ea1a

Browse files
authored
Merge pull request #65 from scikit-hep/ariostas/final_tweaks
chore: final tweaks before release
2 parents 995a3aa + 1226b18 commit f89ea1a

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ ci:
55

66
repos:
77
- repo: https://github.com/pre-commit/pre-commit-hooks
8-
rev: v5.0.0
8+
rev: v6.0.0
99
hooks:
1010
- id: check-added-large-files
1111
- id: check-case-conflict
@@ -19,7 +19,7 @@ repos:
1919
- id: trailing-whitespace
2020

2121
- repo: https://github.com/mgedmin/check-manifest
22-
rev: "0.50"
22+
rev: "0.51"
2323
hooks:
2424
- id: check-manifest
2525
stages: [manual]
@@ -35,13 +35,13 @@ repos:
3535
- id: rst-directive-colons
3636

3737
- repo: https://github.com/asottile/pyupgrade
38-
rev: v3.19.1
38+
rev: v3.21.0
3939
hooks:
4040
- id: pyupgrade
4141
args: [--py310-plus]
4242

4343
- repo: https://github.com/asottile/setup-cfg-fmt
44-
rev: v2.8.0
44+
rev: v3.1.0
4545
hooks:
4646
- id: setup-cfg-fmt
4747
args: [--max-py-version=3.13, --include-version-classifiers]
@@ -80,7 +80,7 @@ repos:
8080
# - id: oxipng
8181

8282
- repo: https://github.com/python-jsonschema/check-jsonschema
83-
rev: 0.33.0
83+
rev: 0.34.1
8484
hooks:
8585
- id: check-github-workflows
8686
- id: check-github-actions
@@ -93,7 +93,7 @@ repos:
9393
- id: rm-unneeded-f-str
9494

9595
- repo: https://github.com/astral-sh/ruff-pre-commit
96-
rev: "v0.11.10"
96+
rev: "v0.14.0"
9797
hooks:
9898
- id: ruff
9999
types_or: [python, pyi, jupyter]
@@ -103,7 +103,7 @@ repos:
103103
types_or: [python, pyi, jupyter]
104104

105105
- repo: https://github.com/pre-commit/mirrors-mypy
106-
rev: "v1.17.1"
106+
rev: "v1.18.2"
107107
hooks:
108108
- id: mypy
109109
files: src

CHANGELOG.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
11
# Changelog
22

3-
## 1.0.1 (16 Oct. 2025)
3+
## v1.0.1 (16 Oct. 2025)
44

5-
Complete overhaul of the parsing and conversion logic to improve reliability and maintainability.
6-
TODO
5+
This release provided significant bug fixes and cleanup with respect to the previous overhaul. The switch to Lark as the parsing backend and the internal AST were kept, but the code was significantly simplified and many issues were ironed out.
6+
7+
### Breaking changes
8+
9+
- A `numexpr` parsing bug was fixed, which had been present since the initial release of `formulate`. Bitwise operator precedence was changed, so some expressions will be interpreted differently, or fail to be parsed if they are not valid `numexpr` expressions. (See bug fixes section for more details.)
10+
- Some constant names were changed. In particular, very generic names are not assumed to be constants and will instead need more specific names. For example `c` is no longer interpreted as the speed of light, so `c_light` should be used instead. Constant names were taken from `hepunits` for consistency within Scikit-HEP.
11+
12+
### Features and improvements
13+
14+
- The CLI interface (which was briefly removed) was reintroduced.
15+
- Added dependency on `hepunits` in order to provide a useful set of constants.
16+
- Added methods to suggest fixes to parsing issues. These will be expanded in the future.
17+
18+
### Bug fixes
19+
20+
- ROOT parsing issues were resolved.
21+
- Various issues with constant and function conversions were resolved.
22+
- Bitwise operator precedence for `numexpr` expressions was fixed. An expression like `x > 1 & x < 3` was being parsed as `(x > 1) & (x < 3)` whereas `numexpr` would actually parse it as `x > (1 & x) < 3`.
23+
24+
### Maintainability improvements
25+
26+
- Added `lark` as a dependency, and moved away from standalone parsers. This simplifies the code and makes future adjustments to the grammar rules much easier.
27+
- Moved function and constant conversions into a central location instead of having them in each `to_*` function. Expressions are converted into a unified internal representation when they are parsed. This makes it easier to identify parsing and conversion issues.

docs/quickstart/whatsnew.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ What's New
22
=====================
33

44
.. include:: ../../CHANGELOG.md
5+
:parser: myst_parser.sphinx_

src/formulate/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
import importlib.resources
56
from typing import Any
67

78
import lark
@@ -14,8 +15,6 @@
1415

1516

1617
def _get_parser(parser_type: str) -> lark.lark.Lark:
17-
import importlib.resources
18-
1918
grammar = (
2019
importlib.resources.files(__package__)
2120
/ "resources"

0 commit comments

Comments
 (0)