MCPcopy Index your code
hub / github.com/numpy/numpy / format_float_scientific

Function format_float_scientific

numpy/_core/arrayprint.py:1140–1217  ·  view source on GitHub ↗

Format a floating-point scalar as a decimal string in scientific 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, trim='k',
                            sign=False, pad_left=None, exp_digits=None,
                            min_digits=None)

Source from the content-addressed store, hash-verified

1138
1139@set_module('numpy')
1140def format_float_scientific(x, precision=None, unique=True, trim='k',
1141 sign=False, pad_left=None, exp_digits=None,
1142 min_digits=None):
1143 """
1144 Format a floating-point scalar as a decimal string in scientific notation.
1145
1146 Provides control over rounding, trimming and padding. Uses and assumes
1147 IEEE unbiased rounding. Uses the "Dragon4" algorithm.
1148
1149 Parameters
1150 ----------
1151 x : python float or numpy floating scalar
1152 Value to format.
1153 precision : non-negative integer or None, optional
1154 Maximum number of digits to print. May be None if `unique` is
1155 `True`, but must be an integer if unique is `False`.
1156 unique : boolean, optional
1157 If `True`, use a digit-generation strategy which gives the shortest
1158 representation which uniquely identifies the floating-point number from
1159 other values of the same type, by judicious rounding. If `precision`
1160 is given fewer digits than necessary can be printed. If `min_digits`
1161 is given more can be printed, in which cases the last digit is rounded
1162 with unbiased rounding.
1163 If `False`, digits are generated as if printing an infinite-precision
1164 value and stopping after `precision` digits, rounding the remaining
1165 value with unbiased rounding
1166 trim : one of 'k', '.', '0', '-', optional
1167 Controls post-processing trimming of trailing digits, as follows:
1168
1169 * 'k' : keep trailing zeros, keep decimal point (no trimming)
1170 * '.' : trim all trailing zeros, leave decimal point
1171 * '0' : trim all but the zero before the decimal point. Insert the
1172 zero if it is missing.
1173 * '-' : trim trailing zeros and any trailing decimal point
1174 sign : boolean, optional
1175 Whether to show the sign for positive values.
1176 pad_left : non-negative integer, optional
1177 Pad the left side of the string with whitespace until at least that
1178 many characters are to the left of the decimal point.
1179 exp_digits : non-negative integer, optional
1180 Pad the exponent with zeros until it contains at least this
1181 many digits. If omitted, the exponent will be at least 2 digits.
1182 min_digits : non-negative integer or None, optional
1183 Minimum number of digits to print. This only has an effect for
1184 `unique=True`. In that case more digits than necessary to uniquely
1185 identify the value may be printed and rounded unbiased.
1186
1187 .. versionadded:: 1.21.0
1188
1189 Returns
1190 -------
1191 rep : string
1192 The string representation of the floating point value
1193
1194 See Also
1195 --------
1196 format_float_positional
1197

Callers

nothing calls this directly

Calls 1

_none_or_positive_argFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…