query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Create an IK attribute on the given ctrl, connect IK handles to ik switch. Also connect fk ctrls and ik ctrls visibility to switch. This will create an 'IK' attr on the switch ctrl
def create_fk_ik_switch(switch_ctrl, ik_handles, fk_ctrls, ik_ctrls, vis_ctrl=None, switch_attr_name='IK', vis_attr_name='fkIkCtrlVis'): fk_ctrls = mc.ls(fk_ctrls) ik_ctrls = mc.ls(ik_ctrls) ik_handles = mc.ls(ik_handles) if not vis_ctrl: vis_ctrl = switch_ctrl # Create attributes if not mc.objExists(switch_ctrl+'.'+switch_attr_name): mc.addAttr(switch_ctrl, ln=switch_attr_name, min=0, max=1, k=1) if not mc.objExists(vis_ctrl+'.'+vis_attr_name): mc.addAttr(vis_ctrl, ln=vis_attr_name, at='enum', en='auto:fkOnly:ikOnly:both', k=1) # Connect ik handles for handle in ik_handles: mc.connectAttr(switch_ctrl+'.'+switch_attr_name, handle+'.ikBlend') # Create swicth for ik ctrl ik_choice = utils.create_node('choice', n=vis_attr_name+'_ik_choice') mc.connectAttr(vis_ctrl+'.'+vis_attr_name, ik_choice+'.selector') mc.connectAttr(switch_ctrl+'.'+switch_attr_name, ik_choice+'.input[0]') mc.setAttr(ik_choice+'.input[1]', 0) mc.setAttr(ik_choice+'.input[2]', 1) mc.setAttr(ik_choice+'.input[3]', 1) for ctrl in ik_ctrls: mc.setAttr(ctrl+'.v', l=0) mc.connectAttr(ik_choice+'.output', ctrl+'.v', f=1) mc.setAttr(ctrl+'.v', l=1) # Create swicth for ik ctrl fk_choice = utils.create_node('choice', n=vis_attr_name+'_fk_choice') fk_rv = utils.create_node('reverse', n=vis_attr_name+'_fk_choice') mc.connectAttr(switch_ctrl+'.'+switch_attr_name, fk_rv+'.inputX') mc.connectAttr(vis_ctrl+'.'+vis_attr_name, fk_choice+'.selector') mc.connectAttr(fk_rv+'.outputX', fk_choice+'.input[0]') mc.setAttr(fk_choice+'.input[1]', 1) mc.setAttr(fk_choice+'.input[2]', 0) mc.setAttr(fk_choice+'.input[3]', 1) for ctrl in fk_ctrls: mc.setAttr(ctrl+'.v', l=0) mc.connectAttr(fk_choice+'.output', ctrl+'.v', f=1) mc.setAttr(ctrl+'.v', l=1) return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_soft_ik(ik_ctrl, ik_joints, ik_handle):\n\n # get name and constant variables\n name = ik_handle+'Soft'\n parent = utils.get_parent(ik_joints[0])\n ik_handle_parent = utils.get_parent(ik_handle)\n\n # get total length of joint chain\n chain_length = 0\n for jnt in ik_joints[1:]:\n ...
[ "0.6865341", "0.670034", "0.6326762", "0.61733705", "0.6086193", "0.59026164", "0.57446015", "0.55481964", "0.540773", "0.5367092", "0.53659767", "0.51581305", "0.5066359", "0.493914", "0.48905978", "0.48687443", "0.48397043", "0.48023486", "0.47860128", "0.47808054", "0.4765...
0.7807563
0
Create soft ik constraint on ikHandle.
def create_soft_ik(ik_ctrl, ik_joints, ik_handle): # get name and constant variables name = ik_handle+'Soft' parent = utils.get_parent(ik_joints[0]) ik_handle_parent = utils.get_parent(ik_handle) # get total length of joint chain chain_length = 0 for jnt in ik_joints[1:]: chain_length += abs(mc.getAttr(jnt+'.tx')) mc.addAttr(ik_joints[0], ln='softIkChainLength', k=1, dv=chain_length) #create dist node, (distance between top ik_joint and ik_handle) = X soft_ik_root = utils.snap_locator(ik_joints[0], node_type='transform') soft_ik_root = mc.rename(soft_ik_root, name+'_root_'+utils.get_suffix('transform')) dist = utils.create_distance_reader(soft_ik_root, ik_handle_parent) #create the dSoft and softIK attributes on the controller mc.addAttr(ik_ctrl, ln='softIK', min=0, k=1) ctrl_clamp = mc.createNode('clamp') mc.connectAttr(ik_ctrl+'.softIK', ctrl_clamp+'.inputR') mc.setAttr(ctrl_clamp+'.minR', 0.0001) mc.setAttr(ctrl_clamp+'.maxR', 10000000) #create node network for soft IK da_pma = mc.createNode('plusMinusAverage', n=name+'_da_pma') x_minus_da_pma = mc.createNode('plusMinusAverage', n=name+'_x_minus_da_pma') negate_x_minus_md = mc.createNode('multiplyDivide', n=name+'_negate_x_minus_md') divBy_dSoft_md = mc.createNode('multiplyDivide', n=name+'_divBy_dSoft_md') pow_e_md = mc.createNode('multiplyDivide', n=name+'_pow_e_md') one_minus_pow_e_pma = mc.createNode('plusMinusAverage', n=name+'_one_minus_pow_e_pma') times_dSoft_md = mc.createNode('multiplyDivide', n=name+'_times_dSoft_md') plus_da_pma = mc.createNode('plusMinusAverage', n=name+'_plus_da_pma') da_cond = mc.createNode('condition', n=name+'_da_cond') dist_diff_pma = mc.createNode('plusMinusAverage', n=name+'_dist_diff_pma') defaultPos_pma = mc.createNode('plusMinusAverage', n=name+'_defaultPos_pma') #set operations mc.setAttr(da_pma+'.operation', 2) mc.setAttr(x_minus_da_pma+'.operation', 2) mc.setAttr(negate_x_minus_md+'.operation', 1) mc.setAttr(divBy_dSoft_md+'.operation', 2) mc.setAttr(pow_e_md+'.operation', 3) mc.setAttr(one_minus_pow_e_pma+'.operation', 2) mc.setAttr(times_dSoft_md+'.operation', 1) mc.setAttr(plus_da_pma+'.operation', 1) mc.setAttr(da_cond+'.operation', 5) mc.setAttr(dist_diff_pma+'.operation', 2) mc.setAttr(defaultPos_pma+'.operation', 2) #make connections mc.connectAttr(ik_joints[0]+'.softIkChainLength', da_pma+'.input1D[0]') mc.connectAttr(ctrl_clamp+'.outputR', da_pma+'.input1D[1]') mc.connectAttr(dist+'.localDistance', x_minus_da_pma+'.input1D[0]') mc.connectAttr(da_pma+'.output1D', x_minus_da_pma+'.input1D[1]') mc.connectAttr(x_minus_da_pma+'.output1D', negate_x_minus_md+'.input1X') mc.setAttr(negate_x_minus_md+'.input2X', -1) mc.connectAttr(negate_x_minus_md+'.outputX', divBy_dSoft_md+'.input1X') mc.connectAttr(ctrl_clamp+'.outputR', divBy_dSoft_md+'.input2X') mc.setAttr(pow_e_md+'.input1X', 2.718281828) mc.connectAttr(divBy_dSoft_md+'.outputX', pow_e_md+'.input2X') mc.setAttr(one_minus_pow_e_pma+'.input1D[0]', 1) mc.connectAttr(pow_e_md+'.outputX' , one_minus_pow_e_pma+'.input1D[1]') mc.connectAttr(one_minus_pow_e_pma+'.output1D', times_dSoft_md+'.input1X') mc.connectAttr(ctrl_clamp+'.outputR', times_dSoft_md+'.input2X') mc.connectAttr(times_dSoft_md+'.outputX', plus_da_pma+'.input1D[0]') mc.connectAttr(da_pma+'.output1D', plus_da_pma+'.input1D[1]') mc.connectAttr(da_pma+'.output1D', da_cond+'.firstTerm') mc.connectAttr(dist+'.localDistance', da_cond+'.secondTerm') mc.connectAttr(dist+'.localDistance', da_cond+'.colorIfFalseR') mc.connectAttr(plus_da_pma+'.output1D', da_cond+'.colorIfTrueR') mc.connectAttr(da_cond+'.outColorR', dist_diff_pma+'.input1D[0]') mc.connectAttr(dist+'.localDistance', dist_diff_pma+'.input1D[1]') mc.setAttr(defaultPos_pma+'.input1D[0]', 0) mc.connectAttr(dist_diff_pma+'.output1D', defaultPos_pma+'.input1D[1]') # Create new ik aim node up = [1,0,0] aim = [0,1,0] grp = mc.createNode('transform', n=name+'_soft_aim_'+utils.get_suffix('transform'), p=ik_handle_parent) gAim = mc.createNode('transform', n=name+'_soft_'+utils.get_suffix('transform'), p=grp) mc.aimConstraint(soft_ik_root, grp, aim=aim, u=up, wu=up, wut='objectRotation', wuo=ik_ctrl, n=grp+'_ac') mc.connectAttr(defaultPos_pma+'.output1D', gAim+'.ty') mc.pointConstraint(gAim, ik_handle) mc.parent(ik_handle, gAim) # parent stuff if parent: mc.parent(soft_ik_root, parent) return gAim
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_keep_in_constraint(self,der=2,limit=1e1,weight=1e5):\n print(\"Creating Keep in constraint\")\n constr = dict()\n constr['constraint_type'] = \"ellipsoid\"\n constr['weight'] = self.accel_weight\n constr['keep_out'] = False\n constr['der'] = der\n constr[...
[ "0.5469389", "0.531737", "0.52888745", "0.51781154", "0.50092465", "0.49953595", "0.49701515", "0.4952075", "0.49448365", "0.49093467", "0.49027547", "0.4884955", "0.4834274", "0.47601178", "0.47214177", "0.46724012", "0.4648716", "0.46426857", "0.4633451", "0.46300042", "0.4...
0.7518777
0
Quaterion / matrix based twist for upper arms and legs.
def upper_twist(shoulder_jnt, up_arm_ik_jnt, lo_arm_ik_jnt, up_arm_jnt, lo_arm_jnt, up_arm_twist_jnts): # Create a group that does not rotate and parent under the ik arm parent (shoulder) stable_reader_grp = utils.create_node('transform', n=up_arm_ik_jnt+'_stable_reader', p=up_arm_ik_jnt) # Create a grp that will rotate with ik arm twist_reader_grp = utils.create_node('transform', n=up_arm_ik_jnt+'_twist_reader', p=up_arm_ik_jnt) twist_driver_grp = utils.create_node('transform', n=up_arm_ik_jnt+'_twist', p=twist_reader_grp) mc.parent(stable_reader_grp, shoulder_jnt) mc.addAttr(twist_reader_grp, ln='twist', k=1) # Now set up mult matrix and decomp nodes to extract the twist between the two nodes mult_mtx = mc.createNode('multMatrix') decomp_mtx = mc.createNode('decomposeMatrix') quat_to_euler = mc.createNode('quatToEuler') mc.connectAttr(stable_reader_grp+'.worldInverseMatrix', mult_mtx+'.matrixIn[1]') mc.connectAttr(twist_reader_grp+'.worldMatrix', mult_mtx+'.matrixIn[0]') mc.connectAttr(mult_mtx+'.matrixSum', decomp_mtx+'.inputMatrix') mc.connectAttr(decomp_mtx+'.outputQuatX', quat_to_euler+'.inputQuatX') mc.connectAttr(decomp_mtx+'.outputQuatW', quat_to_euler+'.inputQuatW') utils.connect_negative(quat_to_euler+'.outputRotateX', twist_reader_grp+'.twist') mc.connectAttr(twist_reader_grp+'.twist', twist_driver_grp+'.rx') # Connect joints mc.parentConstraint(twist_driver_grp, up_arm_jnt, mo=1) mc.parentConstraint(lo_arm_ik_jnt, lo_arm_jnt, mo=1) div = 1.0 / (len(up_arm_twist_jnts)) mdl = mc.createNode('multDoubleLinear') mc.setAttr(mdl+'.input1', div) mc.connectAttr(quat_to_euler+'.outputRotateX', mdl+'.input2') for i, joint in enumerate(up_arm_twist_jnts[:-1]): mc.connectAttr(mdl+'.output', joint+'.rx') mc.orientConstraint(up_arm_ik_jnt, up_arm_twist_jnts[-1], mo=1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lower_twist(lo_arm_ik_jnt, wrist_ik_jnt, lo_arm_jnt, lo_arm_twist_jnts, wrist_jnt=None):\n\n # Create a group that does not rotate and parent under the ik arm parent (shoulder)\n stable_reader_grp = utils.create_node('transform', n=lo_arm_ik_jnt+'_stable_reader', p=lo_arm_ik_jnt)\n\n # Create a grp th...
[ "0.5514963", "0.52410305", "0.5185732", "0.51259094", "0.5053267", "0.5020422", "0.49390778", "0.4879556", "0.48793352", "0.4878152", "0.4855", "0.4854443", "0.48542276", "0.48520848", "0.48423955", "0.4821107", "0.4791083", "0.47887972", "0.47870728", "0.47847036", "0.478411...
0.56926125
0
Quaterion / matrix based stretch for forearms and lower legs
def lower_twist(lo_arm_ik_jnt, wrist_ik_jnt, lo_arm_jnt, lo_arm_twist_jnts, wrist_jnt=None): # Create a group that does not rotate and parent under the ik arm parent (shoulder) stable_reader_grp = utils.create_node('transform', n=lo_arm_ik_jnt+'_stable_reader', p=lo_arm_ik_jnt) # Create a grp that will rotate with ik arm twist_reader_grp = utils.create_node('transform', n=lo_arm_ik_jnt+'_twist_reader', p=lo_arm_ik_jnt) mc.addAttr(twist_reader_grp, ln='twist', k=1) mc.delete(mc.pointConstraint(wrist_ik_jnt, twist_reader_grp)) mc.parent(twist_reader_grp, wrist_ik_jnt) # Now set up mult matrix and decomp nodes to extract the twist between the two nodes mult_mtx = mc.createNode('multMatrix') decomp_mtx = mc.createNode('decomposeMatrix') quat_to_euler = mc.createNode('quatToEuler') mc.connectAttr(stable_reader_grp+'.worldInverseMatrix', mult_mtx+'.matrixIn[1]') mc.connectAttr(twist_reader_grp+'.worldMatrix', mult_mtx+'.matrixIn[0]') mc.connectAttr(mult_mtx+'.matrixSum', decomp_mtx+'.inputMatrix') mc.connectAttr(decomp_mtx+'.outputQuatX', quat_to_euler+'.inputQuatX') mc.connectAttr(decomp_mtx+'.outputQuatW', quat_to_euler+'.inputQuatW') utils.connect_negative(quat_to_euler+'.outputRotateX', twist_reader_grp+'.twist') # Connect joints mc.parentConstraint(lo_arm_ik_jnt, lo_arm_jnt, mo=1) if wrist_jnt: mc.parentConstraint(wrist_ik_jnt, wrist_jnt, mo=1) div = 1.0 / (len(lo_arm_twist_jnts)) mdl = mc.createNode('multDoubleLinear') mc.setAttr(mdl+'.input1', div) mc.connectAttr(quat_to_euler+'.outputRotateX', mdl+'.input2') for i, joint in enumerate(lo_arm_twist_jnts): mc.connectAttr(mdl+'.output', joint+'.rx')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ar_addStretchSquash():\n setupName = 'Nose'\n sel = cmds.ls(sl=True)\n chain = cmds.ls(sel[0], dag=True, typ='joint')\n IKSpine = cmds.ikHandle(sj=chain[0], ee=chain[len(chain) - 1], sol='ikSplineSolver')\n # rename\n cmds.rename(IKSpine[0], 'IKSplineHandle_' + setupName)\n cmds.rename(IKS...
[ "0.5521156", "0.52241683", "0.52145356", "0.51717967", "0.5153184", "0.5151809", "0.5132688", "0.5117285", "0.5094757", "0.50800526", "0.5053586", "0.5023979", "0.5008975", "0.50081855", "0.50077236", "0.5004814", "0.49971503", "0.49883208", "0.49845037", "0.49832925", "0.497...
0.0
-1
Stretch setup for biped (2 joint chain) arms and legs
def biped_stretch(ik_ctrl, ik_last_node, pv_ctrl, switch_ctrl, up_arm_fk_ctrl, lo_arm_fk_ctrl, wrist_fk_ctrl, up_arm_ik_jnt, lo_arm_ik_jnt, wrist_ik_jnt, ik_handle, pin_attr_name='pinElbow', shift_attr_name='shiftElbow'): # add all my attrs on ctrls mc.addAttr(ik_ctrl, ln=pin_attr_name, at='double', min=0, max=1, k=1) mc.addAttr(ik_ctrl, ln=shift_attr_name, at='double', min=-1, max=1, k=1) mc.addAttr(ik_ctrl, ln='autoStretch', at='double', min=0, max=1, k=1) mc.addAttr(ik_ctrl, ln='upStretch', at='double', dv=1, min=0.001, k=1) mc.addAttr(ik_ctrl, ln='loStretch', at='double', dv=1, min=0.001, k=1) mc.addAttr(up_arm_fk_ctrl, ln='stretch', at='double', dv=1, min=0.001, k=1) mc.addAttr(lo_arm_fk_ctrl, ln='stretch', at='double', dv=1, min=0.001, k=1) # store initial length of joint lo_init_length = mc.getAttr(lo_arm_ik_jnt+'.tx') wrist_init_length = mc.getAttr(wrist_ik_jnt+'.tx') max_init_length = mc.getAttr(lo_arm_ik_jnt+'.tx')+mc.getAttr(wrist_ik_jnt+'.tx') lo_abs_init_length = abs(mc.getAttr(lo_arm_ik_jnt+'.tx')) wrist_abs_length = abs(mc.getAttr(wrist_ik_jnt+'.tx')) # Get parents for ik handle and root of the parm arm_root_grp = utils.get_parent(up_arm_ik_jnt) # Create distance nodes between base, end, and pv ctrl to get the length of side of the triangle root_to_end_dist = utils.create_distance_reader(arm_root_grp, ik_last_node) root_to_pv_dist = utils.create_distance_reader(arm_root_grp, pv_ctrl) pv_to_end_dist = utils.create_distance_reader(pv_ctrl, ik_last_node) # easy stuff first - create fk stretch nodes lo_arm_fk_mdl = mc.createNode('multDoubleLinear') wrist_fk_mdl = mc.createNode('multDoubleLinear') mc.setAttr(lo_arm_fk_mdl+'.input1', mc.getAttr(lo_arm_ik_jnt+'.tx')) mc.setAttr(wrist_fk_mdl+'.input1', mc.getAttr(wrist_ik_jnt+'.tx')) mc.connectAttr(up_arm_fk_ctrl+'.stretch', lo_arm_fk_mdl+'.input2') mc.connectAttr(lo_arm_fk_ctrl+'.stretch', wrist_fk_mdl+'.input2') utils.connect_abs(lo_arm_fk_mdl+'.output', lo_arm_fk_ctrl+'_ZERO.tx') if wrist_fk_ctrl and mc.objExists(wrist_fk_ctrl): utils.connect_abs(wrist_fk_mdl+'.output', wrist_fk_ctrl+'_ZERO.tx') # These arethe final fk stretch outputs to connect to joints fk_stretch_final_output = [lo_arm_fk_mdl+'.output', wrist_fk_mdl+'.output'] # NOW creates node s for thew elbow pin lo_arm_pin_mdl = mc.createNode('multDoubleLinear') wrist_pin_mdl = mc.createNode('multDoubleLinear') mc.setAttr(lo_arm_pin_mdl+'.input1', 1) mc.setAttr(wrist_pin_mdl+'.input1', 1) if lo_init_length < 0.0: mc.setAttr(lo_arm_pin_mdl+'.input1', -1) if wrist_init_length < 0.0: mc.setAttr(wrist_pin_mdl+'.input1', -1) mc.connectAttr(root_to_pv_dist+'.localDistance', lo_arm_pin_mdl+'.input2') mc.connectAttr(pv_to_end_dist+'.localDistance', wrist_pin_mdl+'.input2') # These arethe final elbow pin stretch outputs to connect to joints pin_final_output = [lo_arm_pin_mdl+'.output', wrist_pin_mdl+'.output'] # create shift nodes mc.addAttr(lo_arm_ik_jnt, ln='shiftLength', k=1) mc.addAttr(wrist_ik_jnt, ln='shiftLength', k=1) tt = 'linear' mc.setDrivenKeyframe(lo_arm_ik_jnt+'.shiftLength', cd=ik_ctrl+'.'+shift_attr_name, dv=0, v=lo_init_length, itt=tt, ott=tt) mc.setDrivenKeyframe(lo_arm_ik_jnt+'.shiftLength', cd=ik_ctrl+'.'+shift_attr_name, dv=1, v=0, itt=tt, ott=tt) mc.setDrivenKeyframe(lo_arm_ik_jnt+'.shiftLength', cd=ik_ctrl+'.'+shift_attr_name, dv=-1, v=max_init_length, itt=tt, ott=tt) mc.setDrivenKeyframe(wrist_ik_jnt+'.shiftLength', cd=ik_ctrl+'.'+shift_attr_name, dv=0, v=wrist_init_length, itt=tt, ott=tt) mc.setDrivenKeyframe(wrist_ik_jnt+'.shiftLength', cd=ik_ctrl+'.'+shift_attr_name, dv=1, v=max_init_length, itt=tt, ott=tt) mc.setDrivenKeyframe(wrist_ik_jnt+'.shiftLength', cd=ik_ctrl+'.'+shift_attr_name, dv=-1, v=0, itt=tt, ott=tt) shift_final_output = [ lo_arm_ik_jnt+'.shiftLength', wrist_ik_jnt+'.shiftLength'] # Create ik indivisual stretch nodes lo_arm_ik_scale_mdl = mc.createNode('multDoubleLinear') wrist_ik_scale_mdl = mc.createNode('multDoubleLinear') mc.connectAttr(shift_final_output[0], lo_arm_ik_scale_mdl+'.input1') mc.connectAttr(shift_final_output[1], wrist_ik_scale_mdl+'.input1') mc.connectAttr(ik_ctrl+'.upStretch', lo_arm_ik_scale_mdl+'.input2') mc.connectAttr(ik_ctrl+'.loStretch', wrist_ik_scale_mdl+'.input2') # This is the final output for scale and shift ik_stretch_final_output = [lo_arm_ik_scale_mdl+'.output', wrist_ik_scale_mdl+'.output'] # Now create the IK auto stretch nodes lo_auto_stretch_mdl = mc.createNode('multDoubleLinear') wrist_auto_stretch_mdl = mc.createNode('multDoubleLinear') auto_stretch_clamp = mc.createNode('clamp') mc.setAttr(auto_stretch_clamp+'.minR', 1) mc.setAttr(auto_stretch_clamp+'.maxR', 10000000) mc.connectAttr(ik_stretch_final_output[0], lo_auto_stretch_mdl+'.input1', f=1) mc.connectAttr(ik_stretch_final_output[1], wrist_auto_stretch_mdl+'.input1', f=1) mc.connectAttr(root_to_end_dist+'.stretchFactor', auto_stretch_clamp+'.inputR') mc.connectAttr(auto_stretch_clamp+'.outputR', lo_auto_stretch_mdl+'.input2', f=1) mc.connectAttr(auto_stretch_clamp+'.outputR', wrist_auto_stretch_mdl+'.input2', f=1) adl = mc.createNode('addDoubleLinear') mc.connectAttr(lo_arm_ik_scale_mdl+'.output', adl+'.input1') mc.connectAttr(wrist_ik_scale_mdl+'.output', adl+'.input2') utils.connect_abs(adl+'.output', root_to_end_dist+'.jointChainLength') # handle soft ik handle constraint override pc = mc.pointConstraint(ik_last_node, ik_handle)[0] if mc.objExists(up_arm_ik_jnt+'.softIkChainLength'): # compensate feed in new chain length for soft ik chain length utils.connect_abs(adl+'.output', up_arm_ik_jnt+'.softIkChainLength') # blend off the soft ik constraint IF im in auto s tretch or pin mode mdl = mc.createNode('multDoubleLinear') utils.connect_reverse(ik_ctrl+'.'+pin_attr_name, mdl+'.input1') utils.connect_reverse(ik_ctrl+'.autoStretch', mdl+'.input2') mc.connectAttr(mdl+'.output', pc+'.w0') utils.connect_reverse(pc+'.w0', pc+'.w1') ik_auto_stretch_final_output = [lo_auto_stretch_mdl+'.output', wrist_auto_stretch_mdl+'.output'] # now create all my blends # first blend btween FK and an empty ik input # (this ikl input will take another blend node for blending oall the IK options ) fk_to_ik_blend = mc.createNode('blendColors') mc.connectAttr(switch_ctrl+'.IK', fk_to_ik_blend+'.blender') mc.connectAttr(fk_stretch_final_output[0], fk_to_ik_blend+'.color2R') mc.connectAttr(fk_stretch_final_output[1], fk_to_ik_blend+'.color2G') # now create a blender between pin elbow and the rest of the ik options auto_ik_blend = mc.createNode('blendColors') mc.connectAttr(ik_ctrl+'.autoStretch', auto_ik_blend+'.blender') mc.connectAttr(ik_auto_stretch_final_output[0], auto_ik_blend+'.color1R') mc.connectAttr(ik_auto_stretch_final_output[1], auto_ik_blend+'.color1G') # Now connect it toth fk blend mc.connectAttr(auto_ik_blend+'.outputR', fk_to_ik_blend+'.color1R') mc.connectAttr(auto_ik_blend+'.outputG', fk_to_ik_blend+'.color1G') # now create a blender between pin elbow and the rest of the ik options pin_ik_blend = mc.createNode('blendColors') mc.connectAttr(ik_ctrl+'.'+pin_attr_name, pin_ik_blend+'.blender') mc.connectAttr(pin_final_output[0], pin_ik_blend+'.color1R') mc.connectAttr(pin_final_output[1], pin_ik_blend+'.color1G') # Now connect it toth fk blend mc.connectAttr(pin_ik_blend+'.outputR', auto_ik_blend+'.color2R') mc.connectAttr(pin_ik_blend+'.outputG', auto_ik_blend+'.color2G') # now connect the shift and scale mc.connectAttr(ik_stretch_final_output[0], pin_ik_blend+'.color2R') mc.connectAttr(ik_stretch_final_output[1], pin_ik_blend+'.color2G') # now for the magic! Connect the blend networll to joints mc.connectAttr(fk_to_ik_blend+'.outputR', lo_arm_ik_jnt+'.tx') mc.connectAttr(fk_to_ik_blend+'.outputG', wrist_ik_jnt+'.tx')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multi_joint_stretch(ik_ctrl, ik_last_node, switch_ctrl, fk_ctrls, jnts, ik_handle):\n\n root_grp = utils.get_parent(jnts[0])\n stretch_jnts = jnts[1:]\n stretch_fk_ctrls = fk_ctrls[1:]\n\n # create attrs\n attrs = ['upStretch','loStretch']\n for i in reversed(range(len(stretch_jnts)-2)):\n ...
[ "0.6122613", "0.60881704", "0.5706191", "0.5586057", "0.554519", "0.55225635", "0.55225635", "0.54242057", "0.54017335", "0.5394755", "0.5353252", "0.52999943", "0.52834505", "0.52750146", "0.524787", "0.5220676", "0.5217967", "0.51952493", "0.51629597", "0.5109538", "0.51004...
0.66334
0
Create IK FK Streatch for limbs with more than two bines
def multi_joint_stretch(ik_ctrl, ik_last_node, switch_ctrl, fk_ctrls, jnts, ik_handle): root_grp = utils.get_parent(jnts[0]) stretch_jnts = jnts[1:] stretch_fk_ctrls = fk_ctrls[1:] # create attrs attrs = ['upStretch','loStretch'] for i in reversed(range(len(stretch_jnts)-2)): ltr = '' if i > 0: ltr = utils.letters[i] attrs.insert(1, 'midStretch'+ltr) if not mc.objExists(ik_ctrl+'.autoStretch'): mc.addAttr(ik_ctrl, ln='autoStretch', at='double', min=0, max=1, k=1) for i in range(len(stretch_jnts)): if not mc.objExists(ik_ctrl+'.'+attrs[i]): mc.addAttr(ik_ctrl, ln=attrs[i], at='double', dv=1, min=0.001, k=1) for fk_ctrl in fk_ctrls[:-1]: if not mc.objExists(fk_ctrl+'.stretch'): mc.addAttr(fk_ctrl, ln='stretch', at='double', dv=1, min=0.001, k=1) # store initial length of joint init_lengths = [mc.getAttr(j+'.tx') for j in stretch_jnts] abs_init_lengths = [abs(v) for v in init_lengths] total_init_length = 0 for v in init_lengths: total_init_length += v abs_total_init_length = abs(total_init_length) # Create dist reader root_to_end_dist = utils.create_distance_reader(root_grp, ik_last_node) auto_stretch_clamp = mc.createNode('clamp') mc.setAttr(auto_stretch_clamp+'.minR', 1) mc.setAttr(auto_stretch_clamp+'.maxR', 10000000) mc.connectAttr(root_to_end_dist+'.stretchFactor', auto_stretch_clamp+'.inputR') mc.addAttr(ik_ctrl, ln='stretchFactor', k=0) mc.connectAttr(auto_stretch_clamp+'.inputR', ik_ctrl+'.stretchFactor') pma = mc.createNode('plusMinusAverage') utils.connect_abs(pma+'.output1D', root_to_end_dist+'.jointChainLength') # handle soft ik handle constraint override pc = mc.pointConstraint(ik_last_node, ik_handle)[0] if mc.objExists(jnts[0]+'.softIkChainLength'): # compensate chain length - feed in new chain length for soft ik chain length utils.connect_abs(pma+'.output1D', jnts[0]+'.softIkChainLength') # blend off the soft ik constraint IF im in auto stretch mc.connectAttr(ik_ctrl+'.autoStretch', pc+'.w1') utils.connect_reverse(pc+'.w1', pc+'.w0') # easy stuff first - create fk stretch nodes fk_to_ik_blends = [] # This is the final output for IK stretch for i, jnt in enumerate(stretch_jnts): # easy stuff first - create fk stretch nodes fk_mdl = mc.createNode('multDoubleLinear') mc.setAttr(fk_mdl+'.input1', mc.getAttr(jnt+'.tx')) mc.connectAttr(fk_ctrls[i]+'.stretch', fk_mdl+'.input2') utils.connect_abs(fk_mdl+'.output', fk_ctrls[i+1]+'_ZERO.tx') # Create user secifed IK stretch user_ik_scale_mdl = mc.createNode('multDoubleLinear') mc.setAttr( user_ik_scale_mdl+'.input1', init_lengths[i]) mc.connectAttr(ik_ctrl+'.'+attrs[i], user_ik_scale_mdl+'.input2') # Now create the IK auto stretch nodes auto_stretch_mdl = mc.createNode('multDoubleLinear') mc.connectAttr(user_ik_scale_mdl+'.output', auto_stretch_mdl+'.input1', f=1) mc.connectAttr(auto_stretch_clamp+'.outputR', auto_stretch_mdl+'.input2', f=1) mc.connectAttr(user_ik_scale_mdl+'.output', '{0}.input1D[{1}]'.format(pma, i)) fk_to_ik_blend = mc.createNode('blendTwoAttr') auto_stretch_blend = mc.createNode('blendTwoAttr') mc.connectAttr(switch_ctrl+'.IK', fk_to_ik_blend+'.attributesBlender') mc.connectAttr(fk_mdl+'.output', fk_to_ik_blend+'.input[0]') mc.connectAttr(auto_stretch_blend+'.output', fk_to_ik_blend+'.input[1]') mc.connectAttr(ik_ctrl+'.autoStretch', auto_stretch_blend+'.attributesBlender') mc.connectAttr(user_ik_scale_mdl+'.output', auto_stretch_blend+'.input[0]') mc.connectAttr(auto_stretch_mdl+'.output', auto_stretch_blend+'.input[1]') fk_to_ik_blends.append(fk_to_ik_blend+'.output') for i, jnt in enumerate(stretch_jnts): mc.connectAttr(fk_to_ik_blends[i], jnt+'.tx')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def boundary(self):\n answer = self.zero()\n for k, v in self.items():\n for idx, cube in enumerate(k):\n acc_dim = sum((cube_l.dimension for cube_l in k[:idx]))\n for i in range(cube.dimension):\n for epsilon in (0, 1):\n ...
[ "0.5314263", "0.5311153", "0.5255831", "0.5082965", "0.50570154", "0.4981262", "0.49758726", "0.4932032", "0.49083376", "0.49006724", "0.48869604", "0.4875669", "0.4868179", "0.48634484", "0.48508698", "0.48497802", "0.48386258", "0.4834771", "0.48233885", "0.48123473", "0.48...
0.0
-1
Create stratch point constraints on a chain of stretch joints.
def stretch_twist_jnts(start_jnt, end_jnt, twist_jnts): div = 1.0 / (len(twist_jnts)+1) for i, joint in enumerate(twist_jnts): weight = div*(i+1) mc.pointConstraint(start_jnt, joint, weight=1.0-weight) mc.pointConstraint(end_jnt, joint, weight=weight)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def multi_joint_stretch(ik_ctrl, ik_last_node, switch_ctrl, fk_ctrls, jnts, ik_handle):\n\n root_grp = utils.get_parent(jnts[0])\n stretch_jnts = jnts[1:]\n stretch_fk_ctrls = fk_ctrls[1:]\n\n # create attrs\n attrs = ['upStretch','loStretch']\n for i in reversed(range(len(stretch_jnts)-2)):\n ...
[ "0.60946095", "0.5763195", "0.5703657", "0.5553354", "0.5487165", "0.5435914", "0.53954494", "0.51878697", "0.51259", "0.51116204", "0.5077191", "0.5054225", "0.4999024", "0.49555075", "0.49334964", "0.4926704", "0.4873679", "0.48712805", "0.48634586", "0.48509604", "0.484819...
0.66719025
0
Duplicate a joint chain.
def duplicate_chain(chain, search='', replace='', suffix=''): if suffix: suffix = '_'+suffix new_jnts = [] for joint in chain: new_name = joint.replace(search, replace, 1)+suffix new_jnt = mc.duplicate(joint, po=1, n=new_name)[0] if new_jnts: mc.parent(new_jnt, new_jnts[-1]) new_jnts.append(new_jnt) return new_jnts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def skeleton_buildDuplicateChain(self,sourceJoints = None, modifier = 'rig', connectToModule = False, connectAs = 'rigJoints', connectToSource = None, singleMode = False, cgmType = None, indices = [],blockNames=False):\n _str_func = 'skeleton_buildDuplicateChain'\n \n \n if indices:\n log.debug...
[ "0.63030636", "0.6269034", "0.60625374", "0.58090156", "0.5777003", "0.57204974", "0.56585926", "0.55766195", "0.5560866", "0.55120313", "0.5510162", "0.54400694", "0.5433781", "0.54283494", "0.5389344", "0.5383912", "0.53801215", "0.53679395", "0.5365678", "0.5365056", "0.53...
0.6813391
0
Extract the images into a 4D uint8 numpy array [index, y, x, depth].
def extract_images(filename,lx): print('Extracting', filename,'aaaaaa') data=numpy.loadtxt(filename,dtype='int64') dim=data.shape[0] data=data.reshape(dim, lx, lx, 1) # Convert shape from [num examples, rows, columns, depth] # to [num examples, rows*columns] (assuming depth == 1) data = data.reshape(data.shape[0], data.shape[1] * data.shape[2]) # Convert from [0, 255] -> [0.0, 1.0]. data = data.astype(numpy.float64) # images = numpy.multiply(images, 1.0 / 255.0) # commented since it is ising variables data = numpy.multiply(data, 1.0 ) # multiply by one, instead print(data.shape) return data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _images(path):\r\n with gzip.open(path) as f:\r\n # First 16 bytes are magic_number, n_imgs, n_rows, n_cols\r\n pixels = np.frombuffer(f.read(), 'B', offset=16)\r\n return pixels.reshape(-1, 784).astype('float32') / 255", "def extract_data(filename, num_images):\n print('...
[ "0.6674317", "0.6536259", "0.651069", "0.63781893", "0.63752973", "0.63359886", "0.6284267", "0.6278434", "0.6248823", "0.623316", "0.6226097", "0.62114894", "0.6170373", "0.61536634", "0.61412567", "0.61320215", "0.61277705", "0.6126708", "0.6115631", "0.61038214", "0.604964...
0.6521254
2
Convert class labels from scalars to onehot vectors.
def dense_to_one_hot(labels_dense, num_classes=10): num_labels = labels_dense.shape[0] index_offset = numpy.arange(num_labels) * num_classes labels_one_hot = numpy.zeros((num_labels, num_classes)) labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1 return labels_one_hot
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def one_hot(labels, classes=None):\n return K.utils.to_categorical(labels, classes)", "def one_hot(labels, classes=None):\n\n one_hot_ = K.utils.to_categorical(labels, classes)\n return(one_hot_)", "def to_onehot(labels: torch.Tensor, num_classes: int) -> torch.Tensor:\n if len(labels.size()) == 1:...
[ "0.8250402", "0.807683", "0.80523187", "0.7977843", "0.7908335", "0.7900327", "0.7892233", "0.7869711", "0.7849721", "0.7849721", "0.7826951", "0.7826122", "0.77677035", "0.7765413", "0.77540547", "0.77540547", "0.77540547", "0.77489346", "0.7742955", "0.7737176", "0.77226317...
0.76462805
33
Extract the labels into a 1D uint8 numpy array [index].
def extract_labels(nlabels,filename, one_hot=False): print('Extracting', filename,'bbbccicicicicib') labels=numpy.loadtxt(filename,dtype='int64') if one_hot: print("LABELS ONE HOT") print(labels.shape) XXX=dense_to_one_hot(labels,nlabels) print(XXX.shape) return dense_to_one_hot(labels,nlabels) print("LABELS") print(labels.shape) return labels
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def labels_array(self):\n return _build_label_vector_rows(\n [[(label, 1)] for label in self.labels], self.training_labels)[1:].T", "def array2(self):\r\n profbox(whoami())\r\n # research\r\n inputLabelID = self.__needleLabelSelector.currentNode().GetID()\r\n labelnode = slicer.mrml...
[ "0.70427394", "0.70352", "0.68724084", "0.6775525", "0.67488664", "0.67066264", "0.67066264", "0.66832286", "0.6675897", "0.65783316", "0.657126", "0.65644187", "0.65461975", "0.6527157", "0.65213823", "0.651859", "0.6512153", "0.65094626", "0.6494245", "0.6442707", "0.642644...
0.64324766
20
Copies the folder from the source directory into a docs folder eliminating commercial information.
def oh_folders(src, dest=dest): copytree(src, dest, ignore=ignore_patterns(*ignore_list), dirs_exist_ok=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy_docs():\n local('rsync -av --delete --exclude=.svn %s:%s/ /tmp/djangodocs/' %\n (env.hosts[0], env.deploy_base.child('docbuilds')))", "def copy_project_docs(srctree):\n docdir = os.path.join(srctree, 'Doc')\n\n # This block shouldn't be here, but I do not yet know how to\n # embed...
[ "0.71197486", "0.64806306", "0.61687136", "0.6106528", "0.6040729", "0.599639", "0.59881204", "0.59192413", "0.5918901", "0.5830127", "0.5795234", "0.57863706", "0.5776979", "0.57418394", "0.57132345", "0.5694525", "0.5685527", "0.5615512", "0.5591277", "0.5551153", "0.554456...
0.0
-1
Remove references to elements in the ignore list.
def edit_summary(): with open("docs/SUMMARY.md", "r") as opened_file: summary = opened_file.readlines() with open("docs/SUMMARY.md", "w") as opened_file: for line in summary: if not any(ext in line for ext in ignore_list): opened_file.write(line)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_ignore_list(book_list):\n my_ignore_list = ['a','able','about','across','after','all','almost','also',\n 'am','an','and','any','are','as','at','be','because',\n 'been','but','by','can','cannot','could','did','do','does',\n 'for','from','get','g...
[ "0.6355515", "0.63518995", "0.62366766", "0.6146372", "0.609999", "0.60373515", "0.59647715", "0.58614707", "0.58380705", "0.581101", "0.57721406", "0.5733889", "0.56982344", "0.5688912", "0.56855273", "0.5677034", "0.5676934", "0.5671325", "0.5661625", "0.56558764", "0.56454...
0.0
-1
This function loops through directory and updates dates of files in said directory.
def update_date(dest=dest): for root, _, files in os.walk(dest): ignore = ["README.md","SUMMARY.md"] _ = [edit_files(root + "/" + file) for file in files if (file not in ignore and file.endswith(".md"))]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _update_files():\n configuration_settings = get_configuration()\n\n # Need to find all of the files that are stored in the input_files directories in order to start building the\n # reports that will be used to generate the static log files.\n for input_path in configuration_settings.processing.inp...
[ "0.7497474", "0.65693516", "0.6360544", "0.6272613", "0.62687546", "0.6217366", "0.58838624", "0.58187634", "0.5807831", "0.57809776", "0.57797885", "0.57654995", "0.5759113", "0.57328516", "0.570991", "0.56900525", "0.56631005", "0.56558955", "0.5641615", "0.5629182", "0.562...
0.7363431
1
This function updates date of files passed into it.
def edit_files(i_file): a_file = open(i_file, "r") content = a_file.readlines() content[3] = f"years: {datetime.now().year}\n" content[4] = f'lastupdated: "{date.today()}"\n' a_file = open(i_file, "w") #open the same file and overrite line3 & 4 a_file.writelines(content) a_file.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_date(dest=dest):\n for root, _, files in os.walk(dest):\n ignore = [\"README.md\",\"SUMMARY.md\"]\n _ = [edit_files(root + \"/\" + file) for file in files if (file not in ignore and file.endswith(\".md\"))]", "def changeDate(names, date, ctlFunc = lambda s, d: True): \n\n # parse ...
[ "0.7073105", "0.6812823", "0.66919583", "0.6668282", "0.62575287", "0.6241051", "0.61830145", "0.6148155", "0.59413326", "0.5930518", "0.58680063", "0.5799601", "0.57853353", "0.5773595", "0.5749723", "0.57237613", "0.5706964", "0.57064885", "0.57048666", "0.56627303", "0.566...
0.6030693
8
Test combining each center's file errors
def test__combine_center_file_errors(syn): expected_error = ( f"\t{ENT1.name} ({ENT1.id}):\n\nmy errors\nn\n\n" f"\t{ENT1.name} ({ENT1.id}):\n\nerrors here\nf\n\n" ) calls = [ mock.call("syn1234", downloadFile=False), mock.call("syn2345", downloadFile=False), ] with patch.object(syn, "get", return_value=ENT1) as patch_synget: center_errors = write_invalid_reasons._combine_center_file_errors( syn, CENTER_ERRORSDF ) assert center_errors == expected_error patch_synget.assert_has_calls(calls)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_single_error_merge(self):\n test_folder = base_path +'/test_data/merging_tests/error_test/'\n output_file = os.path.join(test_folder, \"output1.jpg\")\n\n self.assertRaises(mi.ImageError, lambda: mi.add_background(test_folder+\"dummy.txt\", test_folder+\"background.jpg\", output_file)...
[ "0.6594361", "0.6371965", "0.6179928", "0.617114", "0.613714", "0.61048645", "0.6091394", "0.6054181", "0.5993377", "0.5975022", "0.5965196", "0.5943787", "0.59276956", "0.5922497", "0.59199405", "0.5838658", "0.58281934", "0.58267826", "0.581185", "0.58048946", "0.57999486",...
0.7143594
0
Test getting all center invalid errors
def test_get_center_invalid_errors(syn): with patch.object( syn, "tableQuery", return_value=QueryResponse ) as patch_query, patch.object( write_invalid_reasons, "_combine_center_file_errors", return_value="errors" ) as patch_combine: center_invalid = write_invalid_reasons.get_center_invalid_errors(syn, "syn3333") assert center_invalid == {"SAGE": "errors", "TEST": "errors"} patch_query.assert_called_once_with("SELECT * FROM syn3333") assert patch_combine.call_count == 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_errors(self) -> None:", "def storefront_check_errors():\n\n\tcurrentView = uidoc.ActiveView\n\tfamTypeDict = GetFamilyTypeDict(\"Fabrication-Error-Symbol\")\n\n\t# Clear existing error notations\n\terrorNotations = list(GetElementsInView(BuiltInCategory.OST_GenericAnnotation, Autodesk.Revit.DB.FamilyIn...
[ "0.68639857", "0.65659684", "0.6317057", "0.6280998", "0.624511", "0.62418723", "0.6231955", "0.6174314", "0.6160829", "0.6155387", "0.6125272", "0.61134624", "0.6105969", "0.60783327", "0.606288", "0.60506743", "0.604379", "0.6016345", "0.60074997", "0.6006396", "0.6003036",...
0.73111194
0
Returns the highest magnification for the slide
def highest_mag(slide): return int(slide.properties['aperio.AppMag'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mag(self):\n return self.photosamplers.get_estimate(mag=True)[0]", "def get_mag_for_size(slide, size):\n max_size = slide.dimensions\n max_mag = highest_mag(slide)\n downsample = np.average([max_dim/size_dim for max_dim, size_dim in zip(max_size, size)])\n return max_mag/downsample", "de...
[ "0.7143382", "0.6984062", "0.6947595", "0.6700194", "0.6502702", "0.6465279", "0.6439392", "0.6389368", "0.62770873", "0.62758964", "0.6203424", "0.6182897", "0.6060569", "0.6010728", "0.6000861", "0.59334785", "0.5931892", "0.59017086", "0.5889821", "0.58670044", "0.584315",...
0.8554771
0
Returns the magnification for each level in a slide
def level_mags(slide): return [highest_mag(slide)/downsample for downsample in slide.level_downsamples]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_level_mag(slide, level):\n return level_mags(slide)[level]", "def get_thumbnail_magnification(slide):\n ratio = np.asarray(slide.dimensions) / np.asarray(slide.associated_images[\"thumbnail\"].size)\n # np.sqrt(np.prod(ratio))\n return ratio", "def get_level_for_mag(slide, mag):\n level...
[ "0.7798809", "0.6923862", "0.66853", "0.65677786", "0.62147903", "0.6124908", "0.61031574", "0.6090716", "0.6088541", "0.58556306", "0.5820038", "0.56304854", "0.5626129", "0.56065404", "0.5559378", "0.54275894", "0.54266506", "0.5425498", "0.53985816", "0.53818405", "0.52535...
0.78430814
0
Returns the dimensions of a level
def get_level_size(slide, level): return slide.level_dimensions[level]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dimensions():", "def getDimensions():", "def _get_ndim(self):\n return len(self.level_shapes[0])", "def depth(self):\n return _libsbml.Dimensions_depth(self)", "def dimensions(self) -> int:\n return pulumi.get(self, \"dimensions\")", "def get_map_size(level):\n if level < 5:\n...
[ "0.7337827", "0.7250944", "0.7064121", "0.7035364", "0.6847221", "0.67899704", "0.67407316", "0.6720339", "0.66824", "0.66605484", "0.66371953", "0.6546749", "0.6472022", "0.6469843", "0.64618737", "0.6444262", "0.6423922", "0.6412058", "0.6396843", "0.6379703", "0.6365779", ...
0.8075793
0
Returns the magnification at a particular level
def get_level_mag(slide, level): return level_mags(slide)[level]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calculate_magnification(self, times):\n if self._model.n_lenses == 2:\n factor = 10.\n params = self._model.parameters\n t_1 = params.t_0 - factor * params.t_E\n t_2 = params.t_0 + factor * params.t_E\n self._model.set_magnification_methods([t_1, '...
[ "0.67559737", "0.6685309", "0.66784066", "0.65893006", "0.6497956", "0.62938315", "0.61198086", "0.6092812", "0.6024545", "0.5632027", "0.55412483", "0.5471536", "0.54661393", "0.5413815", "0.5413614", "0.53920174", "0.53455603", "0.5330778", "0.5330044", "0.5313709", "0.5275...
0.7867714
0
Get the level corresponding to a certain magnification, if available
def get_level_for_mag(slide, mag): level_mags_rounded = list(np.round(level_mags(slide), decimals = 2)) if mag in level_mags_rounded: return level_mags_rounded.index(mag) else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_level_mag(slide, level):\n return level_mags(slide)[level]", "def getLevel(unique_name):", "def level_mags(slide):\n return [highest_mag(slide)/downsample for downsample in slide.level_downsamples]", "def mag(self):\n return self.photosamplers.get_estimate(mag=True)[0]", "def get_lumin...
[ "0.76260245", "0.6262649", "0.62293607", "0.61587805", "0.60415137", "0.6033318", "0.58130866", "0.5732402", "0.57084596", "0.5647901", "0.5613819", "0.5604842", "0.5599045", "0.55820286", "0.5574072", "0.5559694", "0.55576396", "0.555535", "0.55302167", "0.5511368", "0.54941...
0.7825988
0
Get the magnification corresponding to an image size at the highest magnification
def get_mag_for_size(slide, size): max_size = slide.dimensions max_mag = highest_mag(slide) downsample = np.average([max_dim/size_dim for max_dim, size_dim in zip(max_size, size)]) return max_mag/downsample
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mag(self):\n return self.photosamplers.get_estimate(mag=True)[0]", "def highest_mag(slide):\n return int(slide.properties['aperio.AppMag'])", "def get_size_for_mag(slide, mag):\n max_size = slide.dimensions\n max_mag = highest_mag(slide)\n downsample = max_mag/mag\n return [np.int(np....
[ "0.7177108", "0.71568376", "0.6950366", "0.67886364", "0.6724605", "0.65802383", "0.62866354", "0.6198589", "0.60788", "0.60172695", "0.599912", "0.5912535", "0.5909752", "0.5874121", "0.5848604", "0.58275664", "0.5797984", "0.5797821", "0.57959604", "0.57886523", "0.5763161"...
0.7147567
2
Get the image size the highest magnification image would have to be resized to get an equivalent magnification
def get_size_for_mag(slide, mag): max_size = slide.dimensions max_mag = highest_mag(slide) downsample = max_mag/mag return [np.int(np.round(dim/downsample)) for dim in max_size]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getZoomFactor(imageSize, maxW, maxH):\n\timageW, imageH = imageSize\n\tzoomW = float(imageW) / float(maxW)\n\tzoomH = float(imageH) / float(maxH)\n\treturn max(zoomW, zoomH)", "def get_image_size(self):", "def get_thumbnail_magnification(slide):\n ratio = np.asarray(slide.dimensions) / np.asarray(slide....
[ "0.70223284", "0.69094974", "0.6904307", "0.6871893", "0.6834652", "0.67987007", "0.6753258", "0.6662533", "0.6641104", "0.6629991", "0.6623062", "0.66070765", "0.65710425", "0.6462559", "0.6438334", "0.64352167", "0.64264476", "0.6413869", "0.64073336", "0.6405353", "0.63959...
0.721434
0
Outputs at Pillow Image for a particular magnification
def read_slide_at_mag(slide, mag): exact_level = get_level_for_mag(slide, mag) if exact_level is not None: return slide.read_region((0,0), exact_level, get_level_size(slide, exact_level)) else: max_size = slide.dimensions region_size = tuple(get_size_for_mag(slide, mag)) downsample = np.average([max_dim/region_dim for max_dim, region_dim in zip(max_size, region_size)]) best_level = slide.get_best_level_for_downsample(downsample) best_level_size = get_level_size(slide, best_level) best_level_img = slide.read_region((0,0), best_level, best_level_size) return best_level_img.resize(region_size, resample = Image.BICUBIC)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def large_image(self):\n pass", "def mag(self):\n return self.photosamplers.get_estimate(mag=True)[0]", "def _calculate_magnification(self, times):\n if self._model.n_lenses == 2:\n factor = 10.\n params = self._model.parameters\n t_1 = params.t_0 - factor ...
[ "0.60173213", "0.5782513", "0.5777427", "0.5764191", "0.56933355", "0.56771076", "0.56483626", "0.5612517", "0.5609735", "0.56014514", "0.5599658", "0.55762804", "0.55341315", "0.55226684", "0.5477635", "0.5477049", "0.546813", "0.54632145", "0.54585576", "0.54283446", "0.538...
0.0
-1
Generates tiles from whole slide images
def tile_gen_at_mag(wsi, mag, tile_size): #Get size of WSI at Level 0 (Max Magnification) x0, y0 = wsi.level_dimensions[0] #Get size of WSI at the mag we want x_mag, y_mag = get_size_for_mag(wsi, mag) x_tiles = int(np.floor(x_mag/tile_size)) y_tiles = int(np.floor(y_mag/tile_size)) #Scale tile size accordingly scale = highest_mag(wsi)/mag yield (x_tiles, y_tiles) tiles = [] for y in range(y_tiles): for x in range(x_tiles): x_coord = round(x*scale*tile_size) y_coord = round(y*scale*tile_size) scaled_tile_size = round(scale*tile_size) tile = wsi.read_region((x_coord, y_coord), 0, (scaled_tile_size, scaled_tile_size)) yield tile.resize((tile_size, tile_size), resample = Image.BICUBIC)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tile_slides(slides_filepaths, desired_tile_with, desired_overlap, desired_magnification):\n containing_folders = []\n for slide_filepath in slides_filepaths:\n containing_folders.append(tile_slide(slide_filepath, desired_tile_with, desired_overlap, desired_magnification))\n return containing_fo...
[ "0.7096497", "0.7032253", "0.6989992", "0.69054127", "0.6749181", "0.66839963", "0.6649588", "0.65237033", "0.6499432", "0.64959127", "0.6372662", "0.6356276", "0.63422674", "0.63199794", "0.6305179", "0.6302457", "0.62703687", "0.62687695", "0.62687695", "0.62516", "0.617920...
0.0
-1
takes a command, telnet session, and a prompt and returns the output of the code
def respond(cmd,t,p): t.write(cmd) return wait(t,p)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_telnet_command(command):\n\n tn = telnetlib.Telnet(stb_parameters.STB_IP)\n tn.read_until(bytes(\"login: \", 'UTF-8'))\n tn.write(bytes(stb_parameters.STB_USER_NAME + \"\\n\", 'UTF-8'))\n tn.write(bytes(command + \"\\n\", 'UTF-8'))\n tn.write(bytes(\"exit\\n\", 'UTF-8'))\n result = tn.re...
[ "0.70798624", "0.7071471", "0.70600575", "0.6706458", "0.6631486", "0.64974564", "0.6339306", "0.62638974", "0.6244074", "0.6220981", "0.60587776", "0.6056408", "0.60353273", "0.5993267", "0.5937854", "0.5930016", "0.59039897", "0.5903268", "0.58991635", "0.5847472", "0.58356...
0.56606126
28
takes a telnet session, and a prompt
def wait(t,p): output_list = [] c = '' d = '' while p not in d: c = t.read_very_eager() if len(c) > 0: d += c print c output_list.append(c) if "Press any key to continue" in c or "--More--" in c: t.write(" ") output_list = ((''.join(output_list)).replace('\r\n','\n')).split('\n') return output_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def telnet_run(self, cmd_list, prompt_usr='Username:', prompt_pwd='Password:', prompt_ena='>',\n prompt_conf=']', timeout=2, LOGIN_LOG=0):\n prompt_usr = prompt_usr.encode(\"ascii\")\n prompt_pwd = prompt_pwd.encode(\"ascii\")\n prompt_ena = prompt_ena.encode(\"ascii\")\n ...
[ "0.7024742", "0.67167115", "0.6706943", "0.65913546", "0.65091944", "0.645665", "0.62801105", "0.6189571", "0.61475736", "0.61325663", "0.60985357", "0.6096203", "0.6044156", "0.60315806", "0.60073096", "0.5959323", "0.5922411", "0.5920338", "0.5898053", "0.58856004", "0.5876...
0.0
-1
Python function for importing the MNIST data set. It returns an iterator of 2tuples with the first element being the label and the second element being a numpy.uint8 2D array of pixel data for the given image.
def read(dataset = "training", path = "."): if dataset is "training": fname_img = os.path.join(path, 'train-images-idx3-ubyte') fname_lbl = os.path.join(path, 'train-labels-idx1-ubyte') elif dataset is "testing": fname_img = os.path.join(path, 't10k-images-idx3-ubyte') fname_lbl = os.path.join(path, 't10k-labels-idx1-ubyte') else: raise ValueError, "dataset must be 'testing' or 'training'" # Load everything in some numpy arrays with open(fname_lbl, 'rb') as flbl: magic, num = struct.unpack(">II", flbl.read(8)) lbl = np.fromfile(flbl, dtype=np.int8) with open(fname_img, 'rb') as fimg: magic, num, rows, cols = struct.unpack(">IIII", fimg.read(16)) img = np.fromfile(fimg, dtype=np.uint8).reshape(len(lbl), rows, cols) get_img = lambda idx: (lbl[idx], img[idx]) # Create an iterator which returns each image in turn for i in xrange(len(lbl)): yield get_img(i)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readmnist(dataset = \"training\", path = \".\"):\n\n if dataset is \"training\":\n fname_img = os.path.join(path, 'train-images.idx3-ubyte')\n fname_lbl = os.path.join(path, 'train-labels.idx1-ubyte')\n elif dataset is \"testing\":\n fname_img = os.path.join(path, 't10k-images.idx3-u...
[ "0.7315804", "0.7006713", "0.6858111", "0.679963", "0.67536896", "0.66597587", "0.6541016", "0.6534925", "0.64882743", "0.6464874", "0.64425945", "0.6425871", "0.6410244", "0.63993555", "0.63947785", "0.63876855", "0.6385198", "0.638357", "0.63787776", "0.6377489", "0.6373172...
0.6018545
67
Render a given numpy.uint8 2D array of pixel data.
def show(image): from matplotlib import pyplot import matplotlib as mpl fig = pyplot.figure() ax = fig.add_subplot(1,1,1) imgplot = ax.imshow(image, cmap=mpl.cm.Greys) imgplot.set_interpolation('nearest') ax.xaxis.set_ticks_position('top') ax.yaxis.set_ticks_position('left') pyplot.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_pixel_array(arr, figsize=(10, 10)):\n arr = arr.squeeze()\n plt.figure(figsize=figsize)\n plt.imshow(arr, cmap=plt.cm.bone)\n plt.show()", "def render(self):\n np_img = np.array(self.prev_img, dtype=np.uint8)\n np_img = np.swapaxes(np_img, 0, 2)\n return np_img", "def ...
[ "0.6824776", "0.6289643", "0.5894268", "0.5886476", "0.58250576", "0.5715473", "0.570549", "0.5702945", "0.5690092", "0.56785333", "0.567429", "0.56699634", "0.56405544", "0.5639835", "0.5638185", "0.562523", "0.56111133", "0.5560625", "0.5559693", "0.5551056", "0.55414987", ...
0.0
-1
Adds 5 latest blog posts as `latest_articles`, 5 latest comments as `latest_comments`, and all tags (annotated with `num_articles` field) as `tags` to the context, regardless of `request`.
def latest_content(request): latest_articles = Article.published_articles()[:5] latest_comments = Comment.objects.all().order_by('-pub_date')[:5] tags = Tag.objects.annotate(num_articles=Count('article')).order_by( '-num_articles') contributors = Contributor.objects.annotate( num_articles=Count('article')).order_by('-num_articles') return {'latest_articles': latest_articles, 'latest_comments': latest_comments, 'tags': tags, 'contributors': contributors, }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def latest_blog_posts(self, request, *args, **kwargs):\n context = self.get_context(request, *args, **kwargs)\n context[\"latest_posts\"] = MyblogDetailPage.objects.live().public()[:1] \n return render(request, \"myblog/latest_posts.html\", context)", "def last_five(request):\n fla...
[ "0.6630519", "0.6064325", "0.5982739", "0.5916848", "0.58361304", "0.5788325", "0.57815117", "0.5755909", "0.57152796", "0.56332666", "0.56171244", "0.5601291", "0.5582968", "0.54634035", "0.5452473", "0.53599924", "0.5354808", "0.5313329", "0.52591276", "0.522024", "0.521882...
0.67686737
0
Format a Roku Channel name.
def format_channel_name(channel_number: str, channel_name: str | None = None) -> str: if channel_name is not None and channel_name != "": return f"{channel_name} ({channel_number})" return channel_number
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def channel_name(radio_id: int, channel_id: int) -> str:\n return f\"COMM{radio_id} Ch {channel_id}\"", "def channelName(self):\n channel_list = (\"Neutral\",\n \"BBC1\",\n \"BBC2\",\n \"ITV\",\n \"Channel 4...
[ "0.78294134", "0.7059564", "0.6983384", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", "0.68293834", ...
0.7868498
1
Input filepath of financial data csv dump compile all the information into one dataframe return dataframe containing Adjusted price values of each security listed in directory
def compile_index_data(data_filepath,index_name): # find existing .pickle file filename = [_ for _ in glob.glob('*.pickle') if index_name in _ ][0].split('.')[0] + '_adj_close.csv' # with open(pickle_list[0],'rb') as f: # tickers = pickle.load(f) tickers = os.listdir(data_filepath) os.chdir(data_filepath) # retrieve list of csv files in given filepath main_df = pd.DataFrame() # create empty dataframe if filename in tickers: print ('{} already exists'.format(filename)) else: for count, ticker in enumerate(tickers): try: # using enumerate to loop through all the tickers # and keep track of the number of tickers df = pd.read_csv(ticker) # import csv into dataframe df.set_index('Date',inplace=True) # set Date column as index column, # inplace set to True so that its not redefined it everytime # is done in place. t_name = ticker.split('.')[0] df.rename(columns = {'Adj Close': t_name}, inplace=True) # since the only values we need for analysis is the adjusted close value # we rename column name to ticker symbol # df_adj_col_ticker = df[ticker].to_frame() if main_df.empty: main_df = df[t_name].to_frame() # convert series into dataframe else: main_df = main_df.join(df[t_name].to_frame(), how='outer') # Track progress of compiling if count % 10 == 0: print ('Percent complete: {}'.format(round(count/500*100))) except Exception as e: print ('Failed to compile {} due to: '.format(t_name) + str(e)) pass # convert dataframe to csv print ('Compiling data into {}'.format(filename)) main_df.to_csv(filename) return filename
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_df(self, file_path):\n df = pd.read_csv(file_path, sep=\";\")\n df.rename(columns={\"Get\": \"Currency\"}, inplace=True)\n df = df[df[\"Pay\"] == \"Chaos Orb\"]\n df = df[[\"League\", \"Date\", \"Currency\", \"Value\"]]\n df[\"Date\"] = pd.to_datetime(df[\"Date\"])\n ...
[ "0.65828145", "0.62339157", "0.6199246", "0.6138019", "0.61140287", "0.6102608", "0.6034207", "0.6006899", "0.59451014", "0.5918473", "0.5865274", "0.5854998", "0.58193326", "0.58130115", "0.57813156", "0.5780981", "0.57623285", "0.5745247", "0.5731047", "0.57274765", "0.5706...
0.5412425
58
pricing data converted into percentage change to normalize data percentage change will be considered as features labels will be either buy, sell or hold. if each week, the company's increasing by 2% = buy if decreasing by 2% = sell, if neither, hold. Each model is made on a percompany basis, but each company is going take into account all the other prices in the index
def process_data_for_labels(df, ticker, time_period): data_ = df.fillna(0) # ensuring NaN values are replaced by 0 incase data doesn't exist. # Avoiding inplace as it does not convert NaNs as expected, and will return None tickers = df.columns.values.tolist() # grab all adj close values of security for i in range(1,time_period+1): # loop through 7 days of adj close values data_['{}_{}d'.format(ticker, i)] = (data_[ticker].shift(-i)-data_[ticker])/data_[ticker] # create each column with percentage change in adj close values with increasing time. The shift # function allows us to grab the previous adjusted close entry. data_.fillna(0) # To ensure there are no NaN values in dataset return tickers, data_ # returns list of tickers and dataframe
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def percent_changes(self):\n\n # close_t = float(val[\"klines\"][\"1m\"].get(self.mw.cfg_manager.pair, {})[-5][4])\n klines_data = self.mw.klines.get(\"1m\")\n coin_data = klines_data.get(self.mw.cfg_manager.pair)\n\n if isinstance(coin_data, list):\n close_5m = float(self.mw...
[ "0.5864486", "0.5679427", "0.55887026", "0.55827385", "0.5496743", "0.5447927", "0.5396345", "0.5391044", "0.5382922", "0.5358451", "0.53466296", "0.53371716", "0.52985895", "0.528991", "0.52696675", "0.52553165", "0.5239735", "0.5239484", "0.5230781", "0.5222127", "0.522195"...
0.5120163
33
Returns an instance of fetcher
def initialize() -> fetcher.Fetcher: options = fetcher.Input( command="some_cmd", config_file="looker.ini", section="Looker" ) return fetcher.Fetcher(options)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_fetcher(self):\n return self.__fetcher", "def fetch(self) -> Fetch:\n return self._fetch", "def get_fetcher(\n launcher_url: str, output_dir: str, spec: Optional[str] = None\n) -> WorkflowFetcherBase:\n parsed_url = ParsedUrl(launcher_url)\n\n if parsed_url.scheme not in FETCHER_...
[ "0.7616966", "0.64553005", "0.6100894", "0.6082667", "0.59977883", "0.5952911", "0.58968616", "0.58818334", "0.5799498", "0.5791189", "0.5787772", "0.57814115", "0.57779944", "0.577231", "0.57723045", "0.5654948", "0.56429166", "0.56370324", "0.56276923", "0.56252486", "0.561...
0.6439661
2
fetcher.get_projects() should return a list of projects.
def test_get_projects_returns_projects(fc: fetcher.Fetcher): projects = fc.get_projects() assert isinstance(projects, list) assert isinstance(projects[0], models.Project)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_projects(self):\n projects = []\n page = 1\n while not len(projects) % 100:\n projects += self._get('/projects?{0}'.format(urllib.urlencode({'per_page': 100, 'page': page})))\n if not projects:\n break\n page += 1\n return projects...
[ "0.8439259", "0.8330137", "0.81635183", "0.790544", "0.7656669", "0.7634909", "0.7559611", "0.7557729", "0.7551785", "0.7523433", "0.7494402", "0.7446309", "0.74364996", "0.7427242", "0.73962003", "0.7385047", "0.73531884", "0.7350818", "0.73503566", "0.7344059", "0.7321423",...
0.862502
0
fetchet.get_projects() should be able to filter on project.
def test_get_projects_filters(fc: fetcher.Fetcher, test_project_name): projects = fc.get_projects(test_project_name) assert isinstance(projects, list) assert len(projects) == 1 assert projects[0].name == test_project_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_projects(self):\n pass", "def test_list_project_request(self):\n pass", "def test_list_projects(self):\n pass", "def test_list_projects(self):\n pass", "def test_get_projects_returns_projects(fc: fetcher.Fetcher):\n projects = fc.get_projects()\n assert isinst...
[ "0.740072", "0.7351347", "0.7287984", "0.7287984", "0.72771144", "0.72143286", "0.7165112", "0.71590155", "0.7144451", "0.7075294", "0.7046728", "0.7021743", "0.70181876", "0.69926757", "0.698769", "0.6950364", "0.6894256", "0.68472075", "0.6795028", "0.67938405", "0.6792199"...
0.829477
0
fetchet.get_projects() should error if filter is invalid
def test_get_projects_throws_if_project_does_not_exist(fc: fetcher.Fetcher): with pytest.raises(exceptions.NotFoundError) as exc: fc.get_projects("BadProject") assert "An error occured while getting projects." in str(exc.value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_projects_filters(fc: fetcher.Fetcher, test_project_name):\n projects = fc.get_projects(test_project_name)\n assert isinstance(projects, list)\n assert len(projects) == 1\n assert projects[0].name == test_project_name", "def _get_filtered_projects(filters):\n projects_itr = (projects_l...
[ "0.8058686", "0.71893626", "0.70169073", "0.6866926", "0.6799763", "0.67065436", "0.66316026", "0.66316026", "0.6614815", "0.66046983", "0.65524906", "0.6446057", "0.64291626", "0.6345218", "0.63182366", "0.6217229", "0.6167629", "0.616253", "0.6144264", "0.612364", "0.611247...
0.59895086
24
fetcher.get_models() should return a list of models.
def test_get_models_returns_models(fc: fetcher.Fetcher): ml = fc.get_models() assert isinstance(ml, list) assert isinstance(ml[0], models.LookmlModel)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_models(self, req, is_detail):\n context = req.environ['meteos.context']\n\n search_opts = {}\n search_opts.update(req.GET)\n\n # Remove keys that are not related to model attrs\n search_opts.pop('limit', None)\n search_opts.pop('offset', None)\n sort_key = ...
[ "0.7452906", "0.72231185", "0.7150281", "0.71438277", "0.70214987", "0.69560665", "0.69169444", "0.6905092", "0.68741965", "0.6871369", "0.6853938", "0.6839921", "0.67970765", "0.67815137", "0.6671083", "0.66492426", "0.6614827", "0.65691483", "0.6551473", "0.64561534", "0.64...
0.769774
0
fetcher.get_models() should be able to filter on project or model.
def test_get_models_filters(fc: fetcher.Fetcher, test_project_name, test_model): ml = fc.get_models(project=test_project_name) assert all(m.project_name == test_project_name for m in ml) ml = fc.get_models(model=test_model["name"]) assert all(m.name == test_model["name"] for m in ml) ml = fc.get_models(project=test_project_name, model=test_model["name"]) assert all( m.project_name == test_project_name and m.name == test_model["name"] for m in ml )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_models(self, req, is_detail):\n context = req.environ['meteos.context']\n\n search_opts = {}\n search_opts.update(req.GET)\n\n # Remove keys that are not related to model attrs\n search_opts.pop('limit', None)\n search_opts.pop('offset', None)\n sort_key = ...
[ "0.72766924", "0.66285986", "0.6556921", "0.6551836", "0.6296319", "0.626473", "0.6252031", "0.61985433", "0.61647654", "0.61226976", "0.61226976", "0.607028", "0.60465264", "0.6035401", "0.60337895", "0.59634507", "0.5959686", "0.5941662", "0.5922241", "0.59054995", "0.58814...
0.75294465
0
fetcher.get_models() should throw if a model is not found.
def test_get_models_throws_if_model_does_not_exist(fc: fetcher.Fetcher, project, model): with pytest.raises(exceptions.NotFoundError) as exc: fc.get_models(project=project, model=model) assert "An error occured while getting models." in str(exc.value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_models_returns_models(fc: fetcher.Fetcher):\n ml = fc.get_models()\n assert isinstance(ml, list)\n assert isinstance(ml[0], models.LookmlModel)", "def get_models(self, app_name):\n try:\n models = list(apps.get_app_config(app_name).get_models())\n return models\...
[ "0.7327567", "0.69435924", "0.67743224", "0.67731684", "0.666128", "0.66390353", "0.6595562", "0.6590047", "0.64084816", "0.6316313", "0.6267025", "0.62651926", "0.626041", "0.6233475", "0.6200443", "0.61957514", "0.61935633", "0.61921066", "0.61672646", "0.61589247", "0.6154...
0.75194955
0
fetcher.get_models() should throw if a model is not found.
def test_get_models_throws_if_project_does_not_exist( fc: fetcher.Fetcher, project, model ): with pytest.raises(exceptions.NotFoundError) as exc: fc.get_models(project=project, model=model) assert "An error occured while getting projects." in str(exc.value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_models_throws_if_model_does_not_exist(fc: fetcher.Fetcher, project, model):\n with pytest.raises(exceptions.NotFoundError) as exc:\n fc.get_models(project=project, model=model)\n assert \"An error occured while getting models.\" in str(exc.value)", "def test_get_models_returns_models(fc...
[ "0.75194955", "0.7327567", "0.69435924", "0.67743224", "0.67731684", "0.66390353", "0.6595562", "0.6590047", "0.64084816", "0.6316313", "0.6267025", "0.62651926", "0.626041", "0.6233475", "0.6200443", "0.61957514", "0.61935633", "0.61921066", "0.61672646", "0.61589247", "0.61...
0.666128
5
fetcher.get_used_models() should return models that have queries against them.
def test_get_used_models(fc: fetcher.Fetcher, test_model): used_models = fc.get_used_models() assert isinstance(used_models, dict) assert len(used_models) > 0 assert all(type(model_name) == str for model_name in used_models.keys()) assert all(type(query_count) == int for query_count in used_models.values()) assert test_model["name"] in used_models.keys()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def availablemodels(self):\n return self.__models.keys()", "def _get_models(self, req, is_detail):\n context = req.environ['meteos.context']\n\n search_opts = {}\n search_opts.update(req.GET)\n\n # Remove keys that are not related to model attrs\n search_opts.pop('limit'...
[ "0.70178705", "0.66382486", "0.6534866", "0.631813", "0.63044095", "0.6285215", "0.61792207", "0.6041896", "0.60361505", "0.6007675", "0.592958", "0.5920479", "0.58479476", "0.5833444", "0.58288264", "0.5817674", "0.58034897", "0.58034897", "0.58034897", "0.58034897", "0.5747...
0.7987806
0
fetcher.get_explores() should return a list of explores.
def test_get_explores(fc: fetcher.Fetcher): explores = fc.get_explores() assert isinstance(explores, list) assert len(explores) > 0 assert isinstance(explores[0], models.LookmlModelExplore)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_explores_filters(fc: fetcher.Fetcher):\n explores = fc.get_explores(model=\"henry_dusty\")\n assert all(e.model_name == \"henry_dusty\" for e in explores)\n\n explores = fc.get_explores(model=\"henry_qa\", explore=\"explore_2_joins_all_used\")\n assert all(\n e.model_name == \"henry...
[ "0.6731509", "0.6563917", "0.6551571", "0.63968503", "0.63752097", "0.5857632", "0.57382774", "0.5567012", "0.54315007", "0.54032236", "0.5390805", "0.53766435", "0.52719086", "0.52510387", "0.52280146", "0.52221656", "0.5203557", "0.5185477", "0.5180662", "0.5156471", "0.514...
0.7531671
0
fetcher.get_explores() should be able to filter on model and/or explore.
def test_get_explores_filters(fc: fetcher.Fetcher): explores = fc.get_explores(model="henry_dusty") assert all(e.model_name == "henry_dusty" for e in explores) explores = fc.get_explores(model="henry_qa", explore="explore_2_joins_all_used") assert all( e.model_name == "henry_qa" and e.name == "explore_2_joins_all_used" for e in explores )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_explores(fc: fetcher.Fetcher):\n explores = fc.get_explores()\n assert isinstance(explores, list)\n assert len(explores) > 0\n assert isinstance(explores[0], models.LookmlModelExplore)", "def test_get_used_explores(fc: fetcher.Fetcher, test_model, test_used_explore_names):\n used_expl...
[ "0.753411", "0.6666877", "0.6630365", "0.63271785", "0.6167889", "0.5833313", "0.55136293", "0.53865874", "0.53228235", "0.53056663", "0.5212486", "0.51720136", "0.51571435", "0.5055647", "0.50480455", "0.50150645", "0.49779034", "0.49160555", "0.49039322", "0.4895284", "0.48...
0.822642
0
fetcher.get_explores() should throw if an explore/model is not found.
def test_get_explores_throws_if_model_or_explore_does_not_exist( fc: fetcher.Fetcher, model: Optional[str], explore: Optional[str], msg: str ): with pytest.raises(exceptions.NotFoundError) as exc: fc.get_explores(model=model, explore=explore) assert msg in str(exc.value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_explores(fc: fetcher.Fetcher):\n explores = fc.get_explores()\n assert isinstance(explores, list)\n assert len(explores) > 0\n assert isinstance(explores[0], models.LookmlModelExplore)", "def test_get_explores_filters(fc: fetcher.Fetcher):\n explores = fc.get_explores(model=\"henry_du...
[ "0.79972434", "0.6808644", "0.64591634", "0.6081574", "0.6081095", "0.6056974", "0.5249449", "0.5153191", "0.5144307", "0.5057118", "0.49663934", "0.49415502", "0.4938596", "0.49360746", "0.49263144", "0.4916875", "0.49087682", "0.48916966", "0.48450214", "0.4824901", "0.4805...
0.73947066
1
fetcher.get_used_explores() should return all used explores.
def test_get_used_explores(fc: fetcher.Fetcher, test_model, test_used_explore_names): used_explores = fc.get_used_explores(model=test_model["name"]) assert isinstance(used_explores, dict) assert all(e in test_used_explore_names for e in used_explores)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_unused_explores(fc: fetcher.Fetcher, test_model, test_unused_explores):\n unused_explores = fc.get_unused_explores(model=test_model[\"name\"])\n assert all(e in test_unused_explores for e in unused_explores)", "def test_get_explores_filters(fc: fetcher.Fetcher):\n explores = fc.get_explores...
[ "0.7264244", "0.6198452", "0.6186663", "0.59214425", "0.5807355", "0.5651149", "0.56107587", "0.5609498", "0.5529075", "0.5527514", "0.5387147", "0.5349075", "0.52784765", "0.52772737", "0.5273169", "0.5267631", "0.52531534", "0.52378064", "0.52269423", "0.5195598", "0.515275...
0.7800213
0
fetcher.get_unused_explores() should return all unused explores.
def test_get_unused_explores(fc: fetcher.Fetcher, test_model, test_unused_explores): unused_explores = fc.get_unused_explores(model=test_model["name"]) assert all(e in test_unused_explores for e in unused_explores)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_used_explores(fc: fetcher.Fetcher, test_model, test_used_explore_names):\n used_explores = fc.get_used_explores(model=test_model[\"name\"])\n assert isinstance(used_explores, dict)\n assert all(e in test_used_explore_names for e in used_explores)", "def exploits(self):\n return self....
[ "0.6674417", "0.5879174", "0.573975", "0.5573522", "0.5512234", "0.5511594", "0.54789424", "0.5453956", "0.54249877", "0.5305752", "0.52119917", "0.5211895", "0.5186949", "0.5154393", "0.5097592", "0.50868165", "0.50696427", "0.4995546", "0.49941427", "0.49911252", "0.4978347...
0.7982038
0
fetcher.get_explore_fields() should return an explores fields.
def test_get_explore_fields_gets_fields( fc: fetcher.Fetcher, test_model, test_explores_stats ): test_explore = test_explores_stats[0] explore = fc.get_explores(model=test_model["name"], explore=test_explore["name"]) assert isinstance(explore, list) explore = explore[0] assert isinstance(explore, models.LookmlModelExplore) assert explore.model_name == test_model["name"] assert explore.name == test_explore["name"] fields = fc.get_explore_fields(explore) assert isinstance(fields, list) assert fields == test_explore["all_fields"]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_explore_fields_gets_fields_for_dimension_or_measure_only_explores(\n fc: fetcher.Fetcher, test_model, test_dimensions_or_measures_only_explores\n):\n expected = test_dimensions_or_measures_only_explores[0]\n explore = fc.get_explores(model=test_model[\"name\"], explore=expected[\"name\"])\n ...
[ "0.7630596", "0.71610755", "0.619276", "0.5935856", "0.5886932", "0.56719977", "0.56685346", "0.56128865", "0.5601622", "0.55978966", "0.55809444", "0.5578002", "0.55722994", "0.54728", "0.5469623", "0.5441008", "0.543378", "0.5390191", "0.5388459", "0.5369778", "0.5361909", ...
0.8270363
0
fetcher.get_explore_fields() should return when an explore has only dimensions or only measures.
def test_get_explore_fields_gets_fields_for_dimension_or_measure_only_explores( fc: fetcher.Fetcher, test_model, test_dimensions_or_measures_only_explores ): expected = test_dimensions_or_measures_only_explores[0] explore = fc.get_explores(model=test_model["name"], explore=expected["name"]) assert isinstance(explore, list) actual = explore[0] assert actual.name == expected["name"] assert not (actual.fields.dimensions and actual.fields.measures) expected_fields = [f["name"] for f in expected["fields"]] actual_fields = fc.get_explore_fields(actual) assert actual_fields == expected_fields
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_explore_fields_gets_fields(\n fc: fetcher.Fetcher, test_model, test_explores_stats\n):\n test_explore = test_explores_stats[0]\n explore = fc.get_explores(model=test_model[\"name\"], explore=test_explore[\"name\"])\n assert isinstance(explore, list)\n explore = explore[0]\n assert is...
[ "0.79898906", "0.7255912", "0.57427955", "0.5689888", "0.5485005", "0.544207", "0.5428259", "0.54008704", "0.5328612", "0.52564484", "0.5198791", "0.5090246", "0.5081006", "0.5072066", "0.50549966", "0.5046278", "0.49843732", "0.49804208", "0.49604252", "0.49604252", "0.49590...
0.81051433
0
fetcher.get_explore_field_stats() should get the stats of all fields in an explore.
def test_get_explore_field_stats( fc: fetcher.Fetcher, looker_sdk: methods.Looker40SDK, test_model, test_used_explore_names, test_explores_stats, ): explore = fc.get_explores( model=test_model["name"], explore=test_used_explore_names[0] )[0] actual_stats = fc.get_explore_field_stats(explore) assert isinstance(actual_stats, dict) for e in test_explores_stats: if e["name"] == test_used_explore_names[0]: expected_stats = e assert all(actual_stats[k] == 0 for k in expected_stats["unused_fields"]) assert all(actual_stats[k] > 0 for k in expected_stats["used_fields"])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_explore_fields_gets_fields(\n fc: fetcher.Fetcher, test_model, test_explores_stats\n):\n test_explore = test_explores_stats[0]\n explore = fc.get_explores(model=test_model[\"name\"], explore=test_explore[\"name\"])\n assert isinstance(explore, list)\n explore = explore[0]\n assert is...
[ "0.757388", "0.66561705", "0.5693254", "0.5563461", "0.5562313", "0.55102324", "0.55069894", "0.54181457", "0.5415948", "0.53354806", "0.53127414", "0.528702", "0.5241747", "0.52340806", "0.52330387", "0.52114326", "0.51936793", "0.5185652", "0.51400167", "0.5138318", "0.5132...
0.7587318
0
fetcher.get_explore_join_stats() should return the stats of all joins in an explore.
def test_get_explore_join_stats(fc: fetcher.Fetcher, test_model): explore = fc.get_explores( model=test_model["name"], explore="explore_2_joins_1_used" )[0] field_stats = { "explore_2_joins_1_used.d1": 10, "explore_2_joins_1_used.d2": 5, "explore_2_joins_1_used.d3": 0, "explore_2_joins_1_used.m1": 0, "join1.d1": 10, "join1.d2": 10, "join1.d3": 10, "join1.m1": 0, "join2.d1": 0, "join2.d2": 0, "join2.d3": 0, "join2.m1": 0, } join_stats = fc.get_explore_join_stats(explore=explore, field_stats=field_stats) assert isinstance(join_stats, dict) assert len(join_stats) == 2 assert join_stats == {"join1": 30, "join2": 0}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_join_info(node):\n operator_info = node['operatorInfo']\n analyze_info = node['AnalyzeInfo']\n\n if 'Join' in node['id']:\n # Join Node\n join_type = extract_join_type(operator_info)\n conditions = extract_join_conditions(operator_info)\n current_node = JoinPlan(joi...
[ "0.5480241", "0.53656536", "0.50666654", "0.5061134", "0.49818888", "0.4904676", "0.48338452", "0.48054832", "0.47597033", "0.47334749", "0.4718956", "0.47070545", "0.46772164", "0.46477938", "0.46049055", "0.45803955", "0.45192826", "0.44968593", "0.44656146", "0.44228086", ...
0.83031076
0
This is the main function.
def main(argv): parser = OptionParser() parser.add_option( "--output-dir", help="Output directory for generated files. Defaults to chromium root " "directory.") parser.add_option( "-v", "--verbose", action="store_true", help="Verbose logging output.") parser.add_option( "-c", "--check", action="store_true", help="Check if output files match generated files in chromium root " "directory. Use this in PRESUBMIT scripts with --output-dir.") (options, _) = parser.parse_args(args=argv) # This script lives under src/gpu/command_buffer. script_dir = os.path.dirname(os.path.abspath(__file__)) assert script_dir.endswith(os.path.normpath("src/gpu/command_buffer")) # os.path.join doesn't do the right thing with relative paths. chromium_root_dir = os.path.abspath(script_dir + "/../..") # Support generating files under gen/ and for PRESUBMIT. if options.output_dir: output_dir = options.output_dir else: output_dir = chromium_root_dir os.chdir(output_dir) # This script lives under gpu/command_buffer, cd to base directory. build_cmd_buffer_lib.InitializePrefix("WebGPU") gen = build_cmd_buffer_lib.GLGenerator( options.verbose, "2018", _FUNCTION_INFO, _NAMED_TYPE_INFO, chromium_root_dir) gen.ParseGLH("gpu/command_buffer/webgpu_cmd_buffer_functions.txt") gen.WriteCommandIds("gpu/command_buffer/common/webgpu_cmd_ids_autogen.h") gen.WriteFormat("gpu/command_buffer/common/webgpu_cmd_format_autogen.h") gen.WriteFormatTest( "gpu/command_buffer/common/webgpu_cmd_format_test_autogen.h") gen.WriteGLES2InterfaceHeader( "gpu/command_buffer/client/webgpu_interface_autogen.h") gen.WriteGLES2ImplementationHeader( "gpu/command_buffer/client/webgpu_implementation_autogen.h") gen.WriteGLES2InterfaceStub( "gpu/command_buffer/client/webgpu_interface_stub_autogen.h") gen.WriteGLES2InterfaceStubImpl( "gpu/command_buffer/client/webgpu_interface_stub_impl_autogen.h") gen.WriteGLES2Implementation( "gpu/command_buffer/client/webgpu_implementation_impl_autogen.h") gen.WriteGLES2ImplementationUnitTests( "gpu/command_buffer/client/webgpu_implementation_unittest_autogen.h") gen.WriteCmdHelperHeader( "gpu/command_buffer/client/webgpu_cmd_helper_autogen.h") # Note: No gen.WriteServiceImplementation # Note: No gen.WriteServiceUnitTests gen.WriteServiceUtilsHeader( "gpu/command_buffer/service/webgpu_cmd_validation_autogen.h") gen.WriteServiceUtilsImplementation( "gpu/command_buffer/service/" "webgpu_cmd_validation_implementation_autogen.h") build_cmd_buffer_lib.Format(gen.generated_cpp_filenames, output_dir, chromium_root_dir) if gen.errors > 0: print("build_webgpu_cmd_buffer.py: Failed with %d errors" % gen.errors) return 1 check_failed_filenames = [] if options.check: for filename in gen.generated_cpp_filenames: if not filecmp.cmp(os.path.join(output_dir, filename), os.path.join(chromium_root_dir, filename)): check_failed_filenames.append(filename) if len(check_failed_filenames) > 0: print('Please run gpu/command_buffer/build_webgpu_cmd_buffer.py') print('Failed check on autogenerated command buffer files:') for filename in check_failed_filenames: print(filename) return 1 return 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main():", "def main(...
[ "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "0.9125712", "...
0.0
-1
Compute Haversine distance between points. LatLongDistance(p1, p2) returns distance in meters between points p1 and p2. A point p is a list/array p=[longitude, latitude]
def latlong_distance(p1, p2): radius = 6371 # km lat1 = p1[1] * math.pi / 180.0 lat2 = p2[1] * math.pi / 180.0 lon1 = p1[0] * math.pi / 180.0 lon2 = p2[0] * math.pi / 180.0 deltaLat = lat2 - lat1 deltaLon = lon2 - lon1 a = (math.sin(deltaLat / 2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(deltaLon / 2)**2) c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a)) d = radius * c d = d * 1e3 # Return in m return d
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def haversine(point_1, \n point_2):\n # Specify the radius of the Earth in kilometers\n earth_radius = 6372.8\n # Extract latitudes and longitudes from the provided points\n latitude_1 = point_1[0]\n latitude_2 = point_2[0]\n longitude_1 = point_1[1]\n longitude_2 = point_2[1]\n ...
[ "0.7411768", "0.7283244", "0.7281911", "0.7275467", "0.7160516", "0.7140681", "0.71359766", "0.706824", "0.7068029", "0.7050806", "0.70261496", "0.70184296", "0.69995123", "0.6997063", "0.69919103", "0.6987301", "0.69823533", "0.69742984", "0.6964179", "0.6947977", "0.6935867...
0.71147573
7
Normalize audio file to range [1, 1]
def normalize(audio): norm = audio/max(audio) return norm
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normalize(filename,wout=True):\n n, data, data_dB,sr,ch=inputwav(filename)\n if ch==1:\n diff=0-max(data_dB)\n if ch==2:\n d1=0-max(data_dB[:,0])\n d2=0-max(data_dB[:,1])\n diff=max(d1,d2)\n print('Adding '+str(diff)+' dB...')\n data_dB_norm=data_dB+diff\n data_nor...
[ "0.6990606", "0.69585127", "0.6922056", "0.6835355", "0.6835355", "0.66305023", "0.64685136", "0.64316094", "0.6400724", "0.6398994", "0.63599336", "0.6334538", "0.63280183", "0.62815994", "0.62611055", "0.62473464", "0.6237534", "0.6221386", "0.6176301", "0.6140515", "0.6132...
0.78221744
0
Load an audio file and divide into 10 second segments.
def segment_10s(audio, sr): seg_files = {} n_seg = int((len(audio)/sr)/10) for i in range(n_seg): segment = audio[10*i*sr:(i+1)*10*sr] seg_files[i] = segment return seg_files
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, secs, path, concat=True):\n audio = np.empty((1,))\n secs_loaded = 0\n files_loaded = 0\n files = glob.glob(path + \"*.wav\")\n for file in files:\n (sr, samples) = wavfile.read(file)\n audio = np.concatenate((audio, samples))\n\n ...
[ "0.64271533", "0.6278708", "0.6274508", "0.6185571", "0.60926473", "0.6001208", "0.59411097", "0.59162825", "0.59099066", "0.5908874", "0.58851975", "0.58825463", "0.58139896", "0.5805803", "0.5801357", "0.57745636", "0.57619977", "0.5760922", "0.5745996", "0.56929225", "0.56...
0.62473094
3
Load an audio file and segment into 10s increments Save each segment to the target directory. Append the gender of the speaker and the segment index to the filename.
def segment_audio(filename, y_value, split='train', clf='gender'): filepath = 'recordings/recordings/' + filename + '.mp3' audio, sr = librosa.load(filepath, sr=16000) audio = normalize(audio) # Add gender label to filename for later processing sex = y_value if sex == 'female': filename = '{}.F'.format(filename) else: filename = '{}.M'.format(filename) # Segment audio file seg_files = segment_10s(audio, sr) for key, val in seg_files.items(): new_name = '{}.{}'.format(filename, key) sf.write('data/{}/{}/{}o.wav'.format(clf, split, new_name), val, sr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def file_generator(files: list,\n segment_duration: float,\n sampleRate: int,\n db_thr: float or None = None,\n frame_length: int = 512,\n hop_length: int = 128,\n ) -> None:\n\n I = 0\n J = 0\n\n s...
[ "0.5985446", "0.5802684", "0.57816744", "0.5737059", "0.5693634", "0.5681921", "0.55937463", "0.5582633", "0.5564124", "0.55507296", "0.55322385", "0.5512459", "0.55056393", "0.5496371", "0.54751974", "0.5456971", "0.5410829", "0.5401392", "0.53417194", "0.5321298", "0.531510...
0.70655805
0
Load an audio file (or segment). Add random noise to the file and save with new filename.
def noisy_data(filename, split='train', clf='gender'): filepath = 'data/{}/{}/{}o.wav'.format(clf, split, filename) audio, sr = librosa.load(filepath, sr=16000) # Add noise noisy = add_noise(audio) # Write noise to file sf.write('data/{}/{}/{}n.wav'.format(clf, split, filename), noisy, sr) #print("Noise added to {}".format(filename))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_audio(file_path):\n # load the audio file in its original sampling rate\n audio_data, sr = librosa.load(file_path, sr=sampling_rate)\n\n # get the common file name\n file_name = file_path.split(\"/\")[-1]\n file_name = file_name.split(\".wav\")[0]\n\n # calculate number of samples in the...
[ "0.62971425", "0.6159043", "0.5984587", "0.59020734", "0.58086365", "0.5675305", "0.56475496", "0.5606833", "0.559785", "0.5565294", "0.54593736", "0.54581594", "0.5443855", "0.5441127", "0.54234785", "0.542045", "0.5408668", "0.53995633", "0.53893155", "0.5381253", "0.537922...
0.689111
0
Upload a file to S3 or move to another directory. INPUT_DIR is the name of the directory with parquets. DETECTIONS_DIR can be a
def upload_file( input_dir, output_dir, partition, node_id, job_id, pattern, file_format ): logging.basicConfig( level=logging.INFO, format="%(asctime)s %(levelname)s %(name)s.%(funcName)s: %(message)s", datefmt="%Y-%m-%d %H:%M:%S", ) logging.info(f"Job: {job_id} | Node: {node_id} | Partition {partition}") filename = f"{pattern}_{partition}.{file_format}" file_path = os.path.join(input_dir, filename) output_path = os.path.join(output_dir, filename) logging.info(f"Opening detection file: {file_path}") data = iodf.read_file(file_path) logging.info(f"Writing output in {output_path}") iodf.write_file(data, output_path, file_format=file_format) logging.info(f"Finish him!") return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def upload_data(dir, input_dir, s3_dir):\n config = _read_config(dir)\n sage_maker_client = sagemaker.SageMakerClient(config.aws_profile, config.aws_region)\n\n return sage_maker_client.upload_data(input_dir, s3_dir)", "def upload_file_to_s3(bucket_name, input_filepath, output_filename):\n s3 = boto3...
[ "0.6746442", "0.6491204", "0.63522506", "0.6235617", "0.6157146", "0.61324275", "0.6127183", "0.6115192", "0.61045253", "0.6098759", "0.60934263", "0.6089703", "0.60668164", "0.60577595", "0.5977721", "0.5973843", "0.59473646", "0.5942112", "0.5934158", "0.5906467", "0.590605...
0.0
-1
Get the state of the fsm
def get_state(self, node_uuid, index): return self.state
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetState(self):\r\n \r\n return self.state", "def getState():\n # TODO: this isn't nearly as meaningful as it used to be", "def getState(self):\r\n return self._get_SS_State()#self.currentState\r", "def _get_state(self):\n return self.__state", "def _get_state(self):\...
[ "0.77134407", "0.76589096", "0.76107895", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", "0.7550614", ...
0.0
-1
Get a lock on the bus
def bus_acquire(self, blocking=True): if self._bus_lock.acquire(blocking): return True return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_lock(name):\n return _handler_locks[name]", "def get_lock():\n\n return multiprocessing.Lock()", "def get_lock(self, name, try_=False):\n lock = Lock(self, name, try_)\n with lock as got_lock:\n yield got_lock", "def get_lock(self):\n function_string = 'IFLOC...
[ "0.7457342", "0.7200968", "0.7150414", "0.71146137", "0.6958682", "0.6892568", "0.6885043", "0.6851491", "0.67310303", "0.6696432", "0.66290563", "0.66086996", "0.6608197", "0.66038275", "0.65713847", "0.6433796", "0.6428536", "0.6421543", "0.6370052", "0.63416463", "0.633213...
0.569449
69
Release a lock on the bus
def bus_release(self): self._bus_lock.release()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def release_lock():\r\n get_lock.n_lock -= 1\r\n assert get_lock.n_lock >= 0\r\n # Only really release lock once all lock requests have ended.\r\n if get_lock.lock_is_enabled and get_lock.n_lock == 0:\r\n get_lock.start_time = None\r\n get_lock.unlocker.unlock()", "def release_lock(self...
[ "0.7924762", "0.7834396", "0.77969474", "0.77904904", "0.74435604", "0.74268526", "0.73679256", "0.7322436", "0.7123128", "0.7118452", "0.71132535", "0.709967", "0.7089947", "0.70288163", "0.7005624", "0.699237", "0.6928809", "0.6910996", "0.6896251", "0.687286", "0.6866911",...
0.8140664
0
Get status of the lock
def bus_locked(self): return self._bus_lock.locked()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lock_status(self) -> Dict[str, str]:\n self.__logger.debug('Eva.lock_status called')\n return self.__http_client.lock_status()", "def getstatus(self):\n with self.lock:\n return (self.status, self.time_start)", "def get_raw_status(self):\n self.__param_lock.acquire()\n ...
[ "0.79571366", "0.72897905", "0.72555906", "0.72103953", "0.70631886", "0.7003551", "0.6984304", "0.6949121", "0.69234353", "0.69027823", "0.6886226", "0.6849591", "0.68323433", "0.67312163", "0.6725681", "0.67219126", "0.67061067", "0.6695192", "0.6695192", "0.6695192", "0.66...
0.0
-1
Retrieve data Don't do long task in loop. Use a separated thread to not perturbate the nodeman
def loop(self, stopevent): for bus in self.buses: self.buses[bus].loop(stopevent)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data_thread(self, ip):\n get_data_thread = Thread(target=self.get_data, args=[ip])\n get_data_thread.start()", "def fetch_data():\n data.fetch_data()\n data.start_updating()", "def main(self):\n while True:\n if not self.data_server_command.empty():\n ...
[ "0.696191", "0.6716008", "0.65941787", "0.6481667", "0.6426779", "0.6374192", "0.62645483", "0.61824685", "0.610256", "0.60537034", "0.60457593", "0.60247904", "0.5971915", "0.59577423", "0.5926537", "0.59190476", "0.58765227", "0.5859717", "0.5845389", "0.58351386", "0.58195...
0.0
-1
Change the position of the pan
def set_position(self, node_uuid, index, data): try: servox = self._bus.nodeman.find_node('servox') servoy = self._bus.nodeman.find_node('servoy') logger.debug('[%s] - set_position of servos %s and %s', self.__class__.__name__, servox, servoy) if data is None or data=="-1|-1": sx,sy = self.values['initial'].get_data_index(index=index).split('|') else: sx,sy = data.split('|') logger.debug('[%s] - set_position to data %s|%s', self.__class__.__name__, sx, sy) datax = "%s|%s|%s"%(sx, self.values['angle_minx'].get_data_index(index=index), self.values['angle_maxx'].get_data_index(index=index)) datay = "%s|%s|%s"%(sy, self.values['angle_miny'].get_data_index(index=index), self.values['angle_maxy'].get_data_index(index=index) ) servox.values['angle'].data = datax servoy.values['angle'].data = datay self.values['position']._data = data except Exception: logger.exception('[%s] - Exception when set_position', self.__class__.__name__)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def panTo(self, p=None):\n if p == None:\n p = self.focus\n MV = self.MV\n vr = self.getViewRight()\n vu = self.getViewUp()\n p = -p\n x = np.dot(p, vr) # dot product\n y = np.dot(p, vu)\n MV[3, :2] = x, y # set first two entries of 4th row to x, y...
[ "0.7055883", "0.7055883", "0.69751316", "0.66623855", "0.65398514", "0.6447946", "0.6447465", "0.64395374", "0.6402126", "0.63889927", "0.63513035", "0.63486654", "0.63106734", "0.6296175", "0.6237631", "0.62298304", "0.62075496", "0.6197965", "0.61601925", "0.61556464", "0.6...
0.0
-1
Decorator to be used in apimethods to serve the swaggerdocumentation for this api.
def api_documentation(api: str, summary: str, in_model: BaseModel, out_model: BaseModel, out_description: str) -> Callable: for model, name in ((in_model, 'Input'), (out_model, 'Output')): doc.Object( make_dataclass( f'Api{api[1:].title()}{name}', [(key, val.type_, val.type_) for key, val in model.__dict__['__fields__'].items()])) im_returns = doc.JsonBody({ key: val.type_ for key, val in in_model.__dict__['__fields__'].items() }) om_returns = { key: val.type_ for key, val in out_model.__dict__['__fields__'].items() } def decorator(func): @doc.summary(summary) @doc.response(412, 'Error: Precondition Failed', description='The passed request-parameters are invalid') @doc.response(500, 'Error: Server-Error occured', description='An internal error occured') @doc.consumes(im_returns, content_type='application/json', location='body') @doc.produces(om_returns, content_type='application/json', description=out_description) @wraps(func) async def function_wrapper(request, *args, **kwargs): return await func(request=request, *args, **kwargs) return function_wrapper return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index():\n definition = {\n \"swagger\": \"2.0\",\n \"info\": {\n \"title\": flask.current_app.config.get(\"APPNAME\", \"Not specified\"),\n \"version\": flask.current_app.config.get(\"VERSION\", \"Not specified\"),\n },\n \"host\": request.host,\n \"...
[ "0.7308593", "0.67804843", "0.67267275", "0.6568308", "0.6500626", "0.6489433", "0.64708114", "0.64436257", "0.63863075", "0.6336464", "0.6331381", "0.6279588", "0.6140457", "0.6124011", "0.6117498", "0.6093394", "0.60924906", "0.60902476", "0.60646194", "0.6054501", "0.60270...
0.6823912
1
Decorator to be used in apimethods to convert the requestdata to an instance of the passed `model`. This instance is passed to the decorated apiendpoint as the parameter `service_params`.
def api_inputmodel(api: str, model: BaseModel, servicename: str, service_logger: logger) -> Callable: def decorator(func): @wraps(func) async def function_wrapper(request, *args, **kwargs): try: service_params = model.parse_raw(request.body) except ValidationError as err: msg = (f'API: {api} - invalid params ({request.json}) passed ' f'to {servicename}: {err}') service_logger.warning(msg) raise PreconditionFailed(msg, status_code=412) result = await func(request=request, service_params=service_params, service_logger=service_logger, *args, **kwargs) return result return function_wrapper return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_outputmodel(api: str, model: BaseModel, servicename: str,\n service_logger: logger) -> Callable:\n\n def decorator(func):\n @wraps(func)\n async def function_wrapper(request, *args, **kwargs):\n service_result = await func(request, *args, **kwargs)\n ...
[ "0.6261429", "0.61969465", "0.5975331", "0.56145257", "0.5604642", "0.55971265", "0.558913", "0.5562619", "0.54409605", "0.5427529", "0.5384895", "0.53138745", "0.531021", "0.5299018", "0.52693087", "0.52421254", "0.5187899", "0.5182848", "0.51826674", "0.5159831", "0.5159831...
0.7151013
0
Decorator to be used in apimethods to convert the responsedata of the decorated apimethod to a json based on the passed `model`.
def api_outputmodel(api: str, model: BaseModel, servicename: str, service_logger: logger) -> Callable: def decorator(func): @wraps(func) async def function_wrapper(request, *args, **kwargs): service_result = await func(request, *args, **kwargs) try: if isinstance(service_result, model): result = service_result else: result = model(**service_result) output = response.json(result.dict()) except Exception as err: msg = ('an internal error occured (service: ' f'{servicename}, api: {api}): {err}') raise ServerError(msg) service_logger.info(f'processed result {result} => ' f'{output.content_type} [{output.status}] ' f'{output.body}') return output return function_wrapper return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def json_response(func):\n\t@wraps(func)\n\tdef decorated_view(*args, **kwargs):\n\t\tdata = func(*args, **kwargs)\n\t\tdata = json.dumps(data)\n\t\tresponse = make_response(data)\n\t\tresponse.headers['Content-Type'] = 'application/json'\n\t\treturn response\n\treturn decorated_view", "def json_response(func):\...
[ "0.6303589", "0.6233411", "0.6158551", "0.61566204", "0.61502767", "0.6142237", "0.6134618", "0.60121006", "0.60005003", "0.5990344", "0.59364825", "0.59224707", "0.59192204", "0.5905445", "0.58905154", "0.58634555", "0.5848181", "0.5831524", "0.58291614", "0.58150035", "0.57...
0.6607163
0
Route to send calculator input
def operation_result(): input1 = request.form['Input1'] input2 = request.form['Input2'] input3 = request.form['Input3'] input4 = request.form['Input4'] input5 = request.form['Input5'] input6 = request.form['Input6'] try: token_price_a_initial = float(input1) token_price_b_initial = float(input2) token_price_a_future = float(input3) token_price_b_future = float(input4) token_a_pool_weight = float(input5) token_b_pool_weight = float(input6) if token_a_pool_weight + token_b_pool_weight == 1: r1 = token_price_a_future/token_price_a_initial r2 = token_price_b_future/token_price_b_initial impermanent_loss = ((r1**(token_a_pool_weight))*(r2**(token_b_pool_weight)) /(r1*token_a_pool_weight + r2*token_b_pool_weight) - 1)*-100 return render_template( 'calculator.html', result=impermanent_loss, calculation_success=True ) except: return render_template( 'calculator.html', calculation_success=False )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculator(operation): \n \n operation = MATH[operation]\n a = int(request.args.get(\"a\"))\n b = int(request.args.get(\"b\"))\n total = operation(a, b)\n\n return f\"<h1>TOTAL: {total}</h1>\"", "def all_arithmetic_operators(request: Any) -> Any:\n return request.param", "def all_arith...
[ "0.6870682", "0.62640357", "0.62640357", "0.6200235", "0.60145706", "0.6007947", "0.5992822", "0.59635174", "0.5928874", "0.58482105", "0.58049804", "0.5771265", "0.5717723", "0.56060153", "0.5605487", "0.5560057", "0.55397177", "0.5519091", "0.54609567", "0.5438152", "0.5435...
0.5568533
15
Create a new branch.
def create_branch(self, name, base_name, from_sha=False): logger.debug( 'GitHubAPI.create_branch: name={}, base_name={}'.format( name, base_name ) ) # raise an error if we can find the branch, continue if we get # a 404 try: self.get_branch(name) except requests.exceptions.HTTPError: pass else: raise DuplicateBranchError( 'Branch already started. Run' '\n\tgit fetch --all && get checkout {}'.format(name) ) if not from_sha: base = self.get_branch(base_name) base_sha = base['object']['sha'] else: base_sha = base_name try: branch_info = { 'ref': 'refs/heads/{}'.format(name), 'sha': base_sha } except KeyError: logger.error('base repsonse: {}'.format(base)) raise Exception( 'Could not locate the current SHA for '.format(base_name)) resp = self.post('git/refs', json=branch_info) try: resp.raise_for_status() except Exception: logger.error(resp.json()) raise return resp.json()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_branch(self):\n os.chdir(str(self.repository_path))\n sh.git.checkout('master')\n sh.git.checkout('-b', self.branch)\n logger.debug('Branch {} created', self.branch)", "def create_branch(ctx, name, sha):\n\n try:\n\n gh = ctx.obj.github\n\n log.echo('Creati...
[ "0.8263331", "0.77891356", "0.76186675", "0.72726834", "0.71636385", "0.7043409", "0.69660765", "0.6948939", "0.6918359", "0.6828066", "0.6820213", "0.6789778", "0.67066014", "0.660529", "0.66019213", "0.65866226", "0.6435828", "0.6376282", "0.62368584", "0.62368584", "0.6212...
0.6839864
9
Update attempt to update branch to the given SHA.
def update_branch(self, name, sha): branch_info = { 'sha': sha, } resp = self.patch('git/refs/heads/{}'.format(name), json=branch_info) try: resp.raise_for_status() except Exception: logger.error(resp.json()) raise return resp.json()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_latest_branch (product, which, main_branch):\n\n name = \"Latest_ACE7TAO3_\" + which\n\n vprint ('Fast-forwarding', name, 'to', main_branch)\n ex (\"cd $DOC_ROOT/\" + product + \" && git fetch . \" + main_branch + \":\" + name)", "def update(self, branch=None):\n if branch is None:\n ...
[ "0.62394434", "0.62033707", "0.58707505", "0.5823983", "0.57316476", "0.5548735", "0.54924744", "0.5490744", "0.54566896", "0.53568214", "0.533697", "0.53313905", "0.5318119", "0.5305053", "0.52909243", "0.52125496", "0.5172792", "0.51444185", "0.5125727", "0.5123589", "0.511...
0.70466286
0
Create a new pull request
def create_pull_request(self, base, head, title, body=None): pull_info = { 'title': title, 'head': head, 'base': base } if body: pull_info['body'] = body logger.info(pull_info) resp = self.post('pulls', json=pull_info) try: resp.raise_for_status() except Exception: logger.error(resp.json()) raise return resp.json()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_pull_request(filepath, github_account):\n repo = _git.clone_from_github(\n _repo_path(), join(filepath, _repo_name()), github_account=github_account)\n branch = ('update-discovery-artifacts-' +\n datetime.datetime.now().strftime('%Y%m%d-%H%M%S'))\n repo.checkout_new(branch)\n i...
[ "0.70592564", "0.704382", "0.6956816", "0.6912854", "0.6759392", "0.6718217", "0.67178744", "0.66204125", "0.6516321", "0.6229428", "0.61973286", "0.61781627", "0.61508805", "0.614511", "0.614511", "0.61279315", "0.61080235", "0.60647273", "0.60609627", "0.603208", "0.6000777...
0.62417126
9
Verify that the release is actually read to be released If the release is new (corresponds to a release branch), then we check that the release is merged into master. If we can not find the release branch, we assume that it is a hotfix and we verify that the major version number matches the latest release.
def check_release_status(self, release_name, release_branch): logger.debug('GitHubAPI.check_release_status args: {}; {}'.format( release_name, release_branch) ) release_version = extract_release_branch_version(release_name) release_branch_base = build_release_base_name(get_config()) # Assume that this is a new release # Check if the release branch is merged into master try: merge_status = self.compare( 'master', release_branch ).get('status') except requests.exceptions.HTTPError as e: logger.debug('HTTPError: {}'.format(e.message)) if not e.response.status_code == 404: raise e else: # can be one of diverged, ahead, behind, identical according to # http://stackoverflow.com/a/23969867 if merge_status in ['diverged', 'ahead']: raise Exception( 'Release must be merged into master before release') return # if the release branch does not exist, then we end up here, # Assume that it is a hotfix raw_version = self.latest_release().get('name', '') if raw_version.startswith(release_branch_base): raw_version = raw_version[len(release_branch_base):] version = extract_year_week_version(raw_version) logger.debug(version) if extract_year_week_version(release_version) != version: raise Exception( 'New release version does not match the current release, ' 'we expected a hotfix.' ) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_release_branch():\n diff_string_config_yml = run_command(\"git diff origin/master .circleci/config.yml\")\n if re.search(r'[+-][ ]+CONTENT_VERSION: \".*', diff_string_config_yml):\n return True\n\n return False", "def verify_tags(git_ref_target):\n latest_release = github_util.get_lates...
[ "0.69423383", "0.6784403", "0.66795766", "0.6649919", "0.6507445", "0.64944094", "0.63654304", "0.6350596", "0.6347604", "0.63336277", "0.6305721", "0.6219666", "0.62047046", "0.61802447", "0.6172858", "0.612331", "0.6118963", "0.6113204", "0.6088553", "0.60614514", "0.604839...
0.73628855
0
Evaluate the mfcc_length for a given file
def get_mfcc_length_from_duration(duration): length = int(duration // FRAME_STRIDE) - 1 return length
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wav2mfcc(file_path, max_len=44, n_mfcc=20):", "def mfcc(path, windowsize, overlap, M):\n srate, data = scipy.io.wavfile.read(path)\n\n bank = filterbank(0, srate/2, M, srate, windowsize)\n buckets = bucketize(data/32768.0, windowsize, overlap)\n energies = buckets.dot(bank.transpose())\n\n ret...
[ "0.6658678", "0.6523835", "0.6392451", "0.61464643", "0.5918345", "0.58868235", "0.5885237", "0.5809652", "0.5772686", "0.5743787", "0.57237357", "0.56915265", "0.5688", "0.5644551", "0.56252927", "0.5590044", "0.5578385", "0.55762726", "0.5562501", "0.5446046", "0.54189724",...
0.60624254
4
Reads in audio file, processes it
def process_audio_file(self, file_name): sig, sr = librosa.load(file_name, mono=True) return self._extract_function(sig, sr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_audio(f, downmix):\n if f.endswith('.mp3'):\n f = _mp3_hook(f)\n sr, audio = scipy.io.wavfile.read(f)\n if not audio.dtype is np.float32:\n audio = _normalize_pcm(audio)\n if downmix and len(audio.shape) == 2:\n audio = down_mix(audio)\n return sr, audio", "def audioR...
[ "0.7045707", "0.6956398", "0.6821181", "0.6742061", "0.6704527", "0.6699321", "0.6644113", "0.6615665", "0.64650714", "0.6453779", "0.63955903", "0.63811314", "0.63749427", "0.6367572", "0.63429946", "0.6340871", "0.633396", "0.6314544", "0.6308602", "0.6294938", "0.6285965",...
0.72694874
0
Reads in audio file, processes it
def process_signal(self, sig, sr): return self._extract_function(sig, sr)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_audio_file(self, file_name):\n sig, sr = librosa.load(file_name, mono=True)\n return self._extract_function(sig, sr)", "def read_audio(f, downmix):\n if f.endswith('.mp3'):\n f = _mp3_hook(f)\n sr, audio = scipy.io.wavfile.read(f)\n if not audio.dtype is np.float32:\n ...
[ "0.72694874", "0.7045707", "0.6956398", "0.6821181", "0.6742061", "0.6704527", "0.6699321", "0.6644113", "0.6615665", "0.64650714", "0.6453779", "0.63955903", "0.63811314", "0.63749427", "0.6367572", "0.63429946", "0.6340871", "0.633396", "0.6314544", "0.6308602", "0.6294938"...
0.0
-1
Compute log mel filterbank features with deltas and double deltas
def _extract_fbank(self, sig, sr): emphasized_signal = np.append(sig[0], sig[1:] - 0.97 * sig[:-1]) frame_length, frame_step = FRAME_SIZE * sr, FRAME_STRIDE * sr signal_length = len(emphasized_signal) frame_length = int(round(frame_length)) frame_step = int(round(frame_step)) num_frames = int(np.ceil(float(np.abs(signal_length - frame_length)) / frame_step)) pad_signal_length = num_frames * frame_step + frame_length z = np.zeros((pad_signal_length - signal_length)) pad_signal = np.append(emphasized_signal, z) indices = np.tile(np.arange(0, frame_length), (num_frames, 1)) + np.tile(np.arange(0, num_frames * frame_step, frame_step), (frame_length, 1)).T frames = pad_signal[indices.astype(np.int32, copy=False)] # Apply the hamming window function frames *= np.hamming(frame_length) nfft, nfilt = 512, 40 mag_frames = np.absolute(np.fft.rfft(frames, nfft)) pow_frames = ((1.0 / nfft) * (mag_frames ** 2)) low_freq_mel = 0 ### AI: # the following line works correcty as-is in python3 # *** high_freq_mel = (2595 * np.log10(1 + (sr / 2) / 700)) *** # however, in python it results in a smaller value of 'high_freq_mel' # as the 'sr' variable is interpreted as integer # it has minor impact on the performance of the natively trained and tested models # however, if one uses python to test the models that were created in python3 # the models show the CER drop as much as 1% absolute # the line below fixes that issue completely high_freq_mel = (2595 * np.log10(1 + (float(sr) / 2) / 700)) mel_points = np.linspace(low_freq_mel, high_freq_mel, nfilt + 2) hz_points = (700 * (10**(mel_points / 2595) - 1)) bin = np.floor((nfft + 1) * hz_points / sr) fbank = np.zeros((nfilt, int(np.floor(nfft / 2 + 1)))) for m in range(1, nfilt + 1): f_m_minus = int(bin[m - 1]) # left f_m = int(bin[m]) # center f_m_plus = int(bin[m + 1]) # right for k in range(f_m_minus, f_m): fbank[m - 1, k] = (k - bin[m - 1]) / (bin[m] - bin[m - 1]) for k in range(f_m, f_m_plus): fbank[m - 1, k] = (bin[m + 1] - k) / (bin[m + 1] - bin[m]) filter_banks = np.dot(pow_frames, fbank.T) filter_banks = np.where(filter_banks == 0, np.finfo(float).eps, filter_banks) # AI: # *** filter_banks = 20 * np.log10(filter_banks) *** # 'pow_frames' contains the power spectrum (i.e. squared magnitude) # the proper formula to convert to the logarithm scale in decibels is # 10*log10(POW), while 20*log10(MAG) is used for the un-squared magnitude # this way both formuli result in the same outcome filter_banks = 10 * np.log10(filter_banks) # Apply mean normalization filter_banks -= (np.mean(filter_banks, axis=0) + 1e-8) filter_banks = filter_banks.transpose() delta = librosa.feature.delta(filter_banks) double_delta = librosa.feature.delta(delta) fbank_feat = np.vstack([filter_banks, delta, double_delta]); fbank_feat = fbank_feat.transpose() assert np.shape(fbank_feat)[1] == 120, "input dimensions incorrect" # Truncate if audio sequence is too long fbank_length = len(fbank_feat) if fbank_length > self.max_input_seq_length: fbank_feat = fbank_feat[:self.max_input_seq_length] return fbank_feat, fbank_length
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def logMelSpectrum(input, samplingrate):\n nfft = input.shape[1]\n N = input.shape[0]\n filters = trfbank(samplingrate, nfft)\n\n # plot Mel filters\n # plt.plot(filters)\n # plt.title('Mel filters')\n # plt.show()\n\n output = np.zeros((N, filters.shape[0]))\n for j in range(filters.sha...
[ "0.6378001", "0.6166156", "0.6106605", "0.5986836", "0.59717876", "0.59704345", "0.59436226", "0.59277886", "0.59004104", "0.5880232", "0.58595026", "0.5850303", "0.5847764", "0.5805098", "0.5797871", "0.5773712", "0.57430214", "0.5730535", "0.5728411", "0.5695498", "0.569287...
0.0
-1
Create the game, SpaceInvaders. Train or test it.
def __init__ (self,gameName,total_episodes=50,train_or_test=2): #additional param:- doLoadNetwork=True self.createGame(gameName) ### Training Hyperparameters self.TOT_EPISODES = total_episodes #no. of episodes/epochs self.MAX_STEPS = 50000 #max steps taken every episode/epoch ### Preprocessing Hyperparameters self.stack_size = 4 #stacking 3 frames at once. self.stacked_frames = deque([np.zeros((84,84), dtype=np.int) for i in range(self.stack_size)], maxlen=4) ### Model self.dqn = DDQN(self.action_space) self.path = "saved.h5" # train agent or simulate the game. if train_or_test == 1: self.trainAgent() elif train_or_test == 2: #load network before simulating. self.load_network() self.simulate()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, game_name, skip_actions=4, num_frames=4, w=84, h=84):\n self.env = gym.make(game_name)\n self.num_frames = num_frames\n self.skip_actions = skip_actions\n self.w = w\n self.h = h\n\n if game_name == 'SpaceInvaders-v0':\n self.action_space=[1,2...
[ "0.6907318", "0.68599695", "0.6728783", "0.66609395", "0.6579913", "0.6554996", "0.6510835", "0.64591074", "0.64184606", "0.6393087", "0.63915473", "0.6364802", "0.6364802", "0.6364802", "0.6364802", "0.6364802", "0.6359255", "0.635703", "0.63438934", "0.6340655", "0.63222647...
0.0
-1
load the network from saved.h5
def load_network(self): self.dqn.load_network(self.path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_network(self, which_epoch):\n save_filename = '%s_net.pth' % which_epoch\n load_path = os.path.join(self.save_dir, save_filename)\n net = self.net\n if isinstance(net, torch.nn.DataParallel):\n net = net.module\n print('loading the model from %s' % load_path)\...
[ "0.71672744", "0.7150659", "0.6883396", "0.67808", "0.6710601", "0.66247654", "0.6531737", "0.64843845", "0.64828396", "0.6471173", "0.6450578", "0.64475465", "0.6441468", "0.64281887", "0.6308086", "0.6201771", "0.6194544", "0.61861485", "0.61786836", "0.61785096", "0.617107...
0.7140678
2
Train the model for a certain no of episodes
def trainAgent(self): for episode in range(self.TOT_EPISODES): #reset environment, stacked frames every episode. state = self.env.reset() rewards = 0 #preprocess and stack the frame/state. state, self.stacked_frames = stack_frames(self.stack_size, self.stacked_frames, state, True) for step in range(self.MAX_STEPS): #for every step in episode: if (step%100==0): print("Episode No.: ", episode, "Step No.: ", step) #agent acts - explores or exploitation of the model action = self.dqn.predictAction(state) #reduce epsilon for more exploitation later. self.dqn.decayEpsilon() #Perform the action and get the next_state, reward, and done vals. next_state, reward, done, _ = self.env.step(action) #append this state to the frame. Pass the previous stacked frame. next_state, self.stacked_frames = stack_frames(self.stack_size, self.stacked_frames, next_state, False) rewards+=reward #add this experience into memory (experience buffer) self.dqn.remember(state, action, reward, next_state, done) state = next_state if done: print("took %d steps" %step) print("Earned a total of reward equal to ", rewards) break # TRAIN self.dqn.replay() #sync target_model and model weights every 10k steps. if step % 10000 == 9999: self.dqn.target_train() # Save the network every 1000 iterations if episode % 5 == 4: print("Saving Network") self.dqn.save_network(self.path)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train(self, num_episodes, max_episode_steps=100, save_freq=100, render=False):\n while self.episodes_done < num_episodes:\n self.trainOneEpisode(num_episodes, max_episode_steps, save_freq, render)\n self.saveCheckpoint()", "def train(self, training_steps=10):", "def train(\n ...
[ "0.75523275", "0.743832", "0.74258286", "0.7422637", "0.7364126", "0.73365295", "0.73187625", "0.72586364", "0.7242011", "0.7233209", "0.72105044", "0.7161378", "0.71507365", "0.713142", "0.71212167", "0.71001995", "0.7051916", "0.7029939", "0.7000444", "0.6976201", "0.693145...
0.66573066
38
Test the agen and watch it play for one episode.
def simulate(self): print("##################################") print("SIMULATING GAME - SpaceInvaders..") print("##################################") # Play 3 episodes: for i in range(3): print("Playing Episode %d" % i) state = self.env.reset() #self.env.render() done = False tot_reward = 0 state,_ = stack_frames(self.stack_size,self.stacked_frames, state, True) # play until dead. while not done: # get the value predicted by the model and perform that action. # keras conv2d expects a 4D input. So add an empty axis. state = np.expand_dims(state, axis=0) # predict action directly from the saved neural network. action = np.argmax(self.dqn.getModel().predict(state)[0]) # perform that action. state, reward, done, _ = self.env.step(action) self.env.render() state,_ = stack_frames(self.stack_size,self.stacked_frames, state, False) tot_reward+=reward print("Reward: ", tot_reward) self.env.close() # to avoid sys.meta_path error
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test():\n env = gym.make('CartPole-v1')\n\n results = []\n for _ in range(100):\n results.append(episode(env, render=False, verbose=False))\n\n print(f'average={sum(results) / len(results)} '\n f'max={max(results)} '\n f'min={min(results)}')", "def test_scraper(self):\n ...
[ "0.6574454", "0.64675266", "0.6428111", "0.6335772", "0.6264014", "0.6199133", "0.6197816", "0.6196485", "0.6193701", "0.6170308", "0.6169579", "0.61569935", "0.61476463", "0.60803", "0.6072124", "0.60470563", "0.6037859", "0.6029739", "0.60170627", "0.60096955", "0.59748065"...
0.0
-1
This function is called to check if a username / password combination is valid.
def check_auth(username, password): return (username == app.config['USERNAME'] and password == app.config['PASSWORD'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_auth(username, password, expected_user, expected_pw):\n return username == expected_user and password == expected_pw", "def validate_authentication(self, username, password):\n return self.user_table[username]['pwd'] == password", "def check_auth(username, password):\n return usernam...
[ "0.82211864", "0.8146436", "0.7975914", "0.7962432", "0.7885527", "0.78588223", "0.78382313", "0.78288996", "0.7815222", "0.7798579", "0.77856815", "0.77700555", "0.7760794", "0.7754975", "0.77548647", "0.7750886", "0.7749223", "0.77322245", "0.7715806", "0.7685904", "0.76736...
0.7687129
19
Sends a 401 response that enables basic auth
def authenticate(): return Response(render_template('index.html', auth=False), 401, {'WWW-Authenticate': 'Basic realm="Login Required"'})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})", "def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )", "def authenticate():\n return Response(\n 'You have to login with pro...
[ "0.8093736", "0.80926424", "0.7958403", "0.7852648", "0.7843114", "0.7824419", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", "0.7810746", ...
0.76140213
41
Check if no user login
def require_visitor(func): @wraps(func) def decorator(*args, **kwargs): if g.user: return redirect(url_for('site.home')) return func(*args, **kwargs) return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_user_and_login(self) -> Response:\n pass", "def check_auth_none(self, username):\n return AUTH_FAILED", "def check_user_logged():\n global user\n if 'user' not in session:\n return False\n else:\n user = session.get('user')\n return user['username'] != ''", "...
[ "0.7631167", "0.7377581", "0.7348826", "0.7320364", "0.72438157", "0.7098895", "0.70730084", "0.70391387", "0.6981259", "0.6977111", "0.6969315", "0.6933913", "0.69154346", "0.6907214", "0.6865833", "0.6815512", "0.6799823", "0.67882526", "0.67734057", "0.67627156", "0.670679...
0.0
-1
Check if user login
def require_user(func): @wraps(func) def decorator(*args, **kwargs): if not g.user: # flash('此操作需要登录账户') return render_template('account/error.html', error='抱歉,您无权进行该操作!') # return redirect(url_for('site.login')) return func(*args, **kwargs) return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_user_and_login(self) -> Response:\n pass", "def is_correct_user(self, login, password):\n pass", "def check_user_logged():\n global user\n if 'user' not in session:\n return False\n else:\n user = session.get('user')\n return user['username'] != ''", "def log...
[ "0.8381395", "0.8055585", "0.7813263", "0.7678583", "0.7649151", "0.7576734", "0.7567418", "0.7521423", "0.75094885", "0.7488563", "0.74643886", "0.7460811", "0.7460811", "0.7443086", "0.7417814", "0.74102914", "0.7391327", "0.73445153", "0.73423046", "0.72956836", "0.7277331...
0.0
-1
Check if mobile user login
def require_mobile_user(func): @wraps(func) def decorator(*args, **kwargs): if not g.user: return redirect(url_for('wechat.signin')) return func(*args, **kwargs) return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_mobile(request):\n MOBILE_AGENT_RE=re.compile(r\".*(iphone|mobile|androidtouch)\",re.IGNORECASE)\n\n if MOBILE_AGENT_RE.match(request.META['HTTP_USER_AGENT']):\n return True\n else:\n return False", "def mobile(request):\n MOBILE_AGENT_RE = re.compile(\n r\".*(iphone|mo...
[ "0.6898011", "0.689399", "0.6369667", "0.635195", "0.63429105", "0.63109106", "0.62703073", "0.6228723", "0.62186426", "0.6195903", "0.6157435", "0.61390567", "0.6046515", "0.60213834", "0.5956583", "0.59477335", "0.5935797", "0.5915573", "0.58781195", "0.58594924", "0.585450...
0.6534018
2
Check if user is admin
def require_admin(func): @wraps(func) def decorator(*args, **kwargs): if not g.user: # flash('此操作需要登录账户') return redirect(url_for('admin.login')) if g.user.name != 'admin': abort(403) return func(*args, **kwargs) return decorator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_is_admin(user):\n return user in admins", "def is_admin(user):\n return user.is_authenticated and user.id == app.config.get('ADMIN')", "def is_admin(self, user):\n return user.name in self.admins", "def is_admin_user(self):\n if \"is_admin\" in self._properties and self.is_ad...
[ "0.8688236", "0.8687356", "0.8556875", "0.8554287", "0.85044616", "0.84716874", "0.8450938", "0.841185", "0.84050906", "0.8394017", "0.8363089", "0.83423585", "0.83161926", "0.8280715", "0.82797027", "0.82743096", "0.82743096", "0.8248748", "0.82192075", "0.8196186", "0.81672...
0.0
-1
r""" Return the ``d x d`` identity matrices on ``nvar`` variables.
def symbolic_max_plus_identity(d, nvar, ch=None): d = int(d) nvar = int(nvar) V = FreeModule(ZZ, nvar) e = () zero = (V([0]*nvar),) data = [[zero if i == j else e for j in range(d)] for i in range(d)] return SymbolicMaxPlusMatrix(d, nvar, data, ch)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def identity_matrix(self, n):\r\n IdM = self.zeros_matrix(n, n)\r\n for i in range(n):\r\n IdM[i][i] = 1.0\r\n \r\n return IdM", "def identity(n):\r\n I = np.zeros((n, n))\r\n diag = np.ones(n)\r\n np.fill_diagonal(I, diag)\r\n return matrix(I)", "d...
[ "0.6807005", "0.63776374", "0.63734645", "0.63494134", "0.6294045", "0.6278014", "0.6278014", "0.61580557", "0.61580557", "0.61580557", "0.615476", "0.6121155", "0.6051036", "0.601457", "0.58180785", "0.5777933", "0.57341456", "0.5717382", "0.5687784", "0.5684385", "0.5680099...
0.0
-1
r""" Return ``n`` independent symbolic matrices in dimension ``d``.
def symbolic_max_plus_matrices(d, n, ch=None, typ='sym'): d = int(d) n = int(n) if d <= 0: raise ValueError("d (= {}) must be postive".format(d)) nvar = n * d * d V = FreeModule(ZZ, nvar) B = ((b,) for b in V.basis()) matrices = [] if d == 1: typ = 'full' if typ == 'sym' or typ == 'quick': z = [0]*nvar for i in range(n): z[i*d*d] = 1 diag = (V(z),) z[i*d*d] = 0 z[i*d*d+1] = 1 nondiag = (V(z),) z[i*d*d+1] = 0 if typ == 'sym': matrices.append(SymbolicSymmetricMaxPlusMatrix(d, n, diag, nondiag, ch)) else: matrices.append(QuickSymbolicSymmetricMaxPlusMatrix(d, n, diag, nondiag, ch)) elif typ == 'full': for i in range(n): mat = [] for j in range(d): mat.append([next(B) for k in range(d)]) matrices.append(SymbolicMaxPlusMatrix(d, nvar, mat, ch)) else: raise ValueError return matrices
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def basis(d, symbolic=True):\n X = sym.symbols('X')\n if d == 0:\n phi_sym = [1]\n else:\n if symbolic:\n h = sym.Rational(1, d) # node spacing\n nodes = [2*i*h - 1 for i in range(d+1)]\n else:\n nodes = np.linspace(-1, 1, d+1)\n \n phi_sym = [Lagrange_poly...
[ "0.59795463", "0.5888374", "0.57391495", "0.5711324", "0.5686454", "0.5563071", "0.5492323", "0.5435326", "0.5423058", "0.5419523", "0.54059994", "0.5392236", "0.538575", "0.5366352", "0.5356909", "0.53455615", "0.5337914", "0.5334625", "0.5330213", "0.53227186", "0.53154725"...
0.58973736
1
r""" Return a string that describes the convex hull engine.
def convex_hull_engine(self): return self.convex_hull._name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _repr_(self):\n desc = ''\n if self.n_vertices()==0:\n desc += 'The empty polyhedron'\n else:\n desc += 'A ' + repr(self.dim()) + '-dimensional polyhedron'\n desc += ' in '\n if self.field()==QQ: desc += 'QQ'\n else: desc += 'RDF'\n...
[ "0.66425604", "0.63532376", "0.6281747", "0.60994506", "0.60871357", "0.5944821", "0.5937618", "0.5842721", "0.5841963", "0.5745582", "0.57072836", "0.5683671", "0.5624012", "0.5577006", "0.55180144", "0.54937017", "0.5490255", "0.5487594", "0.54810053", "0.5431776", "0.54206...
0.75023854
0
r""" Return the dimension of this matrix.
def dim(self): return self._d
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dimension(self):\n return self.__N", "def get_num_dimensions(self):\n dimensions = self.data.shape\n return dimensions[1]", "def dim(self):\n return len(self.shape)", "def dim(self):\n return len(self.shape)", "def dimensionality(self):\n return int(self.nDims)...
[ "0.84898525", "0.84692967", "0.83745944", "0.83745944", "0.8322008", "0.8309151", "0.8180309", "0.81371695", "0.8114333", "0.8109193", "0.8031762", "0.8031762", "0.8015657", "0.7960735", "0.7944764", "0.7926571", "0.79092103", "0.78969157", "0.787916", "0.78600526", "0.778453...
0.7624366
52
r""" Return the number of variables used in this matrix.
def num_vars(self): return self._nvars
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_num_variables(self):\n return len(self.variables)", "def num_vars(self):\n return self.nvars", "def nvar(self):\n return len(self.__vars)", "def GetNumberOfVariables(self):\n\n # nvar = 0\n # for i in self.variables_order:\n # # DO NOT COUNT VARIABLES THAT GE...
[ "0.826646", "0.80817354", "0.79613394", "0.7953327", "0.79433763", "0.7778536", "0.7749949", "0.75871086", "0.74991745", "0.74765337", "0.74339026", "0.72988725", "0.71537995", "0.71156085", "0.7080469", "0.69808406", "0.691234", "0.67460585", "0.6729376", "0.6723816", "0.671...
0.8000086
2
r""" To obtain an item of the matrix
def __getitem__(self, data): i,j = data return self._data[i][j]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, item):\n if type(item) is int:\n # select row by default\n if self.shape[0] == 1: # iterate by column if it's a row vector\n return self.values[0][item]\n elif self.shape[1] == 1: # iterate by row if it's a column vector\n ...
[ "0.75138944", "0.7311626", "0.7112711", "0.7027379", "0.69761306", "0.68627983", "0.6828977", "0.6801616", "0.67811024", "0.6719613", "0.6719613", "0.6719613", "0.6648522", "0.6594458", "0.6576159", "0.65010285", "0.64954424", "0.6479522", "0.6468668", "0.6449649", "0.6440751...
0.61327946
42
r""" Multiplication of matrices
def __mul__(self, other): if type(self) != type(other) and \ not isinstance(self, SymbolicMaxPlusMatrix) and \ not isinstance(other, SymbolicMaxPlusMatrix): raise TypeError("can not multiply {} with {}".format(type(self),type(other))) if self._d != other._d: raise TypeError("dimension or number of variable mismatch") d = self._d new_data = [[None]*d for _ in range(d)] for i in range(d): for j in range(d): vertices = set() for k in range(d): l = [x+y for x in self[i,k] for y in other[k,j]] for v in l: v.set_immutable() vertices.update(l) new_data[i][j] = self.convex_hull(vertices) return SymbolicMaxPlusMatrix(d, self._nvars, tuple(new_data), self.convex_hull)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matrix_mult(m1, m2):\n pass", "def Multiply(M1,M2):\r\n M3=[]\r\n w=0\r\n while w<len(M2[0]):\r\n tap=[]\r\n t=0\r\n while t<len(M2):\r\n tap.append(M2[t][w])\r\n t=t+1\r\n M3.append(tap)\r\n w=w+1\r\n M=[]\r\n # Multiplying matrices\r...
[ "0.839403", "0.77877283", "0.7786913", "0.76345795", "0.7578386", "0.752093", "0.7499151", "0.7495682", "0.74534243", "0.7433087", "0.74056447", "0.73597676", "0.7326738", "0.732322", "0.7322675", "0.731054", "0.72843087", "0.7257866", "0.72538614", "0.7223289", "0.7222726", ...
0.0
-1
r""" Return the list of entries of this matrix.
def list(self): return [self[i,j] for i in range(self._d) for j in range(self._d)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def as_list(self):\n data = []\n for row in self._matrix_data:\n for column in row:\n data.append(column)\n return data", "def rows(self):\n return list(self)", "def as_list_of_lists(self):\n return self._matrix_data", "def readentries(self):\n ...
[ "0.74211484", "0.7351907", "0.7139602", "0.7107239", "0.7102002", "0.7040875", "0.700234", "0.700234", "0.69514894", "0.6915959", "0.6805772", "0.68021935", "0.67886513", "0.6775163", "0.6770315", "0.6736421", "0.67067957", "0.66475236", "0.6628927", "0.66164464", "0.65946597...
0.69504046
9
r""" Return the list of equal coefficients between self and other.
def equal_coefficients(self, other): d = self._d return [(i,j) for i in range(d) for j in range(d) \ if self[i][j] == other[i][j]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __xor__(self, other):\n\n sym_diff = [value for value in self if value not in other]\n sym_diff.extend([value for value in other if value not in self])\n\n return sym_diff", "def GetEqualConstrains(self):\n return _gmat_py.Spacecraft_GetEqualConstrains(self)", "def coefficients(...
[ "0.66310555", "0.6198817", "0.61889756", "0.5865301", "0.5818835", "0.5683608", "0.5683608", "0.56740135", "0.5648324", "0.56273437", "0.56273437", "0.5593266", "0.55242145", "0.5514569", "0.546532", "0.5455155", "0.5414487", "0.5409538", "0.5363544", "0.53480685", "0.5334692...
0.78071773
0
r""" String when the object is printed
def _repr_(self): return 'A {}x{} symbolic max plus matrix on {} variables'.format( self.dim(), self.dim(), self.num_vars())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __str__(self):\n return self.printable()", "def __str__(self):\r\n return repr(self)", "def __str__(self):\n return repr(self)", "def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())", "def __str__(self):\n return_string = self.name + \"\\n\" +...
[ "0.8097469", "0.78782415", "0.77841264", "0.7769064", "0.7669302", "0.76466906", "0.76466906", "0.7623327", "0.75980204", "0.75980204", "0.75980204", "0.75980204", "0.7578883", "0.7571893", "0.75686365", "0.75658494", "0.7563032", "0.7543171", "0.7536491", "0.7536491", "0.753...
0.0
-1
r""" Evaluates this symbolic matrix at the integer point ``p``.
def eval(self, p): from max_plus.max_plus_int import minus_infinity, IntegerMaxPlusMatrix F = FreeModule(ZZ, self._nvars) p = F(p) mat = [] d = self.dim() for i in range(d): row = [] for j in range(d): pts = self[i,j] row.append(minus_infinity() if not pts else max(p.dot_product(v) for v in pts)) mat.append(row) return IntegerMaxPlusMatrix(self._d, self._d, mat)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluate(self,p):\n if not self.initialized: self.__initialize__()\n if self.vp0: p_ = 1-p\n else: p_ = p\n if self.ids_to_consider is None:\n #sum on all parametrized cell\n cf = np.sum(self.V[self.p_ids-1]*p_)/self.V_tot - self.max_v_frac\n else:\n cf = np.sum((self.V[self.ids_t...
[ "0.6590414", "0.64902985", "0.5803352", "0.576456", "0.56841123", "0.56735307", "0.5545928", "0.54923505", "0.54681116", "0.5413606", "0.5399578", "0.5339681", "0.5316676", "0.53084254", "0.5288867", "0.525981", "0.52447516", "0.5244498", "0.5217221", "0.521235", "0.5206362",...
0.6615458
0
r""" Return the dimension of the affine space spanned generated by each Newton polytopes. for triangular matrices, seems to stay 0 on the diagonal.
def get_vector_span(self, i, j): from sage.rings.infinity import Infinity from sage.matrix.constructor import matrix data = self[i,j] if not data: return None elif len(data) == 1: return FreeModule(ZZ, self._nvars).submodule([]) else: return matrix([x-data[0] for x in data]).row_space()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dim(self) -> int:", "def getlen(self):\n if self.onlydiag():\n return self.lendiag()\n else:\n return len(self)", "def dimension(self):\n return 3*self.genus - 3 + self.n", "def dim(self) -> int:\n return self.atoms.shape[:-1]", "def dimension(self):\r\...
[ "0.67515165", "0.67112654", "0.6535919", "0.653394", "0.64353853", "0.6379742", "0.63764715", "0.63629043", "0.63574785", "0.63428813", "0.62986326", "0.6278618", "0.62567246", "0.62425613", "0.6237966", "0.6212587", "0.6183233", "0.61782753", "0.61762774", "0.61756885", "0.6...
0.0
-1
r""" Permutations (i1,j1) > (i2,j2) Make an exchange of rows/columns in matrix data. This is used in multiplication of full symbolic matrices.
def vertex_swap(d, n, l, i1, i2, j1, j2): if i1 == i2 and j1 == j2: return l if i1 == j1: # (i1,i1) -> (i2,i2) assert i2 == j2 def swap(v): swap2(d, n, v, i1, i2) elif i1 == i2: # (i,j1) -> (i,j2) def swap(v): swap2(d, n, v, j1, j2) elif j1 == j2: # (i1,j) -> (i2,j) def swap(v): swap2(d, n, v, i1, i2) elif i1 == j2 and i2 == j1: # (i1,j1) -> (j1,i1) def swap(v): swap2(d, n, v, i1, j1) elif i1 == j2: # (i1,j1) -> (i2,i1) def swap(v): swap3(d, n, v, j1, i1, i2) elif i2 == j1: # (i1,j1) -> (j1,j2) def swap(v): swap3(d, n, v, i1, j1, j2) else: # (i1,j1) -> (i2,j2) def swap(v): swap2(d, n, v, i1, i2) swap2(d, n, v, j1, j2) ll = [] for v in l: v = v.__copy__() swap(v) v.set_immutable() ll.append(v) ll.sort() return tuple(ll)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def swap_columns(i, j, *args):\n output = list()\n for M in args:\n output.append(_cswap(i, j, M))\n return output", "def swap_rows(i, j, *args):\n output = list()\n for M in args:\n output.append(_rswap(i, j, M))\n return output", "def return_swaps( # pylint: disable=too-many-...
[ "0.6260572", "0.61407316", "0.60737467", "0.58037573", "0.5779625", "0.5728096", "0.56909776", "0.5626455", "0.5626066", "0.55842173", "0.5571164", "0.5571073", "0.5566883", "0.55655205", "0.55617666", "0.5537897", "0.55265135", "0.5522779", "0.55212414", "0.5504172", "0.5502...
0.0
-1