array2string
Return a string representation of an array with full control over formatting.| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. |
options | { max_line_width?: number; precision?: number; suppress_small?: boolean; separator?: string; prefix?: string; suffix?: string; threshold?: number; edgeitems?: number; sign?: ' ' | '+' | '-'; floatmode?: 'fixed' | 'unique' | 'maxprec' | 'maxprec_equal'; } | undefined | Formatting options. |
string — Formatted string representation of the array.
array_repr
Return the string representation of an array, including thearray(...) wrapper, dtype, and shape information. This is what toString() uses internally.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. |
max_line_width | number | 75 | Maximum number of characters per line. |
precision | number | 8 | Number of digits of precision for floating-point output. |
suppress_small | boolean | false | If true, numbers very close to zero are printed as 0.. |
string — A string like array([[1, 2], [3, 4]]).
array_str
Return a string representation of the data in an array, without thearray(...) wrapper.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | ArrayLike | — | Input array. |
max_line_width | number | 75 | Maximum number of characters per line. |
precision | number | 8 | Floating-point precision. |
suppress_small | boolean | false | If true, suppress small floating-point values. |
string — The array data as a string without the array() prefix.
base_repr
Return the string representation of a number in the given base.| Parameter | Type | Default | Description |
|---|---|---|---|
number | number | — | The integer to convert. |
base | number | 2 | The base for the representation (2 through 36). |
padding | number | 0 | Minimum number of digits. Pads with leading zeros if needed. |
string — String representation in the specified base.
binary_repr
Return the binary string representation of a number. Negative numbers use two’s complement notation.| Parameter | Type | Default | Description |
|---|---|---|---|
num | number | — | The integer to convert. |
width | number | undefined | Total width of the binary string. For negative numbers, this determines the two’s complement width. |
string — Binary string representation.
format_float_positional
Format a floating-point scalar in positional (non-scientific) notation with fine-grained control.| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | — | Value to format. |
precision | null | number | undefined | Maximum number of digits. |
unique | boolean | true | If true, use the minimum number of digits to uniquely represent the value. |
fractional | boolean | true | If true, precision refers to digits after the decimal point; otherwise total significant digits. |
trim | '-' | '.' | '0' | 'k' | 'k' | Controls trailing zero trimming. |
sign | ' ' | '+' | '-' | '-' | Sign formatting mode. |
pad_left | null | number | undefined | Pad with spaces on the left to this width. |
pad_right | null | number | undefined | Pad with spaces on the right to this width. |
min_digits | null | number | undefined | Minimum significant digits to emit. |
string — Formatted number string.
format_float_scientific
Format a floating-point scalar in scientific notation.| Parameter | Type | Default | Description |
|---|---|---|---|
x | number | — | Value to format. |
precision | null | number | undefined | Number of digits of precision. |
_unique | boolean | true | If true, use minimal digits to uniquely represent the value. |
trim | '-' | '.' | '0' | 'k' | 'k' | Trailing zero trimming (same options as format_float_positional). |
sign | ' ' | '+' | '-' | '-' | Sign formatting mode. |
pad_left | null | number | undefined | Pad with spaces on the left to this width. |
exp_digits | number | undefined | Minimum number of digits in the exponent. |
min_digits | null | number | undefined | Minimum significant digits to emit. |
string — Formatted scientific notation string.
get_printoptions
Return the current default print options used bytoString() and array2string.
PrintOptions — An object with the current settings including precision, threshold, edgeitems, linewidth, suppress, and nanstr.
set_printoptions
Set the default print options globally. These affect all subsequent calls totoString(), array_repr, and array2string.
| Parameter | Type | Default | Description |
|---|---|---|---|
options | PrintOptions | — | An object with one or more print option keys: precision, threshold, edgeitems, linewidth, suppress, nanstr, infstr, sign, formatter. |
void
printoptions
Temporarily set print options and return a context object. This is useful as a scoped context manager for formatting.| Parameter | Type | Default | Description |
|---|---|---|---|
options | Partial<PrintOptions> | — | Temporary print options to apply. |
{ enter, exit, apply, _savedOptions } — Context helpers that apply and restore temporary print settings.