Hey Mike,

Hmmm I don't see LinkAtom or LinkCol anywhere in my source.
Can you try to determine which file they are coming from.  What
does type(LinkAtom) say?

Be Well
Anthony

On Wed, Jun 22, 2011 at 6:41 PM, Tallhamer, Mike <
mike.tallha...@usoncology.com> wrote:

> Here is some additional information on the issue...
>
> I see that if I type the following in ipython...
>
> [1] import tables
>
> I do get access to tables.LinkAtom and tables.LinkCol
>
> If I type...
>
> [2] from tables import *
>
> Neither LinkAtom or LinkCol are available. Furthermore, if I use
> tables.LinkCol in an IsDescription class and try to assign a string to
> it I get a TypeError like the one below.
>
> In [3]: class Test(IsDescription):
>   ...:     name = StringCol(100)
>   ...:     link_col = tables.LinkCol(100)
>   ...:
>   ...:
>
> In [4]: h5file = openFile('mytables.h5','w')
>
> In [5]: h5file.createTable('/', 'Test', Test, title='Test Table')
>
> ------------------------------------------------------------------------
> ---
> TypeError                                 Traceback (most recent call
> last)
>
> C:\tmp\<ipython console> in <module>()
>
> C:\Python27\lib\site-packages\tables\file.pyc in createTable(self,
> where, name,
> description, title, filters, expectedrows, chunkshape, byteorder,
> createparents)
>    772                      description=description, title=title,
>    773                      filters=filters, expectedrows=expectedrows,
> --> 774                      chunkshape=chunkshape, byteorder=byteorder)
>    775
>    776
>
> C:\Python27\lib\site-packages\tables\table.pyc in __init__(self,
> parentNode, name, description, title, filters, expectedrows, chunkshape,
> byteorder, _log)
>    590
>    591         super(Table, self).__init__(parentNode, name, new,
> filters,
> --> 592                                     byteorder, _log)
>    593
>    594
>
> C:\Python27\lib\site-packages\tables\leaf.pyc in __init__(self,
> parentNode, name, new, filters, byteorder, _log)
>    289         # is a lazy property that automatically handles their
> loading.
>
>    290
> --> 291         super(Leaf, self).__init__(parentNode, name, _log)
>    292
>    293
>
> C:\Python27\lib\site-packages\tables\node.pyc in __init__(self,
> parentNode, name, _log)
>    294             #   Create or open the node and get its object ID.
>
>    295             if new:
> --> 296                 self._v_objectID = self._g_create()
>    297             else:
>    298                 self._v_objectID = self._g_open()
>
> C:\Python27\lib\site-packages\tables\table.pyc in _g_create(self)
>    745         # set because it is needed for setting attributes
> afterwards.
>
>    746         self._v_objectID = self._createTable(
> --> 747             self._v_new_title, self.filters.complib or '',
> obversion )
>    748         self._v_recarray = None  # not useful anymore
>    749         self._rabyteorder = None # not useful anymore
>
> C:\Python27\lib\site-packages\tables\tableExtension.pyd in
> tables.tableExtension.Table._createTable
> (tables\tableExtension.c:1822)()
>
> C:\Python27\lib\site-packages\tables\utilsExtension.pyd in
> tables.utilsExtension.createNestedType (tables\utilsExtension.c:7912)()
>
> C:\Python27\lib\site-packages\tables\utilsExtension.pyd in
> tables.utilsExtension.AtomToHDF5Type (tables\utilsExtension.c:5703)()
>
> TypeError: Invalid type for atom LinkCol(itemsize=100, shape=(),
> dflt='', pos=0)
>
>
>
> Any thoughts or ideas?
>
> -Mike
>
>
>
> -----Original Message-----
>
> I would like to create my own atom class but appear to be doing
> something wrong. I basically just need a StringAtom but want to define a
> new class with a new PyTables 'kind' of 'link' instead of 'string.'
>
> I have added the following code to the atom.py file...
>
> class LinkAtom(Atom):
>    """
>    Defines an atom of type ``link``.
>
>    The item size is the *maximum* length in characters of strings.
>    """
>    kind = 'link'
>    itemsize = property(
>        lambda self: self.dtype.base.itemsize,
>        None, None, "Size in bytes of a sigle item in the atom." )
>    type = 'string'
>    _defvalue = ''
>
>    def __init__(self, itemsize, shape=(), dflt=_defvalue):
>        if not hasattr(itemsize, '__int__') or int(itemsize) < 0:
>            raise ValueError( "invalid item size for kind ``%s``: %r; "
>                              "it must be a positive integer"
>                              % ('string', itemsize) )
>        Atom.__init__(self, 'S%d' % itemsize, shape, dflt)
>
>
> However, when I run ipython and import tables a LinkAtom and by
> extension a LinkCol is not created. Can someone tell me what I'm doing
> wrong? This method of generating class in PyTables doesn't seen to be
> very intuitive and/or pythonic.
>
> -Mike
> </pre>The contents of this electronic mail message and any attachments are
> confidential, possibly privileged and intended for the addressee(s)
> only.<br>Only the addressee(s) may read, disseminate, retain or otherwise
> use this message. If received in error, please immediately inform the sender
> and then delete this message without disclosing its contents to
> anyone.</pre>
>
>
>
> ------------------------------------------------------------------------------
> Simplify data backup and recovery for your virtual environment with
> vRanger.
> Installation's a snap, and flexible recovery options mean your data is
> safe,
> secure and there when you need it. Data protection magic?
> Nope - It's vRanger. Get your free trial download today.
> http://p.sf.net/sfu/quest-sfdev2dev
> _______________________________________________
> Pytables-users mailing list
> Pytables-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/pytables-users
>
------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger.
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today.
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users

Reply via email to