summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_arraysetops.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/tests/test_arraysetops.py')
-rw-r--r--numpy/lib/tests/test_arraysetops.py111
1 files changed, 55 insertions, 56 deletions
diff --git a/numpy/lib/tests/test_arraysetops.py b/numpy/lib/tests/test_arraysetops.py
index 7e8a7a6f3..5934ca05a 100644
--- a/numpy/lib/tests/test_arraysetops.py
+++ b/numpy/lib/tests/test_arraysetops.py
@@ -9,10 +9,10 @@ from numpy.lib.arraysetops import *
import warnings
-class TestSetOps(TestCase):
+class TestSetOps(TestCase):
- def test_unique( self ):
+ def test_unique(self):
def check_all(a, b, i1, i2, dt):
msg = "check values failed for type '%s'" % dt
@@ -65,47 +65,46 @@ class TestSetOps(TestCase):
bb = np.array(list(zip(b, b)), dt)
check_all(aa, bb, i1, i2, dt)
-
- def test_intersect1d( self ):
+ def test_intersect1d(self):
# unique inputs
- a = np.array( [5, 7, 1, 2] )
- b = np.array( [2, 4, 3, 1, 5] )
+ a = np.array([5, 7, 1, 2])
+ b = np.array([2, 4, 3, 1, 5])
- ec = np.array( [1, 2, 5] )
- c = intersect1d( a, b, assume_unique=True )
- assert_array_equal( c, ec )
+ ec = np.array([1, 2, 5])
+ c = intersect1d(a, b, assume_unique=True)
+ assert_array_equal(c, ec)
# non-unique inputs
- a = np.array( [5, 5, 7, 1, 2] )
- b = np.array( [2, 1, 4, 3, 3, 1, 5] )
+ a = np.array([5, 5, 7, 1, 2])
+ b = np.array([2, 1, 4, 3, 3, 1, 5])
- ed = np.array( [1, 2, 5] )
- c = intersect1d( a, b )
- assert_array_equal( c, ed )
+ ed = np.array([1, 2, 5])
+ c = intersect1d(a, b)
+ assert_array_equal(c, ed)
assert_array_equal([], intersect1d([], []))
- def test_setxor1d( self ):
- a = np.array( [5, 7, 1, 2] )
- b = np.array( [2, 4, 3, 1, 5] )
+ def test_setxor1d(self):
+ a = np.array([5, 7, 1, 2])
+ b = np.array([2, 4, 3, 1, 5])
- ec = np.array( [3, 4, 7] )
- c = setxor1d( a, b )
- assert_array_equal( c, ec )
+ ec = np.array([3, 4, 7])
+ c = setxor1d(a, b)
+ assert_array_equal(c, ec)
- a = np.array( [1, 2, 3] )
- b = np.array( [6, 5, 4] )
+ a = np.array([1, 2, 3])
+ b = np.array([6, 5, 4])
- ec = np.array( [1, 2, 3, 4, 5, 6] )
- c = setxor1d( a, b )
- assert_array_equal( c, ec )
+ ec = np.array([1, 2, 3, 4, 5, 6])
+ c = setxor1d(a, b)
+ assert_array_equal(c, ec)
- a = np.array( [1, 8, 2, 3] )
- b = np.array( [6, 5, 4, 8] )
+ a = np.array([1, 8, 2, 3])
+ b = np.array([6, 5, 4, 8])
- ec = np.array( [1, 2, 3, 4, 5, 6] )
- c = setxor1d( a, b )
- assert_array_equal( c, ec )
+ ec = np.array([1, 2, 3, 4, 5, 6])
+ c = setxor1d(a, b)
+ assert_array_equal(c, ec)
assert_array_equal([], setxor1d([], []))
@@ -181,7 +180,7 @@ class TestSetOps(TestCase):
assert_array_equal(in1d([], []), [])
- def test_in1d_char_array( self ):
+ def test_in1d_char_array(self):
a = np.array(['a', 'b', 'c', 'd', 'e', 'c', 'e', 'b'])
b = np.array(['a', 'c'])
@@ -212,29 +211,29 @@ class TestSetOps(TestCase):
assert_array_equal(in1d(a, long_b, assume_unique=True), ec)
assert_array_equal(in1d(a, long_b, assume_unique=False), ec)
- def test_union1d( self ):
- a = np.array( [5, 4, 7, 1, 2] )
- b = np.array( [2, 4, 3, 3, 2, 1, 5] )
+ def test_union1d(self):
+ a = np.array([5, 4, 7, 1, 2])
+ b = np.array([2, 4, 3, 3, 2, 1, 5])
- ec = np.array( [1, 2, 3, 4, 5, 7] )
- c = union1d( a, b )
- assert_array_equal( c, ec )
+ ec = np.array([1, 2, 3, 4, 5, 7])
+ c = union1d(a, b)
+ assert_array_equal(c, ec)
assert_array_equal([], union1d([], []))
- def test_setdiff1d( self ):
- a = np.array( [6, 5, 4, 7, 1, 2, 7, 4] )
- b = np.array( [2, 4, 3, 3, 2, 1, 5] )
+ def test_setdiff1d(self):
+ a = np.array([6, 5, 4, 7, 1, 2, 7, 4])
+ b = np.array([2, 4, 3, 3, 2, 1, 5])
- ec = np.array( [6, 7] )
- c = setdiff1d( a, b )
- assert_array_equal( c, ec )
+ ec = np.array([6, 7])
+ c = setdiff1d(a, b)
+ assert_array_equal(c, ec)
- a = np.arange( 21 )
- b = np.arange( 19 )
- ec = np.array( [19, 20] )
- c = setdiff1d( a, b )
- assert_array_equal( c, ec )
+ a = np.arange(21)
+ b = np.arange(19)
+ ec = np.array([19, 20])
+ c = setdiff1d(a, b)
+ assert_array_equal(c, ec)
assert_array_equal([], setdiff1d([], []))
@@ -243,15 +242,15 @@ class TestSetOps(TestCase):
b = np.array(['a', 'b', 's'])
assert_array_equal(setdiff1d(a, b), np.array(['c']))
- def test_manyways( self ):
- a = np.array( [5, 7, 1, 2, 8] )
- b = np.array( [9, 8, 2, 4, 3, 1, 5] )
+ def test_manyways(self):
+ a = np.array([5, 7, 1, 2, 8])
+ b = np.array([9, 8, 2, 4, 3, 1, 5])
- c1 = setxor1d( a, b )
- aux1 = intersect1d( a, b )
- aux2 = union1d( a, b )
- c2 = setdiff1d( aux2, aux1 )
- assert_array_equal( c1, c2 )
+ c1 = setxor1d(a, b)
+ aux1 = intersect1d(a, b)
+ aux2 = union1d(a, b)
+ c2 = setdiff1d(aux2, aux1)
+ assert_array_equal(c1, c2)
if __name__ == "__main__":