Skip to content

Commit fddd618

Browse files
Adapt to rounding error fiy in hepunits 2.4.0 (#700)
1 parent 9f2efc5 commit fddd618

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

docs/CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Changelog
22
=========
33

4+
Version 0.26.0
5+
--------------
6+
7+
In preparation.
8+
9+
- Dependencies:
10+
- hepunits >= 2.4.0.
11+
- Miscellaneous:
12+
- Dropped support for Python 3.8.
13+
- CI and tests:
14+
- Updates to pre-commit hooks and CI YAML files.
15+
416
Version 0.25.4
517
--------------
618

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ classifiers = [
4141
]
4242
dependencies = [
4343
"attrs>=19.2",
44-
"hepunits>=2.0.0",
44+
"hepunits>=2.4.0",
4545
"importlib-resources>=2.0;python_version<\"3.9\"",
4646
"typing-extensions>=4.5;python_version<\"3.13\"",
4747
]

src/particle/particle/kinematics.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,20 @@ def width_to_lifetime(Gamma: float) -> float:
3333
Manipulation with no explicit usage of units:
3434
3535
>>> width_to_lifetime(4.33e-10) # result returned in ns
36-
0.0015201199929582136
36+
0.0015201199929582138
3737
3838
Manipulations with explicit units defined in the HEP system of units:
3939
4040
>>> from hepunits.units import MeV, eV, ps # handy module with units in the HEP system of units
4141
>>>
4242
>>> width_to_lifetime(4.33e-10*MeV) # result returned in ns
43-
0.0015201199929582136
43+
0.0015201199929582138
4444
>>>
4545
>>> width_to_lifetime(4.33e-4*eV) # result again returned in ns
46-
0.0015201199929582136
46+
0.0015201199929582138
4747
>>>
4848
>>> width_to_lifetime(4.33e-10*MeV)/ps # result converted to ps
49-
1.5201199929582137
49+
1.5201199929582139
5050
"""
5151

5252
if Gamma < 0.0:
@@ -78,20 +78,20 @@ def lifetime_to_width(tau: float) -> float:
7878
--------
7979
Manipulation with no explicit usage of units:
8080
81-
>>> lifetime_to_width(0.0015201199929582136) # result returned in MeV
81+
>>> lifetime_to_width(0.0015201199929582138) # result returned in MeV
8282
4.33e-10
8383
8484
Manipulations with explicit units defined in the HEP system of units:
8585
8686
>>> from hepunits.units import MeV, eV, ps # handy module with units in the HEP system of units
8787
>>>
88-
>>> lifetime_to_width(0.0015201199929582136*ns) # result returned in MeV
88+
>>> lifetime_to_width(0.0015201199929582138*ns) # result returned in MeV
8989
4.33e-10
9090
>>>
91-
>>> lifetime_to_width(1.5201199929582137*ps) # result again returned in MeV
91+
>>> lifetime_to_width(1.5201199929582138*ps) # result again returned in MeV
9292
4.33e-10
9393
>>>
94-
>>> lifetime_to_width(1.5201199929582137*ps)/eV # result converted to eV
94+
>>> lifetime_to_width(1.5201199929582138*ps)/eV # result converted to eV
9595
0.000433
9696
"""
9797

0 commit comments

Comments
 (0)