File tree Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Expand file tree Collapse file tree 2 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -447,11 +447,17 @@ def to_object_array_tuples(list rows):
447
447
448
448
result = np.empty((n, k), dtype = object )
449
449
450
- for i from 0 <= i < n:
451
- row = tuple (rows[i]) # upcast any subclasses to tuple
452
-
453
- for j from 0 <= j < len (row):
454
- result[i, j] = row[j]
450
+ try :
451
+ for i in range (n):
452
+ row = rows[i]
453
+ for j from 0 <= j < len (row):
454
+ result[i, j] = row[j]
455
+ except Exception :
456
+ # upcast any subclasses to tuple
457
+ for i in range (n):
458
+ row = tuple (rows[i])
459
+ for j from 0 <= j < len (row):
460
+ result[i, j] = row[j]
455
461
456
462
return result
457
463
Original file line number Diff line number Diff line change @@ -280,12 +280,15 @@ def test_to_object_array_tuples(self):
280
280
values = [r ]
281
281
result = lib .to_object_array_tuples (values )
282
282
283
- # make sure record array works
284
- import collections as col
285
- record = col .namedtuple ('record' , 'x y' )
286
- r = record (5 ,6 )
287
- values = [r ]
288
- result = lib .to_object_array_tuples (values )
283
+ try :
284
+ # make sure record array works
285
+ from collections import namedtuple
286
+ record = namedtuple ('record' , 'x y' )
287
+ r = record (5 , 6 )
288
+ values = [r ]
289
+ result = lib .to_object_array_tuples (values )
290
+ except ImportError :
291
+ pass
289
292
290
293
class TestMoments (unittest .TestCase ):
291
294
pass
You can’t perform that action at this time.
0 commit comments