-
Notifications
You must be signed in to change notification settings - Fork 8
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
Added Standard methods to Ontology #246
Added Standard methods to Ontology #246
Conversation
It now works, but only when the test includes checking for classes and base_iri of the ontology. The test does not include properties.
Preffered is hash on iri, second, try prefLabel, third try name fourth try label
everything except annotation_properties and Individuals
08cc67d
to
3fa0e52
Compare
Note that consistency of blank nodes is not checked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking great. I have only some minor code optimizations and a more significant question concerning the _sorted_entities()
method.
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
Why? I guess changing s to subject, p to predicate and o to obj can be done, but spo is quite standard when looking at triples I think. Then, doing the _unabreviate in the yield, do wish for that because it is faster or just because you think it is prettier? If it is faster I agree, but otherwise I am not a super fan of compacting code all the time, as it is more difficult to read for new people coming in I think. |
Single character variables is very bad practice when collaborating on code. In general, using single character variables is a leftover bad practice from programmers of compiled languages, where one wants to compact as much as possible, while it's uncommon multiple people get to work with the source code who's not deeply initiated in everything about the code base. For open code projects and general readability one should strive to be more explicit and forgiving with the number of characters used. As a note, this is something I've gone through and changed in the whole of the code base in #245 as well.
I am generally against creating unnecessary variables. return (
_unabbreviate(s),
_unabbreviate(p),
_unabbreviate(o),
) I think, in general you are correct to be a bit more explicit in the code in terms of middle-steps, however, in this case it's so simplistic there is no need for this, I should think? |
Co-authored-by: Casper Welzel Andersen <43357585+CasperWA@users.noreply.github.com>
OK, fixed. |
Took a look at the conversation above. I am not sure I fully agree that using one-letter is always bad practice. In general I agree that descriptive variable names are good, but sensible use one-letter variables makes the the lines shorter and the code easier to read. If you just need an integer variable in a loop, I think that |
The underscore is the accepted Pythonic way of defining un-used variables, specifically in the example you show above, but also in other cases, e.g., when a function returns a Triple type and all you need are one of those. I think exactly because they are single-character variables they are not easy to read, quite the contrary, it makes it impenetrable to understand, especially when the method or function names do not mention triples at all. I agree that single-character variables can be used as iterating variables. This is common practice across several programming languages - but for ease of readability I'd like to strongly support more descriptive variable names throughout the code base. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks excellent to me now :) Thank you @francescalb !
Everything said - we can always introduce our own standards for some variable naming, but I think it should be documented well then so there is a resource to go to if one is looking at this as a coder, but without an understanding of the content that's being worked with. |
This is all good for me. Let's discuss naming conventions perhaps in #245? As I'm doing a lot of different updates in the way of naming in that PR. |
Going through the code locally in my editor, I realize now you have overwritten the inherited |
The latest commit from #245 includes my suggested change/fix for this. |
You are right. That is not good at all. Your fix should be included. |
Great - I'll make an extra issue and PR for it and redact my other PR. |
Description:
Closes #228.
hash (based on base_iri) defined for ontology.Ontology (only req to allow for eq implementation)
eq (based on all triples) defined for ontology.Ontology. Note that consistency between blank nodes is not checked.
This is tested in test_load_emmo.py.
The test also checks that two equal emmo-ontologies are no longer equal when a new class or new relation is added to one of them.
Type of change:
Checklist:
This checklist can be used as a help for the reviewer.
Comments: