Skip to content
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

84 add enums for all scenario input names #85

Merged
merged 14 commits into from
Jul 18, 2024

Conversation

ahobeost
Copy link
Contributor

No description provided.

@ahobeost ahobeost linked an issue Jul 18, 2024 that may be closed by this pull request
@@ -183,7 +183,7 @@ def _maybeCreateDiagrams(arguments):
return

diagramsFormat = arguments.diagramsFormat if arguments.diagramsFormat else "pdf"
cmd = f"{_SCRIPTS_DIR / 'pyreverse'} -k -o {diagramsFormat} -p optihood -d test-results optihood"
cmd = f"{_SCRIPTS_DIR / 'pyreverse'} -o {diagramsFormat} -p optihood -d test-results optihood"
_printAndRun(cmd.split())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pyreverse ignores class attributes and methods when "-k" is used.
The new implementation thus provides better feedback.

}
return nodes_data

@staticmethod
def get_values_from_dataframe(df: pd.DataFrame, identifier: str, identifier_column: str, desired_column: str):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very common implementation in this part.
Putting it into a function should make this part more readable.

electricityCost = nodesData["commodity_sources"].loc[nodesData["commodity_sources"]["label"] == "electricityResource", "variable costs"].iloc[0]
demandProfilesPath = nodesData["profiles"].loc[nodesData["profiles"]["name"] == "demand_profiles", "path"].iloc[0]
weatherDataPath = nodesData["profiles"].loc[nodesData["profiles"]["name"] == "weather_data", "path"].iloc[0]
electricityImpact = self.get_values_from_dataframe(nodesData[_ent.NodeKeys.commodity_sources.value], _ent.CommoditySourceTypes.electricityResource.value, _ent.CommoditySourcesLabels.label.value, _ent.CommoditySourcesLabels.CO2_impact.value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First try of using the enums in the main code.
Currently this is very verbose.
Before using this throughout, we should discuss other options.

@@ -23,3 +23,215 @@ class CsvInputFilePathsRelative(_enum.StrEnum):
storages = "storages.csv"
stratified_storage = "stratified_storage.csv"
profiles = "profiles.csv"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These entities are important for another project, where we will automatically be writing a lot of scenario files.



class BusesLabels(_enum.StrEnum):
label = "label"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is quite a bit of repetition here.
Perhaps, these can be combined somehow.

@ahobeost ahobeost merged commit c171ef8 into main Jul 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add enums for all scenario input names
1 participant