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

Unify format for all sectors #217

Closed
6 of 8 tasks
Jeniffere opened this issue Apr 19, 2022 · 6 comments · Fixed by #254 or #255
Closed
6 of 8 tasks

Unify format for all sectors #217

Jeniffere opened this issue Apr 19, 2022 · 6 comments · Fixed by #254 or #255
Assignees
Labels
good first issue Good for newcomers

Comments

@Jeniffere
Copy link
Collaborator

Jeniffere commented Apr 19, 2022

Refactoring to bring all sectors in a consistent form:

  • 1. Make every file # pyright: strict

  • 2. Remove empty dataclasses and all their references

@dataclass
class Vars0:
    # Used by g, g_storage, g_planning
    pass

@bgrundmann:

I think Empty and the corresponding member variables should just die. That requires running update_expectations once, but makes the code much nicer.

  • 3. remove unnecessary default values

@bgrundmann:

I mildly prefer to only (well mostly only) set default values for member variables if they get computed by post_init from other fields. That way one cannot accidentally forget to initialize one of the variables at the call sites.

  • 4. Make every possible dataclass @dataclass(kw_only=True)

  • 5. Put a comment on top of every sector with a link to the matching part in readthedocs

  • 6. Make the interface of each sector more visible by putting it into a separate file like:

i18.py:

@dataclass
class I18:
  • 7. Common structure to make the following tow steps explicit:

There are a lot of sectors which consume energy. All these sectors work in two steps:

  • calc energy demand / consum --> calc_energy_demand
  • split/divide the calculated demand into several energy sources --> calc_energy_sources

Idea: create one file for energy_demand.py and one file for energy_sources.py and call the two calc methods in the init of the sector.
See: industry2018
Todo: Talk about a good naming for the two steps.

  • 8. Unify imports

with the following rules:

  • use relative imports like ..utils instead of generatorcore.utils
  • sort imports: external imports, parent package imports (..), current package imports (.)
  • import concrete classes like this: from ..residences2018.r18 import R18
@Jeniffere Jeniffere added good first issue Good for newcomers question Further information is requested labels Apr 19, 2022
@Jeniffere
Copy link
Collaborator Author

@bgrundmann: feel free to add/update some ideas ;)

@bgrundmann
Copy link
Collaborator

I agree with all of these. To state the obvious right now none of these should touch Industry (because that would only cause merge failures).

@bgrundmann
Copy link
Collaborator

I agree with all of these. To state the obvious right now none of these should touch Industry (because that would only cause merge failures).

And now the changes in industry are merged and everybody should feel free to touch industry again ;-)

@Jeniffere
Copy link
Collaborator Author

Jeniffere commented Jun 20, 2022

I finished 6. (except energy2030)
See #239

@Jeniffere Jeniffere removed the question Further information is requested label Jun 24, 2022
@Jeniffere
Copy link
Collaborator Author

Jeniffere commented Jun 24, 2022

I started with 1.
See #242

Nearly all files are now pyright strict.

But there are a lot of type ignores. These should be removed in a next step ...

@Jeniffere
Copy link
Collaborator Author

  1. und 7. will be done in: Refactoring - Easy Top Level Structure for all sectors #294

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
2 participants