# How to use values method in autotest

Best Python code snippet using autotest_python

talib_indicators.py

Source:talib_indicators.py

qgis2web_expressions.js

Source:qgis2web_expressions.js

1// Aggregates2// Color3// Conditionals4// Conversions5// Custom6// Date and Time7// Fields and Values8// Fuzzy Matching9// General10// Geometry11function fnc_azimuth(values, context) {12 return false;13};14function fnc_project(values, context) {15 return false;16};17// Math18function fnc_abs(values, context) {19 return Math.abs(values[0]);20};21function fnc_degrees(values, context) {22 return values[0] * (180/Math.PI);23};24function fnc_radians(values, context) {25 return values[0] * (Math.PI/180);26};27function fnc_sqrt(values, context) {28 return Math.sqrt(values[0]);29};30function fnc_cos(values, context) {31 return Math.cos(values[0]);32};33function fnc_sin(values, context) {34 return Math.sin(values[0]);35};36function fnc_tan(values, context) {37 return Math.tan(values[0]);38};39function fnc_asin(values, context) {40 return Math.asin(values[0]);41};42function fnc_acos(values, context) {43 return Math.acos(values[0]);44};45function fnc_atan(values, context) {46 return Math.atan(values[0]);47};48function fnc_atan2(values, context) {49 return Math.atan2(values[0]);50};51function fnc_exp(values, context) {52 return Math.exp(values[0]);53};54function fnc_ln(values, context) {55 return Math.log(values[0]);56};57function fnc_log10(values, context) {58 return Math.LN10(values[0]);59};60function fnc_log(values, context) {61 return Math.log(values[0]) / Math.log(values[1]);62};63function fnc_round(values, context) {64 return Math.round(values[0]);65};66function fnc_rand(values, context) {67 return Math.floor(Math.random()*(values[1]-values[0]+1)+values[0]);68};69function fnc_randf(values, context) {70 return Math.random()*(values[1]-values[0]+1)+values[0];71};72function fnc_max(values, context) {73 return Math.max.apply(this, values);74};75function fnc_min(values, context) {76 return Math.min.apply(this, values);77};78function fnc_clamp(values, context) {79 return Math.min(Math.max(values[0],values[1]),values[2]);80};81// Operators82// Record83// String84// TimeManager85// Variables86function fnc_scale_linear(values, context) {87 return false;88};89function fnc_scale_exp(values, context) {90 return false;91};92function fnc_floor(values, context) {93 return Math.floor(values[0]);94};95function fnc_ceil(values, context) {96 return Math.ceil(values[0]);97};98function fnc_pi(values, context) {99 return Math.PI;100};101function fnc_to_int(values, context) {102 var intVal = parseInt(values[0],10);103 if ( isNaN(intVal) ) { return false };104 return intVal;105};106function fnc_to_real(values, context) {107 var realVal = parseFloat(values[0]);108 if ( isNaN(realVal) ) { return false };109 return realVal;110};111function fnc_to_string(values, context) {112 return String(values[0]);113};114function fnc_to_datetime(values, context) {115 return false;116};117function fnc_to_date(values, context) {118 return false;119};120function fnc_to_time(values, context) {121 return false;122};123function fnc_to_interval(values, context) {124 return false;125};126function fnc_coalesce(values, context) {127 return false;128};129function fnc_if(values, context) {130 return false;131};132function fnc_aggregate(values, context) {133 return false;134};135function fnc_relation_aggregate(values, context) {136 return false;137};138function fnc_count(values, context) {139 return false;140};141function fnc_count_distinct(values, context) {142 return false;143};144function fnc_count_missing(values, context) {145 return false;146};147function fnc_minimum(values, context) {148 return false;149};150function fnc_maximum(values, context) {151 return false;152};153function fnc_sum(values, context) {154 return false;155};156function fnc_mean(values, context) {157 return false;158};159function fnc_median(values, context) {160 return false;161};162function fnc_stdev(values, context) {163 return false;164};165function fnc_range(values, context) {166 return false;167};168function fnc_minority(values, context) {169 return false;170};171function fnc_majority(values, context) {172 return false;173};174function fnc_q1(values, context) {175 return false;176};177function fnc_q3(values, context) {178 return false;179};180function fnc_iqr(values, context) {181 return false;182};183function fnc_min_length(values, context) {184 return false;185};186function fnc_max_length(values, context) {187 return false;188};189function fnc_concatenate(values, context) {190 return false;191};192function fnc_regexp_match(values, context) {193 return false;194};195function fnc_now(values, context) {196 return new Date().toISOString();197};198function fnc_age(values, context) {199 return false;200};201function fnc_year(values, context) {202 return false;203};204function fnc_month(values, context) {205 return false;206};207function fnc_week(values, context) {208 return false;209};210function fnc_day(values, context) {211 return false;212};213function fnc_hour(values, context) {214 return false;215};216function fnc_minute(values, context) {217 return false;218};219function fnc_second(values, context) {220 return false;221};222function fnc_day_of_week(values, context) {223 return false;224};225function fnc_lower(values, context) {226 if ( typeof values[0] != "string" ) { return false; } 227 return values[0].toLowerCase();228};229function fnc_upper(values, context) {230 if ( typeof values[0] != "string" ) { return false; } 231 return values[0].toUpperCase();232};233function fnc_title(values, context) {234 if ( typeof values[0] != "string" ) { return false; }235 return values[0].toLowerCase().split(' ').map(function(word) {236 return (word.charAt(0).toUpperCase() + word.slice(1));237 }).join(' ');238};239function fnc_trim(values, context) {240 if ( typeof values[0] != "string" ) { return false; } 241 return String(values[0]).trim();242};243function fnc_levenshtein(values, context) {244 return false;245};246function fnc_longest_common_substring(values, context) {247 return false;248};249function fnc_hamming_distance(values, context) {250 return false;251};252function fnc_soundex(values, context) {253 return false;254};255function fnc_char(values, context) {256 if ( isNaN(values[0]) || !values[0]) { return null; } return String.fromCodePoint(values[0]);257};258function fnc_wordwrap(values, context) {259 return false;260};261function fnc_length(values, context) {262 return false;263};264function fnc_replace(values, context) {265 return false;266};267function fnc_regexp_replace(values, context) {268 if ( !values[0] ) { return null; } return String(values[0]).replace(RegExp(values[1]),values[2]);269};270function fnc_regexp_substr(values, context) {271 if ( !values[0] ) { return null; }272 return String(values[0]).match(RegExp(values[1]))[0];273};274function fnc_substr(values, context) {275 var length = values[2]276 if ( !values[0] || isNaN(values[1])) { return false; }277 return String(values[0]).substr(values[1], length);278};279function fnc_concat(values, context) {280 return values.join(''); 281};282function fnc_strpos(values, context) {283 if (!values[0] || !values[1]) {return null}284 return String(values[0]).indexOf(String(values[1]))+1;285};286function fnc_left(values, context) {287 return false;288};289function fnc_right(values, context) {290 return false;291};292function fnc_rpad(values, context) {293 return false;294};295function fnc_lpad(values, context) {296 return false;297};298function fnc_format(values, context) {299 return false;300};301function fnc_format_number(values, context) {302 return false;303};304function fnc_format_date(values, context) {305 return false;306};307function fnc_color_rgb(values, context) {308 return false;309};310function fnc_color_rgba(values, context) {311 return false;312};313function fnc_ramp_color(values, context) {314 return false;315};316function fnc_color_hsl(values, context) {317 return false;318};319function fnc_color_hsla(values, context) {320 return false;321};322function fnc_color_hsv(values, context) {323 return false;324};325function fnc_color_hsva(values, context) {326 return false;327};328function fnc_color_cmyk(values, context) {329 return false;330};331function fnc_color_cmyka(values, context) {332 return false;333};334function fnc_color_part(values, context) {335 return false;336};337function fnc_darker(values, context) {338 return false;339};340function fnc_lighter(values, context) {341 return false;342};343function fnc_set_color_part(values, context) {344 return false;345};346function fnc_area(values, context) {347 return false;348};349function fnc_perimeter(values, context) {350 return false;351};352function fnc_x(values, context) {353 return false;354};355function fnc_y(values, context) {356 return false;357};358function fnc_z(values, context) {359 return false;360};361function fnc_m(values, context) {362 return false;363};364function fnc_point_n(values, context) {365 return false;366};367function fnc_start_point(values, context) {368 return false;369};370function fnc_end_point(values, context) {371 return false;372};373function fnc_nodes_to_points(values, context) {374 return false;375};376function fnc_segments_to_lines(values, context) {377 return false;378};379function fnc_make_point(values, context) {380 return false;381};382function fnc_make_point_m(values, context) {383 return false;384};385function fnc_make_line(values, context) {386 return false;387};388function fnc_make_polygon(values, context) {389 return false;390};391function fnc_x_min(values, context) {392 return false;393};394function fnc_x_max(values, context) {395 return false;396};397function fnc_y_min(values, context) {398 return false;399};400function fnc_y_max(values, context) {401 return false;402};403function fnc_geom_from_wkt(values, context) {404 return false;405};406function fnc_geom_from_gml(values, context) {407 return false;408};409function fnc_relate(values, context) {410 return false;411};412function fnc_intersects_bbox(values, context) {413 return false;414};415function fnc_disjoint(values, context) {416 return false;417};418function fnc_intersects(values, context) {419 return false;420};421function fnc_touches(values, context) {422 return false;423};424function fnc_crosses(values, context) {425 return false;426};427function fnc_contains(values, context) {428 return false;429};430function fnc_overlaps(values, context) {431 return false;432};433function fnc_within(values, context) {434 return false;435};436function fnc_translate(values, context) {437 return false;438};439function fnc_buffer(values, context) {440 return false;441};442function fnc_centroid(values, context) {443 return false;444};445function fnc_point_on_surface(values, context) {446 return false;447};448function fnc_reverse(values, context) {449 return false;450};451function fnc_exterior_ring(values, context) {452 return false;453};454function fnc_interior_ring_n(values, context) {455 return false;456};457function fnc_geometry_n(values, context) {458 return false;459};460function fnc_boundary(values, context) {461 return false;462};463function fnc_line_merge(values, context) {464 return false;465};466function fnc_bounds(values, context) {467 return false;468};469function fnc_num_points(values, context) {470 return false;471};472function fnc_num_interior_rings(values, context) {473 return false;474};475function fnc_num_rings(values, context) {476 return false;477};478function fnc_num_geometries(values, context) {479 return false;480};481function fnc_bounds_width(values, context) {482 return false;483};484function fnc_bounds_height(values, context) {485 return false;486};487function fnc_is_closed(values, context) {488 return false;489};490function fnc_convex_hull(values, context) {491 return false;492};493function fnc_difference(values, context) {494 return false;495};496function fnc_distance(values, context) {497 return false;498};499function fnc_intersection(values, context) {500 return false;501};502function fnc_sym_difference(values, context) {503 return false;504};505function fnc_combine(values, context) {506 return false;507};508function fnc_union(values, context) {509 return false;510};511function fnc_geom_to_wkt(values, context) {512 return false;513};514function fnc_geometry(values, context) {515 return false;516};517function fnc_transform(values, context) {518 return false;519};520function fnc_extrude(values, context) {521 return false;522};523function fnc_order_parts(values, context) {524 return false;525};526function fnc_closest_point(values, context) {527 return false;528};529function fnc_shortest_line(values, context) {530 return false;531};532function fnc_line_interpolate_point(values, context) {533 return false;534};535function fnc_line_interpolate_angle(values, context) {536 return false;537};538function fnc_line_locate_point(values, context) {539 return false;540};541function fnc_angle_at_vertex(values, context) {542 return false;543};544function fnc_distance_to_vertex(values, context) {545 return false;546};547function fnc_uuid(values, context) {548 return false;549};550function fnc_get_feature(values, context) {551 return false;552};553function fnc_layer_property(values, context) {554 return false;555};556function fnc_var(values, context) {557 return false;558};559function fnc_eval(values, context) {560 return false;561};562function fnc_attribute(values, context) {563 return false;564};565function fnc__specialcol_(values, context) {566 return false;567};568function fnc_project_color(values, context) {569 return false;...

merge_values_unittest.py

Source:merge_values_unittest.py

1# Copyright 2013 The Chromium Authors. All rights reserved.2# Use of this source code is governed by a BSD-style license that can be3# found in the LICENSE file.4import os5import unittest6from telemetry import story7from telemetry import page as page_module8from telemetry.value import improvement_direction9from telemetry.value import list_of_scalar_values10from telemetry.value import merge_values11from telemetry.value import scalar12class TestBase(unittest.TestCase):13 def setUp(self):14 story_set = story.StorySet(base_dir=os.path.dirname(__file__))15 story_set.AddStory(16 page_module.Page('http://www.bar.com/', story_set, story_set.base_dir))17 story_set.AddStory(18 page_module.Page('http://www.baz.com/', story_set, story_set.base_dir))19 story_set.AddStory(20 page_module.Page('http://www.foo.com/', story_set, story_set.base_dir))21 self.story_set = story_set22 @property23 def pages(self):24 return self.story_set.stories25class MergeValueTest(TestBase):26 def testDefaultKeyFuncWithTirLabel(self):27 page0 = self.pages[0]28 value = scalar.ScalarValue(29 page0, 'x', 'units', 1,30 improvement_direction=improvement_direction.UP,31 tir_label='foo')32 self.assertEquals(('x', 'foo'), merge_values.DefaultKeyFunc(value))33 def testSamePageMergeBasic(self):34 page0 = self.pages[0]35 page1 = self.pages[1]36 all_values = [scalar.ScalarValue(37 page0, 'x', 'units', 1,38 improvement_direction=improvement_direction.UP),39 scalar.ScalarValue(40 page1, 'x', 'units', 4,41 improvement_direction=improvement_direction.UP),42 scalar.ScalarValue(43 page0, 'x', 'units', 2,44 improvement_direction=improvement_direction.UP),45 scalar.ScalarValue(46 page1, 'x', 'units', 5,47 improvement_direction=improvement_direction.UP)]48 merged_values = merge_values.MergeLikeValuesFromSamePage(all_values)49 # Sort the results so that their order is predictable for the subsequent50 # assertions.51 merged_values.sort(key=lambda x: x.page.url)52 self.assertEquals(2, len(merged_values))53 self.assertEquals((page0, 'x'),54 (merged_values[0].page, merged_values[0].name))55 self.assertEquals([1, 2], merged_values[0].values)56 self.assertEquals((page1, 'x'),57 (merged_values[1].page, merged_values[1].name))58 self.assertEquals([4, 5], merged_values[1].values)59 def testSamePageMergeNonstandardKeyFunc(self):60 page0 = self.pages[0]61 page1 = self.pages[1]62 all_values = [scalar.ScalarValue(63 page0, 'x', 'units', 1,64 improvement_direction=improvement_direction.UP),65 scalar.ScalarValue(66 page1, 'x', 'units', 4,67 improvement_direction=improvement_direction.UP),68 scalar.ScalarValue(69 page0, 'y', 'units', 2,70 improvement_direction=improvement_direction.UP),71 scalar.ScalarValue(72 page1, 'y', 'units', 5,73 improvement_direction=improvement_direction.UP)]74 merged_values = merge_values.MergeLikeValuesFromSamePage(75 all_values, key_func=lambda v: v.page.display_name)76 # Sort the results so that their order is predictable for the subsequent77 # assertions.78 merged_values.sort(key=lambda x: x.page.url)79 self.assertEquals(2, len(merged_values))80 self.assertEquals([1, 2], merged_values[0].values)81 self.assertEquals([4, 5], merged_values[1].values)82 def testSamePageMergeOneValue(self):83 page0 = self.pages[0]84 all_values = [scalar.ScalarValue(85 page0, 'x', 'units', 1,86 improvement_direction=improvement_direction.DOWN)]87 # Sort the results so that their order is predictable for the subsequent88 # assertions.89 merged_values = merge_values.MergeLikeValuesFromSamePage(all_values)90 self.assertEquals(1, len(merged_values))91 self.assertEquals(all_values[0].name, merged_values[0].name)92 self.assertEquals(all_values[0].units, merged_values[0].units)93 def testSamePageMergeWithInteractionRecord(self):94 page0 = self.pages[0]95 all_values = [scalar.ScalarValue(96 page0, 'foo-x', 'units', 1, tir_label='foo',97 improvement_direction=improvement_direction.UP),98 scalar.ScalarValue(99 page0, 'foo-x', 'units', 4, tir_label='foo',100 improvement_direction=improvement_direction.UP)]101 merged_values = merge_values.MergeLikeValuesFromSamePage(all_values)102 self.assertEquals(1, len(merged_values))103 self.assertEquals('foo', merged_values[0].tir_label)104 def testSamePageMergeWithTwoInteractionRecords(self):105 page0 = self.pages[0]106 all_values = [scalar.ScalarValue(page0, 'x', 'units', 1, tir_label='foo'),107 scalar.ScalarValue(page0, 'x', 'units', 4, tir_label='bar')]108 merged_values = merge_values.MergeLikeValuesFromSamePage(all_values)109 self.assertEquals(2, len(merged_values))110 self.assertEquals('foo', merged_values[0].tir_label)111 self.assertEquals('bar', merged_values[1].tir_label)112 def testDifferentPageMergeBasic(self):113 page0 = self.pages[0]114 page1 = self.pages[1]115 all_values = [scalar.ScalarValue(116 page0, 'x', 'units', 1,117 improvement_direction=improvement_direction.UP),118 scalar.ScalarValue(119 page1, 'x', 'units', 2,120 improvement_direction=improvement_direction.UP),121 scalar.ScalarValue(122 page0, 'y', 'units', 10,123 improvement_direction=improvement_direction.UP),124 scalar.ScalarValue(125 page1, 'y', 'units', 20,126 improvement_direction=improvement_direction.UP)]127 merged_values = merge_values.MergeLikeValuesFromDifferentPages(all_values)128 merged_values.sort(key=lambda x: x.name)129 self.assertEquals(2, len(merged_values))130 self.assertEquals((None, 'x'),131 (merged_values[0].page, merged_values[0].name))132 self.assertEquals([1, 2], merged_values[0].values)133 self.assertEquals((None, 'y'),134 (merged_values[1].page, merged_values[1].name))135 self.assertEquals([10, 20], merged_values[1].values)136 def testDifferentPageMergeNonstandardKeyFunc(self):137 page0 = self.pages[0]138 page1 = self.pages[1]139 all_values = [scalar.ScalarValue(140 page0, 'x', 'units', 1,141 improvement_direction=improvement_direction.UP),142 scalar.ScalarValue(143 page1, 'x', 'units', 2,144 improvement_direction=improvement_direction.UP),145 scalar.ScalarValue(146 page0, 'y', 'units', 10,147 improvement_direction=improvement_direction.UP),148 scalar.ScalarValue(149 page1, 'y', 'units', 20,150 improvement_direction=improvement_direction.UP)]151 merged_values = merge_values.MergeLikeValuesFromDifferentPages(152 all_values, key_func=lambda v: True)153 self.assertEquals(1, len(merged_values))154 self.assertEquals([1, 2, 10, 20], merged_values[0].values)155 def testDifferentPageMergeSingleValueStillMerges(self):156 page0 = self.pages[0]157 all_values = [scalar.ScalarValue(158 page0, 'x', 'units', 1,159 improvement_direction=improvement_direction.DOWN)]160 # Sort the results so that their order is predictable for the subsequent161 # assertions.162 merged_values = merge_values.MergeLikeValuesFromDifferentPages(all_values)163 self.assertEquals(1, len(merged_values))164 self.assertEquals((None, 'x'),165 (merged_values[0].page, merged_values[0].name))166 self.assertTrue(167 isinstance(merged_values[0], list_of_scalar_values.ListOfScalarValues))168 self.assertEquals([1], merged_values[0].values)169 def testDifferentPageMergeWithInteractionRecord(self):170 page0 = self.pages[0]171 page1 = self.pages[1]172 v0 = scalar.ScalarValue(page0, 'x', 'units', 1, tir_label='foo')173 v1 = scalar.ScalarValue(page0, 'y', 'units', 30, tir_label='bar')174 v2 = scalar.ScalarValue(page1, 'x', 'units', 2, tir_label='foo')175 v3 = scalar.ScalarValue(page1, 'y', 'units', 40, tir_label='baz')176 all_values = [v0, v1, v2, v3]177 merged_x = list_of_scalar_values.ListOfScalarValues(178 None, 'x', 'units', [1, 2], tir_label='foo')179 merged_y_bar = list_of_scalar_values.ListOfScalarValues(180 None, 'y', 'units', [30], tir_label='bar')181 merged_y_baz = list_of_scalar_values.ListOfScalarValues(182 None, 'y', 'units', [40], tir_label='baz')183 merged_values = merge_values.MergeLikeValuesFromDifferentPages(all_values)184 merged_values.sort(key=lambda x: x.tir_label)...

test_knapsack_with_repetitions.py

Source:test_knapsack_with_repetitions.py

...16 capacity = -117 weights = []18 values = []19 optimal_value(capacity, weights, values)20 def test_with_less_weights_than_values(self):21 with self.assertRaisesRegex(AssertionError, ''):22 capacity = 123 weights = [ 1 ]24 values = [ 2, 3 ]25 optimal_value(capacity, weights, values)26 def test_with_more_weights_than_values(self):27 with self.assertRaisesRegex(AssertionError, ''):28 capacity = 129 weights = [ 1, 2 ]30 values = [ 3 ]31 optimal_value(capacity, weights, values)32 def test_with_preceeding_lower_bound_of_weights(self):33 with self.assertRaisesRegex(AssertionError, ''):34 capacity = 135 weights = [ 1, -1, 2 ]36 values = [ 1, 2, 3 ]37 optimal_value(capacity, weights, values)38 def test_with_preceeding_lower_bound_of_values(self):39 with self.assertRaisesRegex(AssertionError, ''):40 capacity = 141 weights = [ 1, 2, 3 ]42 values = [ 1, -1, 2 ]43 optimal_value(capacity, weights, values)44 def test_with_zero_capacity(self):45 capacity = 046 weights = []47 values = []48 value, items = optimal_value(capacity, weights, values)49 self.assertEqual(0, value)50 self.assertEqual([], items)51 self.assert_items_within_capacity(capacity, weights, values,52 value, items)53 def test_with_non_zero_capacity_and_empty_items(self):54 capacity = 12355 weights = []56 values = []57 value, items = optimal_value(capacity, weights, values)58 self.assertEqual(0, value)59 self.assertEqual([], items)60 self.assert_items_within_capacity(capacity, weights, values,61 value, items)62 def test_with_capacity_as_1_and_weights_as_1(self):63 capacity = 164 weights = [ 1 ]65 values = [ 2 ]66 value, items = optimal_value(capacity, weights, values)67 self.assertEqual(2, value)68 self.assertEqual([ 0 ], items)69 self.assert_items_within_capacity(capacity, weights, values,70 value, items)71 def test_with_capacity_as_1_and_duplicate_weights_and_values(self):72 capacity = 173 weights = [ 1, 1 ]74 values = [ 2, 2 ]75 value, items = optimal_value(capacity, weights, values)76 self.assertEqual(2, value)77 self.assertEqual([ 0 ], items)78 self.assert_items_within_capacity(capacity, weights, values,79 value, items)80 def test_with_capacity_as_1_and_duplicate_weights(self):81 capacity = 182 weights = [ 1, 1 ]83 values = [ 2, 3 ]84 value, items = optimal_value(capacity, weights, values)85 self.assertEqual(3, value)86 self.assertEqual([ 1 ], items)87 self.assert_items_within_capacity(capacity, weights, values,88 value, items)89 def test_with_capacity_as_1_and_duplicate_values(self):90 capacity = 191 weights = [ 1, 2 ]92 values = [ 2, 2 ]93 value, items = optimal_value(capacity, weights, values)94 self.assertEqual(2, value)95 self.assertEqual([ 0 ], items)96 self.assert_items_within_capacity(capacity, weights, values,97 value, items)98 def test_with_capacity_as_1_and_weights_as_2(self):99 capacity = 1100 weights = [ 2 ]101 values = [ 3 ]102 value, items = optimal_value(capacity, weights, values)103 self.assertEqual(0, value)...

## 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.