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
this function serves to initialize the ROS node
def startNode(): # init node rospy.init_node("resize_and_repub") rospy.loginfo("resize_and_repub node started") # setup subcribers rospy.Subscriber(leftArmCamTopic, Image, leftArmImageCallback) rospy.Subscriber(headCamTopic, Image, headImageCallback) rospy.Subscriber(primaryCamTopic, String, primaryCamCallback) rospy.Subscriber(secondaryCamTopic, String, secondayCamCallback) rospy.loginfo("all subscribers initialized, entering publishing loop...") # start repub thread thread = threading.Thread(target=resizeAndRepubThread) thread.start() rospy.spin()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_ros_node(self): #pylint: disable=no-self-use\n print(\"rospy init node\")\n rospy.init_node('ispy_ROS_receiver', anonymous = True)", "def initNode():\n\n # 0) General Setup\n #initialize listener node!\n rospy.init_node('main', anonymous=True)\n\n #Create instances of subscribe...
[ "0.8261381", "0.7474935", "0.73012865", "0.7279841", "0.6911988", "0.6786043", "0.67791384", "0.67517745", "0.6729871", "0.6711965", "0.66651976", "0.66531044", "0.66189027", "0.6601425", "0.6570407", "0.6547083", "0.6542969", "0.65383095", "0.65187514", "0.65016264", "0.6483...
0.6678193
10
Checkout code for CESM If sandbox exists, check that the right tag has been checkedout. Otherwise, download the code, checkout the tag and run manage_externals. The scripts don't seem to like multiple applications of manage_externals.
def code_checkout(cesm_repo, coderoot, tag): sandbox = os.path.split(coderoot)[-1] if os.path.exists(coderoot): print('Check for right tag: '+coderoot) p = Popen('git status', shell=True, cwd=coderoot, stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate() stdout = stdout.decode('UTF-8') stderr = stderr.decode('UTF-8') print(stdout) print(stderr) if tag not in stdout.split('\n')[0]: raise ValueError('tag does not match') else: stat = check_call(['mkdir', '-p', coderoot]) if stat != 0: sys.exit(1) # clone the repo p = Popen('git clone '+cesm_repo+' '+sandbox, shell=True, cwd=coderoot+'/..', stdout=PIPE, stderr=PIPE) stdout, stderr = p.communicate() if stdout: print(stdout) if stderr: print(stderr) if p.returncode != 0: raise Exception('git error') # check out the right tag p = Popen('git checkout %s'%tag, shell=True, cwd=coderoot) stdout, stderr = p.communicate() if stdout: print(stdout) if stderr: print(stderr) if p.returncode != 0: raise Exception('git error') # check out externals p = Popen('./manage_externals/checkout_externals -v', shell=True, cwd=coderoot) stdout, stderr = p.communicate() if stdout: print(stdout) if stderr: print(stderr) if p.returncode != 0: raise Exception('git error')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n sandbox = create_sandbox()\n directory = download_package_to_sandbox(\n sandbox,\n 'https://pypi.python.org/packages/source/c/checkmyreqs/checkmyreqs-0.1.6.tar.gz'\n )\n print(directory)\n destroy_sandbox(sandbox)", "def checked_out_MPS():\n\n checked_out_packages = ...
[ "0.57098264", "0.5443898", "0.52824104", "0.5211898", "0.50929743", "0.5078513", "0.5051536", "0.50458026", "0.5009098", "0.50035506", "0.49857637", "0.49795955", "0.490863", "0.4892152", "0.4889629", "0.4881726", "0.48687592", "0.48336747", "0.4761207", "0.47558445", "0.4754...
0.6543128
0
Test adding basic InputNode
def test0_init(self): print("\nTest 0: Initialization") builder = StaticBuilder() in1_name = builder.addInput(10) in1 = builder.input_nodes[in1_name] print('Node keys in builder:', list(builder.input_nodes.keys())) self.assertEqual(in1.label, 0, "The label has not been assigned correctly") self.assertEqual(builder.num_nodes, 1, "The number of nodes has not been " "assigned correctly") self.assertEqual(in1.num_declared_outputs, 0, "The number of outputs of " "the InputNode has not been assigned correctly") self.assertEqual(in1.num_declared_inputs, 0, "The number of outputs of " "the InputNode has not been assigned correctly")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testInputDesc(self):\n\n self.assertTrue(\n hasattr(self.node, 'input_desc')\n )\n\n self.assertEqual(\n None,\n self.node.input_desc\n )", "def test_addOutput(self):\n print(\"\\nTest 2: Adding OutputNode\")\n builder = StaticBuilder()\n ...
[ "0.6525281", "0.6475737", "0.6424497", "0.6410956", "0.6354569", "0.63182724", "0.62617815", "0.62125105", "0.61966574", "0.60417753", "0.6039684", "0.60300416", "0.59842473", "0.59750694", "0.5963595", "0.59632045", "0.59500754", "0.59398043", "0.58992374", "0.58532447", "0....
0.6362094
4
Test adding basic Deterministic InnerNode.
def test_addInner(self): print("\nTest 1: Adding InnerNode") try: builder = StaticBuilder() builder.addInput(10, name="In") enc_name = builder.addInner(3, name="In") except AttributeError: print("\nCAUGHT! Trying to assign the same name to two nodes! " "AttributeError exception\n") builder = StaticBuilder() builder.addInput(10, name="In") enc_name = builder.addInner(3, name="Det") enc1 = builder.nodes[enc_name] print('\nNode keys in builder:', list(builder.nodes.keys())) print("This node's key:", enc_name) self.assertEqual(enc1.label, 1, "The label has not been assigned correctly") self.assertEqual(builder.num_nodes, 2, "The number of nodes has not been " "assigned correctly") self.assertEqual(enc1.num_declared_outputs, 0, "The number of outputs of the " "DeterministicNode has not been assigned correctly") self.assertEqual(enc1.num_declared_inputs, 0, "The number of inputs of the " "DeterministicNode has not been assigned correctly")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_znode(self):\n z = self.test_start_empty()\n self.test_start_one_value(z)", "def test_add_new_child(self):\n root = netapp_api.NaElement('root')\n self.mock_object(netapp_api.NaElement,\n '_convert_entity_refs',\n return_val...
[ "0.634626", "0.61077243", "0.60818183", "0.6013245", "0.5986549", "0.597251", "0.595647", "0.58965737", "0.5876589", "0.5845326", "0.5809255", "0.5755622", "0.5737071", "0.5720968", "0.5700372", "0.5690431", "0.56798387", "0.56767136", "0.56564647", "0.5654355", "0.56480926",...
0.751408
0
Test adding basic OutputNode
def test_addOutput(self): print("\nTest 2: Adding OutputNode") builder = StaticBuilder() builder.addInput(10, name="In") builder.addInner(3, name="Det") o_name = builder.addOutput(name="Out") o1 = builder.nodes[o_name] print("\nNode keys in builder:", list(builder.nodes.keys())) print("This node's key:", o_name) self.assertEqual(o1.label, 2, "The label has not been assigned correctly") self.assertEqual(builder.num_nodes, 3, "The number of nodes has not been " "assigned correctly") self.assertEqual(o1.num_declared_outputs, 0, "The number of outputs of the " "OutputNode has not been assigned correctly") self.assertEqual(o1.num_declared_inputs, 0, "The number of inputs of the " "OutputNode has not been assigned correctly")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_node_outputs(self):\n pass", "def addOutputsNode():\n return render_template(\"addOutputsNode.html\")", "def testNewOutputModule(self):\n manager.OutputManager.RegisterOutput(TestOutput)\n\n output_module = manager.OutputManager.NewOutputModule('test_output')\n self.assertIsInst...
[ "0.75490946", "0.666691", "0.63000286", "0.6119677", "0.6104275", "0.6039189", "0.59738773", "0.5940442", "0.5934479", "0.5925732", "0.5917337", "0.5912333", "0.5910766", "0.58941495", "0.5879698", "0.5866728", "0.5860062", "0.5858629", "0.58093554", "0.5797671", "0.57790154"...
0.78752226
0
Test building the simplest model possible.
def test_BuildModel0(self): print("\nTest 4: Building a Basic Model") builder = StaticBuilder(scope="Basic") in_name = builder.addInput(10) enc_name = builder.addInner(3) out_name = builder.addOutput() builder.addDirectedLink(in_name, enc_name) builder.addDirectedLink(enc_name, out_name) self.assertEqual(builder.num_nodes, 3, "The number of nodes has not been " "assigned correctly") builder.build() inn, enc, out = ( builder.nodes[in_name], builder.nodes[enc_name], builder.nodes[out_name] ) self.assertEqual(inn._oslot_to_otensor[0].shape.as_list()[-1], enc._islot_to_itensor[0].shape.as_list()[-1], "The input tensors have not been assigned correctly") self.assertEqual(enc._oslot_to_otensor[0].shape.as_list()[-1], out._islot_to_itensor[0].shape.as_list()[-1], "The input tensors have not been assigned correctly")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_build_model(arguments):\n ...", "def test_quick_build(self):\n pass", "def test_quick_build1(self):\n pass", "def test_simple_creation():\n # Get model file\n create.main(\"mlp\", \"10:12:8\", \"model_test.tar\")", "def test_model():\n pass", "def test_BuildModel3(self)...
[ "0.74242914", "0.7226327", "0.705865", "0.70076", "0.70002264", "0.6796702", "0.6709102", "0.6660882", "0.656199", "0.6525237", "0.6459824", "0.6387487", "0.63846844", "0.635007", "0.63139594", "0.63126516", "0.630687", "0.62744576", "0.6251773", "0.6231023", "0.62173486", ...
0.70569456
3
Test building a model with 2 outputs. Test Cloning an output
def test_BuildModel1(self): print("\nTest 5: Building a Model with cloning") builder = StaticBuilder("Clone") in1 = builder.addInput(10) enc1 = builder.addInner(3) out1 = builder.addOutput(name="Out1") out2 = builder.addOutput(name="Out2") builder.addDirectedLink(in1, enc1) builder.addDirectedLink(enc1, out1) builder.addDirectedLink(enc1, out2) builder.build()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_default_output_2():\n #input_file = os.path.join('.', 'test_files', 'test.input')\n actual = os.path.join('.', 'test_files', 'rc_actual.out')\n times = list(range(0, 30, 5))\n inputs = {\"names\": ['V'],\n \"values\": [\n [1],\n [0],\n ...
[ "0.6694175", "0.6504223", "0.63788325", "0.6321789", "0.6308089", "0.6245688", "0.6215992", "0.61850905", "0.6116955", "0.6110523", "0.609222", "0.6081803", "0.60653377", "0.6058217", "0.6056005", "0.6037613", "0.60202926", "0.5977124", "0.5976717", "0.59375304", "0.59170985"...
0.7202675
0
Builds a model with 2 inputs. Test ConcatNode
def test_BuildModel2(self): print("\nTest 6: Building a Model with Concat") builder = StaticBuilder("Concat") in1 = builder.addInput(10) in2 = builder.addInput(20) enc1 = builder.addInner(3, num_islots=2) out1 = builder.addOutput() builder.addDirectedLink(in1, enc1, islot=0) builder.addDirectedLink(in2, enc1, islot=1) builder.addDirectedLink(enc1, out1) builder.build()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def concat_model():\n x = tf.keras.Input(shape=[10, 10, 3, ])\n x1 = tf.keras.layers.Conv2D(5, (2, 2))(x)\n x2 = tf.keras.layers.Conv2D(6, (2, 2))(x)\n x3 = tf.keras.layers.Conv2D(7, (2, 2))(x)\n z = tf.keras.layers.concatenate([x2, x1, x3], axis=-1)\n z1 = tf.keras.layers.Conv2D(10, (2, 2))(z)\n...
[ "0.6844526", "0.6768665", "0.66675013", "0.65246445", "0.6511792", "0.6232399", "0.6185943", "0.61621577", "0.60782385", "0.60532033", "0.6042736", "0.6000108", "0.5988612", "0.59775037", "0.5974451", "0.5970998", "0.59662324", "0.59449714", "0.59398437", "0.58934414", "0.588...
0.77477473
0
Try to break it, the algorithm... !! Guess not mdrfkr.
def test_BuildModel3(self): print("\nTest 7: Building a more complicated Model") builder = StaticBuilder("BreakIt") in1 = builder.addInput(10) in2 = builder.addInput(20) enc1 = builder.addInner(3) enc2 = builder.addInner(5, num_islots=2) out1 = builder.addOutput() out2 = builder.addOutput() builder.addDirectedLink(in1, enc1) builder.addDirectedLink(in2, enc2, islot=0) builder.addDirectedLink(enc1, enc2, islot=1) builder.addDirectedLink(enc1, out1) builder.addDirectedLink(enc2, out2) builder.build()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_guessing(self):\n self.classifier.guess(self.message)", "def play(self):\n print(\"Game is starting!!\")\n self.generate_secret_number()\n while True:\n self.get_guess_from_user()\n self.ans = self.compare_results()\n if self.ans:\n ...
[ "0.6238723", "0.62207544", "0.5964192", "0.594622", "0.5904978", "0.5902772", "0.585103", "0.581829", "0.5811916", "0.57857025", "0.5780752", "0.57535255", "0.57274103", "0.5718406", "0.57046616", "0.5671099", "0.5660733", "0.5626499", "0.56193167", "0.56131303", "0.5610858",...
0.0
-1
Given the IP ADDRESS of the camera, to which you are connected and ACQUISITION MODE into which you want to put the camera, this command will send the according request to the camera.
def command(mode, ip, log): logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging_config[log]) # Using the default dict to get a valid format string no matter what phantom_socket = PhantomSocket(ip) phantom_socket.connect() click.echo('CONNECTED TO THE PHANTOM CAMERA') mode_identifier = _modes[mode] phantom_socket.set_mode(mode_identifier) click.echo('PHANTOM WILL TRANSIT INTO THE MODE "%s" NOW!' % mode_identifier) click.echo('THIS WILL CAUSE A REBOOT OF THE CAMERA, SO PLEASE HAVE PATIENCE') click.echo('IN CASE A CONNECTION CANNOT BE ESTABLISHED EVEN AFTER SOME TIME, HARD RESET THE CAMERA') click.echo('AFTER THE HARD RESET, THE MODE SHOULD BE CHANGED') phantom_socket.disconnect()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def camera_control(camera_host, camera_port, camera_user, camera_pass, q):\n\n try:\n camera = IPCamera(camera_host, camera_port, camera_user, camera_pass)\n q.put(camera.get_rtsp_url())\n except RuntimeError as exc:\n q.put(exc)\n\n try:\n while True:\n camera.move_...
[ "0.657208", "0.59614706", "0.5739002", "0.5577688", "0.5528365", "0.5405239", "0.54035485", "0.5352449", "0.5316245", "0.53074706", "0.5200834", "0.5174972", "0.51566505", "0.51535857", "0.50904423", "0.50857383", "0.50825894", "0.5082426", "0.507766", "0.5062548", "0.5052165...
0.689005
0
Attempts to insert the supplied genome. If the genome is inserted, this method will return True, otherwise it will return False.
def try_insert_genome(self, genome): raise Exception("called abstract insert_genome method")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inserted(self):\n return True", "def insert(self, row):\n if not self.loaded:\n print(\"Database is not loaded\")\n return False\n\n self.rows.append(row)\n return True", "def _can_insert(self, index, value):\n return not bool(self._insert_callback(i...
[ "0.6346422", "0.6159592", "0.60494566", "0.57980555", "0.578149", "0.57695425", "0.5667096", "0.56136864", "0.5602667", "0.5582492", "0.5562881", "0.5556916", "0.55056053", "0.54988134", "0.54925364", "0.54842436", "0.5480843", "0.547767", "0.54687303", "0.54569113", "0.54469...
0.8167088
0
list of necessary ciphers objects
def ciphers_obj(self): if self.esp_enc_alg == "ENCR_AES_GCM_16_IIV": ## BEGIN code to update return [ AES.new(self.esp_enc_key,AES.MODE_GCM, nonce=self.nonce)] ## END code to update raise UnsupportedEncAlgError(sa.esp_enc_alg, "unsupported")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_all_cipher():\n return OpenSSL.cipher_algo.keys()", "def ciphers(self):\n return self._ciphers", "def ciphers(self) -> Sequence[str]:\n return pulumi.get(self, \"ciphers\")", "def ciphers(self) -> Sequence[str]:\n return pulumi.get(self, \"ciphers\")", "def list_ciphers(...
[ "0.7565985", "0.7461285", "0.7372469", "0.7372469", "0.7340704", "0.66134185", "0.6335098", "0.63059235", "0.60204273", "0.59899426", "0.58400655", "0.5778174", "0.57402366", "0.5726471", "0.5650689", "0.56054634", "0.56048346", "0.5511376", "0.55048597", "0.5406176", "0.5400...
0.7322964
5
Creates useful information compiled from protein dictionary
def __init__(self, proteins_dict): self.proteins_dict = proteins_dict self.proteins = list(proteins_dict.keys())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_info_dict():\n\n d = {\n \"PRED\": {\n \"COLUMN\": [\"predicted_class\"],\n \"Number\": \"1\",\n \"Type\": \"String\",\n \"Description\": \"Predicted class: somatic, germline, artifact\",\n },\n \"PROB\": {\n \"COLUMN\": [\"p...
[ "0.65818685", "0.61850566", "0.6020124", "0.58721864", "0.5824307", "0.5692058", "0.56518245", "0.5619209", "0.55818576", "0.5551026", "0.553083", "0.5518843", "0.5459129", "0.54217863", "0.5413675", "0.54074", "0.5400768", "0.5389365", "0.53707016", "0.53672904", "0.53651774...
0.0
-1
A little shared protein creater from aligned sequences
def shared(self, aligned_a, aligned_b): return "".join([self.delta(aligned_a, aligned_b, i) for i in range(len(aligned_a))])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proteins_align(self, protein_a, protein_b):\n # Set variables\n first = Seq(self.proteins_dict[protein_a][\"protein\"])\n second = Seq(self.proteins_dict[protein_b][\"protein\"])\n \n # Align proteins\n align = pairwise2.align.globalxx(first, second, one_alignment_only...
[ "0.6774844", "0.6548914", "0.6453903", "0.63102025", "0.62329227", "0.62122506", "0.62016445", "0.6198148", "0.61716217", "0.61462194", "0.6104765", "0.60956174", "0.6076317", "0.605018", "0.6017549", "0.60125715", "0.60021424", "0.5987413", "0.598054", "0.59300274", "0.59269...
0.0
-1
Aligns to proteins with BioPython
def proteins_align(self, protein_a, protein_b): # Set variables first = Seq(self.proteins_dict[protein_a]["protein"]) second = Seq(self.proteins_dict[protein_b]["protein"]) # Align proteins align = pairwise2.align.globalxx(first, second, one_alignment_only=True) aligned_a = align[0].seqA aligned_b = align[0].seqB # Calculate shared string shared = self.shared(aligned_a, aligned_b) # Returns dictionary of shared terms return {protein_a: aligned_a, protein_b: aligned_b, "shared": shared, "shared_count": Counter([x for x in shared.split("-") if x != ""]), "percent_simalarity": align[0].score / len(align[0].seqA), "score": align[0].score, "levenshtein_distance": l_dist(str(first), str(second))}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _annotate(reads, mirbase_ref, precursors):\n for r in reads:\n for p in reads[r].precursors:\n start = reads[r].precursors[p].start + 1 # convert to 1base\n end = start + len(reads[r].sequence)\n for mature in mirbase_ref[p]:\n mi = mirbase_ref[p][matu...
[ "0.5886286", "0.578243", "0.5694541", "0.55110466", "0.54499483", "0.5421526", "0.5384452", "0.5378168", "0.53772914", "0.5373772", "0.5367927", "0.5356481", "0.52636886", "0.5250715", "0.52294004", "0.521091", "0.5200446", "0.5192469", "0.5176645", "0.5132264", "0.5124896", ...
0.52686924
12
Instantiate a evaluator class.
def build_evaluator(cfg: CfgNode) -> EvaluatorBase: name = cfg["name"] evaluator = simple_build(name, cfg, EVALUATORS) return evaluator
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def evaluator(self, evaluator):\n self.__evaluator = evaluator", "def _create_evaluators(self):\n pass", "def build_evaluator(cls, cfg, dataset_name, output_folder=None):\n if output_folder is None:\n output_folder = os.path.join(cfg.OUTPUT_DIR, \"inference\")\n evaluator...
[ "0.66867024", "0.6603871", "0.6451372", "0.644928", "0.6330437", "0.6274948", "0.61652106", "0.6148524", "0.6130907", "0.5967345", "0.58819443", "0.5654034", "0.56327844", "0.56159383", "0.55843073", "0.5571741", "0.5563956", "0.5515962", "0.5513957", "0.5500064", "0.5477984"...
0.68942183
0
Instantiate a evaluate helper class.
def build_evaluate_helper(cfg: CfgNode) -> EvaluateHelper: evaluator = build_evaluator(cfg.evaluator) helper = EvaluateHelper(evaluator) return helper
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_evaluators(self):\n pass", "def evaluator(evaluate):\r\n @functools.wraps(evaluate)\r\n def ecspy_evaluator(candidates, args):\r\n fitness = []\r\n for candidate in candidates:\r\n fitness.append(evaluate(candidate, args))\r\n return fitness\r\n ecspy_e...
[ "0.64568245", "0.6257798", "0.6237631", "0.6131028", "0.6065035", "0.60551", "0.60094994", "0.5996954", "0.59962183", "0.59601563", "0.59601563", "0.59439415", "0.5902795", "0.589313", "0.5882588", "0.58795404", "0.58464766", "0.5829064", "0.5801519", "0.5770252", "0.57448375...
0.70881444
0
Plot x and y axis of dfs in common graph.
def plot(x, y, *dfs): ax = None for df in dfs: ax = df[[x, y]].set_index(x).plot(kind='line', ylim=(0, None), xlim=(0, None), ax=ax)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_plot(ax, dfs, legend, x, y, xscale, yaxis_max):\n xticks = dfs_all_values(dfs, x)\n # loop over all pandas.DataFrame objects\n for df in dfs:\n # setting the x-column as an index is required to draw the y-column\n # as a function of x argument\n df = df.set_index(x)\n ...
[ "0.7042768", "0.64889604", "0.6424103", "0.62358296", "0.62245584", "0.6214347", "0.6187972", "0.61645967", "0.6090626", "0.6083194", "0.60742915", "0.60631174", "0.6021211", "0.60032755", "0.5985849", "0.5971447", "0.59706855", "0.5946714", "0.59466743", "0.593274", "0.59300...
0.7176058
0
8 microed stepping by faking distance twice as long.
def micro_8(steps, a): df = pd.DataFrame(index=np.arange(0, steps * 16), columns=('v', 's', 'd', 't')) t = 0.0 m = 8 # micro level d = d0 = math.sqrt(1/a/m) # faster accel since distance is longer s = 0 # steps p = 0 # position p_d = 1/m # position delta for s in range(800): if s == 0: d = d0 * 0.676 else: d -= d * 2 / (4 * s + 1) s += 1 p += p_d t += d df.loc[s] = [1/d/m, p, d, t] # m = 1 # p_d = 1/m # d = d * 8 # for s in range(100, 200): # if s == 0: # d = d0 * 0.676 # else: # d -= d * 2 / (4 * s + 1) # s += 1 # p += p_d # t += d # df.loc[s] = [1/d/m, p, d, t] return df.dropna()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drive_eight(n):\n # Variables for the go_diff function\n fast_speed = 80 \n slow_speed = 25\n # Half a lap time, this is the time the robot turns in a direction before switching\n half_lap_time =6.2 \n # To avoid having tu manually stop the robot we set it to drive continuously for x amount of seconds.\n...
[ "0.6142764", "0.5769263", "0.57421744", "0.5703275", "0.5681504", "0.5650031", "0.5599577", "0.5527048", "0.55249375", "0.55100065", "0.55055285", "0.549204", "0.54680324", "0.5440701", "0.54385084", "0.54321384", "0.5418194", "0.54137677", "0.54083496", "0.5375917", "0.53658...
0.6169425
0
Return the result of an elasticsearch query as a pandas DataFrame.
def _ES_res_to_pandas(self, res, columns, thresh=None): sources = [x['hits']['hits'][0]['_source'] for x in res['responses']] if columns is not None: if isinstance(columns, list): sources = [{key: val for key, val in x.items() if key in columns} for x in sources] elif callable(columns): sources = [{key: val for key, val in x.items() if columns(key)} for x in sources] assert sources columns = list(sources[0].keys()) else: raise TypeError('Variable "columns" should be list or callable or None.') dtype = {col: self._choose_dtype(col) for col in columns} ids = [x['hits']['hits'][0]['_id'] for x in res['responses']] tab = pd.DataFrame(sources, index=ids)[columns] # Workaround for pandas bug: https://stackoverflow.com/a/38750433/7856919 for k, v in dtype.items(): if v == bool: tab[k] = tab[k].astype(str) == 'True' else: tab[k] = tab[k].astype(v) if thresh is not None: # Select rows that are not above the threshold sel = ~(tab['__CONFIDENCE'] >= thresh) columns_to_remove = [x for x in tab.columns if '__' in x] tab.loc[sel, columns_to_remove] = pd.np.nan # Dirty fix for np.nan that transforms dtype bool into float. tab['__IS_MATCH'].fillna(False, inplace=True) tab['__IS_MATCH'] = tab['__IS_MATCH'].astype(bool) return tab
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_pandas(self):\n return pd.DataFrame(self.results)", "def parse_query_result(self):\n results = self.jsonData['results']\n\n df = pd.DataFrame(results)\n df.drop(['rootSource', 'uri'], axis=1, inplace=True)\n\n return df", "def parse_query_result(self):\n result...
[ "0.74036556", "0.70324427", "0.70324427", "0.7026997", "0.6755308", "0.66402763", "0.65239024", "0.6453229", "0.6447718", "0.641856", "0.63828397", "0.63794637", "0.63329643", "0.6315638", "0.63023823", "0.62740153", "0.6256019", "0.6252512", "0.61707205", "0.616961", "0.6168...
0.59003174
47
Load or generate pandas DataFrame from the ES associated to the project.
def from_ES(self, columns=None, chunksize=None, thresh=None): num_rows = ic.stats(self.index_name)['_all']['total']['docs']['count'] if chunksize is None: res = self.fetch_by_id(size=num_rows, from_=0) return self._ES_res_to_pandas(res, columns, thresh) else: # Return a generator. Code has to be separate to allow returning pandas.DataFrame return self._from_ES_gen(num_rows, columns, chunksize, thresh)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(\n self, index_col: str = \"operator\", date_cols: list = [\"updated\", \"created\"]\n ) -> pd.DataFrame:\n df = pd.read_json(self.fspath, convert_dates=date_cols)\n try:\n df = df.set_index(index_col)\n except KeyError:\n raise KeyError(\n ...
[ "0.6643909", "0.6490127", "0.6398309", "0.63942033", "0.6390223", "0.6387757", "0.6322727", "0.6301943", "0.62897563", "0.62897563", "0.6250521", "0.62502694", "0.6227685", "0.62009954", "0.6197437", "0.6136766", "0.6132035", "0.60477877", "0.60312194", "0.6027194", "0.602561...
0.60417974
18
Add the elements in ref_gen to an existing index.
def update_index(self, ref_gen): testing = True logging.warning('Updating index') es_insert.index(es, ref_gen, self.index_name, testing, action="update") logging.warning('Finished updating')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _add_to_index( env, meta_dict, file_str, logger ):\n global adapter_glob\n if adapter_glob is not None:\n adapter = adapter_glob\n else:\n logger.warning( u\"Connecting to index...\" )\n adapter = adapter_file.adapter(env)\n adapter_glob = adapter\n doc = document(\n ...
[ "0.6223327", "0.6165989", "0.6162208", "0.6124569", "0.5892641", "0.5827929", "0.5818835", "0.5818835", "0.5806102", "0.57331675", "0.5731806", "0.57138515", "0.57138515", "0.569752", "0.5685238", "0.5673912", "0.56449544", "0.5584928", "0.5584928", "0.55495024", "0.5501107",...
0.7487727
0
Create new CSP crossword generate.
def __init__(self, crossword): self.crossword = crossword self.domains = { var: self.crossword.words.copy() for var in self.crossword.variables }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate():", "def create_word(self):\r\n\r\n template = self.word_constructions.get()\r\n word = \"\"\r\n for c in template:\r\n if c == \"v\":\r\n letter = self.get_letter(100)\r\n else:\r\n letter = self.get_letter(0)\r\n ...
[ "0.61295784", "0.57595176", "0.57502925", "0.5485153", "0.5463034", "0.5440735", "0.54096925", "0.5384929", "0.5324468", "0.52978784", "0.52702993", "0.5268702", "0.52018815", "0.51922834", "0.51729023", "0.51533055", "0.5123092", "0.5111853", "0.5078365", "0.5064279", "0.506...
0.5178984
16
Return 2D array representing a given assignment.
def letter_grid(self, assignment): letters = [ [None for _ in range(self.crossword.width)] for _ in range(self.crossword.height) ] for variable, word in assignment.items(): direction = variable.direction for k in range(len(word)): i = variable.i + (k if direction == Variable.DOWN else 0) j = variable.j + (k if direction == Variable.ACROSS else 0) letters[i][j] = word[k] return letters
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getArray2d(self):\n\t\treturn self.array2d", "def _make_2x2(self, A11, A12, A21, A22, dtype=float):\n array = np.empty((2,2), dtype=dtype)\n array[0,0] = A11\n array[0,1] = A12\n array[1,0] = A21\n array[1,1] = A22\n return array", "def to_2d_array(self):\n ...
[ "0.606624", "0.5862392", "0.55966055", "0.5584392", "0.54055727", "0.5379813", "0.5306427", "0.52944845", "0.52937496", "0.5269656", "0.52278423", "0.52027124", "0.51681507", "0.5129247", "0.5119349", "0.5079877", "0.50548553", "0.50341636", "0.50252825", "0.5023556", "0.4997...
0.5062015
17
Print crossword assignment to the terminal.
def print(self, assignment): letters = self.letter_grid(assignment) for i in range(self.crossword.height): for j in range(self.crossword.width): if self.crossword.structure[i][j]: print(letters[i][j] or " ", end="") else: print("█", end="") print()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_word_scheme(self) -> None:\n print(\"\".join(self.word2))", "def print(self):\n\n def format_guessed_word(word):\n return ' '.join(list(word))\n\n def format_blank_word(word):\n return ' '.join(list('_' * len(word)))\n\n print('\\n' + \"Board\" + '=' * 7...
[ "0.6418134", "0.6091784", "0.60144675", "0.5868591", "0.58374834", "0.5763381", "0.5702663", "0.56456727", "0.56032985", "0.5602622", "0.5599726", "0.55596346", "0.5540012", "0.55338246", "0.5492764", "0.54739493", "0.5469291", "0.5463655", "0.54530674", "0.54021096", "0.5400...
0.72022206
1
Save crossword assignment to an image file.
def save(self, assignment, filename): from PIL import Image, ImageDraw, ImageFont cell_size = 100 cell_border = 2 interior_size = cell_size - 2 * cell_border letters = self.letter_grid(assignment) # Create a blank canvas img = Image.new( "RGBA", (self.crossword.width * cell_size, self.crossword.height * cell_size), "black" ) font = ImageFont.truetype("assets/fonts/OpenSans-Regular.ttf", 80) draw = ImageDraw.Draw(img) for i in range(self.crossword.height): for j in range(self.crossword.width): rect = [ (j * cell_size + cell_border, i * cell_size + cell_border), ((j + 1) * cell_size - cell_border, (i + 1) * cell_size - cell_border) ] if self.crossword.structure[i][j]: draw.rectangle(rect, fill="white") if letters[i][j]: w, h = draw.textsize(letters[i][j], font=font) draw.text( (rect[0][0] + ((interior_size - w) / 2), rect[0][1] + ((interior_size - h) / 2) - 10), letters[i][j], fill="black", font=font ) img.save(filename)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save(self, filename):\n print(\"Saving...\", end=\"\\r\")\n canvas = self.canvas[self.N:self.S,self.W:self.E]\n cv2.imwrite(\"./Output/\"+filename, canvas)\n print(\"Saved:\",filename)", "def save_detection(self, image):\n\t\timg = self.visualize_detection(image)\n\t\timg = cv2.cv...
[ "0.65461063", "0.6395748", "0.63688743", "0.6313389", "0.62285316", "0.61451906", "0.6133265", "0.6110629", "0.61080384", "0.60995334", "0.6096377", "0.60782754", "0.60167956", "0.60059804", "0.59735614", "0.5961569", "0.5951604", "0.5941784", "0.591758", "0.5905942", "0.5890...
0.78399444
1
Enforce node and arc consistency, and then solve the CSP.
def solve(self): self.enforce_node_consistency() self.ac3() return self.backtrack(dict())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve_csp(nodes, arcs, max_steps):\n\n nodes = list(nodes)\n print 'nodes:', nodes\n\n node_values_dict = dict(zip(nodes, '2'*len(set(nodes))))\n print 'initial random assignment', node_values_dict\n indexes = np.arange(len(nodes))\n\n graph = {}\n for arc in arcs:\n if not arc[0] i...
[ "0.64042765", "0.6084755", "0.60748124", "0.57520914", "0.5737966", "0.56193435", "0.55433697", "0.53763986", "0.5332282", "0.526332", "0.5261379", "0.5261379", "0.52395386", "0.52281404", "0.52064234", "0.5187962", "0.5164979", "0.5130408", "0.5113685", "0.5096188", "0.50758...
0.54098696
8
Update `self.domains` such that each variable is nodeconsistent. (Remove any values that are inconsistent with a variable's unary constraints; in this case, the length of the word.)
def enforce_node_consistency(self): # print("Entered enforce_node_consistency Function") # print("self.domains") # print(self.domains) for mystery in self.domains: # print("!!!!!!!!!!!!") # print(mystery) # print(self.domains[mystery]) keep_list = set() while self.domains[mystery]: word = self.domains[mystery].pop() if(len(word) == mystery.length): keep_list.add(word) for word in keep_list: self.domains[mystery].add(word) # print(self.domains[mystery]) # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enforce_node_consistency(self):\n # Loop over each variable (space for word) in the crossword\n # Use copy to prevent domains from being modified while looping\n for var in self.domains.copy():\n # Get all unary constraints for this variable\n for value in self.domain...
[ "0.80468005", "0.69576985", "0.6794537", "0.63951313", "0.63650477", "0.6052798", "0.5844512", "0.58284026", "0.5795998", "0.5759449", "0.5712677", "0.5712677", "0.56901187", "0.5685086", "0.5629894", "0.5607322", "0.55948013", "0.55813795", "0.5536879", "0.5519875", "0.54945...
0.673076
3
Make variable `x` arc consistent with variable `y`. To do so, remove values from `self.domains[x]` for which there is no possible corresponding value for `y` in `self.domains[y]`. Return True if a revision was made to the domain of `x`; return False if no revision was made.
def revise(self, x, y): # print("Entered revise Function") keep_list_x = set() keep_list_y = set() domain_x = self.domains[x].copy() domain_y = self.domains[y].copy() overlaps = self.crossword.overlaps overlap = overlaps[(x, y)] # print(self.domains[x].copy) revision = False if overlap is not None: while domain_x: word_x = domain_x.pop() # print(word_x) while domain_y: word_y = domain_y.pop() # print(word_y) keep_list_y.add(word_y) if word_x[overlap[0]] != word_y[overlap[1]]: keep_list_x.add(word_x) for word in keep_list_y: domain_y.add(word) remove_list = self.domains[x].difference(keep_list_x) # print("DOMAIN") # print(self.domains[x]) # print("KEEP") # print(keep_list_x) # print("REMOVE") # print(remove_list) for word in remove_list: self.domains[x].remove(word) revision = True return revision # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def revise(self, x, y):\n # return set a default return value of False\n ret_val = False\n # define a tuple of the two variables without their domains\n var_tup = (x, y)\n # define lists of the variable's domains\n x_values = self.domains[x].copy()\n y_values = self...
[ "0.7254103", "0.62908906", "0.567439", "0.5597688", "0.53487086", "0.5329222", "0.5265961", "0.51735663", "0.5155395", "0.5139437", "0.51281583", "0.5127078", "0.50768644", "0.49855748", "0.49679717", "0.49677834", "0.49434954", "0.49179846", "0.4910346", "0.48950416", "0.488...
0.61482406
2
Update `self.domains` such that each variable is arc consistent. If `arcs` is None, begin with initial list of all arcs in the problem. Otherwise, use `arcs` as the initial list of arcs to make consistent. Return True if arc consistency is enforced and no domains are empty; return False if one or more domains end up empty.
def ac3(self, arcs=None): # print("Entered ac3 Function") revise = False if arcs is None: arcs = set() for arc in self.crossword.overlaps: arcs.add(arc) while arcs: arc = arcs.pop() # print("arc") # print(arc) revise = self.revise(arc[0], arc[1]) if revise: arcs.update(self.crossword.neighbors(arc[0])) if (self.domains[arc[0]] is None): return False # print("revise") # print(revise) # print("arc") # print(arc) # input() # print("") # print("") # print("arcs") # print(arcs) # print("") # print("") return True # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ac3(self, arcs=None):\n if arcs == None:\n #creates a queue of arcs to update\n arcs= []\n for node1 in self.domains:\n for node2 in self.domains:\n if node1 != node2:\n #for each pair of nodes that intersect, add ...
[ "0.7341803", "0.69774306", "0.6603775", "0.58208483", "0.5818385", "0.55777776", "0.55287546", "0.5475581", "0.5416812", "0.53949845", "0.5291726", "0.5171484", "0.51074433", "0.5098393", "0.5090242", "0.5040056", "0.49685684", "0.49068654", "0.48768777", "0.48698935", "0.486...
0.6537715
3
Return True if `assignment` is complete (i.e., assigns a value to each crossword variable); return False otherwise.
def assignment_complete(self, assignment): # print("Entered assignment_complete Function") for var in assignment: if assignment[var] is None: return False return self.consistent(assignment) # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assignment_complete(self, assignment):\n # for each variable in the crossword\n for variable in self.crossword.variables:\n # if the variable is not assigned a value\n if variable not in assignment:\n # the crossword is not complete\n return Fal...
[ "0.8660917", "0.7774996", "0.7236496", "0.715314", "0.6777561", "0.67663616", "0.6716149", "0.6668017", "0.6563448", "0.65057194", "0.64147335", "0.6396104", "0.6369181", "0.63129765", "0.63119334", "0.6073311", "0.6054601", "0.603511", "0.6031876", "0.5906102", "0.5893759", ...
0.81902444
1
Return True if `assignment` is consistent (i.e., words fit in crossword puzzle without conflicting characters); return False otherwise.
def consistent(self, assignment): # print("Entered consistent Function") # print("assignment") # print(assignment) overlaps = self.crossword.overlaps value_set = set() for variable in assignment: #checking overlaps with neighbors neighbors = self.crossword.neighbors(variable) for neighbor in neighbors: overlap = overlaps[(variable, neighbor)] if (neighbor in assignment): # print("var 1 overlap letter") # print(assignment[variable][overlap[0]]) # print("var 2 overlap letter") # print(assignment[neighbor][overlap[1]]) if (assignment[variable][overlap[0]] is not assignment[neighbor][overlap[1]]): return False # print("neighbors") # print(neighbors) #checking that the assignment is the correct length for the variable if (variable.length != len(assignment[variable])): return False #the set to check for distinct variables later value_set.add(assignment[variable]) #Checking that all variables are distinct #these should be the same length unless two or more variables share an value if( len(value_set) is not len(assignment)): return False return True # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def consistent(self, assignment):\n # for each of the current assignments\n for word in assignment:\n # if the word does not fit in the gaps\n if len(assignment[word]) != word.length:\n # reject attempt\n return False\n # if the word is a...
[ "0.8402212", "0.8299707", "0.702421", "0.6465896", "0.64497894", "0.6389745", "0.6059358", "0.6028566", "0.58353883", "0.5827617", "0.5789568", "0.5764622", "0.57099473", "0.5694708", "0.5602207", "0.55700195", "0.5525498", "0.5517784", "0.5466885", "0.546393", "0.54609096", ...
0.83261746
1
Return a list of values in the domain of `var`, in order by the number of values they rule out for neighboring variables. The first value in the list, for example, should be the one that rules out the fewest values among the neighbors of `var`.
def order_domain_values(self, var, assignment): # print("Entered order_domain_values Function") ordered_variables = [] # print("Var") # print(var) # print("self.domains[var]") # print(self.domains[var]) # print("self.crossword.neighbor(var)") # print(self.crossword.neighbors(var)) neighbors_to_check = self.crossword.neighbors(var).difference(assignment.keys()) for word in self.domains[var]: n = 0 for neighbor in neighbors_to_check: overlap = self.crossword.overlaps[(var, neighbor)] for neighbor_word in self.domains[neighbor]: if ( word[overlap[0]] is not neighbor_word[overlap[1]] or word is neighbor_word): n += 1 ordered_variables.append( (word, n) ) ordered_variables.sort(key=self.orderFunc) # print("ordered_variables") # print(ordered_variables) # input() return ordered_variables # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eliminate_from_neighbors(csp, var) :\n reduced = []\n val = csp.get_assigned_value(var)\n replacement = []\n for constraint in csp.constraints_between(var,None):\n var2 = constraint.var2\n domainCopy = csp.domains[var2][:]\n numLeft = len(domainCopy)\n if (val!=None):\n ...
[ "0.65513057", "0.6346596", "0.62824583", "0.6041415", "0.60353327", "0.6032189", "0.5999635", "0.58770275", "0.5836044", "0.57163435", "0.55799633", "0.5501954", "0.5491494", "0.5456138", "0.54167825", "0.53648853", "0.53506935", "0.5325021", "0.53222", "0.5308232", "0.529167...
0.54332227
14
Return an unassigned variable not already part of `assignment`. Choose the variable with the minimum number of remaining values in its domain. If there is a tie, choose the variable with the highest degree. If there is a tie, any of the tied variables are acceptable return values.
def select_unassigned_variable(self, assignment): # print("Entered select_unassigned_variable Function") # print("Assignment") # print(assignment) variables = set() variables.update(self.domains.keys()) unassigned_variables = set() unassigned_variables.update(variables.difference(assignment.keys())) # print("All Variables") # print(variables) # print("Unassigned Variables") # print(unassigned_variables) # This chooses the variables with the smallest domain from this list (unassigned_variables) var_list = [] for variable in unassigned_variables: var_list.append( (variable, len(self.domains[variable]), len(self.crossword.neighbors(variable)) ) ) var_list.sort(key = self.sort_by_domain) var_list.sort(reverse=True, key = self.sort_by_neighbors) # print("var_list") # print(var_list) return var_list[0][0] # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def select_unassigned_variable(self, assignment):\n var_list= []\n #add unassigned variabled to a list along with the number of words left in its domain\n for var in self.domains:\n if var not in assignment:\n var_list.append((var, len(self.domains[var])))\n #s...
[ "0.80119693", "0.7859947", "0.76820076", "0.7355518", "0.71462846", "0.703895", "0.703833", "0.6703648", "0.6678851", "0.65556186", "0.6266142", "0.61606276", "0.6047509", "0.6028325", "0.5978296", "0.5843578", "0.5655437", "0.56006765", "0.55530095", "0.5532206", "0.55234164...
0.77794665
2
Using Backtracking Search, take as input a partial assignment for the crossword and return a complete assignment if possible to do so. `assignment` is a mapping from variables (keys) to words (values). If no assignment is possible, return None.
def backtrack(self, assignment): # print("Entered backtrack Function") # Check if assignment is complete if len(assignment) == len(self.domains): return assignment # Try a new variable var = self.select_unassigned_variable(assignment) word_list = self.order_domain_values(var, assignment) for word in word_list: new_assignment = assignment.copy() new_assignment[var] = word[0] if self.consistent(new_assignment): result = self.backtrack(new_assignment) if result is not None: return result return None # raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backtrack(self, assignment):\n # if the assignment is complete\n if self.assignment_complete(assignment):\n # return the assignment, crossword is complete\n return assignment\n # pick a variable to try to assign\n var = self.select_unassigned_variable(assignmen...
[ "0.7360267", "0.70080864", "0.6352615", "0.62211263", "0.6217823", "0.6217823", "0.5960085", "0.59551066", "0.5912701", "0.58554476", "0.5837058", "0.5765993", "0.57650095", "0.5723373", "0.55428743", "0.5452668", "0.5425594", "0.5342919", "0.53365654", "0.5329358", "0.532841...
0.70967716
1
Loads data for a specific game map level.
def load_data(self, map_name, grid_name, tp_name): self.map= TiledMap(path.join(self.map_folder, map_name)) self.map_img = self.map.make_map() self.map_img2 = self.map_img #self.noisy_map_img = noisy("gauss", pg.surfarray.array3d(self.map_img)) self.noisy_map_img = make_noisy(pg.surfarray.array3d(self.map_img)) self.map_rect = self.map_img.get_rect() with open(path.join(self.map_folder, tp_name), 'rt') as f: # destinations is a dict mapping each tilemap teleport coordinate to # the destination tilemap coordinate self.destinations = eval(f.read()) self.grid= OccupancyGrid(self, path.join(self.map_folder, grid_name)) #down here because it needs destinations self.graph = self.grid.make_graph() #sounds self.wall_channel=pg.mixer.Channel(0) self.wall_sound=pg.mixer.Sound(WALL_THUD_SOUND) self.teleport_channel=pg.mixer.Channel(1) self.teleport_sound=pg.mixer.Sound(TELEPORT_SOUND)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_map(self):\n # ask for a new level(str)\n answer = simpledialog.askstring(\"Input\", \"Please input a level\",\n parent=self._master)\n if answer is not None:\n if answer in self._level_dic.keys(): # ensure the level exist\n ...
[ "0.74006486", "0.6749682", "0.62063956", "0.6168153", "0.597027", "0.59682465", "0.58968747", "0.5858254", "0.57994854", "0.57971156", "0.57004493", "0.5693509", "0.56794953", "0.5672299", "0.5622653", "0.5604859", "0.56037986", "0.5574898", "0.5534123", "0.5477678", "0.54526...
0.59912586
4
Initialize and setup a new maze level.
def new(self): #groups for drawing self.moving_sprites = pg.sprite.LayeredUpdates() self.static_sprites = pg.sprite.LayeredUpdates() #other groups self.walls = pg.sprite.Group() self.teleports = pg.sprite.Group() self.win = pg.sprite.Group() self.threat = pg.sprite.Group() self.hearts= pg.sprite.Group() for tile_object in self.map.tmxdata.objects: if tile_object.name == "player": self.player = Player(self, tile_object.x, tile_object.y) if tile_object.name == "monster": self.monster = Monster(self, tile_object.x, tile_object.y) if tile_object.name == "wall": Obstacle(self, tile_object.x, tile_object.y, tile_object.width, tile_object.height) if tile_object.name == "mirror": Mirror(self, tile_object.x, tile_object.y, tile_object.width, tile_object.height, self.destinations) if tile_object.name == "pentagram": self.goal=Pentagram(self, tile_object.x, tile_object.y, tile_object.width, tile_object.height) self.camera = Camera(self.map.width, self.map.height) #static sprites self.flashlight=Flashlight(self, int(WIDTH/2), int(HEIGHT/2)) self.darkness=Darkness(self, int(WIDTH/2), int(HEIGHT/2)) if self.minimap_name != None: self.minimap=Minimap(self, self.minimap_name) for i in range(int(PLAYERHEALTH/10)): Heart(self, 726-37*(2-i), 20) self.battery= Battery(self, 726, 52) self.draw_debug = False self.teleport_list=[] for tele in self.teleports: self.teleport_list.append(tele)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_position():\n __maze.init_position()", "def setUp(self):\n\n self.m=Maze()", "def __init__(self, maze, population_size):\n self.maze = maze\n self.population_size = population_size", "def setupLevel(self):\n\n self.state = GameState.SETUP\n\n # vado a leggere il...
[ "0.7217811", "0.7040007", "0.6914307", "0.68994147", "0.6807719", "0.67093295", "0.67023313", "0.6577321", "0.6552819", "0.6521437", "0.651588", "0.634067", "0.6334667", "0.6277603", "0.62732935", "0.6267083", "0.62319756", "0.6219", "0.6209007", "0.6164258", "0.6150346", "...
0.0
-1
Runs the Mazescape game.
def run(self): #game loop set self.playing to False to end game self.playing = True while self.playing: self.dt = self.clock.tick(FPS) / 1000 self.events() self.update() self.draw() self.losing_sequence()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main():\n g = Game(800, 600)\n g.start()", "def main():\n g = DemoGame(800, 600)\n g.start()", "def main():\n game = RiichiMahjongApp()\n game.run()", "def run(self):\n print(\"WELCOME TO MINESWEEPER!\")\n\n\n while True:\n\n self.get_input()\n start_...
[ "0.6874502", "0.6857758", "0.68047696", "0.6561532", "0.6534774", "0.64771336", "0.64398795", "0.63985527", "0.638074", "0.63475657", "0.6324274", "0.6295392", "0.6273534", "0.62623614", "0.6261345", "0.62363064", "0.6226019", "0.621045", "0.61986893", "0.6194582", "0.6194038...
0.0
-1
Quits the Mazescape game
def quit_game(self): pg.quit() sys.exit()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _quit(self) -> None:\n self._show_bag(True)\n print(\"Thanks for playing!\")\n exit()", "def qpressed(): #QUITTNG FUNCTION\n #print(\"q pressed\")\n sys.exit()", "def __quit(self):\n self.clear_screen()\n self.__print_logo()\n print('\\n'*3)\n self.coo...
[ "0.6897181", "0.6780871", "0.6693137", "0.65562737", "0.65255046", "0.6351009", "0.6307511", "0.6168882", "0.61455756", "0.61273867", "0.61242676", "0.61096215", "0.60773265", "0.60688776", "0.6056135", "0.6048833", "0.6048833", "0.6048833", "0.6034417", "0.6029101", "0.60159...
0.62268347
7
Catches all gamerelated events
def events(self): # catch all events here for event in pg.event.get(): if event.type == pg.QUIT: self.quit_game() if event.type == pg.KEYDOWN: if event.key == pg.K_ESCAPE: menu.paused = True menu.pause_menu() #code gets stuck in this call until a button is pressed in the pause menu self.clock=pg.time.Clock() if event.key == pg.K_h: self.draw_debug = not self.draw_debug if event.key == pg.K_o: if self.flashlight.on:#turning off flashlight self.darkness.on = True self.battery.duration-=pg.time.get_ticks()-self.battery.last_update self.flashlight.on=False else: #turning on flashlight self.darkness.on = False self.battery.last_update=pg.time.get_ticks() self.flashlight.on=True #darkness condition if self.transition: self.darkness_transition(self.player) self.kidnap(self.player) # win condition if pg.sprite.spritecollide(self.player, self.win, False, collide_hit_rect): menu.win_menu() #got hit condition hit=pg.sprite.spritecollide(self.player, self.threat, False, collide_hit2_rect) if hit: self.hit(self.player, hit[0]) #mirror self.portal(self.player) self.portal(self.monster)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __handle_events(self):\r\n for event in pygame.event.get():\r\n self.controller.handle_event(event)", "def process_events(self):\n gameevents = copy.copy(self.gameevents)\n del self.gameevents[:]\n while len(gameevents) > 0:\n currentevent = gameevents.pop(0)...
[ "0.68227965", "0.6619201", "0.65891063", "0.64815664", "0.641884", "0.6384413", "0.616646", "0.6130458", "0.6088237", "0.6078368", "0.60664743", "0.60335886", "0.60190856", "0.59726304", "0.59557456", "0.59455985", "0.5929909", "0.59173644", "0.59143096", "0.5911435", "0.5911...
0.54172313
66
Updates the frame of the game
def update(self): self.moving_sprites.update() self.static_sprites.update() self.camera.update(self.player)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_display(self):\r\n\r\n # The display.update() Updates the screen, making the new frame replace the old one. \r\n pg.display.update()\r\n \r\n # clock.tick sets a framerate for the game.\r\n # This is to make the game run at a stable fps \r\n self.clock.tick(cng....
[ "0.75599945", "0.74793476", "0.7177903", "0.7115879", "0.70343995", "0.6902082", "0.6901963", "0.6897741", "0.6863001", "0.6841528", "0.681301", "0.68126184", "0.6780625", "0.6780625", "0.67711943", "0.6767823", "0.67476755", "0.6745845", "0.6714142", "0.6668295", "0.6652482"...
0.638703
52
Draws a grid onto the map
def draw_grid(self): for x in range(0, WIDTH, TILESIZE): pg.draw.line(self.screen, LIGHTGREY, (x, 0), (x, HEIGHT)) for y in range(0, HEIGHT, TILESIZE): pg.draw.line(self.screen, LIGHTGREY, (0, y), (WIDTH, y))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drawGrid(self):\n\n if self.orientation == \"isometric\":\n for vline in range(0, self.map_array.shape[0]):\n line = self.canvas.create_line(iso(vline*self.cell_width, 0),\n iso(vline*self.cell_width, self.map_array.shape[0]*self.ce...
[ "0.8058154", "0.78003556", "0.76907337", "0.76755744", "0.75905925", "0.7454775", "0.7441136", "0.73149663", "0.7275913", "0.7247664", "0.719331", "0.71902335", "0.7187785", "0.7140632", "0.71196425", "0.7098102", "0.70582795", "0.7006399", "0.70051944", "0.69672275", "0.6918...
0.7732143
2
Draws the given map level by layering all the sprites.
def draw(self): pg.display.set_caption("{:.2f}".format(self.clock.get_fps())) if distance(self.player.pos, self.monster.pos)<MONSTER_BUBBLE_DISTANCE: now=pg.time.get_ticks() if self.fuzz: wait=NOISE_DURATION else: wait=NOISE_TIMESTEP #change to a function of distance to monster if now - self.last_update_noise>wait: self.last_update_noise=now if self.fuzz: self.map_img2=self.map_img else: self.map_img2=self.noisy_map_img #make static sound self.fuzz=not self.fuzz else: self.map_img2=self.map_img self.fuzz=False self.screen.blit(self.map_img2, self.camera.apply_rect(self.map_rect)) # Layer player and monsters on map for sprite in self.moving_sprites: self.screen.blit(sprite.image, self.camera.apply(sprite)) if self.draw_debug: pg.draw.rect(self.screen, LIGHTBLUE, self.camera.apply_rect(sprite.hit_rect), 1) if self.draw_debug: for wall in self.walls: pg.draw.rect(self.screen, LIGHTBLUE, self.camera.apply_rect(wall.rect), 1) for mirror in self.teleports: pg.draw.rect(self.screen, LIGHTBLUE, self.camera.apply_rect(mirror.rect), 1) for goal in self.win: pg.draw.rect(self.screen, LIGHTBLUE, self.camera.apply_rect(goal.rect), 1) dest=(self.monster.next_step[0]*TILESIZE, self.monster.next_step[1]*TILESIZE) next_step=pg.Rect(0, 0, 20, 20) next_step.center=dest pg.draw.rect(self.screen, LIGHTBLUE, self.camera.apply_rect(next_step), 1) for sprite in self.static_sprites: self.screen.blit(sprite.image, sprite.rect) pg.display.flip() #update the full display surface to the screen
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_level(self):\r\n self.level_surface.blit(self.map_image, self.viewport, self.viewport)\r\n self.level_surface.blit(self.title_box, self.title_rect)", "def render(self):\n\n self.baseMap.beginDraw()\n self.baseMap.background(255)\n self.baseMap.endDraw()\n\n numC...
[ "0.7113351", "0.67336434", "0.6681045", "0.666561", "0.6655747", "0.66555613", "0.6489397", "0.6463894", "0.63418233", "0.63139254", "0.6242701", "0.6222603", "0.6166904", "0.61456466", "0.6123982", "0.61208385", "0.6078546", "0.6004719", "0.5968714", "0.5968446", "0.5951832"...
0.5628971
44
Draws text onto a given surface.
def draw_text(self, text, font, color, surface, x, y): #use for narrative in end sequence text_obj = font.render(text, True, color) text_rect = text_obj.get_rect() text_rect.center = (x, y) surface.blit(text_obj, text_rect)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_text(screen, font, text, surfacewidth, surfaceheight):\n\tfw, fh = font.size(text) # fw: font width, fh: font height\n\tsurface = font.render(text, True, (0, 0, 255))\n\t# // makes integer division in python3 \n\tscreen.blit(surface, (0,0))", "def drawText(text, font, surface, x, y, textcolour):\r\n ...
[ "0.8523884", "0.8420744", "0.82012075", "0.81627655", "0.80817306", "0.7885264", "0.78392565", "0.78264725", "0.7806616", "0.77619326", "0.77171636", "0.7670391", "0.7642468", "0.7597258", "0.7542746", "0.7457794", "0.745692", "0.7357429", "0.7349292", "0.7319174", "0.729991"...
0.85818034
0
Split the file and save chunks to separate files
def split(self): print 'Splitting file', self.__filename print 'Number of chunks', self.__numchunks, '\n' try: f = open(self.__filename, 'rb') except (OSError, IOError), e: raise FileSplitterException, str(e) bname = (os.path.split(self.__filename))[1] # Get the file size fsize = os.path.getsize(self.__filename) # Get size of each chunk self.__chunksize = int(float(fsize)/float(self.__numchunks)) chunksz = self.__chunksize total_bytes = 0 for x in range(self.__numchunks): chunkfilename = bname + '-' + str(x+1) + self.__postfix # if reading the last section, calculate correct # chunk size. if x == self.__numchunks - 1: chunksz = fsize - total_bytes try: print 'Writing file',chunkfilename data = f.read(chunksz) total_bytes += len(data) chunkf = file(chunkfilename, 'wb') chunkf.write(data) chunkf.close() except (OSError, IOError), e: print e continue except EOFError, e: print e break print 'Done.'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_file(self, input_file):\r\n file_list = [] \r\n with open(input_file, 'r', encoding='GB18030', errors='ignore') as f_in:\r\n data = f_in.readlines()\r\n lines_num = len(data)\r\n size = lines_num // self.num_workers # lines splitted in a chunk\r\n ...
[ "0.73668265", "0.70914865", "0.7090537", "0.7067825", "0.7001469", "0.68641955", "0.67107993", "0.65979683", "0.65870893", "0.6580552", "0.6572284", "0.65702844", "0.6551708", "0.64280057", "0.6383532", "0.6352524", "0.63487375", "0.629163", "0.62073165", "0.6201502", "0.6150...
0.745905
0
Combine existing chunks to recreate the file. The chunks must be present in the cwd. The new file will be written to cwd.
def combine(self): import re print 'Creating file', self.__filename bname = (os.path.split(self.__filename))[1] bname2 = bname # bugfix: if file contains characters like +,.,[] # properly escape them, otherwise re will fail to match. for a, b in zip(['+', '.', '[', ']','$', '(', ')'], ['\+','\.','\[','\]','\$', '\(', '\)']): bname2 = bname2.replace(a, b) chunkre = re.compile(bname2 + '-' + '[0-9]+') chunkfiles = [] for f in os.listdir("."): print f if chunkre.match(f): chunkfiles.append(f) print 'Number of chunks', len(chunkfiles), '\n' chunkfiles.sort(self.sort_index) data='' for f in chunkfiles: try: print 'Appending chunk', os.path.join(".", f) data += open(f, 'rb').read() except (OSError, IOError, EOFError), e: print e continue try: f = open(bname, 'wb') f.write(data) f.close() except (OSError, IOError, EOFError), e: raise FileSplitterException, str(e) print 'Wrote file', bname
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def merge_vcf_chunks(out_dir, path_name, path_size, chunks, overwrite):\n vcf_path = os.path.join(out_dir, path_name + \".vcf\")\n if overwrite or not os.path.isfile(vcf_path):\n first = True\n for chunk_i, chunk in enumerate(chunks):\n clip_path = chunk_base_name(path_name, out_dir,...
[ "0.65807515", "0.6522695", "0.5830749", "0.56331223", "0.5603233", "0.55737466", "0.5561251", "0.5557075", "0.5543502", "0.55282074", "0.5523479", "0.55110836", "0.547458", "0.54524946", "0.5427168", "0.54180014", "0.5275911", "0.5269838", "0.52052176", "0.5198629", "0.518618...
0.6982434
0
Returns an OAuth2 authorization token or None in case of errors. This is the flow for nonweb clients.
def get_token(client_id, client_secret, username, password): try: if oauth2db.check_client(client_id, client_secret): if oauth2db.check_user(username, password): token, refresh = oauth2db.generate_token(client_id, username) res = { "token": token } except: res = { "error": "" } if 'token' in res: return res['token'] else: return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_auth():\n try:\n token = oidc.get_access_token()\n except TypeError:\n # raised when the token isn't accessible to the oidc lib\n raise Unauthorized(\"missing auth token\")\n\n if not oidc.validate_token(token):\n terminate_session()\n raise Unauthorized(\"i...
[ "0.6736975", "0.672694", "0.6723241", "0.667107", "0.66542256", "0.66330796", "0.6596639", "0.6589812", "0.6496207", "0.6487768", "0.64865583", "0.6483437", "0.64788604", "0.6448414", "0.6448318", "0.6448318", "0.6439682", "0.641158", "0.6389883", "0.63766307", "0.63674885", ...
0.64407897
16
Returns a new valid token or None, in case of error.
def refresh_token(refresh_token): return None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_token(self):\n if not self.is_valid():\n logger.warn(\"TokenWall form data is not valid.\")\n return None\n \n tt = self.cleaned_data['token']\n logger.debug(\"Looking for token '%s'\"%tt)\n return Token.objects.get(value=tt)", "def token(self) -> Toke...
[ "0.68337315", "0.6518242", "0.63705957", "0.63319176", "0.6099937", "0.6092421", "0.60620815", "0.6054427", "0.60395783", "0.60344374", "0.5973788", "0.59650373", "0.5948255", "0.5936152", "0.5906422", "0.5888766", "0.5868331", "0.58436376", "0.5830226", "0.58285004", "0.5814...
0.0
-1
two keras Model instances are equal enough
def assert_models_equal(first, second): # layer names and settings assert first.get_config() == second.get_config() # model weights assert len(first.get_weights()) == len(second.get_weights()) for w1, w2 in zip(first.get_weights(), second.get_weights()): np.testing.assert_array_equal(w1, w2) # optimizer assert first.optimizer.get_config() == second.optimizer.get_config()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_second_keras_model_created():\n X, _, _, _ = get_data()\n tf.random.set_seed(12345)\n initializer = tf.keras.initializers.Zeros()\n input_data = Input(shape=X[0].shape)\n xx = Dense(128, activation=\"relu\", kernel_initializer=initializer)(input_data)\n xx = Dense(128, activation=\"relu\...
[ "0.72829473", "0.72438365", "0.7227518", "0.7076971", "0.6773338", "0.6756114", "0.6642388", "0.6548654", "0.6545828", "0.6540332", "0.65398526", "0.6519682", "0.65037364", "0.6483842", "0.64417934", "0.64361674", "0.6423497", "0.636907", "0.6350753", "0.63441813", "0.6334493...
0.7113716
3
two BaseWrapper instances are equal enough
def assert_wrappers_equal(first, second): assert first.sk_params == second.sk_params assert first.history_ == second.history_ if not first.model_ or not second.model_: assert first.model_ == second.model_ else: assert_models_equal(first.model, second.model)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_inheritedClassesEquality(self):\n self.assertTrue(Record(1, 2) == DerivedRecord(1, 2))\n self.assertFalse(Record(1, 2) == DerivedRecord(1, 3))\n self.assertFalse(Record(1, 2) == DerivedRecord(2, 2))\n self.assertFalse(Record(1, 2) == DerivedRecord(3, 4))", "def test_identical...
[ "0.6653726", "0.6650997", "0.65729487", "0.64894223", "0.6444425", "0.64114064", "0.63375264", "0.63026255", "0.6292803", "0.6269224", "0.6257633", "0.6256101", "0.62419796", "0.62266093", "0.6213192", "0.6190846", "0.6179785", "0.6126253", "0.61250675", "0.6109466", "0.60955...
0.67075044
0
two BaseWrapper instances return same predictions
def assert_predictions_equal(first, second, x): preds1 = first.predict(x, batch_size=batch_size) preds2 = second.predict(x, batch_size=batch_size) np.testing.assert_array_equal(preds1, preds2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_wrappers_equal(first, second):\n assert first.sk_params == second.sk_params\n assert first.history_ == second.history_\n if not first.model_ or not second.model_:\n assert first.model_ == second.model_\n else:\n assert_models_equal(first.model, second.model)", "def predict(se...
[ "0.5750074", "0.57188416", "0.5443609", "0.5316026", "0.52933276", "0.5275967", "0.52627426", "0.5258058", "0.5199715", "0.51438063", "0.5142573", "0.51336676", "0.51235074", "0.5116406", "0.5077794", "0.5052014", "0.50518346", "0.50518346", "0.50518346", "0.5041546", "0.5040...
0.5298379
4
The name of the variable in which the list of all arguments to the function is stored
def name(self): return self._name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_arg_name(self, arg, variable_name):", "def _name(self):\n return self.arguments[0].split('(')[0]", "def _name(self):\n return self._arguments[0].split('(')[0]", "def func_var_names(func):\n names = func.__code__.co_varnames[:func.__code__.co_argcount]\n return names", "def ...
[ "0.74990004", "0.69113594", "0.6881187", "0.67148364", "0.6657547", "0.6623787", "0.6606068", "0.6556822", "0.65215355", "0.6428388", "0.64085597", "0.63898975", "0.6327654", "0.6321967", "0.63197297", "0.6268201", "0.6252624", "0.6248424", "0.6245552", "0.6207349", "0.620119...
0.0
-1
The names of the arguments to the function which are contained in the PyArgKeywords list
def arg_names(self): return self._arg_names
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def names(self):\n result = []\n result.extend(self.positional_arguments)\n if self.arbitary_positional_arguments is not None:\n result.append(self.arbitary_positional_arguments)\n if self.arbitary_keyword_arguments is not None:\n result.append(self.arbitary_keywor...
[ "0.7080962", "0.69528246", "0.6950511", "0.6814684", "0.68055576", "0.67487407", "0.6712614", "0.6712274", "0.6702668", "0.6666874", "0.6628423", "0.66158634", "0.6563383", "0.64373004", "0.64143133", "0.6394061", "0.6304303", "0.6285481", "0.6278419", "0.6258944", "0.6256494...
0.6993237
1
Return the needed flag to parse or build value
def get_pytype(self, c_arg, parse_arg): if isinstance(c_arg, FunctionAddress): return 'O' else: try: return pytype_parse_registry[(parse_arg.dtype, parse_arg.precision)] except KeyError as e: raise NotImplementedError("Type not implemented for argument collection : "+str(type(parse_arg))) from e
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getOption(arg):\n return (False, \"\", \"\")", "def get_parsed_flags():\n return Flags.parsed_args", "def _parse_env_value(val):\n if val.lower() == \"false\":\n return False\n elif val.lower() == \"true\":\n return True\n try:\n return int(val)\n except ValueError:\n ...
[ "0.6345531", "0.62959224", "0.6244244", "0.6242397", "0.6095011", "0.60254776", "0.5950006", "0.5894679", "0.58870685", "0.5881222", "0.5880513", "0.57614744", "0.57475334", "0.57326", "0.5719314", "0.5702136", "0.5597625", "0.55545485", "0.55461335", "0.55367213", "0.5492313...
0.0
-1
The variable containing all positional arguments passed to the function
def pyarg(self): return self._pyarg
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getPositionalArgs():", "def get_args(self):\r\n return self.args", "def punkte(self):\n return self.args", "def args(self) -> tuple[Basic, ...]:\n return self._args", "def args(self):\n return self._args", "def args(self):\n return self._args", "def args(self):\n ...
[ "0.785117", "0.7138741", "0.7081171", "0.6903433", "0.6763262", "0.6763262", "0.6763262", "0.6745838", "0.67380923", "0.6622345", "0.65949064", "0.65869516", "0.65081775", "0.64930344", "0.64645815", "0.6435059", "0.6429822", "0.6423793", "0.6422557", "0.6418105", "0.6416629"...
0.61285037
62
The variable containing all keyword arguments passed to the function
def pykwarg(self): return self._pykwarg
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_kwargs():\n\treturn get_kwargs_raw(sys.argv)", "def get_used_kwargs(self):\n return self._used_kwargs", "def get_keyword_args(function):\n argspec = inspect.getargspec(function)\n kwargs = argspec.args[len(argspec.args) - len(argspec.defaults):]\n kwargs = {arg: value for arg, value in ...
[ "0.6939219", "0.6754662", "0.66321796", "0.659612", "0.6564183", "0.64470226", "0.64470226", "0.64356077", "0.6427776", "0.64146596", "0.63882744", "0.63835824", "0.6379224", "0.6308331", "0.62969697", "0.62953955", "0.62880987", "0.62775856", "0.62775856", "0.6273936", "0.62...
0.6603397
3
The flags indicating the types of the objects to be collected from the python arguments passed to the function
def flags(self): return self._flags
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_check_types():", "def format_flags(self):\n flags = []\n if self.is_unique:\n flags.append('Unique')\n if self.is_weak:\n flags.append('Weak')\n if self.is_ctor:\n flags.append('Constructor')\n if self.is_warning:\n flags.appe...
[ "0.5989417", "0.5906855", "0.5896243", "0.5705391", "0.5656125", "0.5627852", "0.55817276", "0.5562059", "0.5550938", "0.5473497", "0.5464566", "0.5436748", "0.5415903", "0.54050153", "0.53860885", "0.53617835", "0.53323925", "0.5305332", "0.53010184", "0.5295375", "0.5273713...
0.0
-1
The arguments into which the python args and kwargs are collected
def args(self): return self._parse_args
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def preprocess_arguments(self, *args, **kwargs):\n return (args, kwargs)", "def get_all_arguments(self):\n args, varargs, keyword, defaults = inspect.getargspec(self.exec_obj)\n if args.count('self') > 0:\n args.remove('self')\n return args", "def args(self):\n ret...
[ "0.7451631", "0.72647053", "0.72190857", "0.7194664", "0.71847206", "0.71847206", "0.71847206", "0.7184045", "0.71487767", "0.697183", "0.6968741", "0.69624984", "0.69224155", "0.6873307", "0.68517804", "0.68445677", "0.6818598", "0.68127906", "0.6803711", "0.6803707", "0.677...
0.7118921
9
The PyArgKeywords object which contains all the names of the function's arguments
def arg_names(self): return self._arg_names
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_keyword_args(function):\n argspec = inspect.getargspec(function)\n kwargs = argspec.args[len(argspec.args) - len(argspec.defaults):]\n kwargs = {arg: value for arg, value in zip(kwargs, argspec.defaults)}\n return kwargs", "def names(self):\n result = []\n result.extend(self.pos...
[ "0.6879302", "0.6823232", "0.6740888", "0.6619218", "0.6581217", "0.6491079", "0.64394325", "0.6434128", "0.63784575", "0.6353484", "0.6328109", "0.6305639", "0.6271534", "0.62503344", "0.61853814", "0.61465836", "0.61248285", "0.60984993", "0.60940886", "0.6034932", "0.60102...
0.660815
4
Create FunctionDef responsible for casting python argument to C
def Python_to_C(c_object): try : cast_function = py_to_c_registry[(c_object.dtype, c_object.precision)] except KeyError: errors.report(PYCCEL_RESTRICTION_TODO, symbol=c_object.dtype,severity='fatal') cast_func = FunctionDef(name = cast_function, body = [], arguments = [Variable(dtype=PyccelPyObject(), name = 'o', is_pointer=True)], results = [Variable(dtype=c_object.dtype, name = 'v', precision = c_object.precision)]) return cast_func
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def C_to_Python(c_object):\n try :\n cast_function = c_to_py_registry[(c_object.dtype, c_object.precision)]\n except KeyError:\n errors.report(PYCCEL_RESTRICTION_TODO, symbol=c_object.dtype,severity='fatal')\n\n cast_func = FunctionDef(name = cast_function,\n body ...
[ "0.70022583", "0.67676306", "0.6716482", "0.65700346", "0.6408847", "0.6320961", "0.6177105", "0.61178625", "0.609686", "0.60915", "0.6037971", "0.60285324", "0.5978813", "0.5958597", "0.59014344", "0.58797467", "0.58504516", "0.58494455", "0.5848168", "0.5846862", "0.5815121...
0.7423723
0
Create FunctionDef responsible for casting c argument to python
def C_to_Python(c_object): try : cast_function = c_to_py_registry[(c_object.dtype, c_object.precision)] except KeyError: errors.report(PYCCEL_RESTRICTION_TODO, symbol=c_object.dtype,severity='fatal') cast_func = FunctionDef(name = cast_function, body = [], arguments = [Variable(dtype=c_object.dtype, name = 'v', precision = c_object.precision)], results = [Variable(dtype=PyccelPyObject(), name = 'o', is_pointer=True)]) return cast_func
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Python_to_C(c_object):\n try :\n cast_function = py_to_c_registry[(c_object.dtype, c_object.precision)]\n except KeyError:\n errors.report(PYCCEL_RESTRICTION_TODO, symbol=c_object.dtype,severity='fatal')\n cast_func = FunctionDef(name = cast_function,\n body = ...
[ "0.72192234", "0.68052465", "0.6632314", "0.64130855", "0.6358928", "0.63258225", "0.6155145", "0.6139662", "0.60484755", "0.60477465", "0.60254824", "0.6015706", "0.59863913", "0.59403557", "0.58158", "0.57880235", "0.57846373", "0.5784282", "0.5761604", "0.57465273", "0.573...
0.69464856
1
Generate function Call of c/python api PyErr_SetString
def PyErr_SetString(exception, message): func = FunctionDef(name = 'PyErr_SetString', body = [], arguments = [Variable(dtype = PyccelPyObject(), name = 'o'), Variable(dtype = NativeString(), name = 's')], results = []) exception = Variable(PyccelPyObject(), name = exception) return FunctionCall(func, [exception, message])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def failure_code(sub):\r\n return '''{\r\n %(failure_var)s = %(id)s;\r\n if (!PyErr_Occurred()) {\r\n PyErr_SetString(PyExc_RuntimeError,\r\n \"Unexpected error in an Op's C code. \"\r\n \"No Python exception was set.\");\r\n }\r\n goto __...
[ "0.60588336", "0.5961557", "0.58332723", "0.5556526", "0.55433345", "0.54902726", "0.5450629", "0.5449993", "0.5403903", "0.53904366", "0.53624654", "0.533152", "0.53102547", "0.529605", "0.52905834", "0.52848315", "0.52823675", "0.5257808", "0.5237709", "0.52302915", "0.5175...
0.7551365
0
Generate TypeError exception from the variable information (datatype, precision)
def generate_datatype_error(variable): dtype = variable.dtype if isinstance(dtype, NativeBool): precision = '' if isinstance(dtype, NativeComplex): precision = '{} bit '.format(variable.precision * 2 * 8) else: precision = '{} bit '.format(variable.precision * 8) message = '"Argument must be {precision}{dtype}"'.format( precision = precision, dtype = variable.dtype) return PyErr_SetString('PyExc_TypeError', message)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_value_error_for_computing_missing_type():\n with pytest.raises(ValueError):\n compute_type(\"missing_type\", {})", "def test_type_error(self):\n self._error_test(TypeError)", "def test_invalid_expression_type(self, parse_input_mocked_metadata):\n with pytest.raises(TypeError, m...
[ "0.6931209", "0.6566379", "0.6381943", "0.63050914", "0.62194294", "0.61516786", "0.6136856", "0.61005616", "0.60737664", "0.60367274", "0.60167736", "0.6010583", "0.6010164", "0.5982661", "0.59672403", "0.59668577", "0.59405553", "0.5933665", "0.5899024", "0.5894452", "0.588...
0.81578225
0
Create FunctionCall responsible for checking python argument data type
def scalar_object_check(py_object, c_object): try : check_type = check_type_registry[c_object.dtype, c_object.precision] except KeyError: errors.report(PYCCEL_RESTRICTION_TODO, symbol=c_object.dtype,severity='fatal') check_func = FunctionDef(name = check_type, body = [], arguments = [Variable(dtype=PyccelPyObject(), name = 'o', is_pointer=True)], results = [Variable(dtype=NativeBool(), name = 'r')]) return FunctionCall(check_func, [py_object])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CheckType(self, *args, **kwargs):\n pass", "def check_input_type(func):\n @functools.wraps(func)\n def wrapper_check_input_type(*args):\n new_args = []\n for X in list(args):\n new_args.append(_check_type(X))\n return func(*new_args)\n return wrapper_check_inpu...
[ "0.69113696", "0.6676271", "0.66149634", "0.6469016", "0.63755065", "0.63459605", "0.632837", "0.63063824", "0.62952715", "0.629278", "0.6274046", "0.6262766", "0.6187069", "0.6174713", "0.6169088", "0.61163473", "0.61155474", "0.60963315", "0.6094568", "0.6088186", "0.608336...
0.6071258
22
copes with positions with no values
def test_get_logo_missing(self): data = [ [0.1, 0.3, 0.5, 0.1], [0.05, 0.8, 0.05, 0.1], [0, 0, 0, 0], [0.7, 0.1, 0.1, 0.1], [0.6, 0.15, 0.05, 0.2], ] data = DictArrayTemplate(5, "ACGT").wrap(data) get_logo(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filled_positions(self):\n return [x for x in assignable_positions if self.grid[x][0]]", "def no_empty_positions(self):\n clauses = []\n\n for position in range(0,self.graph.num_vertices):\n clause = []\n for vertex in range(0,self.graph.num_vertices):\n ...
[ "0.6175911", "0.5931269", "0.5778021", "0.5594402", "0.54442143", "0.54219913", "0.54111654", "0.53869516", "0.53672886", "0.5318788", "0.53052735", "0.52933586", "0.52916795", "0.52916795", "0.52916795", "0.5270822", "0.5251649", "0.5251649", "0.52438754", "0.5243215", "0.52...
0.0
-1
copes with positions with no values
def test_get_logo_alt_input_type(self): data = [ {"A": 0.1, "C": 0.3, "G": 0.5, "T": 0.1}, {"A": 0.05, "C": 0.8, "G": 0.05, "T": 0.1}, {"A": 0.0, "C": 0.0, "G": 0.0, "T": 0.0}, {"A": 0.7, "C": 0.1, "G": 0.1, "T": 0.1}, {"A": 0.6, "C": 0.15, "G": 0.05, "T": 0.2}, ] get_logo(data) data[-2] = {} get_logo(data)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filled_positions(self):\n return [x for x in assignable_positions if self.grid[x][0]]", "def no_empty_positions(self):\n clauses = []\n\n for position in range(0,self.graph.num_vertices):\n clause = []\n for vertex in range(0,self.graph.num_vertices):\n ...
[ "0.6175911", "0.5931269", "0.5778021", "0.5594402", "0.54442143", "0.54219913", "0.54111654", "0.53869516", "0.53672886", "0.5318788", "0.53052735", "0.52933586", "0.52916795", "0.52916795", "0.52916795", "0.5270822", "0.5251649", "0.5251649", "0.52438754", "0.5243215", "0.52...
0.0
-1
exercising some Letter methods
def test_letter_methods(self): # shift l = get_character("G") self.assertEqual(l.x, 0) self.assertEqual(l.y, 0) l.shift(2, 2) self.assertEqual(l.x, 2) self.assertEqual(l.y, 2) # scale adjusts the scale attributes orig_width = l.scale_x orig_height = l.scale_y l.scale(x=0.5, y=2) self.assertEqual(l.scale_x, orig_width / 2) self.assertEqual(l.scale_y, orig_height * 2) # invert changes the degree attr l.rotate(180) self.assertEqual(l.degrees, 180)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_letters(word, guesses):\n pass", "def letter_for(label):\n return \"ABCDEFGHIJ\"[label]", "def init_letters():\n return ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',\n 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',\n 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',\n ...
[ "0.68726075", "0.6728515", "0.6708404", "0.6602445", "0.6602445", "0.6602445", "0.6595359", "0.65413225", "0.6491447", "0.64886683", "0.6447457", "0.64450705", "0.64275444", "0.63569146", "0.63441706", "0.627932", "0.6252092", "0.62292844", "0.6165212", "0.6158538", "0.613655...
0.68069106
1
correctly convert a series of dicts or a DictArray to lists
def test_input_conversion(self): data = [dict(A=0.1, C=0.2), dict(A=0.1, C=0.2)] base = [("A", 0.1), ("C", 0.2)] expect = [base, base] got = _char_hts_as_lists(data) self.assertEqual(got, expect) # data = [dict(A=0.1, C=0.2), {}] base = [("A", 0.1), ("C", 0.2)] expect = [base, None] got = _char_hts_as_lists(data) self.assertEqual(got, expect) data = [dict(A=0.1, C=0.2), None] base = [("A", 0.1), ("C", 0.2)] expect = [base, None] got = _char_hts_as_lists(data) self.assertEqual(got, expect)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dict_array_values_as_list(self, dict_object: dict()) -> []:\n new_list = []\n for val in dict_object.values():\n new_list = new_list + val\n return new_list", "def __dict_to_list(dict):\n\n max_val = 1\n for k,v in dict.items():\n if type(v) is list:\n...
[ "0.65203464", "0.6443881", "0.64112335", "0.62288743", "0.62244505", "0.62078065", "0.61272603", "0.60739225", "0.60704356", "0.60704356", "0.6049034", "0.5973778", "0.59609526", "0.5909848", "0.5888783", "0.5881044", "0.58610386", "0.5849552", "0.5837635", "0.5829828", "0.58...
0.0
-1
Load an image from a specific path.
def parse_img(image_path): image = tf.read_file(image_path) image = tf.image.decode_image(image) image = tf.reshape(image, [INITIAL_RES, INITIAL_RES, 3]) image = tf.image.resize_images(image, [OUTPUT_RES, OUTPUT_RES]) #image = image[:, :, ::-1] # BGE -> RGB conversion if needed? #image = tf.image.rgb_to_grayscale(image) #image = tf.image.convert_image_dtype(image, tf.float32) # In neuralNet.py image = image.eval() # Convert from tensor to Numpy array for Keras return image
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(path) -> Image:\n return Image.open(path)", "def load_image(self, path):\n if path:\n self.original_image = cv2.imread(path, 1)\n self.prepare_images()", "def load_image(file_path):\r\n return Image.open(file_path)", "def load_image(path_to_image, image_name):\...
[ "0.82594067", "0.8017533", "0.7872266", "0.7861384", "0.7613008", "0.7607398", "0.7584714", "0.75568944", "0.7168932", "0.7154638", "0.70918506", "0.70681524", "0.6985307", "0.6985266", "0.69554704", "0.6927727", "0.6898096", "0.68906724", "0.6875575", "0.686947", "0.68326443...
0.0
-1
Loads all images from ../img folder, split into training and test data.
def load_data(train_test_ratio = 0.8, class_range = 8, randomised = True): # Get image filenames, labels, and the number of classification classes filenames = glob.glob("../img/*.png") if randomised: random.shuffle(filenames) img_labels = [] for filename in filenames: label = int(filename.split("-d",1)[1].split('-',1)[0]) label = max(0, (label - 1) // (class_range)) img_labels.append(label) num_classes = max(img_labels) + 1 # E.g. max label 5 -> 0-5 inclusive num_total_samples = len(filenames) num_train_samples = int(num_total_samples * train_test_ratio) num_test_samples = num_total_samples - num_train_samples training_images = np.empty( (num_train_samples, OUTPUT_RES, OUTPUT_RES, 3), dtype='uint8' ) training_labels = np.asarray(img_labels[:num_train_samples], dtype='uint8') for i in range(0, num_train_samples): training_images[i] = parse_img(filenames[i]) test_images = np.empty( (num_test_samples, OUTPUT_RES, OUTPUT_RES, 3), dtype='uint8' ) test_labels = np.asarray(img_labels[num_train_samples:], dtype='uint8') for i in range(0, num_test_samples): test_images[i] = parse_img(filenames[i + num_train_samples]) return ((training_images, training_labels), (test_images, test_labels), num_classes)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_images(test_data_dir, image_size = (300, 300)):\n # loop over the input images\n images_data = []\n labels = []\n imagePaths = sorted(list(paths.list_images(test_data_dir)))\n for imagePath in imagePaths:\n # load the image, pre-process it, and store it in the data list\n imag...
[ "0.7594195", "0.7443144", "0.74420106", "0.7436539", "0.7346392", "0.73275924", "0.725564", "0.7240028", "0.7179599", "0.7174112", "0.71509814", "0.7121513", "0.7118166", "0.7098444", "0.7097929", "0.70875955", "0.7087226", "0.7081254", "0.70765895", "0.70688915", "0.70635", ...
0.6661814
54
Test the retrieval of the actual rows for "select from HumanResources.Department"
def test_query_subset_response_AdventureWorks2014(self): with open(self.get_test_baseline(u'select_from_humanresources_department_adventureworks2014.txt'), u'r+b', buffering=0) as response_file: request_stream = io.BytesIO() rpc_client = json_rpc_client.JsonRpcClient( request_stream, response_file) rpc_client.start() # Submit a dummy request. parameters = {u'OwnerUri': u'connectionservicetest', u'BatchIndex': 0, u'ResultSetIndex': 0, u'RowsStartIndex': 0, u'RowCount': 16} request = queryservice.QuerySubsetRequest( 3, rpc_client, parameters) self.verify_subset_response(request=request) rpc_client.shutdown()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testSQLString(self): \n val = selectAllSQLStr()\n self.assertEqual(val,\"SELECT * FROM bookStore\")", "def test_get_records(self):\n pass", "def test_query(rgd):\n data = rgd.query(\"test\")\n assert isinstance(data, pd.DataFrame)\n assert data.iloc[0][\"name\"] == \"vm1\...
[ "0.6264874", "0.6200702", "0.61946857", "0.60861903", "0.605207", "0.60488313", "0.6044188", "0.6007789", "0.58853686", "0.5846672", "0.5814985", "0.5803768", "0.5793906", "0.5727903", "0.5715468", "0.5707922", "0.57078373", "0.570377", "0.56463915", "0.5636926", "0.5601166",...
0.0
-1
Helper method to get baseline file.
def get_test_baseline(self, file_name): return os.path.abspath( os.path.join( os.path.abspath(__file__), u'..', u'baselines', file_name))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _GetBaseline(self, filename, directory, upstream_only = False):\n\n local_filename = os.path.join(directory, filename)\n local_directory = local_filename[:local_filename.rfind(\"/\")]\n if upstream_only:\n last_index = local_filename.rfind(\".\")\n if last_index > -1:\n local_filename...
[ "0.72251785", "0.66584283", "0.65599346", "0.6401578", "0.6180834", "0.60123277", "0.5969603", "0.5948323", "0.59022737", "0.5869274", "0.583606", "0.5801047", "0.5801047", "0.5801047", "0.57897425", "0.57875085", "0.56959826", "0.56877124", "0.56490695", "0.56345946", "0.563...
0.79847074
0
self,x_cells, self.y_cells = np.meshgrid(x_spacings, y_spacings, sparse=True)
def __init__(self, x_spacings, y_spacings): self.x_spacings = x_spacings.astype(np.float32) self.y_spacings = y_spacings.astype(np.float32) self.nx = len(x_spacings) self.ny = len(y_spacings) self.n_cells = self.nx * self.ny
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_meshgrid(self):\n x = np.linspace(self.limits[0], self.limits[1], self.resolution)\n y = np.linspace(self.limits[2], self.limits[3], self.resolution)\n X, Y = np.meshgrid(x, y)\n return X, Y", "def make_meshgrid(x_min,x_max,y_min,y_max, h=.02):\n xx, yy = np.meshgrid(np...
[ "0.75481325", "0.7334674", "0.7334674", "0.72951424", "0.72951424", "0.7236079", "0.72319734", "0.72218466", "0.7145317", "0.7145317", "0.7145317", "0.7145317", "0.71451616", "0.71191305", "0.704927", "0.7037136", "0.7016178", "0.6942421", "0.68876344", "0.68683", "0.68584913...
0.69724435
17
Convert two dimensional index to 1d.
def one_dim_index(self, i, j): return int(i + j * self.nx)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index_to_ijk(self, index):\n return self.indices_to_ijk_array([index])[0]", "def to_sparse(a):\n flat = a.flatten()\n indices = np.nonzero(flat)\n values = flat[indices]\n return indices[0], values", "def from_2D_to_1D(constant):\n if isinstance(constant, np.ndarray) and constant.ndim...
[ "0.63026196", "0.6043091", "0.6035447", "0.5884787", "0.5873872", "0.58113074", "0.58112794", "0.5807854", "0.5798596", "0.5788235", "0.576793", "0.57582265", "0.5724153", "0.5716051", "0.57072705", "0.5707207", "0.57035434", "0.5701338", "0.56998104", "0.5698102", "0.5695544...
0.59991854
3
Converts a one dimensional index to 2d.
def two_dim_index(self, k): ind_x = k % self.nx ind_y = (k - ind_x) / self.nx return (int(ind_y), int(ind_x))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index2d(src, idx):\n broadcast_to = P.BroadcastTo(idx.shape)\n offs = broadcast_to(P.range(Tensor(0, mindspore.int32),\n Tensor(idx.shape[0], mindspore.int32),\n Tensor(1, mindspore.int32))[:, None])\n idx = idx + (offs()) * idx.shape[1]\n\...
[ "0.67064077", "0.6169856", "0.60942876", "0.60095567", "0.5960693", "0.5943522", "0.59234434", "0.5917022", "0.58836246", "0.58741325", "0.5864474", "0.58585775", "0.58431876", "0.58389384", "0.5818341", "0.5752824", "0.5739784", "0.5734386", "0.57313216", "0.57089096", "0.56...
0.550443
35
Return a list of all the cells in the grid. We start increasing x first, i.e. 0th cell is the first cell, 1cell is the one with the next x in the list and y unchanged, .... Return array An array of size n_cells n_dims.
def cells_list(self): xx, yy = np.meshgrid(self.x_spacings, self.y_spacings) return np.vstack([yy.ravel(), xx.ravel()]).transpose()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_cells_from_dims(num_verts_x: int, num_verts_y: int):\n num_cells_x = num_verts_x - 1\n num_cells_y = num_verts_y - 1\n num_cells = num_cells_x*num_cells_y\n cell_array = np.zeros((num_cells, 4), dtype=int)\n cell_num = 0\n\n # I am sure this could be done in a more efficient way.\n ...
[ "0.7313377", "0.70912474", "0.70496106", "0.70136446", "0.70017177", "0.69983876", "0.6967043", "0.6942949", "0.69047695", "0.6899912", "0.6888806", "0.6857896", "0.68333375", "0.6820522", "0.6802178", "0.6766183", "0.66904247", "0.66788596", "0.6637702", "0.66127455", "0.660...
0.77503717
0
Calculates silence threshold per sound interval for chunking.
def get_silence_threshold(sound, lower_quantile): soundint = sound.to_intensity() max_intensity = call(soundint, 'Get quantile', 0.0, 0.0, 1) sil_intensity = call(soundint, 'Get quantile', 0.0, 0.0, lower_quantile) return sil_intensity - max_intensity
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def determine_silence_threshold(self):\n loudest_sound_cohort_size = 0.2 # Top 20% are counted in the loudest sound group.\n silence_threshold_multiplier = 1.6 # Sounds must be at least 1.6x as loud as the loudest silence\n\n rospy.loginfo(\"Getting intensity values from mic.\")\n sel...
[ "0.7811607", "0.7448463", "0.6895357", "0.6664065", "0.6417837", "0.6375742", "0.6263973", "0.61554515", "0.6127289", "0.60519105", "0.60171616", "0.5937067", "0.5910318", "0.5892728", "0.58905584", "0.5843424", "0.58425045", "0.5808453", "0.57665783", "0.5759342", "0.5737877...
0.6908193
2
Wrapper to run Praat 'To Textgrid (silences)' function.
def detect_silences(sound, sil_threshold, sil_duration): textgrid = call(sound, 'To TextGrid (silences)', 100, 0.0, sil_threshold, sil_duration, 0.1, 'silence', 'speech') return textgrid
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__ (self,win,text='Press a key to continue',**kwargs):\n\n self.win = win\n \n self.text = visual.TextStim(win,text=text,**kwargs)", "def __init__ (self,win,text='Press a key to continue',**kwargs):\n\n self.win = win\n \n self.text = visual.TextStim(win,text=t...
[ "0.5339875", "0.5339875", "0.52565366", "0.5225016", "0.5224651", "0.52221847", "0.52040446", "0.5149263", "0.50935054", "0.509346", "0.50882745", "0.50577587", "0.50410724", "0.50378585", "0.5034093", "0.5024333", "0.5018697", "0.50046563", "0.4991087", "0.49812207", "0.4980...
0.59195006
0
Saves chunked speech intervals as WAV file.
def save_chunks(chunk_sound, out_path, video_id): chunk_start_ms = int(chunk_sound.get_start_time()*1000) chunk_end_ms = int(chunk_sound.get_end_time()*1000) chunk_duration = chunk_end_ms - chunk_start_ms chunk_fn = '{0}_{1}_{2}.wav'.format(video_id, chunk_start_ms, chunk_end_ms) chunk_file_path = path.join(out_path, chunk_fn) chunk_sound.save(chunk_file_path, 'WAV') return {'filename': chunk_fn, 'video_id': video_id, 'start_time': chunk_start_ms, 'end_time': chunk_end_ms, 'duration': chunk_duration}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_wav(file_name, signal, fs):\n wavfile.write(file_name, fs, np.int16(signal/np.max(np.abs(signal)) * (2**(16)/2-1)))", "def save_audio(self, name=DEFAULT_OUT_NAME):\n print(\"Saving...\")\n wf = wave.open(name+'.wav', 'wb')\n wf.setnchannels(DEFAULT_CHANNELS)\n wf.setsampwi...
[ "0.6919104", "0.6847627", "0.672993", "0.6697336", "0.66271955", "0.6598934", "0.65593815", "0.65480053", "0.65218306", "0.6511665", "0.64606607", "0.6440448", "0.63984156", "0.6338785", "0.63294864", "0.6315476", "0.63118845", "0.63059294", "0.6304708", "0.6291267", "0.62757...
0.6976282
0
Selects which value to return.
def _return(*args): to_return = () for arg in args: cond, value = arg if cond: to_return += (value,) if len(to_return) == 1: return to_return[0] return to_return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getValue(name, default=None):", "def get_value(self):", "def getValue(self,value):\n if value in self.header.keys():\n return self.header[value]\n if value in self.subintinfo.keys():\n return self.subintinfo[value][-1]\n if self.params is None:\n return...
[ "0.6543452", "0.6478195", "0.64064497", "0.6406406", "0.640156", "0.6355146", "0.6348945", "0.634662", "0.634554", "0.6221234", "0.6221234", "0.6220085", "0.6185762", "0.61845344", "0.6182689", "0.61672604", "0.61638516", "0.61610883", "0.6157245", "0.6145623", "0.614436", ...
0.0
-1
Fetches data and metadata from an URL.
def get_content(url, etag=None, use_http_compression=True, return_etag=False, return_status_code=False, return_datetime=False, return_response=False): error_msg = 'HTTP GET %s' % (url,) # Sets the headers. headers = {} if etag: headers['If-None-Match'] = etag if not use_http_compression: headers['Accept-Encoding'] = '' downloaded_date = (return_datetime and [timezone.now()] or [None])[0] # Makes the request. try: response = requests.get(url, headers=headers) except StandardError as e: raise RequestsModuleError('%s - Requests module error\n%s' % (error_msg, e)) data = response.content etag = (return_etag and [response.headers.get('ETag', None)] or [None])[0] status_code = response.status_code return _return((True, data), (return_etag, etag), (return_status_code, status_code), (return_datetime, downloaded_date), (return_response, response))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __fetch_from_url(url: str) -> Any:\n song_information: Any = None\n try:\n # Send the request and load the returned contents.\n req = request.Request(url, headers={\n 'User-Agent': Config.Config.get_user_agent()\n })\n response = request....
[ "0.7141515", "0.68348056", "0.67148185", "0.6683118", "0.6625893", "0.6613337", "0.6553073", "0.6546756", "0.6502782", "0.6493208", "0.6449416", "0.6427715", "0.6386104", "0.6324223", "0.6319196", "0.63145965", "0.6295364", "0.6295271", "0.6283739", "0.6245581", "0.6242461", ...
0.0
-1
Takes input ends of all feed pipes and feeds odd numbers starting from low until high both inclusive. in a round robin fashion. process ends by feeding 1 to all pipes. 1 is a sentinel value.
def distributor(ls_feed_pipe_open,low,high): def getNumber(low,high): i = low if i%2 == 0: #if i is even, then start from i+1 odd. i += 1 while i<=high: yield i i+=2 #no need to check for even numbers, so skip it here at begining yield -1 #when generator yields -1, it reached high, so terminate next_pipe = 0 number = getNumber(low,high) while True: msg = next(number) if msg == -1: #to check when generator reached high. break else: #feed pipes in a round robin fashion, #so that over time each generatePrime process experiences same load. ls_feed_pipe_open[next_pipe].send(msg) next_pipe += 1 if next_pipe == len(ls_feed_pipe_open): next_pipe = 0 for p in ls_feed_pipe_open: p.send(-1) #-1 is sentinel value for all generatePrime processs return 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def odd():\n num = 0\n while True:\n yield num * (num & 1)\n num += 1", "def infinite_odd_generator():\n current = 1\n while True:\n yield current\n current = current + 2", "def input_pipe():\n x = ''\n while True:\n x = yield x\n yiel...
[ "0.5789352", "0.5761657", "0.5741719", "0.564393", "0.52422297", "0.51917", "0.50984246", "0.50861835", "0.5054945", "0.50331575", "0.50145054", "0.5011917", "0.50026035", "0.49603093", "0.49603093", "0.4935153", "0.49219003", "0.49094537", "0.4875977", "0.4841634", "0.483971...
0.68875015
0
will take numbers sequentially from feed_pipe, verify if it is prime. any primes found will be returned as a dict to main process. dict contains only one key value pair. val is always a list.
def generatePrime(ls_primes, feed_pipe,return_dict): local_primes = [] while True: n = feed_pipe.recv() if n == -1: # sentinel given by distributor. break else: is_prime = True ##check for divisibility ## no need to check for 2 since all are odd numbers for prime in ls_primes[1:]: if n%prime == 0: is_prime = False break ##if the number is prime, append to global list if is_prime: local_primes.append(n) if len(local_primes) >0: return_dict[os.getpid()] = local_primes return return_dict return 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def worker(nums, outdict):\n for n in nums:\n outdict[n] = primes2(n)", "def primes():\n D = {} # map composite integers to primes witnessing their compositeness\n q = 2 # first integer to test for primality\n while True:\n if q not in D:\n yield q # not mar...
[ "0.62043977", "0.60420763", "0.6040586", "0.59742284", "0.5961007", "0.59362507", "0.5920342", "0.5811969", "0.5799837", "0.57528454", "0.5740674", "0.5735719", "0.5734782", "0.5734576", "0.5731913", "0.5719384", "0.5716878", "0.5673636", "0.5661564", "0.56440914", "0.5617547...
0.78329885
0
Reject unsuported chain parts
def _select_simple_chainparts(chain_parts): for cp in chain_parts: if reject_substr_res.search(cp['chainPartName']): return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_chain():", "def reject(self):\n pass", "def test_blind_sig_chain_wrong_intermediary(self): # pylint: disable=too-many-locals\n\n test_levels = 4\n msg = os.urandom(1024)\n wrong_level = 2\n\n ca = ECCBlind()\n signer_obj = ca\n fake_intermediary = ...
[ "0.67994744", "0.5958347", "0.5583729", "0.5497606", "0.54252285", "0.54134977", "0.53917265", "0.53915894", "0.53751105", "0.53494143", "0.53485787", "0.5343248", "0.5343216", "0.53384286", "0.5323294", "0.5297185", "0.5291411", "0.52887464", "0.5273759", "0.5243703", "0.523...
0.6198813
1
Marshal information deom the selected chainParts to create a
def _make_simple_label(chain_parts): if not _select_simple_chainparts(chain_parts): msg = 'Jet Configuration error: '\ 'chain fails substring selection: not "simple" ' raise NotImplementedError(msg) label = 'simple([' for cp in chain_parts: smcstr = str(cp['smc']) jvtstr = str(cp['jvt']) if smcstr == 'nosmc': smcstr = '' for i in range(int(cp['multiplicity'])): # condition_str = '(%set,%s,%s)' % (str(cp['threshold']), # str(cp['etaRange']), # smcstr,) condition_str = '(%set,%s' % (str(cp['threshold']), str(cp['etaRange']),) if smcstr: # Run 2 chains have "INF" in the SMC substring condition_str += ',%s)' % smcstr.replace('INF','') elif jvtstr: condition_str += ',%s)' % jvtstr else: condition_str += ')' label += condition_str label += '])' return label
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeBinaryChains():\n\t\n\t# retrieve the binding partner specifications\n\t(maxsize,types) = getTypes()\n\t\n\t# Do some basic argument checking for this model\n\tif (len(types) < 2):\n\t\tprint \"Number of defined types must equal two for binary chain calculations.\"\n\t\treturn\n\tif (maxsize == 0):\n\t\tpr...
[ "0.5191058", "0.516895", "0.5164095", "0.5164095", "0.50821406", "0.5015414", "0.50149983", "0.49796292", "0.49461022", "0.49153453", "0.48709112", "0.48381686", "0.483411", "0.48162767", "0.48084295", "0.4796053", "0.4777216", "0.4726833", "0.4726833", "0.47081837", "0.46883...
0.0
-1
Marshal information deom the selected chainParts to create a 'simple_partition' label.
def _make_simple_partition_label(chain_dict): cps = chain_dict['chainParts'] if not (_select_simple_chainparts(cps)): raise NotImplementedError( 'chain fails substring selection: not "simple": %s' % ( chain_dict['chainName'])) label = 'simplepartition([' for cp in cps: smcstr = str(cp['smc']) if smcstr == 'nosmc': smcstr = '' for i in range(int(cp['multiplicity'])): # condition_str = '(%set,%s,%s)' % (str(cp['threshold']), # str(cp['etaRange']), # smcstr,) condition_str = '(%set,%s' % (str(cp['threshold']), str(cp['etaRange']),) if smcstr: condition_str += ',%s)' else: condition_str += ')' label += condition_str label += '])' return label
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _make_partitionsTest_label(chain_parts):\n\n assert len(chain_parts) == 1\n scenario = chain_parts[0]['hypoScenario']\n \n assert scenario == 'partitionsTest'\n\n \n\n return \"\"\"\n partgen(\n [(20et, 0eta320)]\n \n simple([(40et, 0eta320) (50et, 0eta320)])\n ...
[ "0.65343463", "0.53522164", "0.52719545", "0.52471644", "0.51894504", "0.5177348", "0.5096431", "0.5087608", "0.4973218", "0.4973218", "0.4970022", "0.4951215", "0.49493623", "0.49468526", "0.49310818", "0.492718", "0.49157664", "0.49112102", "0.49103266", "0.48851392", "0.48...
0.6581646
0
Marshal information deom the selected chainParts to create a
def _make_simple_comb_label(chain_dict): cps = chain_dict['chainParts'] if not (_select_simple_chainparts(cps)): raise NotImplementedError( 'chain fails substring selection: not "simple": %s' % ( chain_dict['chainName'])) simple_strs = [] for cp in cps: print(cp) simple_strs.append(_make_simple_label([cp])) label = 'combgen([(%d)]' % len(cps) for s in simple_strs: label += ' %s ' % s label += ')' return label
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makeBinaryChains():\n\t\n\t# retrieve the binding partner specifications\n\t(maxsize,types) = getTypes()\n\t\n\t# Do some basic argument checking for this model\n\tif (len(types) < 2):\n\t\tprint \"Number of defined types must equal two for binary chain calculations.\"\n\t\treturn\n\tif (maxsize == 0):\n\t\tpr...
[ "0.51896733", "0.5168605", "0.51672775", "0.51672775", "0.50873256", "0.5012869", "0.50128603", "0.49828157", "0.49484867", "0.49205998", "0.48682296", "0.48377433", "0.48344752", "0.4816704", "0.48074743", "0.47946405", "0.47819698", "0.47307587", "0.47307587", "0.470948", "...
0.0
-1
Marshal information from the selected chainParts to create a vbenf label. Use a Reducer for elimination of unusable jets
def _make_vbenf_label(chain_parts): # toy label for development: run simple and dijet independently. # simple makes Et cuts on two jets. Independently (sharing possible) # of jets choosean by simple, the dijet # scenario requires a dijet of mass > 900, and opening angle in phi > 2.6 assert len(chain_parts) == 1 scenario = chain_parts[0]['hypoScenario'] assert scenario.startswith('vbenf') args = _args_from_scenario(scenario) if not args: return 'and([]simple([(50et)(70et)])combgen([(2)] dijet([(900djmass, 26djdphi)])))' arg_res = [ re.compile(r'(?P<lo>\d*)(?P<key>fbet)(?P<hi>\d*)'), re.compile(r'(?P<lo>\d*)(?P<key>mass)(?P<hi>\d*)'), re.compile(r'(?P<lo>\d*)(?P<key>et)(?P<hi>\d*)'), ] defaults = { 'et': ('101', 'inf'), 'mass': ('800', 'inf'), 'fbet': ('501', 'inf'), } argvals = {} while args: assert len(args) == len(arg_res) arg = args.pop() for r in arg_res: m = r.match(arg) if m is not None: arg_res.remove(r) gd = m.groupdict() key = gd['key'] try: lo = float(gd['lo']) except ValueError: lo = defaults[key][0] argvals[key+'lo'] = lo try: hi = float(gd['hi']) except ValueError: hi = defaults[key][1] argvals[key+'hi'] = hi assert len(args) == len(arg_res) assert len(args) == 0 return """ and ( [] simple ( [(%(etlo).0fet, 500neta)(%(etlo).0fet, peta500)] ) combgen ( [(10et, 0eta320)] dijet ( [(%(masslo).0fdjmass, 26djdphi)] ) simple ( [(10et, 0eta320)(20et, 0eta320)] ) ) )""" % argvals
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chainDict2jetLabel(chain_dict):\n\n # suported scenarios \n router = {\n 'simple': _make_simple_label,\n 'HT': _make_ht_label,\n 'vbenf': _make_vbenf_label,\n 'dijet': _make_dijet_label,\n 'combinationsTest': _make_combinationsTest_label,\n 'partitionsTest': _mak...
[ "0.53284836", "0.52070326", "0.50032526", "0.4924041", "0.48997957", "0.48227805", "0.4819547", "0.4782699", "0.47695082", "0.4746857", "0.4743185", "0.47308764", "0.4726845", "0.46611047", "0.46597615", "0.463954", "0.46242067", "0.46234703", "0.45942166", "0.45858887", "0.4...
0.61593163
0
dijet label. supports dijet cuts, and cuts on particpating jets
def _make_dijet_label(chain_parts): assert len(chain_parts) == 1 scenario = chain_parts[0]['hypoScenario'] assert scenario.startswith('dijet') arg_res = [ re.compile(r'^(?P<lo>\d*)(?P<key>djmass)(?P<hi>\d*)$'), re.compile(r'^(?P<lo>\d*)(?P<key>j1et)(?P<hi>\d*)$'), re.compile(r'^(?P<lo>\d*)(?P<key>j1eta)(?P<hi>\d*)$'), re.compile(r'^(?P<lo>\d*)(?P<key>j2et)(?P<hi>\d*)$'), re.compile(r'^(?P<lo>\d*)(?P<key>j2eta)(?P<hi>\d*)$'), ] defaults = { 'j1et': ('100', 'inf'), 'j2et': ('100', 'inf'), 'j1eta': ('0', '320'), 'j2eta': ('0', '320'), 'djmass': ('1000', 'inf'), } args = _args_from_scenario(scenario) argvals = {} while args: assert len(args) == len(arg_res) arg = args.pop() for r in arg_res: m = r.match(arg) if m is not None: arg_res.remove(r) gd = m.groupdict() key = gd['key'] try: lo = float(gd['lo']) except ValueError: lo = defaults[key][0] argvals[key+'lo'] = lo try: hi = float(gd['hi']) except ValueError: hi = defaults[key][1] argvals[key+'hi'] = hi assert len(args) == len(arg_res) assert len(args) == 0 return """ combgen( [(2)(%(j1etlo).0fet, %(j1etalo).0feta%(j1etahi).0f) (%(j1etlo).0fet, %(j1etalo).0feta%(j1etahi).0f) ] dijet( [(%(djmasslo).0fdjmass)]) simple([(%(j1etlo).0fet, %(j1etalo).0feta%(j1etahi).0f) (%(j2etlo).0fet, %(j2etalo).0feta%(j2etahi).0f)]) )""" % argvals
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_info(config, cut, label):\n cfg = filter(lambda c: c['name'] == cut, config['physics']['cuts'])[0]\n text = \"\"\n if 'max' not in cfg:\n text += \"#geq \"\n text += str(cfg['min'])\n if 'max' in cfg and cfg['max'] != cfg['min']:\n text += '-' + str(cfg['max']) + ' ' + labe...
[ "0.5650385", "0.54846936", "0.54270923", "0.5375306", "0.53342646", "0.5226105", "0.5209129", "0.51919734", "0.51784825", "0.5173263", "0.5163355", "0.51560795", "0.5154937", "0.51164854", "0.5109441", "0.5093374", "0.50911057", "0.5076122", "0.50540954", "0.50480634", "0.504...
0.6397082
0
ht label. ht cuts, and cuts on particpating jets
def _make_ht_label(chain_parts): assert len(chain_parts) == 1, '_make_ht_label, no. of chain parts != 1' scenario = chain_parts[0]['hypoScenario'] assert scenario.startswith('HT'), '_make_ht_label(): scenario does not start with HT' arg_res = [ re.compile(r'^(?P<lo>\d*)(?P<key>ht)(?P<hi>\d*)$'), re.compile(r'^(?P<lo>\d*)(?P<key>et)(?P<hi>\d*)$'), re.compile(r'^(?P<lo>\d*)(?P<key>eta)(?P<hi>\d*)$'), ] defaults = { 'ht': ('0', 'inf'), 'et': ('0', 'inf'), 'eta': ('0', 'inf'), } args = _args_from_scenario(scenario) argvals = {} nargs = len(args) assert len(args) <= len(arg_res), 'bad num of args %d, expected < %d' % (len(args), len(arg_res)) # obtain argument values frrom scenario while args: arg = args.pop() for r in arg_res: m = r.match(arg) if m is not None: arg_res.remove(r) gd = m.groupdict() key = gd['key'] try: lo = float(gd['lo']) except ValueError: lo = float(defaults[key][0]) argvals[key+'lo'] = lo try: hi = float(gd['hi']) except ValueError: hi = float(defaults[key][1]) argvals[key+'hi'] = hi print (argvals) assert len(argvals) == 2*nargs, 'no of args: %d, expected %d' % (len(argvals), 2*nargs) print ('sent 100') result = """ ht([(%(htlo).0fht) (%(etlo).0fet) (%(etalo).0feta%(etahi).0f) ])""" % argvals print (result) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def label_thin(self, orig_label):\n pil_thin = thin(orig_label)\n # Keep the original label and set non-thinning label as 0\n orig_label[~pil_thin] = 0\n\n return orig_label", "def kohonen():\n# plb.close('all')\n \n dim = 28*28\n data_range = 255.0\n \n # load in da...
[ "0.5253033", "0.5244755", "0.5173087", "0.51096773", "0.5103869", "0.50852627", "0.5053167", "0.4967331", "0.49329308", "0.4927268", "0.4886447", "0.4883699", "0.48704627", "0.48665786", "0.48657504", "0.48568624", "0.484965", "0.48423848", "0.48153552", "0.4808797", "0.47966...
0.5767312
0
make test label for combinations helper with two simple children.
def _make_combinationsTest_label(chain_parts): assert len(chain_parts) == 1 scenario = chain_parts[0]['hypoScenario'] assert scenario == 'combinationsTest' return """ combgen( [(2)(20et, 0eta320)] simple([(40et, 0eta320) (50et, 0eta320)]) simple([(35et, 0eta240) (55et, 0eta240)]) )"""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_sums():\n assert label_parent(1, 2) == 3\n assert label_parent (1, 4) == 8\n # Should ignore arg order\n assert label_parent(4, 1) == 8", "def _make_partitionsTest_label(chain_parts):\n\n assert len(chain_parts) == 1\n scenario = chain_parts[0]['hypoScenario']\n \n assert scenari...
[ "0.6137433", "0.6108757", "0.60195917", "0.5986544", "0.5936767", "0.58589", "0.5759686", "0.56950617", "0.5624841", "0.55902916", "0.55750483", "0.5560212", "0.5554626", "0.55542696", "0.5553175", "0.5553175", "0.55467266", "0.5503819", "0.5457172", "0.5451371", "0.54313546"...
0.6972838
0
make test label for combinations helper with two simple children.
def _make_partitionsTest_label(chain_parts): assert len(chain_parts) == 1 scenario = chain_parts[0]['hypoScenario'] assert scenario == 'partitionsTest' return """ partgen( [(20et, 0eta320)] simple([(40et, 0eta320) (50et, 0eta320)]) simple([(35et, 0eta240) (55et, 0eta240)]) )"""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _make_combinationsTest_label(chain_parts):\n\n assert len(chain_parts) == 1\n scenario = chain_parts[0]['hypoScenario']\n \n assert scenario == 'combinationsTest'\n\n \n\n return \"\"\"\n combgen(\n [(2)(20et, 0eta320)]\n \n simple([(40et, 0eta320) (50et, 0eta320)])...
[ "0.6972838", "0.6137433", "0.60195917", "0.5986544", "0.5936767", "0.58589", "0.5759686", "0.56950617", "0.5624841", "0.55902916", "0.55750483", "0.5560212", "0.5554626", "0.55542696", "0.5553175", "0.5553175", "0.55467266", "0.5503819", "0.5457172", "0.5451371", "0.54313546"...
0.6108757
2
Entry point to this Module. Return a chain label according to the value of cp['hypoScenario'], where cp is an element of list/ chainDict['chainPart']
def chainDict2jetLabel(chain_dict): # suported scenarios router = { 'simple': _make_simple_label, 'HT': _make_ht_label, 'vbenf': _make_vbenf_label, 'dijet': _make_dijet_label, 'combinationsTest': _make_combinationsTest_label, 'partitionsTest': _make_partitionsTest_label, } # chain_part - scenario association cp_sorter = {} for k in router: cp_sorter[k] = [] for cp in chain_dict['chainParts']: if cp['signature'] != 'Jet' and cp['signature'] != 'Bjet': continue for k in cp_sorter: if cp['hypoScenario'].startswith(k): cp_sorter[k].append(cp) break # obtain labels by scenario. labels = [] for k, chain_parts in cp_sorter.items(): if chain_parts: labels.append(router[k](chain_parts)) assert labels nlabels = len(labels) if nlabels == 1: return labels[0] if nlabels == 2: alabel = """\ and([] %s %s)""" % (tuple(labels)) return alabel # more than 2 labels is not expected assert False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _make_ht_label(chain_parts):\n\n assert len(chain_parts) == 1, '_make_ht_label, no. of chain parts != 1'\n scenario = chain_parts[0]['hypoScenario']\n \n assert scenario.startswith('HT'), '_make_ht_label(): scenario does not start with HT'\n\n arg_res = [\n re.compile(r'^(?P<lo>\\d*)(?P<k...
[ "0.67336076", "0.6324823", "0.5675857", "0.56554145", "0.5556557", "0.54489195", "0.5372017", "0.53109175", "0.5194049", "0.509463", "0.50940394", "0.49333954", "0.49087635", "0.4816282", "0.47896782", "0.47874323", "0.4760651", "0.47558823", "0.47320828", "0.47163337", "0.46...
0.6201193
2
(Set, float, float, int, str) > list Filters a set of Products according to the parameters. This function is responsible to determine if filtering with tags should be applied or not.
def get_matching_products(products, lat, lng, radius, tags): if tags: tag_list = tags.split(',') return list([ product for product in products if is_matching_product_with_tags( product, lat, lng, radius, tag_list ) ]) else: return list([ product for product in products if is_matching_product( product, lat, lng, radius ) ])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_generic(products, listings, result=None):\n print \"Apply Generic Filtering \"\n if result == None:\n result = {}\n matched_listings = []\n for alist in listings:\n manufacturer, renamed_manufacturer = find_manufacturer(products, alist)\n if manufacturer == False:\n ...
[ "0.66341794", "0.6542159", "0.63417774", "0.6290791", "0.61444324", "0.61051065", "0.5993559", "0.5917431", "0.5875063", "0.5852951", "0.578841", "0.5734029", "0.57259727", "0.5694228", "0.5673258", "0.565935", "0.5637606", "0.56313235", "0.5576161", "0.5563928", "0.5539448",...
0.6570375
1
(Product, float, float, radius) > boolean Check if the coordinates of a shop is within a radius (in meters) using the Vincenty's formulae.
def is_matching_product(product, lat, lng, radius): return vincenty( (lat, lng), (product.shop.lat, product.shop.lng) ).meters <= radius
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_matching_product_with_tags(product, lat, lng, radius, tags):\n return vincenty(\n (lat, lng),\n (product.shop.lat, product.shop.lng)\n ).meters <= radius and any(tag in product.shop.tags for tag in tags)", "def __contains__(self, position):\n return sum([(c1...
[ "0.64729494", "0.59081954", "0.5859355", "0.58463377", "0.5835103", "0.5793143", "0.5749297", "0.5747117", "0.571432", "0.5694992", "0.5625121", "0.55783933", "0.5532883", "0.5531398", "0.55265725", "0.5519289", "0.54891366", "0.5458684", "0.54542017", "0.5451329", "0.5381592...
0.7570688
0
(Product, float, float, radius, list) > boolean Check if the coordinates of a shop is within a radius (in meters) using the Vincenty's formulae and if the shop contains any of the tags provided.
def is_matching_product_with_tags(product, lat, lng, radius, tags): return vincenty( (lat, lng), (product.shop.lat, product.shop.lng) ).meters <= radius and any(tag in product.shop.tags for tag in tags)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_matching_product(product, lat, lng, radius):\n return vincenty(\n (lat, lng),\n (product.shop.lat, product.shop.lng)\n ).meters <= radius", "def shops_within_radius(self, lat, lng, radius, tags=None):\n center_point = geoindex.GeoPoint(lat, lng)\n poi...
[ "0.7254775", "0.61709523", "0.5765121", "0.57588995", "0.5667875", "0.5657872", "0.5615331", "0.5498272", "0.54953516", "0.5392794", "0.5387623", "0.5384196", "0.53837055", "0.5313938", "0.52996296", "0.5263196", "0.5251948", "0.5240129", "0.5167428", "0.51551384", "0.5082203...
0.78412956
0
Create a copy of a facemap proc file, but pointing to a new video. By default, the new proc file is created in the same folder as the new videofile and named videofile_proc.npy.
def copy_facemap_roi(procfile, videofile, outputfile=None): videodata = np.load(procfile, allow_pickle=True).item() videodata['filenames'] = [[videofile]] if outputfile is None: outputfile = os.path.splitext(videofile)[0]+'_proc.npy' if os.path.isfile(outputfile): print(f'File {outputfile} exists. It will not be overwritten.') return None np.save(outputfile, videodata) return outputfile
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_video(input_file, output_file):\n input_video = VideoFileClip(input_file)\n output_video = input_video.fl_image(detect_lane.fit_and_plot)\n output_video.write_videofile(output_file, audio=False)", "def process_video(lane, fname, output):\n\tclip = VideoFileClip(fname)\n\toutput_name = output\...
[ "0.6444913", "0.6132553", "0.6021357", "0.6021357", "0.5793323", "0.575927", "0.56994724", "0.5620519", "0.5565024", "0.5488642", "0.54845893", "0.5479945", "0.5418265", "0.5404724", "0.53233945", "0.5318268", "0.5299321", "0.5261676", "0.52610755", "0.51977015", "0.51628315"...
0.8082349
0
Find the onsets in the array representing the synchronization light. This function assumes the onsets are periodic (with randomness within 0.5T and 1.5T). The function can also fix missing onsets.
def find_sync_light_onsets(sync_light, invert=True, fixmissing=False): # -- Find changes in synch light -- sync_light_diff = np.diff(sync_light, prepend=0) if invert: sync_light_diff = -sync_light_diff sync_light_diff[sync_light_diff < 0] = 0 sync_light_threshold = 0.2*sync_light_diff.max() sync_light_onset = sync_light_diff > sync_light_threshold # -- Find period of sync_light_onset -- sync_light_onset_ind = np.where(sync_light_onset)[0] sync_light_onset_diff = np.diff(sync_light_onset_ind) # In units of frames expected_onset_period = np.median(sync_light_onset_diff) # In units of (float) frames # -- Remove repeated onsets -- onset_freq_upper_threshold = int(1.5 * expected_onset_period) onset_freq_lower_threshold = int(0.5 * expected_onset_period) repeated_onsets = sync_light_onset_diff < onset_freq_lower_threshold repeated_onsets_ind = np.where(repeated_onsets)[0] fixed_sync_light_onset = sync_light_onset.copy() fixed_sync_light_onset[sync_light_onset_ind[repeated_onsets_ind+1]] = False # -- Fix missing onsets -- if fixmissing: missing_next_onsets = sync_light_onset_diff > onset_freq_upper_threshold missing_next_onsets_ind = np.where(missing_next_onsets)[0] for indm, missing_onset_ind in enumerate(missing_next_onsets_ind): onset_diff = sync_light_onset_diff[missing_onset_ind] n_missing = int(np.round(onset_diff / expected_onset_period))-1 #print(n_missing) last_onset_ind = sync_light_onset_ind[missing_onset_ind] next_onset_ind = sync_light_onset_ind[missing_onset_ind+1] period_missing = (next_onset_ind - last_onset_ind)//(n_missing+1) new_onset_inds = last_onset_ind + np.arange(1, n_missing+1)*period_missing #print([last_onset_ind, next_onset_ind]) #print(new_onset_inds) fixed_sync_light_onset[new_onset_inds] = True return fixed_sync_light_onset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_onsets(self):\n get_onsets = ess.OnsetRate()\n # onset_times is np array\n self.onset_times, onset_rate = get_onsets(self.audio)\n # Onset as sample number in the audio signal\n index2delete = []\n previous_time = -9999999\n for index, itime in enumerate(se...
[ "0.6857784", "0.6249284", "0.58837444", "0.5452273", "0.53577805", "0.5303218", "0.52744794", "0.52505463", "0.51989776", "0.51802486", "0.51636773", "0.50905186", "0.507182", "0.5051442", "0.5007559", "0.50056607", "0.49910834", "0.4961425", "0.4949146", "0.493811", "0.49135...
0.7570172
0
Estimate whether the animal was running during each trial. This function first smooths the running trace according to smoothsize (noncausal), it then uses the average of N presamples before the onset to to estimate whether running was higher than the threshold.
def estimate_running_each_trial(running_trace, trial_onset, smoothsize=10, presamples=4, threshold=3, showfig=False): smoothwin = np.ones(smoothsize)/(smoothsize) running_trace_smooth = np.convolve(running_trace, smoothwin, mode='same') trial_onset_ind = np.where(trial_onset)[0] presamples_inds = np.arange(-presamples, 0) + trial_onset_ind[:, np.newaxis] pretrial_avg = running_trace_smooth[presamples_inds].mean(axis=1) running_each_trial = pretrial_avg > threshold if showfig: plt.cla() plt.plot(running_trace_smooth, '0.8') plt.plot(trial_onset_ind, pretrial_avg, 'xg') plt.plot(trial_onset_ind, running_each_trial*running_trace_smooth.max(), 'og') plt.axhline(threshold, color='k') plt.legend(['running_trace_smooth', 'pretrial_avg', 'running_each_trial'], loc='upper right') plt.show() return running_each_trial, running_trace_smooth
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def punches(self):\n #:TODO Need to parameterize n\n # Initialize smoothing function\n # Also because I can't take the second derivitive\n\n n = 3\n assert (len(self.averages)==len(self.timestamps))\n size = len(self.averages)\n slopes = []\n for t in [0,size...
[ "0.5619866", "0.5553437", "0.5524997", "0.53908414", "0.5296018", "0.5253825", "0.5213897", "0.52011967", "0.51841336", "0.5176683", "0.51282734", "0.5120962", "0.51179755", "0.5112065", "0.50441957", "0.50383514", "0.503653", "0.50297564", "0.4981896", "0.4948819", "0.493829...
0.7172721
0
This test should not be run as a part of the normal test suite. This is a resource test only! Nose2 will find it. Unittest will not.
def test_will_get_nwis_return_response(): expected = 200 response = hf.get_nwis('01585200', 'dv', '2001-01-01', '2001-01-02') actual = response.status_code assert expected == actual print('NWIS is up and running!')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_subsystems(self):\n pass", "def test_create_system_entire(self):\n pass", "def unitary_test():", "def test(self):\n pass", "def test_create_run(self):\n pass", "def test_4_4_1_1(self):\n pass", "def _test(self):\n pass", "def _test(self):\n pa...
[ "0.71541893", "0.713073", "0.71006393", "0.7076272", "0.70147574", "0.69360954", "0.6920686", "0.6920686", "0.6920686", "0.6887088", "0.6876075", "0.6876075", "0.6876075", "0.6876075", "0.6876075", "0.6841704", "0.6797133", "0.67678326", "0.67677563", "0.675755", "0.6699573",...
0.0
-1