6
6
import nose
7
7
from nose .tools import assert_equal , assert_true
8
8
import numpy as np
9
+ import pandas as pd
9
10
from pandas .tslib import iNaT , NaT
10
11
from pandas import Series , DataFrame , date_range , DatetimeIndex , Timestamp , Float64Index
11
12
from pandas import compat
@@ -40,6 +41,7 @@ def __getitem__(self):
40
41
41
42
assert (not is_seq (A ()))
42
43
44
+
43
45
def test_get_callable_name ():
44
46
from functools import partial
45
47
getname = com ._get_callable_name
@@ -49,6 +51,7 @@ def fn(x):
49
51
lambda_ = lambda x : x
50
52
part1 = partial (fn )
51
53
part2 = partial (part1 )
54
+
52
55
class somecall (object ):
53
56
def __call__ (self ):
54
57
return x
@@ -60,6 +63,38 @@ def __call__(self):
60
63
assert getname (somecall ()) == 'somecall'
61
64
assert getname (1 ) is None
62
65
66
+ #Issue 10859
67
+ class TestABCClasses (tm .TestCase ):
68
+ tuples = [[1 , 2 , 2 ], ['red' , 'blue' , 'red' ]]
69
+ multi_index = pd .MultiIndex .from_arrays (tuples , names = ('number' , 'color' ))
70
+ datetime_index = pd .to_datetime (['2000/1/1' , '2010/1/1' ])
71
+ timedelta_index = pd .to_timedelta (np .arange (5 ), unit = 's' )
72
+ period_index = pd .period_range ('2000/1/1' , '2010/1/1/' , freq = 'M' )
73
+ categorical = pd .Categorical ([1 , 2 , 3 ], categories = [2 , 3 , 1 ])
74
+ categorical_df = pd .DataFrame ({"values" : [1 , 2 , 3 ]}, index = categorical )
75
+ df = pd .DataFrame ({'names' : ['a' , 'b' , 'c' ]}, index = multi_index )
76
+ sparse_series = pd .Series ([1 , 2 , 3 ]).to_sparse ()
77
+ sparse_array = pd .SparseArray (np .random .randn (10 ))
78
+
79
+ def test_abc_types (self ):
80
+ self .assertIsInstance (pd .Index (['a' , 'b' , 'c' ]), com .ABCIndex )
81
+ self .assertIsInstance (pd .Int64Index ([1 , 2 , 3 ]), com .ABCInt64Index )
82
+ self .assertIsInstance (pd .Float64Index ([1 , 2 , 3 ]), com .ABCFloat64Index )
83
+ self .assertIsInstance (self .multi_index , com .ABCMultiIndex )
84
+ self .assertIsInstance (self .datetime_index , com .ABCDatetimeIndex )
85
+ self .assertIsInstance (self .timedelta_index , com .ABCTimedeltaIndex )
86
+ self .assertIsInstance (self .period_index , com .ABCPeriodIndex )
87
+ self .assertIsInstance (self .categorical_df .index , com .ABCCategoricalIndex )
88
+ self .assertIsInstance (pd .Index (['a' , 'b' , 'c' ]), com .ABCIndexClass )
89
+ self .assertIsInstance (pd .Int64Index ([1 , 2 , 3 ]), com .ABCIndexClass )
90
+ self .assertIsInstance (pd .Series ([1 , 2 , 3 ]), com .ABCSeries )
91
+ self .assertIsInstance (self .df , com .ABCDataFrame )
92
+ self .assertIsInstance (self .df .to_panel (), com .ABCPanel )
93
+ self .assertIsInstance (self .sparse_series , com .ABCSparseSeries )
94
+ self .assertIsInstance (self .sparse_array , com .ABCSparseArray )
95
+ self .assertIsInstance (self .categorical , com .ABCCategorical )
96
+ self .assertIsInstance (pd .Period ('2012' , freq = 'A-DEC' ), com .ABCPeriod )
97
+
63
98
64
99
def test_notnull ():
65
100
assert notnull (1. )
@@ -942,7 +977,7 @@ def test_2d_float32(self):
942
977
943
978
def test_2d_datetime64 (self ):
944
979
# 2005/01/01 - 2006/01/01
945
- arr = np .random .randint (long (11045376 ), long (11360736 ), (5 ,3 ))* 100000000000
980
+ arr = np .random .randint (long (11045376 ), long (11360736 ), (5 , 3 ))* 100000000000
946
981
arr = arr .view (dtype = 'datetime64[ns]' )
947
982
indexer = [0 , 2 , - 1 , 1 , - 1 ]
948
983
@@ -1026,6 +1061,7 @@ def test_dict_compat():
1026
1061
assert (com ._dict_compat (expected ) == expected )
1027
1062
assert (com ._dict_compat (data_unchanged ) == data_unchanged )
1028
1063
1064
+
1029
1065
def test_possibly_convert_objects_copy ():
1030
1066
values = np .array ([1 , 2 ])
1031
1067
0 commit comments