Skip to content

RandomVariable treats size=() as size=None #568

Closed
@ricardoV94

Description

@ricardoV94

Description

This is different than numpy

import numpy as np
import pytensor.tensor as pt

pt.random.normal([0], size=None).eval()  # array([-0.57354733])
pt.random.normal([0], size=()).eval()  # array([-2.39088062])

np.random.normal([0], size=None)  # array([0.10438181])
np.random.normal([0], size=()).eval()  # ValueError: Output size () is not compatible with broadcast dimensions of inputs (1,).

And also JAX (and probably Numba?)

import jax

jax.random.lognormal(jax.random.PRNGKey(0), sigma=jax.numpy.ones((1,)), shape=())
# parameter shapes must be broadcast-compatible with shape argument, 
# and the result of broadcasting the shapes must equal the shape argument, 
# but got result (1,) for shape argument ().

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions