def test_valid_ts_range_time():
    ts = SMTimeSeries(range(2, 7), range(0, 5))
    arrayts = StorageManager.get(ts._id)
    assert np.array_equal(arrayts._value, np.array([0, 1, 2, 3, 4]))
    assert np.array_equal(arrayts._time, np.array([2, 3, 4, 5, 6]))
    assert np.array_equal(arrayts._timeseries,
                          np.array([(2, 0), (3, 1), (4, 2), (5, 3), (6, 4)]))
def test_construct_with_id_num():
    ts = SMTimeSeries([3, 5], [9, 3], 1990)
    arrayts = StorageManager.get(ts._id)
    assert ts._id == str(1990)
    assert np.array_equal(arrayts._value, np.array([9, 3]))
    assert np.array_equal(arrayts._time, np.array([3, 5]))
    assert np.array_equal(arrayts._timeseries, np.array([(3, 9), (5, 3)]))
def test_empty_ts():
    ts = SMTimeSeries([], [])
    arrayts = StorageManager.get(ts._id)
    for t in arrayts._value == np.array([]):
        assert t
    for t in arrayts._time == np.array([]):
        assert t
    for t in arrayts._timeseries == np.array([]):
        assert t
示例#4
0
 def subConst(self, num):
     arrayts1 = StorageManager.get(self._id)
     arraydiff = arrayts1.subConst(num)
     return SMTimeSeries(arraydiff.times(), arraydiff.values())
示例#5
0
 def addConst(self, num):
     arrayts1 = StorageManager.get(self._id)
     arraysum = arrayts1.addConst(num)
     return SMTimeSeries(arraysum.times(), arraysum.values())
示例#6
0
 def __add__(self, otherTS):
     arrayts1 = StorageManager.get(self._id)
     arrayts2 = StorageManager.get(otherTS._id)
     arraysum = arrayts1 + arrayts2
     return SMTimeSeries(arraysum.times(), arraysum.values())
示例#7
0
 def iteritems(self):
     # raise NotImplementedError('Concrete Implementation are missing for iteritems')
     arrayts = StorageManager.get(self._id)
     return arrayts.iteritems()
示例#8
0
 def times(self):
     arrayts = StorageManager.get(self._id)
     return arrayts.times()
def test_valid_ts_with_time():
    ts = SMTimeSeries([3, 5], [9, 3])
    arrayts = StorageManager.get(ts._id)
    assert np.array_equal(arrayts._value, np.array([9, 3]))
    assert np.array_equal(arrayts._time, np.array([3, 5]))
    assert np.array_equal(arrayts._timeseries, np.array([(3, 9), (5, 3)]))
示例#10
0
 def __mul__(self, otherTS):
     arrayts1 = StorageManager.get(self._id)
     arrayts2 = StorageManager.get(otherTS._id)
     arrayproduct = arrayts1 * arrayts2
     return SMTimeSeries(arrayproduct.times(), arrayproduct.values())
示例#11
0
 def __len__(self):
     arrayts = StorageManager.get(self._id)
     return len(arrayts.values())
示例#12
0
    def __str__(self):
        """ Returns a string represenation of the TimeSeries.
		If there are more than 10 elements, the rest are abbreviated.
		"""
        arrayts = StorageManager.get(self._id)
        return str(arrayts)
示例#13
0
 def __repr__(self):
     arrayts = StorageManager.get(self._id)
     return repr(arrayts)
示例#14
0
 def __bool__(self):
     arrayts = StorageManager.get(self._id)
     return bool(abs(arrayts))
示例#15
0
 def __abs__(self):
     arrayts = StorageManager.get(self._id)
     return abs(arrayts)
示例#16
0
 def __contains__(self, value):
     arrayts = StorageManager.get(self._id)
     return (value in arrayts)
示例#17
0
 def values(self):
     arrayts = StorageManager.get(self._id)
     return arrayts.values()
示例#18
0
 def multConst(self, num):
     arrayts1 = StorageManager.get(self._id)
     arrayproduct = arrayts1.multConst(num)
     return SMTimeSeries(arrayproduct.times(), arrayproduct.values())
示例#19
0
 def __eq__(self, otherTS):
     arrayts1 = StorageManager.get(self._id)
     arrayts2 = StorageManager.get(otherTS._id)
     return arrayts1 == arrayts2
示例#20
0
 def __getitem__(self, index):
     arrayts = StorageManager.get(self._id)
     return arrayts[index]
示例#21
0
 def __neg__(self):
     arrayts = StorageManager.get(self._id)
     return SMTimeSeries(arrayts.times(), -arrayts.values())
示例#22
0
 def interpolate(self, newTimes):
     arrayts = StorageManager.get(self._id)
     arrayinterpolate = arrayts.interpolate(newTimes)
     return SMTimeSeries(arrayinterpolate.times(),
                         arrayinterpolate.values())
示例#23
0
 def __setitem__(self, index, value):
     arrayts = StorageManager.get(self._id)
     arrayts[index] = value
     StorageManager.store(self._id, arrayts)
示例#24
0
 def items(self):
     arrayts = StorageManager.get(self._id)
     return arrayts.items()
示例#25
0
 def __iter__(self):
     arrayts = StorageManager.get(self._id)
     return iter(arrayts)
示例#26
0
 def __sub__(self, otherTS):
     arrayts1 = StorageManager.get(self._id)
     arrayts2 = StorageManager.get(otherTS._id)
     arraydiff = arrayts1 - arrayts2
     return SMTimeSeries(arraydiff.times(), arraydiff.values())