PhysicalConstant¶
-
class
sisl.constant.
PhysicalConstant
[source]¶ Class to create a physical constant with unit-conversion capability, works exactly like a float.
To change the units simply call it like a method with the desired unit:
>>> m = PhysicalConstant(1., 'm') >>> m.unit 'm' >>> m2nm = m('nm') >>> m2nm 1000000000.0 nm >>> m2nm.unit 'nm' >>> m2nm * 2 1000000000.0
Attributes
the imaginary part of a complex number
the real part of a complex number
Unit of constant
Methods
__init__
(self, /, \*args, \*\*kwargs)Initialize self.
Return a pair of integers, whose ratio is exactly equal to the original float and with a positive denominator.
Return self, the complex conjugate of any float.
fromhex
()Create a floating-point number from a hexadecimal string.
hex
()Return a hexadecimal representation of a floating-point number.
Return True if the float is an integer.
-
as_integer_ratio
() -> (int, int)¶ Return a pair of integers, whose ratio is exactly equal to the original float and with a positive denominator. Raise OverflowError on infinities and a ValueError on NaNs.
>>> (10.0).as_integer_ratio() (10, 1) >>> (0.0).as_integer_ratio() (0, 1) >>> (-.25).as_integer_ratio() (-1, 4)
-
conjugate
()¶ Return self, the complex conjugate of any float.
-
fromhex
()¶ Create a floating-point number from a hexadecimal string. >>> float.fromhex(‘0x1.ffffp10’) 2047.984375 >>> float.fromhex(‘-0x1p-1074’) -5e-324
-
hex
()¶ Return a hexadecimal representation of a floating-point number. >>> (-0.1).hex() ‘-0x1.999999999999ap-4’ >>> 3.14159.hex() ‘0x1.921f9f01b866ep+1’
-
imag
¶ the imaginary part of a complex number
-
is_integer
()¶ Return True if the float is an integer.
-
real
¶ the real part of a complex number
-
property
unit
¶ Unit of constant
-