Skip to content

Commit f76e22e

Browse files
committed
additional tests
1 parent d44be7d commit f76e22e

File tree

1 file changed

+23
-13
lines changed

1 file changed

+23
-13
lines changed

test/test_util.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -353,18 +353,18 @@ def test_array_to_tuple_array_e(self) -> None:
353353
self.assertEqual(result.tolist(), [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 11, 12, 13, 14), (15, 16, 17, 18, 19)])
354354

355355
#---------------------------------------------------------------------------
356-
def test_array2d_tuple_iter_a(self) -> None:
356+
def test_array_to_tuple_iter_a(self) -> None:
357357
a1 = np.arange(20, dtype=np.int64).reshape(4, 5)
358358
result = list(array_to_tuple_iter(a1))
359359
self.assertEqual(len(result), 4)
360360
self.assertEqual(result, [(0, 1, 2, 3, 4), (5, 6, 7, 8, 9), (10, 11, 12, 13, 14), (15, 16, 17, 18, 19)])
361361

362-
def test_array2d_tuple_iter_b(self) -> None:
362+
def test_array_to_tuple_iter_b(self) -> None:
363363
a1 = np.arange(20, dtype=np.int64).reshape(10, 2)
364364
result = list(array_to_tuple_iter(a1))
365365
self.assertEqual(result, [(0, 1), (2, 3), (4, 5), (6, 7), (8, 9), (10, 11), (12, 13), (14, 15), (16, 17), (18, 19)])
366366

367-
def test_array2d_tuple_iter_c(self) -> None:
367+
def test_array_to_tuple_iter_c(self) -> None:
368368
a1 = np.array([['aaa', 'bb'], ['c', 'dd'], ['ee', 'fffff']])
369369
it = array_to_tuple_iter(a1)
370370
self.assertEqual(it.__length_hint__(), 3)
@@ -377,52 +377,62 @@ def test_array2d_tuple_iter_c(self) -> None:
377377
with self.assertRaises(StopIteration):
378378
next(it)
379379

380-
def test_array2d_tuple_iter_d(self) -> None:
380+
def test_array_to_tuple_iter_d(self) -> None:
381381
a1 = np.array([['aaa', 'bb'], ['c', 'dd'], ['ee', 'fffff']])
382382
it = array_to_tuple_iter(a1)
383383
# __reversed__ not implemented
384384
with self.assertRaises(TypeError):
385385
reversed(it)
386386

387-
def test_array2d_tuple_iter_e(self) -> None:
387+
def test_array_to_tuple_iter_e(self) -> None:
388388
a1 = np.array([[None, 'bb'], [None, 'dd'], [3, None]])
389389
it = array_to_tuple_iter(a1)
390390
del a1
391391
self.assertEqual(list(it), [(None, 'bb'), (None, 'dd'), (3, None)])
392392

393-
def test_array2d_tuple_iter_f(self) -> None:
393+
def test_array_to_tuple_iter_f(self) -> None:
394394
a1 = np.array([[None, 'bb'], [None, 'dd'], [3, None]])
395395
it1 = array_to_tuple_iter(a1)
396396
del a1
397397
it2 = iter(it1)
398398
self.assertEqual(list(it1), [(None, 'bb'), (None, 'dd'), (3, None)])
399399
self.assertEqual(list(it2), []) # expected behavior
400400

401-
def test_array2d_tuple_iter_g(self) -> None:
401+
def test_array_to_tuple_iter_g(self) -> None:
402402
a1 = np.array([[None, 'bb'], [None, 'dd'], [3, None]])
403403
it1 = array_to_tuple_iter(a1)
404404
it2 = array_to_tuple_iter(a1)
405405
del a1
406406
self.assertEqual(list(it1), [(None, 'bb'), (None, 'dd'), (3, None)])
407407
self.assertEqual(list(it2), [(None, 'bb'), (None, 'dd'), (3, None)])
408408

409-
def test_array2d_tuple_iter_1d_a(self) -> None:
409+
def test_array_to_tuple_iter_1d_a(self) -> None:
410410
a1 = np.array(['bb', 'c', 'aaa'])
411411
result = list(array_to_tuple_iter(a1))
412412
self.assertEqual(len(result), 3)
413413
self.assertEqual(result, [('bb',), ('c',), ('aaa',)])
414414

415-
def test_array2d_tuple_iter_1d_b(self) -> None:
415+
def test_array_to_tuple_iter_1d_b(self) -> None:
416416
a1 = np.array([20, -1, 8])
417417
result = list(array_to_tuple_iter(a1))
418418
self.assertEqual(len(result), 3)
419419
self.assertEqual(result, [(20,), (-1,), (8,)])
420420

421-
def test_array2d_tuple_iter_1d_c(self) -> None:
421+
def test_array_to_tuple_iter_1d_c(self) -> None:
422422
a1 = np.array([('a', 4), ('c', -1), ('d', 8)], dtype=object)
423-
result = list(array_to_tuple_iter(a1))
424-
self.assertEqual(len(result), 3)
425-
self.assertEqual(result, [('a', 4), ('c', -1), ('d', 8)])
423+
a2 = list(array_to_tuple_iter(a1))
424+
self.assertEqual(len(a2), 3)
425+
self.assertEqual(a2, [('a', 4), ('c', -1), ('d', 8)])
426+
427+
def test_array_to_tuple_iter_1d_d(self) -> None:
428+
a1 = np.array([None, None, None], dtype=object)
429+
a1[0] = 3
430+
a1[1] = ('a', 30)
431+
a1[2] = (None, True, 90000000)
432+
433+
a2 = list(array_to_tuple_iter(a1))
434+
self.assertEqual(a2, [(3,), ('a', 30), (None, True, 90000000)])
435+
426436

427437
#---------------------------------------------------------------------------
428438

0 commit comments

Comments
 (0)