def append_columns(classdict, shape=()): """ Append a ``Col`` of each PyTables data type to the `classdict`. A column of a certain TYPE gets called ``c_TYPE``. The number of added columns is returned. """ heavy = common.heavy for (itype, type_) in enumerate(sorted(type_info.iterkeys())): if not heavy and type_ in heavy_types: continue # skip heavy type in non-heavy mode colpos = itype + 1 colname = 'c_%s' % type_ if type_ == 'enum': base = tables.Atom.from_sctype(sctype_from_type[type_]) col = tables.EnumCol(enum, enum(0), base, shape=shape, pos=colpos) else: sctype = sctype_from_type[type_] dtype = numpy.dtype((sctype, shape)) col = tables.Col.from_dtype(dtype, pos=colpos) classdict[colname] = col ncols = colpos return ncols
class Test(tables.IsDescription): """A description that has several columns""" x = tables.Int32Col(shape=2, dflt=0, pos=0) y = tables.Float64Col(dflt=1.2, shape=(2, 3)) z = tables.UInt8Col(dflt=1) color = tables.EnumCol(colors, 'red', base='uint32', shape=(2,)) Info = Info() class extra_info(tables.IsDescription): _v_pos = 1 name = tables.StringCol(10) value = tables.Float64Col(pos=0) y2 = tables.Float64Col(dflt=1, shape=(2, 3), pos=1) z2 = tables.UInt8Col(dflt=1) class info2(tables.IsDescription): y3 = tables.Float64Col(dflt=1, shape=(2, 3)) z3 = tables.UInt8Col(dflt=1) name = tables.StringCol(10) value = tables.EnumCol(colors, 'blue', base='uint32', shape=(1,)) class info3(tables.IsDescription): name = tables.StringCol(10) value = tables.Time64Col() y4 = tables.Float64Col(dflt=1, shape=(2, 3)) z4 = tables.UInt8Col(dflt=1)
class BallExt(tables.IsDescription): ballTime = tables.Time32Col() ballColor = tables.EnumCol(colors, 'black', base='uint8')
class Info2(t.IsDescription): y3 = t.Time64Col(dflt=1, shape=2) z3 = t.EnumCol({'r':4, 'g':2, 'b':1}, 'r', 'int32', shape=2) name = t.StringCol(itemsize=2) value = t.ComplexCol(itemsize=16, shape=2)
class TestDescription(tables.IsDescription): rid = tables.IntCol(pos=0) rcolor = tables.EnumCol( self.enum, self.defaultName, base=self.enumType, shape=shape, pos=1)
class TimeMask(tables.IsDescription): """The pytables derived class that stores time intervals to be masked""" tBegin = tables.UInt32Col() # beginning time of this mask (clock ticks) tEnd = tables.UInt32Col() # ending time of this mask (clock ticks) reason = tables.EnumCol(timeMaskReason, "unknown", base='uint8')
def test04a_validReprEnum(self): """Checking the string representation of an enumeration.""" colors = tables.Enum(['red', 'green', 'blue']) enumcol = tables.EnumCol(colors, 'red', base='uint32', shape=()) assert repr(enumcol) == \ """EnumCol(enum=Enum({'blue': 2, 'green': 1, 'red': 0}), dflt='red', base=UInt32Atom(shape=(), dflt=0), shape=(), pos=None)"""
class MemMapEntry(tables.IsDescription): name = tables.StringCol(512) startaddr = tables.UInt32Col() endaddr = tables.UInt32Col() perms = tables.EnumCol(perms, '?', base='uint8') kind = tables.EnumCol(mmap_type, 'other', base='uint8')