Skip to content

Commit 10bba2e

Browse files
committed
enh: use the autograd_params to not take a gradient with respect to lambda
1 parent 2e8f2ee commit 10bba2e

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

src/zfit_physics/models/pdf_Ipatia2.py

Whitespace-only changes.
Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,16 @@ def __init__(
263263
The default space is used for example in the sample method: if no
264264
sampling limits are given, the default space is used.
265265
266+
If the observables are binned and the model is unbinned, the
267+
model will be a binned model, by wrapping the model in a
268+
:py:class:`~zfit.pdf.BinnedFromUnbinnedPDF`, equivalent to
269+
calling :py:meth:`~zfit.pdf.BasePDF.to_binned`.
270+
271+
If the observables are binned and the model is unbinned, the
272+
model will be a binned model, by wrapping the model in a
273+
:py:class:`~zfit.pdf.BinnedFromUnbinnedPDF`, equivalent to
274+
calling :py:meth:`~zfit.pdf.BasePDF.to_binned`.
275+
266276
The observables are not equal to the domain as it does not restrict or
267277
truncate the model outside this range. |@docend:pdf.init.obs|
268278
mu: Location parameter. Shifts the distribution left/right.
@@ -281,10 +291,13 @@ def __init__(
281291
``ext_*`` methods and the ``counts`` (for binned PDFs). |@docend:pdf.init.extended|
282292
norm: |@doc:pdf.init.norm| Normalization of the PDF.
283293
By default, this is the same as the default space of the PDF. |@docend:pdf.init.norm|
284-
name: |@doc:pdf.init.name| Human-readable name
294+
name: |@doc:pdf.init.name| Name of the PDF.
295+
Maybe has implications on the serialization and deserialization of the PDF.
296+
For a human-readable name, use the label. |@docend:pdf.init.name|
297+
label: |@doc:pdf.init.label| Human-readable name
285298
or label of
286-
the PDF for better identification. |@docend:pdf.init.name|
287-
label: |@doc:pdf.init.label| Label of the PDF, if None is given, it will be the name. |@docend:pdf.init.label|
299+
the PDF for a better description, to be used with plots etc.
300+
Has no programmatical functional purpose as identification. |@docend:pdf.init.label|
288301
"""
289302
params = {
290303
"mu": mu,
@@ -297,10 +310,20 @@ def __init__(
297310
"alphar": alphar,
298311
"nr": nr,
299312
}
300-
super().__init__(obs=obs, params=params, name=name, extended=extended, norm=norm, label=label)
313+
autograd_params = set(params) - {"lambd"}
314+
super().__init__(
315+
obs=obs,
316+
params=params,
317+
name=name,
318+
extended=extended,
319+
norm=norm,
320+
label=label,
321+
autograd_params=autograd_params,
322+
)
301323

302-
@zfit.supports()
303-
def _unnormalized_pdf(self, x: tf.Tensor, params) -> tf.Tensor:
324+
@zfit.supports(norm=False)
325+
def _pdf(self, x: tf.Tensor, norm, params) -> tf.Tensor:
326+
del norm
304327
x0 = x[0]
305328
mu = params["mu"]
306329
sigma = params["sigma"]
@@ -311,5 +334,4 @@ def _unnormalized_pdf(self, x: tf.Tensor, params) -> tf.Tensor:
311334
nl = params["nl"]
312335
alphar = params["alphar"]
313336
nr = params["nr"]
314-
315337
return hypatia2_func(x0, mu, sigma, lambd, zeta, beta, alphal, nl, alphar, nr)

0 commit comments

Comments
 (0)