33from math import nan
44from unittest .mock import patch
55
6- import libsbml
76import pandas as pd
87import pytest
98
109import petab
11- from petab import ( lint , sbml ) # noqa: E402
10+ from petab import lint
1211from petab .C import *
1312
1413# import fixtures
1716]
1817
1918
20- def test_assert_measured_observables_present_in_model ():
19+ def test_assert_measured_observables_present ():
2120 # create test model
2221
2322 measurement_df = pd .DataFrame (data = {
@@ -211,35 +210,32 @@ def test_assert_no_leading_trailing_whitespace():
211210
212211
213212def test_assert_model_parameters_in_condition_or_parameter_table ():
214- document = libsbml .SBMLDocument (3 , 1 )
215- model = document .createModel ()
216- model .setTimeUnits ("second" )
217- model .setExtentUnits ("mole" )
218- model .setSubstanceUnits ('mole' )
219- sbml .add_global_parameter (model , 'parameter1' )
220- sbml .add_global_parameter (model , 'noiseParameter1_' )
221- sbml .add_global_parameter (model , 'observableParameter1_' )
213+ import simplesbml
214+ ss_model = simplesbml .SbmlModel ()
215+ ss_model .addParameter ('parameter1' , 0.0 )
216+ ss_model .addParameter ('noiseParameter1_' , 0.0 )
217+ ss_model .addParameter ('observableParameter1_' , 0.0 )
218+ sbml_model = ss_model .model
222219
223220 lint .assert_model_parameters_in_condition_or_parameter_table (
224- model , pd .DataFrame (columns = ['parameter1' ]), pd .DataFrame ()
221+ sbml_model , pd .DataFrame (columns = ['parameter1' ]), pd .DataFrame ()
225222 )
226223
227224 lint .assert_model_parameters_in_condition_or_parameter_table (
228- model , pd .DataFrame (), pd .DataFrame (index = ['parameter1' ]))
225+ sbml_model , pd .DataFrame (), pd .DataFrame (index = ['parameter1' ]))
229226
230227 with pytest .raises (AssertionError ):
231228 lint .assert_model_parameters_in_condition_or_parameter_table (
232- model ,
229+ sbml_model ,
233230 pd .DataFrame (columns = ['parameter1' ]),
234231 pd .DataFrame (index = ['parameter1' ]))
235232
236233 lint .assert_model_parameters_in_condition_or_parameter_table (
237- model , pd .DataFrame (), pd .DataFrame ())
234+ sbml_model , pd .DataFrame (), pd .DataFrame ())
238235
239- sbml .create_assigment_rule (model , assignee_id = 'parameter1' ,
240- formula = 'parameter2' )
236+ ss_model .addAssignmentRule ('parameter1' , 'parameter2' )
241237 lint .assert_model_parameters_in_condition_or_parameter_table (
242- model , pd .DataFrame (), pd .DataFrame ())
238+ sbml_model , pd .DataFrame (), pd .DataFrame ())
243239
244240
245241def test_assert_noise_distributions_valid ():
@@ -406,10 +402,10 @@ def test_assert_measurement_conditions_present_in_condition_table():
406402 measurement_df = measurement_df , condition_df = condition_df )
407403
408404
409- def test_check_condition_df (minimal_sbml_model ):
405+ def test_check_condition_df ():
410406 """Check that we correctly detect errors in condition table"""
411-
412- _ , sbml_model = minimal_sbml_model
407+ import simplesbml
408+ ss_model = simplesbml . SbmlModel ()
413409
414410 condition_df = pd .DataFrame (data = {
415411 CONDITION_ID : ['condition1' ],
@@ -419,29 +415,29 @@ def test_check_condition_df(minimal_sbml_model):
419415
420416 # parameter missing in model
421417 with pytest .raises (AssertionError ):
422- lint .check_condition_df (condition_df , sbml_model )
418+ lint .check_condition_df (condition_df , ss_model . model )
423419
424420 # fix:
425- sbml_model . createParameter (). setId ( 'p1' )
426- lint .check_condition_df (condition_df , sbml_model )
421+ ss_model . addParameter ( 'p1' , 1.0 )
422+ lint .check_condition_df (condition_df , ss_model . model )
427423
428424 # species missing in model
429425 condition_df ['s1' ] = [3.0 ]
430426 with pytest .raises (AssertionError ):
431- lint .check_condition_df (condition_df , sbml_model )
427+ lint .check_condition_df (condition_df , ss_model . model )
432428
433429 # fix:
434- sbml_model . createSpecies (). setId ( 's1' )
435- lint .check_condition_df (condition_df , sbml_model )
430+ ss_model . addSpecies ( "[s1]" , 1.0 )
431+ lint .check_condition_df (condition_df , ss_model . model )
436432
437433 # compartment missing in model
438- condition_df ['c1 ' ] = [4.0 ]
434+ condition_df ['c2 ' ] = [4.0 ]
439435 with pytest .raises (AssertionError ):
440- lint .check_condition_df (condition_df , sbml_model )
436+ lint .check_condition_df (condition_df , ss_model . model )
441437
442438 # fix:
443- sbml_model . createCompartment (). setId ( 'c1' )
444- lint .check_condition_df (condition_df , sbml_model )
439+ ss_model . addCompartment ( comp_id = 'c2' , vol = 1.0 )
440+ lint .check_condition_df (condition_df , ss_model . model )
445441
446442
447443def test_check_ids ():
0 commit comments