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

WISDEM / WEIS / 9919956665

13 Jul 2024 12:34PM UTC coverage: 79.574% (+8.7%) from 70.904%
9919956665

Pull #289

github

gbarter
use the OpenMDAO approach to the problem_vars.json output
Pull Request #289: Release with improved installation

163 of 521 new or added lines in 17 files covered. (31.29%)

707 existing lines in 19 files now uncovered.

21618 of 27167 relevant lines covered (79.57%)

0.8 hits per line

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

79.52
/weis/inputs/validation.py
1
import os
1✔
2
import jsonmerge
1✔
3
import wisdem.inputs
1✔
4
from wisdem.inputs.validation import load_yaml, write_yaml, _validate, simple_types, DefaultValidatingDraft7Validator
1✔
5
import rosco.toolbox.inputs
1✔
6

7
froot_wisdem           = os.path.dirname(wisdem.inputs.__file__)
1✔
8
fschema_geom_wisdem    = os.path.join(froot_wisdem, 'geometry_schema.yaml')
1✔
9
fschema_model_wisdem   = os.path.join(froot_wisdem, 'modeling_schema.yaml')
1✔
10
fschema_model_rosco    = os.path.join(froot_wisdem, 'modeling_schema.yaml')
1✔
11
fschema_opt_wisdem     = os.path.join(froot_wisdem, 'analysis_schema.yaml')
1✔
12

13
froot_rosco            = os.path.dirname(rosco.toolbox.inputs.__file__)
1✔
14
fschema_model_rosco    = os.path.join(froot_rosco, 'toolbox_schema.yaml')
1✔
15

16
froot           = os.path.dirname(os.path.realpath(__file__))
1✔
17
fdefaults_geom  = os.path.join(froot, 'geometry_defaults.yaml')
1✔
18
fschema_geom    = os.path.join(froot, 'geometry_schema.yaml')
1✔
19
fschema_model   = os.path.join(froot, 'modeling_schema.yaml')
1✔
20
fschema_opt     = os.path.join(froot, 'analysis_schema.yaml')
1✔
21
#---------------------
22
def load_default_geometry_yaml():
1✔
23
    return load_yaml(fdefaults_geom)
×
24

25
def get_geometry_schema():
1✔
26
    wisdem_schema = load_yaml(fschema_geom_wisdem)
1✔
27
    weis_schema   = load_yaml(fschema_geom)
1✔
28
    merged_schema = jsonmerge.merge(wisdem_schema, weis_schema)
1✔
29
    return merged_schema
1✔
30

31
def load_geometry_yaml(finput):
1✔
32
    merged_schema = get_geometry_schema()
1✔
33
    return _validate(finput, merged_schema, defaults=True)
1✔
34

35
def write_geometry_yaml(instance, foutput):
1✔
36
    merged_schema = get_geometry_schema()
×
NEW
37
    _validate(instance, merged_schema, defaults=False)
×
38
    sfx_str = '.yaml'
×
39
    if foutput[-5:] == sfx_str:
×
40
        sfx_str = ''
×
41
    write_yaml(instance, foutput+sfx_str)
×
42

43
def get_modeling_schema():
1✔
44
    wisdem_schema = load_yaml(fschema_model_wisdem)
1✔
45
    rosco_schema  = load_yaml(fschema_model_rosco)
1✔
46
    weis_schema   = load_yaml(fschema_model)
1✔
47
    merged_rosco_schema = jsonmerge.merge(rosco_schema['properties']['controller_params'], weis_schema['properties']['ROSCO'])
1✔
48
    merged_rosco_schema['properties']['linmodel_tuning'] = rosco_schema['properties']['linmodel_tuning']
1✔
49
    weis_schema['properties']['WISDEM'].update( wisdem_schema['properties']['WISDEM'] )
1✔
50
    weis_schema['properties']['ROSCO'].update(merged_rosco_schema)
1✔
51
    return weis_schema
1✔
52

53
def load_modeling_yaml(finput):
1✔
54
    weis_schema = get_modeling_schema()
1✔
55
    return _validate(finput, weis_schema, defaults=True)
1✔
56

57
def write_modeling_yaml(instance, foutput):
1✔
58
    weis_schema = get_modeling_schema()
1✔
59
    _validate(instance, weis_schema, defaults=False)
1✔
60
    sfx_str = ".yaml"
1✔
61
    if foutput[-5:] == sfx_str:
1✔
62
        foutput = foutput[-5:]
×
63
    elif foutput[-4:] == ".yml":
1✔
64
        foutput = foutput[-4:]
×
65
    sfx_str = "-modeling.yaml"
1✔
66
    instance2 = simple_types(instance)
1✔
67
    write_yaml(instance2, foutput+sfx_str)
1✔
68

69
def get_analysis_schema():
1✔
70
    wisdem_schema = load_yaml(fschema_opt_wisdem)
1✔
71
    weis_schema   = load_yaml(fschema_opt)
1✔
72
    merged_schema = jsonmerge.merge(wisdem_schema, weis_schema)
1✔
73
    return merged_schema
1✔
74

75
def load_analysis_yaml(finput):
1✔
76
    merged_schema = get_analysis_schema()
1✔
77
    return _validate(finput, merged_schema, defaults=True)
1✔
78

79
def write_analysis_yaml(instance, foutput):
1✔
80
    merged_schema = get_analysis_schema()
1✔
81
    _validate(instance, merged_schema, defaults=False)
1✔
82
    sfx_str = ".yaml"
1✔
83
    if foutput[-5:] == sfx_str:
1✔
84
        foutput = foutput[-5:]
×
85
    elif foutput[-4:] == ".yml":
1✔
86
        foutput = foutput[-4:]
×
87
    sfx_str = "-analysis.yaml"
1✔
88
    write_yaml(instance, foutput+sfx_str)
1✔
89

90
def re_validate_modeling(modeling_dict):
1✔
NEW
91
    fschema = get_modeling_schema()
×
NEW
92
    yaml_schema = load_yaml(fschema) if isinstance(fschema, type("")) else fschema
×
NEW
93
    DefaultValidatingDraft7Validator(yaml_schema).validate(modeling_dict)
×
94

95
def re_validate_analysis(analysis_dict):
1✔
NEW
96
    fschema = get_analysis_schema()
×
NEW
97
    yaml_schema = load_yaml(fschema) if isinstance(fschema, type("")) else fschema
×
NEW
98
    DefaultValidatingDraft7Validator(yaml_schema).validate(analysis_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