示例#1
0
文件: Op.py 项目: aacitelli/core
    def parse(self):

        # Use one-token lookahead to determine whether it's <int>, <id>, or (<exp>)
        tokNo = t.tokenizer.get_token()
        if tokNo == t.Tokens.NUMBER.value:
            self.__int = Int.Int()
            self.__int.parse()
            self.__alternative = 1
        elif tokNo == t.Tokens.IDENTIFIER.value:
            self.__id = Id.Id()
            self.__id.parse()
            self.__alternative = 2
        elif tokNo == t.Tokens.OPEN_PAREN.value:
            t.tokenizer.skip_token()  # Consume open paren
            self.__exp = Exp.Exp()
            self.__exp.parse()
            self.__alternative = 3
            tokNo = t.tokenizer.get_token()
            t.tokenizer.skip_token()  # Consume closed parent
            if tokNo != t.Tokens.CLOSED_PAREN.value:
                print("If: Expected token {}, got token {}".format(
                    t.Tokens.CLOSED_PAREN.value, tokNo))
                return -1
            # print("Loop: Consumed `)` token.")
        else:
            print("Op: Invalid Next Token {}!".format(tokNo))
            exit(-1)
            return -1

        # Successful error code
        return 0
示例#2
0
文件: Assign.py 项目: aacitelli/core
    def parse(self):

        # Id
        self.__id = Id.Id()
        self.__id.parse()

        # `=` token
        tokNo = t.tokenizer.get_token()
        t.tokenizer.skip_token()
        if tokNo != t.Tokens.EQUALS.value:
            print("Assign: Expected token {}, got token {}".format(
                t.Tokens.EQUALS.value, tokNo))
            return -1
        # print("Assign: Consumed `=` token.")

        # Exp
        self.__exp = Exp.Exp()
        self.__exp.parse()

        # `;` token
        tokNo = t.tokenizer.get_token()
        t.tokenizer.skip_token()
        if tokNo != t.Tokens.SEMICOLON.value:
            print("Assign: Expected token {}, got token {}".format(
                t.Tokens.SEMICOLON.value, tokNo))
            return -1
        # print("Assign: Consumed `;` token.")

        # Successful error code
        return 0
示例#3
0
def data_process(participant_list=[], data_dir=[]):
    output_fields = ['task', 'trial', 'rotation_angle_deg', 'target_angle_deg']
    output_rows = []
    for i in range(0, len(data_dir)):
        output_fields.append(participant_list[i])
        pc = 0
        for j in range(0, len(data_dir[i])):
            for k in range(0, len(data_dir[i][j])):
                #                fields = []
                rows = []
                input_row = []
                with open(data_dir[i][j][k], "rb") as csvfile:
                    csv_reader = csv.reader(csvfile)
                    #                    fields = csv_reader.next()
                    #                    print ("\nField names are:" + ','.join(field for field in fields))
                    for row in csv_reader:
                        rows.append(row)
                for row in rows[1:]:
                    if i == 0:
                        if float(
                                exp.get_dist([0, 0], [
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])) / float(
                                    exp.get_dist([0, 0], [
                                        float(row[11:12][0]),
                                        float(row[12:13][0])
                                    ])) >= float(1) / float(3):
                            input_row.append(row[1:2][0])
                            input_row.append(row[3:4][0])
                            input_row.append(row[5:6][0])
                            input_row.append(row[6:7][0])
                            cursor_deviation = degrees(
                                exp.cart2pol([
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])[1]) - float(row[6:7][0])
                            input_row.append(cursor_deviation)
                            break
                    if i > 0:
                        if float(
                                exp.get_dist([0, 0], [
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])) / float(
                                    exp.get_dist([0, 0], [
                                        float(row[11:12][0]),
                                        float(row[12:13][0])
                                    ])) >= float(1) / float(3):
                            cursor_deviation = degrees(
                                exp.cart2pol([
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])[1]) - float(row[6:7][0])
                            output_rows[pc].append(cursor_deviation)
                            pc = pc + 1
                            break
                if i == 0:
                    output_rows.append(input_row)
    return [output_fields, output_rows]
示例#4
0
 def parse(self):
     # Parse based on one token look ahead
     x = int(self.t.peek())
     if x == 31:
         self.i = Int.Int(self.t)
         self.i.parse()
     elif x == 32:
         self.case = 1
         self.idName = self.t.getValue()
         self.id = Id.Id(self.t)
         self.id.parse()
     elif x == 20:
         self.case = 2
         self.t.getToken()
         self.e = Exp.Exp(self.t)
         x = int(self.t.getToken())
         if x != 21:
             print "Expected end parenthesis."
             exit()
     else:
         print "Invalid op."
         exit()
示例#5
0
def data_process(participant_list=[], data_dir=[], cfg={}):

    output_fields = ['task', 'trial', 'rotation_angle_deg', 'target_angle_deg']
    output_rows = []
    for i in range(0, len(data_dir)):  # does this loop over participants?
        output_fields.append(participant_list[i])  # seems like it does
        pc = 0
        for j in range(0, len(data_dir[i])
                       ):  # does this loop over files in the data directory?
            for k in range(0, len(data_dir[i][j])):
                #                fields = []
                rows = []
                input_row = []
                with open(data_dir[i][j][k], "rb") as csvfile:
                    csv_reader = csv.reader(
                        csvfile
                    )  # why not read in the COMPLETE file as a pandas data frame?
                    #                    fields = csv_reader.next()
                    #                    print ("\nField names are:" + ','.join(field for field in fields))
                    for row in csv_reader:
                        rows.append(row)
                for row in rows[1:]:
                    if i == 0:
                        if float(
                                exp.get_dist([0, 0], [
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])
                        ) / float(
                                exp.get_dist([0, 0], [
                                    float(row[11:12][0]),
                                    float(row[12:13][0])
                                ])
                        ) >= float(
                                1
                        ) / float(
                                3
                        ):  # why use column indices instead of column names? names are more robust to future situations where we add or re-order columns
                            input_row.append(row[1:2][0])  # task?
                            input_row.append(row[3:4][0])  # trial?
                            input_row.append(
                                row[5:6][0])  # rotation_angle_deg?
                            input_row.append(row[6:7][0])  # target_angle_deg?
                            cursor_deviation = degrees(
                                exp.cart2pol([
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])[1]) - float(row[6:7][0])
                            input_row.append(cursor_deviation)
                            break
                    if i > 0:
                        if float(
                                exp.get_dist([0, 0], [
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])) / float(
                                    exp.get_dist([0, 0], [
                                        float(row[11:12][0]),
                                        float(row[12:13][0])
                                    ])) >= float(1) / float(3):
                            cursor_deviation = degrees(
                                exp.cart2pol([
                                    float(row[15:16][0]),
                                    float(row[16:17][0])
                                ])[1]) - float(row[6:7][0])
                            output_rows[pc].append(cursor_deviation)
                            pc = pc + 1
                            break
                if i == 0:
                    output_rows.append(input_row)
    return [output_fields, output_rows
            ]  # why not return a data frame where this is integrated?
示例#6
0
 def __init__(self, t):
     self.e = Exp.Exp(t)
     self.id = Id.Id(t)
     self.t = t
示例#7
0
def exp(x):
    return Exp(float(x))
示例#8
0

import Exp
import WMLock

import time

state = Exp.expState()

WMLock399 = WMLock.WMLock( state, 1, 1, 751.526321 )

WMLock399.voltage.value = 5.0

for i in range( 0, 10 ):
    time.sleep(1)

    WMLock399.update()

WMLock399.findMFR()

while(1):

    time.sleep(1)

    WMLock399.update()    
示例#9
0
def user_pg(request):
    name = request.user.username
    user = Users.objects.get(user_id = name)
    display = user.user_name
    owner_key = user.token
    owner_secret = user.token_secret
    auth = fitbit.Fitbit(FITAPP_CONSUMER_KEY, FITAPP_CONSUMER_SECRET, resource_owner_key = owner_key, resource_owner_secret = owner_secret)
    profile = auth.user_profile_get(name)
    groupname = user.group

    agiexp = user.user_agility
    strexp = user.user_strength
    willexp = user.user_willpower

    strlevel, agilevel,willlevel = Exp.calcLvl(strexp, agiexp, willexp)
    constitution = user.user_constitution
    avatar = profile.get('user').get('avatar')
    exist = user.group


    try:
        creator = Challenge.objects.get(challenger = name)

    except Challenge.DoesNotExist:
        creator = None
        challenge = Challenge.objects.all()
        for i in challenge:
            if i.challengee == name:
                creator = i
                break

    #print(creator)
   # print(exist)



    if exist != 'None' and creator != None:
        groupname = user.group
        return render_to_response('userpage.html', {"name" : display,
                                                 "avatar" : avatar,
                                                 "groupname" : groupname,
                                                 "challenge" : "You are currently in a challenge! Visit the challenge page to see the details!",
                                                 "agilevel" : agilevel,
                                                 "strlevel" : strlevel,
                                                 "willlevel" : willlevel,
                                                 "constitution" : constitution})
    elif exist == 'None' and creator != None:
        groupname = user.group
        return render_to_response('userpage.html', {"name" : display,
                                                 "avatar" : avatar,
                                                 "groupname" : groupname,
                                                 "challenge" : "You are currently in a challenge! Visit the challenge page to see the details!",
                                                 "agilevel" : agilevel,
                                                 "strlevel" : strlevel,
                                                 "willlevel" : willlevel,
                                                 "constitution" : constitution})
    elif exist != 'None' and creator == None:
        groupname = user.group
        return render_to_response('userpage.html', {"name" : display,
                                                 "avatar" : avatar,
                                                 "groupname" : groupname,
                                                 "challenge" : "You are not currently challenging anybody!  Fix this on the challenge page!",
                                                 "agilevel" : agilevel,
                                                 "strlevel" : strlevel,
                                                 "willlevel" : willlevel,
                                                 "constitution" : constitution})
    else:

        return render_to_response('userpage.html', {"name" : display,
                                                 "avatar" : avatar,
                                                 "groupname" : "You are not currently in a group!",
                                                "challenge" : "You are currently not challenging anyone.",
                                                 "agilevel" : agilevel,
                                                 "strlevel" : strlevel,
                                                 "willlevel" : willlevel,
                                                 "constitution" : constitution})
示例#10
0
def calculateExp(request):
    #day_of_year = datetime.now().timetuple().tm_yday


    user = Users.objects.get(user_id = request.user.username)

    #if user.last_login == day_of_year:

    owner_key = user.token
    owner_secret = user.token_secret
    now = '2015-12-08'
    print(now)
    auth = fitbit.Fitbit(FITAPP_CONSUMER_KEY, FITAPP_CONSUMER_SECRET, resource_owner_key = owner_key, resource_owner_secret = owner_secret)
    activity_stats = auth._COLLECTION_RESOURCE('activities', now, request.user.username)

    print(activity_stats)

    distgoal = activity_stats.get('goals').get('distance')
    floorgoal = activity_stats.get('goals').get('floors')
    stepgoal = activity_stats.get('goals').get('steps')



    calories = activity_stats.get('summary').get('activityCalories')
    print(calories)
    dist = activity_stats.get('summary').get('distances')[0]['distance']
    print(dist)
    steps = activity_stats.get('summary').get('steps')
    print(steps)
    floors = activity_stats.get('summary').get('floors')
    print(floors)

    fairlyactive =  activity_stats.get('summary').get('fairlyActiveMinutes')
    veryactive =  activity_stats.get('summary').get('veryActiveMinutes')

    activity_sum = fairlyactive + veryactive
    strxp, agixp, willxp, con_mult = Exp.calcExp(dist, distgoal, calories, floors, floorgoal, steps, stepgoal, activity_sum, 1.0,1)

    expTotal = strxp + agixp + willxp


    curr_str = user.user_strength
    curr_agi = user.user_agility
    curr_will = user.user_willpower


    new_str, new_agil, new_will = Exp.add_exp(curr_str, curr_agi, curr_will,strxp, agixp, willxp)


    user.user_strength = new_str
    user.user_agility = new_agil
    user.user_willpower = new_will
    user.user_constitution = con_mult
    user.save()

    str_level, agil_level, will_level = Exp.calcLvl(new_str, new_agil, new_will)

    try:
        creator = Challenge.objects.get(challenger = request.user.username)
    except Challenge.DoesNotExist:
        creator = None
        gee = None
        challenge = Challenge.objects.all()
        for i in challenge:
            if i.challengee == request.user.username:
                gee = i
                break

    if creator != None:
        string = "You are currently in a challenge! Visit the challenge page to see the details!"
        creator.gerExp += expTotal
        creator.save()

    elif creator == None and gee != None:
        string = "You are currently in a challenge! Visit the challenge page to see the details!"
        gee.geeExp += expTotal
        gee.save()

    if creator == None and gee == None:
        string = "You are currently not in a challenge!"


    profile = auth.user_profile_get(request.user.username)
    username = profile.get('user').get('displayName')


    groupname = user.group
    if groupname == 'None':
        string2 = "You are not currently in a group!  Go join one!"
    else:
        string2 = "You are currently in a group!  Go check it out at the group page!"

    avatar = profile.get('user').get('avatar')


    return render_to_response('userpage.html', {"name" : username,
                                                 "avatar" : avatar,
                                                 "groupname" : string2,
                                                "challenge" : string,
                                                 "agilevel" : agil_level,
                                                 "strlevel" : str_level,
                                                 "willlevel" : will_level,
                                                 "constitution" : con_mult})
示例#11
0
import Exp as ft

a, index, index1, delmass, maxdel, n, delmin, f = [], 0, 0, [], 1, 0, [], True
x = input("\033[34m{}".format('Вводите числа в строку через пробел: '))
a = ft.split(x, a)
b = ft.gen(a, index)
for i in a:
    print(
        '\t', "\033[37m{} [{}]: {}{}".format('Делители числа', i, '1,',
                                             ft.out(b[index1])))
    index1 += 1
a = sorted(a)
delmin = ft.asort(a[0], delmin)
for del2 in delmin:
    n = 0
    for i in b:
        for j in range(len(i)):
            if i[j] == del2:
                n += 1
    if n == len(b):
        f = False
        delmass.append(del2)
if len(delmass) > 0:
    maxdel = delmass[len(delmass) - 1]
print(ft.output(a, maxdel, f))