示例#1
0
    def test_not_a_list_on_filter(self):
        # Typed List Value should raises an error
        # if no iterable variable is given on input

        # list of matrices
        myType = TypedListType(T.TensorType(theano.config.floatX, (False, False)))

        with pytest.raises(TypeError):
            myType.filter(4)
示例#2
0
    def test_wrong_input_on_filter(self):
        # Typed list type should raises an
        # error if the argument given to filter
        # isn't of the same type as the one
        # specified on creation

        # list of matrices
        myType = TypedListType(T.TensorType(theano.config.floatX, (False, False)))

        with pytest.raises(TypeError):
            myType.filter([4])
示例#3
0
    def test_filter_sanity_check(self):
        # Simple test on typed list type filter

        myType = TypedListType(T.TensorType(theano.config.floatX, (False, False)))

        x = rand_ranged_matrix(-1000, 1000, [100, 100])

        assert np.array_equal(myType.filter([x]), [x])
示例#4
0
    def test_load(self):
        myType = TypedListType(T.TensorType(theano.config.floatX, (False, False)))

        x = rand_ranged_matrix(-1000, 1000, [100, 100])
        testList = []
        for i in range(10000):
            testList.append(x)

        assert np.array_equal(myType.filter(testList), testList)
示例#5
0
    def test_filter_sanity_check(self):
        # Simple test on typed list type filter

        myType = TypedListType(T.TensorType(theano.config.floatX,
                                            (False, False)))

        x = rand_ranged_matrix(-1000, 1000, [100, 100])

        self.assertTrue(np.array_equal(myType.filter([x]), [x]))
示例#6
0
    def test_intern_filter(self):
        # Test checking if values contained are themselves
        # filtered. If they weren't this code would raise
        # an exception.

        myType = TypedListType(T.TensorType('float64', (False, False)))

        x = np.asarray([[4, 5], [4, 5]], dtype='float32')

        self.assertTrue(np.array_equal(myType.filter([x]), [x]))
示例#7
0
    def test_basic_nested_list(self):
        # Testing nested list with one level of depth

        myNestedType = TypedListType(T.TensorType(theano.config.floatX, (False, False)))

        myType = TypedListType(myNestedType)

        x = rand_ranged_matrix(-1000, 1000, [100, 100])

        assert np.array_equal(myType.filter([[x]]), [[x]])
示例#8
0
    def test_intern_filter(self):
        # Test checking if values contained are themselves
        # filtered. If they weren't this code would raise
        # an exception.

        myType = TypedListType(T.TensorType('float64',
                                            (False, False)))

        x = np.asarray([[4, 5], [4, 5]], dtype='float32')

        self.assertTrue(np.array_equal(myType.filter([x]), [x]))
示例#9
0
    def test_basic_nested_list(self):
        # Testing nested list with one level of depth

        myNestedType = TypedListType(T.TensorType(theano.config.floatX,
                                                  (False, False)))

        myType = TypedListType(myNestedType)

        x = rand_ranged_matrix(-1000, 1000, [100, 100])

        self.assertTrue(np.array_equal(myType.filter([[x]]), [[x]]))