Commit 13239c5c authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 0.13.4

parent 30413e7b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -34,6 +34,9 @@ matrix:
    - os: linux
      python: 3.6
      env: TOXENV=py36
    - os: linux
      python: 3.7-dev
      env: TOXENV=py37
    - os: linux
      python: 3.5
      env: TOXENV=sbml
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ from cobra.core import (
    DictList, Gene, Metabolite, Model, Object, Reaction, Species)
from cobra.util import show_versions

__version__ = "0.13.3"
__version__ = "0.13.4"

# set the warning format to be prettier and fit on one line
_cobra_path = _dirname(_abspath(__file__))
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ except ImportError:


# precompiled regular expressions
_bracket_re = re.compile("r\[[a-z]\]$")
_bracket_re = re.compile(r"\[[a-z]\]$")
_underscore_re = re.compile(r"_[a-z]$")


+25 −9
Original line number Diff line number Diff line
@@ -5,11 +5,26 @@ from __future__ import absolute_import
import io

from six import string_types
from ruamel import yaml
from ruamel.yaml import YAML
from ruamel.yaml.compat import StringIO

from cobra.io.dict import model_to_dict, model_from_dict

YAML_SPEC = "1"
YAML_SPEC = "1.2"


class MyYAML(YAML):
    def dump(self, data, stream=None, **kwargs):
        inefficient = False
        if stream is None:
            inefficient = True
            stream = StringIO()
        YAML.dump(self, data, stream, **kwargs)
        if inefficient:
            return stream.getvalue()


yaml = MyYAML(typ="rt")


def to_yaml(model, sort=False, **kwargs):
@@ -36,9 +51,10 @@ def to_yaml(model, sort=False, **kwargs):
    save_yaml_model : Write directly to a file.
    ruamel.yaml.dump : Base function.
    """

    obj = model_to_dict(model, sort=sort)
    obj["version"] = YAML_SPEC
    return yaml.dump(obj, Dumper=yaml.RoundTripDumper, **kwargs)
    return yaml.dump(obj, **kwargs)


def from_yaml(document):
@@ -59,7 +75,8 @@ def from_yaml(document):
    --------
    load_yaml_model : Load directly from a file.
    """
    return model_from_dict(yaml.load(document, yaml.RoundTripLoader))
    content = StringIO(document)
    return model_from_dict(yaml.load(content))


def save_yaml_model(model, filename, sort=False, **kwargs):
@@ -88,9 +105,9 @@ def save_yaml_model(model, filename, sort=False, **kwargs):
    obj["version"] = YAML_SPEC
    if isinstance(filename, string_types):
        with io.open(filename, "w") as file_handle:
            yaml.dump(obj, file_handle, Dumper=yaml.RoundTripDumper, **kwargs)
            yaml.dump(obj, file_handle, **kwargs)
    else:
        yaml.dump(obj, filename, Dumper=yaml.RoundTripDumper, **kwargs)
        yaml.dump(obj, filename, **kwargs)


def load_yaml_model(filename):
@@ -114,7 +131,6 @@ def load_yaml_model(filename):
    """
    if isinstance(filename, string_types):
        with io.open(filename, "r") as file_handle:
            return model_from_dict(yaml.load(file_handle,
                                             yaml.RoundTripLoader))
            return model_from_dict(yaml.load(file_handle))
    else:
        return model_from_dict(yaml.load(filename, yaml.RoundTripLoader))
        return model_from_dict(yaml.load(filename))

cobra/test/test_flux_analysis.py

deleted100644 → 0
+0 −1219

File deleted.

Preview size limit exceeded, changes collapsed.

Loading