e2nIEE / pandapower
1
# -*- coding: utf-8 -*-
2

3
# Copyright (c) 2016-2021 by University of Kassel and Fraunhofer Institute for Energy Economics
4
# and Energy System Technology (IEE), Kassel. All rights reserved.
5

6

7

8 1
try:
9 1
    import pplog as logging
10 1
except ImportError:
11 1
    import logging
12

13 1
logger = logging.getLogger(__name__)
14

15
# separator between log messages
16 1
log_message_sep = ("\n --------\n")
17

18

19 1
def diagnostic_report(net, diag_results, diag_errors, diag_params, compact_report, warnings_only):
20 0
    diag_report = DiagnosticReports(net, diag_results, diag_errors, diag_params, compact_report)
21 0
    if warnings_only:
22 0
        logger.setLevel(logging.WARNING)
23
    else:
24 0
        logger.setLevel(logging.INFO)
25

26 0
    report_methods = {
27
        "missing_bus_indices": diag_report.report_missing_bus_indices,
28
        "disconnected_elements": diag_report.report_disconnected_elements,
29
        "different_voltage_levels_connected": diag_report.report_different_voltage_levels_connected,
30
        "impedance_values_close_to_zero": diag_report.report_impedance_values_close_to_zero,
31
        "nominal_voltages_dont_match": diag_report.report_nominal_voltages_dont_match,
32
        "invalid_values": diag_report.report_invalid_values,
33
        "overload": diag_report.report_overload,
34
        "multiple_voltage_controlling_elements_per_bus": diag_report.report_multiple_voltage_controlling_elements_per_bus,
35
        "wrong_switch_configuration": diag_report.report_wrong_switch_configuration,
36
        "no_ext_grid": diag_report.report_no_ext_grid,
37
        "wrong_reference_system": diag_report.report_wrong_reference_system,
38
        "deviation_from_std_type": diag_report.report_deviation_from_std_type,
39
        "numba_comparison": diag_report.report_numba_comparison,
40
        "parallel_switches": diag_report.report_parallel_switches
41
    }
42

43 0
    logger.warning("\n\n_____________ PANDAPOWER DIAGNOSTIC TOOL _____________ \n")
44 0
    for key in report_methods:
45 0
        if (key in diag_results) or not warnings_only:
46 0
            report_methods[key]()
47 0
            logger.warning(log_message_sep)
48

49 0
    logger.warning("_____________ END OF PANDAPOWER DIAGNOSTIC _____________ ")
50

51

52 1
class DiagnosticReports:
53 1
    def __init__(self, net, diag_results, diag_errors, diag_params, compact_report):
54 1
        self.net = net
55 1
        self.diag_results = diag_results
56 1
        self.diag_errors = diag_errors
57 1
        self.diag_params = diag_params
58 1
        self.compact_report = compact_report
59

60 1
    def report_disconnected_elements(self):
61 1
        if "disconnected_elements" in self.diag_results:
62
            # message header
63 1
            if self.compact_report:
64 1
                logger.warning("disconnected_elements:")
65
            else:
66 1
                logger.warning("Checking for elements without a connection to an external grid...")
67 1
            logger.warning("")
68

69
            # message body
70 1
            diag_result = self.diag_results["disconnected_elements"]
71 1
            element_counter = 0
72 1
            for disc_section in diag_result:
73 1
                if self.compact_report:
74 1
                    logger.warning("disonnected_section: %s" % (disc_section))
75

76
                else:
77 1
                    logger.warning("Disconnected section found,"
78
                                   " consisting of the following elements:")
79 1
                    for key in disc_section:
80 1
                        element_counter += len(disc_section[key])
81 1
                        logger.warning("%s: %s" % (key, disc_section[key]))
82

83
            # message summary
84 1
            if not self.compact_report:
85 1
                logger.warning("")
86 1
                logger.warning("SUMMARY: %s disconnected element(s) found." % (element_counter))
87 1
        elif "disconnected_elements" in self.diag_errors:
88 0
            logger.warning("Check for disconnected elements failed due to the following error:")
89 0
            logger.warning(self.diag_errors["disconnected_elements"])
90
        else:
91 1
            logger.info("PASSED: No problematic switches found")
92

93 1
    def report_different_voltage_levels_connected(self):
94 1
        from pandapower.toolbox import get_connected_buses_at_element
95

96 1
        if "different_voltage_levels_connected" in self.diag_results:
97

98
            # message header
99 1
            if self.compact_report:
100 1
                logger.warning("different_voltage_levels_connected:")
101

102
            else:
103 1
                logger.warning("Checking for connections of different voltage levels...")
104 1
            logger.warning("")
105

106
            # message body
107 1
            diag_result = self.diag_results["different_voltage_levels_connected"]
108 1
            element_counter = 0
109 1
            for key in diag_result:
110 1
                element_counter += len(diag_result[key])
111 1
                if key == "lines":
112 1
                    element_type = "line"
113 1
                elif key == "switches":
114 1
                    element_type = "switch"
115 1
                if self.compact_report:
116 1
                    logger.warning("%s:" % (key))
117 1
                for element in diag_result[key]:
118 1
                    buses = list(get_connected_buses_at_element(self.net, element,
119
                                                                key[0]))
120 1
                    if self.compact_report:
121 1
                        logger.warning("%s %s: buses %s" % (element_type, element, buses))
122
                    else:
123 1
                        logger.warning("%s %s connects bus %s: %s (vn_kv = %s) "
124
                                       "and bus %s: %s (vn_kv = %s)"
125
                                       % (element_type, element, buses[0],
126
                                          self.net.bus.name.at[buses[0]],
127
                                          self.net.bus.vn_kv.at[buses[0]],
128
                                          buses[1], self.net.bus.name.at[buses[1]],
129
                                          self.net.bus.vn_kv.at[buses[1]]))
130
                        # message summary
131 1
            if not self.compact_report:
132 1
                logger.warning("")
133 1
                logger.warning("SUMMARY: %s element(s) that connect different voltage "
134
                               "levels found." % (element_counter))
135 1
        elif "different_voltage_levels_connected" in self.diag_errors:
136 0
            logger.warning("Check for connection of different voltage levels failed due to the following error:")
137 0
            logger.warning(self.diag_errors["different_voltage_levels_connected"])
138
        else:
139 1
            logger.info("PASSED: No connection of different voltage levels found")
140

141

142 1
    def report_impedance_values_close_to_zero(self):
143

144 1
        if "impedance_values_close_to_zero" in self.diag_results:
145

146
            # message header
147 1
            if self.compact_report:
148 1
                logger.warning("impedance_values_close_to_zero:")
149

150
            else:
151 1
                logger.warning("Checking for impedance values close to zero...")
152 1
            logger.warning("")
153

154
            # message body
155 1
            diag_result = self.diag_results["impedance_values_close_to_zero"][0]
156 1
            element_counter = 0
157 1
            for key in diag_result:
158 1
                element_counter += len(diag_result[key])
159 1
                for element in diag_result[key]:
160 1
                    if key == "line":
161 1
                        min_r_type = "r_ohm"
162 1
                        min_x_type = "x_ohm"
163 1
                    elif key == "xward":
164 1
                        min_r_type = "r_ohm"
165 1
                        min_x_type = "x_ohm"
166 1
                    elif key == "impedance":
167 1
                        min_r_type = "r_pu"
168 1
                        min_x_type = "x_pu"
169

170 1
                    logger.warning("%s %s: %s <= %s or %s <= %s"
171
                                   % (key, element, min_r_type, self.diag_params["min_"+min_r_type],
172
                                      min_x_type, self.diag_params["min_"+min_x_type]))
173

174 1
            if len(self.diag_results["impedance_values_close_to_zero"]) > 1:
175 1
                switch_replacement = self.diag_results["impedance_values_close_to_zero"][1]
176 1
                if switch_replacement["loadflow_converges_with_switch_replacement"]:
177 1
                    logger.warning("Switch replacement successful: Power flow converges after "
178
                                   "replacing implausible elements with switches.")
179
                else:
180 0
                    logger.warning("Power flow still does not converge after replacing implausible "
181
                                   "elements with switches.")
182

183
            # message summary
184 1
            if not self.compact_report:
185 1
                logger.warning("")
186 1
                logger.warning("SUMMARY: %s element(s) with impedance values close to zero found."
187
                               % (element_counter))
188 1
        elif "impedance_values_close_to_zero" in self.diag_errors:
189 0
            logger.warning("Check for elements with impedance values close to zero failed due "
190
                           "to the following error:")
191 0
            logger.warning(self.diag_errors["impedance_values_close_to_zero"])
192
        else:
193 1
            logger.info("PASSED: No elements with impedance values close to zero found...")
194

195

196 1
    def report_nominal_voltages_dont_match(self):
197

198 1
        if "nominal_voltages_dont_match" in self.diag_results:
199

200
            # message header
201 1
            if self.compact_report:
202 1
                logger.warning("nominal_voltages_dont_match:")
203

204
            else:
205 1
                logger.warning("Checking for components with deviating nominal voltages...")
206 1
            logger.warning("")
207

208
            # message body
209 1
            diag_result = self.diag_results["nominal_voltages_dont_match"]
210 1
            nom_voltage_tolerance = self.diag_params["nom_voltage_tolerance"]
211 1
            element_counter = 0
212 1
            for element in diag_result:
213 1
                if self.compact_report:
214 1
                    logger.warning("%s:" % (element))
215 1
                for key in diag_result[element]:
216 1
                    element_counter += len(diag_result[element][key])
217 1
                    if element == "trafo":
218 1
                        if self.compact_report:
219 1
                            logger.warning("%s: %s" % (key, diag_result[element][key]))
220
                        else:
221 1
                            if key == "hv_lv_swapped":
222 1
                                logger.warning("Trafo(s) %s: hv and lv connectors seem to "
223
                                               "be swapped" % (diag_result[element][key]))
224 1
                            elif key == "hv_bus":
225 1
                                for trafo in diag_result[element][key]:
226 1
                                    logger.warning("Trafo %s: Nominal voltage on hv_side "
227
                                                   "(%s kV) and voltage_level of hv_bus "
228
                                                   "(bus %s with voltage_level %s kV) "
229
                                                   "deviate more than +/- %s percent."
230
                                                   % (trafo, self.net.trafo.vn_hv_kv.at[trafo],
231
                                                      self.net.trafo.hv_bus.at[trafo],
232
                                                      self.net.bus.vn_kv.at[self.net.trafo.hv_bus.at[trafo]],
233
                                                      nom_voltage_tolerance * 100))
234 1
                            elif key == "lv_bus":
235 1
                                for trafo in diag_result[element][key]:
236 1
                                    logger.warning("Trafo %s: Nominal voltage on lv_side "
237
                                                   "(%s kV) and voltage_level of lv_bus "
238
                                                   "(bus %s with voltage_level %s kV) "
239
                                                   "deviate more than +/- %s percent."
240
                                                   % (trafo, self.net.trafo.vn_lv_kv.at[trafo],
241
                                                      self.net.trafo.lv_bus.at[trafo],
242
                                                      self.net.bus.vn_kv.at[self.net.trafo.lv_bus.at[trafo]],
243
                                                      nom_voltage_tolerance * 100))
244 1
                    if element == "trafo3w":
245 1
                        if self.compact_report:
246 1
                            logger.warning("%s: %s" % (key, diag_result[element][key]))
247
                        else:
248 1
                            if key == "connectors_swapped_3w":
249 1
                                logger.warning("Trafo3w %s: connectors seem to "
250
                                               "be swapped" % (diag_result[element][key]))
251 1
                            elif key == "hv_bus":
252 1
                                for trafo3w in diag_result[element][key]:
253 1
                                    logger.warning("Trafo3w %s: Nominal voltage on hv_side "
254
                                                   "(%s kV) and voltage_level of hv_bus "
255
                                                   "(bus %s with voltage_level %s kV) "
256
                                                   "deviate more than +/- %s percent."
257
                                                   % (trafo3w, self.net.trafo3w.vn_hv_kv.at[trafo3w],
258
                                                      self.net.trafo3w.hv_bus.at[trafo3w],
259
                                                      self.net.bus.vn_kv.at[self.net.trafo3w.hv_bus.at[trafo3w]],
260
                                                      nom_voltage_tolerance * 100))
261 1
                            elif key == "mv_bus":
262 1
                                for trafo3w in diag_result[element][key]:
263 1
                                    logger.warning("Trafo3w %s: Nominal voltage on mv_side "
264
                                                   "(%s kV) and voltage_level of mv_bus "
265
                                                   "(bus %s with voltage_level %s kV) "
266
                                                   "deviate more than +/- %s percent."
267
                                                   % (trafo3w, self.net.trafo3w.vn_mv_kv.at[trafo3w],
268
                                                      self.net.trafo3w.mv_bus.at[trafo3w],
269
                                                      self.net.bus.vn_kv.at[self.net.trafo3w.mv_bus.at[trafo3w]],
270
                                                      nom_voltage_tolerance * 100))
271 1
                            elif key == "lv_bus":
272 1
                                for trafo3w in diag_result[element][key]:
273 1
                                    logger.warning("Trafo3w %s: Nominal voltage on lv_side "
274
                                                   "(%s kV) and voltage_level of lv_bus "
275
                                                   "(bus %s with voltage_level %s kV) "
276
                                                   "deviate more than +/- %s percent."
277
                                                   % (trafo3w, self.net.trafo3w.vn_lv_kv.at[trafo3w],
278
                                                      self.net.trafo3w.lv_bus.at[trafo3w],
279
                                                      self.net.bus.vn_kv.at[self.net.trafo3w.lv_bus.at[trafo3w]],
280
                                                      nom_voltage_tolerance * 100))
281

282
                                    # message summary
283 1
            if not self.compact_report:
284 1
                logger.warning("")
285 1
                logger.warning("SUMMARY: %s component(s) with deviating nominal voltages found"
286
                               % (element_counter))
287 1
        elif "nominal_voltages_dont_match" in self.diag_errors:
288 0
            logger.warning("Check for components with deviating nominal voltages failed due "
289
                           "to the following error:")
290 0
            logger.warning(self.diag_errors["nominal_voltages_dont_match"])
291
        else:
292 1
            logger.info("PASSED: No components with deviating nominal voltages found")
293

294 1
    def report_invalid_values(self):
295

296 1
        if "invalid_values" in self.diag_results:
297

298
            # message header
299 1
            if self.compact_report:
300 1
                logger.warning("invalid_values:")
301
            else:
302 1
                logger.warning("Checking for invalid_values...")
303 1
            logger.warning("")
304

305
        # message body
306 1
        if "invalid_values" in self.diag_results:
307 1
            diag_result = self.diag_results["invalid_values"]
308 1
            element_counter = 0
309 1
            for element_type in diag_result:
310 1
                element_counter += len(diag_result[element_type])
311 1
                logger.warning("%s:" % (element_type))
312 1
                for inv_value in diag_result[element_type]:
313 1
                    if self.compact_report:
314 1
                        logger.warning("%s %s: '%s' = %s (restriction: %s)"
315
                                       % (element_type, inv_value[0], inv_value[1], inv_value[2],
316
                                          inv_value[3]))
317
                    else:
318 1
                        logger.warning("Invalid value found: '%s %s' with attribute '%s' = %s "
319
                                       "(data type: %s). Valid input needs to be %s."
320
                                       % (element_type, inv_value[0], inv_value[1], inv_value[2],
321
                                          type(inv_value[2]), inv_value[3]))
322

323
                        # message summary
324 1
            if not self.compact_report:
325 1
                logger.warning("")
326 1
                logger.warning("SUMMARY: %s invalid values found." % element_counter)
327

328 1
        elif "invalid_values" in self.diag_errors:
329 0
            logger.warning("Check for invalid values failed due to the following error:")
330 0
            logger.warning(self.diag_errors["invalid_values"])
331
        else:
332 1
            logger.info("PASSED: No invalid values found")
333

334

335 1
    def report_overload(self):
336

337 1
        if "overload" in self.diag_results:
338
            # message header
339 1
            if self.compact_report:
340 1
                logger.warning("overload:")
341
            else:
342 1
                logger.warning("Checking for overload...")
343 1
            logger.warning("")
344

345
            # message body
346 1
            diag_result = self.diag_results["overload"]
347 1
            overload_scaling_factor = self.diag_params["overload_scaling_factor"]
348 1
            if not diag_result["load"] and not diag_result["generation"]:
349 0
                logger.warning("Overload check failed: Power flow still does not "
350
                               "converge with load and generation scaled down to %s percent."
351
                               % (overload_scaling_factor * 100))
352 1
            elif (diag_result["load"] and diag_result["generation"]):
353 1
                logger.warning("overload found: Power flow converges "
354
                               "with load and generation scaled down to %s percent."
355
                               % (overload_scaling_factor * 100))
356
            else:
357 1
                if diag_result["load"]:
358 1
                    logger.warning("overload found: Power flow converges "
359
                                   "with load scaled down to %s percent."
360
                                   % (overload_scaling_factor * 100))
361 1
                elif diag_result["generation"]:
362 1
                    logger.warning("overload found: Power flow converges "
363
                                   "with generation scaled down to %s percent."
364
                                   % (overload_scaling_factor * 100))
365
        # message summary
366 1
        elif "overload" in self.diag_errors:
367 0
            logger.warning("Check for overload failed due to the following error:")
368 0
            logger.warning(self.diag_errors["overload"])
369
        else:
370 1
            logger.info("PASSED: Power flow converges. No overload found.")
371

372

373 1
    def report_wrong_switch_configuration(self):
374

375 1
        if "wrong_switch_configuration" in self.diag_results:
376

377
            # message header
378 1
            if self.compact_report:
379 1
                logger.warning("wrong_switch_configuration:")
380
            else:
381 1
                logger.warning("Checking switch configuration...")
382 1
            logger.warning("")
383

384
            # message body
385 1
            diag_result = self.diag_results["wrong_switch_configuration"]
386 1
            if diag_result:
387 0
                logger.warning("Possibly wrong switch configuration found: power flow "
388
                               "converges with all switches closed.")
389
            else:
390 1
                logger.warning("Power flow still does not converge with all switches closed.")
391

392
        # message summary
393 1
        elif "wrong_switch_configuration" in self.diag_errors:
394 0
            logger.warning("Check for wrong switch configuration failed due to the following error:")
395 0
            logger.warning(self.diag_errors["wrong_switch_configuration"])
396
        else:
397 1
            logger.info("PASSED: Power flow converges. Switch configuration seems ok.")
398

399

400 1
    def report_no_ext_grid(self):
401

402 1
        if "no_ext_grid" in self.diag_results:
403
            # message header
404 0
            if self.compact_report:
405 0
                logger.warning("no_external_grid:")
406
            else:
407 0
                logger.warning("Checking if there is at least one external grid...")
408 0
            logger.warning("")
409

410
            # message body
411 0
            diag_result = self.diag_results["no_ext_grid"]
412 0
            if diag_result is True:
413 0
                logger.warning("No ext_grid found. There has to be at least one ext_grid!")
414

415
        # message summary
416 1
        elif "no_ext_grid" in self.diag_errors:
417 0
            logger.warning("Check for external grid failed due to the following error:")
418 0
            logger.warning(self.diag_errors["no_ext_grid"])
419
        else:
420 1
            logger.info("PASSED: External grid found.")
421

422

423 1
    def report_multiple_voltage_controlling_elements_per_bus(self):
424

425 1
        if "multiple_voltage_controlling_elements_per_bus" in self.diag_results:
426
            # message header
427 1
            if self.compact_report:
428 1
                logger.warning("multiple_voltage_controlling_elements_per_bus:")
429
            else:
430 1
                logger.warning("Checking for multiple gens and/or external grids per bus...")
431 1
            logger.warning("")
432

433
            # message body
434 1
            diag_result = self.diag_results["multiple_voltage_controlling_elements_per_bus"]
435 1
            element_counter = 0
436 1
            for feeder_type in diag_result:
437 1
                element_counter += len(diag_result[feeder_type])
438 1
                if self.compact_report:
439 1
                    logger.warning("%s: %s" % (feeder_type, diag_result[feeder_type]))
440

441
                else:
442 1
                    for bus in diag_result[feeder_type]:
443 1
                        if feeder_type == "buses_with_mult_ext_grids":
444 1
                            logger.warning("External grids %s are connected to bus %s. Only one "
445
                                           "external grid per bus is allowed."
446
                                           % (list(self.net.ext_grid[self.net.ext_grid.bus
447
                                                                     == bus].index), bus))
448 1
                        elif feeder_type == "buses_with_gens_and_ext_grids":
449 1
                            logger.warning("Generator(s) %s and external grid(s) %s are connected "
450
                                           "to bus %s. Only one generator OR one external grid "
451
                                           "per bus is allowed."
452
                                           % (list(self.net.gen[self.net.gen.bus == bus].index),
453
                                              list(self.net.ext_grid[self.net.ext_grid.bus
454
                                                                     == bus].index), bus))
455

456
                            # message summary
457 1
            if not self.compact_report:
458 1
                logger.warning("")
459 1
                logger.warning("SUMMARY: %s bus(ses) with multiple gens and/or ext_grids "
460
                               "found." % (element_counter))
461 1
        elif "multiple_voltage_controlling_elements_per_bus" in self.diag_errors:
462 0
            logger.warning("Check for multiple voltage controlling elements per bus failed due "
463
                           "to the following error:")
464 0
            logger.warning(self.diag_errors["multiple_voltage_controlling_elements_per_bus"])
465
        else:
466 1
            logger.info("PASSED: No buses with multiple gens and/or ext_grids found.")
467

468

469 1
    def report_wrong_reference_system(self):
470

471 1
        if "wrong_reference_system" in self.diag_results:
472

473
            # message header
474 1
            if self.compact_report:
475 1
                logger.warning("wrong_reference_system:")
476
            else:
477 1
                logger.warning("Checking for usage of wrong reference system...")
478 1
            logger.warning("")
479

480
            # message body
481 1
            diag_result = self.diag_results["wrong_reference_system"]
482 1
            for element_type in diag_result:
483 1
                if element_type == "loads":
484 1
                    if self.compact_report:
485 1
                        logger.warning("loads %s: wrong reference system."
486
                                       % (diag_result[element_type]))
487
                    else:
488 1
                        for load in diag_result[element_type]:
489 1
                            logger.warning("Found load %s: '%s' with p_mw = %s. In load reference "
490
                                           "system p_mw should be positive."
491
                                           % (load, self.net.load.name.at[load],
492
                                              self.net.load.p_mw.at[load]))
493

494 1
                elif element_type == "gens":
495 1
                    if self.compact_report:
496 1
                        logger.warning("gens %s: wrong reference system."
497
                                       % (diag_result[element_type]))
498
                    else:
499 1
                        for gen in diag_result[element_type]:
500 1
                            logger.warning("Found gen %s: '%s' with p_mw = %s. In load reference "
501
                                           "system p_mw should be negative."
502
                                           % (gen, self.net.gen.name.at[gen], self.net.gen.p_mw.at[gen]))
503

504 1
                elif element_type == "sgens":
505 1
                    if self.compact_report:
506 1
                        logger.warning("sgens %s: wrong reference system."
507
                                       % (diag_result[element_type]))
508
                    else:
509 1
                        for sgen in diag_result[element_type]:
510 1
                            logger.warning("Found sgen %s: '%s' with p_mw = %s. In load reference "
511
                                           "system p_mw should be negative."
512
                                           % (sgen, self.net.sgen.name.at[sgen], self.net.sgen.p_mw.at[sgen]))
513

514
                            # message summary
515 1
            if not self.compact_report:
516 1
                logger.warning("")
517 1
                if 'loads' in diag_result:
518 1
                    logger.warning("SUMMARY: Found %s load(s) with negative p_mw. In load "
519
                                   "reference system, p_mw should be positive. If the intention "
520
                                   "was to model a constant generation, please use an sgen instead."
521
                                   % (len(diag_result['loads'])))
522 1
                if 'gens' in diag_result:
523 1
                    logger.warning("SUMMARY: Found %s gen(s) with positive p_mw. In load "
524
                                   "reference system, p_mw should be negative. If the intention "
525
                                   "was to model a load, please use a load instead."
526
                                   % (len(diag_result['gens'])))
527 1
                if 'sgens' in diag_result:
528 1
                    logger.warning("SUMMARY: Found %s sgen(s) with positive p_mw. In load "
529
                                   "reference system, p_mw should be negative. If the intention "
530
                                   "was to model a load, please use a load instead."
531
                                   % (len(diag_result['sgens'])))
532

533 1
        elif "wrong_reference_system" in self.diag_errors:
534 0
            logger.warning("Check for wrong reference system failed due to the following error:")
535 0
            logger.warning(self.diag_errors["wrong_reference_system"])
536
        else:
537 1
            logger.info("PASSED: correct reference system")
538

539

540 1
    def report_deviation_from_std_type(self):
541

542 1
        if "deviation_from_std_type" in self.diag_results:
543
            # message header
544 1
            if self.compact_report:
545 1
                logger.warning("deviation_from_std_type:")
546
            else:
547 1
                logger.warning("Checking for deviation from std type...")
548 1
            logger.warning("")
549

550
            # message body
551 1
            diag_result = self.diag_results["deviation_from_std_type"]
552 1
            element_counter = 0
553 1
            for et in diag_result:
554 1
                for eid in diag_result[et]:
555 1
                    element_counter += 1
556 1
                    values = diag_result[et][eid]
557 1
                    if values['std_type_in_lib']:
558 1
                        logger.warning("%s %s: %s = %s, std_type_value = %s"
559
                                       % (et, eid, values['param'], values['e_value'],
560
                                          values['std_type_value']))
561
                    else:
562 0
                        logger.warning("%s %s: No valid std_type or std_type not in net.std_types"
563
                                       % (et, eid))
564

565
                        # message summary
566 1
            if not self.compact_report:
567 1
                logger.warning("")
568 1
                logger.warning("SUMMARY: %s elements with deviations from std_type found."
569
                               % (element_counter))
570

571 1
        elif "deviation_from_std_type" in self.diag_errors:
572 0
            logger.warning("Check for deviation from std_type failed due to the following error:")
573 0
            logger.warning(self.diag_errors["deviation_from_std_type"])
574
        else:
575 1
            logger.info("PASSED: No elements with deviations from std_type found.")
576

577 1
    def report_numba_comparison(self):
578

579 1
        if "numba_comparison" in self.diag_results:
580
            # message header
581 1
            if self.compact_report:
582 1
                logger.warning("numba_comparison:")
583
            else:
584 1
                logger.warning("Checking for deviations between numba = True vs. False...")
585 1
            logger.warning("")
586

587
            # message body
588 1
            diag_result = self.diag_results["numba_comparison"]
589 1
            element_counter = 0
590 1
            for element_type in diag_result:
591 1
                for res_type in diag_result[element_type]:
592 1
                    if self.compact_report:
593 1
                        logger.warning("%s.%s absolute deviations:\n%s"
594
                                       % (element_type, res_type,
595
                                          diag_result[element_type][res_type]))
596
                    else:
597 1
                        for idx in diag_result[element_type][res_type].index:
598 1
                            element_counter += 1
599 1
                            dev = diag_result[element_type][res_type].loc[idx]
600 1
                            logger.warning("%s.%s at index %s: absolute deviation = %s"
601
                                           % (element_type, res_type, idx, dev))
602

603
                                # message summary
604 1
                if not self.compact_report:
605 1
                    logger.warning("")
606 1
                    logger.warning("SUMMARY: %s results with deviations between numba = True vs. \
607
                                    False found." % (element_counter))
608

609 1
        elif "numba_comparison" in self.diag_errors:
610 0
            logger.warning("numba_comparison failed due to the following error:")
611 0
            logger.warning(self.diag_errors["numba_comparison"])
612
        else:
613 1
            logger.info("PASSED: No results with deviations between numba = True vs. False found.")
614

615

616 1
    def report_parallel_switches(self):
617

618 1
        if "parallel_switches" in self.diag_results:
619
            # message header
620 1
            if self.compact_report:
621 1
                logger.warning("parallel_switches:")
622
            else:
623 1
                logger.warning("Checking for parallel switches...")
624 1
            logger.warning("")
625

626
            # message body
627 1
            diag_result = self.diag_results["parallel_switches"]
628 1
            for switch_tuple in diag_result:
629 1
                logger.warning("switches %s are parallel." % switch_tuple)
630

631
                # message summary
632 1
            if not self.compact_report:
633 1
                logger.warning("")
634 1
                logger.warning("SUMMARY: %s occurences of parallel switches found."
635
                               % len(diag_result))
636 1
        elif "parallel_switches" in self.diag_errors:
637 0
            logger.warning("Check for parallel_switches failed due to the following error:")
638 0
            logger.warning(self.diag_errors["parallel_switches"])
639
        else:
640 1
            logger.info("PASSED: No parallel switches found.")
641

642

643 1
    def report_missing_bus_indices(self):
644
        # message header
645 1
        if self.compact_report:
646 1
            logger.info("missing_bus_indices:")
647
        else:
648 1
            logger.info("Checking for missing bus indices...")
649 1
        logger.info("")
650 1
        if "missing_bus_indices" in self.diag_results:
651
            # message body
652 1
            diag_result = self.diag_results["missing_bus_indices"]
653 1
            element_counter = 0
654 1
            for element_type in diag_result:
655 1
                for element in diag_result[element_type]:
656 1
                    element_counter += 1
657 1
                    logger.warning("%s %s: %s (%s) not in net.bus.index" % (element_type,
658
                                                                            element[0], element[1], element[2]))
659

660
                    # message summary
661 1
            if not self.compact_report:
662 1
                logger.warning("")
663 1
                logger.warning("SUMMARY: %s missing bus indices found." % element_counter)
664

665 1
        elif "missing_bus_indices" in self.diag_errors:
666 0
            logger.warning("Check for missing bus indices failed due to the following error:")
667 0
            logger.warning(self.diag_errors["missing_bus_indices"])
668
        else:
669 1
            logger.info("PASSED: No missing bus indices found.")

Read our documentation on viewing source code .

Loading