@@ -1329,8 +1329,7 @@ def setUp(self):
1329
1329
1330
1330
def test_plot_return (self ):
1331
1331
# check the plot returns correct objects
1332
- fig1 , axs1 = qdb .util .resource_allocation_plot (
1333
- self .df , self .cname , self .sname , self .col_name )
1332
+ fig1 , axs1 = qdb .util .resource_allocation_plot (self .df , self .col_name )
1334
1333
self .assertIsInstance (
1335
1334
fig1 , Figure ,
1336
1335
"Returned object fig1 is not a Matplotlib Figure" )
@@ -1346,46 +1345,46 @@ def test_minimize_const(self):
1346
1345
self .df [self .col_name ] = self .df .samples * self .df ['columns' ]
1347
1346
fig , axs = plt .subplots (ncols = 2 , figsize = (10 , 4 ), sharey = False )
1348
1347
1349
- bm , options = qdb .util ._resource_allocation_plot_helper (
1350
- self . df , axs [ 0 ], self . cname , self . sname , 'MaxRSSRaw' ,
1351
- qdb . util . MODELS_MEM , self .col_name )
1348
+ mem_models , time_models = qdb .util .retrieve_equations ()
1349
+ bm_name , bm , options = qdb . util . _resource_allocation_plot_helper (
1350
+ self . df , axs [ 0 ], 'MaxRSSRaw' , mem_models , self .col_name )
1352
1351
# check that the algorithm chooses correct model for MaxRSSRaw and
1353
1352
# has 0 failures
1354
1353
k , a , b = options .x
1355
- failures_df = qdb .util ._resource_allocation_failures (
1356
- self .df , k , a , b , bm , self .col_name , 'MaxRSSRaw' )
1354
+ failures_df = qdb .util ._resource_allocation_success_failures (
1355
+ self .df , k , a , b , bm , self .col_name , 'MaxRSSRaw' )[ - 1 ]
1357
1356
failures = failures_df .shape [0 ]
1358
- self .assertEqual (bm , qdb .util .mem_model3 ,
1357
+
1358
+ self .assertEqual (bm_name , 'mem_model4' ,
1359
+ msg = f"""Best memory model
1360
+ doesn't match
1361
+ { bm_name } != 'mem_model4'""" )
1362
+ self .assertEqual (bm , mem_models ['mem_model4' ]['equation' ],
1359
1363
msg = f"""Best memory model
1360
1364
doesn't match
1361
1365
Coefficients:{ k } { a } { b }
1362
- { qdb .util .mem_model1 } , "qdb.util.mem_model1"
1363
- { qdb .util .mem_model2 } , "qdb.util.mem_model2"
1364
- { qdb .util .mem_model3 } , "qdb.util.mem_model3"
1365
- { qdb .util .mem_model4 } , "qdb.util.mem_model4"
1366
1366
""" )
1367
1367
self .assertEqual (failures , 0 , "Number of failures must be 0" )
1368
1368
1369
1369
# check that the algorithm chooses correct model for ElapsedRaw and
1370
1370
# has 1 failure
1371
- bm , options = qdb .util ._resource_allocation_plot_helper (
1372
- self .df , axs [1 ], self .cname , self .sname , 'ElapsedRaw' ,
1373
- qdb .util .MODELS_TIME , self .col_name )
1371
+ bm_name , bm , options = qdb .util ._resource_allocation_plot_helper (
1372
+ self .df , axs [1 ], 'ElapsedRaw' , time_models , self .col_name )
1374
1373
k , a , b = options .x
1375
- failures_df = qdb .util ._resource_allocation_failures (
1376
- self .df , k , a , b , bm , self .col_name , 'ElapsedRaw' )
1374
+ failures_df = qdb .util ._resource_allocation_success_failures (
1375
+ self .df , k , a , b , bm , self .col_name , 'ElapsedRaw' )[ - 1 ]
1377
1376
failures = failures_df .shape [0 ]
1377
+ self .assertEqual (bm_name , 'time_model4' ,
1378
+ msg = f"""Best time model
1379
+ doesn't match
1380
+ { bm_name } != 'time_model4'""" )
1378
1381
1379
- self .assertEqual (bm , qdb . util . time_model1 ,
1382
+ self .assertEqual (bm , time_models [ bm_name ][ 'equation' ] ,
1380
1383
msg = f"""Best time model
1381
1384
doesn't match
1382
1385
Coefficients:{ k } { a } { b }
1383
- { qdb .util .time_model1 } , "qdb.util.time_model1"
1384
- { qdb .util .time_model2 } , "qdb.util.time_model2"
1385
- { qdb .util .time_model3 } , "qdb.util.time_model3"
1386
- { qdb .util .time_model4 } , "qdb.util.time_model4"
1387
1386
""" )
1388
- self .assertEqual (failures , 1 , "Number of failures must be 1 " )
1387
+ self .assertEqual (failures , 0 , "Number of failures must be 0 " )
1389
1388
1390
1389
def test_MaxRSS_helper (self ):
1391
1390
tests = [
0 commit comments