8000 TST: fix #6542, add tests to check non-iterable argument raises in hstack and related functions. by gkBCCN · Pull Request #7366 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

TST: fix #6542, add tests to check non-iterable argument raises in hstack and related functions. #7366

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 1 commit into from
Mar 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions numpy/core/tests/test_shape_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def test_3D_array(self):


class TestHstack(TestCase):
def test_non_iterable(self):
assert_raises(TypeError, hstack, 1)

def test_0D_array(self):
a = array(1)
b = array(2)
Expand All @@ -143,6 +146,9 @@ def test_2D_array(self):


class TestVstack(TestCase):
def test_non_iterable(self):
assert_raises(TypeError, vstack, 1)

def test_0D_array(self):
a = array(1)
b = array(2)
Expand Down Expand Up @@ -265,6 +271,9 @@ def test_concatenate(self):


def test_stack():
# non-iterable input
assert_raises(TypeError, stack, 1)

# 0d input
for input_ in [(1, 2, 3),
[np.int32(1), np.int32(2), np.int32(3)],
Expand Down
29 changes: 28 additions & 1 deletion numpy/lib/tests/test_shape_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from numpy.lib.shape_base import (
apply_along_axis, apply_over_axes, array_split, split, hsplit, dsplit,
vsplit, dstack, kron, tile
vsplit, dstack, column_stack, kron, tile
)
from numpy.testing import (
run_module_suite, TestCase, assert_, assert_equal, assert_array_equal,
Expand Down Expand Up @@ -175,8 +175,15 @@ def test_unequal_split(self):
a = np.arange(10)
assert_raises(ValueError, split, a, 3)

class TestColumnStack(TestCase):
def test_non_iterable(self):
assert_raises(TypeError, column_stack, 1)


class TestDstack(TestCase):
def test_non_iterable(self):
assert_raises(TypeError, dstack, 1)

def test_0D_array(self):
a = np.array(1)
b = np.array(2)
Expand Down Expand Up @@ -212,6 +219,9 @@ class TestHsplit(TestCase):
"""Only testing for integer splits.

"""
def test_non_iterable(self):
assert_raises(ValueError, hsplit, 1, 1)

def test_0D_array(self):
a = np.array(1)
try:
Expand All @@ -238,6 +248,13 @@ class TestVsplit(TestCase):
"""Only testing for integer splits.

"""
def test_non_iterable(self):
assert_raises(ValueError, vsplit, 1, 1)

def test_0D_array(self):
a = np.array(1)
assert_raises(ValueError, vsplit, a, 2)

def test_1D_array(self):
a = np.array([1, 2, 3, 4])
try:
Expand All @@ -256,6 +273,16 @@ def test_2D_array(self):

class TestDsplit(TestCase):
# Only testing for integer splits.
def test_non_iterable(self):
assert_raises(ValueError, dsplit, 1, 1)

def test_0D_array(self):
a = np.array(1)
assert_raises(ValueError, dsplit, a, 2)

def test_1D_array(self):
a = np.array([1, 2, 3, 4])
assert_raises(ValueError, dsplit, a, 2)

def test_2D_array(self):
a = np.array([[1, 2, 3, 4],
Expand Down
0