Skip to content

Commit 9c4cb1d

Browse files
fixing numpy 2 issues
1 parent 7626e33 commit 9c4cb1d

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

misc/xpp/xpp_models.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,9 @@ def simulate(sbml_file):
194194
traceback.print_exc(file=sys.stdout)
195195
print()
196196
success = False
197-
valid = np.NaN
198-
simulates = np.NaN
199-
Nall, Nerr, Nwarn = np.NaN, np.NaN, np.NaN
197+
valid = np.nan
198+
simulates = np.nan
199+
Nall, Nerr, Nwarn = np.nan, np.nan, np.nan
200200

201201
Nfail += 1
202202
results.append([xpp_file, success, valid, simulates, Nall, Nerr, Nwarn])

src/sbmlutils/examples/reaction.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
+ templates.terms_of_use,
2121
creators=templates.creators,
2222
compartments=[
23-
Compartment(sid="c", name="cytosol", value=np.NaN),
23+
Compartment(sid="c", name="cytosol", value=np.nan),
2424
],
2525
species=[
2626
Species(
@@ -102,10 +102,10 @@
102102
sid="v4",
103103
equation=ReactionEquation(
104104
reactants=[
105-
EquationPart(species="x", stoichiometry=np.NaN, sid="v4_x"),
105+
EquationPart(species="x", stoichiometry=np.nan, sid="v4_x"),
106106
],
107107
products=[
108-
EquationPart(species="y", stoichiometry=np.NaN, sid="v4_y"),
108+
EquationPart(species="y", stoichiometry=np.nan, sid="v4_y"),
109109
],
110110
reversible=False,
111111
),

src/sbmlutils/factory.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
import libsbml
4343
import numpy as np
4444
import xmltodict # type: ignore
45-
from numpy import NaN
45+
from numpy import nan as NaN
4646
from pint import UndefinedUnitError, UnitRegistry
4747
from pydantic import BaseModel, ConfigDict
4848
from pymetadata.core.creator import Creator
@@ -1088,7 +1088,7 @@ def create_sbml(self, model: libsbml.Model) -> libsbml.Parameter:
10881088
obj: libsbml.Parameter = model.createParameter()
10891089
self._set_fields(obj, model)
10901090
if self.value is None:
1091-
obj.setValue(np.NaN)
1091+
obj.setValue(np.nan)
10921092

10931093
elif type(self.value) is str:
10941094
try:
@@ -1160,7 +1160,7 @@ def create_sbml(self, model: libsbml.Model) -> libsbml.Compartment:
11601160
self._set_fields(obj, model)
11611161

11621162
if self.value is None:
1163-
obj.setSize(np.NaN)
1163+
obj.setSize(np.nan)
11641164
elif type(self.value) is str:
11651165
try:
11661166
# check if number

src/sbmlutils/resources/converters/odefac_template.pytemp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ x0 = np.array([
4949
# -------------------
5050
p = np.array([
5151
{% for id in pids %}
52-
{{ 'np.NaN' if p.get(id)|string == 'nan' else p[id] }}, # [{{ loop.index0 }}] {{ id }} [{{units[id]}}] {{names[id]}}
52+
{{ 'np.nan' if p.get(id)|string == 'nan' else p[id] }}, # [{{ loop.index0 }}] {{ id }} [{{units[id]}}] {{names[id]}}
5353
{% endfor %}
5454
])
5555

tests/test_factory.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
{"compartments": 1, "parameters": 0, "initial_assignments": 0, "rules": 0},
2626
),
2727
(
28-
np.NaN,
28+
np.nan,
2929
True,
3030
{"compartments": 1, "parameters": 0, "initial_assignments": 0, "rules": 0},
3131
),
@@ -103,7 +103,7 @@ def test_compartment_value(
103103
parameter_value_data = [
104104
(1.0, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
105105
(1, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
106-
(np.NaN, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
106+
(np.nan, True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
107107
("1.0", True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
108108
("1", True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),
109109
("NaN", True, {"parameters": 1, "initial_assignments": 0, "rules": 0}),

0 commit comments

Comments
 (0)