7
7
import pandas as pd
8
8
9
9
from xray import Variable , Dataset , DataArray , indexing
10
- from xray .variable import (Index , as_variable , NumpyArrayAdapter ,
10
+ from xray .variable import (XIndex , as_variable , NumpyArrayAdapter ,
11
11
PandasIndexAdapter , _as_compatible_data )
12
12
from xray .pycompat import PY3 , OrderedDict
13
13
@@ -171,9 +171,9 @@ def test_1d_math(self):
171
171
self .assertEqual (float , (0 + v ).values .dtype )
172
172
# check types of returned data
173
173
self .assertIsInstance (+ v , Variable )
174
- self .assertNotIsInstance (+ v , Index )
174
+ self .assertNotIsInstance (+ v , XIndex )
175
175
self .assertIsInstance (0 + v , Variable )
176
- self .assertNotIsInstance (0 + v , Index )
176
+ self .assertNotIsInstance (0 + v , XIndex )
177
177
178
178
def test_1d_reduce (self ):
179
179
x = np .arange (5 )
@@ -194,7 +194,7 @@ def test_array_interface(self):
194
194
# test ufuncs
195
195
self .assertVariableIdentical (np .sin (v ), self .cls (['x' ], np .sin (x )))
196
196
self .assertIsInstance (np .sin (v ), Variable )
197
- self .assertNotIsInstance (np .sin (v ), Index )
197
+ self .assertNotIsInstance (np .sin (v ), XIndex )
198
198
199
199
def example_1d_objects (self ):
200
200
for data in [range (3 ),
@@ -299,7 +299,7 @@ def test_numpy_same_methods(self):
299
299
self .assertEqual (v .item (), 0 )
300
300
self .assertIs (type (v .item ()), float )
301
301
302
- v = Index ('x' , np .arange (5 ))
302
+ v = XIndex ('x' , np .arange (5 ))
303
303
self .assertEqual (2 , v .searchsorted (2 ))
304
304
305
305
def test_datetime64_conversion (self ):
@@ -566,27 +566,27 @@ def test_reduce_keep_attrs(self):
566
566
self .assertEqual (vm .attrs , _attrs )
567
567
568
568
569
- class TestIndex (TestCase , VariableSubclassTestCases ):
570
- cls = staticmethod (Index )
569
+ class TestXIndex (TestCase , VariableSubclassTestCases ):
570
+ cls = staticmethod (XIndex )
571
571
572
572
def test_init (self ):
573
573
with self .assertRaisesRegexp (ValueError , 'must be 1-dimensional' ):
574
- Index ((), 0 )
574
+ XIndex ((), 0 )
575
575
576
576
def test_as_index (self ):
577
577
data = 0.5 * np .arange (10 )
578
- v = Index (['time' ], data , {'foo' : 'bar' })
579
- self .assertTrue (pd .Index (data , name = 'time' ).identical (v .as_pandas ))
578
+ v = XIndex (['time' ], data , {'foo' : 'bar' })
579
+ self .assertTrue (pd .Index (data , name = 'time' ).identical (v .as_index ))
580
580
581
581
def test_data (self ):
582
- x = Index ('x' , np .arange (3.0 ))
582
+ x = XIndex ('x' , np .arange (3.0 ))
583
583
# data should be initially saved as an ndarray
584
584
self .assertIs (type (x ._data ), NumpyArrayAdapter )
585
585
self .assertEqual (float , x .dtype )
586
586
self .assertArrayEqual (np .arange (3 ), x )
587
587
self .assertEqual (float , x .values .dtype )
588
588
self .assertEqual ('x' , x .name )
589
- # after inspecting x.values, the Index will be saved as an Index
589
+ # after inspecting x.values, the XIndex value will be saved as an Index
590
590
self .assertIsInstance (x ._data , PandasIndexAdapter )
591
591
with self .assertRaisesRegexp (TypeError , 'cannot be modified' ):
592
592
x [:] = 0
@@ -595,7 +595,7 @@ def test_avoid_index_dtype_inference(self):
595
595
# verify our work-around for (pandas<0.14):
596
596
# https://github.com/pydata/pandas/issues/6370
597
597
data = pd .date_range ('2000-01-01' , periods = 3 ).to_pydatetime ()
598
- t = Index ('t' , data )
598
+ t = XIndex ('t' , data )
599
599
self .assertArrayEqual (t .values [:2 ], data [:2 ])
600
600
self .assertArrayEqual (t [:2 ].values , data [:2 ])
601
601
self .assertArrayEqual (t .values [:2 ], data [:2 ])
0 commit comments