feat: add basic support for GET DATA BETWEEN TIMES function #42
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.
This adds support for the
GET DATA BETWEEN TIMES
function, which can be used to look up a value from an external data variable.I originally thought it would behave exactly like the existing
__lookup
function, but there are subtle differences so I split it out into a separate__get_data_between_times
function.Our results match Vensim exactly for mode=1 ("look forward") and mode=-1 ("hold backward") for both whole and fractional inputs, and for mode=0 ("interpolate") for integral inputs. For some reason Vensim produces unexpected results for interpolate mode when the input is fractional. For now I added a warning message that gets printed once if this case is detected.
In the En-ROADS model, this function is only used in a few places, and each time it passes mode=1 ("look forward"), so it's not urgent to fix that issue with the interpolate case (and fractional inputs are probably uncommon for that scenario), but we can circle back to it another time.
Fixes #33