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

Guard against methods-terms as sub-categories #89

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions definitions/variable/sdg-indicators/sdg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@
sdg: 2
unit: kcal/cap/day
weight: Population
- Price|Agriculture|Livestock|Index:
- Price|Agriculture|Livestock [Index]:
description: Weighted average price index of livestock
sdg: 2
unit: Index (2020 = 1)
skip-region-aggregation: true
# weight: Agricultural Production|Non-Energy
shape: Price|Agriculture|Livestock|Index
phackstock marked this conversation as resolved.
Show resolved Hide resolved
- Health|Premature Deaths|PM2.5:
description: Number of premature deaths associated with increased health risks from
exposure to air pollution of fine particles with a diameter of 2.5 μm or less (PM2.5)
Expand Down
17 changes: 17 additions & 0 deletions tests/test_reserved_terms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from nomenclature import DataStructureDefinition


def test_variable_ops_as_square_brackets():
phackstock marked this conversation as resolved.
Show resolved Hide resolved
# Check that variables use square brackets for operations
# https://github.com/IAMconsortium/common-definitions/issues/55

dsd = DataStructureDefinition("definitions/", dimensions=["variable"])

error = []
for variable, attrs in dsd.variable.items():
phackstock marked this conversation as resolved.
Show resolved Hide resolved
if reserved_terms := [r for r in ["Index", "Share"] if "|" + r in variable]:
error.append(f"Variable '{variable}' -> '[{''.join(reserved_terms)}]'")
if error:
raise ValueError(
f"Found reserved terms in the following variables:\n{'\n - '.join(error)}"
)
Loading