Skip to content

Commit

Permalink
fixing numpy 2 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskoenig committed Jan 31, 2025
1 parent 7626e33 commit 9c4cb1d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions misc/xpp/xpp_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,9 @@ def simulate(sbml_file):
traceback.print_exc(file=sys.stdout)
print()
success = False
valid = np.NaN
simulates = np.NaN
Nall, Nerr, Nwarn = np.NaN, np.NaN, np.NaN
valid = np.nan
simulates = np.nan
Nall, Nerr, Nwarn = np.nan, np.nan, np.nan

Nfail += 1
results.append([xpp_file, success, valid, simulates, Nall, Nerr, Nwarn])
Expand Down
6 changes: 3 additions & 3 deletions src/sbmlutils/examples/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
+ templates.terms_of_use,
creators=templates.creators,
compartments=[
Compartment(sid="c", name="cytosol", value=np.NaN),
Compartment(sid="c", name="cytosol", value=np.nan),
],
species=[
Species(
Expand Down Expand Up @@ -102,10 +102,10 @@
sid="v4",
equation=ReactionEquation(
reactants=[
EquationPart(species="x", stoichiometry=np.NaN, sid="v4_x"),
EquationPart(species="x", stoichiometry=np.nan, sid="v4_x"),
],
products=[
EquationPart(species="y", stoichiometry=np.NaN, sid="v4_y"),
EquationPart(species="y", stoichiometry=np.nan, sid="v4_y"),
],
reversible=False,
),
Expand Down
6 changes: 3 additions & 3 deletions src/sbmlutils/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
import libsbml
import numpy as np
import xmltodict # type: ignore
from numpy import NaN
from numpy import nan as NaN
from pint import UndefinedUnitError, UnitRegistry
from pydantic import BaseModel, ConfigDict
from pymetadata.core.creator import Creator
Expand Down Expand Up @@ -1088,7 +1088,7 @@ def create_sbml(self, model: libsbml.Model) -> libsbml.Parameter:
obj: libsbml.Parameter = model.createParameter()
self._set_fields(obj, model)
if self.value is None:
obj.setValue(np.NaN)
obj.setValue(np.nan)

elif type(self.value) is str:
try:
Expand Down Expand Up @@ -1160,7 +1160,7 @@ def create_sbml(self, model: libsbml.Model) -> libsbml.Compartment:
self._set_fields(obj, model)

if self.value is None:
obj.setSize(np.NaN)
obj.setSize(np.nan)
elif type(self.value) is str:
try:
# check if number
Expand Down
2 changes: 1 addition & 1 deletion src/sbmlutils/resources/converters/odefac_template.pytemp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ x0 = np.array([
# -------------------
p = np.array([
{% for id in pids %}
{{ 'np.NaN' if p.get(id)|string == 'nan' else p[id] }}, # [{{ loop.index0 }}] {{ id }} [{{units[id]}}] {{names[id]}}
{{ 'np.nan' if p.get(id)|string == 'nan' else p[id] }}, # [{{ loop.index0 }}] {{ id }} [{{units[id]}}] {{names[id]}}
{% endfor %}
])

Expand Down
4 changes: 2 additions & 2 deletions tests/test_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
{"compartments": 1, "parameters": 0, "initial_assignments": 0, "rules": 0},
),
(
np.NaN,
np.nan,
True,
{"compartments": 1, "parameters": 0, "initial_assignments": 0, "rules": 0},
),
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_compartment_value(
parameter_value_data = [
(1.0, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
(1, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
(np.NaN, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
(np.nan, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
("1.0", True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
("1", True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
("NaN", True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
Expand Down

0 comments on commit 9c4cb1d

Please sign in to comment.