Skip to content

Commit bf56676

Browse files
authored
Merge pull request numpy#30139 from mhvk/array-string-keyword-arguments
MAINT,BUG: make later arguments in array2string keyword only.
2 parents 9b62c2e + b5474d4 commit bf56676

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

doc/release/upcoming_changes/30068.expired.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
The following long-deprecated APIs have been removed or converted to errors:
55

66
* The ``style`` parameter has been removed from ``numpy.array2string``.
7-
This argument had no effect since Numpy 1.14.0.
7+
This argument had no effect since Numpy 1.14.0. Any arguments following
8+
it, such as ``formatter`` have now been made keyword-only.
89

910
* Calling ``np.sum(generator)`` directly on a generator object now raises a `TypeError`.
1011
This behavior was deprecated in NumPy 1.15.0. Use ``np.sum(np.fromiter(generator))``

numpy/_core/arrayprint.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,18 +619,18 @@ def _array2string(a, options, separator=' ', prefix=""):
619619
def _array2string_dispatcher(
620620
a, max_line_width=None, precision=None,
621621
suppress_small=None, separator=None, prefix=None,
622-
formatter=None, threshold=None,
622+
*, formatter=None, threshold=None,
623623
edgeitems=None, sign=None, floatmode=None, suffix=None,
624-
*, legacy=None):
624+
legacy=None):
625625
return (a,)
626626

627627

628628
@array_function_dispatch(_array2string_dispatcher, module='numpy')
629629
def array2string(a, max_line_width=None, precision=None,
630630
suppress_small=None, separator=' ', prefix="",
631-
formatter=None, threshold=None,
631+
*, formatter=None, threshold=None,
632632
edgeitems=None, sign=None, floatmode=None, suffix="",
633-
*, legacy=None):
633+
legacy=None):
634634
"""
635635
Return a string representation of an array.
636636

numpy/_core/arrayprint.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,13 @@ def array2string(
9898
suppress_small: bool | None = None,
9999
separator: str = " ",
100100
prefix: str = "",
101+
*,
101102
formatter: _FormatDict | None = None,
102103
threshold: int | None = None,
103104
edgeitems: int | None = None,
104105
sign: _Sign | None = None,
105106
floatmode: _FloatMode | None = None,
106107
suffix: str = "",
107-
*,
108108
legacy: _Legacy | None = None,
109109
) -> str: ...
110110

0 commit comments

Comments
 (0)