Best Python code snippet using playwright-python
gui.py
Source:gui.py  
...329    instrText = 'Use the drop-down menus under the "To" column to choose where the Pok\u00E9mon in the corresponding "From" box will be sent. Boxes marked with "None" will not be transferred. Click the name of the From box to see its contents in the display below.'330    instrLabel = ttk.Label(displayFrame, text=instrText,331                           wraplength=DISP_WIDTH)332    instrLabel.grid(row=0, column=0)333    boxDisplay = ttk.Labelframe(displayFrame)334    boxDisplay.grid(row=1, column=0, pady=20)335    336    #todo: make warning red?337    warning = "WARNING! Any Pok\u00E9mon that previously inhabited chosen boxes in the Gen III save file will be ERASED. It is recommended that you only select empty Gen III boxes."338    warningLabel = ttk.Label(displayFrame, text=warning,339                             wraplength=DISP_WIDTH)340    warningLabel.grid(row=2, column=0)341    navFrame = Nav(baseFrame, root.prevPage, nextPage)342    navFrame.grid(row=1, column=0, sticky='we')343    return (baseFrame, 'Box Selection', {'sticky':'nsew'})344def overwriteWindow(root):345    '''Creates the window for deciding to overwrite or not.'''346    def toggle(*args):    347        setState(choice.get(), 'disabled', [gen2Label, gen3Label,...talib_indicators.py
Source:talib_indicators.py  
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)...animation_file_conversion_helpers.py
Source:animation_file_conversion_helpers.py  
1# Copyright (c) 2022 Boston Dynamics, Inc.  All rights reserved.2#3# Downloading, reproducing, distributing or otherwise using the SDK Software4# is subject to the terms and conditions of the Boston Dynamics Software5# Development Kit License (20191101-BDSDK-SL).6"""A set helpers which convert specific lines from an animation7file into the animation-specific protobuf messages.8NOTE: All of these helpers are to convert specific values read from a `cha`9file into fields within the choreography_sequence_pb2.Animation protobuf10message. They are used by the animation_file_to_proto.py file.11"""12from bosdyn.api.spot import (choreography_sequence_pb2, choreography_service_pb2,13                             choreography_service_pb2_grpc)14def start_time_handler(val, animation_frame):15    animation_frame.time = val16    return animation_frame17def fl_angles_handler(vals, animation_frame):18    animation_frame.legs.fl.joint_angles.hip_x = vals[0]19    animation_frame.legs.fl.joint_angles.hip_y = vals[1]20    animation_frame.legs.fl.joint_angles.knee = vals[2]21    return animation_frame22def fr_angles_handler(vals, animation_frame):23    animation_frame.legs.fr.joint_angles.hip_x = vals[0]24    animation_frame.legs.fr.joint_angles.hip_y = vals[1]25    animation_frame.legs.fr.joint_angles.knee = vals[2]26    return animation_frame27def hl_angles_handler(vals, animation_frame):28    animation_frame.legs.hl.joint_angles.hip_x = vals[0]29    animation_frame.legs.hl.joint_angles.hip_y = vals[1]30    animation_frame.legs.hl.joint_angles.knee = vals[2]31    return animation_frame32def hr_angles_handler(vals, animation_frame):33    animation_frame.legs.hr.joint_angles.hip_x = vals[0]34    animation_frame.legs.hr.joint_angles.hip_y = vals[1]35    animation_frame.legs.hr.joint_angles.knee = vals[2]36    return animation_frame37def fl_pos_handler(vals, animation_frame):38    animation_frame.legs.fl.foot_pos.x.value = vals[0]39    animation_frame.legs.fl.foot_pos.y.value = vals[1]40    animation_frame.legs.fl.foot_pos.z.value = vals[2]41    return animation_frame42def fr_pos_handler(vals, animation_frame):43    animation_frame.legs.fr.foot_pos.x.value = vals[0]44    animation_frame.legs.fr.foot_pos.y.value = vals[1]45    animation_frame.legs.fr.foot_pos.z.value = vals[2]46    return animation_frame47def hl_pos_handler(vals, animation_frame):48    animation_frame.legs.hl.foot_pos.x.value = vals[0]49    animation_frame.legs.hl.foot_pos.y.value = vals[1]50    animation_frame.legs.hl.foot_pos.z.value = vals[2]51    return animation_frame52def hr_pos_handler(vals, animation_frame):53    animation_frame.legs.hr.foot_pos.x.value = vals[0]54    animation_frame.legs.hr.foot_pos.y.value = vals[1]55    animation_frame.legs.hr.foot_pos.z.value = vals[2]56    return animation_frame57def gripper_handler(val, animation_frame):58    animation_frame.gripper.gripper_angle.value = val59    return animation_frame60def fl_contact_handler(val, animation_frame):61    animation_frame.legs.fl.stance.value = val62    return animation_frame63def fr_contact_handler(val, animation_frame):64    animation_frame.legs.fr.stance.value = val65    return animation_frame66def hl_contact_handler(val, animation_frame):67    animation_frame.legs.hl.stance.value = val68    return animation_frame69def hr_contact_handler(val, animation_frame):70    animation_frame.legs.hr.stance.value = val71    return animation_frame72def sh0_handler(val, animation_frame):73    animation_frame.arm.joint_angles.shoulder_0.value = val74    return animation_frame75def sh1_handler(val, animation_frame):76    animation_frame.arm.joint_angles.shoulder_1.value = val77    return animation_frame78def el0_handler(val, animation_frame):79    animation_frame.arm.joint_angles.elbow_0.value = val80    return animation_frame81def el1_handler(val, animation_frame):82    animation_frame.arm.joint_angles.elbow_1.value = val83    return animation_frame84def wr0_handler(val, animation_frame):85    animation_frame.arm.joint_angles.wrist_0.value = val86    return animation_frame87def wr1_handler(val, animation_frame):88    animation_frame.arm.joint_angles.wrist_1.value = val89    return animation_frame90def fl_hx_handler(val, animation_frame):91    animation_frame.legs.fl.joint_angles.hip_x = val92    return animation_frame93def fl_hy_handler(val, animation_frame):94    animation_frame.legs.fl.joint_angles.hip_y = val95    return animation_frame96def fl_kn_handler(val, animation_frame):97    animation_frame.legs.fl.joint_angles.knee = val98    return animation_frame99def fr_hx_handler(val, animation_frame):100    animation_frame.legs.fr.joint_angles.hip_x = val101    return animation_frame102def fr_hy_handler(val, animation_frame):103    animation_frame.legs.fr.joint_angles.hip_y = val104    return animation_frame105def fr_kn_handler(val, animation_frame):106    animation_frame.legs.fr.joint_angles.knee = val107    return animation_frame108def hl_hx_handler(val, animation_frame):109    animation_frame.legs.hl.joint_angles.hip_x = val110    return animation_frame111def hl_hy_handler(val, animation_frame):112    animation_frame.legs.hl.joint_angles.hip_y = val113    return animation_frame114def hl_kn_handler(val, animation_frame):115    animation_frame.legs.hl.joint_angles.knee = val116    return animation_frame117def hr_hx_handler(val, animation_frame):118    animation_frame.legs.hr.joint_angles.hip_x = val119    return animation_frame120def hr_hy_handler(val, animation_frame):121    animation_frame.legs.hr.joint_angles.hip_y = val122    return animation_frame123def hr_kn_handler(val, animation_frame):124    animation_frame.legs.hr.joint_angles.knee = val125    return animation_frame126def fl_x_handler(val, animation_frame):127    animation_frame.legs.fl.foot_pos.x.value = val128    return animation_frame129def fl_y_handler(val, animation_frame):130    animation_frame.legs.fl.foot_pos.y.value = val131    return animation_frame132def fl_z_handler(val, animation_frame):133    animation_frame.legs.fl.foot_pos.z.value = val134    return animation_frame135def fr_x_handler(val, animation_frame):136    animation_frame.legs.fr.foot_pos.x.value = val137    return animation_frame138def fr_y_handler(val, animation_frame):139    animation_frame.legs.fr.foot_pos.y.value = val140    return animation_frame141def fr_z_handler(val, animation_frame):142    animation_frame.legs.fr.foot_pos.z.value = val143    return animation_frame144def hl_x_handler(val, animation_frame):145    animation_frame.legs.hl.foot_pos.x.value = val146    return animation_frame147def hl_y_handler(val, animation_frame):148    animation_frame.legs.hl.foot_pos.y.value = val149    return animation_frame150def hl_z_handler(val, animation_frame):151    animation_frame.legs.hl.foot_pos.z.value = val152    return animation_frame153def hr_x_handler(val, animation_frame):154    animation_frame.legs.hr.foot_pos.x.value = val155    return animation_frame156def hr_y_handler(val, animation_frame):157    animation_frame.legs.hr.foot_pos.y.value = val158    return animation_frame159def hr_z_handler(val, animation_frame):160    animation_frame.legs.hr.foot_pos.z.value = val161    return animation_frame162def body_x_handler(val, animation_frame):163    animation_frame.body.body_pos.x.value = val164    return animation_frame165def body_y_handler(val, animation_frame):166    animation_frame.body.body_pos.y.value = val167    return animation_frame168def body_z_handler(val, animation_frame):169    animation_frame.body.body_pos.z.value = val170    return animation_frame171def com_x_handler(val, animation_frame):172    animation_frame.body.com_pos.x.value = val173    return animation_frame174def com_y_handler(val, animation_frame):175    animation_frame.body.com_pos.y.value = val176    return animation_frame177def com_z_handler(val, animation_frame):178    animation_frame.body.com_pos.z.value = val179    return animation_frame180def body_quat_x_handler(val, animation_frame):181    animation_frame.body.quaternion.x = val182    return animation_frame183def body_quat_y_handler(val, animation_frame):184    animation_frame.body.quaternion.y = val185    return animation_frame186def body_quat_z_handler(val, animation_frame):187    animation_frame.body.quaternion.z = val188    return animation_frame189def body_quat_w_handler(val, animation_frame):190    animation_frame.body.quaternion.w = val191    return animation_frame192def body_roll_handler(val, animation_frame):193    animation_frame.body.euler_angles.roll.value = val194    return animation_frame195def body_pitch_handler(val, animation_frame):196    animation_frame.body.euler_angles.pitch.value = val197    return animation_frame198def body_yaw_handler(val, animation_frame):199    animation_frame.body.euler_angles.yaw.value = val200    return animation_frame201def body_pos_handler(vals, animation_frame):202    animation_frame.body.body_pos.x.value = vals[0]203    animation_frame.body.body_pos.y.value = vals[1]204    animation_frame.body.body_pos.z.value = vals[2]205    return animation_frame206def com_pos_handler(vals, animation_frame):207    animation_frame.body.com_pos.x.value = vals[0]208    animation_frame.body.com_pos.y.value = vals[1]209    animation_frame.body.com_pos.z.value = vals[2]210    return animation_frame211def body_euler_rpy_angles_handler(vals, animation_frame):212    animation_frame.body.euler_angles.roll.value = vals[0]213    animation_frame.body.euler_angles.pitch.value = vals[1]214    animation_frame.body.euler_angles.yaw.value = vals[2]215    return animation_frame216def body_quaternion_xyzw_handler(vals, animation_frame):217    animation_frame.body.quaternion.x = vals[0]218    animation_frame.body.quaternion.y = vals[1]219    animation_frame.body.quaternion.z = vals[2]220    animation_frame.body.quaternion.w = vals[3]221    return animation_frame222def body_quaternion_wxyz_handler(vals, animation_frame):223    animation_frame.body.quaternion.x = vals[1]224    animation_frame.body.quaternion.y = vals[2]225    animation_frame.body.quaternion.z = vals[3]226    animation_frame.body.quaternion.w = vals[0]227    return animation_frame228def leg_angles_handler(vals, animation_frame):229    animation_frame.legs.fl.joint_angles.hip_x = vals[0]230    animation_frame.legs.fl.joint_angles.hip_y = vals[1]231    animation_frame.legs.fl.joint_angles.knee = vals[2]232    animation_frame.legs.fr.joint_angles.hip_x = vals[3]233    animation_frame.legs.fr.joint_angles.hip_y = vals[4]234    animation_frame.legs.fr.joint_angles.knee = vals[5]235    animation_frame.legs.hl.joint_angles.hip_x = vals[6]236    animation_frame.legs.hl.joint_angles.hip_y = vals[7]237    animation_frame.legs.hl.joint_angles.knee = vals[8]238    animation_frame.legs.hr.joint_angles.hip_x = vals[9]239    animation_frame.legs.hr.joint_angles.hip_y = vals[10]240    animation_frame.legs.hr.joint_angles.knee = vals[11]241    return animation_frame242def foot_pos_handler(vals, animation_frame):243    animation_frame.legs.fl.foot_pos.x.value = vals[0]244    animation_frame.legs.fl.foot_pos.y.value = vals[1]245    animation_frame.legs.fl.foot_pos.z.value = vals[2]246    animation_frame.legs.fr.foot_pos.x.value = vals[3]247    animation_frame.legs.fr.foot_pos.y.value = vals[4]248    animation_frame.legs.fr.foot_pos.z.value = vals[5]249    animation_frame.legs.hl.foot_pos.x.value = vals[6]250    animation_frame.legs.hl.foot_pos.y.value = vals[7]251    animation_frame.legs.hl.foot_pos.z.value = vals[8]252    animation_frame.legs.hr.foot_pos.x.value = vals[9]253    animation_frame.legs.hr.foot_pos.y.value = vals[10]254    animation_frame.legs.hr.foot_pos.z.value = vals[11]255    return animation_frame256def contact_handler(vals, animation_frame):257    animation_frame.legs.fl.stance.value = vals[0]258    animation_frame.legs.fr.stance.value = vals[1]259    animation_frame.legs.hl.stance.value = vals[2]260    animation_frame.legs.hr.stance.value = vals[3]261    return animation_frame262def arm_joints_handler(vals, animation_frame):263    animation_frame.arm.joint_angles.shoulder_0.value = vals[0]264    animation_frame.arm.joint_angles.shoulder_1.value = vals[1]265    animation_frame.arm.joint_angles.elbow_0.value = vals[2]266    animation_frame.arm.joint_angles.elbow_1.value = vals[3]267    animation_frame.arm.joint_angles.wrist_0.value = vals[4]268    animation_frame.arm.joint_angles.wrist_1.value = vals[5]269    return animation_frame270def hand_x_handler(vals, animation_frame):271    animation_frame.arm.hand_pose.position.x = vals[0]272    return animation_frame273def hand_y_handler(vals, animation_frame):274    animation_frame.arm.hand_pose.position.y = vals[0]275    return animation_frame276def hand_z_handler(vals, animation_frame):277    animation_frame.arm.hand_pose.position.z = vals[0]278    return animation_frame279def hand_quat_x_handler(val, animation_frame):280    animation_frame.arm.hand_pose.quaternion.x = val281    return animation_frame282def hand_quat_y_handler(val, animation_frame):283    animation_frame.arm.hand_pose.quaternion.y = val284    return animation_frame285def hand_quat_z_handler(val, animation_frame):286    animation_frame.arm.hand_pose.quaternion.z = val287    return animation_frame288def hand_quat_w_handler(val, animation_frame):289    animation_frame.arm.hand_pose.quaternion.w = val290    return animation_frame291def hand_roll_handler(val, animation_frame):292    animation_frame.arm.hand_pose.euler_angles.roll.value = val293    return animation_frame294def hand_pitch_handler(val, animation_frame):295    animation_frame.arm.hand_pose.euler_angles.pitch.value = val296    return animation_frame297def hand_yaw_handler(val, animation_frame):298    animation_frame.arm.hand_pose.euler_angles.yaw.value = val299    return animation_frame300def hand_pos_handler(vals, animation_frame):301    animation_frame.arm.hand_pose.position.x.value = vals[0]302    animation_frame.arm.hand_pose.position.y.value = vals[1]303    animation_frame.arm.hand_pose.position.z.value = vals[2]304    return animation_frame305def hand_euler_rpy_angles_handler(vals, animation_frame):306    animation_frame.arm.hand_pose.euler_angles.roll.value = vals[0]307    animation_frame.arm.hand_pose.euler_angles.pitch.value = vals[1]308    animation_frame.arm.hand_pose.euler_angles.yaw.value = vals[2]309    return animation_frame310def hand_quaternion_xyzw_handler(vals, animation_frame):311    animation_frame.arm.hand_pose.quaternion.x = vals[0]312    animation_frame.arm.hand_pose.quaternion.y = vals[1]313    animation_frame.arm.hand_pose.quaternion.z = vals[2]314    animation_frame.arm.hand_pose.quaternion.w = vals[3]315    return animation_frame316def hand_quaternion_wxyz_handler(vals, animation_frame):317    animation_frame.arm.hand_pose.quaternion.x = vals[1]318    animation_frame.arm.hand_pose.quaternion.y = vals[2]319    animation_frame.arm.hand_pose.quaternion.z = vals[3]320    animation_frame.arm.hand_pose.quaternion.w = vals[0]321    return animation_frame322def controls_option(file_line_split, animation):323    for track in file_line_split:324        if track == "legs":325            animation.proto.controls_legs = True326        elif track == "arm":327            animation.proto.controls_arm = True328        elif track == "body":329            animation.proto.controls_body = True330        elif track == "gripper":331            animation.proto.controls_gripper = True332        elif track == "controls":333            continue334        else:335            print("Unknown track name %s" % track)336    return animation337def bpm_option(file_line_split, animation):338    bpm = file_line_split[1]339    animation.bpm = int(bpm)340    return animation341def extendable_option(file_line_split, animation):342    animation.proto.extendable = True343    return animation344def truncatable_option(file_line_split, animation):345    animation.proto.truncatable = True346    return animation347def neutral_start_option(file_line_split, animation):348    animation.proto.neutral_start = True349    return animation350def precise_steps_option(file_line_split, animation):351    animation.proto.precise_steps = True352def precise_timing_option(file_line_split, animation):353    animation.proto.precise_timing = True354def no_looping_option(file_line_split, animation):355    animation.proto.no_looping = True356def arm_required_option(file_line_split, animation):357    animation.proto.arm_required = True358def arm_prohibited_option(file_line_split, animation):359    animation.proto.arm_prohibited = True360def track_swing_trajectories_option(file_line_split, animation):361    animation.proto.track_swing_trajectories = True362    return animation363def assume_zero_roll_and_pitch_option(file_line_split, animation):364    animation.proto.assume_zero_roll_and_pitch = True365    return animation366def track_hand_rt_body_option(file_line_split, animation):367    animation.proto.track_hand_rt_body = True368    return animation369def track_hand_rt_feet_option(file_line_split, animation):370    animation.proto.track_hand_rt_feet = True371    return animation372def arm_playback_option(file_line_split, animation):373    playback = file_line_split[1]374    if playback == "jointspace":375        animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_JOINTSPACE376    elif playback == "workspace":377        animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_WORKSPACE378    elif playback == "workspace_dance_frame":379        animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_WORKSPACE_DANCE_FRAME380    else:381        animation.proto.arm_playback = choreography_sequence_pb2.Animation.ARM_PLAYBACK_DEFAULT382        print("Unknown arm playback option %s" % playback)383    return animation384def display_rgb_option(file_line_split, animation):385    for i in range(1, 3):386        animation.rgb[i - 1] = int(file_line_split[i])387    return animation388def frequency_option(file_line_split, animation):389    freq = file_line_split[1]390    animation.frequency = float(freq)391    return animation392def retime_to_integer_slices_option(file_line_split, animation):393    animation.proto.retime_to_integer_slices = True394    return animation395def description_option(file_line_split, animation):396    description = " ".join(file_line_split[1:])397    description = description.replace('"', '')  # remove any quotation marks398    animation.description = description...frame_helpers.py
Source:frame_helpers.py  
...136    if se3_a_tform_b is None:137        # Failed to find the transformation between frames a and b in the frame tree snapshot.138        return None139    return se3_a_tform_b.get_closest_se2_transform()140def express_se2_velocity_in_new_frame(frame_tree_snapshot, frame_b, frame_c, vel_of_a_in_b,141                                      validate=True):142    """Convert the SE2 Velocity in frame b to a SE2 Velocity in frame c using143       the frame tree snapshot.144    Args:145        frame_tree_snapshot (dict) dictionary representing the child_to_parent_edge_map146        frame_b (string)147        frame_c (string)148        vel_of_a_in_b (SE2Velocity proto) SE2 Velocity in frame_b149        validate (bool) if the FrameTreeSnapshot should be checked for a valid tree structure150    Returns:151        math_helpers.SE2Velocity velocity_of_a_in_c in frame_c if the frames exist in the tree. None otherwise.152    """153    # Find the SE(3) pose in the frame tree snapshot that represents c_tform_b.154    se3_c_tform_b = get_a_tform_b(frame_tree_snapshot, frame_c, frame_b, validate)155    if se3_c_tform_b is None:156        # If the SE3Pose for c_tform_b does not exist in the frame tree snapshot,157        # then we cannot transform the velocity.158        return None159    # Check that the frame name of frame_c is considered to be a gravity aligned frame.160    if not is_gravity_aligned_frame_name(frame_c):161        # Frame C is not gravity aligned, and therefore c_tform_b cannot be converted into162        # an SE(2) pose because it will lose height information.163        return None164    # Find the closest SE(2) pose for the c_tform_b SE(3) pose found from the snapshot.165    se2_c_tform_b = se3_c_tform_b.get_closest_se2_transform()166    # Transform the velocity into the new frame to get vel_of_a_in_c.167    c_adjoint_b = se2_c_tform_b.to_adjoint_matrix()168    vel_of_a_in_c = math_helpers.transform_se2velocity(c_adjoint_b, vel_of_a_in_b)169    return vel_of_a_in_c170def express_se3_velocity_in_new_frame(frame_tree_snapshot, frame_b, frame_c, vel_of_a_in_b,171                                      validate=True):172    """Convert the SE(3) Velocity in frame b to an SE(3) Velocity in frame c using173       the frame tree snapshot.174    Args:175        frame_tree_snapshot (dict) dictionary representing the child_to_parent_edge_map176        frame_b (string)177        frame_c (string)178        vel_of_a_in_b (SE3Velocity proto) SE(3) Velocity in frame_b179        validate (bool) if the FrameTreeSnapshot should be checked for a valid tree structure180    Returns:181        math_helpers.SE3Velocity velocity_of_a_in_c in frame_c if the frames exist in the tree. None otherwise.182    """183    # Find the SE(3) pose in the frame tree snapshot that represents c_tform_b.184    se3_c_tform_b = get_a_tform_b(frame_tree_snapshot, frame_c, frame_b, validate)...LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.
Get 100 minutes of automation test minutes FREE!!
