示例#1
0
 def setUp(self):
     redis_client = redis.StrictRedis()
     self.dtype = [("timestamp", "float64"), ("value", "int")]
     self.time_series = RedisNumpyTimeSeries(redis_client=redis_client,
                                             max_length=20, dtype=self.dtype,
                                             timestamp_column_name="timestamp")
     self.timestamp = datetime.now().timestamp()
示例#2
0
class RedisNumpyDtypeTSTest(unittest.TestCase, RedisNumpyTSTestMixin):

    def setUp(self):
        redis_client = redis.StrictRedis()
        self.dtype = [("timestamp", "float64"), ("value", "int")]
        self.time_series = RedisNumpyTimeSeries(redis_client=redis_client,
                                                max_length=20, dtype=self.dtype,
                                                timestamp_column_name="timestamp")
        self.timestamp = datetime.now().timestamp()

    def tearDown(self):
        self.time_series.flush()

    def prepare_numpy_data(self, length):
        data_list = []

        for i in range(length):
            timestamp = self.timestamp + i
            data_list.append((timestamp, i))
        array = np.array(data_list, dtype=self.dtype)
        return array

    def test_get(self):
        key = "AAPL:SECOND"
        array = self.prepare_numpy_data(10)
        self.time_series.add_many(key, array)

        result = self.time_series.get(key, array["timestamp"][0])

        numpy.testing.assert_array_equal(result, array[0])
示例#3
0
class RedisNumpyTSTest(unittest.TestCase, RedisNumpyTSTestMixin):
    def setUp(self):
        redis_client = redis.StrictRedis()
        self.time_series = RedisNumpyTimeSeries(redis_client=redis_client,
                                                max_length=20)
        self.timestamp = datetime.now().timestamp()

    def tearDown(self):
        self.time_series.flush()

    def prepare_numpy_data(self, length):
        data_list = []
        for i in range(length):
            timestamp = self.timestamp + i
            data_list.append((timestamp, i))
        array = np.array(data_list)
        return array

    def test_get(self):
        key = "AAPL:SECOND"
        array = self.prepare_numpy_data(10)

        self.time_series.add_many(key, array)
        timestamp = array[0][0]
        result = self.time_series.get(key, timestamp)

        numpy.testing.assert_array_equal(result, array[0])
示例#4
0
 def setUp(self):
     redis_client = redis.StrictRedis()
     self.time_series = RedisNumpyTimeSeries(redis_client=redis_client,
                                             max_length=20)
     self.timestamp = datetime.now().timestamp()