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

BUG: pt.full doesn't work with int shape #758

Closed
wd60622 opened this issue May 9, 2024 · 3 comments · Fixed by #759
Closed

BUG: pt.full doesn't work with int shape #758

wd60622 opened this issue May 9, 2024 · 3 comments · Fixed by #759
Labels
bug Something isn't working

Comments

@wd60622
Copy link
Contributor

wd60622 commented May 9, 2024

Describe the issue:

numpy.full works with shape as int and the pt.full docstring suggests that it works like numpy. However, this case does not work with current main branch of pytensor

Reproducable code example:

import pytensor.tensor as pt
import numpy as np

# Works
pt.full((5, 3), 3)

# Doesn't work
pt.full(5, 3) # TypeError see below
np.full(5, 3) # array([3, 3, 3, 3, 3])

# Work around
pt.full((5,), 3)

Error message:

Traceback (most recent call last):
    pt.full(5, 3)
  File "/home/.../pytensor/tensor/basic.py", line 1722, in full
    return alloc(fill_value, *shape)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Value after * must be an iterable, not int

PyTensor version information:

current main branch

Context for the issue:

Trying to switch out numpy with pytensor

@wd60622 wd60622 added the bug Something isn't working label May 9, 2024
@ricardoV94
Copy link
Member

Wanna open a PR?

@wd60622
Copy link
Contributor Author

wd60622 commented May 9, 2024

Sure thing. Do you expect alloc to handle it or only full?

@ricardoV94
Copy link
Member

ricardoV94 commented May 9, 2024

Only full, alloc is more internal and actually already accepts it because it expects separate values instead of a tuple?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants