@@ -451,36 +451,35 @@ def test_dti_constructor_preserve_dti_freq(self):
451
451
rng2 = DatetimeIndex (rng )
452
452
assert rng .freq == rng2 .freq
453
453
454
- def test_dti_constructor_years_only (self ):
454
+ @pytest .mark .parametrize ('tz' , [None , 'UTC' , 'Asia/Tokyo' ,
455
+ 'dateutil/US/Pacific' ])
456
+ def test_dti_constructor_years_only (self , tz ):
455
457
# GH 6961
456
- for tz in [None , 'UTC' , 'Asia/Tokyo' , 'dateutil/US/Pacific' ]:
457
- rng1 = date_range ('2014' , '2015' , freq = 'M' , tz = tz )
458
- expected1 = date_range ('2014-01-31' , '2014-12-31' , freq = 'M' , tz = tz )
458
+ rng1 = date_range ('2014' , '2015' , freq = 'M' , tz = tz )
459
+ expected1 = date_range ('2014-01-31' , '2014-12-31' , freq = 'M' , tz = tz )
459
460
460
- rng2 = date_range ('2014' , '2015' , freq = 'MS' , tz = tz )
461
- expected2 = date_range ('2014-01-01' , '2015-01-01' , freq = 'MS' ,
462
- tz = tz )
461
+ rng2 = date_range ('2014' , '2015' , freq = 'MS' , tz = tz )
462
+ expected2 = date_range ('2014-01-01' , '2015-01-01' , freq = 'MS' , tz = tz )
463
463
464
- rng3 = date_range ('2014' , '2020' , freq = 'A' , tz = tz )
465
- expected3 = date_range ('2014-12-31' , '2019-12-31' , freq = 'A' , tz = tz )
464
+ rng3 = date_range ('2014' , '2020' , freq = 'A' , tz = tz )
465
+ expected3 = date_range ('2014-12-31' , '2019-12-31' , freq = 'A' , tz = tz )
466
466
467
- rng4 = date_range ('2014' , '2020' , freq = 'AS' , tz = tz )
468
- expected4 = date_range ('2014-01-01' , '2020-01-01' , freq = 'AS' ,
469
- tz = tz )
467
+ rng4 = date_range ('2014' , '2020' , freq = 'AS' , tz = tz )
468
+ expected4 = date_range ('2014-01-01' , '2020-01-01' , freq = 'AS' , tz = tz )
470
469
471
- for rng , expected in [(rng1 , expected1 ), (rng2 , expected2 ),
472
- (rng3 , expected3 ), (rng4 , expected4 )]:
473
- tm .assert_index_equal (rng , expected )
470
+ for rng , expected in [(rng1 , expected1 ), (rng2 , expected2 ),
471
+ (rng3 , expected3 ), (rng4 , expected4 )]:
472
+ tm .assert_index_equal (rng , expected )
474
473
475
- def test_dti_constructor_small_int (self ):
474
+ @pytest .mark .parametrize ('dtype' , [np .int64 , np .int32 , np .int16 , np .int8 ])
475
+ def test_dti_constructor_small_int (self , dtype ):
476
476
# GH 13721
477
477
exp = DatetimeIndex (['1970-01-01 00:00:00.00000000' ,
478
478
'1970-01-01 00:00:00.00000001' ,
479
479
'1970-01-01 00:00:00.00000002' ])
480
480
481
- for dtype in [np .int64 , np .int32 , np .int16 , np .int8 ]:
482
- arr = np .array ([0 , 10 , 20 ], dtype = dtype )
483
- tm .assert_index_equal (DatetimeIndex (arr ), exp )
481
+ arr = np .array ([0 , 10 , 20 ], dtype = dtype )
482
+ tm .assert_index_equal (DatetimeIndex (arr ), exp )
484
483
485
484
def test_ctor_str_intraday (self ):
486
485
rng = DatetimeIndex (['1-1-2000 00:00:01' ])
@@ -499,7 +498,7 @@ def test_index_cast_datetime64_other_units(self):
499
498
assert (idx .values == conversion .ensure_datetime64ns (arr )).all ()
500
499
501
500
def test_constructor_int64_nocopy (self ):
502
- # #1624
501
+ # GH #1624
503
502
arr = np .arange (1000 , dtype = np .int64 )
504
503
index = DatetimeIndex (arr )
505
504
@@ -512,19 +511,17 @@ def test_constructor_int64_nocopy(self):
512
511
arr [50 :100 ] = - 1
513
512
assert (index .asi8 [50 :100 ] != - 1 ).all ()
514
513
515
- def test_from_freq_recreate_from_data (self ):
516
- freqs = ['M' , 'Q' , 'A' , 'D' , 'B' , 'BH' , 'T' , 'S' , 'L' , 'U' , 'H' , 'N' ,
517
- 'C' ]
518
-
519
- for f in freqs :
520
- org = DatetimeIndex (start = '2001/02/01 09:00' , freq = f , periods = 1 )
521
- idx = DatetimeIndex (org , freq = f )
522
- tm .assert_index_equal (idx , org )
523
-
524
- org = DatetimeIndex (start = '2001/02/01 09:00' , freq = f ,
525
- tz = 'US/Pacific' , periods = 1 )
526
- idx = DatetimeIndex (org , freq = f , tz = 'US/Pacific' )
527
- tm .assert_index_equal (idx , org )
514
+ @pytest .mark .parametrize ('freq' , ['M' , 'Q' , 'A' , 'D' , 'B' , 'BH' ,
515
+ 'T' , 'S' , 'L' , 'U' , 'H' , 'N' , 'C' ])
516
+ def test_from_freq_recreate_from_data (self , freq ):
517
+ org = DatetimeIndex (start = '2001/02/01 09:00' , freq = freq , periods = 1 )
518
+ idx = DatetimeIndex (org , freq = freq )
519
+ tm .assert_index_equal (idx , org )
520
+
521
+ org = DatetimeIndex (start = '2001/02/01 09:00' , freq = freq ,
522
+ tz = 'US/Pacific' , periods = 1 )
523
+ idx = DatetimeIndex (org , freq = freq , tz = 'US/Pacific' )
524
+ tm .assert_index_equal (idx , org )
528
525
529
526
def test_datetimeindex_constructor_misc (self ):
530
527
arr = ['1/1/2005' , '1/2/2005' , 'Jn 3, 2005' , '2005-01-04' ]
0 commit comments