diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/_add_newdocs.py | 14 | ||||
-rw-r--r-- | numpy/core/defchararray.py | 2 | ||||
-rw-r--r-- | numpy/core/fromnumeric.py | 11 | ||||
-rw-r--r-- | numpy/core/numerictypes.py | 10 | ||||
-rw-r--r-- | numpy/core/records.py | 8 | ||||
-rw-r--r-- | numpy/core/shape_base.py | 4 | ||||
-rw-r--r-- | numpy/fft/fftpack.py | 28 | ||||
-rw-r--r-- | numpy/lib/_datasource.py | 4 | ||||
-rw-r--r-- | numpy/lib/_iotools.py | 10 | ||||
-rw-r--r-- | numpy/lib/function_base.py | 8 | ||||
-rw-r--r-- | numpy/lib/nanfunctions.py | 4 | ||||
-rw-r--r-- | numpy/lib/npyio.py | 4 | ||||
-rw-r--r-- | numpy/lib/recfunctions.py | 2 | ||||
-rw-r--r-- | numpy/lib/utils.py | 4 |
14 files changed, 59 insertions, 54 deletions
diff --git a/numpy/core/_add_newdocs.py b/numpy/core/_add_newdocs.py index 5eb236694..60cb62bb5 100644 --- a/numpy/core/_add_newdocs.py +++ b/numpy/core/_add_newdocs.py @@ -3073,7 +3073,7 @@ add_newdoc('numpy.core.multiarray', 'ndarray', ('getfield', >>> x.getfield(np.float64, offset=8) array([[1., 0.], - [0., 4.]]) + [0., 4.]]) """)) @@ -5151,9 +5151,9 @@ add_newdoc('numpy.core', 'ufunc', ('reduceat', >>> x = np.linspace(0, 15, 16).reshape(4,4) >>> x - array([[ 0., 1., 2., 3.], - [ 4., 5., 6., 7.], - [ 8., 9., 10., 11.], + array([[ 0., 1., 2., 3.], + [ 4., 5., 6., 7.], + [ 8., 9., 10., 11.], [12., 13., 14., 15.]]) :: @@ -5168,8 +5168,8 @@ add_newdoc('numpy.core', 'ufunc', ('reduceat', >>> np.add.reduceat(x, [0, 3, 1, 2, 0]) array([[12., 15., 18., 21.], [12., 13., 14., 15.], - [ 4., 5., 6., 7.], - [ 8., 9., 10., 11.], + [ 4., 5., 6., 7.], + [ 8., 9., 10., 11.], [24., 28., 32., 36.]]) :: @@ -5178,7 +5178,7 @@ add_newdoc('numpy.core', 'ufunc', ('reduceat', # [col1 * col2 * col3, col4] >>> np.multiply.reduceat(x, [0, 3], 1) - array([[ 0., 3.], + array([[ 0., 3.], [ 120., 7.], [ 720., 11.], [2184., 15.]]) diff --git a/numpy/core/defchararray.py b/numpy/core/defchararray.py index cdb8fe6bc..eeba5da8f 100644 --- a/numpy/core/defchararray.py +++ b/numpy/core/defchararray.py @@ -1090,7 +1090,7 @@ def lstrip(a, chars=None): >>> np.char.lstrip(c, 'A') # leaves c unchanged array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') >>> (np.char.lstrip(c, ' ') == np.char.lstrip(c, '')).all() - ... # XXX: is this a regression? this line now returns False + ... # This used to return True ... # np.char.lstrip(c,'') does not modify c at all. False >>> (np.char.lstrip(c, ' ') == np.char.lstrip(c, None)).all() diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 33ecd6905..575e0a8ef 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -2240,13 +2240,10 @@ def all(a, axis=None, out=None, keepdims=np._NoValue): >>> np.all([1.0, np.nan]) True - >>> o=np.array([False]) + >>> o=np.array(False) >>> z=np.all([-1, 4, 5], out=o) - Traceback (most recent call last): - ... - ValueError: output parameter for reduction operation logical_and has too many dimensions - >>> id(z), id(o), z # doctest: +SKIP - (28293632, 28293632, array([ True])) + >>> id(z), id(o), z + (28293632, 28293632, array([ True])) # may vary """ return _wrapreduction(a, np.logical_and, 'all', axis, None, out, keepdims=keepdims) @@ -2732,7 +2729,7 @@ def prod(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, initial=np._N >>> x = np.array([536870910, 536870910, 536870910, 536870910]) >>> np.prod(x) - 6917529010461212688 # may vary + 16 # may vary The product of an empty array is the neutral element 1: diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py index eef1efb64..5bc37b73a 100644 --- a/numpy/core/numerictypes.py +++ b/numpy/core/numerictypes.py @@ -167,7 +167,7 @@ def maximum_sctype(t): >>> np.maximum_sctype(np.uint8) <class 'numpy.uint64'> >>> np.maximum_sctype(complex) - <class 'numpy.complex256'> + <class 'numpy.complex256'> # may vary >>> np.maximum_sctype(str) <class 'numpy.str_'> @@ -175,7 +175,7 @@ def maximum_sctype(t): >>> np.maximum_sctype('i2') <class 'numpy.int64'> >>> np.maximum_sctype('f4') - <class 'numpy.float128'> + <class 'numpy.float128'> # may vary """ g = obj2sctype(t) @@ -318,7 +318,7 @@ def issubclass_(arg1, arg2): Examples -------- >>> np.issubclass_(np.int32, int) - False + False # True on Python 2.7 >>> np.issubclass_(np.int32, float) False @@ -484,9 +484,9 @@ def sctype2char(sctype): Examples -------- - >>> for sctype in [np.int32, np.double, complex, np.string_, np.ndarray]: + >>> for sctype in [np.int32, np.double, np.complex, np.string_, np.ndarray]: ... print(np.sctype2char(sctype)) - i + l # may vary d D S diff --git a/numpy/core/records.py b/numpy/core/records.py index c4c2e8025..ff2a3ef9f 100644 --- a/numpy/core/records.py +++ b/numpy/core/records.py @@ -127,7 +127,7 @@ class format_parser(object): Examples -------- - >>> np.format_parser(['f8', 'i4', 'a5'], ['col1', 'col2', 'col3'], + >>> np.format_parser(['<f8', '<i4', '<a5'], ['col1', 'col2', 'col3'], ... ['T1', 'T2', 'T3']).dtype dtype([(('T1', 'col1'), '<f8'), (('T2', 'col2'), '<i4'), (('T3', 'col3'), 'S5')]) @@ -137,8 +137,8 @@ class format_parser(object): >>> np.format_parser(['f8', 'i4', 'a5'], ['col1', 'col2', 'col3'], ... []).dtype - dtype([('col1', '<f8'), ('col2', '<i4'), ('col3', 'S5')]) - >>> np.format_parser(['f8', 'i4', 'a5'], [], []).dtype + dtype([('col1', '<f8'), ('col2', '<i4'), ('col3', '<S5')]) + >>> np.format_parser(['<f8', '<i4', '<a5'], [], []).dtype dtype([('f0', '<f8'), ('f1', '<i4'), ('f2', 'S5')]) """ @@ -378,7 +378,7 @@ class recarray(ndarray): -------- Create an array with two fields, ``x`` and ``y``: - >>> x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', np.float64), ('y', np.int64)]) + >>> x = np.array([(1.0, 2), (3.0, 4)], dtype=[('x', '<f8'), ('y', '<i8')]) >>> x array([(1., 2), (3., 4)], dtype=[('x', '<f8'), ('y', '<i8')]) diff --git a/numpy/core/shape_base.py b/numpy/core/shape_base.py index 83a33a036..0378d3c1f 100644 --- a/numpy/core/shape_base.py +++ b/numpy/core/shape_base.py @@ -182,9 +182,9 @@ def atleast_3d(*arys): ... print(arr, arr.shape) # doctest: +SKIP ... [[[1] - [2]]] (1, 2, 1) + [2]]] (1, 2, 1) [[[1] - [2]]] (1, 2, 1) + [2]]] (1, 2, 1) [[[1 2]]] (1, 1, 2) """ diff --git a/numpy/fft/fftpack.py b/numpy/fft/fftpack.py index c6d40c8d6..d0df6fb48 100644 --- a/numpy/fft/fftpack.py +++ b/numpy/fft/fftpack.py @@ -276,7 +276,7 @@ def ifft(a, n=None, axis=-1, norm=None): Examples -------- >>> np.fft.ifft([0, 4, 0, 0]) - array([ 1.+0.j, 0.+1.j, -1.+0.j, 0.-1.j]) + array([ 1.+0.j, 0.+1.j, -1.+0.j, 0.-1.j]) # may vary Create and plot a band-limited signal with random phases: @@ -374,9 +374,9 @@ def rfft(a, n=None, axis=-1, norm=None): Examples -------- >>> np.fft.fft([0, 1, 0, 0]) - array([ 1.+0.j, 0.-1.j, -1.+0.j, 0.+1.j]) + array([ 1.+0.j, 0.-1.j, -1.+0.j, 0.+1.j]) # may vary >>> np.fft.rfft([0, 1, 0, 0]) - array([ 1.+0.j, 0.-1.j, -1.+0.j]) + array([ 1.+0.j, 0.-1.j, -1.+0.j]) # may vary Notice how the final element of the `fft` output is the complex conjugate of the second element, for real input. For `rfft`, this symmetry is @@ -465,7 +465,7 @@ def irfft(a, n=None, axis=-1, norm=None): Examples -------- >>> np.fft.ifft([1, -1j, -1, 1j]) - array([0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j]) + array([0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j]) # may vary >>> np.fft.irfft([1, -1j, -1]) array([0., 1., 0., 0.]) @@ -543,7 +543,7 @@ def hfft(a, n=None, axis=-1, norm=None): -------- >>> signal = np.array([1, 2, 3, 4, 3, 2]) >>> np.fft.fft(signal) - array([15.+0.j, -4.+0.j, 0.+0.j, -1.+0.j, 0.+0.j, -4.+0.j]) + array([15.+0.j, -4.+0.j, 0.+0.j, -1.-0.j, 0.+0.j, -4.+0.j]) # may vary >>> np.fft.hfft(signal[:4]) # Input first half of signal array([15., -4., 0., -1., 0., -4.]) >>> np.fft.hfft(signal, 6) # Input entire signal and truncate @@ -552,7 +552,7 @@ def hfft(a, n=None, axis=-1, norm=None): >>> signal = np.array([[1, 1.j], [-1.j, 2]]) >>> np.conj(signal.T) - signal # check Hermitian symmetry - array([[ 0.-0.j, -0.+0.j], + array([[ 0.-0.j, -0.+0.j], # may vary [ 0.+0.j, 0.-0.j]]) >>> freq_spectrum = np.fft.hfft(signal) >>> freq_spectrum @@ -616,7 +616,7 @@ def ihfft(a, n=None, axis=-1, norm=None): -------- >>> spectrum = np.array([ 15, -4, 0, -1, 0, -4]) >>> np.fft.ifft(spectrum) - array([1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 3.+0.j, 2.+0.j]) + array([1.+0.j, 2.+0.j, 3.+0.j, 4.+0.j, 3.+0.j, 2.+0.j]) # may vary >>> np.fft.ihfft(spectrum) array([ 1.-0.j, 2.-0.j, 3.-0.j, 4.-0.j]) # may vary @@ -732,7 +732,7 @@ def fftn(a, s=None, axes=None, norm=None): -------- >>> a = np.mgrid[:3, :3, :3][0] >>> np.fft.fftn(a, axes=(1, 2)) - array([[[ 0.+0.j, 0.+0.j, 0.+0.j], + array([[[ 0.+0.j, 0.+0.j, 0.+0.j], # may vary [ 0.+0.j, 0.+0.j, 0.+0.j], [ 0.+0.j, 0.+0.j, 0.+0.j]], [[ 9.+0.j, 0.+0.j, 0.+0.j], @@ -742,7 +742,7 @@ def fftn(a, s=None, axes=None, norm=None): [ 0.+0.j, 0.+0.j, 0.+0.j], [ 0.+0.j, 0.+0.j, 0.+0.j]]]) >>> np.fft.fftn(a, (2, 2), axes=(0, 1)) - array([[[ 2.+0.j, 2.+0.j, 2.+0.j], + array([[[ 2.+0.j, 2.+0.j, 2.+0.j], # may vary [ 0.+0.j, 0.+0.j, 0.+0.j]], [[-2.+0.j, -2.+0.j, -2.+0.j], [ 0.+0.j, 0.+0.j, 0.+0.j]]]) @@ -838,7 +838,7 @@ def ifftn(a, s=None, axes=None, norm=None): -------- >>> a = np.eye(4) >>> np.fft.ifftn(np.fft.fftn(a, axes=(0,)), axes=(1,)) - array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], + array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], # may vary [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j], [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j]]) @@ -934,7 +934,7 @@ def fft2(a, s=None, axes=(-2, -1), norm=None): -------- >>> a = np.mgrid[:5, :5][0] >>> np.fft.fft2(a) - array([[ 50. +0.j , 0. +0.j , 0. +0.j , + array([[ 50. +0.j , 0. +0.j , 0. +0.j , # may vary 0. +0.j , 0. +0.j ], [-12.5+17.20477401j, 0. +0.j , 0. +0.j , 0. +0.j , 0. +0.j ], @@ -1028,7 +1028,7 @@ def ifft2(a, s=None, axes=(-2, -1), norm=None): -------- >>> a = 4 * np.eye(4) >>> np.fft.ifft2(a) - array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], + array([[1.+0.j, 0.+0.j, 0.+0.j, 0.+0.j], # may vary [0.+0.j, 0.+0.j, 0.+0.j, 1.+0.j], [0.+0.j, 0.+0.j, 1.+0.j, 0.+0.j], [0.+0.j, 1.+0.j, 0.+0.j, 0.+0.j]]) @@ -1110,13 +1110,13 @@ def rfftn(a, s=None, axes=None, norm=None): -------- >>> a = np.ones((2, 2, 2)) >>> np.fft.rfftn(a) - array([[[8.+0.j, 0.+0.j], + array([[[8.+0.j, 0.+0.j], # may vary [0.+0.j, 0.+0.j]], [[0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j]]]) >>> np.fft.rfftn(a, axes=(2, 0)) - array([[[4.+0.j, 0.+0.j], + array([[[4.+0.j, 0.+0.j], # may vary [4.+0.j, 0.+0.j]], [[0.+0.j, 0.+0.j], [0.+0.j, 0.+0.j]]]) diff --git a/numpy/lib/_datasource.py b/numpy/lib/_datasource.py index b136314a2..3a0e67f60 100644 --- a/numpy/lib/_datasource.py +++ b/numpy/lib/_datasource.py @@ -20,8 +20,8 @@ gzip, bz2 and xz are supported. Example:: >>> # Create a DataSource, use os.curdir (default) for local storage. - >>> import numpy.lib._datasource as datasource - >>> ds = datasource.DataSource() + >>> from numpy import DataSource + >>> ds = DataSource() >>> >>> # Open a remote file. >>> # DataSource downloads the file, stores it locally in: diff --git a/numpy/lib/_iotools.py b/numpy/lib/_iotools.py index d41e39227..0ebd39b8c 100644 --- a/numpy/lib/_iotools.py +++ b/numpy/lib/_iotools.py @@ -148,7 +148,15 @@ def flatten_dtype(ndtype, flatten_base=False): >>> np.lib._iotools.flatten_dtype(dt) [dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64')] >>> np.lib._iotools.flatten_dtype(dt, flatten_base=True) - [dtype('S4'), dtype('float64'), dtype('float64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64'), dtype('int64')] + [dtype('S4'), + dtype('float64'), + dtype('float64'), + dtype('int64'), + dtype('int64'), + dtype('int64'), + dtype('int64'), + dtype('int64'), + dtype('int64')] """ names = ndtype.names diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 2f73e4828..1ead375de 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -3196,10 +3196,10 @@ def kaiser(M, beta): >>> matplotlib.use('agg') >>> import matplotlib.pyplot as plt >>> np.kaiser(12, 14) - array([7.72686684e-06, 3.46009194e-03, 4.65200189e-02, # may vary - 2.29737120e-01, 5.99885316e-01, 9.45674898e-01, - 9.45674898e-01, 5.99885316e-01, 2.29737120e-01, - 4.65200189e-02, 3.46009194e-03, 7.72686684e-06]) + array([7.72686684e-06, 3.46009194e-03, 4.65200189e-02, # may vary + 2.29737120e-01, 5.99885316e-01, 9.45674898e-01, + 9.45674898e-01, 5.99885316e-01, 2.29737120e-01, + 4.65200189e-02, 3.46009194e-03, 7.72686684e-06]) Plot the window and the frequency response: diff --git a/numpy/lib/nanfunctions.py b/numpy/lib/nanfunctions.py index 284f1eb62..b3bf1880b 100644 --- a/numpy/lib/nanfunctions.py +++ b/numpy/lib/nanfunctions.py @@ -1468,8 +1468,8 @@ def nanvar(a, axis=None, dtype=None, out=None, ddof=0, keepdims=np._NoValue): Examples -------- >>> a = np.array([[1, np.nan], [3, 4]]) - >>> np.var(a) - nan + >>> np.nanvar(a) + 1.5555555555555554 >>> np.nanvar(a, axis=0) array([1., 0.]) >>> np.nanvar(a, axis=1) diff --git a/numpy/lib/npyio.py b/numpy/lib/npyio.py index 71261b826..e98c33e29 100644 --- a/numpy/lib/npyio.py +++ b/numpy/lib/npyio.py @@ -173,7 +173,7 @@ class NpzFile(Mapping): >>> npz = np.load(outfile) >>> isinstance(npz, np.lib.io.NpzFile) True - >>> npz.files + >>> sorted(npz.files) ['x', 'y'] >>> npz['x'] # getitem access array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) @@ -610,7 +610,7 @@ def savez(file, *args, **kwds): >>> np.savez(outfile, x=x, y=y) >>> _ = outfile.seek(0) >>> npzfile = np.load(outfile) - >>> npzfile.files + >>> sorted(npzfile.files) ['x', 'y'] >>> npzfile['x'] array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) diff --git a/numpy/lib/recfunctions.py b/numpy/lib/recfunctions.py index 199d68649..844132333 100644 --- a/numpy/lib/recfunctions.py +++ b/numpy/lib/recfunctions.py @@ -838,7 +838,7 @@ def repack_fields(a, align=False, recurse=False): ... print("offsets:", [d.fields[name][1] for name in d.names]) ... print("itemsize:", d.itemsize) ... - >>> dt = np.dtype('u1,l,d', align=True) + >>> dt = np.dtype('u1,<i4,<f4', align=True) >>> dt dtype({'names':['f0','f1','f2'], 'formats':['u1','<i8','<f8'], 'offsets':[0,8,16], 'itemsize':24}, align=True) >>> print_offsets(dt) diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 1c834e7f2..355b66df9 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -198,8 +198,8 @@ def byte_bounds(a): >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True - >>> I = np.eye(2, dtype='G'); I.dtype - dtype('complex256') + >>> I = np.eye(2); I.dtype + dtype('complex256') # may vary >>> low, high = np.byte_bounds(I) >>> high - low == I.size*I.itemsize True |