Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f6a7e79
#42 Support no-ODE models via placeholder state variable
kwabenantim Jul 5, 2026
7572e44
Merge branch 'develop' into 42-no-ode-models
kwabenantim Jul 5, 2026
ef44f99
#42 Report renamed SBML ids under their original id + triage no-ODE c…
kwabenantim Jul 5, 2026
c52f53e
#42 Emit n-ary relationals via the sm:: SbmlMath helpers
kwabenantim Jul 5, 2026
af7440b
#42 Convert powers to pow() on the AST; tidy formula_to_string
kwabenantim Jul 5, 2026
9173e6b
#42 Handle SBML symbols and rateOf on the AST in formula_to_string
kwabenantim Jul 5, 2026
67102bb
#42 Precompile shared headers to speed up SbmlRefModels rebuilds
kwabenantim Jul 6, 2026
abe0f40
#42 Handle events/functions with missing MathML instead of crashing
kwabenantim Jul 6, 2026
97a3ba2
#42 Classify event-modified constant species as parameters
kwabenantim Jul 6, 2026
c2e5aa6
#42 Reject flux-balance (fbc package) models with a clear error
kwabenantim Jul 6, 2026
c5e3031
#42 Support the implies operator and single-argument min/max
kwabenantim Jul 6, 2026
a24d29a
#42 Derive variable types from records; use a DerivedQuantity kind enum
kwabenantim Jul 6, 2026
86212a8
#42 Fix xor on doubles, piecewise without otherwise, and map arcsec/a…
kwabenantim Jul 6, 2026
6ef1b09
#42 Rename SBML ids that collide with C++ macros
kwabenantim Jul 6, 2026
764c88a
#42 Rewrite function-call refs when renaming a keyword-clashing function
kwabenantim Jul 6, 2026
7a7c7af
#42 Handle non-finite values in results and MathML constants
kwabenantim Jul 6, 2026
fdd5e88
#42 Initialise the no-ODE placeholder state variable
kwabenantim Jul 6, 2026
1648c5d
Tidy SBML test-suite status notes
kwabenantim Jul 6, 2026
5b7c581
Rebalance SBML test-suite CI matrix into 5 equal batches
kwabenantim Jul 6, 2026
defe36a
#42 Add test cases README
kwabenantim Jul 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/sbml_test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ jobs:

strategy:
fail-fast: false
# matrix is split by number of passing test cases (~230 per batch)
# matrix is split by number of passing test cases (269 per batch)
matrix:
include:
- first_case: "1"
last_case: "245"
- first_case: "246"
last_case: "578"
- first_case: "579"
last_case: "890"
- first_case: "891"
last_case: "1267"
- first_case: "1268"
last_case: "276"
- first_case: "277"
last_case: "678"
- first_case: "679"
last_case: "1030"
- first_case: "1031"
last_case: "1364"
- first_case: "1365"
last_case: "1821"

steps:
Expand Down
8 changes: 8 additions & 0 deletions chaste_sbml/SbmlRefModels/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
find_package(Chaste COMPONENTS cell_based)
chaste_do_project(SbmlRefModels)

# Precompile the heavy header every generated case model includes, to speed up rebuilds. The
# serialization export wrappers are deliberately excluded (they are order-sensitive and belong in
# each .cpp, not a shared PCH).
if (TARGET chaste_project_SbmlRefModels)
target_precompile_headers(chaste_project_SbmlRefModels PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/src/AbstractSbmlOdeSystem.hpp")
endif()
24 changes: 22 additions & 2 deletions chaste_sbml/SbmlRefModels/generate_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from typing import TYPE_CHECKING

from chaste_sbml import ChasteSbmlModel
from chaste_sbml._config import ROOT_DIR, ModelType
from chaste_sbml._config import ModelType
from chaste_sbml._names import generate_header_guard

if TYPE_CHECKING:
Expand All @@ -20,6 +20,24 @@
sbml_versions = ["l2v5", "l3v2", "l3v1"]


def _cpp_double_literal(value: str) -> str:
"""Render a reference-CSV cell as a C++ double literal.

Reference results can be non-finite -- a division by zero gives INF and 0/0 gives NaN -- and
the SBML Test Suite writes these as ``INF``/``-INF``/``NaN``, which are not valid C++ tokens.
Map them to the ``<cmath>`` macros so the expected-results initialiser list compiles; finite
numbers are already valid literals and pass through unchanged.
"""
token = value.strip()
magnitude = token.lstrip("+-").lower()
sign = "-" if token.startswith("-") else ""
if magnitude == "inf":
return f"{sign}INFINITY"
if magnitude == "nan":
return "NAN"
return token


class TestType(Enum):
"""Enumeration of test types for code generation."""

Expand Down Expand Up @@ -50,7 +68,9 @@ def __init__(self, sbml_file: str, sbml_version: str, test_params: dict[str, "An
self._test_hpp_filename = f"Test{self._model_name}.hpp"

test_result_columns = ", ".join(f'"{col}"' for col in test_params["results"][0])
test_result_data = ["{ " + ", ".join(row) + " }" for row in test_params["results"][1:]]
test_result_data = [
"{ " + ", ".join(_cpp_double_literal(cell) for cell in row) + " }" for row in test_params["results"][1:]
]
test_result_data = ",\n".join(test_result_data)

test_amounts = test_params["settings"]["amount"].split(",")
Expand Down
4 changes: 2 additions & 2 deletions chaste_sbml/SbmlRefModels/infra/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ fi

if [[ ! -d "${chaste_dir}" ]]; then
echo "Error: Chaste source directory not found at '${chaste_dir}'." >&2
echo "Set CHASTE_SOURCE_DIR to override the default sibling checkout path." >&2
echo "Set CHASTE_SOURCE_DIR to override the default checkout path." >&2
exit 1
fi

mkdir -p "${output_dir}" "${build_dir}"
export CHASTE_TEST_OUTPUT="${output_dir}"

cd "${build_dir}"
nice -n 9 cmake "${chaste_dir}"
nice -n 9 cmake -DChaste_UPDATE_PROVENANCE=OFF "${chaste_dir}"

22 changes: 19 additions & 3 deletions chaste_sbml/SbmlRefModels/src/SbmlMath.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ constexpr bool or_(Args... args);
// not_
inline bool not_(bool x) { return !x; }

// implies (a implies b == (not a) or b)
inline bool implies(double antecedent, double consequent) { return !antecedent || consequent; }

// xor_
template <typename... Args>
constexpr bool xor_(Args... args);
Expand Down Expand Up @@ -149,17 +152,23 @@ inline double asech(double x) { return std::acosh(1.0 / x); }
// factorial
inline double factorial(double x) { return std::tgamma(x + 1.0); }

// max
// max (the max of a single value is that value)
constexpr double max(double only) { return only; }
template <typename... Args>
constexpr double max(double first, double second, Args... rest);

// min
// min (the min of a single value is that value)
constexpr double min(double only) { return only; }
template <typename... Args>
constexpr double min(double first, double second, Args... rest);

// piecewise
constexpr double piecewise(double otherwise);

// A piecewise with no otherwise clause: undefined (NaN) when the condition does not hold. Also the
// recursion base case for an even number of arguments (pieces without a trailing otherwise).
constexpr double piecewise(double value, bool condition);

constexpr double piecewise(double value, bool condition, double otherwise);

template <typename... Args>
Expand Down Expand Up @@ -206,7 +215,9 @@ constexpr bool sbmlmath::or_(Args... args)
template <typename... Args>
constexpr bool sbmlmath::xor_(Args... args)
{
return (false ^ ... ^ args);
// Cast each operand to bool first: the arguments are numeric booleans (0/non-0), and ^ is
// bitwise (undefined for double), so xor them as bools -- true when an odd number are true.
return (false ^ ... ^ static_cast<bool>(args));
}

// Relational (variadic templates) ==============
Expand Down Expand Up @@ -296,6 +307,11 @@ constexpr double sbmlmath::piecewise(double otherwise)
return otherwise;
}

constexpr double sbmlmath::piecewise(double value, bool condition)
{
return condition ? value : std::numeric_limits<double>::quiet_NaN();
}

constexpr double sbmlmath::piecewise(double value, bool condition, double otherwise)
{
return condition ? value : otherwise;
Expand Down
7 changes: 5 additions & 2 deletions chaste_sbml/SbmlRefModels/src/cases/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# SBML Test Suite Cases

## Semantic

## Stochastic
Case support tracked in test/data/sbml_test_suite_status.csv

## Syntactic
Covered by libSBML

## Stochastic
Not supported
Loading