-
Notifications
You must be signed in to change notification settings - Fork 42
Make ismutable
a type-parameter of FunctionMap
#194
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
Codecov ReportBase: 99.47% // Head: 99.41% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #194 +/- ##
==========================================
- Coverage 99.47% 99.41% -0.07%
==========================================
Files 19 19
Lines 1530 1534 +4
==========================================
+ Hits 1522 1525 +3
- Misses 8 9 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
b07c670
to
7e8da22
Compare
@JeffFessler I suspect you are using |
acdda87
to
5efa304
Compare
5efa304
to
136e652
Compare
Sorry I messed a few things up while splitting. Seems fixed now. |
Ok, I did a test of I have not done much (if any) testing of PR branches of others so I want to describe the approach so that you can confirm if I did it properly. I started Julia 1.8 in an empty directory, then: ] activate .
add LinearMaps#dk/iipfunctionmap
add LinearMapsAA
test LinearMapsAA
add MIRT
test MIRT So LTGM overall, and I am sure that #193 will bite me too at some point so I am in favor of this direction! |
Thank you very much for the detailed report! If you received deprecation warnings (no matter how many), then it grabbed the right branch. I'm glad that tests pass, too. I hope that |
A bit of a drive-by comment, but I personally find |
Drive-by comments are always welcome! There is dispatch on |
I tend to agree. And the |
Hm, another option could be to make |
I realized we already have some kind of the necessary machinery: |
I think it is fine not to have type inference for the kwarg constructors because (at least in my use cases) construction is done just once in an initialization phase and not in any tight loop. Maintaining the old constructors sounds convenient to me. |
test/linearcombination.jl
Outdated
alloc = @allocated similar(v) | ||
Loop = @inferred CS + CS + CS | ||
@test Loop * v ≈ 3cumsum(v) | ||
@test (@allocated Loop * v) <= 3alloc | ||
Loop = @inferred CS + CS; Loop * v | ||
@test (@allocated Loop * v) <= 2alloc | ||
Lmix = @inferred CS + CS + CS!; Lmix * v | ||
@test (@allocated Lmix * v) <= 3alloc | ||
Lmix = @inferred CS + CS + CS!; Lmix * v | ||
@test (@allocated Lmix * v) <= 3alloc | ||
Lmix = @inferred CS! + (CS + CS); Lmix * v | ||
@test (@allocated Lmix * v) <= 3alloc |
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.
These tests are all sharp. They fail on the currently released version!
This is now new-feature-only, nothing breaks (except for the lack of complete type inference for the convenience constructor). Thanks @fredrikekre for retriggering some thought, thanks @JeffFessler for your comments and testing! |
BTW, I changed the default values of |
This takes a small step towards what I think is wide-spread in the SciML/DiffEq world: making mutability a type-parameter. This allows to solve #193 by multiple dispatch, rather than querying a specific field of all factors/summands. The downside is that previous constructor calls are potentially not fully inferred, see the changed tests. If we advise users, however, to use the
FunctionMap
constructor explicitly and provide the mutability information, that is most likely statically known anyway, directly, then that shouldn't do much harm. In any case, the current design is such that the "old" behavior still works, it's just deprecated. What I find nice is that for out-of-placeFunctionMap
s,A*B*C*D*x
first folds from the left, so that we first create aCompositeMap
until we hitx
, from where it folds from the right, without going through 3-argmul!
.