Skip to content

Commit

Permalink
Merge branch 'develop' into fix_919
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Dec 18, 2023
2 parents fb0169b + e213d59 commit ecba04c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-22.04, macos-latest]

runs-on: ${{ matrix.os }}
Expand Down
20 changes: 16 additions & 4 deletions .github/workflows/test_python_ver_matrix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ['3.9', '3.10', '3.11']
python-version: ['3.9', '3.10', '3.11', '3.12']
experimental: [false]

steps:
Expand All @@ -44,15 +44,27 @@ jobs:
- name: Install apt dependencies
uses: ./.github/actions/install-apt-dependencies

# install AMICI
- name: Build BNGL
run: scripts/buildBNGL.sh

- name: Install python package
run: scripts/installAmiciSource.sh

# until https://github.com/dateutil/dateutil >2.8.2 is released https://github.com/dateutil/dateutil/issues/1314
- run: source build/venv/bin/activate && pip3 install git+https://github.com/dateutil/dateutil.git@296d419fe6bf3b22897f8f210735ac9c4e1cb796
if: matrix.python-version == '3.12'

# install pysb before sympy to allow for sympy>=1.12 (https://github.com/pysb/pysb/commit/e83937cb8c74afc9b2fa96595b68464946745f33)
- run: source build/venv/bin/activate && pip3 install git+https://github.com/pysb/pysb

# until sympy>1.12 is released
- run: source build/venv/bin/activate && pip3 install git+https://github.com/sympy/sympy.git@master
if: matrix.python-version == '3.12'

- name: Python tests
run: |
source build/venv/bin/activate \
&& pip3 install git+https://github.com/pysb/pysb \
&& python3 -m pytest --ignore-glob=*petab* \
&& python3 -m pytest \
--durations=10 \
--ignore-glob=*petab* \
--ignore-glob=*test_splines.py ${AMICI_DIR}/python/tests
24 changes: 16 additions & 8 deletions python/sdist/amici/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@ def _setup_logger(
level: Optional[int] = logging.WARNING,
console_output: Optional[bool] = True,
file_output: Optional[bool] = False,
capture_warnings: Optional[bool] = True,
capture_warnings: Optional[bool] = False,
) -> logging.Logger:
"""
Set up a new logging.Logger for AMICI logging
Set up a new :class:`logging.Logger` for AMICI logging.
:param level:
Logging level, typically using a constant like logging.INFO or
logging.DEBUG
Logging level, typically using a constant like :obj:`logging.INFO` or
:obj:`logging.DEBUG`
:param console_output:
Set up a default console log handler if True (default)
Set up a default console log handler if ``True`` (default)
:param file_output:
Supply a filename to copy all log output to that file, or
set to False to disable (default)
set to ``False`` to disable (default)
:param capture_warnings:
Capture warnings from Python's warnings module if True (default)
Capture warnings from Python's warnings module if ``True``
:return:
A :class:`logging.Logger` object for AMICI logging. Note that other
Expand Down Expand Up @@ -81,7 +81,12 @@ def _setup_logger(

log.setLevel(level)

py_warn_logger = logging.getLogger("py.warnings")

# Remove default logging handler
for handler in log.handlers:
if handler in py_warn_logger.handlers:
py_warn_logger.removeHandler(handler)
log.handlers = []

log_fmt = logging.Formatter(
Expand All @@ -105,7 +110,10 @@ def _setup_logger(
log.debug("Python version: %s", platform.python_version())
log.debug("Hostname: %s", socket.getfqdn())

logging.captureWarnings(capture_warnings)
if capture_warnings:
logging.captureWarnings(capture_warnings)
for handler in log.handlers:
py_warn_logger.addHandler(handler)

return log

Expand Down
8 changes: 5 additions & 3 deletions python/sdist/amici/sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2776,15 +2776,17 @@ def replace_logx(math_str: Union[str, float, None]) -> Union[str, float, None]:
return re.sub(r"(^|\W)log(\d+)\(", r"\g<1>1/ln(\2)*ln(", math_str)


def _collect_event_assignment_parameter_targets(sbml_model: sbml.Model):
targets = set()
def _collect_event_assignment_parameter_targets(
sbml_model: sbml.Model,
) -> list[sp.Symbol]:
targets = []
sbml_parameters = sbml_model.getListOfParameters()
sbml_parameter_ids = [p.getId() for p in sbml_parameters]
for event in sbml_model.getListOfEvents():
for event_assignment in event.getListOfEventAssignments():
target_id = event_assignment.getVariable()
if target_id in sbml_parameter_ids:
targets.add(
targets.append(
_get_identifier_symbol(
sbml_parameters[sbml_parameter_ids.index(target_id)]
)
Expand Down

0 comments on commit ecba04c

Please sign in to comment.