Skip to content

Bug in conversion of None dims to InferenceData #6379

@ricardoV94

Description

@ricardoV94

Description

This snippet hast the effect of shifting the known dims to the "left":

https://github.com/pymc-devs/pymc/blob/6b60804c3a5fdb75f95cc60042061a6e38ec72a3/pymc/backends/arviz.py#L217-L220

import pymc as pm

with pm.Model(coords={"a": range(5)}) as m:
    x = pm.Normal("x", shape=(10, 5), dims=(None, "a"))        
    pm.sample()
ValueError: conflicting sizes for dimension 'a': length 10 on the data but length 5 on coordinate 'a'

Whereas this wrong specification goes unnoticed:

    x = pm.Normal("x", shape=(5, 10), dims=(None, "a"))        

Do we need None dims? It's annoying if we want to create Xarray datasets in multiple places as in #6374

More generally, it seems we don't do any sort of type check. The following are all allowed at creation time. I don't know if that's by design.

import pymc as pm
with pm.Model(coords={"a": range(5)}) as m:
    x = pm.Normal("x", shape=(10, 5), dims=("a", ..., 5, pm.Normal.dist()))        
    pm.sample()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions