diff options
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/arrayprint.py | 3 | ||||
-rw-r--r-- | numpy/core/fromnumeric.py | 11 |
2 files changed, 10 insertions, 4 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index db491e6f5..125d57672 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -21,6 +21,7 @@ from . import numerictypes as _nt from .umath import maximum, minimum, absolute, not_equal, isnan, isinf from .multiarray import format_longfloat, datetime_as_string, datetime_data from .fromnumeric import ravel +from .numeric import asarray if sys.version_info[0] >= 3: _MAXINT = sys.maxsize @@ -250,7 +251,7 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', data = _leading_trailing(a) else: summary_insert = "" - data = ravel(a) + data = ravel(asarray(a)) formatdict = {'bool' : _boolFormatter, 'int' : IntegerFormat(data), diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index c14d2e357..55789d780 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1342,6 +1342,10 @@ def ravel(a, order='C'): A 1-D array, containing the elements of the input, is returned. A copy is made only if needed. + As of NumPy 1.10, the returned array will have the same type as the input + array. (for example, a masked array will be returned for a masked array + input) + Parameters ---------- a : array_like @@ -1363,8 +1367,9 @@ def ravel(a, order='C'): Returns ------- - 1d_array : ndarray - Output of the same dtype as `a`, and of shape ``(a.size,)``. + y : array_like + Array of the same type as `a`, and of shape ``(a.size,)`` + or ``(1, a.size)`` for matrices. See Also -------- @@ -1422,7 +1427,7 @@ def ravel(a, order='C'): array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) """ - return asarray(a).ravel(order) + return asanyarray(a).ravel(order) def nonzero(a): |