-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Removing unnecessary comp_shape
from class NormalMixture
#7098
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
Conversation
comp_shape
from class NormalMixture
Thanks @mohammed052, running that tests and we can merge if everything passes |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7098 +/- ##
=======================================
Coverage 92.29% 92.29%
=======================================
Files 100 100
Lines 16875 16875
=======================================
Hits 15575 15575
Misses 1300 1300
|
@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 can you please elaborate on what needs to be done next to tweak the tests |
@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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mohammed052, as @ricardoV94 mentioned, you will have to adjust tests in test_mixture.py
as comp_shape
is still passed as an argument to NormalMixture
, which is why the tests are failing. Notice the lines where we have extra_args={"comp_shape": 2}
. See snippets below. Once all tests pass, this PR would be ready to merge :)
Let us know if you have any other questions!
pymc/tests/distributions/test_mixture.py
Lines 858 to 884 in 94020c9
def test_random(self, seeded_test): | |
def ref_rand(size, w, mu, sigma): | |
component = np.random.choice(w.size, size=size, p=w) | |
return np.random.normal(mu[component], sigma[component], size=size) | |
continuous_random_tester( | |
NormalMixture, | |
{ | |
"w": Simplex(2), | |
"mu": Domain([[0.05, 2.5], [-5.0, 1.0]], edges=(None, None)), | |
"sigma": Domain([[1, 1], [1.5, 2.0]], edges=(None, None)), | |
}, | |
extra_args={"comp_shape": 2}, | |
size=1000, | |
ref_rand=ref_rand, | |
) | |
continuous_random_tester( | |
NormalMixture, | |
{ | |
"w": Simplex(3), | |
"mu": Domain([[-5.0, 1.0, 2.5]], edges=(None, None)), | |
"sigma": Domain([[1.5, 2.0, 3.0]], edges=(None, None)), | |
}, | |
extra_args={"comp_shape": 3}, | |
size=1000, | |
ref_rand=ref_rand, | |
) |
pymc/tests/distributions/test_mixture.py
Lines 893 to 907 in 94020c9
def test_scalar_components(self): | |
nd = 3 | |
npop = 4 | |
# [[0, 1, 2, 3], [0, 1, 2, 3], [0, 1, 2, 3]] | |
mus = pt.constant(np.full((nd, npop), np.arange(npop))) | |
with Model() as model: | |
m = NormalMixture( | |
"m", | |
w=np.ones(npop) / npop, | |
mu=mus, | |
sigma=1e-5, | |
comp_shape=(nd, npop), | |
shape=nd, | |
) |
I was facing difficulty earlier in identifying the problem in tests.Thank You @larryshamalama for your input. |
Thanks for the changes
There seems to be a lot more tests in |
I made a few more changes last week, @ricardoV94 @larryshamalama can you now review the pull request once. |
a73e954
to
aa602ec
Compare
@mohammed052 you need to run pre-commit
|
I was the one rebasing this PR |
aa602ec
to
b6eeec8
Compare
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
Checklist
Type of change
📚 Documentation preview 📚: https://pymc--7098.org.readthedocs.build/en/7098/