Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FFTConvPDFV1 doesn't work with create_extended #386

Open
LHUecker opened this issue Mar 2, 2022 · 2 comments
Open

FFTConvPDFV1 doesn't work with create_extended #386

LHUecker opened this issue Mar 2, 2022 · 2 comments

Comments

@LHUecker
Copy link

LHUecker commented Mar 2, 2022

Bug

When a PDF is created with FFTConvPDFV1, the create_extended method raises a Type Error.
However set_yield still works.

Current Behaviour

import zfit
obs = zfit.Space('x', (-0.8,1.3))
yield = zfit.Parameter('sig_yield', 500, step_size=1)
loc = zfit.Parameter('loc', 0, floating=False)
lam = zfit.Parameter('lam', 0, -2, 1, step_size = 0.001)
sigma = zfit.Parameter('sigma', 0.07, 0.0, 0.2, step_size = 0.001)
lower = zfit.Parameter('lower', 0.0, -0.5, 0.5, step_size = 0.0001)
upper = zfit.Parameter('upper', 0.3, -0.2, 0.8, step_size = 0.0001)

gauss = zfit.pdf.Gauss(obs=obs, mu=loc, sigma=sigma)
uniform = zfit.pdf.Uniform(obs=obs, low=lower, high=upper)

conv = zfit.pdf.FFTConvPDFV1(uniform, gauss)
conv_ext = conv.create_extended(yield)

 ---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_2005/35580713.py in <module>
----> 1 conv_ext = conv.create_extended(yield_c)

~/.local/lib/python3.9/site-packages/zfit/core/basepdf.py in create_extended(self, yield_, name_addition)
    445         if self.is_extended:
    446             raise AlreadyExtendedPDFError("This PDF is already extended, cannot create an extended one.")
--> 447         new_pdf = self.copy(name=self.name + str(name_addition))
    448         new_pdf.set_yield(value=yield_)
    449         return new_pdf

~/.local/lib/python3.9/site-packages/zfit/core/basepdf.py in copy(self, **override_parameters)
    618         #     parameters.update(distribution=self.distribution)
    619         yield_ = parameters.pop('yield', None)
--> 620         new_instance = type(self)(**parameters)
    621         if yield_ is not None:
    622             new_instance.set_yield(yield_)

TypeError: __init__() got an unexpected keyword argument 'pdfs'

Expected Behaviour

Should return a new PDF that is extended.

Context (Environment)

  • zfit version: 0.8.2 & 0.9.0a0
  • Python version: 3.9.10
  • Are you using conda, pipenv, etc? : conda
  • Operating System: CentOS Linux (lxplus)
  • Tensorflow version: 2.5.0

Possible Solution/Implementation

set_yield works perfectly fine as an alternativ if one doesn't need to return a new PDF.

@jonas-eschle
Copy link
Contributor

Hey, thank you very much for raising the issue! This is indeed a known problem which has roots that are deeper in the design to do it properly and the recommended way is to use set_yield in place for now.

@jonas-eschle
Copy link
Contributor

Just to add to this @LHUecker , the preferred way is now to create an extended PDF right with the initialization, all PDFs now take an extended argument which can be a yield.
Does this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants