def makeWeightRoutine(data, target, reps, parts): """ Requires data to be appropriately filtered. Returns routine format dict of full body / main lift weight exercises, according to specsand also appropriate rep lengths. """ # Initalise routine routine = {} # Get exercises for target group & remove warmup exercises data = filterExercises(data, ["MuscleGroup"], [[target.capitalize()]]) # Depending on target, initialise different tally totals if target in ["chest", "arms", "core"]: tot = 2 else: tot = 1 # Initialise tallies for parts in target group majorTally = {part: tot for part in parts} minorTally = {part: tot for part in parts} # Ensure inclusion of main compound lift # Get main exercise main = filterExercises(data, ["MainLift"], [["Yes"]]) # Attribute main to tallies for index, exercise in main.iterrows(): # Attribute exercises to tallies majorTally = changeTally(majorTally, [exercise.MajorMuscle[0]]) minorTally = changeTally(minorTally, [exercise.MinorMuscle[0]]) # Add main exercise to the routine routine[exercise.Exercise] = reps[0] # Get major exercises and chalk off as many minor counts as well for part in parts: # Get exercise entry from data exerciseEntry = filterExercises(data, ["MajorMuscle"], [[part]]).sample(1) # Assign appropriate reps to each exercise exReps = assignReps(exerciseEntry, reps) routine[exReps[0]] = exReps[1] # Update major & minor tallies majorTally = changeTally(majorTally, exerciseEntry.MajorMuscle.iloc[0]) minorTally = changeTally(minorTally, exerciseEntry.MinorMuscle.iloc[0]) return routine
def makeFullBodyRoutine(data, reps): """ Requires data to be appropriately filtered. Returns routine format dict of full body / main lift weight exercises, according to specsand also appropriate rep lengths. """ # Initialise routine routine = {} # Pool together all relevant exercises & sample fullData = filterExercises(data, ["MuscleGroup"], [["Full"]]) mainData = filterExercises(data, ["MainLift"], [["Yes"]]) pool = fullData.append(mainData, ignore_index=True) # Sample the exercises exercises = pool.sample(6).Exercise.tolist() # Loop through samples for e in exercises: # Get exercise row in pool en = pool[pool.Exercise.isin([e])] # If weight in exercise, assign reps, else set time if "Weight" in en.ExerciseType.tolist()[0]: routine[e] = reps[0] else: routine[e] = "15 seconds" return routine
def generateWarmup(self): """ Uses class properties to output a workout warmup. Returns a dict, of key:value pairs where key is an warmup exercise with a value of of one set's worth of work """ # Get necessary properties # print("Get data") genData = self.getData() # Create warmup # Filter data for plyo and calisthenics options # print("Filter warmup exercises") warmupData = filterExercises(genData, ["ExerciseType"], [["Calisthenics", "Plyo"]]) # Get warmup rep ranges # print("Warmup rep ranges") warmupRR = ["5 seconds", "10 seconds", "15 seconds"] # Get 3 exercises # Cardio exercise for warmup # print("Get cardio warmup exercise") fbWarmupExercise = filterExercises( genData, ["MuscleGroup", "MainLift"], [["Full"], ["No"]]).Exercise.sample(1).tolist() # Assign to final list # print("Add to list") warmupExercises = fbWarmupExercise # Extend by two local exercises # print("Add on warmup exercises") warmupExercises.extend(warmupData.Exercise.sample(2).tolist()) # Assign each with reps / sets # print("Initialise dict") warmup = {} # Assign reps to exercise for i in range(3): # print("Add exercise") warmup[warmupExercises[i]] = warmupRR # print("Successfully created warmup") # Set self.warmup as new warmup self.setWarmup(warmup)
def makeHiitRoutine(data, reps): """ Requires data to be appropriately filtered. Returns routine format dict of hiit cardio exercises, according to specs and also appropriate rep lengths. """ # Initialise routine routine = {} # Filter data for hiit exercises data = filterExercises(data, ["ExerciseType"], [["Plyo"]]) # Take sample of 8 exercises hiitSample = data.sample(10).Exercise.tolist() # Insert rests hiitSample.insert(5, "Rest") hiitSample.insert(11, "Rest") # Loop through exercises and assign rep time for exercise in hiitSample: routine[exercise] = reps[0] # Return obj return routine
def makeRegularRoutine(data, reps, gearLevel): """ Requires data to be appropriately filtered. Returns routine format dict of regular cardio exercises, according to specs and also appropriate rep lengths. """ # Initialise routine routine = {} # Filter data for regular exercises data = filterExercises(data, ["ExerciseType"], [["Cardio"]]) # Due to lack of options, sample with replacement depending on avaliable # gear if gearLevel == "gymless": cardioSample = data.Exercise.sample(4, replace=True).tolist() else: cardioSample = data.Exercise.sample(4).tolist() # Loop through and assign rep length for exercise in cardioSample: routine[exercise] = reps[0] # Return obj return routine
def makeMixedRoutine(data, reps): """ Requires data to be appropriately filtered. Returns routine format dict of both hiit & regular cardio exercises, according to specs and also appropriate rep lengths. """ # Initialise tally & routine dicts routine = {} tally = {"Plyo": 4, "Cardio": 2} # Get exercises for both cardio types bothData = { "Plyo": filterExercises(data, ["ExerciseType"], [["Plyo"]]), "Cardio": filterExercises(data, ["ExerciseType"], [["Cardio"]]) } # Loop through both types for cardioType in tally.keys(): # Pool together possible exercises pool = bothData[cardioType].Exercise.tolist() # While tally is not 0 (not enough exercises) while tally[cardioType] > 0: # Get exercise exercise = pool.pop(randint(0, len(pool) - 1)) # Add to routine routine[exercise] = reps[cardioType] # Adjust tally tally[cardioType] -= 1 # Return obj return routine
def makeCalisthenicsRoutine(data, target, reps): """ Requires data to be appropriately filtered. Returns routine format dict of calisthenics weight exercises, according to specsand also appropriate rep lengths. """ # Initialise return dict routine = {} # Get 5 calisthenics workouts # Pool together all exercises & sample pool = filterExercises(data, ["ExerciseType", "MuscleGroup"], [["Calisthenics", "Plyo"], [target.capitalize()]]) # Get exercises exercises = pool.sample(5).Exercise.tolist() for e in exercises: # Get exercise row in pool en = pool[pool.Exercise.isin([e])] # Conditions for assigning reps valid = [ "Plyo" in en.ExerciseType.iloc[0], "Cardio" in en.ExerciseType.iloc[0], "Hold" in en.MovementType.iloc[0] ] # Check conditions if any(valid): # Assign plyo routine[e] = "15 seconds" else: # Assign calisthenics routine[e] = reps[0] return routine
def returnWorkout(data, goal, groupOrCardio, gear): """ Returns a workout class object from inputed args from user """ # Go through every column and filter out all the data we need per the # user inputs # Initialise reference dicts for body parts and for goals bodyDict = { "chest": ["Pec Major", "Pec Minor"], "shoulders": ["Rear Delt", "Mid Delt", "Front Delt"], "back": ["Upper Back", "Mid Back", "Lower Back", "Lats", "Traps"], "legs": ["Quads", "Hamstrings", "Calves"], "arms": ["Biceps", "Triceps"], "core": ["Core", "Obliques"], "full": ["Full Body"] } allRanges = { "low": ["3-5"], "mix": ["5", "8-12", "10-15"], "high": ["12-15"], "cardio": { "regular": ["8 mins"], "hiit": ["15 seconds"], "both": { "Plyo": "10 seconds", "Cardio": "5 mins" } } } # Initially filter down by gear if gear == "gymless": data = filterExercises(data, ["GymLevel"], [["Gymless"]]) elif gear == "basic": data = filterExercises(data, ["GymLevel"], [["None", "Gymless", "Basic"]]) # Get repRanges for the specified goal repRanges = allRanges[goal] # Cardio process is different so check the goal input if goal == "cardio": # Check the cardio value for rep range repRanges = repRanges[groupOrCardio] # Assign body parts variable (For object) to None allParts = None # Filter for cardio exercises only data = filterExercises(data, ["ExerciseType"], [["Cardio", "Plyo"]]) else: # Get full body exercise for warmup fullBody = filterExercises(data, ["MuscleGroup"], [["Full"]]) # Filter data for body part data = filterExercises(data, ["MuscleGroup"], [[groupOrCardio.capitalize()]]) # Drop deadlift fullBody.drop(fullBody[fullBody.MainLift == "Yes"].index) # Append together data = data.append(fullBody, ignore_index=True) # All parts assigned from bodyDict allParts = bodyDict[groupOrCardio] # Finalise Workout object args target = groupOrCardio workoutObj = Workout(data, target, allParts, repRanges, gear) return workoutObj