Skip to content

Commit

Permalink
Merge branch 'develop' into feature_2327_constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
dweindl authored Mar 4, 2024
2 parents e99a50e + e8852be commit a7232d9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
9 changes: 7 additions & 2 deletions python/sdist/amici/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import itertools
from typing import Literal, Union
from collections.abc import Iterator

from numbers import Number
import amici
import numpy as np
import sympy as sp
Expand Down Expand Up @@ -238,6 +238,7 @@ class ReturnDataView(SwigPtrView):
"numnonlinsolvconvfailsB",
"cpu_timeB",
"cpu_time_total",
"messages",
]

def __init__(self, rdata: Union[ReturnDataPtr, ReturnData]):
Expand Down Expand Up @@ -440,7 +441,11 @@ def _field_as_numpy(
attr = getattr(data, field)
if field_dim := field_dimensions.get(field, None):
return None if len(attr) == 0 else np.array(attr).reshape(field_dim)
return float(attr)

if isinstance(attr, Number):
return float(attr)

return attr


def _entity_type_from_id(
Expand Down
1 change: 1 addition & 0 deletions python/sdist/amici/petab/petab_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import shutil
from pathlib import Path
from typing import Union
from warnings import warn

import amici
import petab
Expand Down
2 changes: 1 addition & 1 deletion python/tests/test_sbml_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def test_solver_reuse(model_steadystate_module):
assert rdata1.status == amici.AMICI_SUCCESS

for attr in rdata1:
if "time" in attr:
if "time" in attr or attr == "messages":
continue

val1 = getattr(rdata1, attr)
Expand Down
8 changes: 8 additions & 0 deletions swig/amici.i
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ def __repr__(self):
%}
};

%extend amici::LogItem {
%pythoncode %{
def __repr__(self):
return (f"{self.__class__.__name__}(severity={self.severity}, "
f"identifier={self.identifier!r}, message={self.message!r})")
%}
};


// Convert integer values to enum class
// defeats the purpose of enum class, but didn't find a better way to allow for
Expand Down
2 changes: 1 addition & 1 deletion swig/std_unique_ptr.i
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace std {

pointer operator-> () const;
pointer release ();
void reset (pointer __p=pointer());
void reset (pointer __p=std::unique_ptr<Type>::pointer());
void swap (unique_ptr &__u);
pointer get () const;
operator bool () const;
Expand Down

0 comments on commit a7232d9

Please sign in to comment.