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

Fix plot_lm handling of multidimensional data with y_model (#1992) #2408

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

uzairgheewala
Copy link

@uzairgheewala uzairgheewala commented Jan 13, 2025

Description

Fix plot_lm functionality when using multidimensional data with y_model parameter. Previously, attempting to use plot_lm with both multidimensional y and y_model would result in dimension mismatch errors.
Also adds a test to check for the proper functioning of plot_lm when using multidimensional data with y_model parameter.
Addresses issue #1992.

Checklist

  • Follows official PR format
  • Includes a sample plot to visually illustrate the changes (only for plot-related functions)
  • Includes new or updated tests to cover the new feature
  • Code style correct (follows pylint and black guidelines)
  • Changes are listed in changelog

Following problematic cases in this notebook now work: https://gist.github.com/colehaus/b2aa195687f53ef7c86eec2ebb3798c2

  # Works now with multidimensional data
  data = az.from_dict(
      observed_data = { "y": np.random.normal(size=(5, 7)) },
      posterior = {"y_model": np.random.randn(4, 1000, 5, 7)},
      dims={"y": ["dim1", "dim2"]},
      coords={"dim1": range(5), "dim2": range(7)}
  )
  # Both modes now work
  az.plot_lm(idata=data, y="y", plot_dim="dim1", y_model="y_model", kind_model="lines")
  az.plot_lm(idata=data, y="y", plot_dim="dim1", y_model="y_model", kind_model="hdi")

📚 Documentation preview 📚: https://arviz--2408.org.readthedocs.build/en/2408/

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

Successfully merging this pull request may close these issues.

1 participant