10000 ENH: add signature argument to vectorize for vectorizing like generalized ufuncs by shoyer · Pull Request #8054 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: add signature argument to vectorize for vectorizing like generalized ufuncs #8054

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 18, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

8000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix spelling typo
  • Loading branch information
shoyer committed Oct 11, 2016
commit 7d14629e865e69e68a7c4507352865ed54889dbe
10 changes: 5 additions & 5 deletions numpy/lib/tests/test_function_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,30 +1104,30 @@ def addsubtract(a, b):
r = f([0, 3, 6, 9], [1, 3, 5, 7])
assert_array_equal(r, [1, 6, 1, 2])

def test_siganture_mean_last(self):
def test_signature_mean_last(self):
def mean(a):
return a.mean()

f = vectorize(mean, signature='(n)->()')
r = f([[1, 3], [2, 4]])
assert_array_equal(r, [2, 3])

def test_siganture_center(self):
def test_signature_center(self):
def center(a):
return a - a.mean()

f = vectorize(center, signature='(n)->(n)')
r = f([[1, 3], [2, 4]])
assert_array_equal(r, [[-1, 1], [-1, 1]])

def test_siganture_two_outputs(self):
def test_signature_two_outputs(self):
f = vectorize(lambda x: (x, x), signature='()->(),()')
r = f([1, 2, 3])
assert_(isinstance(r, tuple) and len(r) == 2)
assert_array_equal(r[0], [1, 2, 3])
assert_array_equal(r[1], [1, 2, 3])

def test_siganture_outer(self):
def test_signature_outer(self):
f = vectorize(np.outer, signature='(a),(b)->(a,b)')
r = f([1, 2], [1, 2, 3])
assert_array_equal(r, [[1, 2, 3], [2, 4, 6]])
Expand All @@ -1143,7 +1143,7 @@ def test_siganture_outer(self):
assert_array_equal(r, [[[1, 2, 3], [2, 4, 6]],
[[0, 0, 0], [0, 0, 0]]])

def test_siganture_computed_size(self):
def test_signature_computed_size(self):
f = vectorize(lambda x: x[:-1], signature='(n)->(m)')
r = f([1, 2, 3])
assert_array_equal(r, [1, 2])
Expand Down
0