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

Refactoring printing module with aeppl/printing.py #6447

Closed

Conversation

larryshamalama
Copy link
Member

Closes #6311 and #6261, supersedes #5793 and part of #6072.

This PR refactors most of our printing module. Most of the contents were taken verbatim from aeppl/printing.py as it was not ported in #6334; I was unable to retrieve the Git history from that file and the AePPL license is available in the beginning of the printing module now.

While tensor variables are no longer expected to have a str_repr method attached, the main benefits are that 1) printing is done with respect to Ops (instead of seeing f()s as per #6261) and 2) there will be a default printing mechanism for newly created distributions due to the dispatching approach, although how good the latter will be remains unclear to me. This PR also makes use of the printing module in PyTensor.

I am creating this PR "early on" to receive feedback, especially in how we want to display some newly created symbolic distributions and how the API will work. This refactoring took quite some time, so I also want to check in that this is going in the right direction as there are still many elements to work on. Tests will fail, for now at least. This will be a slow WIP.

To-do's:

  • Create CensoredPrinter
  • Adapt CensoredPrinter to the distribution being censored (e.g. CensoredNormal)
  • Adapt MarginalMixturePrinter when using single component dispatching
  • Refactor tests
  • Tailor docstrings to new printing functionality

@codecov
Copy link

codecov bot commented Jan 9, 2023

Codecov Report

Merging #6447 (367f60c) into main (434333f) will decrease coverage by 38.84%.
The diff coverage is 36.36%.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #6447       +/-   ##
===========================================
- Coverage   85.92%   47.07%   -38.85%     
===========================================
  Files         148      148               
  Lines       27691    27838      +147     
===========================================
- Hits        23794    13106    -10688     
- Misses       3897    14732    +10835     
Impacted Files Coverage Δ
pymc/distributions/discrete.py 52.42% <0.00%> (-46.80%) ⬇️
pymc/distributions/distribution.py 68.60% <ø> (-28.86%) ⬇️
pymc/printing.py 35.49% <36.19%> (-52.41%) ⬇️
pymc/distributions/mixture.py 28.00% <100.00%> (-67.41%) ⬇️
pymc/model.py 70.73% <100.00%> (-19.11%) ⬇️
pymc/tests/backends/test_base.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/tuning/test_scaling.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/tuning/test_starting.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/backends/test_ndarray.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/sampling/test_forward.py 0.00% <0.00%> (-100.00%) ⬇️
... and 75 more

@rlouf
Copy link
Contributor

rlouf commented Jan 9, 2023

👀

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.

Do not expect model variables to always have str_repr
2 participants