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

[Style] Check db_creator.py for consistent style #30

Open
samgdotson opened this issue Sep 29, 2021 · 0 comments
Open

[Style] Check db_creator.py for consistent style #30

samgdotson opened this issue Sep 29, 2021 · 0 comments
Labels
Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:1-Beginner This issue does not require expert knowledge and may be a good issue for new contributors. Priority:4-Low This work is valuable, but not urgent or mission critical. Type:Style Is related to coding style guide compliance (e.g. PEP8 or google C++ style guide). Type:Test Is related to software testing. Failing tests, necessary new tests, test frameworks, etc.

Comments

@samgdotson
Copy link
Collaborator

The db_creator file should be checked for consistent style. For example, some functions that depend on regions will loop through tech.regions rather than the keys of the particular parameter.

# this will break if the place key doesn't exist.
for tech in tech_list:
    for place in tech.regions:
        data = tech.max_capacity[place]

However, not all technologies have data for ALL places. I.e. Place 1 might have a capacity limit, but Place 2 does not. In which case, trying to call tech.max_capacity[place] would break the database creation. In some cases, there is a try/except block that attempts to access the data if it exists, otherwise it skips. There is an easier way to do this however, and that is to loop through the keys of the dictionary tech.max_capacity.

# This is guaranteed to work without a try/except.
for tech in tech_list:
    for place in list(tech.max_capacity.keys()):
        data = tech.max_capacity[place]

That is one example where code should be made consistent throughout the module. There are sure to be others.

This issue should be resolved using Open Development practices.

@samgdotson samgdotson added Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:1-Beginner This issue does not require expert knowledge and may be a good issue for new contributors. Priority:4-Low This work is valuable, but not urgent or mission critical. Type:Style Is related to coding style guide compliance (e.g. PEP8 or google C++ style guide). Type:Test Is related to software testing. Failing tests, necessary new tests, test frameworks, etc. labels Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Comp:Core This issue has to do with the main bulk of the code or document. (methods, main content) Difficulty:1-Beginner This issue does not require expert knowledge and may be a good issue for new contributors. Priority:4-Low This work is valuable, but not urgent or mission critical. Type:Style Is related to coding style guide compliance (e.g. PEP8 or google C++ style guide). Type:Test Is related to software testing. Failing tests, necessary new tests, test frameworks, etc.
Projects
None yet
Development

No branches or pull requests

1 participant