You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just came across this after a few months, so I though I'd post an update. I've come to the conclusion that it's not possible to implement Base.iterate over a TypeSortedCollection in a type-stable way. Quoted from a slack conversation with Jose:
Iteration over a heterogeneous tuple [much less a tuple-of-vectors] isn't type stable! There are some tricks by which it can be made type stable: options being "lisp-y recursion tricks, unrolling, or TypeSortedCollections.jl."
Unrolling: when writing Base.iterate, I'm not given the body of the for loop, unlike foreach. Could be done with a macro, but then users can't simply write for item in collection.
Lisp-y recursion tricks: works for tuples. For tuples of vectors, though, the return type changes when we move on to the next vector. That seems inherently type unstable. Could be fixed if we knew the lengths at compile time...but then we're basically using a tuple-of-tuples [not a tuple-of-vectors], which will scale poorly for large collections.
TypeSortedCollections.jl : I took a look at the original repo, hoping that they implement Base.iterate, but no, only broadcast.
My current suggestion: get_components continues to return a flattened iterator. We add support for TSCs, but only for internal usage in performance critical sections of code. And in order to re-write flatten iterator to TSC, we'll have to refactor for loops as map, mapreduce etc. calls. (In PSI, constructing lines and thermals are two big candidates: large collections and boatloads of different formulations.)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Yet to do profiling, but it's working. Tests were mostly written by CoPilot.
The tests that are failing are unrelated, would be fixed by rebasing onto main. [I tried doing that, but got conflicts.]