-
Notifications
You must be signed in to change notification settings - Fork 38
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
Solve all problems with extra indirection #163
Conversation
Codecov Report
@@ Coverage Diff @@
## master #163 +/- ##
==========================================
+ Coverage 96.25% 96.49% +0.24%
==========================================
Files 4 4
Lines 640 627 -13
==========================================
- Hits 616 605 -11
+ Misses 24 22 -2
Continue to review full report at Codecov.
|
Boom. Thanks. I knew you'd be the one to know the solution haha |
The best answer to ambiguities is almost always to delete methods. After all, if you have 0 methods, it's guaranteed there will be 0 ambiguities 😆. |
Note the I think this is probably more proof that the tests are not testing the added functionality of the overload, rather that it doesn't break. But TBH I don't really understand the use case for these special |
Here's a test that now passes that didn't before: mask = OffsetArray(Trues(dim), 0:3, -2:2)
x = OffsetArray(randn(dim), axes(mask)...)
@test x[mask] == vec(x)
@test_throws BoundsError x[parent(mask)] Unfortunately, simply loading OffsetArrays introduces an ambiguity with your reshape methods. If you delete all your support for |
908512a
to
2f95b82
Compare
This should fix it.
I am guessing it's a performance optimization to save time in checking each boolean value. |
Removing In the end ambiguities are just a fact of life in combining Julia packages, trying to avoid them completely is not realistic. This is where a glue package called OffsetFillArrays.jl or whatever would come in (with future Pkg support for making it mandatory when one uses the two packages together) |
Yes of course, the question is when would anyone in practice call |
The `getindex` and `setindex!` methods for `Trues` are limited while also risking ambiguities. This replaces those definitions with a specialization for `to_indices` that avoids such problems. Closes #162
2f95b82
to
44e223b
Compare
I bet there's a way around it. You're right, though, that Base has |
I wonder if long term it’s better to make an ordering of which comes first, array overloads or shapes. If so we could do reshape(A…) = reshapebyshapes(A…)
reshapebyshapes(A…) = reshapebyarraytype(A…)
reshapebyarraytype(A…) = defaultreshape(A…) Then if one only does overloads by reshapebyshapes(A, ::MyShape) = …
reshapebyarraytype(A::MyArray, sh…) = … We would avoid ambiguity But would need a change in |
Yep, it's a tricky design problem. No time to look into it now, but it turns out that when I tested reshape method deletion I also deleted all the support routines. If you keep those and just delete the Shall I pile that on here or do you want a separate PR? |
Does it still return a |
Yes (the tests check as much) |
My use case for So I very much hope that some version of Is there some other way to restrict the types of this I need to think more about whether the proposed deletion of On a perhaps slightly related note, to support all the functionality needed efficiently I also had to write a |
@JeffFessler Yes no rush. It's possible to fix the issue without deleting everything. Can you add tests so that we make sure we don't lose the functionality you need? |
Yes, that's a good idea. I really doubt there will be any performance implications but you never know unless you check. No rush here. |
Can we merge this? I think that's been ample time to test. |
and a tag? |
Sure, done. Note (I assume) you have admin rights and can just tag a new release yourself in the future |
Err no one bumped the version. If you want a PR tagged please up the version first. |
The
getindex
andsetindex!
methods forTrues
are limitedwhile also risking ambiguities. This replaces those definitions
with a specialization for
to_indices
that avoids such problems.Closes #162