-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/check res table #848
Feat/check res table #848
Changes from 6 commits
8f674f6
e08b537
0ed716e
9ffd2a0
772cf00
2c2f02a
8a5458e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -333,3 +333,54 @@ def wrapper(*args, **kwargs): | |
func(*args, **kwargs) | ||
|
||
return wrapper | ||
|
||
|
||
# Function to build main | ||
def check_res_table(row_names=None, simulation_res=None, target_res=None): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If these parameters are always required, then should be using arg and not kwarg. |
||
|
||
# If someone did not identify inputs at all, | ||
# it represents default data frame example. | ||
if row_names is None: | ||
print("No Inputs") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't print, raise:
|
||
row_names = ["row1", "row2"] | ||
simulation_res = [1, 2] | ||
target_res = [10, 20] | ||
|
||
# If the quantity of the rows does not equal to the quantity. | ||
if len(row_names) != len(target_res) or len(row_names) != len(target_res): | ||
raise TypeError("Not the same quantity of the rows and filled data") | ||
|
||
# Import Pandas and Numpy. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to top, specify why you're doing a lazy import. |
||
import pandas as pd | ||
|
||
# Define column names with corresponding inputs. | ||
main_columns = { | ||
"Target": target_res, | ||
"Mechanical APDL": simulation_res, | ||
"Ratio": list(np.divide(simulation_res, target_res)) | ||
} | ||
|
||
# Create a Data Frame with Pandas. | ||
df = pd.DataFrame(main_columns, index=row_names) | ||
|
||
# Define setting of the Data Frame Style. | ||
df2 = df.style.set_table_styles([ | ||
{ | ||
"selector": "th", | ||
"props": [('font-size', '16px')] | ||
}, | ||
{ | ||
"selector": "td", | ||
"props": [('font-size', '16px')] | ||
}, | ||
{ | ||
"selector": "td:hover", | ||
"props": [("background-color", "#FFF8DC")] | ||
}], | ||
).set_properties(** | ||
{ | ||
"color": "black", | ||
"text-align": "center" | ||
}).format("{:.2f}") | ||
|
||
return df2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add docstring here.