Skip to content

Commit 5ef6251

Browse files
committed
- ensure petabtests can be imported
1 parent fc8347a commit 5ef6251

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

copasi_petab_importer/convert_petab.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,8 +752,9 @@ def add_fit_items(self, parameters):
752752
if obj is not None:
753753
obj.setInitialValue(value)
754754
else:
755-
# check whether this is used in a noiseFormula
756-
if not self.petab.observable_data.noiseFormula.str.contains(name).any():
755+
# check whether this is used in a noiseFormula if type is string
756+
if isinstance(self.petab.observable_data.noiseFormula, str) and \
757+
not self.petab.observable_data.noiseFormula.str.contains(name).any():
757758
# otherwise raise warning since we could not resolve object
758759
logger.warning('could not resolve object {0} for fit item'.format(name))
759760
continue

test/test_importer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import COPASI
44
import sys
55
import os
6+
from pathlib import Path
67
_PATH = os.path.abspath(os.path.dirname(__file__))
78
_BENCHMARK_DIR = os.path.join(_PATH, '..', 'benchmarks',
89
'hackathon_contributions_new_data_format')
@@ -14,6 +15,7 @@
1415
import petabtests
1516
petab_tests_available = True
1617
except ImportError:
18+
print("petabtests not available")
1719
petab_tests_available = False
1820

1921

@@ -63,10 +65,10 @@ def test_import_bachmann(self):
6365

6466
@unittest.skipUnless(petab_tests_available, 'petabtests need to be installed to run this')
6567
def test_petabtest_import(self):
66-
cases = [c for c in glob.glob(str(petabtests.CASES_DIR) + '/*/*.yaml') if '0' in c and 'solution' not in c]
68+
cases = [c for c in glob.glob(str(petabtests.CASES_DIR / Path('v1.0.0/sbml')) + '/*/*.yaml') if '0' in c and 'solution' not in c]
6769
for case in cases:
68-
if '17' not in case:
69-
continue
70+
#if '17' not in case:
71+
# continue
7072
converter = convert_petab.PEtabConverter.from_yaml(case)
7173
converter.convert()
7274

0 commit comments

Comments
 (0)