[pymvpa] PyMVPA for Python 3 -- first report

Yaroslav Halchenko debian at onerussian.com
Thu Apr 19 13:53:04 UTC 2012


On Thu, 19 Apr 2012, Tiziano Zito wrote:
> a first report of my efforts for a py3 version of PyMVPA. Put aside
> a couple of incompatibilities in the swig wrappers and the usage of
> some deprecated functions and modules that were easily fixable, my
> PyMVPA port now runs succesfully 67 out of 127 quick-non-labile
> tests :)

awesome -- thank you Tiziano!

I have added your py3k branch to testing battery anyways to see if
nothing in python2 world gets broken.  So expect an email next day (I
will modify the script in place so nothing will be reflected in GIT...
Later on we will tune it up for py3 as well anyways)

> the reason I am writing to the list is that almost of all of the
> remaining errors are exactly of the same type: 

> AttributeError: 'XXX' object has no attribute 'ca'

And that looks like the one possible place I told you about -- custom
__metaclass__'ing in 

mvpa2/base/state.py:    __metaclass__ = AttributesCollector

that AttributesCollector  should construct the classes and extend them
with possible collections (listed in _ATTRIBUTE_COLLECTIONS
attribute of those classes).  It actually just precrafts those
collections, assignes (via setattr) to _collections_template, which then
in the instance constructor does evil

        if not s__dict__.has_key('_collections'):
            s__class__ = self.__class__
                
            collections = copy.deepcopy(s__class__._collections_template)
            s__dict__['_collections'] = collections
            s__dict__['_known_attribs'] = {}
            """Dictionary to contain 'links' to the collections from each
            known attribute. Is used to gain some speed up in lookup within
            __getattribute__ and __setattr__
            """
and relies on __getattribute__ to spit them out upon request

NB this all collections business is quite old hackery and might need to
   go away or be heavily refactored

> I suspect this is involved in some magic happening in
> mvpa2.base.{attributes,collections}, but I have a hard time trying
> to understand where the hell this attribute 'ca' is supposed to be
> set. as there are metaclasses involved, I figured I may be better
> off just asking what is the intent of that code and how it is
> supposed to work. note that lib2to3 has no problems converting
> metaclasses (we have several of them successfully converted in MDP),
> so the problem lies somewhere else. 

My guess is that it is still related to how that AttributesCollector
injects those additional attributes into the freshly constructed
classes.  I hope above clues would be of help

you might also benefit from looking at what is happening if you set

MVPA_DEBUG=COLR

and for even more joy

MVPA_DEBUG=ATTRREFER,COLR

;-)

> if you want to test yourself, install python3-numpy on debian (or
> put a python3 numpy in your PYTHONPATH), clone my repo on github
> [1], switch to py3k branch and just run

> make unittest-py3

cool -- will do!

-- 
=------------------------------------------------------------------=
Keep in touch                                     www.onerussian.com
Yaroslav Halchenko                 www.ohloh.net/accounts/yarikoptic



More information about the Pkg-ExpPsy-PyMVPA mailing list