Open
Description
Bugs Please fill the below form if possible.
It seems that I cannot use names that start with _
when making JohnsonSU
PDFs.
You should be able to reproduce the problem with:
import zfit
obs = zfit.Space('B_M', limits=(4500, 6000))
mu = zfit.param.Parameter('mu_suj', 5300, 4000, 6000)
sg = zfit.param.Parameter('sg_suj', 10, 2, 1000)
gm = zfit.param.Parameter('gm_suj', 1, 0.1, 10)
dl = zfit.param.Parameter('dl_suj', 1, 0.1, 10)
pdf = zfit.pdf.JohnsonSU(mu, sg, gm, dl, obs, name='_name')
dat = pdf.create_sampler(n=10_000)
nll = zfit.loss.UnbinnedNLL(model=pdf, data=dat)
minimizer = zfit.minimize.Minuit()
result = minimizer.minimize(nll)
if you use name
instead of _name
, the error goes away.
Current Behaviour
I would expect to be able to use any name, as with the other PDFs.
2025-02-26 11:15:33.666113: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:477] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
E0000 00:00:1740539733.677244 209190 cuda_dnn.cc:8310] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
E0000 00:00:1740539733.680699 209190 cuda_blas.cc:1418] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2025-02-26 11:15:35.804243: E external/local_xla/xla/stream_executor/cuda/cuda_driver.cc:152] failed call to cuInit: INTERNAL: CUDA error: Failed call to cuInit: UNKNOWN ERROR (303)
Traceback (most recent call last):
File "/home/acampove/Tests/zfit/suj/test.py", line 10, in <module>
dat = pdf.create_sampler(n=10_000)
File "/home/acampove/.local/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py", line 588, in new_func
return func(*args, **kwargs)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1127, in create_sampler
return SamplerData.from_sampler(
File "/home/acampove/.local/lib/python3.9/site-packages/tensorflow/python/util/deprecation.py", line 588, in new_func
return func(*args, **kwargs)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/data.py", line 1450, in from_sampler
init_val, init_weights = sample_and_weights_func(n, params)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/data.py", line 1439, in sample_and_weights_func
return sample_func(n, params), None
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1125, in sample_func
return self.sample(n=n, limits=limits, params=params).value()
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1196, in sample
tensor = run_tf(n=n, limits=limits, x=xclean)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1192, in run_tf
return self._single_hook_sample(n=n, limits=limits, x=x) # todo: make data a composite object
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/z/zextension.py", line 332, in concrete_func
result = func_to_run(*args, **kwargs)
File "/home/acampove/.local/lib/python3.9/site-packages/tensorflow/python/util/traceback_utils.py", line 153, in error_handler
raise e.with_traceback(filtered_tb) from None
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1202, in _single_hook_sample
return self._hook_sample(n=n, limits=limits)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basepdf.py", line 787, in _hook_sample
samples = super()._hook_sample(limits=limits, n=n)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1205, in _hook_sample
return self._limits_sample(n=n, limits=limits)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1209, in _limits_sample
return self._call_sample(n=n, limits=limits)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/core/basemodel.py", line 1237, in _call_sample
return self._analytic_sample(n=n, limits=limits)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/models/dist_tfp.py", line 119, in _analytic_sample
return tfd_analytic_sample(n=n, dist=self.distribution, limits=limits)
File "/home/acampove/.local/lib/python3.9/site-packages/zfit/models/dist_tfp.py", line 102, in distribution
return self._distribution(**params, **kwargs, name=self.name + "_tfp")
File "/home/acampove/.local/lib/python3.9/site-packages/decorator.py", line 235, in fun
return caller(func, *(extras + args), **kw)
File "/home/acampove/.local/lib/python3.9/site-packages/tensorflow_probability/python/distributions/distribution.py", line 342, in wrapped_init
default_init(self_, *args, **kwargs)
File "/home/acampove/.local/lib/python3.9/site-packages/tensorflow_probability/python/distributions/johnson_su.py", line 169, in __init__
with tf.name_scope(name or 'JohnsonSU') as name:
File "/usr/lib64/python3.9/contextlib.py", line 119, in __enter__
return next(self.gen)
ValueError: '_name_tfp' is not a valid root scope name. A root scope name has to match the following pattern: ^[A-Za-z0-9.][A-Za-z0-9_.\\/>-]*$
Expected Behaviour
Context (Environment)
- zfit version: 0.24.3
- Python version: 3.9.21
- Are you using conda, pipenv, etc? : micromamba
- Operating System: AlmaLinux 9
- Tensorflow version: tensorflow-2.18.0-cp39-cp39