Skip to content
Snippets Groups Projects
Commit 5eeed6fc authored by Mads M. Pedersen's avatar Mads M. Pedersen Committed by Mads M. Pedersen
Browse files

add assert in speed check

parent 06ef8680
No related branches found
No related tags found
No related merge requests found
......@@ -11,9 +11,16 @@ from py_wake.deficit_models.gaussian import IEA37SimpleBastankhahGaussian
from py_wake.examples.data.hornsrev1 import wt_x, wt_y, HornsrevV80, Hornsrev1Site
from py_wake.tests import npt
from py_wake.tests.test_files import tfp
from pandas.plotting import register_matplotlib_converters
import sys
register_matplotlib_converters()
path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+00/'
def Fuga(site, wt):
return fuga.Fuga(path, site, wt)
test_lst = [(NOJ, 1.2), (IEA37SimpleBastankhahGaussian, 1.5), (Fuga, 1)]
def timeit(func, min_time=0, min_runs=1, verbose=False, line_profile=False, profile_funcs=[]):
......@@ -49,13 +56,13 @@ def timeit(func, min_time=0, min_runs=1, verbose=False, line_profile=False, prof
return newfunc
def check_speed_Hornsrev(WFModel):
def check_speed_Hornsrev(WFModel, max_min):
assert getattr(sys, 'gettrace')() is None, "Skipping speed check, In debug mode!!!"
wt = HornsrevV80()
site = Hornsrev1Site()
wf_model = WFModel(site, wt)
aep, t_lst = timeit(lambda x, y: wf_model(x, y).aep().sum(), min_runs=3)(wt_x, wt_y)
assert min(t_lst) < max_min, f'{WFModel},{t_lst}'
fn = tfp + "speed_check/%s.txt" % WFModel.__name__
if os.path.isfile(fn):
with open(fn) as fid:
......@@ -86,32 +93,16 @@ def check_speed_Hornsrev(WFModel):
def test_check_speed():
path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+0/'
def Fuga(site, wt):
return fuga.Fuga(path, site, wt)
for WFModel in [NOJ, IEA37SimpleBastankhahGaussian, Fuga]:
for WFModel, max_min in test_lst:
try:
check_speed_Hornsrev(WFModel)
check_speed_Hornsrev(WFModel, max_min)
except Exception as e:
print(WFModel)
print(e)
raise e
if 1:
plt.show()
if __name__ == '__main__':
path = tfp + 'fuga/2MW/Z0=0.03000000Zi=00401Zeta0=0.00E+0/'
def Fuga(site, wt):
return fuga.Fuga(path, site, wt)
for WFModel in [NOJ, IEA37SimpleBastankhahGaussian, Fuga]:
try:
check_speed_Hornsrev(WFModel)
except Exception as e:
print(e)
raise e
test_check_speed()
plt.show()
......@@ -46,3 +46,9 @@
2021-03-24 15:40:01.069009;680.0542817176;[0.9410347938537598]
2021-03-24 15:40:25.680229;680.0542817176;[0.9509880542755127]
2021-03-24 15:40:37.274572;680.0542817176;[0.9289705753326416]
2021-12-20 10:39:07.203441;680.6961102419;[0.9689991474151611, 0.8240001201629639, 0.7909998893737793] # new tables
2021-12-20 10:40:08.368150;680.6961102419;[0.8190009593963623, 0.812999963760376, 0.8109989166259766]
2021-12-20 10:47:24.988146;680.6961102419;[0.963998556137085, 0.8930001258850098, 0.9760003089904785]
2021-12-20 10:48:05.853171;680.6961102419;[0.7829618453979492, 0.7910001277923584, 0.809999942779541]
2021-12-20 10:48:40.895869;680.6961102419;[0.9470000267028809, 0.8640005588531494, 0.7500016689300537]
2021-12-20 10:49:05.187948;680.6961102419;[0.698009729385376, 0.701991081237793, 0.6890013217926025]
......@@ -45,3 +45,12 @@
2021-03-24 15:40:00.018012;694.1483188596;[1.6139659881591797]
2021-03-24 15:40:24.636272;694.1483188596;[1.5940558910369873]
2021-03-24 15:40:36.251507;694.1483188596;[1.6099998950958252]
2021-12-20 10:35:59.216210;694.1483188596;[1.270026683807373, 1.2549817562103271, 1.2079956531524658]
2021-12-20 10:37:13.608183;694.1483188596;[1.2830283641815186, 1.2799711227416992, 1.2120251655578613]
2021-12-20 10:37:50.511622;694.1483188596;[1.1530787944793701, 1.1429729461669922, 1.1049988269805908]
2021-12-20 10:39:04.512441;694.1483188596;[1.3489983081817627, 1.4019999504089355, 1.3509981632232666]
2021-12-20 10:40:05.819106;694.1483188596;[1.3552088737487793, 1.3480010032653809, 1.3265700340270996]
2021-12-20 10:47:22.038147;694.1483188596;[1.4070005416870117, 1.4819998741149902, 1.4779999256134033]
2021-12-20 10:48:03.359170;694.1483188596;[1.317962408065796, 1.3052401542663574, 1.3630027770996094]
2021-12-20 10:48:38.176819;694.1483188596;[2.2689995765686035, 1.52699875831604, 1.3280010223388672]
2021-12-20 10:49:02.965995;694.1483188596;[1.2209546566009521, 1.287999153137207, 1.2370526790618896]
......@@ -52,3 +52,13 @@
2021-03-24 15:39:58.350058;702.4351577191;[1.1950287818908691]
2021-03-24 15:40:22.993230;702.4351577191;[1.1969554424285889]
2021-03-24 15:40:34.592555;702.4351577191;[1.1860566139221191]
2021-12-20 10:35:55.425211;702.4351577191;[0.9559552669525146, 0.9260003566741943, 0.9099986553192139]
2021-12-20 10:37:09.776184;702.4351577191;[0.9470012187957764, 0.9230577945709229, 0.9379405975341797]
2021-12-20 10:37:47.058572;702.4351577191;[0.8040854930877686, 0.8061859607696533, 0.862985372543335]
2021-12-20 10:39:00.331441;702.4351577191;[0.968998908996582, 0.9860002994537354, 1.0679988861083984]
2021-12-20 10:40:01.719281;702.4351577191;[0.9549996852874756, 0.9740481376647949, 0.9611327648162842]
2021-12-20 10:46:54.640428;702.4351577191;[1.0889983177185059, 1.1360008716583252, 1.2905142307281494]
2021-12-20 10:47:17.593145;702.4351577191;[1.1049983501434326, 1.1020004749298096, 1.0570001602172852]
2021-12-20 10:47:59.304929;702.4351577191;[1.0309536457061768, 1.119999647140503, 0.984044075012207]
2021-12-20 10:48:32.975818;702.4351577191;[1.328003168106079, 1.1939973831176758, 1.0870013236999512]
2021-12-20 10:48:59.162999;702.4351577191;[0.8490030765533447, 0.9049582481384277, 0.8761954307556152]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment