@@ -134,6 +134,93 @@ def test_exec_sed_task(self):
134134 numpy .full ((task .simulation .number_of_points + 1 ,), 1. )
135135 )
136136
137+ def test_exec_sed_task_positive_initial_time (self ):
138+ task = sedml_data_model .Task (
139+ model = sedml_data_model .Model (
140+ source = os .path .join (os .path .dirname (__file__ ), 'fixtures' , 'BIOMD0000000297.edited' , 'ex1' , 'BIOMD0000000297.xml' ),
141+ language = sedml_data_model .ModelLanguage .SBML .value ,
142+ changes = [],
143+ ),
144+ simulation = sedml_data_model .UniformTimeCourseSimulation (
145+ algorithm = sedml_data_model .Algorithm (
146+ kisao_id = 'KISAO_0000088' ,
147+ ),
148+ initial_time = 10. ,
149+ output_start_time = 10. ,
150+ output_end_time = 30. ,
151+ number_of_points = 20 ,
152+ ),
153+ )
154+
155+ variables = [
156+ sedml_data_model .Variable (
157+ id = 'time' ,
158+ symbol = sedml_data_model .Symbol .time ,
159+ task = task ,
160+ ),
161+ sedml_data_model .Variable (
162+ id = 'BE' ,
163+ target = "/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='BE']" ,
164+ target_namespaces = self .NAMESPACES ,
165+ task = task ,
166+ ),
167+ ]
168+
169+ variable_results , _ = core .exec_sed_task (task , variables , TaskLog ())
170+
171+ self .assertTrue (sorted (variable_results .keys ()), sorted ([var .id for var in variables ]))
172+ self .assertEqual (variable_results [variables [0 ].id ].shape , (task .simulation .number_of_points + 1 ,))
173+ numpy .testing .assert_almost_equal (
174+ variable_results ['time' ],
175+ numpy .linspace (task .simulation .output_start_time , task .simulation .output_end_time , task .simulation .number_of_points + 1 ),
176+ )
177+ for variable in variables :
178+ self .assertFalse (numpy .any (numpy .isnan (variable_results [variable .id ])))
179+
180+ @unittest .expectedFailure
181+ def test_exec_sed_task_negative_initial_time (self ):
182+ task = sedml_data_model .Task (
183+ model = sedml_data_model .Model (
184+ source = os .path .join (os .path .dirname (__file__ ), 'fixtures' , 'BIOMD0000000297.edited' , 'ex1' , 'BIOMD0000000297.xml' ),
185+ language = sedml_data_model .ModelLanguage .SBML .value ,
186+ changes = [],
187+ ),
188+ simulation = sedml_data_model .UniformTimeCourseSimulation (
189+ algorithm = sedml_data_model .Algorithm (
190+ kisao_id = 'KISAO_0000088' ,
191+ ),
192+ initial_time = - 10. ,
193+ output_start_time = - 10. ,
194+ output_end_time = 10. ,
195+ number_of_points = 20 ,
196+ ),
197+ )
198+
199+ variables = [
200+ sedml_data_model .Variable (
201+ id = 'time' ,
202+ symbol = sedml_data_model .Symbol .time ,
203+ task = task ,
204+ ),
205+ sedml_data_model .Variable (
206+ id = 'BE' ,
207+ target = "/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id='BE']" ,
208+ target_namespaces = self .NAMESPACES ,
209+ task = task ,
210+ ),
211+ ]
212+
213+ variable_results , _ = core .exec_sed_task (task , variables , TaskLog ())
214+
215+ self .assertTrue (sorted (variable_results .keys ()), sorted ([var .id for var in variables ]))
216+ self .assertEqual (variable_results [variables [0 ].id ].shape , (task .simulation .number_of_points + 1 ,))
217+ numpy .testing .assert_almost_equal (
218+ variable_results ['time' ],
219+ numpy .linspace (task .simulation .output_start_time , task .simulation .output_end_time , task .simulation .number_of_points + 1 ),
220+ )
221+ for variable in variables :
222+ self .assertFalse (numpy .any (numpy .isnan (variable_results [variable .id ])))
223+
137224 def test_exec_sed_task_errors (self ):
138225 with mock .patch .dict ('os.environ' , {'ALGORITHM_SUBSTITUTION_POLICY' : 'NONE' }):
139226 task = sedml_data_model .Task ()
@@ -150,7 +237,7 @@ def test_exec_sed_task_errors(self):
150237 task .simulation = sedml_data_model .UniformTimeCourseSimulation (
151238 id = 'simulation' ,
152239 algorithm = sedml_data_model .Algorithm (kisao_id = 'KISAO_0000448' ),
153- initial_time = 10. ,
240+ initial_time = - 10. ,
154241 output_start_time = 10. ,
155242 output_end_time = 20.1 ,
156243 number_of_points = 10 ,
@@ -178,7 +265,7 @@ def test_exec_sed_task_errors(self):
178265 core .exec_sed_task (task , variables , TaskLog ())
179266 task .simulation .algorithm .changes [0 ].new_value = '10'
180267
181- with self .assertRaisesRegex (NotImplementedError , 'is not supported. Initial time must be 0' ):
268+ with self .assertRaisesRegex (NotImplementedError , 'is not supported. Initial time must be >= 0' ):
182269 core .exec_sed_task (task , variables , TaskLog ())
183270 task .simulation .initial_time = 0.
184271
0 commit comments