Best Python code snippet using locust
math_ops_linspace_test.py
Source: math_ops_linspace_test.py
1# Copyright 2020 The TensorFlow Authors. All Rights Reserved.2#3# Licensed under the Apache License, Version 2.0 (the "License");4# you may not use this file except in compliance with the License.5# You may obtain a copy of the License at6#7# http://www.apache.org/licenses/LICENSE-2.08#9# Unless required by applicable law or agreed to in writing, software10# distributed under the License is distributed on an "AS IS" BASIS,11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.12# See the License for the specific language governing permissions and13# limitations under the License.14# ==============================================================================15"""Tests for tensorflow.ops.math_ops.linspace."""16from __future__ import absolute_import17from __future__ import division18from __future__ import print_function19# Using distutils.version.LooseVersion was resulting in an error, so importing20# directly.21from distutils.version import LooseVersion # pylint: disable=g-importing-member22from absl.testing import parameterized23import numpy as np24from tensorflow.python.framework import test_util25from tensorflow.python.ops import math_ops26from tensorflow.python.platform import googletest27@test_util.run_all_in_graph_and_eager_modes28class LinspaceTest(test_util.TensorFlowTestCase, parameterized.TestCase):29 # pylint: disable=g-complex-comprehension30 @parameterized.parameters([31 {32 "start_shape": start_shape,33 "stop_shape": stop_shape,34 "dtype": dtype,35 "num": num36 }37 for start_shape in [(), (2,), (2, 2)]38 for stop_shape in [(), (2,), (2, 2)]39 for dtype in [np.float64, np.int64]40 for num in [0, 1, 2, 20]41 ])42 # pylint: enable=g-complex-comprehension43 def testLinspaceBroadcasts(self, start_shape, stop_shape, dtype, num):44 if LooseVersion(np.version.version) < LooseVersion("1.16.0"):45 self.skipTest("numpy doesn't support axes before version 1.16.0")46 ndims = max(len(start_shape), len(stop_shape))47 for axis in range(-ndims, ndims):48 start = np.ones(start_shape, dtype)49 stop = 10 * np.ones(stop_shape, dtype)50 np_ans = np.linspace(start, stop, num, axis=axis)51 tf_ans = self.evaluate(52 math_ops.linspace_nd(start, stop, num, axis=axis))53 self.assertAllClose(np_ans, tf_ans)54if __name__ == "__main__":...
math_ops_linspace_test.py.transformed.py
1from absl.testing import parameterized2import numpy as np3from tensorflow.python.framework import test_util4from tensorflow.python.ops import math_ops5from tensorflow.python.platform import googletest6@test_util.run_all_in_graph_and_eager_modes7class LinspaceTest(test_util.TensorFlowTestCase, parameterized.TestCase):8 @parameterized.parameters([9 {10 "start_shape": start_shape,11 "stop_shape": stop_shape,12 "dtype": dtype,13 "num": num14 }15 for start_shape in [(), (2,), (2, 2)]16 for stop_shape in [(), (2,), (2, 2)]17 for dtype in [np.float64, np.int64]18 for num in [0, 1, 2, 20]19 ])20 def testLinspaceBroadcasts(self, start_shape, stop_shape, dtype, num):21 if LooseVersion(np.version.version) < LooseVersion("1.16.0"):22 self.skipTest("numpy doesn't support axes before version 1.16.0")23 ndims = max(len(start_shape), len(stop_shape))24 for axis in range(-ndims, ndims):25 start = np.ones(start_shape, dtype)26 stop = 10 * np.ones(stop_shape, dtype)27 np_ans = np.linspace(start, stop, num, axis=axis)28 tf_ans = self.evaluate(29 math_ops.linspace_nd(start, stop, num, axis=axis))30 self.assertAllClose(np_ans, tf_ans)31if __name__ == "__main__":...
Check out the latest blogs from LambdaTest on this topic:
Joseph, who has been working as a Quality Engineer, was assigned to perform web automation for the company’s website.
Lack of training is something that creates a major roadblock for a tester. Often, testers working in an organization are all of a sudden forced to learn a new framework or an automation tool whenever a new project demands it. You may be overwhelmed on how to learn test automation, where to start from and how to master test automation for web applications, and mobile applications on a new technology so soon.
There are times when developers get stuck with a problem that has to do with version changes. Trying to run the code or test without upgrading the package can result in unexpected errors.
Websites and web apps are growing in number day by day, and so are the expectations of people for a pleasant web experience. Even though the World Wide Web (WWW) was invented only in 1989 (32 years back), this technology has revolutionized the world we know back then. The best part is that it has made life easier for us. You no longer have to stand in long queues to pay your bills. You can get that done within a few minutes by visiting their website, web app, or mobile app.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!