Skip to content

_get_scaling raises TypeError due to misformatted message #5545

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

Closed
Icyshaman opened this issue Mar 4, 2022 · 3 comments
Closed

_get_scaling raises TypeError due to misformatted message #5545

Icyshaman opened this issue Mar 4, 2022 · 3 comments
Labels

Comments

@Icyshaman
Copy link
Contributor

Description of your problem

When we are passing tuple (tuple is a valid data-structure for total_size) for total_size as an argument in _get_scaling() we are getting TypeError instead of ValueError even though it should raise a ValueError and this is all because of the use of old-style formatting.

Example:
When we pass a tuple containing more than one Ellipsis it should raise a ValueError but instead of that, it is throwing TypeError.

Please provide a minimal, self-contained, and reproducible example.

_get_scaling((1, 2, 5, Ellipsis, Ellipsis), (2, 3), 2)

Please provide the full traceback.
pymc.distributions.logprob._get_scaling()

Complete error traceback

Input In [1], in _get_scaling(total_size, shape, ndim)
     60     end = total_size[sep + 1 :]
     61     if Ellipsis in end:
     62         raise ValueError(
---> 63             "Double Ellipsis in `total_size` is restricted, got %r" % total_size
     64         )
     65 else:
     66     begin = total_size

TypeError: not all arguments converted during string formatting

Please provide any additional information below.
The above-mentioned issue can be solved by replacing

"Double Ellipsis in `total_size` is restricted, got %r" % total_size

in _get_scaling() by

"Double Ellipsis in `total_size` is restricted, got {}".format(total_size)

Since in present version of code it is trying to unpack the tuple elements which leads to error.

Versions and main components

  • PyMC/PyMC3 Version: 4.0.0b2
  • Aesara/Theano Version: 2.3.8
  • Python Version: 3.8.12
  • Operating system: Windows 10 Pro, Version: 21H1, OS Build: 19043.1566
  • How did you install PyMC/PyMC3: conda

Related To: #5544

@ricardoV94 ricardoV94 changed the title Valid tuple input for total_size in _get_scaling (pymc.distributions.logprob._get_scaling()) is throwing an unexpected error. _get_scaling raises TypeError due to misformatted message Mar 6, 2022
@ricardoV94
Copy link
Member

@Icyshaman Thanks for reporting. Do you want to open a PR to fix this issue?

@ricardoV94 ricardoV94 added the bug label Mar 6, 2022
@Icyshaman
Copy link
Contributor Author

@Icyshaman Thanks for reporting. Do you want to open a PR to fix this issue?

Sure, I will work on this.

@ricardoV94
Copy link
Member

I think we fixed this

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

No branches or pull requests

2 participants