13
13
DateOffset , Week , YearBegin , YearEnd , Hour , Minute , Second , Day , Micro ,
14
14
Milli , Nano ,
15
15
WeekOfMonth , format , ole2datetime , QuarterEnd , to_datetime , normalize_date ,
16
- get_offset , get_offset_name , inferTimeRule , hasOffsetName ,
17
- get_standard_freq )
16
+ get_offset , get_offset_name , hasOffsetName , get_standard_freq )
18
17
19
18
from pandas .tseries .frequencies import _offset_map
20
19
from pandas .tseries .index import _to_m8 , DatetimeIndex , _daterange_cache
@@ -532,7 +531,7 @@ def test_repr(self):
532
531
self .assertEqual (repr (Week (weekday = 0 )), "<Week: weekday=0>" )
533
532
self .assertEqual (repr (Week (n = - 1 , weekday = 0 )), "<-1 * Week: weekday=0>" )
534
533
self .assertEqual (repr (Week (n = - 2 , weekday = 0 )), "<-2 * Weeks: weekday=0>" )
535
-
534
+
536
535
def test_corner (self ):
537
536
self .assertRaises (ValueError , Week , weekday = 7 )
538
537
assertRaisesRegexp (ValueError , "Day must be" , Week , weekday = - 1 )
@@ -905,7 +904,7 @@ def test_onOffset(self):
905
904
906
905
907
906
class TestBQuarterBegin (unittest .TestCase ):
908
-
907
+
909
908
def test_repr (self ):
910
909
self .assertEqual (repr (BQuarterBegin ()),"<BusinessQuarterBegin: startingMonth=3>" )
911
910
self .assertEqual (repr (BQuarterBegin (startingMonth = 3 )), "<BusinessQuarterBegin: startingMonth=3>" )
@@ -1000,7 +999,7 @@ def test_repr(self):
1000
999
self .assertEqual (repr (BQuarterEnd ()),"<BusinessQuarterEnd: startingMonth=3>" )
1001
1000
self .assertEqual (repr (BQuarterEnd (startingMonth = 3 )), "<BusinessQuarterEnd: startingMonth=3>" )
1002
1001
self .assertEqual (repr (BQuarterEnd (startingMonth = 1 )), "<BusinessQuarterEnd: startingMonth=1>" )
1003
-
1002
+
1004
1003
def test_isAnchored (self ):
1005
1004
self .assert_ (BQuarterEnd (startingMonth = 1 ).isAnchored ())
1006
1005
self .assert_ (BQuarterEnd ().isAnchored ())
@@ -1107,7 +1106,7 @@ def test_repr(self):
1107
1106
self .assertEqual (repr (QuarterBegin ()), "<QuarterBegin: startingMonth=3>" )
1108
1107
self .assertEqual (repr (QuarterBegin (startingMonth = 3 )), "<QuarterBegin: startingMonth=3>" )
1109
1108
self .assertEqual (repr (QuarterBegin (startingMonth = 1 )),"<QuarterBegin: startingMonth=1>" )
1110
-
1109
+
1111
1110
def test_isAnchored (self ):
1112
1111
self .assert_ (QuarterBegin (startingMonth = 1 ).isAnchored ())
1113
1112
self .assert_ (QuarterBegin ().isAnchored ())
@@ -1181,7 +1180,7 @@ def test_repr(self):
1181
1180
self .assertEqual (repr (QuarterEnd ()), "<QuarterEnd: startingMonth=3>" )
1182
1181
self .assertEqual (repr (QuarterEnd (startingMonth = 3 )), "<QuarterEnd: startingMonth=3>" )
1183
1182
self .assertEqual (repr (QuarterEnd (startingMonth = 1 )), "<QuarterEnd: startingMonth=1>" )
1184
-
1183
+
1185
1184
def test_isAnchored (self ):
1186
1185
self .assert_ (QuarterEnd (startingMonth = 1 ).isAnchored ())
1187
1186
self .assert_ (QuarterEnd ().isAnchored ())
@@ -1631,6 +1630,7 @@ def assertEq(offset, base, expected):
1631
1630
"\n At Date: %s" %
1632
1631
(expected , actual , offset , base ))
1633
1632
1633
+
1634
1634
def test_Hour ():
1635
1635
assertEq (Hour (), datetime (2010 , 1 , 1 ), datetime (2010 , 1 , 1 , 1 ))
1636
1636
assertEq (Hour (- 1 ), datetime (2010 , 1 , 1 , 1 ), datetime (2010 , 1 , 1 ))
@@ -1698,6 +1698,8 @@ def test_Microsecond():
1698
1698
1699
1699
1700
1700
def test_NanosecondGeneric ():
1701
+ if _np_version_under1p7 :
1702
+ raise nose .SkipTest ('numpy >= 1.7 required' )
1701
1703
timestamp = Timestamp (datetime (2010 , 1 , 1 ))
1702
1704
assert timestamp .nanosecond == 0
1703
1705
@@ -1710,7 +1712,6 @@ def test_NanosecondGeneric():
1710
1712
1711
1713
def test_Nanosecond ():
1712
1714
if _np_version_under1p7 :
1713
- import nose
1714
1715
raise nose .SkipTest ('numpy >= 1.7 required' )
1715
1716
1716
1717
timestamp = Timestamp (datetime (2010 , 1 , 1 ))
@@ -1815,8 +1816,6 @@ def setUp(self):
1815
1816
pass
1816
1817
1817
1818
def test_alias_equality (self ):
1818
- from pandas .tseries .frequencies import _offset_map
1819
-
1820
1819
for k , v in compat .iteritems (_offset_map ):
1821
1820
if v is None :
1822
1821
continue
@@ -1872,7 +1871,8 @@ def test_freq_offsets():
1872
1871
1873
1872
off = BDay (1 , offset = timedelta (0 , - 1800 ))
1874
1873
assert (off .freqstr == 'B-30Min' )
1875
-
1874
+
1875
+
1876
1876
def get_all_subclasses (cls ):
1877
1877
ret = set ()
1878
1878
this_subclasses = cls .__subclasses__ ()
@@ -1881,40 +1881,41 @@ def get_all_subclasses(cls):
1881
1881
ret | get_all_subclasses (this_subclass )
1882
1882
return ret
1883
1883
1884
- class TestCaching (unittest .TestCase ):
1884
+
1885
+ class TestCaching (unittest .TestCase ):
1885
1886
def test_should_cache_month_end (self ):
1886
1887
self .assertTrue (MonthEnd ()._should_cache ())
1887
-
1888
+
1888
1889
def test_should_cache_bmonth_end (self ):
1889
1890
self .assertTrue (BusinessMonthEnd ()._should_cache ())
1890
-
1891
+
1891
1892
def test_should_cache_week_month (self ):
1892
1893
self .assertTrue (WeekOfMonth (weekday = 1 , week = 2 )._should_cache ())
1893
-
1894
+
1894
1895
def test_all_cacheableoffsets (self ):
1895
1896
for subclass in get_all_subclasses (CacheableOffset ):
1896
1897
if subclass in [WeekOfMonth ]:
1897
1898
continue
1898
1899
self .run_X_index_creation (subclass )
1899
-
1900
+
1900
1901
def setUp (self ):
1901
1902
_daterange_cache .clear ()
1902
-
1903
+
1903
1904
def run_X_index_creation (self , cls ):
1904
1905
inst1 = cls ()
1905
1906
if not inst1 .isAnchored ():
1906
1907
self .assertFalse (inst1 ._should_cache (), cls )
1907
1908
return
1908
-
1909
+
1909
1910
self .assertTrue (inst1 ._should_cache (), cls )
1910
-
1911
+
1911
1912
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,31 ), freq = inst1 , normalize = True )
1912
1913
self .assertTrue (cls () in _daterange_cache , cls )
1913
-
1914
+
1914
1915
def test_month_end_index_creation (self ):
1915
1916
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,31 ), freq = MonthEnd (), normalize = True )
1916
1917
self .assertTrue (MonthEnd () in _daterange_cache )
1917
-
1918
+
1918
1919
def test_bmonth_end_index_creation (self ):
1919
1920
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,29 ), freq = BusinessMonthEnd (), normalize = True )
1920
1921
self .assertTrue (BusinessMonthEnd () in _daterange_cache )
@@ -1924,9 +1925,8 @@ def test_week_of_month_index_creation(self):
1924
1925
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,29 ), freq = inst1 , normalize = True )
1925
1926
inst2 = WeekOfMonth (weekday = 1 , week = 2 )
1926
1927
self .assertTrue (inst2 in _daterange_cache )
1927
-
1928
-
1928
+
1929
+
1929
1930
if __name__ == '__main__' :
1930
- import nose
1931
1931
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
1932
1932
exit = False )
0 commit comments