Attempt to make setindex!! on PA slices more understandable#1326
Draft
penelopeysm wants to merge 1 commit intomainfrom
Draft
Attempt to make setindex!! on PA slices more understandable#1326penelopeysm wants to merge 1 commit intomainfrom
penelopeysm wants to merge 1 commit intomainfrom
Conversation
Contributor
Benchmark Report
Computer InformationBenchmark Results |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1326 +/- ##
==========================================
+ Coverage 78.26% 78.34% +0.07%
==========================================
Files 50 50
Lines 3566 3583 +17
==========================================
+ Hits 2791 2807 +16
- Misses 775 776 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cff4adc to
f883feb
Compare
penelopeysm
commented
Mar 14, 2026
Comment on lines
+672
to
+686
| # Step 2: Copy only the elements where value.mask is true. | ||
| # We mutate pa.data and pa.mask in place via views — this is safe because this | ||
| # function follows the `!!` convention (try to mutate, return the result). | ||
| # We do not do upfront type promotion here: the elements of `value` should have the | ||
| # same type as the elements of `pa`, since both originate from the same container. | ||
| data_view = view(pa.data, inds...; kw...) | ||
| mask_view = view(pa.mask, inds...; kw...) | ||
| for i in eachindex(value.mask) | ||
| if value.mask[i] | ||
| data_view[i] = value.data[i] | ||
| mask_view[i] = true | ||
| end | ||
| end | ||
|
|
||
| return pa |
Member
Author
There was a problem hiding this comment.
Claude claimed there's no need to broaden the eltype of pa.data, but I think it's wrong; I think it does need to be broadened if necessary. The issue with that is that it breaks type stability for some tests.
Contributor
|
DynamicPPL.jl documentation for PR #1326 is available at: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is Claude's partial attempt to refactor my ugly VNT code into smaller bits. Unfortunately, while the code here gives all the right results, it leads to type instabilities for less pathological cases, specifically setting
x[1][1,2]when there's already an element inside. Consequently, this cannot be merged right now. I don't yet know if this can be worked around.