feat: Add num_samples parameter to date_range and datetime_range
#25329
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.
Closes #7525
Closes #23424
This update adds the
num_samplesparameter todate_rangeanddatetime_range. The input parameters that define the range are now:start,end,interval, andnum_samples. A range can be generated using any three of these parameters. In order to keep backwards compatibility, and for the most common usage, the two-parameter combination ofstartandendworks, and uses a default duration of 1 day.This update also allows for ranges generated using negative intervals, in much the same way that
linear_spaceandint_rangecan generate backwards ranges. Note that theclosedparameter applies these as directional intervals, meaning that a left-closed series always has the form[s1, s2, ..., s_n)even if the values are descending.This had the minor side effect of enabling negative intervals in
time_rangeas well, with no additional effort, so I threw in a quick test for that. We can manually disable that by adding in a check if we don't want that in this PR.Examples