Closed qwhelan closed 3 weeks ago
Unit tests are now passing (other than a new false alarm on an external link)
Unit tests are now passing (other than a new false alarm on an external link)
Oh, fantastic! Let me take another look.
@eprbell Refactor is complete and all tests are passing, but I'm guessing we'll need a round of cleanup or two. I didn't see your suggestion on row
until just now but I'll implement that this week with any cleanup you suggest.
@eprbell Refactor is complete and all tests are passing, but I'm guessing we'll need a round of cleanup or two. I didn't see your suggestion on
row
until just now but I'll implement that this week with any cleanup you suggest.
Great! I'll review.
The
LIFO
andHIFO
methods are unfortunately quadratic time (first test is trivial forLIFO
):The cases are the same as in https://github.com/eprbell/rp2/pull/115 and assume the
FIFO
improvements there are merged.The overall approach is to filter out exhausted lots early, so they do not need to be considered in each pass. In
FIFO
, this can be done by keeping track of another index. InLIFO
andHIFO
we introduce a heap where "active" lots are kept. The generalfor
loop structure is kept to remove exhausted lots (as may occur when switching accounting methods across years), with the first non-exhausted lot guaranteed to be the one we are searching for. The use of heaps improves each loop toO(log m)
.We translate the search criteria into a
heap_key
as Python only natively supports min heaps. It is likely that this key will need to be refined to guarantee deterministic behavior.Due to test failures, this is not ready to merge but posting to start getting feedback.
And the results with this PR: