@@ -580,7 +580,7 @@ def _write_index(self, group, key, index):
580
580
node ._v_attrs .name = index .name
581
581
582
582
if isinstance (index , (DatetimeIndex , PeriodIndex , IntIndex )):
583
- node ._v_attrs .index_class = type (index )
583
+ node ._v_attrs .index_class = _class_to_alias ( type (index ) )
584
584
585
585
if hasattr (index , 'freq' ):
586
586
node ._v_attrs .freq = index .freq
@@ -670,9 +670,7 @@ def _read_index_node(self, node):
670
670
if 'name' in node ._v_attrs :
671
671
name = node ._v_attrs .name
672
672
673
- index_class = getattr (node ._v_attrs , 'index_class' , Index )
674
-
675
- factory = _get_index_factory (index_class )
673
+ index_class = _alias_to_class (getattr (node ._v_attrs , 'index_class' , '' ))
676
674
677
675
kwargs = {}
678
676
if 'freq' in node ._v_attrs :
@@ -1012,6 +1010,22 @@ def _is_table_type(group):
1012
1010
# new node, e.g.
1013
1011
return False
1014
1012
1013
+ _index_type_map = {DatetimeIndex : 'datetime' ,
1014
+ PeriodIndex : 'period' ,
1015
+ IntIndex : 'sparse integer' }
1016
+
1017
+ _reverse_index_map = {}
1018
+ for k , v in _index_type_map .iteritems ():
1019
+ _reverse_index_map [v ] = k
1020
+
1021
+ def _class_to_alias (cls ):
1022
+ return _index_type_map .get (cls , '' )
1023
+
1024
+ def _alias_to_class (alias ):
1025
+ if isinstance (alias , type ):
1026
+ return alias
1027
+ return _reverse_index_map .get (alias , Index )
1028
+
1015
1029
class Selection (object ):
1016
1030
"""
1017
1031
Carries out a selection operation on a tables.Table object.
0 commit comments