Skip to content

Commit

Permalink
Merge pull request #494 from PEtab-dev/develop
Browse files Browse the repository at this point in the history
Release 0.1.13
  • Loading branch information
yannikschaelte authored Jan 2, 2021
2 parents 4d6d917 + 75a1aed commit d948970
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## 0.1 series

### 0.1.13

* Fix for pandas 1.2.0 -- use `get_handle` instead of `get_filepath_or_buffer`
* Fix erroneous `petab_test_suite` symlink (all #493)

### 0.1.12

* Documentation update:
Expand Down
14 changes: 3 additions & 11 deletions petab/sbml.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Functions for interacting with SBML models"""
from warnings import warn
import logging
from pandas.io.common import get_handle, is_url, is_file_like
import re
from typing import Dict, Any, List, Union, Tuple
import libsbml
Expand Down Expand Up @@ -416,19 +417,10 @@ def get_sbml_model(
File or URL or file handle to read the model from
:return: The SBML document, model and reader
"""

from pandas.io.common import get_filepath_or_buffer, is_url, is_file_like

if is_file_like(filepath_or_buffer) or is_url(filepath_or_buffer):
buffer = get_filepath_or_buffer(filepath_or_buffer, mode='r')[0]
if is_url(filepath_or_buffer):
buffer = ''.join(line.decode('utf-8') for line in buffer)
else:
buffer = ''.join(line for line in buffer)

handle = get_handle(filepath_or_buffer, mode='r').handle
# URL or already opened file, we will load the model from a string

return load_sbml_from_string(buffer)
return load_sbml_from_string(''.join(handle))

return load_sbml_from_file(filepath_or_buffer)

Expand Down
2 changes: 1 addition & 1 deletion petab/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""PEtab library version"""
__version__ = '0.1.12'
__version__ = '0.1.13'
11 changes: 3 additions & 8 deletions petab/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import jsonschema
import numpy as np
import yaml
from pandas.io.common import get_filepath_or_buffer
from pandas.io.common import get_handle

from .C import * # noqa: F403

Expand Down Expand Up @@ -123,13 +123,8 @@ def load_yaml(yaml_config: Union[Dict, str]) -> Dict:
if isinstance(yaml_config, dict):
return yaml_config

filepath_or_buffer = get_filepath_or_buffer(yaml_config, mode='r')[0]
if isinstance(filepath_or_buffer, str):
# a filename
with open(filepath_or_buffer, 'r') as f:
return yaml.safe_load(f)
# a stream
return yaml.safe_load(filepath_or_buffer)
handle = get_handle(yaml_config, mode='r').handle
return yaml.safe_load(handle)


def is_composite_problem(yaml_config: Union[Dict, str]) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def absolute_links(txt):
url='https://github.com/PEtab-dev/PEtab',
packages=find_packages(exclude=['doc*', 'test*']),
install_requires=['numpy>=1.15.1',
'pandas>=1.0.1',
'pandas>=1.2.0',
'matplotlib>=2.2.3',
'python-libsbml>=5.17.0',
'sympy',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_petab.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def test_load_remote():
"""Test loading remote files"""

yaml_url = "https://raw.githubusercontent.com/PEtab-dev/petab_test_suite" \
"/master/cases/0001/_0001.yaml"
"/master/petabtests/cases/0001/_0001.yaml"
petab_problem = petab.Problem.from_yaml(yaml_url)

assert petab_problem.sbml_model is not None
Expand Down

0 comments on commit d948970

Please sign in to comment.