8000 Added an 'elementary' function. by mttpgn · Pull Request #4573 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

Added an 'elementary' function. #4573

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

Closed
wants to merge 10 commits into from
Prev Previous commit
Next Next commit
Added tests for the elementary function.
  • Loading branch information
Matt Pagan committed Apr 14, 2014
commit 9dba2618220d00aa22da9322f202c7e15e8c6bae
24 changes: 24 additions & 0 deletions numpy/lib/tests/test_twodim_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,30 @@ def test_dtypes(self):
# assert_array_almost_equal).
yield (assert_array_equal, v, expected)

class TestElementary(object):
def test_switch_rows(self):
G = elementary(4, 0, 3)
assert_array_equal(G, np.array([[0., 0., 0., 1.],
[0., 1., 0., 0.],
[0., 0., 1., 0.],
[1., 0., 0., 0.]]))


def test_add_row_multiple(self):
H = elementary(5, 1, 3, 7, 'i')
assert_array_equal(H, np.array([[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 7, 0, 1, 0],
[0, 0, 0, 0, 1]]))


def test_multiply_row(self):
I = elementary(3, 0, multiplier=6, dtype=int)
assert_array_equal(I, np.array([[6, 0, 0],
[0, 1, 0],
[0, 0, 1]]))


if __name__ == "__main__":
run_module_suite()
0