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 8 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/

Copy link

codecov bot commented Feb 8, 2025

Codecov Report

Attention: Patch coverage is 98.11321% with 1 line in your changes missing coverage. Please review.

Project coverage is 86.78%. Comparing base (e74c3af) to head (8a71015).

Files with missing lines Patch % Lines
arviz/plots/backends/bokeh/hdiplot.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2408      +/-   ##
==========================================
+ Coverage   86.75%   86.78%   +0.02%     
==========================================
  Files         124      124              
  Lines       12938    12973      +35     
==========================================
+ Hits        11224    11258      +34     
- Misses       1714     1715       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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