From 79c132f78de5aa2f0e44d68f624ae7ac949beedb Mon Sep 17 00:00:00 2001 From: Ruizhi Yu Date: Sun, 12 Jan 2025 15:45:40 +0800 Subject: [PATCH] refactor: let `TimeSeriesParam` return array --- Solverz/equation/param.py | 4 ++-- Solverz/equation/test/test_Param.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Solverz/equation/param.py b/Solverz/equation/param.py index 61d4ec4..5a85ba0 100644 --- a/Solverz/equation/param.py +++ b/Solverz/equation/param.py @@ -140,9 +140,9 @@ def get_v_t(self, t): # input of interp1d is zero-dimensional, we need to reshape # [0] is to eliminate the numpy DeprecationWarning in m3b9 test: Conversion of an array with ndim > 0 to a scalar is # deprecated, and will error in the future, which should be resolved. - vt = self.vt(t).reshape((-1,))[0] + vt = self.vt(t).reshape((-1,)) else: - vt = self.v_series[-1] + vt = self.v_series[-1:] if self.index is not None: temp = self.v.copy() diff --git a/Solverz/equation/test/test_Param.py b/Solverz/equation/test/test_Param.py index 0b70ded..fc390f4 100644 --- a/Solverz/equation/test/test_Param.py +++ b/Solverz/equation/test/test_Param.py @@ -46,7 +46,7 @@ def test_Param(): v_series=[0, 10, 100], time_series=[0, 10, 20], value=0) - assert Pb.get_v_t(5).__str__() == '5.0' + assert Pb.get_v_t(5).__str__() == '[5.]' try: Pb = TimeSeriesParam(name='Pb',