예제 #1
0
파일: main.py 프로젝트: nslee0/trackster-py
    def build_add_btn_clicked(self):
        date = pd.Timestamp(self.build_date.text())
        sets = []

        # Warmup sets
        if self.build_warmup.text() == '':    # Auto-calculate warmup if no text present
            warmup = analysis.calc_warmup(self._build_tgt_e1rm, self._build_cur_lift)
            sets.extend(warmup)
        else:
            for set in self.build_warmup.text().split(','):
                parsed = analysis.parse_sets(set.strip(), self._build_tgt_e1rm)
                sets.extend(parsed)

        # Main/Drop sets
        if self.build_top_set.text() != '':
            top_set = analysis.parse_sets(self.build_top_set.text())
            sets.extend(top_set)

            top_weight, top_reps, top_rpe = top_set[-1]
            top_e1rm = analysis.calc_e1RM(self._build_cur_lift, top_weight, top_reps, top_rpe)
            fatigue = self.build_fatigue.value()
            self._build_cur_workout = self.db.make_workout(self._build_cur_lift, sets, date)
            drop_sets = self.build_get_drop_sets(top_set[-1], top_e1rm, fatigue, date)
            self._build_cur_workout = pd.concat((self._build_cur_workout, drop_sets), ignore_index=True)

        # Perform housekeeping
        self.build_clear.setEnabled(True)
        self.build_data_changed.emit()
        self.build_accept.setEnabled(True)
        self._log_unsaved_changes = True
예제 #2
0
 def _make_sets_repeat(self):
     if not self._drop_reps and self._drop_rpe and self._fatigue:
         return pd.DataFrame()
     start_rpe = analysis.rpe_table.ix[self._drop_reps, self._drop_rpe]
     desired_end_rpe = start_rpe + (self._fatigue / 100.0)
     if desired_end_rpe > analysis.rpe_table.ix[self._drop_reps].max():
         log_warn('Cannot achieve desired fatigue with given starting set')
     end_rpe_idx = np.argmin(np.abs(desired_end_rpe - analysis.rpe_table.ix[self._drop_reps]))
     end_rpe = analysis.rpe_table.ix[self._drop_reps, end_rpe_idx]
     sets_str = '{}x{}x{}@{}'.format(self._drop_weight, self._drop_reps, self._num_drop_sets, end_rpe)
     sets_tup = analysis.parse_sets(sets_str, self._e1rm)
     return self._db.make_workout(self._lift, sets_tup, self._date)
예제 #3
0
파일: main.py 프로젝트: nslee0/trackster-py
 def log_add_entry(self):
     try:
         date = pd.Timestamp(self.log_date.date().toPyDate())
         lift = self.log_lift.currentText()
         if not self.db.is_valid_lift(lift):
             raise ValueError('{} is not a valid lift'.format(lift))
         raw_sets = self.log_sets.text().split(',')
         parsed_sets = []
         for set in raw_sets:
             parsed_sets.extend(analysis.parse_sets(set.strip()))
         comments = self.log_comments.text()
         for set in parsed_sets:
             weight, reps, rpe = set
             self.db.add_set(date, lift, weight, reps, rpe, comments)
         self.db.calc_workout_data()
         self.log_date_changed(date - pd.Timedelta(days=1))
         self.log_date_changed(date)
         self.wl_data_changed.emit()
         self.log_lift.setCurrentText('')
         self.log_sets.setText('')
     except (ValueError, TypeError) as err:
         log_err(err, "Couldn't parse log entry")
예제 #4
0
 def _make_sets_manual(self):
     sets_str = self.drop_set.text()
     sets_tup = analysis.parse_sets(sets_str, self._e1rm)
     return self._db.make_workout(self._lift, sets_tup, self._date)
예제 #5
0
 def _make_sets_drop(self):
     if not self._drop_weight and self._drop_reps and self._num_drop_sets and self._drop_rpe:
         return pd.DataFrame()
     sets_str = '{}x{}x{}@{}'.format(self._drop_weight, self._drop_reps, self._num_drop_sets, self._drop_rpe)
     sets_tup = analysis.parse_sets(sets_str, self._e1rm)
     return self._db.make_workout(self._lift, sets_tup, self._date)