/usr/lib/python2.7/dist-packages/mdp/test/test_VariadicCumulator.py is in python-mdp 3.5-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | from builtins import range
import mdp
from ._tools import *
def test_VariadicCumulator():
# create random data
ONELEN = 101
NREP = 7
x = [numx_rand.rand(ONELEN, 3) for _ in range(NREP)]
y = [numx_rand.rand(ONELEN, 3) for _ in range(NREP)]
ABCumulator = mdp.VariadicCumulator('a', 'b')
class TestABCumulator(ABCumulator):
def _stop_training(self, *args, **kwargs):
super(TestABCumulator, self)._stop_training(*args, **kwargs)
# verify that the attributes are there
assert hasattr(self, 'a')
assert hasattr(self, 'b')
# test tlen
tlen = ONELEN*NREP
assert self.tlen == tlen
assert self.a.shape == (tlen, 3)
assert self.b.shape == (tlen, 3)
# test content
for i in range(NREP):
assert numx.all(self.a[i*ONELEN:(i+1)*ONELEN,:] == x[i])
assert numx.all(self.b[i*ONELEN:(i+1)*ONELEN,:] == y[i])
ab = TestABCumulator()
for i in range(NREP):
ab.train(x[i], y[i])
ab.stop_training()
|