コード例 #1
0
ファイル: test_inference.py プロジェクト: rparrapy/nideep
    def test_infer_to_lmdb_fixed_dims_preserve_batch_no(self, mock_net):

        # fake minimal test data
        b = {
            k: Bunch(data=np.random.rand(4, 1, 3, 2))
            for k in ['x', 'y', 'z']
        }

        # mock methods and properties of Net objects
        mock_net.return_value.forward.return_value = np.zeros(1)
        type(mock_net.return_value).blobs = PropertyMock(return_value=b)
        net = mock_net()

        dst_prefix = os.path.join(
            self.dir_tmp,
            'test_infer_to_lmdb_fixed_dims_preserve_batch_no_%s_lmdb')
        for k in b.keys():
            assert_false(os.path.isdir(dst_prefix % k))

        n = 3
        out = infr.infer_to_lmdb(net, ['x', 'z'], n, dst_prefix)

        assert_equal(net.forward.call_count, n)
        assert_list_equal(out, [n * 4] * 2)
        for k in b.keys():
            if k in ['x', 'z']:
                assert_true(os.path.isdir(dst_prefix % k))
            else:
                assert_false(os.path.isdir(dst_prefix % k))
コード例 #2
0
ファイル: test_inference.py プロジェクト: nigroup/nideep
    def test_infer_to_lmdb_fixed_dims_n(self, mock_net):

        # fake minimal test data
        b = {k : Bunch(data=np.random.rand(1, 1, 3, 2)) for k in ['x', 'y', 'z']}

        # mock methods and properties of Net objects
        mock_net.return_value.forward.return_value = np.zeros(1)
        type(mock_net.return_value).blobs = PropertyMock(return_value=b)

        for n in range(1, 10):

            net = mock_net()
            net.reset_mock()

            dst_prefix = os.path.join(self.dir_tmp, 'test_infer_to_lmdb_fixed_dims_n_%s_lmdb')
            out = infr.infer_to_lmdb(net, ['x', 'z'], n, dst_prefix)

            assert_equal(net.forward.call_count, n)
            assert_list_equal(out, [n, n])
コード例 #3
0
ファイル: test_inference.py プロジェクト: rparrapy/nideep
    def test_infer_to_lmdb_fixed_dims_n(self, mock_net):

        # fake minimal test data
        b = {
            k: Bunch(data=np.random.rand(1, 1, 3, 2))
            for k in ['x', 'y', 'z']
        }

        # mock methods and properties of Net objects
        mock_net.return_value.forward.return_value = np.zeros(1)
        type(mock_net.return_value).blobs = PropertyMock(return_value=b)

        for n in range(1, 10):

            net = mock_net()
            net.reset_mock()

            dst_prefix = os.path.join(
                self.dir_tmp, 'test_infer_to_lmdb_fixed_dims_n_%s_lmdb')
            out = infr.infer_to_lmdb(net, ['x', 'z'], n, dst_prefix)

            assert_equal(net.forward.call_count, n)
            assert_list_equal(out, [n, n])
コード例 #4
0
ファイル: test_inference.py プロジェクト: nigroup/nideep
    def test_infer_to_lmdb_fixed_dims_preserve_batch_no(self, mock_net):

        # fake minimal test data
        b = {k : Bunch(data=np.random.rand(4, 1, 3, 2)) for k in ['x', 'y', 'z']}

        # mock methods and properties of Net objects
        mock_net.return_value.forward.return_value = np.zeros(1)
        type(mock_net.return_value).blobs = PropertyMock(return_value=b)
        net = mock_net()

        dst_prefix = os.path.join(self.dir_tmp, 'test_infer_to_lmdb_fixed_dims_preserve_batch_no_%s_lmdb')
        for k in b.keys():
            assert_false(os.path.isdir(dst_prefix % k))

        n = 3
        out = infr.infer_to_lmdb(net, ['x', 'z'], n, dst_prefix)

        assert_equal(net.forward.call_count, n)
        assert_list_equal(out, [n * 4] * 2)
        for k in b.keys():
            if k in ['x', 'z']:
                assert_true(os.path.isdir(dst_prefix % k))
            else:
                assert_false(os.path.isdir(dst_prefix % k))