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

Bugfix in VarInfo. #516

Merged
merged 7 commits into from
Aug 9, 2023
Merged

Bugfix in VarInfo. #516

merged 7 commits into from
Aug 9, 2023

Conversation

yebai
Copy link
Member

@yebai yebai commented Aug 8, 2023

No description provided.

src/varinfo.jl Outdated Show resolved Hide resolved
@torfjelde
Copy link
Member

I'll have a look at this in a few hours. But is it not supposed to be length instead of finish?

Also is this there an example test/case for this bug? As in, what is this fixing, given that we didn't have any failing tests in previous PRs?

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@yebai
Copy link
Member Author

yebai commented Aug 8, 2023

I'll have a look at this in a few hours. But is it not supposed to be length instead of finish?

Fixed.

Also is this there an example test/case for this bug? As in, what is this fixing, given that we didn't have any failing tests in previous PRs?

It fixes #504 (comment). Not sure why our tests didn't catch this issue -- maybe we didn't have a test targeting this new case at all.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

Pull Request Test Coverage Report for Build 5801165167

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 76.354%

Totals Coverage Status
Change from base Build 5794694053: 0.0%
Covered Lines: 2115
Relevant Lines: 2770

💛 - Coveralls

@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (4a986df) 76.35% compared to head (184888a) 76.36%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #516   +/-   ##
=======================================
  Coverage   76.35%   76.36%           
=======================================
  Files          24       24           
  Lines        2770     2771    +1     
=======================================
+ Hits         2115     2116    +1     
  Misses        655      655           
Files Changed Coverage Δ
src/test_utils.jl 84.70% <100.00%> (+0.04%) ⬆️
src/varinfo.jl 81.45% <100.00%> (ø)

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

src/varinfo.jl Outdated Show resolved Hide resolved
yebai and others added 2 commits August 8, 2023 20:22
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
test/varinfo.jl Outdated Show resolved Hide resolved
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@yebai
Copy link
Member Author

yebai commented Aug 8, 2023

I added some tests. Feel free to merge when CI passes.

Copy link
Member

@torfjelde torfjelde left a comment

Choose a reason for hiding this comment

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

Looks good! But can we move the added tests to the same tests as added in #513 + test all the varinfos?

test/varinfo.jl Outdated
Comment on lines 278 to 280
@model function demo2d()
return x ~ Dirichlet(2, 1.0)
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@model function demo2d()
return x ~ Dirichlet(2, 1.0)
end
@model demo2d() = x ~ Dirichlet(2, 1.0)

test/varinfo.jl Outdated
Comment on lines 293 to 295
@model function demo3d()
return x ~ Dirichlet(3, 1.0) # increase K to 3
end
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
@model function demo3d()
return x ~ Dirichlet(3, 1.0) # increase K to 3
end
@model demo3d() = x ~ Dirichlet(3, 1.0)

test/varinfo.jl Outdated
@@ -273,6 +273,40 @@
@test vals_prev == vi.metadata.x.vals
end

# See https://github.com/TuringLang/DynamicPPL.jl/issues/504
@testset "Dimentionality checks" begin
Copy link
Member

Choose a reason for hiding this comment

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

Can we move this to the same tests as added in #513, i.e. the testset in test/linking.jl + include tests for all the varinfos (those tests only test for 2d dirichlet, so it's just a matter of adding one more model to test).

test/varinfo.jl Outdated
end
model = demo2d()
vi = VarInfo(model) # make VarInfo -> sample from prior and compute logdensity
getlogp(vi) ≈ 0.0 # zero because Dirichlet(1) == Uniform over Simplex
Copy link
Member

Choose a reason for hiding this comment

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

This is not a @test

test/varinfo.jl Outdated
getlogp(vi) ≈ 0.0 # zero because Dirichlet(1) == Uniform over Simplex
spl = SampleFromPrior() # create dummy sampler for linking
DynamicPPL.link!!(vi, spl, model) # transform to unconstrained space
!(0.0 ≈ getlogp(last(DynamicPPL.evaluate!!(model, vi)))) # non-zero now due to log(abs(determinant(jacobian)))
Copy link
Member

Choose a reason for hiding this comment

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

This is not a @test

test/varinfo.jl Outdated
end
model = demo3d()
vi = VarInfo(model) # make VarInfo -> sample from prior and compute logdensity
getlogp(vi) ≈ 0.0 # zero because Dirichlet(1) == Uniform over Simplex
Copy link
Member

Choose a reason for hiding this comment

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

This is not a @test

test/varinfo.jl Outdated
getlogp(vi) ≈ 0.0 # zero because Dirichlet(1) == Uniform over Simplex
spl = SampleFromPrior() # create dummy sampler for linking
DynamicPPL.link!!(vi, spl, model) # transform to unconstrained space
!(0.0 ≈ getlogp(last(DynamicPPL.evaluate!!(model, vi)))) # non-zero now due to log(abs(determinant(jacobian)))
Copy link
Member

Choose a reason for hiding this comment

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

This is not a @test

@yebai
Copy link
Member Author

yebai commented Aug 8, 2023

I'll probably not have much time till late this week; please feel free to take over this PR if it needs to be merged quicker.

@torfjelde
Copy link
Member

Fixed the tests in #517 ; feel free to just merge this into this PR. Then it should be an easy approve:) (the added tests are passing locally)

* fixed tests for linking of dirichlet with different dimensionality

* added usage of same logp in TestUtils.setup_varinfos
@torfjelde torfjelde added this pull request to the merge queue Aug 9, 2023
Merged via the queue into master with commit 7ef5da7 Aug 9, 2023
1 check passed
@torfjelde torfjelde deleted the yebai-patch-1 branch August 9, 2023 06:24
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.

3 participants