text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|>avetxt("valid.csv", valid, fmt='%s', delimiter=',', header= head) np.savetxt("test.csv", test, fmt='%s', delimiter=',', header= head) filename = sys.argv[1] createtv(filename)<|fim_prefix|># repo: nandini269/graph-hyperband path: /create_tv.py import sys import numpy as np import csv def createtv(fil...
code_fim
medium
{ "lang": "python", "repo": "nandini269/graph-hyperband", "path": "/create_tv.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: nandini269/graph-hyperband path: /create_tv.py import sys import numpy as np import csv def createtv(filename): r = csv.reader(open(filename), delimiter=",") res = np.array(list(r)) head = res[0][0] for i in range(1,len(res[0])): head = head + ',' + res[0][i] #print(head) res = res[1:]...
code_fim
medium
{ "lang": "python", "repo": "nandini269/graph-hyperband", "path": "/create_tv.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yanchdh/LeetCode path: /80-89/88_Merge Sorted Array.py # -*- coding:utf-8 -*- # https://leetcode.com/problems/merge-sorted-array/description/ class Solution(object): <|fim_suffix|> """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int ...
code_fim
hard
{ "lang": "python", "repo": "yanchdh/LeetCode", "path": "/80-89/88_Merge Sorted Array.py", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|> self.tmp_dir = tempfile.mkdtemp() self.workspace = context.Workspace(self.tmp_dir) def tearDown(self): shutil.rmtree(self.tmp_dir) def test_contains(self): p = 'foo' self.assertFalse(self.workspace.Contains(p)) with open(os.path.join(self.tmp_dir, ...
code_fim
medium
{ "lang": "python", "repo": "GoogleCloudPlatform/runtimes-common", "path": "/ftl/common/context_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> shutil.rmtree(self.tmp_dir) def test_contains(self): p = 'foo' self.assertFalse(self.workspace.Contains(p)) with open(os.path.join(self.tmp_dir, p), 'w') as f: f.write('hey') self.assertTrue(self.workspace.Contains(p)) # Subdir d = ...
code_fim
medium
{ "lang": "python", "repo": "GoogleCloudPlatform/runtimes-common", "path": "/ftl/common/context_test.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: GoogleCloudPlatform/runtimes-common path: /ftl/common/context_test.py # Copyright 2017 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at ...
code_fim
medium
{ "lang": "python", "repo": "GoogleCloudPlatform/runtimes-common", "path": "/ftl/common/context_test.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def main(): L = [2, 4, 6, 2, 5] print(f"largest sum of non-adjacent numbers of L={L} -> {largest_sum_nonadjacents_numbers_1(L)}") L = [5, 1, 1, 5] print(f"largest sum of non-adjacent numbers of L={L} -> {largest_sum_nonadjacents_numbers_1(L)}") if __name__ == '__main__': main()<|fim...
code_fim
hard
{ "lang": "python", "repo": "yoyonel/DailyCodingProblem", "path": "/src/dailycodingproblem/9_Sum_Of_Non_Adjacent_Numbers/app.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: yoyonel/DailyCodingProblem path: /src/dailycodingproblem/9_Sum_Of_Non_Adjacent_Numbers/app.py """ largest sum of non-adjacent numbers of L=[2, 4, 6, 2, 5] -> 13 largest sum of non-adjacent numbers of L=[5, 1, 1, 5] -> 10 """ from typing import List <|fim_suffix|> def largest_sum_nonadjacents_num...
code_fim
hard
{ "lang": "python", "repo": "yoyonel/DailyCodingProblem", "path": "/src/dailycodingproblem/9_Sum_Of_Non_Adjacent_Numbers/app.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: muhaiminmuh/School-Academic-Management-System-SIAKAD path: /master/admin.py from django.contrib import admin from master.models import * # Register your models here. class ProgramStudiAdmin (admin.ModelAdmin) : list_display = ['kode_progdi', 'nama_progdi'] list_filter = () search_fields = ['...
code_fim
hard
{ "lang": "python", "repo": "muhaiminmuh/School-Academic-Management-System-SIAKAD", "path": "/master/admin.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>admin.site.register(MataKuliah, MataKuliahAdmin) class KelasAdmin (admin.ModelAdmin) : list_display = ['nama_kelas'] search_fields = ['nama_kelas'] list_per_page = 20 admin.site.register(Kelas, KelasAdmin) class KurikulumAdmin (admin.ModelAdmin ) : list_display = ['kode_kurikulum', 'nama_kurikulum'...
code_fim
hard
{ "lang": "python", "repo": "muhaiminmuh/School-Academic-Management-System-SIAKAD", "path": "/master/admin.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#make boxplot sns.set_style("whitegrid") b=sns.color_palette(["#866080"]) box_plot=sns.boxplot(y='Dice', x='Algorithm', data=df, palette=b) plt.xlabel('Skull-Stripping Methods') plt.ylabel('Dice Similarity Coefficients') plt.ylim((0.7,1.0)) plt.title('NFBS') plt.savefig('boxplot_NFBS2.png')<|fim_prefix|>#...
code_fim
hard
{ "lang": "python", "repo": "preprocessed-connectomes-project/NFB_skullstripped", "path": "/validation_scripts/dice_boxplot_NFBS.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: preprocessed-connectomes-project/NFB_skullstripped path: /validation_scripts/dice_boxplot_NFBS.py #DICE coefficient plot #Ben Puccio #2016-06-08 # # #Load numpy arrays of NFBS dice coefficients from dice.py #Make boxplot using Matplotlib and Seaborn import numpy as np import matplotlib.pyplot a...
code_fim
hard
{ "lang": "python", "repo": "preprocessed-connectomes-project/NFB_skullstripped", "path": "/validation_scripts/dice_boxplot_NFBS.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>total_elements = len(cc_imgs) batch_size = 32 cc_data_de = {"images":[], "dataset": cc_data['dataset']} output_cc_data_path = '/'.join([data_path, "dataset_cc_de.json"]) start_time = time.perf_counter() for i in tqdm(range(0,total_elements,batch_size)): #form the batch of sentences captions_en_ba...
code_fim
hard
{ "lang": "python", "repo": "zmykevin/fairseq", "path": "/translate_cc.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>#Translate the CC cc_imgs = cc_data['images'] total_elements = len(cc_imgs) batch_size = 32 cc_data_de = {"images":[], "dataset": cc_data['dataset']} output_cc_data_path = '/'.join([data_path, "dataset_cc_de.json"]) start_time = time.perf_counter() for i in tqdm(range(0,total_elements,batch_size)): ...
code_fim
medium
{ "lang": "python", "repo": "zmykevin/fairseq", "path": "/translate_cc.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: zmykevin/fairseq path: /translate_cc.py import torch import os import json from tqdm import tqdm import time #Load the translation model #en2de = torch.hub.load('pytorch/fairseq', 'transformer.wmt16.en-de',tokenizer='moses', bpe='subword_nmt') en2de = torch.hub.load('pytorch/fairseq', 'transform...
code_fim
hard
{ "lang": "python", "repo": "zmykevin/fairseq", "path": "/translate_cc.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for next_piece in pieces: planner.game.piece = piece planner.game.next_piece = next_piece key1 = (letter_pieces[piece], letter_pieces[next_piece]) if not key1 in self[key0]: move = planner.move() letter = letter_pieces[move.piece] rotation = m...
code_fim
medium
{ "lang": "python", "repo": "vancezuo/block-battle-bot", "path": "/openings.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: vancezuo/block-battle-bot path: /openings.py #!/usr/bin/env python from __future__ import print_function, division from game import Game, Placement, pieces, letter_pieces, piece_letters from collections import deque from copy import copy <|fim_suffix|> key1 = (letter_pieces[piece], ...
code_fim
hard
{ "lang": "python", "repo": "vancezuo/block-battle-bot", "path": "/openings.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AsadRasheed-AR/Xtreme-Vision path: /xtreme_vision/Segmentation/cdcl/inference_15parts_skeletons.py ori_paf_idx = [12, 13, 20, 21, 14, 15, 16, 17, 22, 23, 24, 25, 0, 1, 2, 3, \ 4, 5, 6, 7, 8, 9, 10, 11, 28, 29, 30, 31, 34,35, 32, 33, 36, 37, 18, 19, 26, 27] flip_paf_idx = [20, 21...
code_fim
hard
{ "lang": "python", "repo": "AsadRasheed-AR/Xtreme-Vision", "path": "/xtreme_vision/Segmentation/cdcl/inference_15parts_skeletons.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> connection_all.append(connection) else: special_k.append(k) connection_all.append([]) # last number in each row is the total parts number of that person # the second last number in each row is the score of the overall configuration subset = -1 * np....
code_fim
hard
{ "lang": "python", "repo": "AsadRasheed-AR/Xtreme-Vision", "path": "/xtreme_vision/Segmentation/cdcl/inference_15parts_skeletons.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> segmap_a = np.maximum(segmap_scale1,segmap_scale2) segmap_b = np.maximum(segmap_scale4,segmap_scale3) segmap_c = np.maximum(segmap_scale5,segmap_scale6) segmap_d = np.maximum(segmap_scale7,segmap_scale8) seg_ori = np.maximum(segmap_a, segmap_b) seg_flip = np.maximum(segmap_c, segma...
code_fim
hard
{ "lang": "python", "repo": "AsadRasheed-AR/Xtreme-Vision", "path": "/xtreme_vision/Segmentation/cdcl/inference_15parts_skeletons.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: alpinho/winrepo path: /profiles/views.py matching_domains = list( Q(domains__contains=code) for code, name in Profile.get_domains_choices() if st_regex.match(name) ) st_conditions = [ ...
code_fim
hard
{ "lang": "python", "repo": "alpinho/winrepo", "path": "/profiles/views.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> class UserPasswordResetView(FormView): form_class = PasswordResetForm template_name = 'registration/reset_password.html' success_message = 'If your e-mail address is in our registry, you will receive an e-mail soon on how to reset your password.' def get(self, request, *args, **kwargs): ...
code_fim
hard
{ "lang": "python", "repo": "alpinho/winrepo", "path": "/profiles/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # deactivate account until email is verified self.object = original_user form.instance.is_active = False form.instance.email = original_user.email self.success_message = self.email_success_message form.changed...
code_fim
hard
{ "lang": "python", "repo": "alpinho/winrepo", "path": "/profiles/views.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: SJTU-Thinklab-Det/DOTA-DOAI path: /FPN_Tensorflow/libs/networks/resnet.py # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, division import tensorflow as tf import tensorflow.contrib.slim as slim from libs.configs import cfgs from tensorflow.contrib.slim.nets impo...
code_fim
hard
{ "lang": "python", "repo": "SJTU-Thinklab-Det/DOTA-DOAI", "path": "/FPN_Tensorflow/libs/networks/resnet.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def resnet_base(img_batch, scope_name, is_training=True): ''' this code is derived from light-head rcnn. https://github.com/zengarden/light_head_rcnn It is convenient to freeze blocks. So we adapt this mode. ''' if scope_name == 'resnet_v1_50': middle_num_units = 6 eli...
code_fim
hard
{ "lang": "python", "repo": "SJTU-Thinklab-Det/DOTA-DOAI", "path": "/FPN_Tensorflow/libs/networks/resnet.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def ajax_insert_absent(request, coursid, etudiantid): if True:#request.is_ajax(): cours = Cours.objects.get(id=coursid) user = User.objects.get(username=etudiantid) etudiant = Etudiant.objects.get(user=user) absence = Absence(cours = cours, etudiant = etudiant) ...
code_fim
hard
{ "lang": "python", "repo": "tornoz/ezvezans", "path": "/absences/abs/views.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: tornoz/ezvezans path: /absences/abs/views.py from django.shortcuts import render, redirect from django.http import HttpResponse from django.contrib.auth.decorators import login_required from django.template import RequestContext, loader from django.contrib.auth.models import User, Group from abs....
code_fim
hard
{ "lang": "python", "repo": "tornoz/ezvezans", "path": "/absences/abs/views.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> #Formset Formset = modelformset_factory(Absence) var['formset'] = Formset(queryset=Absence.objects.none()) #Limite les cours du formset à ceux de l'enseignant var['formset'].forms[0].fields['cours'].queryset = Cours.objects.filter(enseignant = var['enseigna...
code_fim
hard
{ "lang": "python", "repo": "tornoz/ezvezans", "path": "/absences/abs/views.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|># repo: tillhainbach/pyansiescapes path: /tests/test_color_256.py from pyansiescapes.pyansiescapes import ColorDrawingLevel, Colors, Colors256 from itertools import chain from collections.abc import Iterable import sys def _print_color(color = "0", colormode = "", color256 = "", drawing_level = "3", dis...
code_fim
hard
{ "lang": "python", "repo": "tillhainbach/pyansiescapes", "path": "/tests/test_color_256.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if not isinstance(drawing_level, ColorDrawingLevel): drawing_level = ColorDrawingLevel[drawing_level] if any((display_hex, display_rgb, display_hsl)): # just display 256 bit colors colormodes = [256] display_string_length = 6 max_characters_per_line = 72 iter_...
code_fim
hard
{ "lang": "python", "repo": "tillhainbach/pyansiescapes", "path": "/tests/test_color_256.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for colormode in colormodes: colormode_string = "" color256 = "" for color in chain.from_iterable(iter_dict[colormode]): display_name = _make_display_name(color, display_colorid, display_colorname, display_hex, display_rgb, display_hsl) color_int = int(c...
code_fim
hard
{ "lang": "python", "repo": "tillhainbach/pyansiescapes", "path": "/tests/test_color_256.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: JohnReid/bioinf-utilities path: /scripts/seq-head #!/usr/bin/env python2 # # Copyright John Reid 2009, 2010, 2013 # """ Code that reads in sequences and outputs first so many """ <|fim_suffix|>for i, seq in zip( xrange(options.num_seqs), F.iterseq(input, corebio.seq.dna_alphabet...
code_fim
hard
{ "lang": "python", "repo": "JohnReid/bioinf-utilities", "path": "/scripts/seq-head", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>for i, seq in zip( xrange(options.num_seqs), F.iterseq(input, corebio.seq.dna_alphabet)): F.writeseq(sys.stdout, seq)<|fim_prefix|># repo: JohnReid/bioinf-utilities path: /scripts/seq-head #!/usr/bin/env python2 # # Copyright John Reid 2009, 2010, 2013 # """ Code that reads in sequen...
code_fim
hard
{ "lang": "python", "repo": "JohnReid/bioinf-utilities", "path": "/scripts/seq-head", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|># # Check args # if 1 != len(args): print >> sys.stderr, 'USAGE: %s <fasta file>' % __file__ sys.exit(-1) fasta = args[0] if '-' == fasta: input = sys.stdin else: input = bioinfutils.open_input(fasta) for i, seq in zip( xrange(options.num_seqs), F.iterseq(input, corebio.se...
code_fim
hard
{ "lang": "python", "repo": "JohnReid/bioinf-utilities", "path": "/scripts/seq-head", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: daniel-andersen/Interactive-Tabletop-Projected-Old path: /Server/src/board/markers/marker_util.py from default_marker import DefaultMarker from triangle_marker import TriangleMarker def create_marker_from_name(name=None, marker_id=-1): if name is None: return DefaultMarker(marker_id...
code_fim
hard
{ "lang": "python", "repo": "daniel-andersen/Interactive-Tabletop-Projected-Old", "path": "/Server/src/board/markers/marker_util.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> :param marker_result_list: Marker result list :return: List of dictionaries with "contour" key filtered out """ return [filter_out_contour_from_marker_result(marker_result) for marker_result in marker_result_list] def filter_out_contour_from_marker_result(marker_result): """ Filt...
code_fim
medium
{ "lang": "python", "repo": "daniel-andersen/Interactive-Tabletop-Projected-Old", "path": "/Server/src/board/markers/marker_util.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|># get lemmatization response = requests.get( url='http://localhost:9001/get-lemma', params={ 'text': text, }, ) print(response.json()) # get state abbrevitaions response = requests.get( url='http://localhost:9001/convert-state-abbreviation', params={ 'queries': json.du...
code_fim
hard
{ "lang": "python", "repo": "ophirgal/sm-scraper", "path": "/src/nlp/example.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: ophirgal/sm-scraper path: /src/nlp/example.py import requests, json text = 'Police say John Doe was seen doing a thing in Elizabeth, New Jersey on May 32, 1999.' print(f'INPUT: {text}') <|fim_suffix|># get entities response = requests.get( url='http://localhost:9001/get-entities', para...
code_fim
hard
{ "lang": "python", "repo": "ophirgal/sm-scraper", "path": "/src/nlp/example.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: initzhang/Hetu path: /examples/ctr/tf_models/tf_dcn_criteo.py import tensorflow as tf def cross_layer(x0, x1, device): # x0: input embedding feature (batch_size, 26 * embedding_size + 13) # x1: the output of last layer (batch_size, 26 * embedding_size + 13) embed_dim = x1.shape[-1]...
code_fim
hard
{ "lang": "python", "repo": "initzhang/Hetu", "path": "/examples/ctr/tf_models/tf_dcn_criteo.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> with tf.device('/gpu:0'): flatten = tf.reshape(sparse_input_embedding, (-1, 26*embedding_size)) x = tf.concat((flatten, dense_input), 1) # CrossNet cross_output = build_cross_layer(x, num_layers=3, device=device) ...
code_fim
hard
{ "lang": "python", "repo": "initzhang/Hetu", "path": "/examples/ctr/tf_models/tf_dcn_criteo.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>def _if_else_statement(args=None): """ Draw a specific number of spirographs if a command line option is given. Otherwise, draw 4 spirographs. Parameters ---------- args : argparse.Namespace, optional Optional command line arguments. Returns ------- None "...
code_fim
hard
{ "lang": "python", "repo": "hestrang1993/pp", "path": "/spirograph/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # checks args and draw if args.sparams: parameters = [float(x) for x in args.sparams] # draw spirograph with given parameters # black by default col = (0.0, 0.0, 0.0) spirograph = Spirograph(0, 0, col, *parameters) spirograph.draw() else: ...
code_fim
hard
{ "lang": "python", "repo": "hestrang1993/pp", "path": "/spirograph/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: hestrang1993/pp path: /spirograph/main.py """ The :mod:`spirograph.main` module contains the :function:`main`. The :function:`main` function, along with it's associated helper functions, will make it easy to draw multiple spirographs from the command line. """ import argparse import turtle from...
code_fim
hard
{ "lang": "python", "repo": "hestrang1993/pp", "path": "/spirograph/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Run LBP while loop while cond_fun(alpha_beta_iteration): alpha_beta_iteration = body_fun(alpha_beta_iteration) alphabeta, _ = alpha_beta_iteration # Compute two consecutive marginals marginal = marginal_from_alphabeta(alphabeta) marginal_plus_one_iteration = marginal_from_alphabeta(lbp...
code_fim
hard
{ "lang": "python", "repo": "Ayoob7/google-research", "path": "/grouptesting/samplers/loopy_belief_propagation.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ayoob7/google-research path: /grouptesting/samplers/loopy_belief_propagation.py # coding=utf-8 # Copyright 2020 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a co...
code_fim
hard
{ "lang": "python", "repo": "Ayoob7/google-research", "path": "/grouptesting/samplers/loopy_belief_propagation.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> Args: rng : random PRNG key state : state object containing all relevant information to produce sample Returns: a measure of the quality of convergence, here gap_between_consecutives also updates particle_weights and particles members. """ self.particle_weights = ...
code_fim
hard
{ "lang": "python", "repo": "Ayoob7/google-research", "path": "/grouptesting/samplers/loopy_belief_propagation.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>ft_xor_sum = num ^ left_xor_sum else: right_xor_sum = num ^ right_xor_sum return [left_xor_sum, right_xor_sum]<|fim_prefix|># repo: pauvrepetit/leetcode path: /others/剑指 Offer/56/main.py from typing import List class Solution: def singleNumbers(self, nums: List[in...
code_fim
hard
{ "lang": "python", "repo": "pauvrepetit/leetcode", "path": "/others/剑指 Offer/56/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: pauvrepetit/leetcode path: /others/剑指 Offer/56/main.py from typing import List class Solution: def singleNumbers(self, nums: List[int]) -> List[int]: xor_sum = 0 for num in nums: xor_sum = num ^ xor_sum count = 0 while xor_sum & 1 == 0: ...
code_fim
hard
{ "lang": "python", "repo": "pauvrepetit/leetcode", "path": "/others/剑指 Offer/56/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Colk-tech/ColkSmallUtils path: /ChangeGitProfile/main.py import sys import shutil import os import initializer args = sys.argv home = str(os.environ['HOME']) gitconfigs = home + "/.gitconfigs" if not os.path.exists(gitconfigs): print("It seems that you are running this script at first tim...
code_fim
medium
{ "lang": "python", "repo": "Colk-tech/ColkSmallUtils", "path": "/ChangeGitProfile/main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>if not len(args) == 2: print("Error!") raise IndexError("Please specify only one argument") if not os.path.exists(gitconfigs + "/" + args[1]): print("Configure '{}' not found".format(args[1])) exit() else: if os.path.exists(home + "/.gitconfig"): try: os.remove(ho...
code_fim
hard
{ "lang": "python", "repo": "Colk-tech/ColkSmallUtils", "path": "/ChangeGitProfile/main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # Selecting the best individuals in the current generation as # parents for producing the offspring of the next generation. parents = numpy.empty((num_parents, pop.shape[1])) for parent_num in range(num_parents): max_fitness_idx = numpy.where(fitness == numpy.max(fitness)) ...
code_fim
hard
{ "lang": "python", "repo": "AndreiPi/MetodeDeNatura", "path": "/GA Versions/manual_ga/ga.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def crossover(parents, offspring_size): offspring = numpy.empty(offspring_size) # The point at which crossover takes place between two parents. Usually, it is at the center. crossover_point = numpy.uint32(offspring_size[1] / 2) for k in range(offspring_size[0]): # Index of the fir...
code_fim
hard
{ "lang": "python", "repo": "AndreiPi/MetodeDeNatura", "path": "/GA Versions/manual_ga/ga.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AndreiPi/MetodeDeNatura path: /GA Versions/manual_ga/ga.py import numpy import random # Converting each solution from matrix to vector. def mat_to_vector(mat_pop_weights): pop_weights_vector = [] for sol_idx in range(mat_pop_weights.shape[0]): curr_vector = [] for layer_...
code_fim
hard
{ "lang": "python", "repo": "AndreiPi/MetodeDeNatura", "path": "/GA Versions/manual_ga/ga.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> # and/or store regions in HDF5 format hdf5 = HDF5File(mesh.mpi_comm(), "results/h5-ernie-parcellation.h5", "w") hdf5.write(mesh, "/mesh") hdf5.write(regions, "/regions") hdf5.close() map_parcellation_to_mesh("wmparc.mgz", "ernie-brain-32.xdmf")<|fim_prefix|># r...
code_fim
hard
{ "lang": "python", "repo": "elepiersan/mri2fem", "path": "/mri2fem/mri2fem/chp4/map_parcellation.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: elepiersan/mri2fem path: /mri2fem/mri2fem/chp4/map_parcellation.py import numpy import nibabel from nibabel.affines import apply_affine from dolfin import * def map_parcellation_to_mesh(parcfile, meshfile): # Load image from the parcellation file, # extract its data and output its dimens...
code_fim
hard
{ "lang": "python", "repo": "elepiersan/mri2fem", "path": "/mri2fem/mri2fem/chp4/map_parcellation.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> parser.add_argument( '--source-directory', default='.', help='The path to directory containing the source code for the build.') parser.add_argument( '--output-file', default='source-context.json', help='The path to the output file containing the sour...
code_fim
hard
{ "lang": "python", "repo": "twistedpair/google-cloud-sdk", "path": "/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/gen_repo_info_file.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: twistedpair/google-cloud-sdk path: /google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/gen_repo_info_file.py # Copyright 2014 Google Inc. All Rights Reserved. """The gen_repo_info_file command.""" from googlecloudsdk.api_lib.source import generate_source_context from googlecloudsdk.cal...
code_fim
medium
{ "lang": "python", "repo": "twistedpair/google-cloud-sdk", "path": "/google-cloud-sdk/lib/googlecloudsdk/appengine/app_commands/gen_repo_info_file.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: deepampatel/jina path: /jina/parsers/peapods/pod.py import argparse from jina.enums import PollingType, SchedulerType, PodRoleType from jina.parsers.helper import add_arg_group, _SHOW_ALL_ARGS def mixin_base_pod_parser(parser): """Mixing in arguments required by :class:`BasePod` into the g...
code_fim
hard
{ "lang": "python", "repo": "deepampatel/jina", "path": "/jina/parsers/peapods/pod.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> # hidden CLI used for internal only gp.add_argument('--pod-role', type=PodRoleType.from_string, choices=list(PodRoleType), help='The role of this pod in the flow' if _SHOW_ALL_ARGS else argparse.SUPPRESS)<|fim_prefix|># repo: deepampatel/jina path: /jina/parsers/peapods/pod.p...
code_fim
hard
{ "lang": "python", "repo": "deepampatel/jina", "path": "/jina/parsers/peapods/pod.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>tractor as Extractor elif module == 'tensorrt': from .extract_tensorrt import TensorrtExtractor as Extractor else: raise ImportError( 'module must be in one of [onnx, caffemodel, netdef, graphdef, h5, mxnetparams, savedmodel, torchscript, pmml, tensorrt]' )<|fim_prefix|># repo: judgeee...
code_fim
hard
{ "lang": "python", "repo": "judgeeeeee/klever-model-registry", "path": "/scripts/extract/extractor/__init__.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: judgeeeeee/klever-model-registry path: /scripts/extract/extractor/__init__.py import os module = os.environ.get('EXTRACTOR', 'NULL') if module == 'onnx': from .extract_onnx import OnnxExtractor as Extractor elif module == 'caffemodel': from .extract_caffe import CaffeExtractor as Extract...
code_fim
hard
{ "lang": "python", "repo": "judgeeeeee/klever-model-registry", "path": "/scripts/extract/extractor/__init__.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: run-ai/runai path: /examples/elastic/keras/mnist.py # horovodrun -np `nvidia-smi --list-gpus | wc -l` -H localhost:`nvidia-smi --list-gpus | wc -l` python examples/elastic/keras/mnist.py from __future__ import print_function import keras from keras.models import Sequential from keras.layers imp...
code_fim
hard
{ "lang": "python", "repo": "run-ai/runai", "path": "/examples/elastic/keras/mnist.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>NUM_CLASSES = 10 (x_train, y_train), (x_test, y_test) = keras.datasets.mnist.load_data() x_train = x_train.reshape(60000, 784) x_test = x_test.reshape(10000, 784) x_train = x_train.astype('float32') x_test = x_test.astype('float32') x_train /= 255 x_test /= 255 y_train = keras.utils.to_categorical(y_tr...
code_fim
medium
{ "lang": "python", "repo": "run-ai/runai", "path": "/examples/elastic/keras/mnist.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>model.compile( loss='categorical_crossentropy', optimizer=keras.optimizers.Adadelta(lr=1.0), # pass any valid Keras optimizer metrics=['accuracy'] ) model.fit(x_train, y_train, batch_size=runai.elastic.batch_size, # use the calculated configuration (batch size in this case...
code_fim
hard
{ "lang": "python", "repo": "run-ai/runai", "path": "/examples/elastic/keras/mnist.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: vas3k/vas3k.club path: /common/data/countries.py COUNTRIES = [ ("Россия", "Россия"), ("Украина", "Украина"), ("Беларусь", "Беларусь"), ("Казахстан", "Казахстан"), ("Абхазия", "Абхазия"), ("Австралия", "Австралия"), ("Австрия", "Австрия"), ("Азербайджан", "Азербайдж...
code_fim
hard
{ "lang": "python", "repo": "vas3k/vas3k.club", "path": "/common/data/countries.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>нт-Люсия"), ("Сент-Пьер и Микелон", "Сент-Пьер и Микелон"), ("Сербия", "Сербия"), ("Сингапур", "Сингапур"), ("Синт-Мартен", "Синт-Мартен"), ("Сирийская Арабская Республика", "Сирийская Арабская Республика"), ("Словакия", "Словакия"), ("Словения", "Словения"), ("Соломоновы о...
code_fim
hard
{ "lang": "python", "repo": "vas3k/vas3k.club", "path": "/common/data/countries.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Pruning variables by given ratios. Args: ratios(dict<str, float>): The key is the name of variable to be pruned and the value is the pruned ratio. axis(int): The dimension to be pruned on. Returns: ...
code_fim
hard
{ "lang": "python", "repo": "PaddlePaddle/PaddleSlim", "path": "/paddleslim/dygraph/prune/pruner.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|># repo: PaddlePaddle/PaddleSlim path: /paddleslim/dygraph/prune/pruner.py import os import pickle import numpy as np import logging from .pruning_plan import PruningPlan from paddleslim.common import get_logger __all__ = ["Pruner"] _logger = get_logger(__name__, level=logging.INFO) class Pruner(objec...
code_fim
hard
{ "lang": "python", "repo": "PaddlePaddle/PaddleSlim", "path": "/paddleslim/dygraph/prune/pruner.py", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>badgeSwappers = badge_swappers() print("\n\n------------ Stats ------------") print("You're missing $"+str(round(sumFunds,2)*-1)+" Canadian Rupees from your wallet") print("You've swapped with "+str(len(badgeSwappers.keys()))+" different friends since May 3rd 🏓") print("You've swapped with "+str(len(swap...
code_fim
hard
{ "lang": "python", "repo": "dlabrie/shakescripts-python", "path": "/pyscripts/all_swaps_short.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: dlabrie/shakescripts-python path: /pyscripts/all_swaps_short.py from modules.shakepay import * updateTransactions() swaps = all_swaps() swapsSummary = {} for swapper in swaps: if swaps[swapper] != 0: transactions = swapperTransactions(swapper) lastTransaction = list(transac...
code_fim
medium
{ "lang": "python", "repo": "dlabrie/shakescripts-python", "path": "/pyscripts/all_swaps_short.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> for iter_ in tqdm(range(settings.num_inference_samples), ncols=100): arr_preds, arr_target = get_batch_predictions( rnn, packed, target_tensor ) # Revert sorting that occurs in get_batch_predictions ...
code_fim
hard
{ "lang": "python", "repo": "supernnova/SuperNNova", "path": "/supernnova/validation/validate_rnn.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: supernnova/SuperNNova path: /supernnova/validation/validate_rnn.py s lu def find_idx(array, value): """Utility to find the index of the element of ``array`` that most closely matches ``value`` Args: array (np.array): The array in which to search value (float): The v...
code_fim
hard
{ "lang": "python", "repo": "supernnova/SuperNNova", "path": "/supernnova/validation/validate_rnn.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: supernnova/SuperNNova path: /supernnova/validation/validate_rnn.py the element of ``array`` that most closely matches ``value`` Args: array (np.array): The array in which to search value (float): The value for which we are looking for a match Returns: (int) t...
code_fim
hard
{ "lang": "python", "repo": "supernnova/SuperNNova", "path": "/supernnova/validation/validate_rnn.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #Load regressor model = pickle.load(open('data/regressor.sav', 'rb')) #Test against the test database predictions = model.predict(X_test) #Calculate mean distance between prediction and real values i = 0 mean_dist = 0.0 while(i < len(predictions)): prediction = predictions[i] real = Y_test[i...
code_fim
hard
{ "lang": "python", "repo": "urbanoanderson/ufpe-graduation-thesis", "path": "/src/wcnc_paper/experiments/extra/test_regressor.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: urbanoanderson/ufpe-graduation-thesis path: /src/wcnc_paper/experiments/extra/test_regressor.py #!/usr/bin/python # -*- coding: utf-8 -*- #Utils import math import pickle #Custom Classes from measurement import * from erb import * def GetRegressorArrays(measurement_list): X = [] Y = [] <|fi...
code_fim
hard
{ "lang": "python", "repo": "urbanoanderson/ufpe-graduation-thesis", "path": "/src/wcnc_paper/experiments/extra/test_regressor.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == "__main__": main() """ Ubuntu 18.04, CPython 3.6.9, 48 core machine: count: 1000 cv2: 0.000188s np: 0.002309s """<|fim_prefix|># repo: EricCousineau-TRI/repro path: /bug/opencv_cvtcolor_slow/repro.py import sys import timeit import cv2 import numpy as np def main():...
code_fim
hard
{ "lang": "python", "repo": "EricCousineau-TRI/repro", "path": "/bug/opencv_cvtcolor_slow/repro.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: EricCousineau-TRI/repro path: /bug/opencv_cvtcolor_slow/repro.py import sys import timeit import cv2 import numpy as np def main(): np.random.seed(0) rgb = np.random.randint(0, high=255, size=(480, 848, 3), dtype=np.uint8) bgr = np.zeros_like(rgb) count = 1000 scope = dict...
code_fim
medium
{ "lang": "python", "repo": "EricCousineau-TRI/repro", "path": "/bug/opencv_cvtcolor_slow/repro.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: jpsampaio/ExEcommIT path: /Ex82.py l1 = [] l2 = [] l3 = [] r = 's' while r == 's': x = int(input('Digite um número: ')) if x % 2 == 0 and x != 0: l2.append(x) elif x % 2 == 1 and x != 0: l3.append(x) l1.append(x) r = str(input('Quer c<|fim_suffix|>odos os valor...
code_fim
medium
{ "lang": "python", "repo": "jpsampaio/ExEcommIT", "path": "/Ex82.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>odos os valores é {l1}') print(f'A lista com os valores pares é {l2}') print(f'A lista com os valores impares é {l3}')<|fim_prefix|># repo: jpsampaio/ExEcommIT path: /Ex82.py l1 = [] l2 = [] l3 = [] r = 's' while r == 's': x = int(input('Digite um número: ')) if x % 2 == 0 and x != 0: l2....
code_fim
medium
{ "lang": "python", "repo": "jpsampaio/ExEcommIT", "path": "/Ex82.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: Haider8/oscarine-api path: /app/tests/conftest.py from typing import Generator import pytest from fastapi.testclient import TestClient from app.db.base import Base from app.db.session import db_session as db_session_ from app.db.session import engine from app.main import app <|fim_suffix|> ...
code_fim
medium
{ "lang": "python", "repo": "Haider8/oscarine-api", "path": "/app/tests/conftest.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> @pytest.fixture(scope="module") def client() -> Generator: with TestClient(app) as c: yield c<|fim_prefix|># repo: Haider8/oscarine-api path: /app/tests/conftest.py from typing import Generator import pytest from fastapi.testclient import TestClient <|fim_middle|>from app.db.base import Ba...
code_fim
hard
{ "lang": "python", "repo": "Haider8/oscarine-api", "path": "/app/tests/conftest.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: judebues/softmanage path: /work/yml/Wordprocessing/urls.py from django.urls import path from django.conf.urls import url,include from . import views urlpatterns = [ url(r'^upload/$', views.upload_file), u<|fim_suffix|>home_page,name="home"), url(r"^search/$",views.search,name='searc...
code_fim
medium
{ "lang": "python", "repo": "judebues/softmanage", "path": "/work/yml/Wordprocessing/urls.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>home_page,name="home"), url(r"^search/$",views.search,name='search'), ]<|fim_prefix|># repo: judebues/softmanage path: /work/yml/Wordprocessing/urls.py from django.urls import path from django.conf.urls import url,include from . import views urlpatterns = [ url(r'^upload/$', views.upload_fil...
code_fim
medium
{ "lang": "python", "repo": "judebues/softmanage", "path": "/work/yml/Wordprocessing/urls.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> utt_elem = etree.Element(self.TEI + "u", who=self.speaker, nsmap=self.NSMAP) utt_elem.text = self.speech # return etree.tostring(utt_elem) return utt_elem def append(self, text): # self.speech = self.speech + "\n\n" + text ...
code_fim
hard
{ "lang": "python", "repo": "agile-humanities/ddhi-encoder", "path": "/src/ddhi_encoder/utterance.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: agile-humanities/ddhi-encoder path: /src/ddhi_encoder/utterance.py # -*- coding: utf-8 -*- # utterance.py from lxml import etree import re class Utterance: TEI_NAMESPACE = "http://www.tei-c.org/ns/1.0" TEI = "{%s}" % TEI_NAMESPACE NSMAP = {None: TEI_NAMESPACE} # default namespace ...
code_fim
hard
{ "lang": "python", "repo": "agile-humanities/ddhi-encoder", "path": "/src/ddhi_encoder/utterance.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def dfs(root: Optional[TreeNode]) -> T: if not root: return T(-1, -1, -1) left = dfs(root.left) right = dfs(root.right) leftZigZag = left.rightMax + 1 rightZigZag = right.leftMax + 1 subtreeMax = max(leftZigZag, rightZigZag, left.subtr...
code_fim
medium
{ "lang": "python", "repo": "walkccc/LeetCode", "path": "/solutions/1372. Longest ZigZag Path in a Binary Tree/1372.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def longestZigZag(self, root: Optional[TreeNode]) -> int: def dfs(root: Optional[TreeNode]) -> T: if not root: return T(-1, -1, -1) left = dfs(root.left) right = dfs(root.right) leftZigZag = left.rightMax + 1 rightZigZag = right.leftMax + 1 subtreeMax = ma...
code_fim
medium
{ "lang": "python", "repo": "walkccc/LeetCode", "path": "/solutions/1372. Longest ZigZag Path in a Binary Tree/1372.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: walkccc/LeetCode path: /solutions/1372. Longest ZigZag Path in a Binary Tree/1372.py class T: def __init__(self, leftMax: int, rightMax: int, subtreeMax: int): self.leftMax = leftMax self.rightMax = rightMax self.subtreeMax = subtreeMax <|fim_suffix|> if not root: retu...
code_fim
medium
{ "lang": "python", "repo": "walkccc/LeetCode", "path": "/solutions/1372. Longest ZigZag Path in a Binary Tree/1372.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if loaded_data[xf].shape[1] == len(loaded_data[yf]): loaded_data[xf] = np.transpose(loaded_data[xf]) if sw in data_fields: loaded_data[sw] = np.array(r_data[sw]).flatten() if 'variable_names' in data_fields: loaded_data['variable_names'...
code_fim
hard
{ "lang": "python", "repo": "ustunb/dcptree", "path": "/dcptree/data_io.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: ustunb/dcptree path: /dcptree/data_io.py ".weights" (if dataset_file ends in ".data") "_weights.csv" (if dataset_file ends in "_data.csv") include_intercept if True then an intercept is added to the X matrix Returns -------...
code_fim
hard
{ "lang": "python", "repo": "ustunb/dcptree", "path": "/dcptree/data_io.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> if 'format' in data_fields: loaded_data['format'] = np.array(r_data['format'])[0] if 'partitions' in data_fields: loaded_data['partitions'] = np.array(rn.r.data['partitions']).tolist() cvindices = _load_cvindices_from_rdata(file_name) data = set_defaults_for_data(loaded_d...
code_fim
hard
{ "lang": "python", "repo": "ustunb/dcptree", "path": "/dcptree/data_io.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': dump(sys.stdin, sys.stdout)<|fim_prefix|># repo: klaasjacobdevries/kyaml path: /python/test/dump.py #!/usr/bin/python import pykyaml as kyaml import sys def dump(input, output): parser = kyaml.parser(input) root = parser.parse() <|fim_middle|> output.write('%s...
code_fim
easy
{ "lang": "python", "repo": "klaasjacobdevries/kyaml", "path": "/python/test/dump.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: klaasjacobdevries/kyaml path: /python/test/dump.py #!/usr/bin/python import pykyaml as kyaml import sys def dump(input, output): parser = kyaml.parser(input) root = parser.parse() <|fim_suffix|>if __name__ == '__main__': dump(sys.stdin, sys.stdout)<|fim_middle|> output.write('%s...
code_fim
easy
{ "lang": "python", "repo": "klaasjacobdevries/kyaml", "path": "/python/test/dump.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> output.write('%s\n' % root) if __name__ == '__main__': dump(sys.stdin, sys.stdout)<|fim_prefix|># repo: klaasjacobdevries/kyaml path: /python/test/dump.py #!/usr/bin/python import pykyaml as kyaml import sys def dump(input, output): <|fim_middle|> parser = kyaml.parser(input) root = par...
code_fim
medium
{ "lang": "python", "repo": "klaasjacobdevries/kyaml", "path": "/python/test/dump.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>t(f'A primeira letra A aparece na posição {juntar.find("A") + 1} e a última letra A aparece na posição {juntar.rfind("A") + 1}.')<|fim_prefix|># repo: LarissaMidori/curso_em_video path: /exercicio026.py ''' Faça um programa que leia uma frase pelo teclado e mostre quantas vezes aparece a letra “A”, em qu...
code_fim
medium
{ "lang": "python", "repo": "LarissaMidori/curso_em_video", "path": "/exercicio026.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: LarissaMidori/curso_em_video path: /exercicio026.py ''' Faça um programa que leia uma frase pelo teclado e mostre quantas vezes aparece a letra “A”, em que posição ela aparece a primeira vez e em que posição ela aparece a última vez. ''' frase = str(input('Digite uma frase: ')).upper().strip() s...
code_fim
medium
{ "lang": "python", "repo": "LarissaMidori/curso_em_video", "path": "/exercicio026.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> posicao = self.pesquisar(valor) if posicao == -1: return -1 else: for i in range(posicao, self.ultima_posicao): self.valores[i] = self.valores[i+1] self.ultima_posicao -= 1 vetor = VetorNaoOrdenado(5) vetor.insere(2) vetor.insere(3) vetor.insere(8) vetor.ins...
code_fim
hard
{ "lang": "python", "repo": "AlissonRaphael/algorithm_and_data_structures", "path": "/02_vetor_ordenado_pesquisa_linear.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: AlissonRaphael/algorithm_and_data_structures path: /02_vetor_ordenado_pesquisa_linear.py import numpy as np class VetorNaoOrdenado: def __init__(self, capacidade): self.capacidade = capacidade self.ultima_posicao = -1 self.valores = np.empty(self.capacidade, dtype=int) # BigO =>...
code_fim
medium
{ "lang": "python", "repo": "AlissonRaphael/algorithm_and_data_structures", "path": "/02_vetor_ordenado_pesquisa_linear.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if i == self.ultima_posicao: return -1 # BigO => O(n) def excluir(self, valor): posicao = self.pesquisar(valor) if posicao == -1: return -1 else: for i in range(posicao, self.ultima_posicao): self.valores[i] = self.valores[i+1] self.ultima_po...
code_fim
hard
{ "lang": "python", "repo": "AlissonRaphael/algorithm_and_data_structures", "path": "/02_vetor_ordenado_pesquisa_linear.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>_assignments", "check_mixture_model", "check_component_model" ]<|fim_prefix|># repo: thetianshuhuang/bmcc path: /bmcc/util/__init__.py from .get_params import get_params from .type_check import ( check<|fim_middle|>_data, check_assignments, check_mixture_model, check_component_mod...
code_fim
medium
{ "lang": "python", "repo": "thetianshuhuang/bmcc", "path": "/bmcc/util/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }