@@ -424,7 +424,7 @@ def test_total_seconds(self):
424
424
freq = 's' )
425
425
expt = [1 * 86400 + 10 * 3600 + 11 * 60 + 12 + 100123456. / 1e9 ,
426
426
1 * 86400 + 10 * 3600 + 11 * 60 + 13 + 100123456. / 1e9 ]
427
- tm .assert_almost_equal (rng .total_seconds (), np . array (expt ))
427
+ tm .assert_almost_equal (rng .total_seconds (), Index (expt ))
428
428
429
429
# test Series
430
430
s = Series (rng )
@@ -486,16 +486,16 @@ def test_append_numpy_bug_1681(self):
486
486
def test_fields (self ):
487
487
rng = timedelta_range ('1 days, 10:11:12.100123456' , periods = 2 ,
488
488
freq = 's' )
489
- self .assert_numpy_array_equal (rng .days , np .array (
490
- [1 , 1 ], dtype = 'int64' ))
491
- self .assert_numpy_array_equal (
489
+ self .assert_index_equal (rng .days , Index ([1 , 1 ], dtype = 'int64' ))
490
+ self .assert_index_equal (
492
491
rng .seconds ,
493
- np .array ([10 * 3600 + 11 * 60 + 12 , 10 * 3600 + 11 * 60 + 13 ],
494
- dtype = 'int64' ))
495
- self .assert_numpy_array_equal (rng .microseconds , np .array (
496
- [100 * 1000 + 123 , 100 * 1000 + 123 ], dtype = 'int64' ))
497
- self .assert_numpy_array_equal (rng .nanoseconds , np .array (
498
- [456 , 456 ], dtype = 'int64' ))
492
+ Index ([10 * 3600 + 11 * 60 + 12 , 10 * 3600 + 11 * 60 + 13 ],
493
+ dtype = 'int64' ))
494
+ self .assert_index_equal (
495
+ rng .microseconds ,
496
+ Index ([100 * 1000 + 123 , 100 * 1000 + 123 ], dtype = 'int64' ))
497
+ self .assert_index_equal (rng .nanoseconds ,
498
+ Index ([456 , 456 ], dtype = 'int64' ))
499
499
500
500
self .assertRaises (AttributeError , lambda : rng .hours )
501
501
self .assertRaises (AttributeError , lambda : rng .minutes )
@@ -509,6 +509,10 @@ def test_fields(self):
509
509
tm .assert_series_equal (s .dt .seconds , Series (
510
510
[10 * 3600 + 11 * 60 + 12 , np .nan ], index = [0 , 1 ]))
511
511
512
+ # preserve name (GH15589)
513
+ rng .name = 'name'
514
+ assert rng .days .name == 'name'
515
+
512
516
def test_freq_conversion (self ):
513
517
514
518
# doc example
0 commit comments