arac icon indicating copy to clipboard operation
arac copied to clipboard

Not compatible with PyBrain 0.3.1

Open NicholasWalton opened this issue 12 years ago • 2 comments

PyBrain 0.3 works fine.

Procedure: Install PyBrain 0.3.1 Run test_pybrainbridge.py

Expected result: All tests pass

Observed result: 13 tests fail with identical exceptions.

======================================================================
ERROR: testCopyable (__main__.TestNetworkEquivalence)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/nicholas/src/arac/src/python/arac/tests/test_pybrainbridge.py", line 348, in testCopyable
    copied = net.copy()
  File "/home/nicholas/src/arac/src/python/arac/pybrainbridge.py", line 266, in copy
    result.sortModules()
  File "/home/nicholas/src/pybrain/pybrain/structure/networks/recurrent.py", line 137, in sortModules
    super(RecurrentNetworkComponent, self).sortModules()
  File "/home/nicholas/src/arac/src/python/arac/pybrainbridge.py", line 274, in sortModules
    super(_Network, self).sortModules()
  File "/home/nicholas/src/pybrain/pybrain/structure/networks/network.py", line 259, in sortModules
    Module.__init__(self, self.indim, self.outdim, name=self.name)
  File "/home/nicholas/src/pybrain/pybrain/structure/modules/module.py", line 51, in __init__
    self._resetBuffers()
  File "/home/nicholas/src/pybrain/pybrain/structure/networks/network.py", line 263, in _resetBuffers
    super(Network, self)._resetBuffers(length)
  File "/home/nicholas/src/pybrain/pybrain/structure/modules/module.py", line 58, in _resetBuffers
    self.offset = 0
AttributeError: can't set attribute

NicholasWalton avatar Apr 01 '12 21:04 NicholasWalton

I had this problem a while ago. I guess it happens because the attribute offset of the module class is replaced by a property in the arac wrapper class _Network ( which is in the file pybrainbridge.py) and this property is read only i.e. has no setter. I added a setter

    @offset.setter
    def offset(self, value):
        pass

below the following lines of code in _Network:

    @property
    def offset(self):
        return self.proxies[self].timestep()

This fixed the AttributeError regarding offset for me and I was able to train networks, but I hardly used pybrain and arac and therefore have not tested if an empty setter does not break certain parts of pybrain <-> arac interaction, but maybe someone might find this info helpful.

o-v-o avatar Jun 12 '13 08:06 o-v-o

add a function to component.cpp

void
Component::set_timestep(int value)
{
    _timestep = value;
    return ;
}

add the function declaration in component.h

then in pybrainbridge.py

add the following :

    @property
    def offset(self):
        return self.proxies.handle(self).timestep()

    @offset.setter
    def offset(self, value):  
        self.proxies.handle(self).set_timestep(int(value))

the original self.proxies(self) does not work.

Then the uncompatibility should be fixed.

ypxie avatar Feb 17 '16 19:02 ypxie