array_combinations using array::map#991
Conversation
src/combinations.rs
Outdated
| { | ||
| } | ||
|
|
||
| pub(crate) fn n_and_count<I: Iterator>( |
There was a problem hiding this comment.
Can you provide documentation here?
There was a problem hiding this comment.
Added documentation, although as far as I can tell the existence of that function (and not just count by itself) is to enable powerset::count so maybe there is a better refactoring here.
Also added the specialization tests, but I'm not really sure what that's doing so adapted the one for tuple_combinations.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #991 +/- ##
==========================================
+ Coverage 94.38% 94.41% +0.02%
==========================================
Files 48 49 +1
Lines 6665 6768 +103
==========================================
+ Hits 6291 6390 +99
- Misses 374 378 +4 ☔ View full report in Codecov by Sentry. |
|
Note that |
|
Hi there, thanks for this. As far as I can judge, this is pretty much a copy-paste of combinations.rs, right? As such, I strongly suggest to try and generalize our existing combinations (that works on In addition, I hope that we are able to not only generalize combinations to arrays, but also other algorithms. @Philippe-Cholet You refactored lots of these algorithms. What's your take on this? As far as I can see, generalizing our
Maybe there are even simpler/better abstractions, but I think generalizing over
|
|
Hi, thanks for the suggestion! Yes, it's basically copy-paste from combinations. I have refactored following your comment. I didn't include the initialization function (what you called I also hope that there will be more array methods soon, |
There was a problem hiding this comment.
Thank you, this is very nice. Could you please address my nitpicks?
@jswrenn After the nits have been fixed (or refused with reason), could you have one final look? If you're satisfied, too, I think we can merge this.
Note: Honestly, I'm unsure about the day-to-day speedups achievable by this, but I think it serves as a starting point for our generics initiative.
|
Thanks for the extremely helpful guidance! |
8df4572 to
c50677b
Compare
|
Is there something to do on my end about the semver check? I'm not sure why it's complaining about |
|
@jswrenn Do you agree we can include this? |
jswrenn
left a comment
There was a problem hiding this comment.
This looks good to me! Just one remaining nit about doc comments.
64447fb to
90bc8d5
Compare
90bc8d5 to
a2d4808
Compare
a2d4808 to
b5e5cd1
Compare
This is an implementation of
array_combinationsthat imitatescombinationsexcept using[_; K](withKa const generic) for the indices and the item type instead ofVec. Usesarray::from_fnandarray::mapalthough the former could be easily avoided.