@@ -84,7 +84,7 @@ def _tables():
84
84
85
85
# version requirements
86
86
major , minor , subv = tables .__version__ .split ('.' )
87
- if int (major ) >= 2 and int (minor ) >= 3 :
87
+ if int (major ) >= 2 and int (minor [ 0 ] ) >= 3 :
88
88
_table_supports_index = True
89
89
90
90
return _table_mod
@@ -400,7 +400,7 @@ def append(self, key, value, **kwargs):
400
400
self ._write_to_group (key , value , table = True , append = True , ** kwargs )
401
401
402
402
def create_table_index (self , key , ** kwargs ):
403
- """ Create a pytables index on the table
403
+ """ Create a pytables index on the table
404
404
Paramaters
405
405
----------
406
406
key : object (the node to index)
@@ -569,7 +569,7 @@ def _read_block_manager(self, group):
569
569
def _write_frame_table (self , group , df , append = False , comp = None , ** kwargs ):
570
570
t = create_table (self , group , typ = 'appendable_frame' )
571
571
t .write (axes_to_index = [0 ], obj = df , append = append , compression = comp , ** kwargs )
572
-
572
+
573
573
def _write_wide (self , group , panel ):
574
574
panel ._consolidate_inplace ()
575
575
self ._write_block_manager (group , panel ._data )
@@ -581,7 +581,7 @@ def _write_wide_table(self, group, panel, append=False, comp=None, **kwargs):
581
581
t = create_table (self , group , typ = 'appendable_panel' )
582
582
t .write (axes_to_index = [1 ,2 ], obj = panel ,
583
583
append = append , compression = comp , ** kwargs )
584
-
584
+
585
585
def _read_wide_table (self , group , where = None ):
586
586
t = create_table (self , group )
587
587
return t .read (where )
@@ -806,15 +806,15 @@ def _read_frame_table(self, group, where=None):
806
806
807
807
808
808
class Col (object ):
809
- """ a column description class
809
+ """ a column description class
810
810
811
811
Parameters
812
812
----------
813
813
814
814
values : the ndarray like converted values
815
815
kind : a string description of this type
816
816
typ : the pytables type
817
-
817
+
818
818
"""
819
819
is_indexable = True
820
820
@@ -906,7 +906,7 @@ def validate_col(self):
906
906
907
907
# validate this column for string truncation (or reset to the max size)
908
908
if self .kind == 'string' :
909
-
909
+
910
910
c = self .col
911
911
if c is not None :
912
912
if c .itemsize < self .itemsize :
@@ -1016,7 +1016,7 @@ class Table(object):
1016
1016
1017
1017
parent : my parent HDFStore
1018
1018
group : the group node where the table resides
1019
-
1019
+
1020
1020
"""
1021
1021
table_type = None
1022
1022
ndim = None
@@ -1047,7 +1047,7 @@ def nrows(self):
1047
1047
@property
1048
1048
def table (self ):
1049
1049
""" return the table group """
1050
- return getattr (self .group , 'table' , None )
1050
+ return getattr (self .group , 'table' , None )
1051
1051
1052
1052
@property
1053
1053
def handle (self ):
@@ -1097,7 +1097,7 @@ def kinds_map(self):
1097
1097
def index_cols (self ):
1098
1098
""" return a list of my index cols """
1099
1099
return [ i .cname for i in self .index_axes ]
1100
-
1100
+
1101
1101
def values_cols (self ):
1102
1102
""" return a list of my values cols """
1103
1103
return [ i .cname for i in self .values_axes ]
@@ -1119,7 +1119,7 @@ def validate(self):
1119
1119
if ic is not None and ic != self .index_cols ():
1120
1120
raise TypeError ("incompatible index cols with existing [%s - %s]" %
1121
1121
(ic , self .index_cols ()))
1122
-
1122
+
1123
1123
@property
1124
1124
def indexables (self ):
1125
1125
""" create/cache the indexables if they don't exist """
@@ -1130,7 +1130,7 @@ def indexables(self):
1130
1130
1131
1131
# index columns
1132
1132
self ._indexables .extend ([ Col (name = i ) for i in self .attrs .index_cols ])
1133
-
1133
+
1134
1134
# data columns
1135
1135
self ._indexables .extend ([ DataCol .create_for_block (i = i ) for i , c in enumerate (self .attrs .values_cols ) ])
1136
1136
@@ -1140,7 +1140,7 @@ def create_index(self, columns = None, optlevel = None, kind = None):
1140
1140
"""
1141
1141
Create a pytables index on the specified columns
1142
1142
note: cannot index Time64Col() currently; PyTables must be >= 2.3.1
1143
-
1143
+
1144
1144
1145
1145
Paramaters
1146
1146
----------
@@ -1309,7 +1309,7 @@ def read(self, where=None):
1309
1309
1310
1310
major = Factor .from_array (index )
1311
1311
minor = Factor .from_array (column )
1312
-
1312
+
1313
1313
J , K = len (major .levels ), len (minor .levels )
1314
1314
key = major .labels * K + minor .labels
1315
1315
@@ -1373,7 +1373,7 @@ def read(self, where=None):
1373
1373
1374
1374
return wp
1375
1375
1376
- def write (self , axes_to_index , obj , append = False , compression = None ,
1376
+ def write (self , axes_to_index , obj , append = False , compression = None ,
1377
1377
complevel = None , min_itemsize = None , ** kwargs ):
1378
1378
1379
1379
# create the table if it doesn't exist (or get it if it does)
@@ -1391,7 +1391,7 @@ def write(self, axes_to_index, obj, append=False, compression=None,
1391
1391
1392
1392
# set the table attributes
1393
1393
self .set_attrs ()
1394
-
1394
+
1395
1395
# create the table
1396
1396
table = self .handle .createTable (self .group , ** options )
1397
1397
@@ -1475,7 +1475,7 @@ def delete(self, where = None):
1475
1475
l .reverse ()
1476
1476
for c in l :
1477
1477
table .removeRows (c )
1478
-
1478
+
1479
1479
self .handle .flush ()
1480
1480
1481
1481
# return the number of rows removed
@@ -1725,7 +1725,7 @@ def _alias_to_class(alias):
1725
1725
1726
1726
1727
1727
class Term (object ):
1728
- """ create a term object that holds a field, op, and value
1728
+ """ create a term object that holds a field, op, and value
1729
1729
1730
1730
Parameters
1731
1731
----------
@@ -1748,7 +1748,7 @@ class Term(object):
1748
1748
Term('index', datetime(2012,11,14))
1749
1749
Term('major>20121114')
1750
1750
Term('minor', ['A','B'])
1751
-
1751
+
1752
1752
"""
1753
1753
1754
1754
_ops = ['<=' ,'<' ,'>=' ,'>' ,'!=' ,'=' ]
@@ -1772,7 +1772,7 @@ def __init__(self, field, op = None, value = None, kinds = None):
1772
1772
op = f [1 ]
1773
1773
if len (f ) > 2 :
1774
1774
value = f [2 ]
1775
-
1775
+
1776
1776
# backwards compatible
1777
1777
if isinstance (field , dict ):
1778
1778
self .field = field .get ('field' )
@@ -1808,7 +1808,7 @@ def __init__(self, field, op = None, value = None, kinds = None):
1808
1808
1809
1809
else :
1810
1810
raise Exception ("Term does not understand the supplied field [%s]" % field )
1811
-
1811
+
1812
1812
# we have valid fields
1813
1813
if self .field is None or self .op is None or self .value is None :
1814
1814
raise Exception ("Could not create this term [%s]" % str (self ))
@@ -1848,19 +1848,19 @@ def kind(self):
1848
1848
1849
1849
def eval (self ):
1850
1850
""" set the numexpr expression for this term """
1851
-
1851
+
1852
1852
# convert values
1853
1853
values = [ self .convert_value (v ) for v in self .value ]
1854
1854
1855
1855
# equality conditions
1856
1856
if self .op in ['=' ,'!=' ]:
1857
-
1857
+
1858
1858
if self .is_in_table :
1859
1859
1860
1860
# too many values to create the expression?
1861
1861
if len (values ) <= 61 :
1862
1862
self .condition = "(%s)" % ' | ' .join ([ "(%s == %s)" % (self .field ,v [0 ]) for v in values ])
1863
-
1863
+
1864
1864
# use a filter after reading
1865
1865
else :
1866
1866
self .filter = set ([ v [1 ] for v in values ])
@@ -1874,7 +1874,7 @@ def eval(self):
1874
1874
if self .is_in_table :
1875
1875
1876
1876
self .condition = '(%s %s %s)' % (self .field , self .op , values [0 ][0 ])
1877
-
1877
+
1878
1878
def convert_value (self , v ):
1879
1879
1880
1880
if self .field == 'index' :
0 commit comments