Skip to content

Reconsider not allowing shape/ellipsis in dist classmethods #5701

@ricardoV94

Description

@ricardoV94

When working in #5690, I realized we have a bug when doing the following:

import pymc as pm
x = pm.GaussianRandomWalk.dist(init=pm.Normal.dist(), steps=5, shape=(3, ...))
print(x.shape.eval())  # [3, 3, 6]; should be [3, 6]
print(x.eval())  # ValueError

This happens because we have to resize init to be of the same size of x, as the GaussianRandomWalk (GRW) is a composite distribution of init + innovations. We do this in dist, and I simply did not consider that shape could have an ellipsis.

In general, this sort of issue will be prevalent in most "composite" distributions, such as LKJCorr, Censored, Mixture, and so on, where we need to resize some of the the dist arguments to match size, shape, dims or else ask users to to it themselves. We can make things quite simpler for us if we don't allow the ellipsis or shape argument into the dist classmethod, as we will only have to worry about size in that case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions