|
| 1 | +from cmath import inf |
1 | 2 | import enum
|
2 | 3 | from RFEM.initModel import Model
|
3 | 4 | from RFEM.enums import CaseObjectType
|
| 5 | +from RFEM.dataTypes import inf |
4 | 6 |
|
5 | 7 | # We can't extract lines with description: Extremes, Total, and Average. Those are language dependent.
|
6 | 8 | # To do it set_settings_program_language() has to be called before calculation and the program needs to be restarted.
|
@@ -78,6 +80,46 @@ def ConvertResultsToListOfDct(results, includeBase = False):
|
78 | 80 |
|
79 | 81 | return lstOfDct
|
80 | 82 |
|
| 83 | +def GetMinValue(structured_results, parameter): |
| 84 | + |
| 85 | + ''' |
| 86 | + Args: |
| 87 | + structured_results(list of dicts): Result of ConvertResultsToListOfDct() function |
| 88 | + parameter(str, mandatory): The parameter for which the minimum is sought. |
| 89 | + ''' |
| 90 | + |
| 91 | + min_val = inf |
| 92 | + for i in structured_results: |
| 93 | + # Sometimes there is text where the float should be |
| 94 | + try: |
| 95 | + min_val = min(float(i[parameter]), min_val) |
| 96 | + except: |
| 97 | + pass |
| 98 | + |
| 99 | + assert min_val < inf, 'Check if the parameter is in the table.' |
| 100 | + |
| 101 | + return min_val |
| 102 | + |
| 103 | +def GetMaxValue(structured_results, parameter): |
| 104 | + |
| 105 | + ''' |
| 106 | + Args: |
| 107 | + structured_results(list of dicts): Result of ConvertResultsToListOfDct() function |
| 108 | + parameter(str, mandatory): The parameter for which the maximum is sought. |
| 109 | + ''' |
| 110 | + |
| 111 | + max_val = -inf |
| 112 | + for i in structured_results: |
| 113 | + # Sometimes there is text where the float should be |
| 114 | + try: |
| 115 | + max_val = max(float(i[parameter]), max_val) |
| 116 | + except: |
| 117 | + pass |
| 118 | + |
| 119 | + assert max_val > -inf, 'Check if the parameter is in the table.' |
| 120 | + |
| 121 | + return max_val |
| 122 | + |
81 | 123 | class ResultTables():
|
82 | 124 |
|
83 | 125 | @staticmethod
|
|
0 commit comments