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)
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)
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, )
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)
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)