File tree Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Expand file tree Collapse file tree 4 files changed +32
-2
lines changed Original file line number Diff line number Diff line change 4
4
"""Main script for pyopmspe11"""
5
5
import os
6
6
import argparse
7
+ import warnings
7
8
from pyopmspe11 .utils .inputvalues import process_input , check_deck , handle_tuning
8
9
from pyopmspe11 .utils .runs import simulations , plotting , data
9
10
from pyopmspe11 .visualization .plotting import plot_results
@@ -29,6 +30,9 @@ def pyopmspe11():
29
30
dic ["dt_data" ] = float (
30
31
cmdargs ["write" ].strip ()
31
32
) # Temporal resolution to write the sparse and performance data
33
+ dic ["showpywarn" ] = int (cmdargs ["showpywarn" ]) # Show or hidde python warnings
34
+ if dic ["showpywarn" ] != 1 :
35
+ warnings .warn = lambda * args , ** kwargs : None
32
36
# If the compare plots are generated, then we exit right afterwards
33
37
if dic ["compare" ]:
34
38
plot_results (dic )
@@ -154,6 +158,12 @@ def load_parser():
154
158
help = "Time interval for the sparse and performance data (spe11a [h]; spe11b/c [y]) "
155
159
"('0.1' by default)." ,
156
160
)
161
+ parser .add_argument (
162
+ "-s" ,
163
+ "--showpywarn" ,
164
+ default = 0 ,
165
+ help = "Set to 1 to show Python warnings ('0' by default)." ,
166
+ )
157
167
return vars (parser .parse_known_args ()[0 ])
158
168
159
169
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ def plotting(dic):
52
52
"-d " + f"{ dic ['spe11' ]} " ,
53
53
"-g " + f"{ dic ['generate' ]} " ,
54
54
"-r " + f"{ dic ['resolution' ]} " ,
55
+ "-s " + f"{ dic ['showpywarn' ]} " ,
55
56
]
56
57
print (" " .join (plot_exe ))
57
58
prosc = subprocess .run (plot_exe , check = True )
@@ -81,6 +82,7 @@ def data(dic):
81
82
"-t " + f"{ dic ['time_data' ]} " ,
82
83
"-w " + f"{ dic ['dt_data' ]} " ,
83
84
"-u " + f"{ dic ['use' ]} " ,
85
+ "-s " + f"{ dic ['showpywarn' ]} " ,
84
86
]
85
87
print (" " .join (data_exe ))
86
88
prosc = subprocess .run (data_exe , check = True )
Original file line number Diff line number Diff line change 1
1
# SPDX-FileCopyrightText: 2023 NORCE
2
2
# SPDX-License-Identifier: MIT
3
- # pylint: disable=C0302, R0912, R0914
3
+ # pylint: disable=C0302, R0912, R0914, R0801
4
4
5
5
""""
6
6
Script to write the benchmark data
7
7
"""
8
8
9
9
import os
10
10
import argparse
11
+ import warnings
11
12
import csv
12
13
from io import StringIO
13
14
from shapely .geometry import Polygon
@@ -86,7 +87,15 @@ def main():
86
87
default = "resdata" ,
87
88
help = "Using the 'resdata' or python package (resdata by default)." ,
88
89
)
90
+ parser .add_argument (
91
+ "-s" ,
92
+ "--showpywarn" ,
93
+ default = 0 ,
94
+ help = "Set to 1 to show Python warnings ('0' by default)." ,
95
+ )
89
96
cmdargs = vars (parser .parse_known_args ()[0 ])
97
+ if int (cmdargs ["showpywarn" ]) != 1 : # Show or hidde python warnings
98
+ warnings .warn = lambda * args , ** kwargs : None
90
99
dig = {"path" : cmdargs ["path" ].strip ()}
91
100
dig ["case" ] = cmdargs ["deck" ].strip ()
92
101
dig ["mode" ] = cmdargs ["generate" ].strip ()
Original file line number Diff line number Diff line change 1
1
# SPDX-FileCopyrightText: 2023 NORCE
2
2
# SPDX-License-Identifier: MIT
3
- # pylint: disable=R0912
3
+ # pylint: disable=R0912, R0801
4
4
5
5
""""
6
6
Script to plot the results
7
7
"""
8
8
9
9
import argparse
10
10
import os
11
+ import warnings
11
12
import math as mt
12
13
import numpy as np
13
14
import matplotlib
@@ -62,7 +63,15 @@ def main():
62
63
"'dense_performance', 'dense_sparse', 'performance_sparse', "
63
64
"'dense_performance-spatial', 'dense_performance_sparse', or 'all'" ,
64
65
)
66
+ parser .add_argument (
67
+ "-s" ,
68
+ "--showpywarn" ,
69
+ default = 0 ,
70
+ help = "Set to 1 to show Python warnings ('0' by default)." ,
71
+ )
65
72
cmdargs = vars (parser .parse_known_args ()[0 ])
73
+ if int (cmdargs ["showpywarn" ]) != 1 : # Show or hidde python warnings
74
+ warnings .warn = lambda * args , ** kwargs : None
66
75
dic = {"folders" : [cmdargs ["folder" ].strip ()]}
67
76
dic ["case" ] = cmdargs ["deck" ].strip ()
68
77
dic ["generate" ] = cmdargs ["generate" ].strip ()
You can’t perform that action at this time.
0 commit comments