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

Fix type instability when setindex!! #549

Merged
merged 8 commits into from
Nov 2, 2023
Merged

Conversation

sunxd3
Copy link
Collaborator

@sunxd3 sunxd3 commented Oct 24, 2023

Temporary fix for #530

src/utils.jl Outdated
Comment on lines 572 to 577
function BangBang.possible(
::typeof(BangBang._setindex!), ::C, ::T, ::Vararg
) where {C<:AbstractArray,T<:AbstractArray}
return BangBang.implements(setindex!, C) &&
promote_type(eltype(C), eltype(T)) <: eltype(C)
end
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 type piracy, isn't it? It shouldn't be defined in DynamicPPL but in BangBang itself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, @torfjelde already open a PR at JuliaFolds/BangBang.jl#238.

Copy link
Member

Choose a reason for hiding this comment

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

This repo is inactive. JuliaFolds was forked to JuliaFolds2, so the PR has to be opened in https://github.com/JuliaFolds2/BangBang.jl.

Copy link
Member

Choose a reason for hiding this comment

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

We should be able to get a timely review and release there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also verified locally that the BangBang PR should fix the issue

Copy link
Member

Choose a reason for hiding this comment

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

Oh wow, I was not aware of this! Okay, that's quite good to know 👍

And yeah, we should do that 👍

One thing though: we probably don't need the other overloads with this Vararg version, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think removing the other should be safe 👍.

Maybe if the JuliaFold2 folks are responsive, this PR can be just removing all the BangBang.possible

@github-actions
Copy link
Contributor

Pull Request Test Coverage Report for Build 6623738317

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.01%) to 82.778%

Totals Coverage Status
Change from base Build 6619122585: 0.01%
Covered Lines: 2634
Relevant Lines: 3182

💛 - Coveralls

@codecov
Copy link

codecov bot commented Oct 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (12e7c27) 82.76% compared to head (3ca938c) 80.29%.
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #549      +/-   ##
==========================================
- Coverage   82.76%   80.29%   -2.48%     
==========================================
  Files          25       25              
  Lines        3180     3156      -24     
==========================================
- Hits         2632     2534      -98     
- Misses        548      622      +74     
Files Coverage Δ
src/utils.jl 82.28% <100.00%> (+0.78%) ⬆️

... and 13 files with indirect coverage changes

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

@sunxd3
Copy link
Collaborator Author

sunxd3 commented Oct 24, 2023

Just making a note: comparing the size and dimensions of the target and value arrays is bad, because the existence of vector of arrays

@torfjelde
Copy link
Member

torfjelde commented Oct 24, 2023

Just making a note: comparing the size and dimensions of the target and value arrays is bad, because the existence of vector of arrays

Is this referring to my PR to BangBang.jl? If so, isn't this dealt with first through the check of the eltypes?

EDIT: Realized what you meant. I think we should just restrict to Real. Seems like the easiest way to go about it.

@torfjelde
Copy link
Member

JuliaFolds2/BangBang.jl#16

@sunxd3
Copy link
Collaborator Author

sunxd3 commented Oct 24, 2023

Is this referring to my PR to BangBang.jl?

Haha, it was actually for myself, sorry for the confusion, I was trying to make the possible function more restrictive by comparing the size of target and value, then I realize it was unnecessary.

@torfjelde
Copy link
Member

@devmotion do you know who to ping for the PR over at JuliaFolds2?

@devmotion
Copy link
Member

Mason would be my first guess.

@sunxd3
Copy link
Collaborator Author

sunxd3 commented Oct 31, 2023

@torfjelde, @devmotion do we want to merge this for now and remove the type-piracy code after the JuliaFolds2 PR merged?

@torfjelde
Copy link
Member

torfjelde commented Oct 31, 2023 via email

@torfjelde
Copy link
Member

@sunxd3 do you want to have a go at moving the changes from my PR into one for DynamicPPL?

@sunxd3
Copy link
Collaborator Author

sunxd3 commented Nov 1, 2023

Done, although I didn't copy the tests form JuliaFolds2

@torfjelde
Copy link
Member

Dope 👍 We should also include the tests though

@sunxd3
Copy link
Collaborator Author

sunxd3 commented Nov 1, 2023

@torfjelde another look?

@yebai yebai enabled auto-merge November 2, 2023 17:38
@yebai yebai added this pull request to the merge queue Nov 2, 2023
Merged via the queue into master with commit 2e940aa Nov 2, 2023
12 of 14 checks passed
@yebai yebai deleted the sunxd/fix_bangbang_possible branch November 2, 2023 18:07
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.

4 participants