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

Added units submodule for working with units and quantities defined in ontologies #324

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

jesper-friis
Copy link
Contributor

@jesper-friis jesper-friis commented Feb 12, 2025

Description

Added a new units submodule for working with units and quantities defined in ontologies.

The module provides support to populate a Pint units definition file from EMMO. It also subclasses pint.UnitRegistry, pint.Uni, and pint.Quantity, enhancing them with knowledge from the ontology.

Currently it only supports EMMO as source. But it utilises the references to QUDT and OM such that it is possible to work with IRIs to these ontologies as well.

The PR includes tests and documentation.

Other fixes:

  • Silence warning from doctest in literal.py
  • More informative error message from Triplestore.value()
  • Corrected type annotation of Triplestore.restrictions()
  • Made AttrDict pickleable
  • Run mkdocs and other tools on GitHub with Python 3.11, since it Python 3.9 doesn't understand TypeAlias

Follow-up tasks

  • Allow to update the unit registry from domain or application ontologies.
  • Represent quantities the same way as units. The Quantity subclass should know about the ontological IRI corresponding to a Pint Quantity.
  • Given IRI to a quantity in the KB, represent it as a Quantity object.
  • Store a Quantity object to KB.
  • Add physical constants from the ontology.

Type of change

  • Bug fix and code cleanup
  • New feature
  • Documentation update
  • Testing

Checklist for the reviewer

This checklist should be used as a help for the reviewer.

  • Is the change limited to one issue?
  • Does this PR close the issue?
  • Is the code easy to read and understand?
  • Do all new feature have an accompanying new test?
  • Has the documentation been updated as necessary?
  • Is the code properly tested?

Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 83.25991% with 38 lines in your changes missing coverage. Please review.

Project coverage is 77.37%. Comparing base (4fc872f) to head (b4cc37a).

Files with missing lines Patch % Lines
tripper/units/units.py 82.80% 38 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #324      +/-   ##
==========================================
+ Coverage   76.83%   77.37%   +0.53%     
==========================================
  Files          22       24       +2     
  Lines        2491     2718     +227     
==========================================
+ Hits         1914     2103     +189     
- Misses        577      615      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jesper-friis jesper-friis removed the request for review from francescalb February 13, 2025 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant