fixes, test_aworkouts misbehaving
This commit is contained in:
@@ -170,6 +170,7 @@ pytest-django==3.4.8
|
||||
pytest-forked==1.0.2
|
||||
pytest-runner==4.4
|
||||
pytest-sugar==0.9.2
|
||||
pytest-timeout==1.4.2
|
||||
pytest-xdist==1.27.0
|
||||
python-dateutil==2.8.0
|
||||
python-memcached==1.59
|
||||
|
||||
@@ -60,7 +60,7 @@ def updatecp(delta,cpvalues,r,workouttype='water'):
|
||||
|
||||
return 1
|
||||
|
||||
def cpfit(powerdf):
|
||||
def cpfit(powerdf,fraclimit=0.0001,nmax=1000):
|
||||
# Fit the data to thee parameter CP model
|
||||
fitfunc = lambda pars,x: abs(pars[0])/(1+(x/abs(pars[2]))) + abs(pars[1])/(1+(x/abs(pars[3])))
|
||||
errfunc = lambda pars,x,y: fitfunc(pars,x)-y
|
||||
@@ -96,11 +96,13 @@ def cpfit(powerdf):
|
||||
|
||||
frac = abs(ddmin)/fitpoints.mean()
|
||||
|
||||
while frac>0.0001:
|
||||
counter = 0
|
||||
while frac>fraclimit and counter<nmax:
|
||||
fitpoints = fitpoints*(fitpoints.mean()-ddmin)/(fitpoints.mean())
|
||||
dd = fitpoints-theavpower
|
||||
ddmin = dd.min()
|
||||
frac = abs(ddmin)/fitpoints.mean()
|
||||
counter += 1
|
||||
|
||||
ratio = fitpoints.mean()/fitpoints0.mean()
|
||||
|
||||
|
||||
@@ -158,6 +158,8 @@ class BoxPlotTest(TestCase):
|
||||
options['userid'] = 1
|
||||
options['plotfield'] = 'spm'
|
||||
options['rankingonly'] = False
|
||||
options['cpfit'] = 'data'
|
||||
options['piece'] = 4
|
||||
|
||||
session = self.c.session
|
||||
session['options'] = options
|
||||
@@ -1065,6 +1067,8 @@ class WorkoutStatsTestNew(TestCase):
|
||||
'spmmax':55,
|
||||
'workmin':0,
|
||||
'workmax':1500,
|
||||
'cpfit':'data',
|
||||
'piece': 4,
|
||||
'includereststrokes':False,
|
||||
'modality':'all',
|
||||
'waterboattype':['1x','2x','4x'],
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from .statements import *
|
||||
from django.db import transaction
|
||||
|
||||
nu = datetime.datetime.now()
|
||||
|
||||
@@ -144,7 +145,9 @@ class WorkoutViewTest(TestCase):
|
||||
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
@patch('rowers.dataprep.getsmallrowdata_db')
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_joins(self, mocked_sqlalchemy, mocked_getsmallrowdata_db):
|
||||
with transaction.atomic():
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
self.assertTrue(login)
|
||||
|
||||
@@ -485,8 +488,10 @@ class WorkoutViewTest(TestCase):
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
@patch('rowers.dataprep.getsmallrowdata_db')
|
||||
@patch('rowers.dataprep.getrowdata_db',side_effect=mocked_getrowdata_db)
|
||||
@pytest.mark.django_db(transaction=True)
|
||||
def test_workout_split(self, mocked_sqlalchemy, mocked_getsmallrowdata_db,
|
||||
mocked_getrowdata_db):
|
||||
with transaction.atomic():
|
||||
login = self.c.login(username=self.u.username, password=self.password)
|
||||
self.assertTrue(login)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user