Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
lkdvos
left a comment
There was a problem hiding this comment.
In principle I think the addition of the StatsBase dependency is breaking, as this would now make downstream tests fail since they are missing the dependency...
|
Are we okay with this, or is there an alternative? A very silly one is to manually sample with |
|
It's not about a version bump, it would then have to be a major version bump. I am not necessarily opposed to this, but it's definitely a bit disruptive for a somewhat minor convenience update. How about just some manual intervention: The main idea is that while this is not guaranteed to have exactly [EDIT] since we are already depending on |
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
|
Can you explain a bit why the loop is still necessary? If the probabilities are mapped correctly and the default size is 5, should this not be selecting every sector with 100% chance if there are only 5 or less, and (5/6)^6% chance that the set is empty in the 6 sector case seems acceptable? |
| function Base.IteratorSize(::Type{SectorValues{TimeReversed{I}}}) where {I <: Sector} | ||
|
|
||
| # capture product sectors as well | ||
| function Base.IteratorSize(::Type{SectorValues{TimeReversed{I}}}) where {I} |
There was a problem hiding this comment.
Wait, is ProductSector not a subtype of Sector?
There was a problem hiding this comment.
It is, but for some reason the time-reversed of a product sector didn't behave so nicely.
|
|
| return Random.randsubseq(vals, min(size, L) / L) # returns all sectors if L < size | ||
| p = resize!(randperm(L), min(size, L)) # sampling with fixed size | ||
| return collect(vals)[p] | ||
| end |
There was a problem hiding this comment.
I like this randperm solution, and would also put it into place for infinite sectors. Something closely similar can be obtained by using shuffle, so how about this implementation:
| end | |
| function smallset(::Type{I}, size::Int = 5, maxdim::Real = 10) where {I <: Sector} | |
| vals = values(I) | |
| L = Base.IteratorSize(vals) === Base.IsInfinite() ? 10 * size : min(10 * size, length(vals)) | |
| sectors = getindex.((vals,), 2:L) # exclude unit in simple-unit categories | |
| sectors = shuffle!(filter!(s->dim(s) > maxdim, sectors)) | |
| return sectors[1:min(size, length(sectors))] | |
| end |
I think this should work for all sectors. It will first select the first 10 * size sectors (if there are that many), excluding the unit. Then it will possibly throw out sectors with a large quantum dimension. Then it will randomly permute them via shuffle!, and only keep the first size (unless fewer sectors were left).
Part 3 of splitting #71 in pieces. The motivation for changing
smallsetlike this is to at least be able to sample from the sectors when there's finitely many.Base.Iterators.takewill always take the first n many sectors implemented inSectorValues{I}. The change toTimeReversedis needed to callcollecton its values in product sectors.