# Path: philharmonic/simulator/environment.py
# class FBFSimpleSimulatedEnvironment(SimulatedEnvironment):
#     """Couple of requests in a day."""
#     def __init__(self, times=None, requests=None, forecast_periods=24):
#         """@param times: list of time ticks"""
#         super(SimulatedEnvironment, self).__init__()
#         if not times is None:
#             self._times = times
#             self._period = times[1] - times[0]
#             #self._period = pd. # TODO: switch to above when issue with pandas fixed
#             self._t = self._times[0]
#             self.start = self._times[0]
#             self.end = self._times[-1]
#             if requests is not None:
#                 self._requests = requests
#             else:
#                 self._requests = inputgen.normal_vmreqs(self.start, self.end)
#         else:
#             self._t = 0
#             self._period = 1
#             self.el_prices = []
#             self.temperature = []
#         self._forecast_periods = forecast_periods
# 
#     # TODO: better to make the environment immutable
#     def itertimes(self):
#         """Generator that iterates over times. To be called by the simulator."""
#         for t in self._times:
#             self._t = t
#             yield t
# 
#     def itertimes_immutable(self):
#         """Like itertimes, but doesn't alter state. Goes from start to end."""
#         t = self.start
#         while t <= self.end:
#             yield t
#             t += self._period
# 
#     def times_index(self):
#         """Return a pandas Index based on the set times"""
#         idx = pd.date_range(start=self.start, end=self.end, freq=self.period)
#         # TODO: figure out how to turn self.period into a DateOffset
#         return idx
# 
#     def forecast_window_index(self):
#         """Return a pandas Index from t to forecast_end"""
#         #idx = pd.date_range(start=self.t, end=self.forecast_end,
#         #                    freq=self.period)
#         idx = self.times_index()[self.t, self.forecast_end]
#         return idx
# 
#     def get_requests(self):
#         start = self.get_time()
#         justabit = pd.offsets.Micro(1)
#         end = start + self._period - justabit
#         #TODO: if same vm booted & deleted at once, skip it
#         return cleaned_requests(self._requests[start:end])


from nose.tools import *
from philharmonic.simulator.environment import FBFSimpleSimulatedEnvironment
from philharmonic import *
import pandas as pd


def test_fbf_simple_simulated_environment_series():
    times = pd.date_range('1789-07-14', periods=17, freq='H')
    times_list = [t for t in times]

# Path: philharmonic/simulator/environment.py
# class FBFSimpleSimulatedEnvironment(SimulatedEnvironment):
#     """Couple of requests in a day."""
#     def __init__(self, times=None, requests=None, forecast_periods=24):
#         """@param times: list of time ticks"""
#         super(SimulatedEnvironment, self).__init__()
#         if not times is None:
#             self._times = times
#             self._period = times[1] - times[0]
#             #self._period = pd. # TODO: switch to above when issue with pandas fixed
#             self._t = self._times[0]
#             self.start = self._times[0]
#             self.end = self._times[-1]
#             if requests is not None:
#                 self._requests = requests
#             else:
#                 self._requests = inputgen.normal_vmreqs(self.start, self.end)
#         else:
#             self._t = 0
#             self._period = 1
#             self.el_prices = []
#             self.temperature = []
#         self._forecast_periods = forecast_periods
# 
#     # TODO: better to make the environment immutable
#     def itertimes(self):
#         """Generator that iterates over times. To be called by the simulator."""
#         for t in self._times:
#             self._t = t
#             yield t
# 
#     def itertimes_immutable(self):
#         """Like itertimes, but doesn't alter state. Goes from start to end."""
#         t = self.start
#         while t <= self.end:
#             yield t
#             t += self._period
# 
#     def times_index(self):
#         """Return a pandas Index based on the set times"""
#         idx = pd.date_range(start=self.start, end=self.end, freq=self.period)
#         # TODO: figure out how to turn self.period into a DateOffset
#         return idx
# 
#     def forecast_window_index(self):
#         """Return a pandas Index from t to forecast_end"""
#         #idx = pd.date_range(start=self.t, end=self.forecast_end,
#         #                    freq=self.period)
#         idx = self.times_index()[self.t, self.forecast_end]
#         return idx
# 
#     def get_requests(self):
#         start = self.get_time()
#         justabit = pd.offsets.Micro(1)
#         end = start + self._period - justabit
#         #TODO: if same vm booted & deleted at once, skip it
#         return cleaned_requests(self._requests[start:end])


# Path: philharmonic/simulator/tests/test_environment.py
from nose.tools import *
from philharmonic.simulator.environment import FBFSimpleSimulatedEnvironment
from philharmonic import *
import pandas as pd



def test_fbf_simple_simulated_environment_series():
    times = pd.date_range('1789-07-14', periods=17, freq='H')
    times_list = [t for t in times]

    env = FBFSimpleSimulatedEnvironment(times)