Format a floating-point scalar as a decimal string in positional notation. Provides control over rounding, trimming and padding. Uses and assumes IEEE unbiased rounding. Uses the "Dragon4" algorithm. Parameters ---------- x : python float or numpy floating scalar V
(x, precision=None, unique=True,
fractional=True, trim='k', sign=False,
pad_left=None, pad_right=None, min_digits=None)
| 1219 | |
| 1220 | @set_module('numpy') |
| 1221 | def format_float_positional(x, precision=None, unique=True, |
| 1222 | fractional=True, trim='k', sign=False, |
| 1223 | pad_left=None, pad_right=None, min_digits=None): |
| 1224 | """ |
| 1225 | Format a floating-point scalar as a decimal string in positional notation. |
| 1226 | |
| 1227 | Provides control over rounding, trimming and padding. Uses and assumes |
| 1228 | IEEE unbiased rounding. Uses the "Dragon4" algorithm. |
| 1229 | |
| 1230 | Parameters |
| 1231 | ---------- |
| 1232 | x : python float or numpy floating scalar |
| 1233 | Value to format. |
| 1234 | precision : non-negative integer or None, optional |
| 1235 | Maximum number of digits to print. May be None if `unique` is |
| 1236 | `True`, but must be an integer if unique is `False`. |
| 1237 | unique : boolean, optional |
| 1238 | If `True`, use a digit-generation strategy which gives the shortest |
| 1239 | representation which uniquely identifies the floating-point number from |
| 1240 | other values of the same type, by judicious rounding. If `precision` |
| 1241 | is given fewer digits than necessary can be printed, or if `min_digits` |
| 1242 | is given more can be printed, in which cases the last digit is rounded |
| 1243 | with unbiased rounding. |
| 1244 | If `False`, digits are generated as if printing an infinite-precision |
| 1245 | value and stopping after `precision` digits, rounding the remaining |
| 1246 | value with unbiased rounding |
| 1247 | fractional : boolean, optional |
| 1248 | If `True`, the cutoffs of `precision` and `min_digits` refer to the |
| 1249 | total number of digits after the decimal point, including leading |
| 1250 | zeros. |
| 1251 | If `False`, `precision` and `min_digits` refer to the total number of |
| 1252 | significant digits, before or after the decimal point, ignoring leading |
| 1253 | zeros. |
| 1254 | trim : one of 'k', '.', '0', '-', optional |
| 1255 | Controls post-processing trimming of trailing digits, as follows: |
| 1256 | |
| 1257 | * 'k' : keep trailing zeros, keep decimal point (no trimming) |
| 1258 | * '.' : trim all trailing zeros, leave decimal point |
| 1259 | * '0' : trim all but the zero before the decimal point. Insert the |
| 1260 | zero if it is missing. |
| 1261 | * '-' : trim trailing zeros and any trailing decimal point |
| 1262 | sign : boolean, optional |
| 1263 | Whether to show the sign for positive values. |
| 1264 | pad_left : non-negative integer, optional |
| 1265 | Pad the left side of the string with whitespace until at least that |
| 1266 | many characters are to the left of the decimal point. |
| 1267 | pad_right : non-negative integer, optional |
| 1268 | Pad the right side of the string with whitespace until at least that |
| 1269 | many characters are to the right of the decimal point. |
| 1270 | min_digits : non-negative integer or None, optional |
| 1271 | Minimum number of digits to print. Only has an effect if `unique=True` |
| 1272 | in which case additional digits past those necessary to uniquely |
| 1273 | identify the value may be printed, rounding the last additional digit. |
| 1274 | |
| 1275 | .. versionadded:: 1.21.0 |
| 1276 | |
| 1277 | Returns |
| 1278 | ------- |
nothing calls this directly
no test coverage detected
searching dependent graphs…