11"""Metrology APIs.""" 
22
3- from  typing  import  Final , Protocol , Self , override , runtime_checkable 
3+ from  typing  import  TYPE_CHECKING ,  Final , Protocol , Self , override , runtime_checkable 
44
55import  optype  as  op 
66
7+ if  TYPE_CHECKING :
8+     import  fractions 
9+ 
10+ 
711__version__ : Final  =  "0.0.1.dev0" 
812__all__  =  ["__version__" , "Dimension" , "Quantity" , "Unit" ]
913
@@ -17,6 +21,31 @@ def __pow__(self, other: int, /) -> Self: ...
1721    def  __rmul__ (self , other : Self , / ) ->  Self : ...
1822    def  __rtruediv__ (self , other : Self , / ) ->  Self : ...
1923
24+     def  decompose (self ) ->  "dict[Dimension, int | fractions.Fraction]" :
25+         """ 
26+         Decompose the dimension into its base dimensions and exponents. 
27+ 
28+         Notes 
29+         ----- 
30+         By far the most common dimension system is (Length, Mass, Time, Electric 
31+         Current, Temperature, Amount of Substance, Luminous Intensity). 
32+         This method will decompose the dimension into a dictionary of these 
33+         base dimensions and their respective exponents. 
34+ 
35+         Examples 
36+         -------- 
37+         As this is an API protocol, no runtime examples are possible. The 
38+         following is an illustrative example: 
39+ 
40+         >>> import metrology as u 
41+ 
42+         >>> dim = u.Length / u.Time 
43+ 
44+         >>> dim.decompose() 
45+         {Length: 1, Time: -1} 
46+         """ 
47+         ...
48+ 
2049
2150@runtime_checkable  
2251class  Unit (Protocol ):
0 commit comments