summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--LICENSE.txt30
-rw-r--r--MANIFEST.in3
-rw-r--r--numpy/core/arrayprint.py68
-rw-r--r--numpy/core/src/multiarray/iterators.c8
-rw-r--r--numpy/core/tests/test_arrayprint.py78
-rw-r--r--numpy/linalg/lapack_lite/LICENSE.txt48
-rw-r--r--numpy/ma/tests/test_core.py4
-rw-r--r--numpy/testing/nose_tools/utils.py3
-rwxr-xr-xsetup.py7
9 files changed, 212 insertions, 37 deletions
diff --git a/LICENSE.txt b/LICENSE.txt
index 906c7b536..0065d465f 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -28,3 +28,33 @@ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+
+The NumPy repository and source distributions bundle several libraries that are
+compatibly licensed. We list these here.
+
+Name: Numpydoc
+Files: doc/sphinxext/numpydoc/*
+License: 2-clause BSD
+ For details, see doc/sphinxext/LICENSE.txt
+
+Name: scipy-sphinx-theme
+Files: doc/scipy-sphinx-theme/*
+License: 3-clause BSD, PSF and Apache 2.0
+ For details, see doc/sphinxext/LICENSE.txt
+
+Name: lapack-lite
+Files: numpy/linalg/lapack_lite/*
+License: 3-clause BSD
+ For details, see numpy/linalg/lapack_lite/LICENSE.txt
+
+Name: tempita
+Files: tools/npy_tempita/*
+License: BSD derived
+ For details, see tools/npy_tempita/license.txt
+
+Name: dragon4
+Files: numpy/core/src/multiarray/dragon4.c
+License: One of a kind
+ For license text, see numpy/core/src/multiarray/dragon4.c
diff --git a/MANIFEST.in b/MANIFEST.in
index 0e11cb4f8..a15a05c63 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -11,6 +11,7 @@ recursive-include numpy/random/mtrand *.pyx *.pxd
# Add build support that should go in sdist, but not go in bdist/be installed
recursive-include numpy/_build_utils *
recursive-include numpy/linalg/lapack_lite *.c *.h
+include tox.ini
# Add sdist files whose use depends on local configuration.
include numpy/core/src/multiarray/cblasfuncs.c
include numpy/core/src/multiarray/python_xerbla.c
@@ -26,4 +27,4 @@ recursive-include doc/sphinxext *
recursive-include tools/swig *
recursive-include doc/scipy-sphinx-theme *
-global-exclude *.pyc *.pyo *.pyd
+global-exclude *.pyc *.pyo *.pyd *.swp *.bak *~
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 2aa35224c..93a659616 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -272,22 +272,27 @@ def get_printoptions():
"""
return _format_options.copy()
-def _leading_trailing(a):
+
+def _leading_trailing(a, index=()):
+ """
+ Keep only the N-D corners (leading and trailing edges) of an array.
+
+ Should be passed a base-class ndarray, since it makes no guarantees about
+ preserving subclasses.
+ """
edgeitems = _format_options['edgeitems']
- if a.ndim == 1:
- if len(a) > 2*edgeitems:
- b = concatenate((a[:edgeitems], a[-edgeitems:]))
- else:
- b = a
+ axis = len(index)
+ if axis == a.ndim:
+ return a[index]
+
+ if a.shape[axis] > 2*edgeitems:
+ return concatenate((
+ _leading_trailing(a, index + np.index_exp[ :edgeitems]),
+ _leading_trailing(a, index + np.index_exp[-edgeitems:])
+ ), axis=axis)
else:
- if len(a) > 2*edgeitems:
- l = [_leading_trailing(a[i]) for i in range(min(len(a), edgeitems))]
- l.extend([_leading_trailing(a[-i]) for i in range(
- min(len(a), edgeitems), 0, -1)])
- else:
- l = [_leading_trailing(a[i]) for i in range(0, len(a))]
- b = concatenate(tuple(l))
- return b
+ return _leading_trailing(a, index + np.index_exp[:])
+
def _object_format(o):
""" Object arrays containing lists should be printed unambiguously """
@@ -427,12 +432,14 @@ def _recursive_guard(fillvalue='...'):
# gracefully handle recursive calls, when object arrays contain themselves
@_recursive_guard()
def _array2string(a, options, separator=' ', prefix=""):
+ # The formatter __init__s cannot deal with subclasses yet
+ data = asarray(a)
+
if a.size > options['threshold']:
summary_insert = "..."
- data = _leading_trailing(a)
+ data = _leading_trailing(data)
else:
summary_insert = ""
- data = asarray(a)
# find the right formatting function for the array
format_function = _get_format_function(data, **options)
@@ -443,8 +450,8 @@ def _array2string(a, options, separator=' ', prefix=""):
next_line_prefix += " "*len(prefix)
lst = _formatArray(a, format_function, a.ndim, options['linewidth'],
- next_line_prefix, separator,
- options['edgeitems'], summary_insert)[:-1]
+ next_line_prefix, separator, options['edgeitems'],
+ summary_insert, options['legacy'])[:-1]
return lst
@@ -617,8 +624,8 @@ def _extendLine(s, line, word, max_line_len, next_line_prefix):
return s, line
-def _formatArray(a, format_function, rank, max_line_len,
- next_line_prefix, separator, edge_items, summary_insert):
+def _formatArray(a, format_function, rank, max_line_len, next_line_prefix,
+ separator, edge_items, summary_insert, legacy):
"""formatArray is designed for two modes of operation:
1. Full output
@@ -633,6 +640,8 @@ def _formatArray(a, format_function, rank, max_line_len,
leading_items = edge_items
trailing_items = edge_items
summary_insert1 = summary_insert + separator
+ if legacy == '1.13':
+ summary_insert1 = summary_insert + ', '
else:
leading_items = 0
trailing_items = len(a)
@@ -646,7 +655,8 @@ def _formatArray(a, format_function, rank, max_line_len,
s, line = _extendLine(s, line, word, max_line_len, next_line_prefix)
if summary_insert1:
- s, line = _extendLine(s, line, summary_insert1, max_line_len, next_line_prefix)
+ s, line = _extendLine(s, line, summary_insert1, max_line_len,
+ next_line_prefix)
for i in range(trailing_items, 1, -1):
word = format_function(a[-i]) + separator
@@ -659,29 +669,33 @@ def _formatArray(a, format_function, rank, max_line_len,
else:
s = '['
sep = separator.rstrip()
+ line_sep = '\n'*max(rank-1, 1)
for i in range(leading_items):
if i > 0:
s += next_line_prefix
s += _formatArray(a[i], format_function, rank-1, max_line_len,
" " + next_line_prefix, separator, edge_items,
- summary_insert)
- s = s.rstrip() + sep.rstrip() + '\n'*max(rank-1, 1)
+ summary_insert, legacy)
+ s = s.rstrip() + sep.rstrip() + line_sep
if summary_insert1:
- s += next_line_prefix + summary_insert1 + "\n"
+ if legacy == '1.13':
+ s += next_line_prefix + summary_insert1 + "\n"
+ else:
+ s += next_line_prefix + summary_insert1.strip() + line_sep
for i in range(trailing_items, 1, -1):
if leading_items or i != trailing_items:
s += next_line_prefix
s += _formatArray(a[-i], format_function, rank-1, max_line_len,
" " + next_line_prefix, separator, edge_items,
- summary_insert)
- s = s.rstrip() + sep.rstrip() + '\n'*max(rank-1, 1)
+ summary_insert, legacy)
+ s = s.rstrip() + sep.rstrip() + line_sep
if leading_items or trailing_items > 1:
s += next_line_prefix
s += _formatArray(a[-1], format_function, rank-1, max_line_len,
" " + next_line_prefix, separator, edge_items,
- summary_insert).rstrip()+']\n'
+ summary_insert, legacy).rstrip()+']\n'
return s
diff --git a/numpy/core/src/multiarray/iterators.c b/numpy/core/src/multiarray/iterators.c
index 0c83b9387..9cd5f036c 100644
--- a/numpy/core/src/multiarray/iterators.c
+++ b/numpy/core/src/multiarray/iterators.c
@@ -342,7 +342,9 @@ PyArray_BroadcastToShape(PyObject *obj, npy_intp *dims, int nd)
it->ao = ao;
it->size = PyArray_MultiplyList(dims, nd);
it->nd_m1 = nd - 1;
- it->factors[nd-1] = 1;
+ if (nd != 0) {
+ it->factors[nd-1] = 1;
+ }
for (i = 0; i < nd; i++) {
it->dims_m1[i] = dims[i] - 1;
k = i - diff;
@@ -1324,7 +1326,9 @@ PyArray_Broadcast(PyArrayMultiIterObject *mit)
it->nd_m1 = mit->nd - 1;
it->size = tmp;
nd = PyArray_NDIM(it->ao);
- it->factors[mit->nd-1] = 1;
+ if (nd != 0) {
+ it->factors[mit->nd-1] = 1;
+ }
for (j = 0; j < mit->nd; j++) {
it->dims_m1[j] = mit->dimensions[j] - 1;
k = j + nd - mit->nd;
diff --git a/numpy/core/tests/test_arrayprint.py b/numpy/core/tests/test_arrayprint.py
index 9719e8668..4d67d6eac 100644
--- a/numpy/core/tests/test_arrayprint.py
+++ b/numpy/core/tests/test_arrayprint.py
@@ -487,6 +487,13 @@ class TestPrintOptions(object):
'1.1234567891234568')
assert_equal(str(np.complex128(complex(1, np.nan))), '(1+nanj)')
+ def test_legacy_stray_comma(self):
+ np.set_printoptions(legacy='1.13')
+ assert_equal(str(np.arange(10000)), '[ 0 1 2 ..., 9997 9998 9999]')
+
+ np.set_printoptions(legacy=False)
+ assert_equal(str(np.arange(10000)), '[ 0 1 2 ... 9997 9998 9999]')
+
def test_dtype_linewidth_wrapping(self):
np.set_printoptions(linewidth=75)
assert_equal(repr(np.arange(10,20., dtype='f4')),
@@ -502,6 +509,77 @@ class TestPrintOptions(object):
array(['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],
dtype='{}')""".format(styp)))
+ def test_edgeitems(self):
+ np.set_printoptions(edgeitems=1, threshold=1)
+ a = np.arange(27).reshape((3, 3, 3))
+ assert_equal(
+ repr(a),
+ textwrap.dedent("""\
+ array([[[ 0, ..., 2],
+ ...,
+ [ 6, ..., 8]],
+
+ ...,
+
+ [[18, ..., 20],
+ ...,
+ [24, ..., 26]]])""")
+ )
+
+ b = np.zeros((3, 3, 1, 1))
+ assert_equal(
+ repr(b),
+ textwrap.dedent("""\
+ array([[[[0.]],
+
+ ...,
+
+ [[0.]]],
+
+
+ ...,
+
+
+ [[[0.]],
+
+ ...,
+
+ [[0.]]]])""")
+ )
+
+ # 1.13 had extra trailing spaces, and was missing newlines
+ np.set_printoptions(legacy='1.13')
+
+ assert_equal(
+ repr(a),
+ textwrap.dedent("""\
+ array([[[ 0, ..., 2],
+ ...,
+ [ 6, ..., 8]],
+
+ ...,
+ [[18, ..., 20],
+ ...,
+ [24, ..., 26]]])""")
+ )
+
+ assert_equal(
+ repr(b),
+ textwrap.dedent("""\
+ array([[[[ 0.]],
+
+ ...,
+ [[ 0.]]],
+
+
+ ...,
+ [[[ 0.]],
+
+ ...,
+ [[ 0.]]]])""")
+ )
+
+
def test_unicode_object_array():
import sys
if sys.version_info[0] >= 3:
diff --git a/numpy/linalg/lapack_lite/LICENSE.txt b/numpy/linalg/lapack_lite/LICENSE.txt
new file mode 100644
index 000000000..9b379c9e8
--- /dev/null
+++ b/numpy/linalg/lapack_lite/LICENSE.txt
@@ -0,0 +1,48 @@
+Copyright (c) 1992-2013 The University of Tennessee and The University
+ of Tennessee Research Foundation. All rights
+ reserved.
+Copyright (c) 2000-2013 The University of California Berkeley. All
+ rights reserved.
+Copyright (c) 2006-2013 The University of Colorado Denver. All rights
+ reserved.
+
+$COPYRIGHT$
+
+Additional copyrights may follow
+
+$HEADER$
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+- Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer listed
+ in this license in the documentation and/or other materials
+ provided with the distribution.
+
+- Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+The copyright holders provide no reassurances that the source code
+provided does not infringe any patent, copyright, or any other
+intellectual property rights of third parties. The copyright holders
+disclaim any liability to any recipient for claims brought against
+recipient by any third party for infringement of that parties
+intellectual property rights.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/numpy/ma/tests/test_core.py b/numpy/ma/tests/test_core.py
index be56833fd..cc447e37e 100644
--- a/numpy/ma/tests/test_core.py
+++ b/numpy/ma/tests/test_core.py
@@ -571,8 +571,8 @@ class TestMaskedArray(object):
a[1:50] = np.ma.masked
assert_equal(
repr(a),
- 'masked_array(data = [0 -- -- ... 1997 1998 1999],\n'
- ' mask = [False True True ... False False False],\n'
+ 'masked_array(data = [0 -- -- ..., 1997 1998 1999],\n'
+ ' mask = [False True True ..., False False False],\n'
' fill_value = 999999)\n'
)
finally:
diff --git a/numpy/testing/nose_tools/utils.py b/numpy/testing/nose_tools/utils.py
index 0b6fafc96..973e3bb4b 100644
--- a/numpy/testing/nose_tools/utils.py
+++ b/numpy/testing/nose_tools/utils.py
@@ -773,8 +773,7 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
+ '\n(mismatch %s%%)' % (match,),
verbose=verbose, header=header,
names=('x', 'y'), precision=precision)
- if not cond:
- raise AssertionError(msg)
+ raise AssertionError(msg)
except ValueError:
import traceback
efmt = traceback.format_exc()
diff --git a/setup.py b/setup.py
index 43c82a7b5..38d180248 100755
--- a/setup.py
+++ b/setup.py
@@ -81,7 +81,7 @@ def git_version():
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
- out = subprocess.Popen(cmd, stdout = subprocess.PIPE, env=env).communicate()[0]
+ out = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env).communicate()[0]
return out
try:
@@ -147,8 +147,8 @@ if not release:
a = open(filename, 'w')
try:
a.write(cnt % {'version': VERSION,
- 'full_version' : FULLVERSION,
- 'git_revision' : GIT_REVISION,
+ 'full_version': FULLVERSION,
+ 'git_revision': GIT_REVISION,
'isrelease': str(ISRELEASED)})
finally:
a.close()
@@ -164,6 +164,7 @@ def configuration(parent_package='',top_path=None):
quiet=True)
config.add_subpackage('numpy')
+ config.add_data_files(('numpy', 'LICENSE.txt'))
config.get_version('numpy/version.py') # sets config.version