Source code for pyxu.runtime

 1import enum
 2
 3import numpy as np
 4
 5import pyxu.info.ptype as pxt
 6
 7__all__ = [
 8    "Width",
 9    "CWidth",
10]
11
12
[docs] 13@enum.unique 14class Width(enum.Enum): 15 """ 16 Machine-dependent floating-point types. 17 """ 18 19 SINGLE = np.dtype(np.single) 20 DOUBLE = np.dtype(np.double) 21
[docs] 22 def eps(self) -> pxt.Real: 23 """ 24 Machine precision of a floating-point type. 25 26 Returns the difference between 1 and the next smallest representable float larger than 1. 27 """ 28 eps = np.finfo(self.value).eps 29 return float(eps)
30 31 @property 32 def complex(self) -> "CWidth": 33 """ 34 Returns precision-equivalent complex-valued type. 35 """ 36 return CWidth[self.name]
37 38
[docs] 39@enum.unique 40class CWidth(enum.Enum): 41 """ 42 Machine-dependent complex-valued floating-point types. 43 """ 44 45 SINGLE = np.dtype(np.csingle) 46 DOUBLE = np.dtype(np.cdouble) 47 48 @property 49 def real(self) -> "Width": 50 """ 51 Returns precision-equivalent real-valued type. 52 """ 53 return Width[self.name]