|
34 | 34 | This module provides public type interface file for the library
|
35 | 35 | """
|
36 | 36 |
|
| 37 | +import dpctl.tensor as dpt |
37 | 38 | import numpy
|
38 | 39 |
|
| 40 | +from dpnp.dpnp_array import dpnp_array |
| 41 | + |
39 | 42 | __all__ = [
|
40 | 43 | "bool",
|
41 | 44 | "bool_",
|
|
50 | 53 | "dtype",
|
51 | 54 | "e",
|
52 | 55 | "euler_gamma",
|
| 56 | + "finfo", |
53 | 57 | "float",
|
54 | 58 | "float_",
|
55 | 59 | "float16",
|
56 | 60 | "float32",
|
57 | 61 | "float64",
|
58 | 62 | "floating",
|
| 63 | + "iinfo", |
59 | 64 | "inexact",
|
60 | 65 | "Inf",
|
61 | 66 | "inf",
|
|
140 | 145 | PZERO = numpy.PZERO
|
141 | 146 |
|
142 | 147 |
|
| 148 | +def finfo(dtype): |
| 149 | + """ |
| 150 | + Returns machine limits for floating-point data types. |
| 151 | +
|
| 152 | + For full documentation refer to :obj:`numpy.finfo`. |
| 153 | +
|
| 154 | + Parameters |
| 155 | + ---------- |
| 156 | + dtype : dtype, dpnp_array |
| 157 | + Floating-point dtype or an array with floating point data type. |
| 158 | + If complex, the information is about its component data type. |
| 159 | +
|
| 160 | + Returns |
| 161 | + ------- |
| 162 | + out : finfo_object |
| 163 | + An object have the following attributes |
| 164 | + * bits: int |
| 165 | + number of bits occupied by dtype. |
| 166 | + * dtype: dtype |
| 167 | + real-valued floating-point data type. |
| 168 | + * eps: float |
| 169 | + difference between 1.0 and the next smallest representable |
| 170 | + real-valued floating-point number larger than 1.0 according |
| 171 | + to the IEEE-754 standard. |
| 172 | + * epsneg: float |
| 173 | + difference between 1.0 and the next smallest representable real-valued |
| 174 | + floating-point number smaller than 1.0 according to the IEEE-754 |
| 175 | + standard. |
| 176 | + * max: float |
| 177 | + largest representable real-valued number. |
| 178 | + * min: float |
| 179 | + smallest representable real-valued number. |
| 180 | + * precision: float |
| 181 | + the approximate number of decimal digits to which this kind of |
| 182 | + floating point type is precise. |
| 183 | + * resolution: float |
| 184 | + the approximate decimal resolution of this type. |
| 185 | + * tiny: float |
| 186 | + an alias for `smallest_normal` |
| 187 | + * smallest_normal: float |
| 188 | + smallest positive real-valued floating-point number with |
| 189 | + full precision. |
| 190 | +
|
| 191 | + """ |
| 192 | + if isinstance(dtype, dpnp_array): |
| 193 | + dtype = dtype.dtype |
| 194 | + return dpt.finfo(dtype) |
| 195 | + |
| 196 | + |
| 197 | +def iinfo(dtype): |
| 198 | + """ |
| 199 | + Returns machine limits for integer data types. |
| 200 | +
|
| 201 | + For full documentation refer to :obj:`numpy.iinfo`. |
| 202 | +
|
| 203 | + Parameters |
| 204 | + ---------- |
| 205 | + dtype : dtype, dpnp_array |
| 206 | + Integer dtype or an array with integer dtype. |
| 207 | +
|
| 208 | + Returns |
| 209 | + ------- |
| 210 | + out : iinfo_object |
| 211 | + An object with the following attributes |
| 212 | + * bits: int |
| 213 | + number of bits occupied by the data type |
| 214 | + * dtype: dtype |
| 215 | + integer data type. |
| 216 | + * max: int |
| 217 | + largest representable number. |
| 218 | + * min: int |
| 219 | + smallest representable number. |
| 220 | +
|
| 221 | + """ |
| 222 | + if isinstance(dtype, dpnp_array): |
| 223 | + dtype = dtype.dtype |
| 224 | + return dpt.iinfo(dtype) |
| 225 | + |
| 226 | + |
143 | 227 | def isscalar(obj):
|
144 | 228 | """
|
145 | 229 | Returns True if the type of `obj` is a scalar type.
|
|
0 commit comments