Comments (3)
Thanks Jan Ivar for that comment. Can you explain a bit further what your vision for the "working further in Python with the invalid items" actually is? I'm a bit worried that defining a usable return-type is not obvious...
Also, as you write yourself, getting the invalid items is only one-and-a-half lines of code, like
for dim in dimensions:
invalid = getattr(dsd, dim).validate_items(getattr(df, dim))
...
so you might as well include that line in your processing workflow rather than having to parse the returned object from a new validation-method.
from nomenclature.
Yes, that's what I would do for dimensions. But I had to search through the source code to find that solution. And it's not sufficient for checking variable/unit combos (see below).
A dedicated method would be more convenient for anyone who isn't already familiar with the codebase. For the dimensions, it could just return
{dim: getattr(dsd, dim).validate_items(getattr(df, dim)) for dim in dimensions}
I.e., the return type would be dict[str, str|int]
(although alternative value types might be needed for custom dimensions).
Checking variable/unit combinations, is less straight-forward. The core part of validation.validate
that performs that check is 12 lines long, and could be hard to come up with on your own without searching through the source code. It would be convenient to have a method that returns the variable invalid_units
that results from those lines, rather than keep it internal and raise an error.
It could either be a separate item in the dict returned by the method that checks individual dimensions (e.g., with key 'invalid_units'
. Or it could be returned by a separate method (e.g., .get_invalid_units
), to avoid introducing a custom key like that in the dict. In the latter case, the return type would be dict[str, str]
, with the keys being variable names and the values being unit names.
If you want, I can add the necessary code myself and submit a pull request (I would probably make a branch and do that for my own use anyway). But in that case it would be good to get your feedback on the solution I've sketched here.
from nomenclature.
I'd still be curious to better understand your intended use case.
But yes, happy to review a PR and provide feedback - please create a fork and tinker away...
from nomenclature.
Related Issues (20)
- Double stacking external repos does not work as expected HOT 1
- Nomenclature not compatible with latest version of black
- Using only country in nomenclature config breaks CodeList HOT 2
- Update to pyam 2.1 breaks test_aggregation_differences_export
- Multiple external repo docs are not up to date
- Allow attribute filtering in nomenclature.yaml for importing definitions form external repo HOT 4
- Version number slightly broken
- Export complete DataStructureDefinition to Excel HOT 1
- Setting of repository attribute slightly broken
- Exclude defaults when writing to yaml
- Show source file and line for duplicate items
- Enforce IAMC-conventions in project-validation
- Replace tags in attribute-lists HOT 1
- Add NUTS regions as an option HOT 1
- Nightly tests currently (April 23 2024) failing
- Add option to sort CodeLists
- Remove trailing whitespaces HOT 2
- Nightly tests failing because of legacy definitions update
- Document model mapping conversion from Excel to YAML
- Add CLI option to run workflow file from command line HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nomenclature.