From 10bba2e3cf1a2529c77e46bfdbcce9c5cb10fd1d Mon Sep 17 00:00:00 2001 From: Jonas Eschle Date: Fri, 1 Nov 2024 15:20:05 -0400 Subject: [PATCH] enh: use the autograd_params to not take a gradient with respect to lambda --- src/zfit_physics/models/pdf_Ipatia2.py | 0 .../zfit_physics}/models/pdf_hypatia2.py | 36 +++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) delete mode 100644 src/zfit_physics/models/pdf_Ipatia2.py rename {zfit_physics => src/zfit_physics}/models/pdf_hypatia2.py (89%) diff --git a/src/zfit_physics/models/pdf_Ipatia2.py b/src/zfit_physics/models/pdf_Ipatia2.py deleted file mode 100644 index e69de29..0000000 diff --git a/zfit_physics/models/pdf_hypatia2.py b/src/zfit_physics/models/pdf_hypatia2.py similarity index 89% rename from zfit_physics/models/pdf_hypatia2.py rename to src/zfit_physics/models/pdf_hypatia2.py index 377741f..be1302a 100644 --- a/zfit_physics/models/pdf_hypatia2.py +++ b/src/zfit_physics/models/pdf_hypatia2.py @@ -263,6 +263,16 @@ def __init__( The default space is used for example in the sample method: if no sampling limits are given, the default space is used. + If the observables are binned and the model is unbinned, the + model will be a binned model, by wrapping the model in a + :py:class:`~zfit.pdf.BinnedFromUnbinnedPDF`, equivalent to + calling :py:meth:`~zfit.pdf.BasePDF.to_binned`. + + If the observables are binned and the model is unbinned, the + model will be a binned model, by wrapping the model in a + :py:class:`~zfit.pdf.BinnedFromUnbinnedPDF`, equivalent to + calling :py:meth:`~zfit.pdf.BasePDF.to_binned`. + The observables are not equal to the domain as it does not restrict or truncate the model outside this range. |@docend:pdf.init.obs| mu: Location parameter. Shifts the distribution left/right. @@ -281,10 +291,13 @@ def __init__( ``ext_*`` methods and the ``counts`` (for binned PDFs). |@docend:pdf.init.extended| norm: |@doc:pdf.init.norm| Normalization of the PDF. By default, this is the same as the default space of the PDF. |@docend:pdf.init.norm| - name: |@doc:pdf.init.name| Human-readable name + name: |@doc:pdf.init.name| Name of the PDF. + Maybe has implications on the serialization and deserialization of the PDF. + For a human-readable name, use the label. |@docend:pdf.init.name| + label: |@doc:pdf.init.label| Human-readable name or label of - the PDF for better identification. |@docend:pdf.init.name| - label: |@doc:pdf.init.label| Label of the PDF, if None is given, it will be the name. |@docend:pdf.init.label| + the PDF for a better description, to be used with plots etc. + Has no programmatical functional purpose as identification. |@docend:pdf.init.label| """ params = { "mu": mu, @@ -297,10 +310,20 @@ def __init__( "alphar": alphar, "nr": nr, } - super().__init__(obs=obs, params=params, name=name, extended=extended, norm=norm, label=label) + autograd_params = set(params) - {"lambd"} + super().__init__( + obs=obs, + params=params, + name=name, + extended=extended, + norm=norm, + label=label, + autograd_params=autograd_params, + ) - @zfit.supports() - def _unnormalized_pdf(self, x: tf.Tensor, params) -> tf.Tensor: + @zfit.supports(norm=False) + def _pdf(self, x: tf.Tensor, norm, params) -> tf.Tensor: + del norm x0 = x[0] mu = params["mu"] sigma = params["sigma"] @@ -311,5 +334,4 @@ def _unnormalized_pdf(self, x: tf.Tensor, params) -> tf.Tensor: nl = params["nl"] alphar = params["alphar"] nr = params["nr"] - return hypatia2_func(x0, mu, sigma, lambd, zeta, beta, alphal, nl, alphar, nr)