Ejemplo n.º 1
0
    def __init__(self, title, width, height, frame_rate):

        game.Game.__init__(self, title, width, height, frame_rate)

        # create a game instance
        # YOU SHOULD CHANGE THIS TO IMPORT YOUR GAME MODULE
        self.mGame = example.Example(width, height)
        return
Ejemplo n.º 2
0
def test_Example():
    import example

    ex = example.Example("Test")

    assert ex.name == "Test"

    ex.name = "Test2"

    assert ex.name == "Test2"
Ejemplo n.º 3
0
# e.add(3,4,c)     #调用函数
# print(example.intp_value(c))   #解除引用
#
# example.intp_assign(c,10)    #对c指向的对象进行赋值
# print(example.intp_value(c))

#使用pointer_class
# import example
# e = example.Example()
# c = example.intp()      #创建一个int*
# e.add(3,4,c)
# print(c.value())   #deference
# c.assign(10)
# print(c.value())

#测试array_functions
# import example
# c = example.new_doubleArray(10)
# for i in range(10):
#     example.doubleArray_setitem(c,i,2*i)
# example.Example().print_array(c)
# example.delete_doubleArray(c)
# example.Example().print_array(c)

#测试array_class
import example
c = example.doubleArray(10)
for i in range(10):
    c[i] = 2 * i
example.Example().print_array(c)
Ejemplo n.º 4
0
import example as model
# import trainExample as trainer

RightFoot_path = "../../Recordings/Fall_2020/OpenBCISession_2020-10-11_16-26-10-YAN-RIGHT-FOOT/OpenBCI-RAW-2020-10-11_16-26-50.txt"
RightFoot_label_path = "../../Recordings/Labels/yanRightFoot"

LeftFoot_path = "../../Recordings/Fall_2020/OpenBCISession_2020-10-11_16-26-10-YAN-RIGHT-FOOT/OpenBCI-RAW-2020-10-11_16-26-50.txt"
LeftFoot_label_path = "../../Recordings/Labels/yanLeftFoot.txt.txt"

RightEye_path = "../../Recordings/Fall_2020/OpenBCISession_2020-10-11_16-58-40-YAN-RIGHT-EYE/OpenBCI-RAW-2020-10-11_16-59-03.txt"
RightEye_label_path = "../../Recordings/Labels/yanRightEye"

LeftEye_path = "../../Recordings/Fall_2020/OpenBCISession_2020-10-11_16-33-50-YAN-LEFT-EYE/OpenBCI-RAW-2020-10-11_16-38-59.txt"
LeftEye_label_path = "../../Recordings/Labels/yanLeftEye"

exampleModel = model.Example("modelFile")

RightFoot_observations = dc.getObservationSet(RightFoot_path,
                                              RightFoot_label_path, 1000,
                                              [0, 1, 2], 'R_FOOT')
LeftFoot_observations = dc.getObservationSet(LeftFoot_path,
                                             LeftFoot_label_path, 1000,
                                             [0, 1, 2], 'L_FOOT')
RightEye_observations = dc.getObservationSet(RightEye_path,
                                             RightEye_label_path, 1000,
                                             [0, 1, 2], 'R_EYE')
LeftEye_observations = dc.getObservationSet(LeftEye_path, LeftEye_label_path,
                                            1000, [0, 1, 2], 'L_EYE')

exampleModel.train([
    RightFoot_observations, LeftFoot_observations, RightEye_observations,
def get_data(filename, time_map, distance_map, carrier_map, airport_map):
    # open the data file
    file = open(filename)

    # skip the header
    next(file)

    # convert data file into Example objects
    data = []
    for line in file:
        line = re.sub('[\n]', '', line)  # delete newline characters
        values = line.split(',')  # split the data up

        # only consider flights that haven't been canceled
        if float(values[21]) != 1.0:
            x = []
            y = []

            try:
                # get normalized inputs
                dept_time = float(time_map[values[5][:-2]][2])
                carrier = float(carrier_map[values[8]][2])
                airport = float(airport_map[values[16]][2])

                # get delay and apply threshold
                delay = float(values[15])
                if delay > 15:
                    delay = 1.0
                else:
                    delay = 0.0

                # get distance and find normalized value from range
                distance = float(values[18])
                if distance < 300:
                    distance = float(distance_map['0'][2])
                elif 300 <= distance < 600:
                    distance = float(distance_map['1'][2])
                elif 600 <= distance < 900:
                    distance = float(distance_map['2'][2])
                else:
                    distance = float(distance_map['3'][2])

                # put the values in the arrays
                x.append(dept_time)
                x.append(carrier)
                x.append(airport)
                x.append(distance)
                y.append(delay)

            except ValueError:
                logging.debug(
                    'Could not add {0} because of an invalid value'.format(
                        values))
                continue
            except KeyError:
                logging.debug(
                    'Could not find key for value in {0}'.format(values))
                continue

            # add the data point
            logging.debug('Adding data point [{0}, {1}]'.format(x, y))
            data.append(example.Example(x, y))

        else:
            logging.debug('Found a canceled flight')

    return data
Ejemplo n.º 6
0
#!/usr/bin/env python

import example
import numpy as np
import scipy.sparse

t = example.Example()
t.set('bom dia!')
print(t.greet())

t.many(['Good Morning', 'Buon giorno', 'Kali mera'])
print(t.greet())

print(example.add_to_3(2))
print(example.apply_5(example.add_to_3))
print(example.apply_5(lambda x: x + 4))

xs = [1, 2, 3, 4, 5]
print(xs)
print(example.map1(example.add_to_3, xs))
print(example.map1(lambda x: x + 4, xs))
print(xs)
fs = [(lambda a: lambda x: x + a)(a) for a in xs]
print(example.zip_map(fs, xs))

m = np.array([[1, 2], [3, 4]])
print(m)
print(example.a_mat)
print(example.a_mat())

L = scipy.sparse.identity(2).tocsc()
Ejemplo n.º 7
0
 def setup(self):
     self.ex = example.Example()
Ejemplo n.º 8
0
import example

obj = example.Example()
obj.say_hello()

ret = obj.add(3, 4)
print(ret)

ret = obj.sub(7, 4)
print(ret)

ret = obj.negateint(4)
print(ret)

rc, len = obj.strLen("hello,swig")
print("rc =", rc, "len = ", len)

# http://www.swig.org/Doc3.0/Library.html#Library_carrays
a = example.new_intArray(10)
for i in range(10):
    example.intArray_setitem(a, i, i)
print("a[3] = ", example.intArray_getitem(a, 3))
tmp = obj.sumArr(a, 10)
print(tmp)
example.delete_intArray(a)

a = example.intArrayclass(10)
for i in range(10):
    a[i] = i * 10
tmp = obj.sumArr(a, 10)
print(tmp)
Ejemplo n.º 9
0
 def __init__(self, methodName='runTest'):
     super().__init__(methodName)
     self.example = example.Example(5, 5)
Ejemplo n.º 10
0
 def test_func2(self, mock_func1):
     mock_func1.return_value = 0
     self.assertEqual(example.Example(5).func2(), 1)