Skip to content

Conversation

@nsmith-
Copy link
Member

@nsmith- nsmith- commented Sep 23, 2025

Closes #262

Example usage:

import pint

from hepunits.pint import to_clhep

ureg = pint.UnitRegistry()
vacuum_impedance = (
    (1 * ureg.vacuum_permeability / ureg.vacuum_permittivity) ** 0.5
).to(ureg.ohm)
print(f"Vacuum impedance: {vacuum_impedance}")
print(f"In CLHEP units: {to_clhep(vacuum_impedance)}")

resulting in

Vacuum impedance: 376.73031341191023 ohm
In CLHEP units: 6.035885054680593e-14

@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2025

Codecov Report

❌ Patch coverage is 86.95652% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 98.67%. Comparing base (6804332) to head (c2dbec1).

Files with missing lines Patch % Lines
src/hepunits/pint.py 86.95% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##              main     #273      +/-   ##
===========================================
- Coverage   100.00%   98.67%   -1.33%     
===========================================
  Files            6        7       +1     
  Lines          278      301      +23     
===========================================
+ Hits           278      297      +19     
- Misses           0        4       +4     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eduardo-rodrigues
Copy link
Member

Many thanks 👍! I will review this properly tomorrow.

@eduardo-rodrigues eduardo-rodrigues added the enhancement New feature or request label Sep 24, 2025
Copy link
Member

@eduardo-rodrigues eduardo-rodrigues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great. Many thanks.

I added a couple of examples of usage.

It will be useful to update the README with a subsection on "Conversions to/from Pint" (or alike) at the bottom so that people realise this new functionality exists. See if you have a nice example to add or else we follow it up in a new PR.

@nsmith-
Copy link
Member Author

nsmith- commented Sep 24, 2025

Ok I added a section to the README

@eduardo-rodrigues eduardo-rodrigues merged commit 1b2cdee into scikit-hep:main Sep 24, 2025
8 checks passed
@eduardo-rodrigues
Copy link
Member

I already made a release, https://github.com/scikit-hep/hepunits/releases/tag/v2.4.0, in case you have use cases already for your work.

@nsmith-
Copy link
Member Author

nsmith- commented Sep 24, 2025

Thanks, I likely will be using it!

@nsmith- nsmith- deleted the pint branch September 24, 2025 16:19
bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Oct 11, 2025
https://build.opensuse.org/request/show/1310617
by user dirkmueller + dimstar_suse
- update to 2.4.2:
  * Add more subunits and unit aliases
- update to 2.4.1:
  * Add new SI prefixes from 2022
  * fix: Use the correct unit registry in pint
- update to 2.4.0:
  * Introduced integration with the `Pint` package for unit
    conversions (scikit-hep/hepunits#273)
- update to 2.3.6:
  * Several new units (notably for electromagnetism) added.
- update to 2.3.5:
  * Added support for 3.13.
- update to 2.3.4:
  * Dropped support for Python 3.7 and added support for 3.12.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Casting to and from pint quantities

3 participants