Skip to content

Commit

Permalink
Merge pull request #412 from zfit/precommit_hooks2
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-eschle committed Jul 9, 2022
2 parents 82d5a68 + 88c1a4d commit 7ef35bf
Show file tree
Hide file tree
Showing 48 changed files with 414 additions and 406 deletions.
19 changes: 13 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ ci:

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.3.0
hooks:
- id: check-added-large-files
args: [ '--maxkb=1000' ]
- id: check-case-conflict
# - id: check-merge-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: check-toml
Expand All @@ -18,7 +18,7 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace
- id: detect-private-key
# - id: name-tests-test
# - id: name-tests-test # TODO: rename tests correctly?
- id: fix-byte-order-marker
- id: check-ast
- repo: local
Expand Down Expand Up @@ -46,11 +46,11 @@ repos:
- id: python-use-type-annotations
- id: python-check-mock-methods
- id: python-no-eval
# - id: rst-backticks
- id: rst-backticks
- id: rst-directive-colons

- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
rev: v2.34.0
hooks:
- id: pyupgrade
args: [ --py37-plus ]
Expand Down Expand Up @@ -90,8 +90,15 @@ repos:
- id: upgrade-type-hints
args: [ '--futures=true' ]

- repo: https://github.com/shssoichiro/oxipng
rev: acdd66b4c5a5fda8b08281ad9b3216327b6847b4
hooks:
- id: oxipng



- repo: https://github.com/ambv/black
rev: 22.3.0
rev: 22.6.0
hooks:
- id: black
language_version: python3
46 changes: 23 additions & 23 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Develop

Major Features and Improvements
-------------------------------
- improved data handling in constructors `from_pandas` (which allows now to
- improved data handling in constructors ``from_pandas`` (which allows now to
have weights as columns, dataframes that are a superset of the obs) and
`from_root` (obs can now be spaces and therefore cuts can be direcly applied)
- add hashing of unbinned datasets with a `hashint` attribute. None if no hash was possible.
``from_root`` (obs can now be spaces and therefore cuts can be direcly applied)
- add hashing of unbinned datasets with a ``hashint`` attribute. None if no hash was possible.

Breaking changes
------------------
Expand Down Expand Up @@ -47,14 +47,14 @@ Thanks

Major Features and Improvements
-------------------------------
- Save results by pickling, unpickling a frozen (`FitResult.freeze()`) result and using
`zfit.param.set_values(params, result)` to set the values of `params`.
- Save results by pickling, unpickling a frozen (``FitResult.freeze()``) result and using
``zfit.param.set_values(params, result)`` to set the values of ``params``.



Deprecations
-------------
- the default name of the uncertainty methods `hesse` and `errors` depended on
- the default name of the uncertainty methods ``hesse`` and ``errors`` depended on
the method used (such as 'minuit_hesse', 'zfit_errors' etc.) and would be the exact method name.
New names are now 'hesse' and 'errors', independent of the method used. This reflects better that the
methods, while internally different, produce the same result.
Expand Down Expand Up @@ -86,22 +86,22 @@ Major Features and Improvements
binned losses. TODO: extend to include changes/point to binned introduction.
- new Poisson PDF
- added Poisson constraint, LogNormal Constraint
- Save results by pickling, unpickling a frozen (`FitResult.freeze()`) result and using
`zfit.param.set_values(params, result)` to set the values of `params`.
- Save results by pickling, unpickling a frozen (``FitResult.freeze()``) result and using
``zfit.param.set_values(params, result)`` to set the values of ``params``.

Breaking changes
------------------

- params given in ComposedParameters are not sorted anymore. Rely on their name instead.
- `norm_range` is now called `norm` and should be replaced everywhere if possible. This will break in
- ``norm_range`` is now called ``norm`` and should be replaced everywhere if possible. This will break in
the future.

Deprecation
-------------

Bug fixes and small changes
---------------------------
- remove warning when using `rect_limits` or similar.
- remove warning when using ``rect_limits`` or similar.
- gauss integral accepts now also tensor inputs in limits
- parameters at limits is now shown correctly

Expand Down Expand Up @@ -134,7 +134,7 @@ Bug fixes and small changes
Major Features and Improvements
-------------------------------

- allow `FitResult` to `freeze()`, making it pickleable. The parameters
- allow ``FitResult`` to ``freeze()``, making it pickleable. The parameters
are replaced by their name, the objects such as loss and minimizer as well.
- improve the numerical integration by adding a one dimensional efficient integrator, testing for the accuracy of
multidimensional integrals. If there is a sharp peak, this maybe fails to integrate and the number of points
Expand All @@ -156,7 +156,7 @@ Breaking changes
------------------
- the numerical integration improved with more sensible values for tolerance. This means however that some fits will
greatly increase the runtime. To restore the old behavior globally, do
for each instance `pdf.update_integration_options(draws_per_dim=40_000, max_draws=40_000, tol=1)`
for each instance ``pdf.update_integration_options(draws_per_dim=40_000, max_draws=40_000, tol=1)``
This will integrate regardless of the chosen precision and it may be non-optimal.
However, the precision estimate in the integrator is also not perfect and maybe overestimates the error, so that
the integration by default takes longer than necessary. Feel free to play around with the parameters and report back.
Expand Down Expand Up @@ -187,7 +187,7 @@ Thanks

Bug fixes and small changes
---------------------------
- fix wrong arguments to `minimize`
- fix wrong arguments to ``minimize``
- make BaseMinimizer arguments optional

0.7.1 (6. July 2021)
Expand All @@ -210,7 +210,7 @@ Major Features and Improvements

Bug fixes and small changes
---------------------------
- Scipy minimizers with hessian arguments use now `BFGS` as default
- Scipy minimizers with hessian arguments use now ``BFGS`` as default


Requirement changes
Expand All @@ -230,8 +230,8 @@ Update ipyopt requirement < 0.12 to allow numpy compatible with TensorFlow
==================

- hotfix for wrong argument in exponential PDF
- removed requirement ipyopt, can be installed with `pip install zfit[ipyopt]`
or by manually installing `pip install ipyopt`
- removed requirement ipyopt, can be installed with ``pip install zfit[ipyopt]``
or by manually installing ``pip install ipyopt``



Expand Down Expand Up @@ -306,7 +306,7 @@ Major Features and Improvements
- Completely new and overhauled minimizers design, including:

- minimizers can now be used with arbitrary Python functions and an initial array independent of zfit
- a minimization can be 'continued' by passing `init` to `minimize`
- a minimization can be 'continued' by passing ``init`` to ``minimize``
- more streamlined arguments for minimizers, harmonized names and behavior.
- Adding a flexible criterion (currently EDM) that will terminate the minimization.
- Making the minimizer fully stateless.
Expand All @@ -315,10 +315,10 @@ Major Features and Improvements

- Major overhaul of the ``FitResult``, including:

- improved `zfit_error` (equivalent of `MINOS`)
- `minuit_hesse` and `minuit_minos` are now available with all minimizers as well thanks to an great
- improved ``zfit_error`` (equivalent of ``MINOS``)
- ``minuit_hesse`` and ``minuit_minos`` are now available with all minimizers as well thanks to an great
improvement in iminuit.
- Added an `approx` hesse that returns the approximate hessian (if available, otherwise empty)
- Added an ``approx`` hesse that returns the approximate hessian (if available, otherwise empty)

- upgrade to iminuit v2 changes the way it works and also the Minuit minimizer in zfit,
including a new step size heuristic.
Expand All @@ -330,11 +330,11 @@ Major Features and Improvements

Breaking changes
------------------
- NLL (and extended) subtracts now by default a constant value. This can be changed with a new `options` argument.
- NLL (and extended) subtracts now by default a constant value. This can be changed with a new ``options`` argument.
COMPARISON OF DIFFEREN NLLs (their absolute values) fails now! (flag can be deactivated)
- BFGS (from TensorFlow Probability) has been removed as it is not working properly. There are many alternatives
such as ScipyLBFGSV1 or NLoptLBFGSV1
- Scipy (the minimizer) has been removed. Use specialized `Scipy*` minimizers instead.
- Scipy (the minimizer) has been removed. Use specialized ``Scipy*`` minimizers instead.
- Creating a ``zfit.Parameter``, usign ``set_value`` or ``set_values`` now raises a ``ValueError``
if the value is outside the limits. Use ``assign`` to suppress it.

Expand All @@ -348,7 +348,7 @@ Bug fixes and small changes
- FFTconv was shifted if the kernel limits were not symetrical, now properly taken into account.
- circumvent overflow error in sampling
- shuffle samples from sum pdfs to ensure uniformity and remove conv sampling bias
- `create_sampler` now samples immediately to allow for precompile, a new hook that will allow objects to optimize
- ``create_sampler`` now samples immediately to allow for precompile, a new hook that will allow objects to optimize
themselves.


Expand Down
8 changes: 4 additions & 4 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@
# releases_github_path = "zfit/zfit" # TODO: use releases or similar?
# releases_document_name = "../CHANGELOG.rst"

jupyter_execute_notebooks = "force" # use if needed and cache should be ignored
# jupyter_execute_notebooks = "cache"
if jupyter_execute_notebooks == "cache":
nb_execution_mode = "force" # use if needed and cache should be ignored
# nb_execution_mode = "cache"
if nb_execution_mode == "cache":
jupyter_cache_path = project_dir.joinpath("docs", ".cache", "myst-nb")
jupyter_cache_path.mkdir(parents=True, exist_ok=True)
jupyter_cache = str(jupyter_cache_path)
Expand All @@ -83,7 +83,7 @@
atexit.register(lambda path=zfit_tutorials_path: shutil.rmtree(path))
pygit2.clone_repository("https://github.com/zfit/zfit-tutorials", zfit_tutorials_path)

execution_in_temp = True
nb_execution_in_temp = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
Expand Down
Binary file modified docs/images/Gaussian.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/zfit-logo-light_400x168.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/zfit-logo_57x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/zfit-logo_hires.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/images/zfit-logo_veryhires.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/tutorials/components/intro/space.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ with or without limits.

**Limit** The range on a certain axis. Typically defines an interval. In fact, there are two times of limits:
* **rectangular**: This type is the usual limit as e.g. ``(-2, 5)`` for a simple, 1 dimensional interval. It is
rectangular. This can either be given as ``limits`` of a :py:class:`~zfit.Space` or as `rect_limits``.
rectangular. This can either be given as ``limits`` of a :py:class:`~zfit.Space` or as ``rect_limits``.
* **functional**: In order to define arbitrary limits, a function can be used that receives a tensor-like
object ``x`` and returns ``True`` on every position that is inside the limits, ``False`` for every value outside.
When a functional limit is given, rectangular limits that contain the functional limit as a subset **must** be
Expand Down Expand Up @@ -80,7 +80,7 @@ to be combined with ``product`` has to be specified in the same space.
data = zfit.Data.from_numpy(obs=combined_obs, ...)
Now we have a :py:class:`~zfit.Data` object that is defined in the same domain as `product``
Now we have a :py:class:`~zfit.Data` object that is defined in the same domain as ``product``
and can be used to build a loss function.

Limits
Expand All @@ -99,9 +99,9 @@ two intervals) or combination (increase the dimensionality) are also possible.

added_limits = simple_limit1 + simple_limit2

In this case, ``added_limits`` is now a :py:class:`zfit.Space` with observable `'obs1'`` defined in the intervals
In this case, ``added_limits`` is now a :py:class:`zfit.Space` with observable ``obs1'`` defined in the intervals
(-5, 1) and (3, 7.5). This can be useful, *e.g.*, when fitting in two regions.
An example of the product of different :py:class:`zfit.Space` instances has been shown before as `combined_obs``.
An example of the product of different :py:class:`zfit.Space` instances has been shown before as ``combined_obs``.

Functional limits
'''''''''''''''''
Expand Down
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ mplhep # docs
myst-nb
pip>=9.0.1
pre-commit
progressbar2
pydata-sphinx-theme>=0.6.2 # fix for Jinja
pygit2
pyhf # for comparison of correctness
pyhf
pytest-benchmark
pyyaml
seed_intersphinx_mapping
Expand All @@ -28,7 +28,7 @@ sphinx-copybutton
sphinx-panels
sphinxcontrib-bibtex
sphinxcontrib-images
sphinxcontrib-youtube>=1.0.0
sphinxcontrib-youtube>=1.0.0,<1.2.0
tox>=2.9.1
twine>=1.10.0
watchdog>=0.8.3
Expand Down
28 changes: 14 additions & 14 deletions utils/api/argdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ pdf.init.norm: |1+
pdf.pdf.norm: |1+
Normalization of the function.
By default, this is the `norm` of the PDF (which by default is the same as
By default, this is the ``norm`` of the PDF (which by default is the same as
the space of the PDF).
pdf.init.extended: |1+
The overall yield of the PDF.
If this is parameter-like, it will be used as the yield,
the expected number of events, and the PDF will be extended.
An extended PDF has additional functionality, such as the
`ext_*` methods and the `counts` (for binned PDFs).
``ext_*`` methods and the ``counts`` (for binned PDFs).
pdf.init.extended.auto: |1+
If `True`,
If ``True``,
the PDF will be extended automatically if the PDF is extended
using the total number of events in the histogram.
This is the default.
Expand All @@ -61,11 +61,11 @@ pdf.integrate.limits: |1+
pdf.integrate.norm: |1+
Normalization of the integration.
By default, this is the same as the default space of the PDF.
`False` means no normalization and returns the unnormed integral.
``False`` means no normalization and returns the unnormed integral.
pdf.integrate.options: |1+
Options for the integration.
Additional options for the integration. Currently supported options are:
- type: one of (`bins`)
- type: one of (``bins``)
This hints that bins are integrated. A method that is vectorizable, non-dynamic and
therefore less suitable for complicated functions is chosen.
Expand All @@ -80,7 +80,7 @@ pdf.sample.limits: |1+
pdf.binned.counts.x: |1+
Data for the binned PDF.
The returned counts correspond to the binned axis in `x`.
The returned counts correspond to the binned axis in ``x``.
pdf.binned.counts.norm: |1+
Normalization of the counts.
Expand Down Expand Up @@ -295,14 +295,14 @@ minimizer.criterion: |1+
stopps and it is assumed that the minimum
has been found.
minimizer.strategy: |1+
A class of type `ZfitStrategy` that takes no
A class of type ``ZfitStrategy`` that takes no
input arguments in the init. Determines the behavior of the minimizer in
certain situations, most notably when encountering
NaNs. It can also implement a callback function.
minimizer.maxiter: |1+
Approximate number of iterations.
This corresponds to roughly the maximum number of
evaluations of the `value`, 'gradient` or `hessian`.
evaluations of the ``value``, 'gradient`` or ``hessian``.
minimizer.name: |1+
Human-readable name of the minimizer.
minimizer.maxcor: |1+
Expand Down Expand Up @@ -411,7 +411,7 @@ minimizer.nlopt.info: |1+
loss.binned.init.model: |1+
Binned PDF(s) that return the normalized probability
(`rel_counts` or `counts`) for
(``rel_counts`` or ``counts``) for
*data* under the given parameters.
If multiple model and data are given, they will be used
in the same order to do a simultaneous fit.
Expand Down Expand Up @@ -460,7 +460,7 @@ loss.init.explain.extendedterm: |1+
and the extended likelihood is the product of both.
loss.init.explain.simultaneous: |1+
A simultaneous fit can be performed by giving one or more `model`, `data`, to the loss. The
A simultaneous fit can be performed by giving one or more ``model``, ``data``, to the loss. The
length of each has to match the length of the others
.. math::
Expand Down Expand Up @@ -521,12 +521,12 @@ loss.init.options: |1+
value of the NLL is meaningless. However,
with this switch on, one cannot directly compare
different likelihoods ablolute value as the constant
may differ! Use `create_new` in order to have a comparable likelihood
may differ! Use ``create_new`` in order to have a comparable likelihood
between different losses
These settings may extend over time. In order to make sure that a loss is the
same under the same data, make sure to use `create_new` instead of instantiating
same under the same data, make sure to use ``create_new`` instead of instantiating
a new loss as the former will automatically overtake any relevant constants
and behavior.
Expand All @@ -543,10 +543,10 @@ result.init.params: |1+
value from the minimum found by the minimizer.
result.init.minimizer: |1+
Minimizer that was used to obtain this `FitResult` and will be used to
Minimizer that was used to obtain this ``FitResult`` and will be used to
calculate certain errors. If the minimizer
is state-based (like "iminuit"), then this is a copy
and the state of other `FitResults` or of the *actual*
and the state of other ``FitResults`` or of the *actual*
minimizer that performed the minimization
won't be altered.
result.init.valid: |1+
Expand Down
Loading

0 comments on commit 7ef35bf

Please sign in to comment.