Skip to content

Commit

Permalink
Merge branch 'develop' into feature_1269_split_exprs
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl committed Feb 26, 2024
2 parents ce9f48b + 16ec8b2 commit 44068d8
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 139 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/deploy_protected.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,25 @@ on:
workflow_dispatch:

jobs:
check-secret:
runs-on: ubuntu-latest
outputs:
secrets-defined: ${{ steps.secret-check.outputs.defined }}
steps:
- name: Check for Secret availability
id: secret-check
shell: bash
run: |
if [ "${{ secrets.DOCKER_USERNAME }}" != '' ]; then
echo "defined=true" >> $GITHUB_OUTPUT;
else
echo "defined=false" >> $GITHUB_OUTPUT;
fi
dockerhub:
name: Deploy Dockerhub
if: github.event.pull_request.head.repo.fork == false
needs: [check-secret]
if: needs.check-secret.outputs.secrets-defined == 'true'
runs-on: ubuntu-22.04

strategy:
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

## v0.X Series

### v0.22.0 (2024-02-23)

**Features**

* PEtab import: User option to fail if model needs to be compiled
by @dilpath in https://github.com/AMICI-dev/AMICI/pull/2289

The `force_compile` argument is now **deprecated**. Use `compile_` instead.

* Model import now adds a `.gitignore` file to the model output directory
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2301

**Fixes**

* **Fixed a bug that may have caused wrong simulation results for certain**
**SBML models that contain `rateOf`-expressions**
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2291
* More informative error message for `ReturnDataView.by_id`
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2295
* Fixed `ENABLE_AMICI_DEBUGGING=TRUE` not working with MSVC
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2296
* Fixed MANIFEST.in warning by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2297
* (performance) Skip unnecessary toposorting in `DEModel._collect_heaviside_roots`
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2299
* (performance) Fix redundant calls to `Model::fdwdx` from `Model_ODE::fJ`
(only relevant for dense and banded solvers)
by @dweindl in https://github.com/AMICI-dev/AMICI/pull/2298

**Full Changelog**: https://github.com/AMICI-dev/AMICI/compare/v0.21.2...v0.22.0

### v0.21.2 (2024-02-06)

* Fixed `Solver` copyctor issues with swig4.2 that resulted in installation
Expand Down
165 changes: 81 additions & 84 deletions python/sdist/amici/cxxcodeprinter.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,90 +221,6 @@ def format_line(symbol: sp.Symbol):
if math not in [0, 0.0]
]

def csc_matrix(
self,
matrix: sp.Matrix,
rownames: list[sp.Symbol],
colnames: list[sp.Symbol],
identifier: Optional[int] = 0,
pattern_only: Optional[bool] = False,
) -> tuple[list[int], list[int], sp.Matrix, list[str], sp.Matrix]:
"""
Generates the sparse symbolic identifiers, symbolic identifiers,
sparse matrix, column pointers and row values for a symbolic
variable
:param matrix:
dense matrix to be sparsified
:param rownames:
ids of the variable of which the derivative is computed (assuming
matrix is the jacobian)
:param colnames:
ids of the variable with respect to which the derivative is computed
(assuming matrix is the jacobian)
:param identifier:
additional identifier that gets appended to symbol names to
ensure their uniqueness in outer loops
:param pattern_only:
flag for computing sparsity pattern without whole matrix
:return:
symbol_col_ptrs, symbol_row_vals, sparse_list, symbol_list,
sparse_matrix
"""
idx = 0

nrows, ncols = matrix.shape

if not pattern_only:
sparse_matrix = sp.zeros(nrows, ncols)
symbol_list = []
sparse_list = []
symbol_col_ptrs = []
symbol_row_vals = []

for col in range(ncols):
symbol_col_ptrs.append(idx)
for row in range(nrows):
if matrix[row, col] == 0:
continue

symbol_row_vals.append(row)
idx += 1
symbol_name = (
f"d{rownames[row].name}" f"_d{colnames[col].name}"
)
if identifier:
symbol_name += f"_{identifier}"
symbol_list.append(symbol_name)
if pattern_only:
continue

sparse_matrix[row, col] = sp.Symbol(symbol_name, real=True)
sparse_list.append(matrix[row, col])

if idx == 0:
symbol_col_ptrs = [] # avoid bad memory access for empty matrices
else:
symbol_col_ptrs.append(idx)

if pattern_only:
sparse_matrix = None
else:
sparse_list = sp.Matrix(sparse_list)

return (
symbol_col_ptrs,
symbol_row_vals,
sparse_list,
symbol_list,
sparse_matrix,
)

@staticmethod
def print_bool(expr) -> str:
"""Print the boolean value of the given expression"""
Expand Down Expand Up @@ -374,3 +290,84 @@ def get_switch_statement(
),
indent0 + "}",
]


def csc_matrix(
matrix: sp.Matrix,
rownames: list[sp.Symbol],
colnames: list[sp.Symbol],
identifier: Optional[int] = 0,
pattern_only: Optional[bool] = False,
) -> tuple[list[int], list[int], sp.Matrix, list[str], sp.Matrix]:
"""
Generates the sparse symbolic identifiers, symbolic identifiers,
sparse matrix, column pointers and row values for a symbolic
variable
:param matrix:
dense matrix to be sparsified
:param rownames:
ids of the variable of which the derivative is computed (assuming
matrix is the jacobian)
:param colnames:
ids of the variable with respect to which the derivative is computed
(assuming matrix is the jacobian)
:param identifier:
additional identifier that gets appended to symbol names to
ensure their uniqueness in outer loops
:param pattern_only:
flag for computing sparsity pattern without whole matrix
:return:
symbol_col_ptrs, symbol_row_vals, sparse_list, symbol_list,
sparse_matrix
"""
idx = 0
nrows, ncols = matrix.shape

if not pattern_only:
sparse_matrix = sp.zeros(nrows, ncols)
symbol_list = []
sparse_list = []
symbol_col_ptrs = []
symbol_row_vals = []

for col in range(ncols):
symbol_col_ptrs.append(idx)
for row in range(nrows):
if matrix[row, col] == 0:
continue

symbol_row_vals.append(row)
idx += 1
symbol_name = f"d{rownames[row].name}" f"_d{colnames[col].name}"
if identifier:
symbol_name += f"_{identifier}"
symbol_list.append(symbol_name)
if pattern_only:
continue

sparse_matrix[row, col] = sp.Symbol(symbol_name, real=True)
sparse_list.append(matrix[row, col])

if idx == 0:
symbol_col_ptrs = [] # avoid bad memory access for empty matrices
else:
symbol_col_ptrs.append(idx)

if pattern_only:
sparse_matrix = None
else:
sparse_list = sp.Matrix(sparse_list)

return (
symbol_col_ptrs,
symbol_row_vals,
sparse_list,
symbol_list,
sparse_matrix,
)
Loading

0 comments on commit 44068d8

Please sign in to comment.