View source on GitHub
|
A date range [start_date, end_date] with both bounds inclusive.
meridian.model.spec.DateRange(
start_date: meridian.data.time_coordinates.Date = None,
end_date: meridian.data.time_coordinates.Date = None
)
This matches the convention used throughout Meridian's other date selection
APIs -- notably TimeCoordinates.get_selected_dates and
expand_selected_time_dims -- so that the same pair of dates selects the
same time periods wherever it is used.
Either bound may be omitted to leave that side open. An omitted bound is
resolved against the input data when the range is compiled, not at
construction time, so the same DateRange may cover different dates for
different datasets:
DateRange(start, None): fromstartthrough the last date in the data.DateRange(None, end): from the first date in the data throughend.DateRange(): the entire date range of the data. This is the identity range; specifying it is equivalent to applying no date restriction at all.
A range whose bounds are equal is valid and selects that single date.
A bound that is present must name one of the input data's time coordinates
exactly; a bound falling between two coordinates is rejected. Because it
depends on the data, the check happens when the range is compiled against an
InputData, not at construction time.
Note | |
|---|---|
The mmm.v1.common.DateInterval proto that these specs serialize to uses
the opposite, half-open [start_date, end_date) convention. The
conversion between the two is performed in the serialization layer, which
is the only place the two conventions meet.
|
Methods
from_date_interval
@classmethodfrom_date_interval( date_interval:meridian.data.time_coordinates.DateInterval) -> 'DateRange'
Creates a DateRange from a time_coordinates.DateInterval tuple.
The tuple is interpreted with both bounds inclusive, the convention
TimeCoordinates.get_selected_dates uses. It is therefore not
interchangeable with the half-open mmm.v1.common.DateInterval proto of
the same name.
| Args | |
|---|---|
date_interval
|
An inclusive (start_date, end_date) tuple.
|
| Returns | |
|---|---|
The equivalent DateRange.
|
__eq__
__eq__(
other
)
Return self==value.
Class Variables | |
|---|---|
| end_date |
None
|
| start_date |
None
|
View source on GitHub