@@ -10,4 +10,71 @@ def test_first_true_1d():
1010 assert first_true_1d (b ) == - 1
1111
1212
13+ #--------------------------------------------------------------------------
14+ def test_first_true_1d_a () -> None :
15+ a1 = np .arange (100 ) == 50
16+ post = first_true_1d (a1 , forward = True )
17+ assert post == 50
1318
19+ # def test_first_true_1d_b() -> None:
20+ # with self.assertRaises(TypeError):
21+ # a1 = [2, 4, 5,]
22+ # first_true_1d(a1, forward=True)
23+
24+ # def test_first_true_1d_c() -> None:
25+ # with self.assertRaises(ValueError):
26+ # a1 = np.arange(100) == 50
27+ # first_true_1d(a1, forward=a1)
28+
29+ def test_first_true_1d_d () -> None :
30+ a1 = np .arange (100 ) < 0
31+ post = first_true_1d (a1 , forward = True )
32+ assert post == - 1
33+
34+ # def test_first_true_1d_e() -> None:
35+ # a1 = np.arange(100)
36+ # # only a Boolean array
37+ # with self.assertRaises(ValueError):
38+ # post = first_true_1d(a1, forward=True)
39+
40+ # def test_first_true_1d_f() -> None:
41+ # a1 = (np.arange(100) == 0)[:50:2]
42+ # # only a contiguous array
43+ # with self.assertRaises(ValueError):
44+ # post = first_true_1d(a1, forward=True)
45+
46+ # def test_first_true_1d_g() -> None:
47+ # a1 = (np.arange(100) == 0).reshape(10, 10)
48+ # # only a contiguous array
49+ # with self.assertRaises(ValueError):
50+ # post = first_true_1d(a1, forward=True)
51+
52+ def test_first_true_1d_reverse_a () -> None :
53+ a1 = np .arange (100 ) == 50
54+ post = first_true_1d (a1 , forward = False )
55+ assert post == 50
56+
57+ def test_first_true_1d_reverse_b () -> None :
58+ a1 = np .arange (100 ) == 0
59+ post = first_true_1d (a1 , forward = False )
60+ assert post == 0
61+
62+ def test_first_true_1d_reverse_c () -> None :
63+ a1 = np .arange (100 ) == - 1
64+ post = first_true_1d (a1 , forward = False )
65+ assert post == - 1
66+
67+ def test_first_true_1d_reverse_d () -> None :
68+ a1 = np .arange (100 ) == 99
69+ post = first_true_1d (a1 , forward = False )
70+ assert post == 99
71+
72+ def test_first_true_1d_multi_a () -> None :
73+ a1 = np .isin (np .arange (100 ), (50 , 70 , 90 ))
74+ assert first_true_1d (a1 , forward = True ) == 50
75+ assert first_true_1d (a1 , forward = False ) == 90
76+
77+ def test_first_true_1d_multi_b () -> None :
78+ a1 = np .isin (np .arange (100 ), (10 , 30 , 50 ))
79+ assert first_true_1d (a1 , forward = True ) == 10
80+ assert first_true_1d (a1 , forward = False ) == 50
0 commit comments