physpyx 2.2.0__tar.gz → 2.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: physpyx
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: Provides a way to use python code in LaTeX
5
5
  Author: Jérôme Dufour
6
6
  Author-email: Jérôme Dufour <jerome.dufour@eduvaud.ch>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "physpyx"
3
- version = "2.2.0"
3
+ version = "2.2.1"
4
4
  authors = [
5
5
  { name="Jérôme Dufour", email="jerome.dufour@eduvaud.ch" },
6
6
  ]
@@ -1,6 +1,7 @@
1
1
  from .astronomy import Orbit
2
+ from .context import NuclearContext
2
3
  from .nuclide import NuclideTable
3
4
  from .physpyx import PhysPyX
4
5
  from .qty import Qty
5
6
 
6
- __all__ = ["NuclideTable", "PhysPyX", "Qty", "Orbit"]
7
+ __all__ = ["NuclideTable", "NuclearContext", "Orbit", "PhysPyX", "Qty"]
@@ -7,7 +7,7 @@ class SiunitxContext(Context):
7
7
 
8
8
 
9
9
  class NuclearContext(SiunitxContext):
10
- def __init__(self, mass_is_amu: bool = True):
10
+ def __init__(self, preferred_units: bool = True):
11
11
  super().__init__("nuclear")
12
12
  self.add_transformation(
13
13
  "[mass]",
@@ -20,5 +20,16 @@ class NuclearContext(SiunitxContext):
20
20
  lambda ureg, x: x / ureg.speed_of_light / ureg.speed_of_light,
21
21
  )
22
22
  self.preferred_units = (
23
- {UnitsContainer({"[mass]": 1}): "amu"} if mass_is_amu else {}
23
+ {
24
+ UnitsContainer({"[mass]": 1}): "amu",
25
+ UnitsContainer(
26
+ {
27
+ "[mass]": 1,
28
+ "[length]": 2,
29
+ "[time]": -2,
30
+ }
31
+ ): "megaelectronvolt",
32
+ }
33
+ if preferred_units
34
+ else {}
24
35
  )
@@ -146,6 +146,11 @@ class SiunitxQuantity(Quantity):
146
146
  # "PlainQuantity[Unknown]"'
147
147
  return cast(SiunitxQuantity, super().__neg__())
148
148
 
149
+ def __add__(self, other: object) -> "SiunitxQuantity":
150
+ # NOTE: to fix typing warning 'Cannot access attribute "???" for class
151
+ # "PlainQuantity[Unknown]"'
152
+ return cast(SiunitxQuantity, super().__add__(other))
153
+
149
154
  def _format_unit(self) -> str:
150
155
  num = ""
151
156
  den = ""
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes