How to use values method in Molotov

Best Python code snippet using molotov_python

talib_indicators.py

Source:talib_indicators.py Github

copy

Full Screen

1# coding:utf-82#3# The MIT License (MIT)4#5# Copyright (c) 2016-2021 yutiansut/QUANTAXIS6#7# Permission is hereby granted, free of charge, to any person obtaining a copy8# of this software and associated documentation files (the "Software"), to deal9# in the Software without restriction, including without limitation the rights10# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell11# copies of the Software, and to permit persons to whom the Software is12# furnished to do so, subject to the following conditions:13#14# The above copyright notice and this permission notice shall be included in all15# copies or substantial portions of the Software.16#17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE20# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE23# SOFTWARE.24import pandas as pd25try:26 import talib27except:28 pass29 #print('PLEASE install TALIB to call these methods')30def AD(DataFrame):31 res = talib.AD(DataFrame.high.values, DataFrame.low.values,32 DataFrame.close.values, DataFrame.volume.values)33 return pd.DataFrame({'AD': res}, index=DataFrame.index)34def ADOSC(DataFrame, N1=3, N2=10):35 res = talib.ADOSC(DataFrame.high.values, DataFrame.low.values,36 DataFrame.close.values, DataFrame.volume.values, N1, N2)37 return pd.DataFrame({'ADOSC': res}, index=DataFrame.index)38def ADX(DataFrame, N=14):39 res = talib.ADX(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)40 return pd.DataFrame({'ADX': res}, index=DataFrame.index)41def ADXR(DataFrame, N=14):42 res = talib.ADXR(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)43 return pd.DataFrame({'ADXR': res}, index=DataFrame.index)44def AROON(DataFrame, N=14):45 """阿隆指标46 47 Arguments:48 DataFrame {[type]} -- [description]49 50 Keyword Arguments:51 N {int} -- [description] (default: {14})52 53 Returns:54 [type] -- [description]55 """56 ar_up, ar_down = talib.AROON(DataFrame.high.values, DataFrame.low.values, N)57 return pd.DataFrame({'AROON_UP': ar_up,'AROON_DOWN': ar_down}, index=DataFrame.index)58def AROONOSC(DataFrame, N=14):59 res = talib.AROONOSC(DataFrame.high.values, DataFrame.low.values, N)60 return pd.DataFrame({'AROONOSC': res}, index=DataFrame.index)61def ATR(DataFrame, N=14):62 res = talib.ATR(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)63 return pd.DataFrame({'ATR': res}, index=DataFrame.index)64def AVGPRICE(DataFrame):65 res = talib.AVGPRICE(DataFrame.open.values, DataFrame.high.values,66 DataFrame.low.values, DataFrame.close.values)67 return pd.DataFrame({'AVGPRICE': res}, index=DataFrame.index)68def BOP(DataFrame):69 res = talib.BOP(DataFrame.open.values, DataFrame.high.values,70 DataFrame.low.values, DataFrame.close.values)71 return pd.DataFrame({'BOP': res}, index=DataFrame.index)72def CCI(DataFrame, N=14):73 res = talib.CCI(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)74 return pd.DataFrame({'CCI': res}, index=DataFrame.index)75def CDL2CROWS(DataFrame):76 res = talib.CDL2CROWS(DataFrame.open.values, DataFrame.high.values,77 DataFrame.low.values, DataFrame.close.values)78 return pd.DataFrame({'CDL2CROWS': res}, index=DataFrame.index)79def CDL3BLACKCROWS(DataFrame):80 res = talib.CDL3BLACKCROWS(81 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)82 return pd.DataFrame({'CDL3BLACKCROWS': res}, index=DataFrame.index)83def CDL3INSIDE(DataFrame):84 res = talib.CDL3INSIDE(85 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)86 return pd.DataFrame({'CDL3INSIDE': res}, index=DataFrame.index)87def CDL3LINESTRIKE(DataFrame):88 res = talib.CDL3LINESTRIKE(89 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)90 return pd.DataFrame({'CDL3LINESTRIKE': res}, index=DataFrame.index)91def CDL3OUTSIDE(DataFrame):92 res = talib.CDL3OUTSIDE(93 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)94 return pd.DataFrame({'CDL3OUTSIDE': res}, index=DataFrame.index)95def CDL3STARSINSOUTH(DataFrame):96 res = talib.CDL3STARSINSOUTH(97 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)98 return pd.DataFrame({'CDL3STARSINSOUTH': res}, index=DataFrame.index)99def CDL3WHITESOLDIERS(DataFrame):100 res = talib.CDL3WHITESOLDIERS(101 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)102 return pd.DataFrame({'CDL3WHITESOLDIERS': res}, index=DataFrame.index)103def CDLABANDONEDBABY(DataFrame):104 res = talib.CDLABANDONEDBABY(105 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)106 return pd.DataFrame({'CDLABANDONEDBABY': res}, index=DataFrame.index)107def CDLADVANCEBLOCK(DataFrame):108 res = talib.CDLADVANCEBLOCK(109 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)110 return pd.DataFrame({'CDLADVANCEBLOCK': res}, index=DataFrame.index)111def CDLBELTHOLD(DataFrame):112 res = talib.CDLBELTHOLD(113 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)114 return pd.DataFrame({'CDLBELTHOLD': res}, index=DataFrame.index)115def CDLBREAKAWAY(DataFrame):116 res = talib.CDLBREAKAWAY(117 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)118 return pd.DataFrame({'CDLBREAKAWAY': res}, index=DataFrame.index)119def CDLCLOSINGMARUBOZU(DataFrame):120 """121 Closing Marubozu (Pattern Recognition)122 Arguments:123 DataFrame {[type]} -- [description]124 """125 res = talib.CDLCLOSINGMARUBOZU(126 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)127 return pd.DataFrame({'CDLCLOSINGMARUBOZU': res}, index=DataFrame.index)128def CDLCONCEALBABYSWALL(DataFrame):129 res = talib.CDLCONCEALBABYSWALL(130 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)131 return pd.DataFrame({'CDLCONCEALBABYSWALL': res}, index=DataFrame.index)132def CDLCOUNTERATTACK(DataFrame):133 res = talib.CDLCOUNTERATTACK(134 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)135 return pd.DataFrame({'CDLCOUNTERATTACK': res}, index=DataFrame.index)136def CDLDARKCLOUDCOVER(DataFrame):137 res = talib.CDLDARKCLOUDCOVER(138 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)139 return pd.DataFrame({'CDLDARKCLOUDCOVER': res}, index=DataFrame.index)140def CDLDOJI(DataFrame):141 res = talib.CDLDOJI(DataFrame.open.values, DataFrame.high.values,142 DataFrame.low.values, DataFrame.close.values)143 return pd.DataFrame({'CDLDOJI': res}, index=DataFrame.index)144def CDLDOJISTAR(DataFrame):145 res = talib.CDLDOJISTAR(146 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)147 return pd.DataFrame({'CDLDOJISTAR': res}, index=DataFrame.index)148def CDLDRAGONFLYDOJI(DataFrame):149 res = talib.CDLDRAGONFLYDOJI(150 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)151 return pd.DataFrame({'CDLDRAGONFLYDOJI': res}, index=DataFrame.index)152def CDLENGULFING(DataFrame):153 res = talib.CDLENGULFING(154 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)155 return pd.DataFrame({'CDLENGULFING': res}, index=DataFrame.index)156def CDLEVENINGDOJISTAR(DataFrame):157 res = talib.CDLEVENINGDOJISTAR(158 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)159 return pd.DataFrame({'CDLEVENINGDOJISTAR': res}, index=DataFrame.index)160def CDLEVENINGSTAR(DataFrame):161 res = talib.CDLEVENINGSTAR(162 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)163 return pd.DataFrame({'CDLEVENINGSTAR': res}, index=DataFrame.index)164def CDLGAPSIDESIDEWHITE(DataFrame):165 res = talib.CDLGAPSIDESIDEWHITE(166 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)167 return pd.DataFrame({'CDLGAPSIDESIDEWHITE': res}, index=DataFrame.index)168def CDLGRAVESTONEDOJI(DataFrame):169 res = talib.CDLGRAVESTONEDOJI(170 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)171 return pd.DataFrame({'CDLGRAVESTONEDOJI': res}, index=DataFrame.index)172def CDLHAMMER(DataFrame):173 res = talib.CDLHAMMER(DataFrame.open.values, DataFrame.high.values,174 DataFrame.low.values, DataFrame.close.values)175 return pd.DataFrame({'CDLHAMMER': res}, index=DataFrame.index)176def CDLHANGINGMAN(DataFrame):177 res = talib.CDLHANGINGMAN(178 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)179 return pd.DataFrame({'CDLHANGINGMAN': res}, index=DataFrame.index)180def CDLHARAMI(DataFrame):181 res = talib.CDLHARAMI(DataFrame.open.values, DataFrame.high.values,182 DataFrame.low.values, DataFrame.close.values)183 return pd.DataFrame({'CDLHARAMI': res}, index=DataFrame.index)184def CDLHARAMICROSS(DataFrame):185 res = talib.CDLHARAMICROSS(186 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)187 return pd.DataFrame({'CDLHARAMICROSS': res}, index=DataFrame.index)188def CDLHIGHWAVE(DataFrame):189 res = talib.CDLHIGHWAVE(190 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)191 return pd.DataFrame({'CDLHIGHWAVE': res}, index=DataFrame.index)192def CDLHIKKAKE(DataFrame):193 res = talib.CDLHIKKAKE(DataFrame.open.values, DataFrame.high.values,194 DataFrame.low.values, DataFrame.close.values)195 return pd.DataFrame({'CDLHIKKAKE': res}, index=DataFrame.index)196def CDLHIKKAKEMOD(DataFrame):197 res = talib.CDLHIKKAKEMOD(198 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)199 return pd.DataFrame({'CDLHIKKAKEMOD': res}, index=DataFrame.index)200def CDLHOMINGPIGEON(DataFrame):201 res = talib.CDLHOMINGPIGEON(202 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)203 return pd.DataFrame({'CDLHOMINGPIGEON': res}, index=DataFrame.index)204def CDLIDENTICAL3CROWS(DataFrame):205 res = talib.CDLIDENTICAL3CROWS(206 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)207 return pd.DataFrame({'CDLIDENTICAL3CROWS': res}, index=DataFrame.index)208def CDLINNECK(DataFrame):209 res = talib.CDLINNECK(DataFrame.open.values, DataFrame.high.values,210 DataFrame.low.values, DataFrame.close.values)211 return pd.DataFrame({'CDLINNECK': res}, index=DataFrame.index)212def CDLINVERTEDHAMMER(DataFrame):213 res = talib.CDLINVERTEDHAMMER(214 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)215 return pd.DataFrame({'CDLINVERTEDHAMMER': res}, index=DataFrame.index)216def CDLKICKING(DataFrame):217 res = talib.CDLKICKING(DataFrame.open.values, DataFrame.high.values,218 DataFrame.low.values, DataFrame.close.values)219 return pd.DataFrame({'CDLKICKING': res}, index=DataFrame.index)220def CDLKICKINGBYLENGTH(DataFrame):221 res = talib.CDLKICKINGBYLENGTH(222 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)223 return pd.DataFrame({'CDLKICKINGBYLENGTH': res}, index=DataFrame.index)224def CDLLADDERBOTTOM(DataFrame):225 res = talib.CDLLADDERBOTTOM(226 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)227 return pd.DataFrame({'CDLLADDERBOTTOM': res}, index=DataFrame.index)228def CDLLONGLEGGEDDOJI(DataFrame):229 res = talib.CDLLONGLEGGEDDOJI(230 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)231 return pd.DataFrame({'CDLLONGLEGGEDDOJI': res}, index=DataFrame.index)232def CDLLONGLINE(DataFrame):233 res = talib.CDLLONGLINE(234 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)235 return pd.DataFrame({'CDLLONGLINE': res}, index=DataFrame.index)236def CDLMARUBOZU(DataFrame):237 res = talib.CDLMARUBOZU(238 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)239 return pd.DataFrame({'CDLMARUBOZU': res}, index=DataFrame.index)240def CDLMATCHINGLOW(DataFrame):241 res = talib.CDLMATCHINGLOW(242 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)243 return pd.DataFrame({'CDLMATCHINGLOW': res}, index=DataFrame.index)244def CDLMATHOLD(DataFrame):245 res = talib.CDLMATHOLD(DataFrame.open.values, DataFrame.high.values,246 DataFrame.low.values, DataFrame.close.values)247 return pd.DataFrame({'CDLMATHOLD': res}, index=DataFrame.index)248def CDLMORNINGDOJISTAR(DataFrame):249 res = talib.CDLMORNINGDOJISTAR(250 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)251 return pd.DataFrame({'CDLMORNINGDOJISTAR': res}, index=DataFrame.index)252def CDLMORNINGSTAR(DataFrame):253 res = talib.CDLMORNINGSTAR(254 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)255 return pd.DataFrame({'CDLMORNINGSTAR': res}, index=DataFrame.index)256def CDLONNECK(DataFrame):257 res = talib.CDLONNECK(DataFrame.open.values, DataFrame.high.values,258 DataFrame.low.values, DataFrame.close.values)259 return pd.DataFrame({'CDLONNECK': res}, index=DataFrame.index)260def CDLPIERCING(DataFrame):261 res = talib.CDLPIERCING(262 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)263 return pd.DataFrame({'CDLPIERCING': res}, index=DataFrame.index)264def CDLRICKSHAWMAN(DataFrame):265 res = talib.CDLRICKSHAWMAN(266 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)267 return pd.DataFrame({'CDLRICKSHAWMAN': res}, index=DataFrame.index)268def CDLRISEFALL3METHODS(DataFrame):269 res = talib.CDLRISEFALL3METHODS(270 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)271 return pd.DataFrame({'CDLRISEFALL3METHODS': res}, index=DataFrame.index)272def CDLSEPARATINGLINES(DataFrame):273 res = talib.CDLSEPARATINGLINES(274 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)275 return pd.DataFrame({'CDLSEPARATINGLINES': res}, index=DataFrame.index)276def CDLSHOOTINGSTAR(DataFrame):277 res = talib.CDLSHOOTINGSTAR(278 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)279 return pd.DataFrame({'CDLSHOOTINGSTAR': res}, index=DataFrame.index)280def CDLSHORTLINE(DataFrame):281 res = talib.CDLSHORTLINE(282 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)283 return pd.DataFrame({'CDLSHORTLINE': res}, index=DataFrame.index)284def CDLSPINNINGTOP(DataFrame):285 res = talib.CDLSPINNINGTOP(286 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)287 return pd.DataFrame({'CDLSPINNINGTOP': res}, index=DataFrame.index)288def CDLSTALLEDPATTERN(DataFrame):289 res = talib.CDLSTALLEDPATTERN(290 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)291 return pd.DataFrame({'CDLSTALLEDPATTERN': res}, index=DataFrame.index)292def CDLSTICKSANDWICH(DataFrame):293 res = talib.CDLSTICKSANDWICH(294 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)295 return pd.DataFrame({'CDLSTICKSANDWICH': res}, index=DataFrame.index)296def CDLTAKURI(DataFrame):297 res = talib.CDLTAKURI(DataFrame.open.values, DataFrame.high.values,298 DataFrame.low.values, DataFrame.close.values)299 return pd.DataFrame({'CDLTAKURI': res}, index=DataFrame.index)300def CDLTASUKIGAP(DataFrame):301 res = talib.CDLTASUKIGAP(302 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)303 return pd.DataFrame({'CDLTASUKIGAP': res}, index=DataFrame.index)304def CDLTHRUSTING(DataFrame):305 res = talib.CDLTHRUSTING(306 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)307 return pd.DataFrame({'CDLTHRUSTING': res}, index=DataFrame.index)308def CDLTRISTAR(DataFrame):309 res = talib.CDLTRISTAR(DataFrame.open.values, DataFrame.high.values,310 DataFrame.low.values, DataFrame.close.values)311 return pd.DataFrame({'CDLTRISTAR': res}, index=DataFrame.index)312def CDLUNIQUE3RIVER(DataFrame):313 res = talib.CDLUNIQUE3RIVER(314 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)315 return pd.DataFrame({'CDLUNIQUE3RIVER': res}, index=DataFrame.index)316def CDLUPSIDEGAP2CROWS(DataFrame):317 res = talib.CDLUPSIDEGAP2CROWS(318 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)319 return pd.DataFrame({'CDLUPSIDEGAP2CROWS': res}, index=DataFrame.index)320def CDLXSIDEGAP3METHODS(DataFrame):321 res = talib.CDLXSIDEGAP3METHODS(322 DataFrame.open.values, DataFrame.high.values, DataFrame.low.values, DataFrame.close.values)323 return pd.DataFrame({'CDLXSIDEGAP3METHODS': res}, index=DataFrame.index)324def DX(DataFrame, N=14):325 res = talib.DX(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values, N)326 return pd.DataFrame({'DX': res}, index=DataFrame.index)327# SAR - Parabolic SAR328def SAR(DataFrame, acceleration=0, maximum=0):329 res = talib.SAR(DataFrame.high.values, DataFrame.low.values, acceleration, maximum)330 return pd.DataFrame({'SAR': res}, index=DataFrame.index)331def SAREXT(DataFrame, startvalue=0, offsetonreverse=0, accelerationinitlong=0,332 accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0, accelerationshort=0, accelerationmaxshort=0):333 res = talib.SAREXT(DataFrame.high.values, DataFrame.low.values,334 startvalue, offsetonreverse, accelerationinitlong, accelerationlong, accelerationmaxlong,335 accelerationinitshort, accelerationshort, accelerationmaxshort)336 return pd.DataFrame({'SAREXT': res}, index=DataFrame.index)337def STOCH(DataFrame, fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0):338 slowk, slowd = talib.STOCH(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values,339 fastk_period, slowk_period, slowk_matype, slowd_period, slowd_matype)340 return pd.DataFrame({'STOCH_SLOWK': slowk, 'STOCH_SLOWD': slowd}, index=DataFrame.index)341def STOCHF(DataFrame, fastk_period=5, fastd_period=3, fastd_matype=0):342 fastk, fastd = talib.STOCHF(DataFrame.high.values, DataFrame.low.values, DataFrame.close.values,343 fastk_period, fastd_period, fastd_matype)...

Full Screen

Full Screen

qgis2web_expressions.js

Source:qgis2web_expressions.js Github

copy

Full Screen

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

Full Screen

Full Screen

merge_values_unittest.py

Source:merge_values_unittest.py Github

copy

Full Screen

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

Full Screen

Full Screen

test_knapsack_with_repetitions.py

Source:test_knapsack_with_repetitions.py Github

copy

Full Screen

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

Full Screen

Full Screen

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 Molotov 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