コード例 #1
0
def MoveActiveCars(cars, MainWindow):
    # Moves active cars every 300 ms
    while True:
        with dataframe(carlock) as df:
            acs = df.add(ActiveCar, cars)
            for car in acs:
                car.Move()
                _sleep(0.3)
コード例 #2
0
def StartPedestrian(peds, MainWindow):
    # Make a pedestrian walk every 3 secs.
    while True:
        with dataframe(pedlock) as df:
            for ped in df.add(StoppedPedestrian, peds):
                register(ped.ID, peds, MainWindow)
                ped.Move()
                break
        _sleep(3)
コード例 #3
0
def StartInactiveCars(cars, MainWindow):
    # Starts inactive cars every 5 secs
    while True:
        with dataframe(carlock) as df:
            iacs = df.add(InactiveCar, cars)
            for car in iacs:
                car.Start()
                register(car.ID, cars, MainWindow)
                break
        _sleep(5)
コード例 #4
0
def MovePedestrian(peds, cars, MainWindow):
    # Nake a Walker move.
    while True:
        with dataframe(pedlock) as df:
            pids = df.add(PedestrianInDanger, peds, params=(cars, ))
            wks = df.add(Walker, peds)
            for pid in pids:
                pid.Avoid()
            for wk in wks:
                wk.Move()
        _sleep(0.5)
コード例 #5
0
    def change_owner(self, owner, license):
        self.owner, self.license = owner, license

    def details(self):
        print (self.id,
         self.owner,
         self.location,
         self.velocity)

@projection(Car, Car.location, Car.velocity)
class CarForPedestrian(object):
    pass

car1 = Car(1,
                     "Murugan",
                     "himalaya",
                     299792458)

with dataframe() as df:
    for car in df.add(CarForPedestrian, [car1]):
        print "location, velocity:", car.location, car.velocity
        try:
            print "owner, license", car.owner, car.license
        except Exception:
            print "Other attributes are not there in projection"
        car.location, car.velocity = "western ghats", 299792459

car1.details()


コード例 #6
0
def findResults(testSet, trainingSet, k):
    for one_test in testSet:
        with dataframe() as df:
            knns = df.add(knn, trainingSet, params=(one_test, k))
            one_test.predicted_type = getResponse(knns)
コード例 #7
0
ファイル: knn_pcc_threaded.py プロジェクト: Mondego/pcc
def findResults(testSet, trainingSet, k):
    for one_test in testSet:
        with dataframe() as df:
            knns = df.add(knn, trainingSet, params = (one_test, k))
            one_test.predicted_type = getResponse(knns)