<commit_before>import numpy as np
import theanets
import theano.tensor as TT


class TestLayer:
    def test_build(self):
        for f in 'feedforward Feedforward classifier rnn lstm'.split():
            l = theanets.layers.build(f, nin=2, nout=4)
            assert isinstance(l, theanets.layers.Layer)


class Base:
    def setUp(self):
        self.x = TT.matrix('x')


class TestFeedforward(Base):
    def _build(self):
        return theanets.layers.Feedforward(nin=2, nout=4)

    def test_create(self):
        l = self._build()
        assert l.reset() == 12

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestTied(Base):
    def _build(self):
        l0 = theanets.layers.Feedforward(nin=2, nout=4)
        l0.reset()
        return theanets.layers.Tied(partner=l0)

    def test_create(self):
        l = self._build()
        assert l.reset() == 2

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestClassifier(Base):
    def _build(self):
        return theanets.layers.Classifier(nin=2, nout=4)

    def test_create(self):
        l = self._build()
        assert l.reset() == 12

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestRNN(Base):
    def _build(self, **kwargs):
        return theanets.layers.RNN(nin=2, nout=4, **kwargs)

    def test_create(self):
        l = self._build()
        assert l.reset() == 28

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestRRNN(Base):
    def _build(self, **kwargs):
        return theanets.layers.RRNN(nin=2, nout=4, **kwargs)

    def test_create(self):
        l = self._build()
        assert l.reset() == 40

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestMRNN(Base):
    def _build(self):
        return theanets.layers.MRNN(nin=2, nout=4, factors=3)

    def test_create(self):
        l = self._build()
        assert l.reset() == 42

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestLSTM(Base):
    def _build(self):
        return theanets.layers.LSTM(nin=2, nout=4)

    def test_create(self):
        l = self._build()
        assert l.reset() == 124

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd
<commit_msg>Update test for rrnn -> arrnn change.<commit_after>import numpy as np
import theanets
import theano.tensor as TT


class TestLayer:
    def test_build(self):
        for f in 'feedforward Feedforward classifier rnn lstm'.split():
            l = theanets.layers.build(f, nin=2, nout=4)
            assert isinstance(l, theanets.layers.Layer)


class Base:
    def setUp(self):
        self.x = TT.matrix('x')


class TestFeedforward(Base):
    def _build(self):
        return theanets.layers.Feedforward(nin=2, nout=4)

    def test_create(self):
        l = self._build()
        assert l.reset() == 12

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestTied(Base):
    def _build(self):
        l0 = theanets.layers.Feedforward(nin=2, nout=4)
        l0.reset()
        return theanets.layers.Tied(partner=l0)

    def test_create(self):
        l = self._build()
        assert l.reset() == 2

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestClassifier(Base):
    def _build(self):
        return theanets.layers.Classifier(nin=2, nout=4)

    def test_create(self):
        l = self._build()
        assert l.reset() == 12

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestRNN(Base):
    def _build(self, **kwargs):
        return theanets.layers.RNN(nin=2, nout=4, **kwargs)

    def test_create(self):
        l = self._build()
        assert l.reset() == 28

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestARRNN(Base):
    def _build(self, **kwargs):
        return theanets.layers.ARRNN(nin=2, nout=4, **kwargs)

    def test_create(self):
        l = self._build()
        assert l.reset() == 40

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestMRNN(Base):
    def _build(self):
        return theanets.layers.MRNN(nin=2, nout=4, factors=3)

    def test_create(self):
        l = self._build()
        assert l.reset() == 42

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd


class TestLSTM(Base):
    def _build(self):
        return theanets.layers.LSTM(nin=2, nout=4)

    def test_create(self):
        l = self._build()
        assert l.reset() == 124

    def test_transform(self):
        l = self._build()
        l.reset()
        out, upd = l.transform(self.x)
        assert out is not None
        assert not upd

{'fraction_non_alphanumeric': 0.11702838063439065, 'fraction_numerical': 0.011352253756260434, 'mean_word_length': 2.0457549567869853, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6497197', 'n_tokens_mistral': 2050, 'n_tokens_neox': 1939, 'n_words': 511}