Best Python code snippet using tempest_python
test_getlimits.py
Source:test_getlimits.py
...7from numpy.testing import assert_equal, assert_, assert_raises8from numpy.core.getlimits import _discovered_machar, _float_ma9##################################################10class TestPythonFloat(object):11 def test_singleton(self):12 ftype = finfo(float)13 ftype2 = finfo(float)14 assert_equal(id(ftype), id(ftype2))15class TestHalf(object):16 def test_singleton(self):17 ftype = finfo(half)18 ftype2 = finfo(half)19 assert_equal(id(ftype), id(ftype2))20class TestSingle(object):21 def test_singleton(self):22 ftype = finfo(single)23 ftype2 = finfo(single)24 assert_equal(id(ftype), id(ftype2))25class TestDouble(object):26 def test_singleton(self):27 ftype = finfo(double)28 ftype2 = finfo(double)29 assert_equal(id(ftype), id(ftype2))30class TestLongdouble(object):31 def test_singleton(self):32 ftype = finfo(longdouble)33 ftype2 = finfo(longdouble)34 assert_equal(id(ftype), id(ftype2))35class TestFinfo(object):36 def test_basic(self):37 dts = list(zip(['f2', 'f4', 'f8', 'c8', 'c16'],38 [np.float16, np.float32, np.float64, np.complex64,39 np.complex128]))40 for dt1, dt2 in dts:41 for attr in ('bits', 'eps', 'epsneg', 'iexp', 'machar', 'machep',42 'max', 'maxexp', 'min', 'minexp', 'negep', 'nexp',43 'nmant', 'precision', 'resolution', 'tiny'):44 assert_equal(getattr(finfo(dt1), attr),45 getattr(finfo(dt2), attr), attr)...
test_intervalops.py
Source:test_intervalops.py
1import numpy as np2from numpy.testing import assert_array_equal3from skfuzzy.intervals import addval, divval, multval, scaleval, subval4def test_addval():5 test = addval([2, 3], [3, 4]) # Generalized iterable input6 test2 = addval(np.r_[2, 3], np.r_[3, 4]) # Numpy array input7 test_broadcast = addval(3, np.r_[3, 4])8 test_singleton = addval(3, 4)9 expected = np.r_[5, 7]10 assert_array_equal(test, expected)11 assert_array_equal(test2, expected)12 assert_array_equal(test_broadcast, np.r_[6, 7])13 assert test_singleton == 714def test_divval():15 test = divval([3, 6], [1, 3]) # Generalized iterable input16 test2 = divval(np.r_[3, 6], np.r_[1, 3]) # Numpy array input17 test_broadcast = divval(6, np.r_[1, 3])18 test_singleton = divval(6, 3)19 expected = np.r_[1, 6]20 assert_array_equal(test, expected)21 assert_array_equal(test2, expected)22 assert_array_equal(test_broadcast, np.r_[6, 2])23 assert test_singleton == 224def test_multval():25 test = multval([1, 2], [2, 3]) # Generalized iterable input26 test2 = multval(np.r_[1, 2], np.r_[2, 3]) # Numpy array input27 test_broadcast = multval(2, np.r_[2, 3])28 test_singleton = multval(2, 3)29 expected = np.r_[2, 6]30 assert_array_equal(test, expected)31 assert_array_equal(test2, expected)32 assert_array_equal(test_broadcast, np.r_[4, 6])33 assert test_singleton == 634def test_scaleval():35 test = scaleval(5, [2, 9]) # General iterable36 test2 = scaleval(5, np.r_[2, 9]) # Numpy array37 test_reverse = scaleval(5, [2, -9]) # Fix reverse interval38 test_singleton = scaleval(5, 4)39 expected = np.r_[10, 45]40 assert_array_equal(test, expected)41 assert_array_equal(test2, expected)42 assert_array_equal(test_reverse, np.r_[-45, 10])43 assert test_singleton == 2044def test_subval():45 test = subval([2, 5], [4, 6]) # Generalized iterable input46 test2 = subval(np.r_[2, 5], np.r_[4, 6]) # Numpy array input47 test_broadcast = subval(5, np.r_[4, 6])48 test_singleton = subval(5, 4)49 expected = np.r_[-4, 1]50 assert_array_equal(test, expected)51 assert_array_equal(test2, expected)52 assert_array_equal(test_broadcast, np.r_[1, -1])53 assert test_singleton == 154# todo: DSW method tests (check lit / probs)55if __name__ == "__main__":...
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!!