• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SDXorg / pysd / 20222568494

26 Aug 2025 09:06AM UTC coverage: 98.751% (-1.1%) from 99.861%
20222568494

push

github

enekomartinmartinez
Bump lycheeverse/lychee-action from 2.5.0 to 2.6.1

Bumps [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action) from 2.5.0 to 2.6.1.
- [Release notes](https://github.com/lycheeverse/lychee-action/releases)
- [Commits](https://github.com/lycheeverse/lychee-action/compare/v2.5.0...v2.6.1)

---
updated-dependencies:
- dependency-name: lycheeverse/lychee-action
  dependency-version: 2.6.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

4981 of 5044 relevant lines covered (98.75%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

30.56
/pysd/cli/main.py
1
import sys
1✔
2
import os
1✔
3
from pathlib import Path
1✔
4

5
from datetime import datetime
1✔
6

7
import pysd
1✔
8
from pysd.translators.vensim.vensim_utils import supported_extensions as\
1✔
9
    vensim_extensions
10
from pysd.translators.xmile.xmile_utils import supported_extensions as\
1✔
11
    xmile_extensions
12

13
from .parser import parser
1✔
14

15

16
def main(args):
1✔
17
    """
18
    Main function. Reads user arguments, loads the models,
19
    runs it and saves the output
20

21
    Parameters
22
    ----------
23
    args: list
24
        User arguments.
25

26
    Returns
27
    -------
28
    None
29

30
    """
31
    options = parser.parse_args(args)
×
32

33
    model = load(options.model_file, options.data_files,
×
34
                 options.missing_values, options.split_views,
35
                 subview_sep=options.subview_sep)
36

37
    if not options.run:
×
38
        print("\nFinished!")
×
39
        sys.exit()
×
40

41
    model.initialize()
×
42

43
    if not options.output_file:
×
44
        options.output_file = os.path.splitext(os.path.basename(
×
45
            options.model_file
46
            ))[0]\
47
                + datetime.now().strftime("_output_%Y_%m_%d-%H_%M_%S_%f.tab")
48

49
    model.run(**create_configuration(model, options))
×
50

51
    if options.export_file:
×
52
        model.export(options.export_file)
×
53

54
    print("\nFinished!")
×
55
    sys.exit()
×
56

57

58
def load(model_file, data_files, missing_values, split_views, **kwargs):
1✔
59
    """
60
    Translate and load model file.
61

62
    Paramters
63
    ---------
64
    model_file: str
65
        Vensim, Xmile or PySD model file.
66

67
    data_files: list
68
        If given the list of files where the necessary data to run the model
69
        is given.
70

71
    missing_values : str ("warning", "error", "ignore", "keep")
72
        What to do with missing values. If "warning" (default)
73
        shows a warning message and interpolates the values.
74
        If "raise" raises an error. If "ignore" interpolates
75
        the values without showing anything. If "keep" it will keep
76
        the missing values, this option may cause the integration to
77
        fail, but it may be used to check the quality of the data.
78

79
    split_views: bool (optional)
80
        If True, the sketch is parsed to detect model elements in each
81
        model view, and then translate each view in a separate Python
82
        file. Setting this argument to True is recommended for large
83
        models split in many different views. Default is False.
84

85
    **kwargs: (optional)
86
        Additional keyword arguments.
87
        subview_sep:(str)
88
            Character used to separate views and subviews. If provided,
89
            and split_views=True, each submodule will be placed inside the
90
            folder of the parent view.
91

92
    Returns
93
    -------
94
    pysd.model
95

96
    """
97
    model_file_suffix = Path(model_file).suffix.lower()
×
98
    if model_file_suffix in vensim_extensions:
×
99
        print("\nTranslating model file...\n")
×
100
        return pysd.read_vensim(model_file, initialize=False,
×
101
                                data_files=data_files,
102
                                missing_values=missing_values,
103
                                split_views=split_views, **kwargs)
104
    elif model_file_suffix in xmile_extensions:
×
105
        print("\nTranslating model file...\n")
×
106
        return pysd.read_xmile(model_file, initialize=False,
×
107
                               data_files=data_files,
108
                               missing_values=missing_values)
109
    else:
110
        return pysd.load(model_file, initialize=False,
×
111
                         data_files=data_files,
112
                         missing_values=missing_values)
113

114

115
def create_configuration(model, options):
1✔
116
    """
117
    create configuration dict to pass to the run method.
118

119
    Parameters
120
    ----------
121
    model: pysd.model object
122

123
    options: argparse.Namespace
124

125
    Returns
126
    -------
127
    conf_dict: dict
128

129
    """
130
    conf_dict = {
×
131
        "progress": options.progress,
132
        "params": options.new_values["param"],
133
        "initial_condition": (options.initial_time or model.time(),
134
                              options.new_values["initial"]),
135
        "return_columns": options.return_columns,
136
        "final_time": options.final_time,
137
        "time_step": options.time_step,
138
        "saveper": options.saveper,
139
        "flatten_output": True,  # need to return totally flat DF
140
        "return_timestamps": options.return_timestamps,  # given or None,
141
        "output_file": options.output_file
142
    }
143

144
    if options.import_file:
×
145
        conf_dict["initial_condition"] = options.import_file
×
146

147
    return conf_dict
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc