Skip to content

Instantly share code, notes, and snippets.

@LarsBergqvist

LarsBergqvist/data_fake.py

Last active Jul 11, 2016
Embed
What would you like to do?
from datetime import datetime, timedelta
from repository_base import Repository
class FakeRepository(Repository):
def get_data(self,topic_name, numdays):
today=datetime.today()
# Create some test data
# Three values from yesterday and three values from today
dataPoint = (
(20.1,today-timedelta(1.8)),
(19.1,today-timedelta(1.4)),
(22.1,today-timedelta(1.2)),
(23.3,today-timedelta(0.9)),
(19.1,today-timedelta(0.5)),
(30.1,today-timedelta(0.1))
)
values = []
labels = []
for value,time in dataPoint:
if (time > (today - timedelta(numdays))):
values.append(value)
labels.append(super(FakeRepository,self).date_formatted(time))
return labels, values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.