diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2018-10-11 14:01:05 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 14:01:05 -0500 |
commit | eb2bd11870731ea19a0eee72e616c7deb00f6c54 (patch) | |
tree | b9eb90efea2f4757ce94da52417bd34b07f0b82b /numpy/core/arrayprint.py | |
parent | e309fb06d8c42e1500e3249e79b5d04fec0d66c2 (diff) | |
parent | 607842ab59b0479c485eb6fa30778f47dccc224a (diff) | |
download | numpy-eb2bd11870731ea19a0eee72e616c7deb00f6c54.tar.gz |
Merge pull request #12115 from shoyer/array-function-numpy-core
ENH: __array_function__ support for most of numpy.core
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 960e64ca3..1b9fbbfa9 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -48,6 +48,7 @@ from .fromnumeric import ravel, any from .numeric import concatenate, asarray, errstate from .numerictypes import (longlong, intc, int_, float_, complex_, bool_, flexible) +from .overrides import array_function_dispatch import warnings import contextlib @@ -496,6 +497,16 @@ def _array2string(a, options, separator=' ', prefix=""): return lst +def _array2string_dispatcher( + a, max_line_width=None, precision=None, + suppress_small=None, separator=None, prefix=None, + style=None, formatter=None, threshold=None, + edgeitems=None, sign=None, floatmode=None, suffix=None, + **kwarg): + return (a,) + + +@array_function_dispatch(_array2string_dispatcher) def array2string(a, max_line_width=None, precision=None, suppress_small=None, separator=' ', prefix="", style=np._NoValue, formatter=None, threshold=None, @@ -1370,6 +1381,12 @@ def dtype_short_repr(dtype): return typename +def _array_repr_dispatcher( + arr, max_line_width=None, precision=None, suppress_small=None): + return (arr,) + + +@array_function_dispatch(_array_repr_dispatcher) def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): """ Return the string representation of an array. @@ -1454,8 +1471,16 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): return arr_str + spacer + dtype_str + _guarded_str = _recursive_guard()(str) + +def _array_str_dispatcher( + a, max_line_width=None, precision=None, suppress_small=None): + return (a,) + + +@array_function_dispatch(_array_str_dispatcher) def array_str(a, max_line_width=None, precision=None, suppress_small=None): """ Return a string representation of the data in an array. |