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

Relax pm.observe to allow observing already observed variables #7679

Merged
merged 1 commit into from
Feb 8, 2025

Conversation

zaxtax
Copy link
Contributor

@zaxtax zaxtax commented Feb 8, 2025

Description

This PR closes #6932 by relaxing checks over which model variables can be observed to include already observed variables.

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7679.org.readthedocs.build/en/7679/

@zaxtax zaxtax requested a review from ricardoV94 February 8, 2025 16:04
Copy link

codecov bot commented Feb 8, 2025

Codecov Report

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

Project coverage is 92.70%. Comparing base (d7d2be2) to head (02bb237).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pymc/model/transform/conditioning.py 66.66% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7679   +/-   ##
=======================================
  Coverage   92.70%   92.70%           
=======================================
  Files         107      107           
  Lines       18391    18391           
=======================================
  Hits        17050    17050           
  Misses       1341     1341           
Files with missing lines Coverage Δ
pymc/model/transform/conditioning.py 95.74% <66.66%> (ø)

@@ -95,7 +96,7 @@ def observe(
for var, obs in vars_to_observations.items()
}

valid_model_vars = set(model.free_RVs + model.deterministics)
valid_model_vars = set(model.free_RVs + model.deterministics + model.observed_RVs)
Copy link
Member

@ricardoV94 ricardoV94 Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message below should be updated to "... is not a random variable or deterministic in the model"

You can use model.basic_RVs in place of free + observed, and ModelValuedVar for the corresponding in the ir representation in the assert below

@zaxtax zaxtax merged commit 358b825 into pymc-devs:main Feb 8, 2025
25 checks passed
@zaxtax zaxtax deleted the relax_observe branch February 8, 2025 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ENH: Enable changing observations of observed variables with observe operator
2 participants