How to use _test_run_helper method in autotest

Best Python code snippet using autotest_python

train_test.py

Source: train_test.py Github

copy

Full Screen

...478 discriminator_train_op=step.assign_add(discriminator_add,479 use_locking=True),480 global_step_inc_op=step.assign_add(1))481 return train_ops482 def _test_run_helper(self, create_gan_model_fn):483 random_seed.set_random_seed(1234)484 model = create_gan_model_fn()485 loss = train.gan_loss(model)486 g_opt = gradient_descent.GradientDescentOptimizer(1.0)487 d_opt = gradient_descent.GradientDescentOptimizer(1.0)488 train_ops = train.gan_train_ops(model, loss, g_opt, d_opt)489 final_step = train.gan_train(490 train_ops,491 logdir='',492 hooks=[basic_session_run_hooks.StopAtStepHook(num_steps=2)])493 self.assertTrue(np.isscalar(final_step))494 self.assertEqual(2, final_step)495 def test_run_gan(self):496 self._test_run_helper(create_gan_model)497 def test_run_callable_gan(self):498 self._test_run_helper(create_callable_gan_model)499 def test_run_infogan(self):500 self._test_run_helper(create_infogan_model)501 def test_run_callable_infogan(self):502 self._test_run_helper(create_callable_infogan_model)503 def test_run_acgan(self):504 self._test_run_helper(create_acgan_model)505 def test_run_callable_acgan(self):506 self._test_run_helper(create_callable_acgan_model)507 # Test multiple train steps.508 def _test_multiple_steps_helper(self, get_hooks_fn_fn):509 train_ops = self._gan_train_ops(generator_add=10, discriminator_add=100)510 train_steps = namedtuples.GANTrainSteps(511 generator_train_steps=3,512 discriminator_train_steps=4)513 final_step = train.gan_train(514 train_ops,515 get_hooks_fn=get_hooks_fn_fn(train_steps),516 logdir='',517 hooks=[basic_session_run_hooks.StopAtStepHook(num_steps=1)])518 self.assertTrue(np.isscalar(final_step))519 self.assertEqual(1 + 3 * 10 + 4 * 100, final_step)520 def test_multiple_steps_seq_train_steps(self):...

Full Screen

Full Screen

test_Cloudgen.py

Source: test_Cloudgen.py Github

copy

Full Screen

...50 assert cloud.updated51 # Check resetting puts everything back to normal52 cloud.input = cirrus53 assert not cloud.updated54def _test_run_helper(cloud_dat: pathlib.Path,55 sample_dir: pathlib.Path,56 tmp_path: pathlib.Path) -> None:57 """Check that running :program:`cloudgen` works"""58 cloud = Cloudgen(cloud_dat)59 try:60 cloud.run(cwd=tmp_path, check=True)61 except Exception:62 raise63 else:64 assert tmp_path.joinpath(cloud_dat).exists()65 new = Cloudgen(tmp_path.joinpath(cloud_dat))66 for param, value in cloud.rc_data.items():67 assert param in new.rc_data68 assert value.strip() == new.rc_data[param].strip()69 assert all(_ in cloud.rc_data for _ in new.rc_data)70 output = tmp_path.joinpath(cloud.output_filename)71 assert output.exists()72 with netCDF4.Dataset(output, "r") as out:73 assert "variable_name" in cloud.rc_data74 variable = cloud.rc_data["variable_name"].strip()75 assert variable in out.variables76 reference = sample_dir.joinpath(new.output_filename)77 assert reference.exists()78 with netCDF4.Dataset(reference, "r") as ref:79 assert variable in ref.variables80 assert numpy.isclose(out[variable],81 ref[variable]).all()82 finally:83 if tmp_path.joinpath(cloud.output_filename).exists():84 tmp_path.joinpath(cloud.output_filename).unlink()85def test_run_cirrus(cirrus: pathlib.Path,86 sample_dir: pathlib.Path,87 tmp_path: pathlib.Path) -> None:88 """Check the cirrus clouds yield the expected results"""89 _test_run_helper(cirrus, sample_dir, tmp_path)90def test_run_stratucumulus(stratocumulus: pathlib.Path,91 sample_dir: pathlib.Path,92 tmp_path: pathlib.Path) -> None:93 """Check the stratocumulus clouds yield the expected results"""94 _test_run_helper(stratocumulus, sample_dir, tmp_path)95def test_str(cirrus: pathlib.Path, cirrus_expected: RCData) -> None:96 """Check converting to string preserves structure"""97 cloud = Cloudgen(cirrus)98 for line in str(cloud).splitlines():99 param, value = line.split(" ", 1)100 assert param in cirrus_expected...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful