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 ))
@@ -1710,7 +1710,6 @@ def test_NanosecondGeneric():
1710
1710
1711
1711
def test_Nanosecond ():
1712
1712
if _np_version_under1p7 :
1713
- import nose
1714
1713
raise nose .SkipTest ('numpy >= 1.7 required' )
1715
1714
1716
1715
timestamp = Timestamp (datetime (2010 , 1 , 1 ))
@@ -1815,8 +1814,6 @@ def setUp(self):
1815
1814
pass
1816
1815
1817
1816
def test_alias_equality (self ):
1818
- from pandas .tseries .frequencies import _offset_map
1819
-
1820
1817
for k , v in compat .iteritems (_offset_map ):
1821
1818
if v is None :
1822
1819
continue
@@ -1872,7 +1869,8 @@ def test_freq_offsets():
1872
1869
1873
1870
off = BDay (1 , offset = timedelta (0 , - 1800 ))
1874
1871
assert (off .freqstr == 'B-30Min' )
1875
-
1872
+
1873
+
1876
1874
def get_all_subclasses (cls ):
1877
1875
ret = set ()
1878
1876
this_subclasses = cls .__subclasses__ ()
@@ -1881,40 +1879,41 @@ def get_all_subclasses(cls):
1881
1879
ret | get_all_subclasses (this_subclass )
1882
1880
return ret
1883
1881
1884
- class TestCaching (unittest .TestCase ):
1882
+
1883
+ class TestCaching (unittest .TestCase ):
1885
1884
def test_should_cache_month_end (self ):
1886
1885
self .assertTrue (MonthEnd ()._should_cache ())
1887
-
1886
+
1888
1887
def test_should_cache_bmonth_end (self ):
1889
1888
self .assertTrue (BusinessMonthEnd ()._should_cache ())
1890
-
1889
+
1891
1890
def test_should_cache_week_month (self ):
1892
1891
self .assertTrue (WeekOfMonth (weekday = 1 , week = 2 )._should_cache ())
1893
-
1892
+
1894
1893
def test_all_cacheableoffsets (self ):
1895
1894
for subclass in get_all_subclasses (CacheableOffset ):
1896
1895
if subclass in [WeekOfMonth ]:
1897
1896
continue
1898
1897
self .run_X_index_creation (subclass )
1899
-
1898
+
1900
1899
def setUp (self ):
1901
1900
_daterange_cache .clear ()
1902
-
1901
+
1903
1902
def run_X_index_creation (self , cls ):
1904
1903
inst1 = cls ()
1905
1904
if not inst1 .isAnchored ():
1906
1905
self .assertFalse (inst1 ._should_cache (), cls )
1907
1906
return
1908
-
1907
+
1909
1908
self .assertTrue (inst1 ._should_cache (), cls )
1910
-
1909
+
1911
1910
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,31 ), freq = inst1 , normalize = True )
1912
1911
self .assertTrue (cls () in _daterange_cache , cls )
1913
-
1912
+
1914
1913
def test_month_end_index_creation (self ):
1915
1914
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,31 ), freq = MonthEnd (), normalize = True )
1916
1915
self .assertTrue (MonthEnd () in _daterange_cache )
1917
-
1916
+
1918
1917
def test_bmonth_end_index_creation (self ):
1919
1918
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,29 ), freq = BusinessMonthEnd (), normalize = True )
1920
1919
self .assertTrue (BusinessMonthEnd () in _daterange_cache )
@@ -1924,9 +1923,8 @@ def test_week_of_month_index_creation(self):
1924
1923
DatetimeIndex (start = datetime (2013 ,1 ,31 ), end = datetime (2013 ,3 ,29 ), freq = inst1 , normalize = True )
1925
1924
inst2 = WeekOfMonth (weekday = 1 , week = 2 )
1926
1925
self .assertTrue (inst2 in _daterange_cache )
1927
-
1928
-
1926
+
1927
+
1929
1928
if __name__ == '__main__' :
1930
- import nose
1931
1929
nose .runmodule (argv = [__file__ , '-vvs' , '-x' , '--pdb' , '--pdb-failure' ],
1932
1930
exit = False )
0 commit comments