Skip to content

Commit fde0bf6

Browse files
authored
Release 0.1.22
Merge pull request #94 from PEtab-dev/release/0.1.22
2 parents 0a2de3b + 47e7fb6 commit fde0bf6

28 files changed

+398
-296
lines changed

.github/workflows/ci_tests.yml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
name: CI
22

3-
# trigger
4-
on: [push, workflow_dispatch]
3+
on:
4+
push:
5+
workflow_dispatch:
6+
schedule:
7+
- cron: '48 4 * * *'
58

69
jobs:
710
build:
8-
runs-on: ubuntu-latest
911
strategy:
1012
matrix:
11-
python-version: [3.7, 3.8, 3.9]
13+
platform: [windows-latest, macos-latest, ubuntu-latest]
14+
python-version: [3.7, 3.8, 3.9, "3.10"]
15+
runs-on: ${{ matrix.platform }}
1216

1317
steps:
1418
- name: Check out repository
@@ -33,13 +37,18 @@ jobs:
3337
pip install -r .ci_pip_reqs.txt
3438
pip install -e .[reports,combine]
3539
40+
- name: Run flake8
41+
run: |
42+
python -m flake8 --exclude=build,doc,example,tmp --extend-ignore=F403,F405
43+
if: matrix.platform == 'ubuntu-latest'
44+
3645
- name: Run tests
3746
run: |
3847
pytest --cov --cov-report=xml tests
39-
python -m flake8 --exclude=build,doc,example,tmp --extend-ignore=F403,F405
4048
4149
- name: Coverage
4250
uses: codecov/codecov-action@v1
4351
with:
4452
token: ${{ secrets.CODECOV_TOKEN }}
4553
file: ./coverage.xml
54+
if: matrix.platform == 'ubuntu-latest'

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22

33
## 0.1 series
44

5+
### 0.1.22
6+
7+
* Allow zero bounds for log parameters by @FFroehlich in
8+
https://github.com/PEtab-dev/libpetab-python/pull/83
9+
* Adapt to Matplotlib 3.5 by @dweindl in
10+
https://github.com/PEtab-dev/libpetab-python/pull/86
11+
* Allow specifying file format for visualization by @dweindl in
12+
https://github.com/PEtab-dev/libpetab-python/pull/85
13+
* Visualization: Don't mess with rcParams by @dweindl in
14+
https://github.com/PEtab-dev/libpetab-python/pull/90
15+
* Linter: Check condition IDs are unique by @dweindl in
16+
https://github.com/PEtab-dev/libpetab-python/pull/92
17+
* Add support for `pathlib` for reading PEtab tables by @dweindl, @dilpath
18+
in https://github.com/PEtab-dev/libpetab-python/pull/93,
19+
https://github.com/PEtab-dev/libpetab-python/pull/91
20+
* Run tests also on Python 3.10 by @dweindl in
21+
https://github.com/PEtab-dev/libpetab-python/pull/88
22+
* Fix remote file retrieval on Windows @dweindl, @dilpath
23+
in https://github.com/PEtab-dev/libpetab-python/pull/91
24+
* Fix test suite for Windows @dweindl, @dilpath
25+
in https://github.com/PEtab-dev/libpetab-python/pull/91
26+
27+
**Full Changelog**:
28+
https://github.com/PEtab-dev/libpetab-python/compare/v0.1.21...v0.1.22
29+
530
### 0.1.21
631

732
* PEtab spec compliance: measurements must now be not null, and numeric (#76)

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
[![CI](https://github.com/PEtab-dev/libpetab-python/actions/workflows/ci_tests.yml/badge.svg?branch=master)](https://github.com/PEtab-dev/libpetab-python/actions/workflows/ci_tests.yml)
2-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/fd7dd5cee68e449983be5c43f230c7f3)](https://www.codacy.com/gh/PEtab-dev/libpetab-python)
32
[![codecov](https://codecov.io/gh/PEtab-dev/libpetab-python/branch/master/graph/badge.svg)](https://codecov.io/gh/PEtab-dev/libpetab-python)
43
[![PyPI version](https://badge.fury.io/py/petab.svg)](https://badge.fury.io/py/petab)
54

petab/conditions.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
"""Functions operating on the PEtab condition table"""
22

3-
from typing import Iterable, Optional, List, Union
3+
from pathlib import Path
4+
from typing import Iterable, List, Optional, Union
45

56
import numpy as np
67
import pandas as pd
78

8-
from . import lint, core
9+
from . import core, lint
910
from .C import *
1011

1112
__all__ = ['get_condition_df', 'write_condition_df', 'create_condition_df',
1213
'get_parametric_overrides']
1314

1415

1516
def get_condition_df(
16-
condition_file: Union[str, pd.DataFrame, None]
17+
condition_file: Union[str, pd.DataFrame, Path, None]
1718
) -> pd.DataFrame:
1819
"""Read the provided condition file into a ``pandas.Dataframe``
1920
@@ -25,7 +26,7 @@ def get_condition_df(
2526
if condition_file is None:
2627
return condition_file
2728

28-
if isinstance(condition_file, str):
29+
if isinstance(condition_file, (str, Path)):
2930
condition_file = pd.read_csv(condition_file, sep='\t',
3031
float_precision='round_trip')
3132

@@ -44,7 +45,7 @@ def get_condition_df(
4445
return condition_file
4546

4647

47-
def write_condition_df(df: pd.DataFrame, filename: str) -> None:
48+
def write_condition_df(df: pd.DataFrame, filename: Union[str, Path]) -> None:
4849
"""Write PEtab condition table
4950
5051
Arguments:

petab/core.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""PEtab core functions (or functions that don't fit anywhere else)"""
2-
2+
from pathlib import Path
33
import logging
44
import os
55
import re
@@ -43,7 +43,7 @@ def write_simulation_df(df: pd.DataFrame, filename: str) -> None:
4343
df.to_csv(filename, sep='\t', index=False)
4444

4545

46-
def get_visualization_df(visualization_file: str) -> pd.DataFrame:
46+
def get_visualization_df(visualization_file: Union[str, Path]) -> pd.DataFrame:
4747
"""Read PEtab visualization table
4848
4949
Arguments:
@@ -62,7 +62,9 @@ def get_visualization_df(visualization_file: str) -> pd.DataFrame:
6262
return vis_spec
6363

6464

65-
def write_visualization_df(df: pd.DataFrame, filename: str) -> None:
65+
def write_visualization_df(
66+
df: pd.DataFrame, filename: Union[str, Path]
67+
) -> None:
6668
"""Write PEtab visualization table
6769
6870
Arguments:
@@ -177,7 +179,8 @@ def flatten_timepoint_specific_output_overrides(
177179

178180

179181
def concat_tables(
180-
tables: Union[str, pd.DataFrame, Iterable[Union[pd.DataFrame, str]]],
182+
tables: Union[str, Path, pd.DataFrame,
183+
Iterable[Union[pd.DataFrame, str, Path]]],
181184
file_parser: Optional[Callable] = None
182185
) -> pd.DataFrame:
183186
"""Concatenate DataFrames provided as DataFrames or filenames, and a parser
@@ -196,14 +199,14 @@ def concat_tables(
196199
if isinstance(tables, pd.DataFrame):
197200
return tables
198201

199-
if isinstance(tables, str):
202+
if isinstance(tables, (str, Path)):
200203
return file_parser(tables)
201204

202205
df = pd.DataFrame()
203206

204207
for tmp_df in tables:
205208
# load from file, if necessary
206-
if isinstance(tmp_df, str):
209+
if isinstance(tmp_df, (str, Path)):
207210
tmp_df = file_parser(tmp_df)
208211

209212
df = df.append(tmp_df, sort=False,
@@ -241,14 +244,14 @@ def is_empty(val) -> bool:
241244

242245

243246
def create_combine_archive(
244-
yaml_file: str,
245-
filename: str,
247+
yaml_file: Union[str, Path],
248+
filename: Union[str, Path],
246249
family_name: Optional[str] = None,
247250
given_name: Optional[str] = None,
248251
email: Optional[str] = None,
249252
organization: Optional[str] = None,
250253
) -> None:
251-
"""Create COMBINE archive (http://co.mbine.org/documents/archive) based
254+
"""Create COMBINE archive (https://co.mbine.org/documents/archive) based
252255
on PEtab YAML file.
253256
254257
Arguments:
@@ -260,7 +263,7 @@ def create_combine_archive(
260263
organization: Organization of archive creator
261264
"""
262265

263-
path_prefix = os.path.dirname(yaml_file)
266+
path_prefix = os.path.dirname(str(yaml_file))
264267
yaml_config = yaml.load_yaml(yaml_file)
265268

266269
# function-level import, because module-level import interfered with
@@ -285,7 +288,7 @@ def _add_file_metadata(location: str, description: str = ""):
285288

286289
# Add PEtab files and metadata
287290
archive.addFile(
288-
yaml_file,
291+
str(yaml_file),
289292
os.path.basename(yaml_file),
290293
libcombine.KnownFormats.lookupFormat("yaml"),
291294
True
@@ -353,7 +356,7 @@ def _add_file_metadata(location: str, description: str = ""):
353356
description.addCreator(creator)
354357

355358
archive.addMetadata(".", description)
356-
archive.writeToFile(filename)
359+
archive.writeToFile(str(filename))
357360

358361

359362
def unique_preserve_order(seq: Sequence) -> List:

petab/lint.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ def check_condition_df(
108108

109109
check_ids(df.index.values, kind='condition')
110110

111+
if not df.index.is_unique:
112+
raise AssertionError("Non-unique condition IDs: "
113+
f"{df.index.values[df.index.duplicated()]}")
114+
111115
for column_name in req_cols:
112116
if not np.issubdtype(df[column_name].dtype, np.number):
113117
assert_no_leading_trailing_whitespace(
@@ -466,7 +470,7 @@ def check_parameter_bounds(parameter_df: pd.DataFrame) -> None:
466470
raise AssertionError(
467471
f"{LOWER_BOUND} greater than {UPPER_BOUND} for "
468472
f"{PARAMETER_ID} {row.name}.")
469-
if (row[LOWER_BOUND] <= 0.0 or row[UPPER_BOUND] < 0.0) \
473+
if (row[LOWER_BOUND] < 0.0 or row[UPPER_BOUND] < 0.0) \
470474
and row[PARAMETER_SCALE] in [LOG, LOG10]:
471475
raise AssertionError(
472476
f"Bounds for {row[PARAMETER_SCALE]} scaled parameter "

petab/measurements.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
"""Functions operating on the PEtab measurement table"""
22
# noqa: F405
33

4-
54
import itertools
65
import numbers
7-
from typing import List, Union, Dict
6+
from pathlib import Path
7+
from typing import Dict, List, Union
88
from warnings import warn
99

1010
import numpy as np
1111
import pandas as pd
1212

13-
from . import (lint, core, observables)
13+
from . import (core, lint, observables)
1414
from .C import * # noqa: F403
1515

1616
__all__ = ['assert_overrides_match_parameter_count',
@@ -26,7 +26,7 @@
2626

2727

2828
def get_measurement_df(
29-
measurement_file: Union[None, str, pd.DataFrame]
29+
measurement_file: Union[None, str, Path, pd.DataFrame]
3030
) -> pd.DataFrame:
3131
"""
3232
Read the provided measurement file into a ``pandas.Dataframe``.
@@ -40,7 +40,7 @@ def get_measurement_df(
4040
if measurement_file is None:
4141
return measurement_file
4242

43-
if isinstance(measurement_file, str):
43+
if isinstance(measurement_file, (str, Path)):
4444
measurement_file = pd.read_csv(measurement_file, sep='\t',
4545
float_precision='round_trip')
4646

@@ -50,7 +50,7 @@ def get_measurement_df(
5050
return measurement_file
5151

5252

53-
def write_measurement_df(df: pd.DataFrame, filename: str) -> None:
53+
def write_measurement_df(df: pd.DataFrame, filename: Union[str, Path]) -> None:
5454
"""Write PEtab measurement table
5555
5656
Arguments:

petab/observables.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""Functions for working with the PEtab observables table"""
22

3+
import re
34
from collections import OrderedDict
4-
from typing import Union, List
5+
from pathlib import Path
6+
from typing import List, Union
57

68
import libsbml
79
import pandas as pd
8-
import re
910
import sympy as sp
1011

11-
from . import lint, core
12+
from . import core, lint
1213
from .C import * # noqa: F403
1314

1415
__all__ = ['create_observable_df',
@@ -20,7 +21,7 @@
2021

2122

2223
def get_observable_df(
23-
observable_file: Union[str, pd.DataFrame, None]
24+
observable_file: Union[str, pd.DataFrame, Path, None]
2425
) -> pd.DataFrame:
2526
"""
2627
Read the provided observable file into a ``pandas.Dataframe``.
@@ -34,7 +35,7 @@ def get_observable_df(
3435
if observable_file is None:
3536
return observable_file
3637

37-
if isinstance(observable_file, str):
38+
if isinstance(observable_file, (str, Path)):
3839
observable_file = pd.read_csv(observable_file, sep='\t',
3940
float_precision='round_trip')
4041

@@ -53,7 +54,7 @@ def get_observable_df(
5354
return observable_file
5455

5556

56-
def write_observable_df(df: pd.DataFrame, filename: str) -> None:
57+
def write_observable_df(df: pd.DataFrame, filename: Union[str, Path]) -> None:
5758
"""Write PEtab observable table
5859
5960
Arguments:

petab/parameters.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
"""Functions operating on the PEtab parameter table"""
22

33
import numbers
4-
import pandas as pd
5-
import numpy as np
64
from collections import OrderedDict
7-
from typing import Iterable, Set, List, Tuple, Dict, Union
5+
from pathlib import Path
6+
from typing import Dict, Iterable, List, Set, Tuple, Union
87

98
import libsbml
9+
import numpy as np
10+
import pandas as pd
1011

11-
from . import lint, core, measurements, conditions, observables
12+
from . import conditions, core, lint, measurements, observables
1213
from .C import * # noqa: F403
1314

1415
__all__ = ['create_parameter_df',
@@ -27,7 +28,7 @@
2728

2829

2930
def get_parameter_df(
30-
parameter_file: Union[str, List[str], pd.DataFrame, None]
31+
parameter_file: Union[str, Path, List[str], pd.DataFrame, None]
3132
) -> pd.DataFrame:
3233
"""
3334
Read the provided parameter file into a ``pandas.Dataframe``.
@@ -46,7 +47,7 @@ def get_parameter_df(
4647
if isinstance(parameter_file, pd.DataFrame):
4748
parameter_df = parameter_file
4849

49-
if isinstance(parameter_file, str):
50+
if isinstance(parameter_file, (str, Path)):
5051
parameter_df = pd.read_csv(parameter_file, sep='\t',
5152
float_precision='round_trip')
5253

@@ -82,7 +83,7 @@ def get_parameter_df(
8283
return parameter_df
8384

8485

85-
def write_parameter_df(df: pd.DataFrame, filename: str) -> None:
86+
def write_parameter_df(df: pd.DataFrame, filename: Union[str, Path]) -> None:
8687
"""Write PEtab parameter table
8788
8889
Arguments:

0 commit comments

Comments
 (0)