Private
Public Access
1
0

Merge branch 'feature/thinkpad' into develop

This commit is contained in:
Sander Roosendaal
2019-02-09 08:58:11 +01:00
19 changed files with 170 additions and 151 deletions
+14 -14
View File
@@ -327,11 +327,11 @@ def createc2workoutdata_as_splits(w):
maxhr = int(df[' HRCur (bpm)'].max()) maxhr = int(df[' HRCur (bpm)'].max())
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
t = 10*df.ix[:,' ElapsedTime (sec)'].diff().values t = 10*df.loc[:,' ElapsedTime (sec)'].diff().values
t[0] = t[1] t[0] = t[1]
d = df.ix[:,' Horizontal (meters)'].diff().values d = df.loc[:,' Horizontal (meters)'].diff().values
d[0] = d[1] d[0] = d[1]
p = 10*df.ix[:,' Stroke500mPace (sec/500m)'].values p = 10*df.loc[:,' Stroke500mPace (sec/500m)'].values
t = t.astype(int) t = t.astype(int)
d = d.astype(int) d = d.astype(int)
p = p.astype(int) p = p.astype(int)
@@ -396,11 +396,11 @@ def createc2workoutdata(w):
maxhr = 0 maxhr = 0
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
t = 10*row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] t = 10*row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.loc[:,'TimeStamp (sec)'].iloc[0]
t[0] = t[1] t[0] = t[1]
d = 10*row.df.ix[:,' Horizontal (meters)'].values d = 10*row.df.loc[:,' Horizontal (meters)'].values
d[0] = d[1] d[0] = d[1]
p = abs(10*row.df.ix[:,' Stroke500mPace (sec/500m)'].values) p = abs(10*row.df.loc[:,' Stroke500mPace (sec/500m)'].values)
p = np.clip(p,0,3600) p = np.clip(p,0,3600)
if w.workouttype == 'bike': if w.workouttype == 'bike':
p = 2.0*p p = 2.0*p
@@ -817,35 +817,35 @@ def add_workout_from_data(user,importid,data,strokedata,
unixtime = cum_time+starttimeunix unixtime = cum_time+starttimeunix
# unixtime[0] = starttimeunix # unixtime[0] = starttimeunix
seconds = 0.1*strokedata.ix[:,'t'] seconds = 0.1*strokedata.loc[:,'t']
nr_rows = len(unixtime) nr_rows = len(unixtime)
try: try:
latcoord = strokedata.ix[:,'lat'] latcoord = strokedata.loc[:,'lat']
loncoord = strokedata.ix[:,'lon'] loncoord = strokedata.loc[:,'lon']
except: except:
latcoord = np.zeros(nr_rows) latcoord = np.zeros(nr_rows)
loncoord = np.zeros(nr_rows) loncoord = np.zeros(nr_rows)
try: try:
strokelength = strokedata.ix[:,'strokelength'] strokelength = strokedata.loc[:,'strokelength']
except: except:
strokelength = np.zeros(nr_rows) strokelength = np.zeros(nr_rows)
dist2 = 0.1*strokedata.ix[:,'d'] dist2 = 0.1*strokedata.loc[:,'d']
try: try:
spm = strokedata.ix[:,'spm'] spm = strokedata.loc[:,'spm']
except KeyError: except KeyError:
spm = 0*dist2 spm = 0*dist2
try: try:
hr = strokedata.ix[:,'hr'] hr = strokedata.loc[:,'hr']
except KeyError: except KeyError:
hr = 0*spm hr = 0*spm
pace = strokedata.ix[:,'p']/10. pace = strokedata.loc[:,'p']/10.
pace = np.clip(pace,0,1e4) pace = np.clip(pace,0,1e4)
pace = pace.replace(0,300) pace = pace.replace(0,300)
+48 -48
View File
@@ -2001,18 +2001,18 @@ def interactive_windchart(id=0,promember=0):
if rowdata == 0: if rowdata == 0:
return 0 return 0
dist = rowdata.df.ix[:,'cum_dist'] dist = rowdata.df.loc[:,'cum_dist']
try: try:
vwind = rowdata.df.ix[:,'vwind'] vwind = rowdata.df.loc[:,'vwind']
winddirection = rowdata.df.ix[:,'winddirection'] winddirection = rowdata.df.loc[:,'winddirection']
bearing = rowdata.df.ix[:,'bearing'] bearing = rowdata.df.loc[:,'bearing']
except KeyError: except KeyError:
rowdata.add_wind(0,0) rowdata.add_wind(0,0)
rowdata.add_bearing() rowdata.add_bearing()
vwind = rowdata.df.ix[:,'vwind'] vwind = rowdata.df.loc[:,'vwind']
winddirection = rowdata.df.ix[:,'winddirection'] winddirection = rowdata.df.loc[:,'winddirection']
bearing = rowdata.df.ix[:,'winddirection'] bearing = rowdata.df.loc[:,'winddirection']
rowdata.write_csv(f1,gzip=True) rowdata.write_csv(f1,gzip=True)
dataprep.update_strokedata(id,rowdata.df) dataprep.update_strokedata(id,rowdata.df)
@@ -2091,13 +2091,13 @@ def interactive_streamchart(id=0,promember=0):
if rowdata == 0: if rowdata == 0:
return "","No Valid Data Available" return "","No Valid Data Available"
dist = rowdata.df.ix[:,'cum_dist'] dist = rowdata.df.loc[:,'cum_dist']
try: try:
vstream = rowdata.df.ix[:,'vstream'] vstream = rowdata.df.loc[:,'vstream']
except KeyError: except KeyError:
rowdata.add_stream(0) rowdata.add_stream(0)
vstream = rowdata.df.ix[:,'vstream'] vstream = rowdata.df.loc[:,'vstream']
rowdata.write_csv(f1,gzip=True) rowdata.write_csv(f1,gzip=True)
dataprep.update_strokedata(id,rowdata.df) dataprep.update_strokedata(id,rowdata.df)
@@ -2300,7 +2300,7 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='',
xaxmax = datadf[xparam].max() xaxmax = datadf[xparam].max()
xaxmin = datadf[xparam].min() xaxmin = datadf[xparam].min()
elif xparam=='time': elif xparam=='time':
tseconds = datadf.ix[:,'time'] tseconds = datadf.loc[:,'time']
xaxmax = tseconds.max() xaxmax = tseconds.max()
xaxmin = 0 xaxmin = 0
elif xparam == 'workoutid': elif xparam == 'workoutid':
@@ -2314,7 +2314,7 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='',
yaxmax = datadf[yparam].max() yaxmax = datadf[yparam].max()
yaxmin = datadf[yparam].min() yaxmin = datadf[yparam].min()
elif yparam=='time': elif yparam=='time':
tseconds = datadf.ix[:,'time'] tseconds = datadf.loc[:,'time']
yaxmax = tseconds.max() yaxmax = tseconds.max()
yaxmin = 0 yaxmin = 0
elif yparam == 'workoutid': elif yparam == 'workoutid':
@@ -2517,7 +2517,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
try: try:
datadf['x1'] = datadf.ix[:,xparam] datadf['x1'] = datadf.loc[:,xparam]
except KeyError: except KeyError:
try: try:
datadf['x1'] = datadf['distance'] datadf['x1'] = datadf['distance']
@@ -2528,7 +2528,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
return ['','<p>No non-zero data in selection</p>','',''] return ['','<p>No non-zero data in selection</p>','','']
try: try:
datadf['y1'] = datadf.ix[:,yparam1] datadf['y1'] = datadf.loc[:,yparam1]
except KeyError: except KeyError:
try: try:
datadf['y1'] = datadf['pace'] datadf['y1'] = datadf['pace']
@@ -2536,7 +2536,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
return ['','<p>No non-zero data in selection</p>','',''] return ['','<p>No non-zero data in selection</p>','','']
if yparam2 != 'None': if yparam2 != 'None':
try: try:
datadf['y2'] = datadf.ix[:,yparam2] datadf['y2'] = datadf.loc[:,yparam2]
except KeyError: except KeyError:
datadf['y2'] = datadf['y1'] datadf['y2'] = datadf['y1']
else: else:
@@ -2566,7 +2566,7 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
if yparam1 == 'pace': if yparam1 == 'pace':
y_axis_type = 'datetime' y_axis_type = 'datetime'
y1mean = datadf.ix[:,'pace'].mean() y1mean = datadf.loc[:,'pace'].mean()
datadf['xname'] = axlabels[xparam] datadf['xname'] = axlabels[xparam]
datadf['yname1'] = axlabels[yparam1] datadf['yname1'] = axlabels[yparam1]
@@ -2896,30 +2896,30 @@ def interactive_flex_chart2(id=0,promember=0,
pass pass
try: try:
tseconds = rowdata.ix[:,'time'] tseconds = rowdata.loc[:,'time']
except KeyError: except KeyError:
return '','No time data - cannot make flex plot','','',workstrokesonly return '','No time data - cannot make flex plot','','',workstrokesonly
try: try:
rowdata['x1'] = rowdata.ix[:,xparam] rowdata['x1'] = rowdata.loc[:,xparam]
rowmin = rowdata[xparam].min() rowmin = rowdata[xparam].min()
except KeyError: except KeyError:
rowdata['x1'] = 0*rowdata.ix[:,'time'] rowdata['x1'] = 0*rowdata.loc[:,'time']
try: try:
rowdata['y1'] = rowdata.ix[:,yparam1] rowdata['y1'] = rowdata.loc[:,yparam1]
rowmin = rowdata[yparam1].min() rowmin = rowdata[yparam1].min()
except KeyError: except KeyError:
rowdata['y1'] = 0*rowdata.ix[:,'time'] rowdata['y1'] = 0*rowdata.loc[:,'time']
rowdata[yparam1] = rowdata['y1'] rowdata[yparam1] = rowdata['y1']
if yparam2 != 'None': if yparam2 != 'None':
try: try:
rowdata['y2'] = rowdata.ix[:,yparam2] rowdata['y2'] = rowdata.loc[:,yparam2]
rowmin = rowdata[yparam2].min() rowmin = rowdata[yparam2].min()
except KeyError: except KeyError:
rowdata['y2'] = 0*rowdata.ix[:,'time'] rowdata['y2'] = 0*rowdata.loc[:,'time']
rowdata[yparam2] = rowdata['y2'] rowdata[yparam2] = rowdata['y2']
else: else:
rowdata['y2'] = rowdata['y1'] rowdata['y2'] = rowdata['y1']
@@ -2968,7 +2968,7 @@ def interactive_flex_chart2(id=0,promember=0,
if yparam1 == 'pace': if yparam1 == 'pace':
y_axis_type = 'datetime' y_axis_type = 'datetime'
try: try:
y1mean = rowdata.ix[:,'pace'].mean() y1mean = rowdata.loc[:,'pace'].mean()
except KeyError: except KeyError:
y1mean = 0 y1mean = 0
@@ -3450,26 +3450,26 @@ def thumbnail_flex_chart(rowdata,id=0,promember=0,
try: try:
tseconds = rowdata.ix[:,'time'] tseconds = rowdata.loc[:,'time']
except KeyError: except KeyError:
return '','No time data - cannot make flex plot' return '','No time data - cannot make flex plot'
try: try:
rowdata['x1'] = rowdata.ix[:,xparam] rowdata['x1'] = rowdata.loc[:,xparam]
except KeyError: except KeyError:
rowdata['x1'] = 0*rowdata.ix[:,'time'] rowdata['x1'] = 0*rowdata.loc[:,'time']
try: try:
rowdata['y1'] = rowdata.ix[:,yparam1] rowdata['y1'] = rowdata.loc[:,yparam1]
except KeyError: except KeyError:
rowdata['y1'] = 0*rowdata.ix[:,'time'] rowdata['y1'] = 0*rowdata.loc[:,'time']
if yparam2 != 'None': if yparam2 != 'None':
try: try:
rowdata['y2'] = rowdata.ix[:,yparam2] rowdata['y2'] = rowdata.loc[:,yparam2]
except KeyError: except KeyError:
rowdata['y2'] = 0*rowdata.ix[:,'time'] rowdata['y2'] = 0*rowdata.loc[:,'time']
else: else:
rowdata['y2'] = rowdata['y1'] rowdata['y2'] = rowdata['y1']
@@ -3490,7 +3490,7 @@ def thumbnail_flex_chart(rowdata,id=0,promember=0,
if yparam1 == 'pace': if yparam1 == 'pace':
y_axis_type = 'datetime' y_axis_type = 'datetime'
y1mean = rowdata.ix[:,'pace'].mean() y1mean = rowdata.loc[:,'pace'].mean()
rowdata['xname'] = axlabels[xparam] rowdata['xname'] = axlabels[xparam]
@@ -3732,9 +3732,9 @@ def interactive_multiple_compare_chart(ids,xparam,yparam,plottype='line',
nrworkouts = len(ids) nrworkouts = len(ids)
try: try:
tseconds = datadf.ix[:,'time'] tseconds = datadf.loc[:,'time']
except KeyError: except KeyError:
tseconds = datadf.ix[:,xparam] tseconds = datadf.loc[:,xparam]
yparamname = axlabels[yparam] yparamname = axlabels[yparam]
@@ -3954,11 +3954,11 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
rowdata2.sort_values(by='time',ascending=True,inplace=True) rowdata2.sort_values(by='time',ascending=True,inplace=True)
try: try:
x1 = rowdata1.ix[:,xparam] x1 = rowdata1.loc[:,xparam]
x2 = rowdata2.ix[:,xparam] x2 = rowdata2.loc[:,xparam]
y1 = rowdata1.ix[:,yparam] y1 = rowdata1.loc[:,yparam]
y2 = rowdata2.ix[:,yparam] y2 = rowdata2.loc[:,yparam]
except KeyError: except KeyError:
return "","No valid Data Available" return "","No valid Data Available"
@@ -3976,21 +3976,21 @@ def interactive_comparison_chart(id1=0,id2=0,xparam='distance',yparam='spm',
ymax = 1.0e3*90 ymax = 1.0e3*90
ymin = 1.0e3*210 ymin = 1.0e3*210
ftime1 = rowdata1.ix[:,'ftime'] ftime1 = rowdata1.loc[:,'ftime']
ftime2 = rowdata2.ix[:,'ftime'] ftime2 = rowdata2.loc[:,'ftime']
hr1 = rowdata1.ix[:,'hr'] hr1 = rowdata1.loc[:,'hr']
hr2 = rowdata2.ix[:,'hr'] hr2 = rowdata2.loc[:,'hr']
fpace1 = rowdata1.ix[:,'fpace'] fpace1 = rowdata1.loc[:,'fpace']
fpace2 = rowdata2.ix[:,'fpace'] fpace2 = rowdata2.loc[:,'fpace']
distance1 = rowdata1.ix[:,'distance'] distance1 = rowdata1.loc[:,'distance']
distance2 = rowdata2.ix[:,'distance'] distance2 = rowdata2.loc[:,'distance']
spm1 = rowdata1.ix[:,'spm'] spm1 = rowdata1.loc[:,'spm']
spm2 = rowdata2.ix[:,'spm'] spm2 = rowdata2.loc[:,'spm']
if (promember==1): if (promember==1):
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,resize,crosshair' TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,hover,resize,crosshair'
+27 -19
View File
@@ -56,6 +56,19 @@ timezones = (
(x,x) for x in pytz.common_timezones (x,x) for x in pytz.common_timezones
) )
def half_year_from_now():
return (datetime.datetime.now(tz=timezone.utc)+timezone.timedelta(days=182)).date()
def a_week_from_now():
return (datetime.datetime.now(tz=timezone.utc)+timezone.timedelta(days=7)).date()
def current_day():
return (datetime.datetime.now(tz=timezone.utc)).date()
def current_time():
return datetime.datetime.now(tz=timezone.utc)
class UserFullnameChoiceField(forms.ModelChoiceField): class UserFullnameChoiceField(forms.ModelChoiceField):
def label_from_instance(self,obj): def label_from_instance(self,obj):
return obj.get_full_name() return obj.get_full_name()
@@ -246,7 +259,7 @@ class PowerTimeFitnessMetric(models.Model):
('water','On the water') ('water','On the water')
) )
date = models.DateField(default=datetime.date.today) date = models.DateField(default=current_day)
last_workout = models.IntegerField(default=0) last_workout = models.IntegerField(default=0)
user = models.ForeignKey(User) user = models.ForeignKey(User)
PowerFourMin = models.FloatField(default=0) PowerFourMin = models.FloatField(default=0)
@@ -334,7 +347,7 @@ class TeamForm(ModelForm):
class TeamInvite(models.Model): class TeamInvite(models.Model):
team = models.ForeignKey(Team) team = models.ForeignKey(Team)
user = models.ForeignKey(User,null=True) user = models.ForeignKey(User,null=True)
issuedate = models.DateField(default=datetime.date.today) issuedate = models.DateField(default=current_day)
code = models.CharField(max_length=150,unique=True) code = models.CharField(max_length=150,unique=True)
email = models.CharField(max_length=150,null=True,blank=True) email = models.CharField(max_length=150,null=True,blank=True)
@@ -352,7 +365,7 @@ class TeamInviteForm(ModelForm):
class TeamRequest(models.Model): class TeamRequest(models.Model):
team = models.ForeignKey(Team) team = models.ForeignKey(Team)
user = models.ForeignKey(User,null=True) user = models.ForeignKey(User,null=True)
issuedate = models.DateField(default=datetime.date.today) issuedate = models.DateField(default=current_day)
code = models.CharField(max_length=150,unique=True) code = models.CharField(max_length=150,unique=True)
from utils import ( from utils import (
@@ -655,8 +668,8 @@ class Rower(models.Model):
paidplan = models.ForeignKey(PaidPlan,null=True,default=None) paidplan = models.ForeignKey(PaidPlan,null=True,default=None)
planexpires = models.DateField(default=datetime.date.today) planexpires = models.DateField(default=current_day)
teamplanexpires = models.DateField(default=datetime.date.today) teamplanexpires = models.DateField(default=current_day)
clubsize = models.IntegerField(default=0) clubsize = models.IntegerField(default=0)
protrialexpires = models.DateField(blank=True,null=True) protrialexpires = models.DateField(blank=True,null=True)
plantrialexpires = models.DateField(blank=True,null=True) plantrialexpires = models.DateField(blank=True,null=True)
@@ -1021,11 +1034,6 @@ class GeoPoint(models.Model):
# of multiple GeoPoint instances # of multiple GeoPoint instances
def half_year_from_now():
return (timezone.now()+timezone.timedelta(days=182)).date()
def a_week_from_now():
return (timezone.now()+timezone.timedelta(days=7)).date()
# models related to training planning - draft # models related to training planning - draft
# Do we need a separate class TestTarget? # Do we need a separate class TestTarget?
@@ -1104,7 +1112,7 @@ class TrainingPlan(models.Model):
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
status = models.BooleanField(default=True,verbose_name='Active') status = models.BooleanField(default=True,verbose_name='Active')
target = models.ForeignKey(TrainingTarget,blank=True,null=True) target = models.ForeignKey(TrainingTarget,blank=True,null=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
@@ -1193,7 +1201,7 @@ class TrainingPlanForm(ModelForm):
elif self.instance.pk is not None: elif self.instance.pk is not None:
self.fields['target'].queryset = TrainingTarget.objects.filter( self.fields['target'].queryset = TrainingTarget.objects.filter(
manager=self.instance.manager, manager=self.instance.manager,
date__gte=datetime.date.today()).order_by("date") date__gte=current_day()).order_by("date")
else: else:
self.fields.pop('target') self.fields.pop('target')
@@ -1468,7 +1476,7 @@ def macrocyclecheckdates(plan):
class TrainingMacroCycle(models.Model): class TrainingMacroCycle(models.Model):
plan = models.ForeignKey(TrainingPlan) plan = models.ForeignKey(TrainingPlan)
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True) notes = models.TextField(max_length=300,blank=True)
@@ -1554,7 +1562,7 @@ class TrainingMacroCycleForm(ModelForm):
class TrainingMesoCycle(models.Model): class TrainingMesoCycle(models.Model):
plan = models.ForeignKey(TrainingMacroCycle) plan = models.ForeignKey(TrainingMacroCycle)
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True) notes = models.TextField(max_length=300,blank=True)
@@ -1629,7 +1637,7 @@ class TrainingMesoCycle(models.Model):
class TrainingMicroCycle(models.Model): class TrainingMicroCycle(models.Model):
plan = models.ForeignKey(TrainingMesoCycle) plan = models.ForeignKey(TrainingMesoCycle)
name = models.CharField(max_length=150,blank=True) name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=datetime.date.today) startdate = models.DateField(default=current_day)
enddate = models.DateField( enddate = models.DateField(
default=half_year_from_now) default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True) notes = models.TextField(max_length=300,blank=True)
@@ -1776,7 +1784,7 @@ class PlannedSession(models.Model):
comment = models.TextField(max_length=500,blank=True, comment = models.TextField(max_length=500,blank=True,
) )
startdate = models.DateField(default=datetime.date.today, startdate = models.DateField(default=current_day,
verbose_name='On or After') verbose_name='On or After')
enddate = models.DateField(default=a_week_from_now, enddate = models.DateField(default=a_week_from_now,
@@ -3288,10 +3296,10 @@ class RowerForm(ModelForm):
# An announcement that goes to the right of the workouts list # An announcement that goes to the right of the workouts list
# optionally sends a tweet to our twitter account # optionally sends a tweet to our twitter account
class SiteAnnouncement(models.Model): class SiteAnnouncement(models.Model):
created = models.DateField(default=datetime.date.today) created = models.DateField(default=current_day)
announcement = models.TextField(max_length=280) announcement = models.TextField(max_length=280)
expires = models.DateField(default=datetime.date.today) expires = models.DateField(default=current_day)
modified = models.DateField(default=datetime.date.today) modified = models.DateField(default=current_day)
dotweet = models.BooleanField(default=False) dotweet = models.BooleanField(default=False)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
+5 -5
View File
@@ -58,10 +58,10 @@ def y_axis_range(ydata,miny=0,padding=.1,ultimate=[-1e9,1e9]):
def mkplot(row,title): def mkplot(row,title):
df = row.df df = row.df
t = df.ix[:,' ElapsedTime (sec)'] t = df.loc[:,' ElapsedTime (sec)']
p = df.ix[:,' Stroke500mPace (sec/500m)'] p = df.loc[:,' Stroke500mPace (sec/500m)']
hr = df.ix[:,' HRCur (bpm)'] hr = df.loc[:,' HRCur (bpm)']
end_time = int(df.ix[df.shape[0]-1,'TimeStamp (sec)']) end_time = int(df.loc[:,'TimeStamp (sec)'].iloc[df.shape[0]-1])
fig, ax1 = plt.subplots(figsize=(5,4)) fig, ax1 = plt.subplots(figsize=(5,4))
@@ -69,7 +69,7 @@ def mkplot(row,title):
ax1.set_xlabel('Time (h:m)') ax1.set_xlabel('Time (h:m)')
ax1.set_ylabel('(sec/500)') ax1.set_ylabel('(sec/500)')
yrange = y_axis_range(df.ix[:,' Stroke500mPace (sec/500m)'], yrange = y_axis_range(df.loc[:,' Stroke500mPace (sec/500m)'],
ultimate = [85,190]) ultimate = [85,190])
plt.axis([0,end_time,yrange[1],yrange[0]]) plt.axis([0,end_time,yrange[1],yrange[0]])
+2 -2
View File
@@ -117,10 +117,10 @@ def createrunkeeperworkoutdata(w):
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] #t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
t = row.df.ix[:,'TimeStamp (sec)'].values-row.df.ix[0,'TimeStamp (sec)'] t = row.df.loc[:,'TimeStamp (sec)'].values-row.df.loc[:,'TimeStamp (sec)'].iloc[0]
t[0] = t[1] t[0] = t[1]
d = row.df.ix[:,'cum_dist'].values d = row.df.loc[:,'cum_dist'].values
d[0] = d[1] d[0] = d[1]
t = t.astype(int) t = t.astype(int)
d = d.astype(int) d = d.astype(int)
+3 -3
View File
@@ -124,11 +124,11 @@ def createsporttracksworkoutdata(w):
duration += +1.0e-6*w.duration.microsecond duration += +1.0e-6*w.duration.microsecond
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] #t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
t = row.df.ix[:,'TimeStamp (sec)'].values-row.df.ix[0,'TimeStamp (sec)'] t = row.df.loc[:,'TimeStamp (sec)'].values-row.df.loc[:,'TimeStamp (sec)'].iloc[0]
t[0] = t[1] t[0] = t[1]
d = row.df.ix[:,'cum_dist'].values d = row.df.loc[:,'cum_dist'].values
d[0] = d[1] d[0] = d[1]
t = t.astype(int) t = t.astype(int)
d = d.astype(int) d = d.astype(int)
+9 -9
View File
@@ -518,42 +518,42 @@ def add_workout_from_data(user,importid,data,strokedata,
lapidx = res[1] lapidx = res[1]
unixtime = cum_time+starttimeunix unixtime = cum_time+starttimeunix
seconds = 0.1*strokedata.ix[:,'t'] seconds = 0.1*strokedata.loc[:,'t']
nr_rows = len(unixtime) nr_rows = len(unixtime)
try: try:
latcoord = strokedata.ix[:,'lat'] latcoord = strokedata.loc[:,'lat']
loncoord = strokedata.ix[:,'lon'] loncoord = strokedata.loc[:,'lon']
except: except:
latcoord = np.zeros(nr_rows) latcoord = np.zeros(nr_rows)
loncoord = np.zeros(nr_rows) loncoord = np.zeros(nr_rows)
try: try:
strokelength = strokedata.ix[:,'strokelength'] strokelength = strokedata.loc[:,'strokelength']
except: except:
strokelength = np.zeros(nr_rows) strokelength = np.zeros(nr_rows)
dist2 = 0.1*strokedata.ix[:,'d'] dist2 = 0.1*strokedata.loc[:,'d']
try: try:
spm = strokedata.ix[:,'spm'] spm = strokedata.loc[:,'spm']
except KeyError: except KeyError:
spm = 0*dist2 spm = 0*dist2
try: try:
hr = strokedata.ix[:,'hr'] hr = strokedata.loc[:,'hr']
except KeyError: except KeyError:
hr = 0*spm hr = 0*spm
pace = strokedata.ix[:,'p']/10. pace = strokedata.loc[:,'p']/10.
pace = np.clip(pace,0,1e4) pace = np.clip(pace,0,1e4)
pace = pace.replace(0,300) pace = pace.replace(0,300)
velo = 500./pace velo = 500./pace
try: try:
power = strokedata.ix[:,'power'] power = strokedata.loc[:,'power']
except KeyError: except KeyError:
power = 2.8*velo**3 power = 2.8*velo**3
+12 -1
View File
@@ -185,16 +185,27 @@ class SessionFactory(factory.DjangoModelFactory):
@pytest.fixture(scope="session", autouse=True) @pytest.fixture(scope="session", autouse=True)
def cleanup(request): def cleanup(request):
def remove_test_files(): def remove_test_files():
try:
for filename in os.listdir('media/mailbox_attachments'): for filename in os.listdir('media/mailbox_attachments'):
path = os.path.join('media/mailbox_attachments/',filename) path = os.path.join('media/mailbox_attachments/',filename)
if not os.path.isdir(path): if not os.path.isdir(path):
try:
os.remove(path) os.remove(path)
except OSError:
pass
except OSError:
pass
try:
for filename in os.listdir('rowers/tests/testdata/temp'): for filename in os.listdir('rowers/tests/testdata/temp'):
path = os.path.join('rowers/tests/testdata/temp/',filename) path = os.path.join('rowers/tests/testdata/temp/',filename)
if not os.path.isdir(path): if not os.path.isdir(path):
try:
os.remove(path) os.remove(path)
except OSError:
pass
except OSError:
pass
request.addfinalizer(remove_test_files) request.addfinalizer(remove_test_files)
+2 -2
View File
@@ -31,7 +31,7 @@ class SimpleViewTest(TestCase):
except (IOError, WindowsError,OSError): except (IOError, WindowsError,OSError):
pass pass
def start_protrial(self): def test_start_protrial(self):
login = self.c.login(username=self.u.username, password=self.password) login = self.c.login(username=self.u.username, password=self.password)
self.assertTrue(login) self.assertTrue(login)
@@ -43,7 +43,7 @@ class SimpleViewTest(TestCase):
expected_url='/rowers/list-workouts/', expected_url='/rowers/list-workouts/',
status_code=302,target_status_code=200) status_code=302,target_status_code=200)
def start_plantrial(self): def test_start_plantrial(self):
login = self.c.login(username=self.u.username, password=self.password) login = self.c.login(username=self.u.username, password=self.password)
self.assertTrue(login) self.assertTrue(login)
+14 -14
View File
@@ -36,11 +36,11 @@ class OTWCPChartTest(TestCase):
for filename in os.listdir(u'rowers/tests/testdata/otwcp'): for filename in os.listdir(u'rowers/tests/testdata/otwcp'):
a2 = 'rowers/tests/testdata/otwcp/temp/'+filename a2 = 'rowers/tests/testdata/otwcp/temp/'+filename
try: try:
copyfile(u'rowers/tests/testdata/otwcp/'+filename,a2) copy(u'rowers/tests/testdata/otwcp/'+filename,a2)
row = rdata(a2) row = rdata(a2)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -124,16 +124,16 @@ class CPChartTest(TestCase):
recordsdf = pd.read_csv('rowers/tests/worldrecords.csv',encoding='utf-8') recordsdf = pd.read_csv('rowers/tests/worldrecords.csv',encoding='utf-8')
for i in range(len(recordsdf)): for i in recordsdf.index:
record = C2WorldClassAgePerformance( record = C2WorldClassAgePerformance(
name = recordsdf.ix[i,'name'], name = recordsdf.loc[i,'name'],
age = recordsdf.ix[i,'age'], age = recordsdf.loc[i,'age'],
distance = recordsdf.ix[i,'distance'], distance = recordsdf.loc[i,'distance'],
duration = recordsdf.ix[i,'duration'], duration = recordsdf.loc[i,'duration'],
power = recordsdf.ix[i,'power'], power = recordsdf.loc[i,'power'],
season = recordsdf.ix[i,'season'], season = recordsdf.loc[i,'season'],
sex = recordsdf.ix[i,'sex'], sex = recordsdf.loc[i,'sex'],
weightcategory = recordsdf.ix[i,'weightcategory'], weightcategory = recordsdf.loc[i,'weightcategory'],
) )
record.save() record.save()
@@ -142,11 +142,11 @@ class CPChartTest(TestCase):
r = self.u.rower r = self.u.rower
for i in range(len(perfsdf)): for i in perfsdf.index:
perf = CalcAgePerformance( perf = CalcAgePerformance(
age = age, age = age,
duration = perfsdf.ix[i,'duration'], duration = perfsdf.loc[i,'duration'],
power = perfsdf.ix[i,'power'], power = perfsdf.loc[i,'power'],
sex = r.sex, sex = r.sex,
weightcategory = r.weightcategory weightcategory = r.weightcategory
) )
+1 -1
View File
@@ -181,7 +181,7 @@ race 1
""") """)
m.save() m.save()
a2 = 'media/mailbox_attachments/minute.csv' a2 = 'media/mailbox_attachments/minute.csv'
copyfile('rowers/tests/testdata/minute.csv',a2) copy('rowers/tests/testdata/minute.csv',a2)
a = MessageAttachment(message=m,document=a2[6:]) a = MessageAttachment(message=m,document=a2[6:])
a.save() a.save()
+8 -8
View File
@@ -35,7 +35,7 @@ class C2Objects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -169,7 +169,7 @@ class C2ObjectsTokenExpired(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -247,7 +247,7 @@ class StravaObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -354,7 +354,7 @@ class STObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -484,7 +484,7 @@ class RunKeeperObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -577,7 +577,7 @@ class UAObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -679,7 +679,7 @@ class TPObjects(DjangoTestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
@@ -767,7 +767,7 @@ boattype: 2x
""") """)
m.save() m.save()
a2 = 'media/mailbox_attachments/'+filename a2 = 'media/mailbox_attachments/'+filename
copyfile('rowers/tests/testdata/'+filename,a2) copy('rowers/tests/testdata/'+filename,a2)
a = MessageAttachment(message=m,document=a2[6:]) a = MessageAttachment(message=m,document=a2[6:])
a.save() a.save()
+1 -1
View File
@@ -216,7 +216,7 @@ class URLTests(TestCase):
'/rowers/workout/1/split/', '/rowers/workout/1/split/',
'/rowers/workout/1/stats/', '/rowers/workout/1/stats/',
'/rowers/workout/1/stream/', '/rowers/workout/1/stream/',
'/rowers/workout/1/task/', # '/rowers/workout/1/task/',
'/rowers/workout/1/test_strokedata/', '/rowers/workout/1/test_strokedata/',
'/rowers/workout/1/toggle-ranking/', '/rowers/workout/1/toggle-ranking/',
'/rowers/workout/1/undosmoothenpace/', '/rowers/workout/1/undosmoothenpace/',
+1 -1
View File
@@ -26,7 +26,7 @@ class UserMiddleWareTest(TestCase):
row = rdata(filename,rower=rr) row = rdata(filename,rower=rr)
totaldist = row.df['cum_dist'].max() totaldist = row.df['cum_dist'].max()
totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min() totaltime = row.df['TimeStamp (sec)'].max()-row.df['TimeStamp (sec)'].min()
totaltime = totaltime+row.df.ix[0,' ElapsedTime (sec)'] totaltime = totaltime+row.df.loc[:,' ElapsedTime (sec)'].iloc[0]
hours = int(totaltime/3600.) hours = int(totaltime/3600.)
Binary file not shown.
+3 -3
View File
@@ -111,14 +111,14 @@ def createunderarmourworkoutdata(w):
notes = 'from '+w.workoutsource+' via rowsandall.com' notes = 'from '+w.workoutsource+' via rowsandall.com'
# adding diff, trying to see if this is valid # adding diff, trying to see if this is valid
#t = row.df.ix[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)'] #t = row.df.loc[:,'TimeStamp (sec)'].values-10*row.df.ix[0,'TimeStamp (sec)']
t = row.df.ix[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)'] t = row.df.loc[:,'TimeStamp (sec)'].values #-row.df.ix[0,'TimeStamp (sec)']
# t += arrow.get(st).timestamp # t += arrow.get(st).timestamp
# t[0] = t[1] # t[0] = t[1]
d = row.df.ix[:,'cum_dist'].values d = row.df.loc[:,'cum_dist'].values
d[0] = d[1] d[0] = d[1]
t = t.astype(float) t = t.astype(float)
+2 -2
View File
@@ -405,8 +405,8 @@ def ewmovingaverage(interval,window_size):
idf_ewma1 = intervaldf.ewm(span=window_size) idf_ewma1 = intervaldf.ewm(span=window_size)
idf_ewma2 = intervaldf[::-1].ewm(span=window_size) idf_ewma2 = intervaldf[::-1].ewm(span=window_size)
i_ewma1 = idf_ewma1.mean().ix[:,'v'] i_ewma1 = idf_ewma1.mean().loc[:,'v']
i_ewma2 = idf_ewma2.mean().ix[:,'v'] i_ewma2 = idf_ewma2.mean().loc[:,'v']
interval2 = np.vstack((i_ewma1,i_ewma2[::-1])) interval2 = np.vstack((i_ewma1,i_ewma2[::-1]))
interval2 = np.mean( interval2, axis=0) # average interval2 = np.mean( interval2, axis=0) # average
+7 -7
View File
@@ -12,7 +12,7 @@ def start_trial_view(request):
r.protrialexpires = datetime.date.today()+datetime.timedelta(13) r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
r.save() r.save()
url = reverse(workouts_view) url = reverse('workouts_view')
messages.info(request,'We have started your 14 day trial period') messages.info(request,'We have started your 14 day trial period')
@@ -40,7 +40,7 @@ def start_plantrial_view(request):
r.protrialexpires = datetime.date.today()+datetime.timedelta(13) r.protrialexpires = datetime.date.today()+datetime.timedelta(13)
r.save() r.save()
url = reverse(workouts_view) url = reverse('workouts_view')
messages.info(request,'We have started your 14 day trial period') messages.info(request,'We have started your 14 day trial period')
@@ -145,7 +145,7 @@ def rower_exportsettings_view(request,userid=0):
'name': 'Profile' 'name': 'Profile'
}, },
{ {
'url': reverse(rower_exportsettings_view), 'url': reverse('rower_exportsettings_view'),
'name': 'Export Settings' 'name': 'Export Settings'
} }
] ]
@@ -171,7 +171,7 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
'name': 'Profile' 'name': 'Profile'
}, },
{ {
'url': reverse(rower_edit_view), 'url': reverse('rower_edit_view'),
'name': 'Account Settings' 'name': 'Account Settings'
} }
] ]
@@ -261,7 +261,7 @@ def rower_prefs_view(request,userid=0,message=""):
'name': 'Profile' 'name': 'Profile'
}, },
{ {
'url': reverse(rower_prefs_view), 'url': reverse('rower_prefs_view'),
'name': 'Zones' 'name': 'Zones'
} }
] ]
@@ -375,7 +375,7 @@ def rower_revokeapp_view(request,id=0):
form = RowerForm(instance=r) form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r) powerform = RowerPowerForm(instance=r)
grants = AccessToken.objects.filter(user=request.user) grants = AccessToken.objects.filter(user=request.user)
url = reverse(rower_edit_view) url = reverse('rower_edit_view')
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
except AccessToken.DoesNotExist: except AccessToken.DoesNotExist:
raise Http404("Access token doesn't exist") raise Http404("Access token doesn't exist")
@@ -459,7 +459,7 @@ def rower_update_empower_view(
messages.info(request,successmessage) messages.info(request,successmessage)
url = reverse(workouts_view) url = reverse('workouts_view')
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
else: else:
+3 -3
View File
@@ -80,11 +80,11 @@ urlpatterns += [
if settings.DEBUG: if settings.DEBUG:
import debug_toolbar import debug_toolbar
import django
urlpatterns += [ urlpatterns += [
url(r'^__debug__/',include(debug_toolbar.urls)), url(r'^__debug__/',include(debug_toolbar.urls)),
url( url(r'^static/(?P<path>.*)$',
regex=r'^static/(?P<path>.*)$', django.views.static.serve,
view='django.views.static.serve',
kwargs={'document_root': settings.STATIC_ROOT,} kwargs={'document_root': settings.STATIC_ROOT,}
) )
] ]