pymc icon indicating copy to clipboard operation
pymc copied to clipboard

Removing unnecessary `comp_shape` from class NormalMixture

Open mohammed052 opened this issue 1 year ago β€’ 8 comments

This modification assumes that the Mixture class automatically handles the reshaping of component batch dimensions, and there is no longer a need to explicitly specify the comp_shape

Description

Related Issue

  • [x] Closes #6986

Checklist

Type of change

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

πŸ“š Documentation preview πŸ“š: https://pymc--7098.org.readthedocs.build/en/7098/

mohammed052 avatar Jan 11 '24 17:01 mohammed052

Thanks @mohammed052, running that tests and we can merge if everything passes

ricardoV94 avatar Jan 15 '24 08:01 ricardoV94

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 92.29%. Comparing base (a033261) to head (aa602ec).

:exclamation: Current head aa602ec differs from pull request most recent head b6eeec8. Consider uploading reports for the commit b6eeec8 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7098   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files         100      100           
  Lines       16875    16875           
=======================================
  Hits        15575    15575           
  Misses       1300     1300           
Files Coverage Ξ”
pymc/distributions/mixture.py 95.08% <100.00%> (ΓΈ)

codecov[bot] avatar Jan 15 '24 09:01 codecov[bot]

@mohammed052 you can see here some tests failed because they were still using the removed keyword: https://github.com/pymc-devs/pymc/actions/runs/7492576052/job/20484268751?pr=7098

We need to tweak the tests to not use it, but keep the same behavior otherwise.

ricardoV94 avatar Jan 15 '24 09:01 ricardoV94

@ricardoV94 can you please elaborate on what needs to be done next to tweak the tests

mohammed052 avatar Jan 15 '24 14:01 mohammed052

@mohammed052 you'll need to investigate yourself, and for that it may be useful to run the tests locally to see what they are doing

ricardoV94 avatar Jan 15 '24 15:01 ricardoV94

I was facing difficulty earlier in identifying the problem in tests.Thank You @larryshamalama for your input. I have made required changes in test_mixture.py. @ricardoV94 kindly review them.

mohammed052 avatar Feb 02 '24 08:02 mohammed052

Thanks for the changes

I was facing difficulty earlier in identifying the problem in tests.Thank You @larryshamalama for your input. I have made required changes in test_mixture.py. @ricardoV94 kindly review them.

There seems to be a lot more tests in test_mixture.py that has comp_shape as an argument, e.g. test_normal_mixture_nd. To be more time efficient, I can't identify every instance where these tests need modifications; there seem to be more. However, akin to my previous comment, the edits should be very similar.

larryshamalama avatar Feb 07 '24 00:02 larryshamalama

I made a few more changes last week, @ricardoV94 @larryshamalama can you now review the pull request once.

mohammed052 avatar Feb 12 '24 12:02 mohammed052

@mohammed052 you need to run pre-commit

diff --git a/tests/distributions/test_mixture.py b/tests/distributions/test_mixture.py
index ec1baa7..7ce6084 100644
--- a/tests/distributions/test_mixture.py
+++ b/tests/distributions/test_mixture.py
@@ -821,9 +821,7 @@ class TestNormalMixture:
             taus = Gamma("taus", alpha=1, beta=1, shape=comp_shape)
             ws = Dirichlet("ws", np.ones(ncomp), shape=(ncomp,))
             mixture0 = NormalMixture("m", w=ws, mu=mus, tau=taus, shape=nd)
-            obs0 = NormalMixture(
-                "obs", w=ws, mu=mus, tau=taus, observed=observed
-            )
+            obs0 = NormalMixture("obs", w=ws, mu=mus, tau=taus, observed=observed)
 
         with Model() as model1:

twiecki avatar Mar 25 '24 04:03 twiecki

I was the one rebasing this PR

ricardoV94 avatar Mar 25 '24 09:03 ricardoV94

Congratulations Banner] Congrats on merging your first pull request! :tada: We here at PyMC are proud of you! :sparkling_heart: Thank you so much for your contribution :gift:

welcome[bot] avatar Mar 25 '24 09:03 welcome[bot]