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

Exclude defaults for yaml export #247

Conversation

phackstock
Copy link
Contributor

closes #231.

Fixed the issue with a couple of additional changes

Additional changes implemented

  • Code and CodeList now feature __eq__ methods which makes for easier comparisons for tests. For the equality operator of Code I explicitly exclude the file property as it does not influence functionality.
  • Code.file is now a named attribute.
  • Streamlined a few unit test accordingly.

Open question

There is one case which is currently not covered very nicely which concerns the create_yaml_from_xlsx function.
Say we have an excel like this:

Variable Description Unit Region-aggregation
Primary Energy Total primary energy consumption EJ/yr [{"Primary Energy (mean)": {"method": "mean"}}]
Primary Energy (mean) Mean primary energy consumption EJ/yr
Share|Coal Share of coal in the total primary energy mix

this will be translated into the following yaml:

- Primary Energy:
    description: Total primary energy consumption
    unit: EJ/yr
    region-aggregation:
      - Primary Energy (mean):
          method: mean
- Primary Energy (mean):
    description: Mean primary energy consumption
    unit: EJ/yr
    region-aggregation:
- Share|Coal:
    description: Share of coal in the total primary energy mix
    unit:
    region-aggregation:

The issue is that Primary Energy (mean) and Share|Coal both feature an empty region-aggregation attribute since the column exists in the excel and the values for those two variables are None.
I don't think that there is a way from distinguishing this unintentional None from the intentional one for Share|Coal unit.
Functionality wise this does not change anything though.

I don't think that there's much we can do here, just wanted to point it out.

@phackstock phackstock added the bug Something isn't working label May 10, 2023
@phackstock phackstock self-assigned this May 10, 2023
Copy link
Member

@danielhuppmann danielhuppmann left a comment

Choose a reason for hiding this comment

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

Nice, thank you!

@danielhuppmann
Copy link
Member

I don't think that there is a way from distinguishing this unintentional None from the intentional one for Share|Coal unit.

Don't think that this is an issue, but thanks for thinking it through carefully!

@phackstock phackstock force-pushed the feature/exclude-defaults-for-yaml-export branch from ca50527 to eb05307 Compare May 17, 2023 13:04
@phackstock phackstock merged commit be48466 into IAMconsortium:main May 17, 2023
@phackstock phackstock deleted the feature/exclude-defaults-for-yaml-export branch May 17, 2023 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default-attributes are exported to yaml
2 participants