Skip to content

Commit 68c21de

Browse files
committed
update tests - use new dict based input for setInput() method
1 parent 4331b75 commit 68c21de

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

tests/test_ModelicaSystem.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def test_simulate_inputs(tmp_path):
357357
assert np.isclose(y[-1], 0.0)
358358

359359
# integrate a constant
360-
mod.setInputs("u1=2.5")
360+
mod.setInputs(name={"u1": 2.5})
361361
assert mod.getInputs() == {
362362
"u1": [
363363
(0.0, 2.5),
@@ -370,7 +370,7 @@ def test_simulate_inputs(tmp_path):
370370
assert np.isclose(y[-1], 2.5)
371371

372372
# now let's integrate the sum of two ramps
373-
mod.setInputs("u1=[(0.0, 0.0), (0.5, 2), (1.0, 0)]")
373+
mod.setInputs(name={"u1": [(0.0, 0.0), (0.5, 2), (1.0, 0)]})
374374
assert mod.getInputs("u1") == [[
375375
(0.0, 0.0),
376376
(0.5, 2.0),
@@ -383,19 +383,17 @@ def test_simulate_inputs(tmp_path):
383383
# let's try some edge cases
384384
# unmatched startTime
385385
with pytest.raises(OMPython.ModelicaSystemError):
386-
mod.setInputs("u1=[(-0.5, 0.0), (1.0, 1)]")
386+
mod.setInputs(name={"u1": [(-0.5, 0.0), (1.0, 1)]})
387387
mod.simulate()
388388
# unmatched stopTime
389389
with pytest.raises(OMPython.ModelicaSystemError):
390-
mod.setInputs("u1=[(0.0, 0.0), (0.5, 1)]")
390+
mod.setInputs(name={"u1": [(0.0, 0.0), (0.5, 1)]})
391391
mod.simulate()
392392

393393
# Let's use both inputs, but each one with different number of of
394394
# samples. This has an effect when generating the csv file.
395-
mod.setInputs([
396-
"u1=[(0.0, 0), (1.0, 1)]",
397-
"u2=[(0.0, 0), (0.25, 0.5), (0.5, 1.0), (1.0, 0)]",
398-
])
395+
mod.setInputs(name={"u1": [(0.0, 0), (1.0, 1)],
396+
"u2": [(0.0, 0), (0.25, 0.5), (0.5, 1.0), (1.0, 0)]})
399397
mod.simulate()
400398
assert pathlib.Path(mod.csvFile).read_text() == """time,u1,u2,end
401399
0.0,0.0,0.0,0

0 commit comments

Comments
 (0)