-
Notifications
You must be signed in to change notification settings - Fork 88
/
integration_test_vensim_pathway.py
495 lines (387 loc) · 21.8 KB
/
integration_test_vensim_pathway.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
"""
Note that this file is autogenerated by `integration_test_factory.py`
and changes are likely to be overwritten.
"""
import warnings
import unittest
from pysd.tools.benchmarking import runner, assert_frames_close
rtol = .05
class TestIntegrationExamples(unittest.TestCase):
def test_abs(self):
output, canon = runner('test-models/tests/abs/test_abs.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_active_initial(self):
output, canon = runner('test-models/tests/active_initial/test_active_initial.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_arguments(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner('test-models/tests/arguments/test_arguments.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_builtin_max(self):
output, canon = runner('test-models/tests/builtin_max/builtin_max.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_builtin_min(self):
output, canon = runner('test-models/tests/builtin_min/builtin_min.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_chained_initialization(self):
output, canon = runner('test-models/tests/chained_initialization/test_chained_initialization.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_constant_expressions(self):
output, canon = runner('test-models/tests/constant_expressions/test_constant_expressions.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_delay_fixed(self):
# issue https://github.com/JamesPHoughton/pysd/issues/147
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner('test-models/tests/delay_fixed/test_delay_fixed.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_delay_numeric_error(self):
# issue https://github.com/JamesPHoughton/pysd/issues/225
output, canon = runner('test-models/tests/delay_numeric_error/test_delay_numeric_error.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_delay_parentheses(self):
output, canon = runner('test-models/tests/delay_parentheses/test_delay_parentheses.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_delay_pipeline(self):
# issue https://github.com/JamesPHoughton/pysd/issues/147
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner('test-models/tests/delay_pipeline/test_pipeline_delays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_delays(self):
# issue https://github.com/JamesPHoughton/pysd/issues/147
output, canon = runner('test-models/tests/delays/test_delays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_dynamic_final_time(self):
# issue https://github.com/JamesPHoughton/pysd/issues/278
output, canon = runner('test-models/tests/dynamic_final_time/test_dynamic_final_time.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_euler_step_vs_saveper(self):
output, canon = runner('test-models/tests/euler_step_vs_saveper/test_euler_step_vs_saveper.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_exp(self):
output, canon = runner('test-models/tests/exp/test_exp.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_exponentiation(self):
output, canon = runner('test-models/tests/exponentiation/exponentiation.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_function_capitalization(self):
output, canon = runner('test-models/tests/function_capitalization/test_function_capitalization.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_game(self):
output, canon = runner('test-models/tests/game/test_game.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_get_data_args_3d_xls(self):
"""
Test for usage of GET DIRECT/XLS DATA with arguments from a Excel file
All the possible combinations of lentgh-wise and different dimensions
are tested in unit_test_external.py, this test want to test only the
good working of the builder
"""
output, canon = runner(
'test-models/tests/get_data_args_3d_xls/'
+ 'test_get_data_args_3d_xls.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_get_lookups_data_3d_xls(self):
"""
Test for usage of GET DIRECT/XLS LOOKUPS/DATA from a Excel file
All the possible combinations of lentgh-wise and different dimensions
are tested in unit_test_external.py, this test want to test only the
good working of the builder
"""
output, canon = runner(
'test-models/tests/get_lookups_data_3d_xls/'
+ 'test_get_lookups_data_3d_xls.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_get_lookups_subscripted_args(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner(
'test-models/tests/get_lookups_subscripted_args/'
+ 'test_get_lookups_subscripted_args.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_get_lookups_subset(self):
output, canon = runner(
'test-models/tests/get_lookups_subset/'
+ 'test_get_lookups_subset.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_get_with_missing_values_xlsx(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner(
'test-models/tests/get_with_missing_values_xlsx/'
+ 'test_get_with_missing_values_xlsx.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_get_mixed_definitions(self):
output, canon = runner(
'test-models/tests/get_mixed_definitions/'
+ 'test_get_mixed_definitions.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_get_subscript_3d_arrays_xls(self):
"""
Test for usage of GET DIRECT/XLS SUBSCRIPTS/CONSTANTS from a Excel file
All the possible combinations of lentgh-wise and different dimensions
are tested in unit_test_external.py, this test want to test only the
good working of the builder
"""
output, canon = runner(
'test-models/tests/get_subscript_3d_arrays_xls/'
+ 'test_get_subscript_3d_arrays_xls.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_get_xls_cellrange(self):
output, canon = runner(
'test-models/tests/get_xls_cellrange/'
+ 'test_get_xls_cellrange.mdl'
)
assert_frames_close(output, canon, rtol=rtol)
def test_if_stmt(self):
output, canon = runner('test-models/tests/if_stmt/if_stmt.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_initial_function(self):
output, canon = runner('test-models/tests/initial_function/test_initial.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_input_functions(self):
output, canon = runner('test-models/tests/input_functions/test_inputs.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_limits(self):
output, canon = runner('test-models/tests/limits/test_limits.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_line_breaks(self):
output, canon = runner('test-models/tests/line_breaks/test_line_breaks.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_line_continuation(self):
output, canon = runner('test-models/tests/line_continuation/test_line_continuation.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_ln(self):
output, canon = runner('test-models/tests/ln/test_ln.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_log(self):
output, canon = runner('test-models/tests/log/test_log.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_logicals(self):
output, canon = runner('test-models/tests/logicals/test_logicals.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_lookups(self):
output, canon = runner('test-models/tests/lookups/test_lookups.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_lookups_without_range(self):
output, canon = runner('test-models/tests/lookups_without_range/test_lookups_without_range.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_lookups_funcnames(self):
output, canon = runner('test-models/tests/lookups_funcnames/test_lookups_funcnames.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_lookups_inline(self):
output, canon = runner('test-models/tests/lookups_inline/test_lookups_inline.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_lookups_inline_bounded(self):
output, canon = runner('test-models/tests/lookups_inline_bounded/test_lookups_inline_bounded.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_lookups_with_expr(self):
output, canon = runner('test-models/tests/lookups_with_expr/test_lookups_with_expr.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_macro_cross_reference(self):
output, canon = runner('test-models/tests/macro_cross_reference/test_macro_cross_reference.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_macro_expression(self):
output, canon = runner('test-models/tests/macro_expression/test_macro_expression.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_macro_multi_expression(self):
output, canon = runner('test-models/tests/macro_multi_expression/test_macro_multi_expression.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_macro_multi_macros(self):
output, canon = runner('test-models/tests/macro_multi_macros/test_macro_multi_macros.mdl')
assert_frames_close(output, canon, rtol=rtol)
@unittest.skip('working')
def test_macro_output(self):
output, canon = runner('test-models/tests/macro_output/test_macro_output.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_macro_stock(self):
output, canon = runner('test-models/tests/macro_stock/test_macro_stock.mdl')
assert_frames_close(output, canon, rtol=rtol)
@unittest.skip('do we need this?')
def test_macro_trailing_definition(self):
output, canon = runner('test-models/tests/macro_trailing_definition/test_macro_trailing_definition.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_model_doc(self):
output, canon = runner('test-models/tests/model_doc/model_doc.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_nested_functions(self):
output, canon = runner('test-models/tests/nested_functions/test_nested_functions.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_number_handling(self):
output, canon = runner('test-models/tests/number_handling/test_number_handling.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_parentheses(self):
output, canon = runner('test-models/tests/parentheses/test_parens.mdl')
assert_frames_close(output, canon, rtol=rtol)
@unittest.skip('low priority')
def test_reference_capitalization(self):
"""A properly formatted Vensim model should never create this failure"""
output, canon = runner('test-models/tests/reference_capitalization/test_reference_capitalization.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_repeated_subscript(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner('test-models/tests/repeated_subscript/test_repeated_subscript.mdl')
assert_frames_close(output, canon, rtol=rtol)
@unittest.skip('in branch')
def test_rounding(self):
output, canon = runner('test-models/tests/rounding/test_rounding.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_sample_if_true(self):
output, canon = runner('test-models/tests/sample_if_true/test_sample_if_true.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_smooth(self):
output, canon = runner('test-models/tests/smooth/test_smooth.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_smooth_and_stock(self):
output, canon = runner('test-models/tests/smooth_and_stock/test_smooth_and_stock.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_special_characters(self):
output, canon = runner('test-models/tests/special_characters/test_special_variable_names.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_sqrt(self):
output, canon = runner('test-models/tests/sqrt/test_sqrt.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subrange_merge(self):
output, canon = runner('test-models/tests/subrange_merge/test_subrange_merge.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_multiples(self):
output, canon = runner('test-models/tests/subscript_multiples/test_multiple_subscripts.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_1d_arrays(self):
output, canon = runner('test-models/tests/subscript_1d_arrays/test_subscript_1d_arrays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_2d_arrays(self):
output, canon = runner('test-models/tests/subscript_2d_arrays/test_subscript_2d_arrays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_3d_arrays(self):
output, canon = runner('test-models/tests/subscript_3d_arrays/test_subscript_3d_arrays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_3d_arrays_lengthwise(self):
output, canon = runner('test-models/tests/subscript_3d_arrays_lengthwise/test_subscript_3d_arrays_lengthwise.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_3d_arrays_widthwise(self):
output, canon = runner('test-models/tests/subscript_3d_arrays_widthwise/test_subscript_3d_arrays_widthwise.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_aggregation(self):
output, canon = runner('test-models/tests/subscript_aggregation/test_subscript_aggregation.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_constant_call(self):
output, canon = runner('test-models/tests/subscript_constant_call/test_subscript_constant_call.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_copy(self):
output, canon = runner('test-models/tests/subscript_copy/test_subscript_copy.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_docs(self):
output, canon = runner('test-models/tests/subscript_docs/subscript_docs.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_element_name(self):
# issue https://github.com/JamesPHoughton/pysd/issues/216
output, canon = runner('test-models/tests/subscript_element_name/test_subscript_element_name.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_individually_defined_1_of_2d_arrays(self):
output, canon = runner('test-models/tests/subscript_individually_defined_1_of_2d_arrays/subscript_individually_defined_1_of_2d_arrays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_individually_defined_1_of_2d_arrays_from_floats(self):
output, canon = runner('test-models/tests/subscript_individually_defined_1_of_2d_arrays_from_floats/subscript_individually_defined_1_of_2d_arrays_from_floats.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_individually_defined_1d_arrays(self):
output, canon = runner('test-models/tests/subscript_individually_defined_1d_arrays/subscript_individually_defined_1d_arrays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_individually_defined_stocks(self):
output, canon = runner('test-models/tests/subscript_individually_defined_stocks/test_subscript_individually_defined_stocks.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_mapping_simple(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner('test-models/tests/subscript_mapping_simple/test_subscript_mapping_simple.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_mapping_vensim(self):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
output, canon = runner('test-models/tests/subscript_mapping_vensim/test_subscript_mapping_vensim.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_mixed_assembly(self):
output, canon = runner('test-models/tests/subscript_mixed_assembly/test_subscript_mixed_assembly.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_selection(self):
output, canon = runner('test-models/tests/subscript_selection/subscript_selection.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_numeric_range(self):
output, canon = runner('test-models/tests/subscript_numeric_range/test_subscript_numeric_range.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_subranges(self):
output, canon = runner('test-models/tests/subscript_subranges/test_subscript_subrange.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_subranges_equal(self):
output, canon = runner('test-models/tests/subscript_subranges_equal/test_subscript_subrange_equal.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_switching(self):
output, canon = runner('test-models/tests/subscript_switching/subscript_switching.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_transposition(self):
output, canon = runner('test-models/tests/subscript_transposition/test_subscript_transposition.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscript_updimensioning(self):
output, canon = runner('test-models/tests/subscript_updimensioning/test_subscript_updimensioning.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscripted_delays(self):
output, canon = runner('test-models/tests/subscripted_delays/test_subscripted_delays.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscripted_flows(self):
output, canon = runner('test-models/tests/subscripted_flows/test_subscripted_flows.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscripted_if_then_else(self):
output, canon = runner('test-models/tests/subscripted_if_then_else/test_subscripted_if_then_else.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscripted_logicals(self):
output, canon = runner('test-models/tests/subscripted_logicals/test_subscripted_logicals.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscripted_smooth(self):
# issue https://github.com/JamesPHoughton/pysd/issues/226
output, canon = runner('test-models/tests/subscripted_smooth/test_subscripted_smooth.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscripted_trend(self):
# issue https://github.com/JamesPHoughton/pysd/issues/226
output, canon = runner('test-models/tests/subscripted_trend/test_subscripted_trend.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subscripted_xidz(self):
output, canon = runner('test-models/tests/subscripted_xidz/test_subscripted_xidz.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_subset_duplicated_coord(self):
output, canon = runner('test-models/tests/subset_duplicated_coord/'
+ 'test_subset_duplicated_coord.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_time(self):
output, canon = runner('test-models/tests/time/test_time.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_trend(self):
output, canon = runner('test-models/tests/trend/test_trend.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_trig(self):
output, canon = runner('test-models/tests/trig/test_trig.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_variable_ranges(self):
output, canon = runner('test-models/tests/variable_ranges/test_variable_ranges.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_unicode_characters(self):
output, canon = runner('test-models/tests/unicode_characters/unicode_test_model.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_xidz_zidz(self):
output, canon = runner('test-models/tests/xidz_zidz/xidz_zidz.mdl')
assert_frames_close(output, canon, rtol=rtol)
def test_run_uppercase(self):
output, canon = runner('test-models/tests/case_sensitive_extension/teacup-upper.MDL')
assert_frames_close(output, canon, rtol=rtol)
def test_odd_number_quotes(self):
output, canon = runner('test-models/tests/odd_number_quotes/teacup_3quotes.mdl')
assert_frames_close(output, canon, rtol=rtol)