* Prints floating-point scalars using the Dragon4 algorithm, positional mode. * See docstring of `np.format_float_positional` for description of arguments. * The differences is that a value of -1 is valid for pad_left, pad_right, * precision, which is equivalent to `None`. */
| 3861 | * precision, which is equivalent to `None`. |
| 3862 | */ |
| 3863 | static PyObject * |
| 3864 | dragon4_positional(PyObject *NPY_UNUSED(dummy), |
| 3865 | PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames) |
| 3866 | { |
| 3867 | PyObject *obj; |
| 3868 | int precision=-1, pad_left=-1, pad_right=-1, min_digits=-1; |
| 3869 | CutoffMode cutoff_mode; |
| 3870 | DigitMode digit_mode; |
| 3871 | TrimMode trim = TrimMode_None; |
| 3872 | int sign=0, unique=1, fractional=0; |
| 3873 | NPY_PREPARE_ARGPARSER; |
| 3874 | |
| 3875 | if (npy_parse_arguments("dragon4_positional", args, len_args, kwnames, |
| 3876 | "x", NULL , &obj, |
| 3877 | "|precision", &PyArray_PythonPyIntFromInt, &precision, |
| 3878 | "|unique", &PyArray_PythonPyIntFromInt, &unique, |
| 3879 | "|fractional", &PyArray_PythonPyIntFromInt, &fractional, |
| 3880 | "|sign", &PyArray_PythonPyIntFromInt, &sign, |
| 3881 | "|trim", &trimmode_converter, &trim, |
| 3882 | "|pad_left", &PyArray_PythonPyIntFromInt, &pad_left, |
| 3883 | "|pad_right", &PyArray_PythonPyIntFromInt, &pad_right, |
| 3884 | "|min_digits", &PyArray_PythonPyIntFromInt, &min_digits, |
| 3885 | NULL, NULL, NULL) < 0) { |
| 3886 | return NULL; |
| 3887 | } |
| 3888 | |
| 3889 | digit_mode = unique ? DigitMode_Unique : DigitMode_Exact; |
| 3890 | cutoff_mode = fractional ? CutoffMode_FractionLength : |
| 3891 | CutoffMode_TotalLength; |
| 3892 | |
| 3893 | if (unique == 0 && precision < 0) { |
| 3894 | PyErr_SetString(PyExc_TypeError, |
| 3895 | "in non-unique mode `precision` must be supplied"); |
| 3896 | return NULL; |
| 3897 | } |
| 3898 | |
| 3899 | return Dragon4_Positional(obj, digit_mode, cutoff_mode, precision, |
| 3900 | min_digits, sign, trim, pad_left, pad_right); |
| 3901 | } |
| 3902 | |
| 3903 | static PyObject * |
| 3904 | format_longfloat(PyObject *NPY_UNUSED(dummy), PyObject *args, PyObject *kwds) |
no test coverage detected