solarforecastarbiter.io.utils.ensure_timestamps

solarforecastarbiter.io.utils.ensure_timestamps(*time_args)[source]

Decorator that converts the specified time arguments of the wrapped function to pandas.Timestamp objects

Parameters:strings – Function arguments to convert to pandas.Timestamp before executing function
Raises:ValueError – If any of time_args cannot be converted to pandas.Timestamp

Examples

>>> @ensure_timestamps('start', 'end')
... def get_values(start, end, other_arg):
...     # do stuff with start, end assumed to be pandas.Timestamps
...     if isinstance(start, pd.Timestamp):
...         return True
>>> get_values('2019-01-01T00:00Z', dt.datetime(2019, 1, 2, 12), 'other')
True