Skip to content

Commit

Permalink
Update type hints and pre-commit hooks
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonas-eschle committed Oct 30, 2024
1 parent 883232e commit ea30221
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
20 changes: 8 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ repos:
- id: check-ast
- id: end-of-file-fixer

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

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


- repo: https://github.com/asottile/pyupgrade
rev: v3.17.0
rev: v3.19.0
hooks:
- id: pyupgrade
args: [ --py38-plus ]

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0
rev: v2.7.0
hooks:
- id: setup-cfg-fmt

Expand All @@ -57,7 +52,7 @@ repos:
args: [ --py38-plus ]

- repo: https://github.com/mgedmin/check-manifest
rev: '0.49'
rev: '0.50'
hooks:
- id: check-manifest
stages: [ manual ]
Expand All @@ -67,10 +62,11 @@ repos:
hooks:
- id: upgrade-type-hints

- repo: https://github.com/janosh/format-ipy-cells
rev: v0.1.11
hooks:
- id: format-ipy-cells
# TODO: requires Python 3.10+
# - repo: https://github.com/janosh/format-ipy-cells
# rev: v0.1.11
# hooks:
# - id: format-ipy-cells

- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
Expand Down
9 changes: 6 additions & 3 deletions _website/tutorials/components/77 - Custom Minimizer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"metadata": {},
"outputs": [],
"source": [
"from __future__ import annotations\n",
"\n",
"from typing import Sequence\n",
"\n",
"import zfit\n",
Expand Down Expand Up @@ -139,7 +141,7 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import zfit.z.numpy as znp\n",
"from zfit.result import FitResult\n",
"\n",
Expand All @@ -164,8 +166,9 @@
" i = 1\n",
" while True:\n",
" value, gradients = evaluator.value_gradient(paramvals)\n",
" 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",
" )\n",
" 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",
" approx={'gradient': gradients}, criterion=criterion,\n",
" )\n",
" if criterion.converged(result=result):\n",
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=True, converged=True, edm=None,\n",
" fminopt=None, approx={'gradient': gradients}, criterion=criterion)\n",
Expand Down
9 changes: 6 additions & 3 deletions components/77 - Custom Minimizer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"metadata": {},
"outputs": [],
"source": [
"from __future__ import annotations\n",
"\n",
"from typing import Sequence\n",
"\n",
"import zfit\n",
Expand Down Expand Up @@ -139,7 +141,7 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"import zfit.z.numpy as znp\n",
"from zfit.result import FitResult\n",
"\n",
Expand All @@ -164,8 +166,9 @@
" i = 1\n",
" while True:\n",
" value, gradients = evaluator.value_gradient(paramvals)\n",
" 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",
" )\n",
" 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",
" approx={'gradient': gradients}, criterion=criterion,\n",
" )\n",
" if criterion.converged(result=result):\n",
" result = FitResult(loss=loss, params={p: v for p, v in zip(params, paramvals)}, minimizer=self, valid=True, converged=True, edm=None,\n",
" fminopt=None, approx={'gradient': gradients}, criterion=criterion)\n",
Expand Down

0 comments on commit ea30221

Please sign in to comment.