Skip to content

Commit

Permalink
refactor: directly access the methods instead of using getattr for …
Browse files Browse the repository at this point in the history
…maintainability
  • Loading branch information
laurent-laporte-pro committed Jul 18, 2023
1 parent 310dab2 commit 90c9747
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,15 @@ def register_matrix(
# use an already-registered default matrix
constants: GeneratorMatrixConstants
constants = values["command_context"].generator_matrix_constants
method_name = f"get_st_storage_{field.name}"
method = getattr(constants, method_name)
# Directly access the methods instead of using `getattr` for maintainability
methods = {
"pmax_injection": constants.get_st_storage_pmax_injection,
"pmax_withdrawal": constants.get_st_storage_pmax_withdrawal,
"lower_rule_curve": constants.get_st_storage_lower_rule_curve,
"upper_rule_curve": constants.get_st_storage_upper_rule_curve,
"inflows": constants.get_st_storage_inflows,
}
method = methods[field.name]
return cast(str, method())
if isinstance(v, str):
# Check the matrix link
Expand Down

0 comments on commit 90c9747

Please sign in to comment.