@@ -286,34 +286,47 @@ def test_array_deepcopy_h(self) -> None:
286
286
a2 = array_deepcopy (a1 , ())
287
287
288
288
#---------------------------------------------------------------------------
289
- def test_array2d_to_array1d_1d_a (self ) -> None :
289
+ def test_array_to_tuple_array_1d_a (self ) -> None :
290
290
a1 = np .arange (10 )
291
291
a2 = array_to_tuple_array (a1 )
292
292
self .assertEqual (a2 .tolist (), [(0 ,), (1 ,), (2 ,), (3 ,), (4 ,), (5 ,), (6 ,), (7 ,), (8 ,), (9 ,)])
293
293
294
- def test_array2d_to_array1d_1d_b (self ) -> None :
294
+ def test_array_to_tuple_array_1d_b (self ) -> None :
295
295
a1 = np .array (['aaa' , 'b' , 'ccc' ])
296
296
a2 = array_to_tuple_array (a1 )
297
297
self .assertEqual (a2 .tolist (), [('aaa' ,), ('b' ,), ('ccc' ,)])
298
298
299
- def test_array2d_to_array1d_1d_c (self ) -> None :
299
+ def test_array_to_tuple_array_1d_c (self ) -> None :
300
300
a1 = np .array ([None , 'b' , 30 ])
301
301
a2 = array_to_tuple_array (a1 )
302
302
self .assertEqual (a2 .tolist (), [(None ,), ('b' ,), (30 ,)])
303
303
304
- def test_array2d_to_array1d_1d_d (self ) -> None :
304
+ def test_array_to_tuple_array_1d_d (self ) -> None :
305
305
a1 = np .array ([('a' , 10 ), ('b' , 30 ), ('c' , 5 )], dtype = object )
306
306
a2 = array_to_tuple_array (a1 ) # from 2d
307
+ self .assertEqual (a2 .tolist (), [('a' , 10 ), ('b' , 30 ), ('c' , 5 )])
307
308
a3 = array_to_tuple_array (a2 ) # from 1d
308
309
self .assertEqual (a3 .tolist (), [('a' , 10 ), ('b' , 30 ), ('c' , 5 )])
309
310
310
- def test_array2d_to_array1d_1d_e (self ) -> None :
311
+ def test_array_to_tuple_array_1d_e (self ) -> None :
311
312
a1 = np .array ([True , False , True ], dtype = object )
312
313
a2 = array_to_tuple_array (a1 )
313
314
self .assertIs (a2 [0 ][0 ].__class__ , bool )
314
315
self .assertEqual (a2 .tolist (), [(True ,), (False ,), (True ,)])
315
316
316
- def test_array2d_to_array1d_b (self ) -> None :
317
+ def test_array_to_tuple_array_1d_f (self ) -> None :
318
+ a1 = np .array ([None , None , None ], dtype = object )
319
+ a1 [0 ] = 3
320
+ a1 [1 ] = ('a' , 30 )
321
+ a1 [2 ] = (None , True , 90000000 )
322
+
323
+ a2 = array_to_tuple_array (a1 )
324
+ self .assertEqual (a2 .tolist (), [(3 ,), ('a' , 30 ), (None , True , 90000000 )])
325
+
326
+ a3 = array_to_tuple_array (a2 )
327
+ self .assertEqual (a3 .tolist (), [(3 ,), ('a' , 30 ), (None , True , 90000000 )])
328
+
329
+ def test_array_to_tuple_array_b (self ) -> None :
317
330
a1 = np .arange (10 , dtype = np .int64 ).reshape (5 , 2 )
318
331
result = array_to_tuple_array (a1 )
319
332
assert isinstance (result [0 ], tuple )
@@ -323,18 +336,18 @@ def test_array2d_to_array1d_b(self) -> None:
323
336
self .assertEqual (tuple (result ), ((0 , 1 ), (2 , 3 ), (4 , 5 ), (6 , 7 ), (8 , 9 )))
324
337
325
338
326
- def test_array2d_to_array1d_c (self ) -> None :
339
+ def test_array_to_tuple_array_c (self ) -> None :
327
340
a1 = np .array ([["a" , "b" ], ["ccc" , "ddd" ], ["ee" , "ff" ]])
328
341
a2 = array_to_tuple_array (a1 )
329
342
self .assertEqual (a2 .tolist (), [('a' , 'b' ), ('ccc' , 'ddd' ), ('ee' , 'ff' )])
330
343
331
- def test_array2d_to_array1d_d (self ) -> None :
344
+ def test_array_to_tuple_array_d (self ) -> None :
332
345
a1 = np .array ([[3 , 5 ], [10 , 20 ], [7 , 2 ]], dtype = np .uint8 )
333
346
a2 = array_to_tuple_array (a1 )
334
347
self .assertEqual (a2 .tolist (), [(3 , 5 ), (10 , 20 ), (7 , 2 )])
335
348
self .assertIs (type (a2 [0 ][0 ]), np .uint8 )
336
349
337
- def test_array2d_to_array1d_e (self ) -> None :
350
+ def test_array_to_tuple_array_e (self ) -> None :
338
351
a1 = np .arange (20 , dtype = np .int64 ).reshape (4 , 5 )
339
352
result = array_to_tuple_array (a1 )
340
353
self .assertEqual (result .tolist (), [(0 , 1 , 2 , 3 , 4 ), (5 , 6 , 7 , 8 , 9 ), (10 , 11 , 12 , 13 , 14 ), (15 , 16 , 17 , 18 , 19 )])
0 commit comments