Conversation
|
Recording the highlights of our conversation...
An alternative would be padding the sequence with zeros at the left end. The current implementation is an optimization that avoids the cost of padding (= copying) the array. It might be worth putting some of this into a comment in the code. |
|
Taking inspiration from https://stackoverflow.com/questions/13828599/generalized-cumulative-functions-in-numpy-scipy ... seems a more straightforward way to calculate the length of each run. (Some post-processing needed to keep only the last value in each run-- |
|
I came up with an alternative that doesn't use diff which looses a point, and that doesn't use an initial concat. Still requires some manipulation to get things right at the end. test__cumsum_flagged_diff took 1.08s I imagine now that spell_length needs not be hidden function and in that case, I may not need to make all the derived calculations as functions as they can somewhat trivially be written live. Then depending on review, will add appropriate doc |
|
@xchourio please review as Aaron will be left out of calculations PRs in the future. I think we should review each other because in case one leaves IRI before the other, we keep familiar with the other's work and can pick up more easily. In that vein, you might want to start having me PR-review your PepsiCo work around the crop app. |
Little suite of spell related functions needed by PepsiCo. They all are meant to then feed "seasonal" functions to be applied to multiple years for same season of the year. The core of the word comes from enacts' longest_run_length.
The "public" functions are a bit dummy, but the "private" one definitely should not be callable because it returns something a bit funky. Not sure if there's a better way to engineer this.
Tests produced (also heavily inspired from enacts')