Ejemplo n.º 1
0
def test_publish():
    """ Test publish method.
        """
    sheet = Sheet('test-sheet', 'worksheet-name')
    publish = Stat(sheet)
    publish_value = publish.publish()
    assert publish_value == True
Ejemplo n.º 2
0
 def end_session(self):
   self.tune_out = datetime.datetime.now()
   self.put()
   
   Stat.add_session(self)
   
   # Track user activity
   if self.sessionMedias.get() and self.channel.privacy != Privacy.PRIVATE:
     from useractivity import UserActivity
     broadcast.broadcastNewActivity(UserActivity.add_session(self.user, self))
Ejemplo n.º 3
0
    def GetSchedule(self, policy, trip, environment):
        totalReward = 0.0
        chargingStations = []
        tripStats = []
        tripTime = 0
        state = environment.Reset()
        tripStats.append(Stat(state, None))

        while True:

            actionToTake = policy[state.StopIndex, state.TimeBlock,
                                  state.BatteryLevel]

            nextState, reward, isDone = environment.Step(actionToTake)
            totalReward += reward

            if nextState is None:
                break

            tripTime += (nextState.TimeBlock - tripTime)

            if actionToTake == ActionSpace.Charge:
                if self.IsStopInList(nextState.StopIndex, chargingStations):
                    chargingStations[self.GetStopIndex(
                        nextState.StopIndex, chargingStations)].TimeAtStop += 1
                else:
                    chargingStations.append(
                        ScheduleStop(
                            nextState.StopIndex,
                            trip.Route.PossibleStops[nextState.StopIndex].Name,
                            1, trip.Route.PossibleStops[
                                nextState.StopIndex].Location))

            state = nextState
            tripStats.append(Stat(state, actionToTake))

            if isDone:
                break

        if nextState is not None and nextState.StopIndex == environment.NumberOfStops - 1:
            return Schedule(trip.Route.Coordinates, chargingStations,
                            trip.Route.PossibleStops[nextState.StopIndex],
                            tripTime, nextState.BatteryLevel, True, tripStats,
                            self.TimeBlockConstant, trip.TripName)
        else:
            return Schedule(trip.Route.Coordinates, chargingStations,
                            trip.Route.PossibleStops[state.StopIndex],
                            tripTime, state.BatteryLevel, False, tripStats,
                            self.TimeBlockConstant, trip.TripName)
Ejemplo n.º 4
0
from stat import Stat

stat = Stat(API_KEY)
data = stat.request("/projects/list")
Ejemplo n.º 5
0
 def __init__(self, params):
     self.stats = {}
     for s in params.keys():
         self.stats[s] = Stat(s, params[s])