def __init__(self, times, values, id=None): """ Parameters: ---------- values : sequence-like Actual data points for SMTimeSeries. Any user-provided sequence-like object. Mandatory. times : sequence-like Time values for SMTimeSeries. Mandatory Notes ----- PRE: _times are mandatory elements that must represent a montonic sequence. Examples: --------- >>> ts = SMTimeSeries(times= [1,2,3], values= [100,200,300]) """ self.__class__.is_sequence(times) self.__class__.is_sequence(values) self._times = (list(times)) if isinstance(values, dict): self._values = (list(values.values())) else: self._values = (list(values)) # if no id is provided, create a new and unique one if id == None: id = FileStorageManagerSingleton.get_unique_id() # store the time series on disk FileStorageManagerSingleton.store( str(id), ArrayTimeSeries(self._times, self._values)) self._id = str(id)
def __setitem__(self, index, value): """ Description ----------- Sets the element of `self._values` at index `index` equal to `value`. Parameters ---------- self: instance of subclass of SizedContainerTimeSeriesInterface index: int index to change the value at value : float the new value to be set """ ts = FileStorageManagerSingleton.get(self._id) ts[index] = value FileStorageManagerSingleton.store(self._id, ts)