Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: preparing for numpy 1.9.4 release#6349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
matthew-brett wants to merge150 commits intonumpy:masterfrommatthew-brett:prepare-1.9.4
Closed
Show file tree
Hide file tree
Changes from3 commits
Commits
Show all changes
150 commits
Select commitHold shift + click to select a range
96b4349
REL: Release 1.9.0b1
juliantaylorJun 8, 2014
301c470
Merge pull request #4849 from juliantaylor/master
juliantaylorJul 7, 2014
b6903d7
Merge pull request #4871 from juliantaylor/linspace-version-doc
juliantaylorJul 16, 2014
b03f241
BUG: add missing elementsize alignment check for simd reductions
juliantaylorJul 8, 2014
52a9ff6
BUG: Use `np.where` in np.triu/np.tril, fixes #4859
jaimefrioJul 10, 2014
2a87c3e
DOC: fix a typo and use TeX for plot labels
endolithJul 15, 2014
029662b
Merge pull request #4872 from juliantaylor/backports-1.9
charrisJul 16, 2014
b583637
Merge pull request #4874 from juliantaylor/masked-sort-memory
charrisJul 16, 2014
e85290a
Merge pull request #4878 from nouiz:doc
juliantaylorJul 17, 2014
99329f9
Merge pull request #4891 from juliantaylor/reduce-float-axis
juliantaylorJul 18, 2014
6805122
Merge pull request #4882 from pv/fix-unpickle-latin1-crash
juliantaylorJul 18, 2014
3c66315
Merge pull request #4883 from pv/fix-scalar-unpickle-py3
juliantaylorJul 18, 2014
bd0a4f3
Merge pull request #4892 from rgommers/msvc10-fix
juliantaylorJul 20, 2014
857c5e2
Merge pull request #4888 from pv/fix-bytes-encoding-unpickle
juliantaylorJul 22, 2014
12f5f18
Merge pull request #4889 from juliantaylor/object-array-init
juliantaylorJul 23, 2014
f94151d
Merge pull request #4866 from mhvk/ma/mvoid-initialisation
juliantaylorJul 23, 2014
8198235
Merge pull request #4887 from ewmoore/conj_obj
juliantaylorJul 23, 2014
33d6a33
Merge pull request #4908 from juliantaylor/win-alignment
charrisJul 27, 2014
8fa45b4
Merge pull request #4906 from juliantaylor/doc-update
charrisJul 27, 2014
da10796
Merge pull request #4910 from seberg/scalar-none-cmp
juliantaylorJul 28, 2014
d3efa83
Merge pull request #4919 from juliantaylor/zeros_like_string
juliantaylorJul 29, 2014
97bf5a7
BUG: Avoid type promotion in tril and triu.
yotamJul 29, 2014
2acbfa7
MAINT: disable ufunc override for 1.9 release
juliantaylorJul 29, 2014
9cd9c6c
Merge pull request #4920 from juliantaylor/ufunc-disable
charrisJul 30, 2014
3b89488
MAINT: also disable has_ufunc_attr
juliantaylorJul 30, 2014
b5a56d6
Merge pull request #4925 from juliantaylor/ufunc-disable2
juliantaylorJul 30, 2014
faa6fa0
REL: Release 1.9.0b2
juliantaylorJul 30, 2014
118a1bb
Merge pull request #4930 from juliantaylor/charris-pep8-numpy-lib
charrisJul 31, 2014
16eef1e
DOC: Fix typo in _iotools.py docstring.
charrisAug 1, 2014
b1d6361
Merge pull request #4924 from charris/pep8-numpy-polynomial
juliantaylorAug 4, 2014
6cafbfd
Merge pull request #4926 from juliantaylor/concatenate-error
juliantaylorAug 4, 2014
f6a0b31
Merge pull request #4976 from juliantaylor/datetime-memleak
charrisAug 18, 2014
ccfd3bb
Merge pull request #4948 from charris/1.9-fix-typo-in-_iotools-docstring
juliantaylorAug 23, 2014
d8af083
ENH: np.dot: better "matrices not aligned" message
larsmansAug 23, 2014
d07c4c7
ENH: include shapes in "matrices not aligned" msg
larsmansAug 23, 2014
181e72c
Merge branch 'gfortran-debug' into maintenance/1.9.x
juliantaylorAug 24, 2014
3f5ae6d
Merge pull request #4989 from juliantaylor/percentile-fix
juliantaylorAug 24, 2014
3f165d4
Merge pull request #4985 from larsmans/dot-errmsg
juliantaylorAug 24, 2014
4475f1e
Merge pull request #4937 from charris/pep8-numpy-random
juliantaylorAug 24, 2014
23825b6
Merge pull request #4996 from fdiary/gfortran-rpath
juliantaylorAug 25, 2014
99391a6
Merge pull request #4997 from juliantaylor/unicode-init
juliantaylorAug 26, 2014
eb8ea0d
Merge pull request #5005 from juliantaylor/use-tempdir-for-large-file
juliantaylorAug 27, 2014
4344ffc
Merge pull request #5006 from dhomeier/ioconv_usecols
juliantaylorAug 27, 2014
07626d8
TST: silence deprecation warnings for bad index calls
juliantaylorAug 24, 2014
216bfb6
Merge pull request #5007 from juliantaylor/dep-silence
juliantaylorAug 27, 2014
36d947f
REL: Release 1.9.0rc1
juliantaylorAug 27, 2014
ef101b8
Merge pull request #5022 from seberg/structured-insert
juliantaylorSep 2, 2014
d03f77e
Merge pull request #5020 from charris/disable-some-test-warnings
juliantaylorSep 2, 2014
5c60b9b
Merge pull request #5035 from juliantaylor/fft-test
juliantaylorSep 3, 2014
b95c7df
TST: skip clongdouble alignment checks on 32 bit arches
juliantaylorSep 3, 2014
90cac3c
Merge pull request #5040 from juliantaylor/align-backport
charrisSep 3, 2014
859d2f1
Merge pull request #5048 from juliantaylor/subclass-test-fix
juliantaylorSep 4, 2014
c796148
Merge pull request #5051 from juliantaylor/thread-test-fix
juliantaylorSep 6, 2014
b5f5441
DOC: sync release notes with 1.8 branch
juliantaylorSep 7, 2014
d9137a4
DOC: fix missing space in percentile doc
juliantaylorSep 7, 2014
07601a6
REL: Release 1.9.0
juliantaylorSep 7, 2014
812f328
Merge pull request #5067 from juliantaylor/restore-dup
juliantaylorSep 11, 2014
f9dd65e
Merge pull request #5066 from seberg/index-sequence
juliantaylorSep 13, 2014
5818fb6
Merge pull request #5087 from juliantaylor/unicode-argmin
juliantaylorSep 19, 2014
2c83836
Merge pull request #5076 from kanhua/kh_fix
juliantaylorSep 19, 2014
5df6ac7
BUG: fix wrong error checks of PyBytes_AsStringAndSize
juliantaylorSep 19, 2014
7c3ec61
Merge pull request #5102 from dpinte/fix/epd_canopy
juliantaylorSep 23, 2014
38ed773
Merge pull request #5104 from juliantaylor/inner-fix
juliantaylorSep 23, 2014
f8a1f66
Merge pull request #5105 from juliantaylor/where-no-subtype
juliantaylorSep 23, 2014
26052d7
Merge pull request #5106 from juliantaylor/sequence-fix
juliantaylorSep 23, 2014
a2bfd3f
Merge pull request #5107 from juliantaylor/na-doc
juliantaylorSep 23, 2014
a6b01cc
Merge pull request #5088 from juliantaylor/not-fix
juliantaylorSep 24, 2014
e1e9117
Merge pull request #5140 from pyhits/5136
juliantaylorSep 30, 2014
ed228e6
Merge pull request #5149 from charris/fix-ma-docs-for-OO-option
juliantaylorOct 4, 2014
5a5dc6e
Merge pull request #5152 from tovrstra/collapsingbug
juliantaylorOct 4, 2014
1b7712b
Merge pull request #5167 from juliantaylor/rh5-miscompile
juliantaylorOct 10, 2014
6cf7ece
REL: set version number to unreleased 1.9.1
juliantaylorOct 10, 2014
e2851d2
Merge pull request #5168 from charris/f2py-space-fix
juliantaylorOct 10, 2014
90ae342
Merge pull request #5178 from charris/fix-npz-header-incompatibility
juliantaylorOct 13, 2014
fb6ff96
Merge pull request #5183 from charris/fix-npy-header-write
juliantaylorOct 15, 2014
d310ff9
Merge pull request #5182 from juliantaylor/nanmedian-inf
juliantaylorOct 16, 2014
ddb5e79
Merge pull request #5212 from charris/fix-long-long-fmt
juliantaylorOct 21, 2014
555d803
Merge pull request #5204 from RobberPhex/master
juliantaylorOct 21, 2014
e2eaf96
BUG: Ugly fix for Apple's cblas_sgemv segfault
sturlamoldenOct 18, 2014
ce0c6e0
Merge pull request #5225 from juliantaylor/datetime-arange-crash
juliantaylorOct 24, 2014
42d890f
Merge pull request #5216 from charris/cleanup-gh-5132
juliantaylorOct 24, 2014
8b58d98
BUG: io: genfromtxt did not handle filling_values=0 correctly. Closes…
WarrenWeckesserAug 15, 2014
079fcfc
BUG: Fixes #5184 gradient calculation behavior at boundaries
Oct 14, 2014
9b4b7b3
Merge pull request #5233 from juliantaylor/off_t-fix
juliantaylorOct 26, 2014
c6900b2
Merge pull request #5234 from juliantaylor/backports-1.9.1
juliantaylorOct 26, 2014
6970732
Merge pull request #5203 from njsmith/master
juliantaylorOct 26, 2014
473a386
DOC: add release notes for 1.9.1
juliantaylorOct 26, 2014
b7cb545
Merge pull request #5235 from juliantaylor/release-notes-1.9.1
juliantaylorOct 26, 2014
15a2097
DOC: add 1.9.1 release notes to index and fix formatting
juliantaylorOct 26, 2014
a373392
Merge pull request #5223 from sturlamolden/accelerate-sgemv-fix
juliantaylorOct 26, 2014
a4eddad
DOC: add Accelerate sgemv crash workaround to release notes
juliantaylorOct 26, 2014
c88fd91
REL: Release 1.9.1rc1
juliantaylorOct 26, 2014
994e98c
Merge pull request #5242 from juliantaylor/fix-ufunc-subok-out
juliantaylorOct 28, 2014
27c8797
Fix issue with fromarrays not correctly determining a format string f…
embrayOct 31, 2014
7d2ebea
DOC: update 1.9.1 release notes
juliantaylorNov 2, 2014
a587b47
Merge pull request #5255 from juliantaylor/backports
juliantaylorNov 2, 2014
d44b9c6
REL: Release 1.9.1
juliantaylorNov 2, 2014
e4c861f
REL: set version number to unreleased 1.9.2
juliantaylorDec 10, 2014
f546b8b
Merge pull request #5359 from tacaswell/linspace_doc
juliantaylorDec 10, 2014
c62f666
Merge pull request #5388 from sturlamolden/mtrand-bugfix-threadsafe
juliantaylorDec 23, 2014
50d8af8
Merge pull request #5390 from sturlamolden/mtrand-bugfix-threadsafe
juliantaylorDec 23, 2014
bd7fcee
Merge pull request #5374 from lebigot/patch-1
juliantaylorDec 24, 2014
f0b2dd7
BUG: Xerbla doesn't get linked in 1.9 on Fedora 21.
charrisDec 24, 2014
5ba6e41
Merge pull request #5393 from charris/detect_atlas_3_10
Dec 29, 2014
825b830
Merge pull request #5392 from charris/xerbla-1.9
charrisJan 2, 2015
9568de1
BUG: Closes #5313 PyArray_AsCArray caused segfault
hensingNov 26, 2014
678d481
Merge pull request #5416 from charris/backport-gh5314
charrisJan 2, 2015
c9075fa
Merge pull request #5417 from charris/tests-for-PyArray_AsCArray
charrisJan 2, 2015
b1ac4a5
Merge pull request #5447 from juliantaylor/ma-median-ndarray
juliantaylorJan 14, 2015
e0ef28b
BUG: fix string arrays not being aligned
juliantaylorNov 26, 2014
43e5e9e
BUG: reduce maximum alignment to 8 bytes on 32 bit
juliantaylorNov 26, 2014
1bce8d7
BUG: Fix astype for structured array fields of different byte order.
Nov 10, 2014
78709e0
Merge pull request #5481 from charris/backport-1.9-gh-5480
charrisJan 22, 2015
6fde11b
Merge pull request #5492 from grahamc/gotofail-malloc-ret-null-fft
juliantaylorJan 25, 2015
79ac576
BUG: Fix loadtxt with comments=None and a string None data.
LeartSOct 5, 2014
4ea05b0
TST: Add test for loadtxt with None as string type.
charrisJan 23, 2015
33bd205
DOC: fix a few bugs in the random.pareto docstring. Closes gh-4181.
Jan 6, 2015
f7cdfe6
BUG: Fix #4476 by adding datetime64 and timedelta64 types
Jan 15, 2015
53b19c5
TST: Add testcase for the fix to bug #4476.
Jan 15, 2015
1cac77b
Merge pull request #5478 from charris/fix-1.9-alignment
juliantaylorJan 25, 2015
fb19fac
MAINT: Get rid of some harmless gcc warnings about macro redefines.
charrisAug 17, 2014
eb73d4b
DOC: add 1.9.2 release notes
juliantaylorJan 25, 2015
311d937
Merge pull request #5500 from juliantaylor/backports-1.9.2
juliantaylorFeb 1, 2015
c04513c
REL: Release 1.9.2rc1
juliantaylorFeb 1, 2015
1f72899
Merge pull request #5599 from pitrou/refleak_ufunc2
juliantaylorFeb 23, 2015
43c8313
BUG: Fixes #5524 and adds test
hannaroFeb 19, 2015
102ba69
BUG: solves complex array clip in issue #5354 and added symmetric reg…
maniteja123Dec 21, 2014
bf6f80d
Merge pull request #5618 from johntyree/arrfill_ulonglong
juliantaylorMar 1, 2015
7cfdd98
DOC: update release notes
juliantaylorFeb 28, 2015
d685309
Merge pull request #5619 from jaimefrio/unique_docstring
juliantaylorMar 1, 2015
1f68813
Merge pull request #5616 from juliantaylor/backport-1.9.2
juliantaylorMar 1, 2015
762c6f1
REL: Release 1.9.2
juliantaylorMar 1, 2015
9a0d851
BUG: Fix #3926: pickling empty string fails
jayviusJan 21, 2015
54e3834
Merge pull request #5720 from cowlicks/backport-3926
charrisMar 25, 2015
35b4920
LIBPATH with spaces is now supported Python 2.7+ and Win32
mindwApr 13, 2015
3a2f055
Merge pull request #5765 from mindw/fix_libpath_win32
Apr 14, 2015
40a6085
MAINT: remove legacy monkeypatching of GzipFile
njsmithJun 25, 2015
6958842
BLD: find Python.h when build_ext --include-dirs is set
tdsmithMay 10, 2015
a6d32de
BLD: disable broken msvc14 trigonometric functions
cgohlkeSep 20, 2015
fa9a404
DEV: Replace deprecated options for ifort.
Feb 10, 2015
fad36c1
remove /GL for vs2015 in check_long_double_representation
Jul 20, 2015
147b828
BLD: enable C99 isnan and isinf for msvc14
cgohlkeAug 2, 2015
f404885
DOC: update release notes for 1.9.3
matthew-brettSep 19, 2015
7f96e9d
MAINT: set versions for 1.9.3 release
matthew-brettSep 19, 2015
edb902c
Merge pull request #6332 from matthew-brett/prepare-1.9.3
matthew-brettSep 21, 2015
5047404
ENH: make f2py an executable module
juliantaylorFeb 13, 2015
7c20ee5
BUG: fix f2py shebang line for bdist wheel, egg
matthew-brettApr 29, 2015
fc4904c
ENH: add bdist_mpkg, bdist_wininst to binary dists
matthew-brettApr 29, 2015
96ed3d2
BUG: revert use of !python for bdist_mpkg scripts
matthew-brettMay 5, 2015
b064e4b
TEST: add module to test installed scripts
matthew-brettApr 29, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletionsnumpy/lib/function_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -883,28 +883,33 @@ def copy(a, order='K'):
# Basic operations


def gradient(f, *varargs):
def gradient(f, *varargs, **kwargs):
"""
Return the gradient of an N-dimensional array.

The gradient is computed using second order accurate central differences
in the interior andsecond order accurate one-sides (forward or backwards)
differences at the boundaries. The returned gradient hence has the same
shape as the input array.
in the interior andeither first differences or second order accurate
one-sides (forward or backwards)differences at the boundaries. The
returned gradient hence has the sameshape as the input array.

Parameters
----------
f : array_like
An N-dimensional array containing samples of a scalar function.
`*varargs` : scalars
0, 1, or N scalars specifying the sample distances in each direction,
that is: `dx`, `dy`, `dz`, ... The default distance is 1.
An N-dimensional array containing samples of a scalar function.
varargs : list of scalar, optional
N scalars specifying the sample distances for each dimension,
i.e. `dx`, `dy`, `dz`, ... Default distance: 1.
edge_order : {1, 2}, optional
Gradient is calculated using N\ :sup:`th` order accurate differences
at the boundaries. Default: 1.

.. versionadded:: 1.9.1

Returns
-------
gradient : ndarray
N arrays of the same shape as `f` giving the derivative of `f` with
respect to each dimension.
N arrays of the same shape as `f` giving the derivative of `f` with
respect to each dimension.

Examples
--------
Expand All@@ -916,15 +921,14 @@ def gradient(f, *varargs):

>>> np.gradient(np.array([[1, 2, 6], [3, 4, 5]], dtype=np.float))
[array([[ 2., 2., -1.],
[ 2., 2., -1.]]),
array([[ 1. , 2.5, 4. ],
[ 1. , 1. , 1. ]])]
[ 2., 2., -1.]]), array([[ 1. , 2.5, 4. ],
[ 1. , 1. , 1. ]])]

>>> x = np.array([0,1,2,3,4])
>>> dx = gradient(x)
>>> x = np.array([0, 1, 2, 3,4])
>>> dx =np.gradient(x)
>>> y = x**2
>>> gradient(y,dx)
array([0., 2., 4., 6., 8.])
>>>np.gradient(y, dx, edge_order=2)
array([-0., 2., 4., 6., 8.])
"""
f = np.asanyarray(f)
N = len(f.shape) # number of dimensions
Expand All@@ -939,6 +943,13 @@ def gradient(f, *varargs):
raise SyntaxError(
"invalid number of arguments")

edge_order = kwargs.pop('edge_order', 1)
if kwargs:
raise TypeError('"{}" are not valid keyword arguments.'.format(
'", "'.join(kwargs.keys())))
if edge_order > 2:
raise ValueError("'edge_order' greater than 2 not supported")

# use central differences on interior and one-sided differences on the
# endpoints. This preserves second order-accuracy over the full domain.

Expand DownExpand Up@@ -978,7 +989,7 @@ def gradient(f, *varargs):
"at least two elements are required.")

# Numerical differentiation: 1st order edges, 2nd order interior
if y.shape[axis] == 2:
if y.shape[axis] == 2 or edge_order == 1:
# Use first order differences for time data
out = np.empty_like(y, dtype=otype)

Expand Down
4 changes: 3 additions & 1 deletionnumpy/lib/npyio.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1518,7 +1518,9 @@ def genfromtxt(fname, dtype=float, comments='#', delimiter=None,

# Process the filling_values ...............................
# Rename the input for convenience
user_filling_values = filling_values or []
user_filling_values = filling_values
if user_filling_values is None:
user_filling_values = []
# Define the default
filling_values = [None] * nbcols
# We have a dictionary : update each entry individually
Expand Down
6 changes: 3 additions & 3 deletionsnumpy/lib/tests/test_function_base.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -536,7 +536,7 @@ def test_datetime64(self):
'1910-10-12', '1910-12-12', '1912-12-12'],
dtype='datetime64[D]')
dx = np.array(
[-7, -3, 0, 31, 61, 396,1066],
[-5, -3, 0, 31, 61, 396,731],
dtype='timedelta64[D]')
assert_array_equal(gradient(x), dx)
assert_(dx.dtype == np.dtype('timedelta64[D]'))
Expand All@@ -547,7 +547,7 @@ def test_timedelta64(self):
[-5, -3, 10, 12, 61, 321, 300],
dtype='timedelta64[D]')
dx = np.array(
[-3, 7, 7, 25, 154, 119, -161],
[2, 7, 7, 25, 154, 119, -21],
dtype='timedelta64[D]')
assert_array_equal(gradient(x), dx)
assert_(dx.dtype == np.dtype('timedelta64[D]'))
Expand All@@ -561,7 +561,7 @@ def test_second_order_accurate(self):
dx = x[1] - x[0]
y = 2 * x ** 3 + 4 * x ** 2 + 2 * x
analytical = 6 * x ** 2 + 8 * x + 2
num_error = np.abs((np.gradient(y, dx) / analytical) - 1)
num_error = np.abs((np.gradient(y, dx, edge_order=2) / analytical) - 1)
assert_(np.all(num_error < 0.03) == True)


Expand Down
10 changes: 10 additions & 0 deletionsnumpy/lib/tests/test_io.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1315,6 +1315,16 @@ def test_user_filling_values(self):
ctrl = np.array([(0, 3), (4, -999)], dtype=[(_, int) for _ in "ac"])
assert_equal(test, ctrl)

data2 = "1,2,*,4\n5,*,7,8\n"
test = np.genfromtxt(TextIO(data2), delimiter=',', dtype=int,
missing_values="*", filling_values=0)
ctrl = np.array([[1, 2, 0, 4], [5, 0, 7, 8]])
assert_equal(test, ctrl)
test = np.genfromtxt(TextIO(data2), delimiter=',', dtype=int,
missing_values="*", filling_values=-1)
ctrl = np.array([[1, 2, -1, 4], [5, -1, 7, 8]])
assert_equal(test, ctrl)

def test_withmissing_float(self):
data = TextIO('A,B\n0,1.5\n2,-999.00')
test = np.mafromtxt(data, dtype=None, delimiter=',',
Expand Down

[8]ページ先頭

©2009-2026 Movatter.jp