Skip to content

Commit ea30221

Browse files
committed
Update type hints and pre-commit hooks
Added future annotations import and modified type hints to use Union for compatibility. Updated versions of various pre-commit hooks and removed the docformatter hook.
1 parent 883232e commit ea30221

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

.pre-commit-config.yaml

+8-12
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ repos:
1919
- id: check-ast
2020
- id: end-of-file-fixer
2121

22-
- repo: https://github.com/PyCQA/docformatter
23-
rev: v1.7.5
24-
hooks:
25-
- id: docformatter
26-
args: [ -r, --in-place, --wrap-descriptions, '120', --wrap-summaries, '120', -- ]
2722

2823
- repo: https://github.com/pre-commit/pygrep-hooks
2924
rev: v1.10.0 # Use the ref you want to point at
@@ -35,13 +30,13 @@ repos:
3530

3631

3732
- repo: https://github.com/asottile/pyupgrade
38-
rev: v3.17.0
33+
rev: v3.19.0
3934
hooks:
4035
- id: pyupgrade
4136
args: [ --py38-plus ]
4237

4338
- repo: https://github.com/asottile/setup-cfg-fmt
44-
rev: v2.5.0
39+
rev: v2.7.0
4540
hooks:
4641
- id: setup-cfg-fmt
4742

@@ -57,7 +52,7 @@ repos:
5752
args: [ --py38-plus ]
5853

5954
- repo: https://github.com/mgedmin/check-manifest
60-
rev: '0.49'
55+
rev: '0.50'
6156
hooks:
6257
- id: check-manifest
6358
stages: [ manual ]
@@ -67,10 +62,11 @@ repos:
6762
hooks:
6863
- id: upgrade-type-hints
6964

70-
- repo: https://github.com/janosh/format-ipy-cells
71-
rev: v0.1.11
72-
hooks:
73-
- id: format-ipy-cells
65+
# TODO: requires Python 3.10+
66+
# - repo: https://github.com/janosh/format-ipy-cells
67+
# rev: v0.1.11
68+
# hooks:
69+
# - id: format-ipy-cells
7470

7571
- repo: https://github.com/kynan/nbstripout
7672
rev: 0.7.1

_website/tutorials/components/77 - Custom Minimizer.ipynb

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18+
"from __future__ import annotations\n",
19+
"\n",
1820
"from typing import Sequence\n",
1921
"\n",
2022
"import zfit\n",
@@ -139,7 +141,7 @@
139141
"metadata": {},
140142
"outputs": [],
141143
"source": [
142-
"import numpy as np\n",
144+
"\n",
143145
"import zfit.z.numpy as znp\n",
144146
"from zfit.result import FitResult\n",
145147
"\n",
@@ -164,8 +166,9 @@
164166
" i = 1\n",
165167
" while True:\n",
166168
" value, gradients = evaluator.value_gradient(paramvals)\n",
167-
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=False, converged=False, edm=None, fminopt=None, approx={'gradient': gradients}, criterion=criterion,\n",
168-
" )\n",
169+
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=False, converged=False, edm=None, fminopt=None,\n",
170+
" approx={'gradient': gradients}, criterion=criterion,\n",
171+
" )\n",
169172
" if criterion.converged(result=result):\n",
170173
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=True, converged=True, edm=None,\n",
171174
" fminopt=None, approx={'gradient': gradients}, criterion=criterion)\n",

components/77 - Custom Minimizer.ipynb

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"metadata": {},
1616
"outputs": [],
1717
"source": [
18+
"from __future__ import annotations\n",
19+
"\n",
1820
"from typing import Sequence\n",
1921
"\n",
2022
"import zfit\n",
@@ -139,7 +141,7 @@
139141
"metadata": {},
140142
"outputs": [],
141143
"source": [
142-
"import numpy as np\n",
144+
"\n",
143145
"import zfit.z.numpy as znp\n",
144146
"from zfit.result import FitResult\n",
145147
"\n",
@@ -164,8 +166,9 @@
164166
" i = 1\n",
165167
" while True:\n",
166168
" value, gradients = evaluator.value_gradient(paramvals)\n",
167-
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=False, converged=False, edm=None, fminopt=None, approx={'gradient': gradients}, criterion=criterion,\n",
168-
" )\n",
169+
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=False, converged=False, edm=None, fminopt=None,\n",
170+
" approx={'gradient': gradients}, criterion=criterion,\n",
171+
" )\n",
169172
" if criterion.converged(result=result):\n",
170173
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=True, converged=True, edm=None,\n",
171174
" fminopt=None, approx={'gradient': gradients}, criterion=criterion)\n",

0 commit comments

Comments
 (0)