コード例 #1
0
ファイル: test_gd.py プロジェクト: webdiscover/neupy
    def test_gd_apply_batches(self):
        def function(x):
            time.sleep(0.02)
            print()
            return 12345

        with catch_stdout() as out:
            apply_batches(function=function,
                          arguments=[np.ones(100)],
                          batch_size=10,
                          logger=TerminalLogger(),
                          show_progressbar=True,
                          show_error_output=True)
            terminal_output = out.getvalue()

        self.assertIn('12345', terminal_output)
        self.assertIn('error', terminal_output)
コード例 #2
0
ファイル: test_gd.py プロジェクト: itdxer/neupy
    def test_gd_apply_batches(self):
        def function(x):
            time.sleep(0.02)
            print()
            return 12345

        with catch_stdout() as out:
            apply_batches(
                function=function,
                arguments=[np.ones(100)],
                batch_size=10,
                logger=TerminalLogger(),
                show_progressbar=True,
                show_error_output=True
            )
            terminal_output = out.getvalue()

        self.assertIn('12345', terminal_output)
        self.assertIn('error', terminal_output)
コード例 #3
0
    def test_gd_apply_batches_exceptions(self):
        with self.assertRaisesRegexp(ValueError, "at least one element"):
            apply_batches(function=lambda x: x, arguments=[], batch_size=12)

        with self.assertRaisesRegexp(ValueError, "Cannot show error"):
            apply_batches(
                function=lambda x: x,
                arguments=[np.random.random((36, 1))],
                batch_size=12,
                show_error_output=True,
                scalar_output=False,
            )

        with self.assertRaisesRegexp(ValueError, "Cannot convert output"):
            apply_batches(
                function=lambda x: x,
                arguments=[np.random.random((36, 1))],
                batch_size=12,
            )
コード例 #4
0
ファイル: test_gd.py プロジェクト: itdxer/neupy
 def test_gd_apply_batches_exceptions(self):
     with self.assertRaisesRegexp(ValueError, "at least one element"):
         apply_batches(function=lambda x: x, arguments=[],
                       batch_size=12, logger=None)
コード例 #5
0
 def test_gd_apply_batches_exceptions(self):
     with self.assertRaisesRegexp(ValueError, "at least one element"):
         apply_batches(function=lambda x: x, arguments=[], batch_size=12)