MCPcopy Create free account
hub / github.com/numpy/numpy / dragon4_scientific

Function dragon4_scientific

numpy/core/src/multiarray/multiarraymodule.c:3821–3855  ·  view source on GitHub ↗

* Prints floating-point scalars using the Dragon4 algorithm, scientific mode. * See docstring of `np.format_float_scientific` for description of arguments. * The differences is that a value of -1 is valid for pad_left, exp_digits, * precision, which is equivalent to `None`. */

Source from the content-addressed store, hash-verified

3819 * precision, which is equivalent to `None`.
3820 */
3821static PyObject *
3822dragon4_scientific(PyObject *NPY_UNUSED(dummy),
3823 PyObject *const *args, Py_ssize_t len_args, PyObject *kwnames)
3824{
3825 PyObject *obj;
3826 int precision=-1, pad_left=-1, exp_digits=-1, min_digits=-1;
3827 DigitMode digit_mode;
3828 TrimMode trim = TrimMode_None;
3829 int sign=0, unique=1;
3830 NPY_PREPARE_ARGPARSER;
3831
3832 if (npy_parse_arguments("dragon4_scientific", args, len_args, kwnames,
3833 "x", NULL , &obj,
3834 "|precision", &PyArray_PythonPyIntFromInt, &precision,
3835 "|unique", &PyArray_PythonPyIntFromInt, &unique,
3836 "|sign", &PyArray_PythonPyIntFromInt, &sign,
3837 "|trim", &trimmode_converter, &trim,
3838 "|pad_left", &PyArray_PythonPyIntFromInt, &pad_left,
3839 "|exp_digits", &PyArray_PythonPyIntFromInt, &exp_digits,
3840 "|min_digits", &PyArray_PythonPyIntFromInt, &min_digits,
3841 NULL, NULL, NULL) < 0) {
3842 return NULL;
3843 }
3844
3845 digit_mode = unique ? DigitMode_Unique : DigitMode_Exact;
3846
3847 if (unique == 0 && precision < 0) {
3848 PyErr_SetString(PyExc_TypeError,
3849 "in non-unique mode `precision` must be supplied");
3850 return NULL;
3851 }
3852
3853 return Dragon4_Scientific(obj, digit_mode, precision, min_digits, sign, trim,
3854 pad_left, exp_digits);
3855}
3856
3857/*
3858 * Prints floating-point scalars using the Dragon4 algorithm, positional mode.

Callers 4

fillFormatMethod · 0.90
__call__Method · 0.90
format_float_scientificFunction · 0.90
format_floatFunction · 0.90

Calls 1

Dragon4_ScientificFunction · 0.85

Tested by

no test coverage detected