generated from iiasa/scse-workflow-template
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guard against methods-terms as sub-category in variable name (#89)
- Loading branch information
1 parent
836c3fe
commit f582737
Showing
3 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from nomenclature import DataStructureDefinition | ||
|
||
RESERVED_TERMS = ["Index", "Share", "Value", "Volume"] | ||
|
||
|
||
# TODO: Move this test to the nomenclature `validate-project` utility | ||
# see https://github.com/IAMconsortium/nomenclature/issues/341 | ||
|
||
|
||
def test_variable_ops_as_square_brackets(): | ||
# Check that variables use square brackets for operations | ||
# https://github.com/IAMconsortium/common-definitions/issues/55 | ||
|
||
dsd = DataStructureDefinition("definitions/", dimensions=["variable"]) | ||
|
||
error = [] | ||
for variable in dsd.variable: | ||
if reserved_terms := [r for r in RESERVED_TERMS 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)}" | ||
) |