text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|># repo: StanczakDominik/LabSpec path: /read_h5py.py import h5py f = h5py.File("data.hdf5") for key, item in f.items(): print(key, item) # if key !="psi": # f.__delitem__(key) # print(item[0]) for key, item in f.attrs.items(): <|fim_suffix|>sx", data=np.load("currents_x.npy")) # c...
code_fim
hard
{ "lang": "python", "repo": "StanczakDominik/LabSpec", "path": "/read_h5py.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> while(count < n): #count is 2, res add str2 res += str[count] count += 2 return res<|fim_prefix|># repo: rohstar/codingbat path: /python/warmup2/string_bits.py #Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo". def st...
code_fim
easy
{ "lang": "python", "repo": "rohstar/codingbat", "path": "/python/warmup2/string_bits.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> count = 0 res = '' while(count < n): #count is 2, res add str2 res += str[count] count += 2 return res<|fim_prefix|># repo: rohstar/codingbat path: /python/warmup2/string_bits.py #Given a string, return a new string made of every other char starting with the first, so "He...
code_fim
easy
{ "lang": "python", "repo": "rohstar/codingbat", "path": "/python/warmup2/string_bits.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: rohstar/codingbat path: /python/warmup2/string_bits.py #Given a string, return a new string made of every other char starting with the first, so "Hello" yields "Hlo". <|fim_suffix|> res += str[count] count += 2 return res<|fim_middle|>def string_bits(str): n = len(str) coun...
code_fim
medium
{ "lang": "python", "repo": "rohstar/codingbat", "path": "/python/warmup2/string_bits.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>print("\n") print(sorted(classes)) print(classes) #The sorted function can be used to temporarily sort lists, #It displays the sorted version of the list without actually changing the order print("\n") print(classes) classes.reverse() print(classes) #Reverse does exactlly what you'd think, it reverses ...
code_fim
hard
{ "lang": "python", "repo": "Chichri/Python-Projects", "path": "/Messing_with_lists.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Chichri/Python-Projects path: /Messing_with_lists.py classes = ['Fighter', 'Rogue', 'Bard', 'Cleric'] message = "My favorite class is the " + classes[2].title() print(message) #This is a list. It can be used to contain information #classes is now a list containing these four items #You can select...
code_fim
hard
{ "lang": "python", "repo": "Chichri/Python-Projects", "path": "/Messing_with_lists.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> response = get_item.get_item(id) return jsonify(response)<|fim_prefix|># repo: OualidZM/flask-Ollivanders path: /controller/get_item.py from flask import jsonify, Blueprint from services import get_item get_item_blue = Blueprint("get_item", __name__) <|fim_middle|> @get_item_blue.route("/item/<...
code_fim
easy
{ "lang": "python", "repo": "OualidZM/flask-Ollivanders", "path": "/controller/get_item.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: OualidZM/flask-Ollivanders path: /controller/get_item.py from flask import jsonify, Blueprint from services import get_item <|fim_suffix|> @get_item_blue.route("/item/<id>") def get_item_func(id): response = get_item.get_item(id) return jsonify(response)<|fim_middle|>get_item_blue = Blue...
code_fim
easy
{ "lang": "python", "repo": "OualidZM/flask-Ollivanders", "path": "/controller/get_item.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: abdaloth/generalized-TLDR path: /summarize.py #!/usr/bin/python import sys from sklearn.feature_extraction.text import TfidfTransformer, CountVectorizer import nltk nltk.download("stopwords") nltk.download("punkt") lang_stopwords = [] from nltk.tokenize import sent_tokenize import n...
code_fim
hard
{ "lang": "python", "repo": "abdaloth/generalized-TLDR", "path": "/summarize.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # mirror the matrix onto itself to get the similarity edges between sentences similarity_matrix = bagofwords_matrix * bagofwords_matrix.T similarity_graph = nx.from_scipy_sparse_matrix(similarity_matrix) scores = nx.nx.pagerank_scipy(similarity_graph) scored_sentences = [(i, s, s...
code_fim
hard
{ "lang": "python", "repo": "abdaloth/generalized-TLDR", "path": "/summarize.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == "__main__": # retrieve command line arguments and store them as variables inputdir = sys.argv[1] lang = sys.argv[2] outfile = sys.argv[3] import pyspark from nltk.corpus import stopwords lang_stopwords = stopwords.words(lang) sc = pyspark.SparkC...
code_fim
hard
{ "lang": "python", "repo": "abdaloth/generalized-TLDR", "path": "/summarize.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ganon1998/COVID_VariantRecognition path: /ProteinRNN.py # Here we import the modules that we will use for the task import numpy as np import math import statistics import tensorflow as tf import string import random import matplotlib.pyplot as plt from tensorflow import keras from tensorflow.kera...
code_fim
hard
{ "lang": "python", "repo": "Ganon1998/COVID_VariantRecognition", "path": "/ProteinRNN.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # We parse files to get training data seq_train, train_label = read_seq('/content/gdrive/My Drive/pdb_seqres.txt') seq_test, test_label = read_seqV2('/content/gdrive/My Drive/pdb_seqres.txt') # We reshape labels to be 2d arrays train_label = np.asarray(train_label).astype('float32').reshape((-1,1)) test...
code_fim
hard
{ "lang": "python", "repo": "Ganon1998/COVID_VariantRecognition", "path": "/ProteinRNN.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if i == 25: seq.append(ord(string.ascii_uppercase[random.randint(0,26)]) - ord('A') + 1) continue if i >= 45: seq.append(ord(string.ascii_uppercase[random.randint(0,26)]) - ord('A') + 1) continue seq.append(ord(charList[i]) - ord('A') + 1) # grab the labels...
code_fim
hard
{ "lang": "python", "repo": "Ganon1998/COVID_VariantRecognition", "path": "/ProteinRNN.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ShresthaRujal/Django-with-Vue-CLI path: /app/views.py from django.shortcuts import render,get_object_or_404 from django.contrib.auth.decorators import login_required from django.views.decorators.http import require_http_methods from rest_framework import viewsets from rest_framework import status...
code_fim
hard
{ "lang": "python", "repo": "ShresthaRujal/Django-with-Vue-CLI", "path": "/app/views.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> print(self.request.user) serializer.save(user_profile=self.request.user) @action(detail=True,methods=['GET']) def publish(self, request,id=None): draft = self.get_object() draft.publish() serializer = serializers.DraftSerializer(draft) return Respon...
code_fim
hard
{ "lang": "python", "repo": "ShresthaRujal/Django-with-Vue-CLI", "path": "/app/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ip3 install hana_automl """ __version__ = "0.0.3"<|fim_prefix|># repo: jorgeporca/SAP-HANA-AutoML path: /hana_automl/__init__.py """Welcome to hana_automl - Automated Machine Lea<|fim_middle|>rning library based on SAP HANA. ******Installation********* 1. pip3 install Cython 2. p
code_fim
medium
{ "lang": "python", "repo": "jorgeporca/SAP-HANA-AutoML", "path": "/hana_automl/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>ation********* 1. pip3 install Cython 2. pip3 install hana_automl """ __version__ = "0.0.3"<|fim_prefix|># repo: jorgeporca/SAP-HANA-AutoML path: /hana_automl/__init__.py """Welcome to hana_automl - Automated Machine Lea<|fim_middle|>rning library based on SAP HANA. ******Install
code_fim
easy
{ "lang": "python", "repo": "jorgeporca/SAP-HANA-AutoML", "path": "/hana_automl/__init__.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jorgeporca/SAP-HANA-AutoML path: /hana_automl/__init__.py """Welcome to hana_automl - Automated Machine Lea<|fim_suffix|>ip3 install hana_automl """ __version__ = "0.0.3"<|fim_middle|>rning library based on SAP HANA. ******Installation********* 1. pip3 install Cython 2. p
code_fim
medium
{ "lang": "python", "repo": "jorgeporca/SAP-HANA-AutoML", "path": "/hana_automl/__init__.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> buckets = Bucket.query.all() for bucket in buckets: out['buckets'][bucket.name] = bucket.amount today = datetime.date.today() last_day = calendar.monthrange(today.year, today.month)[1] transactions = Trans.query.filter(Trans.date.between(today.replace(day=1), ...
code_fim
hard
{ "lang": "python", "repo": "BenDoan/NestEgg", "path": "/nestegg/views/api.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: BenDoan/NestEgg path: /nestegg/views/api.py import calendar import datetime import json from flask import Blueprint, request, abort from util import * from consts import * from database import db, Budget, Bucket, BudgetItem, Trans api = Blueprint('api', __name__, templat...
code_fim
hard
{ "lang": "python", "repo": "BenDoan/NestEgg", "path": "/nestegg/views/api.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Performs a single optimization step """ for p, grad, v, square_grad_avg, delta_x_acc in self.params: # Compute the running average of the squared gradients square_grad_avg.mul_(self.rho) square_grad_avg.addcmul_(grad, grad, value = 1 - self.rho) ...
code_fim
medium
{ "lang": "python", "repo": "marieanselmet/DeepLearningEPFL_projects", "path": "/DL_framework_from_scratch/optimizers.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> class Adadelta(Optimizer): """ Implementation of the ADADELTA optimizer """ def __init__(self, params, lr, rho=0.9, eps=1e-6): self.params = params self.lr = lr self.rho = rho self.eps = eps def step(self): """ Performs a single optimization step "...
code_fim
hard
{ "lang": "python", "repo": "marieanselmet/DeepLearningEPFL_projects", "path": "/DL_framework_from_scratch/optimizers.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: marieanselmet/DeepLearningEPFL_projects path: /DL_framework_from_scratch/optimizers.py class Optimizer(object): """ Optimizer base class """ def step(self): raise NotImplementedError def zero_grad(self): raise NotImplementedError class SGD(...
code_fim
hard
{ "lang": "python", "repo": "marieanselmet/DeepLearningEPFL_projects", "path": "/DL_framework_from_scratch/optimizers.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>x = df[['dti', 'A', 'B', 'C', 'D', 'E', 'F', 'G']] predictions = PD_SVM.predict(x) # Gets a list of all predictions prob_predictions = PD_SVM.predict_proba(x) #print(predictions, prob_predictions, x) print() print('Probability of Default:', prob_predictions[0, 1]) print('\n'*2) endinput = input...
code_fim
hard
{ "lang": "python", "repo": "ghappy112/Probability_of_Default-SVM", "path": "/PD_Calculator.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ghappy112/Probability_of_Default-SVM path: /PD_Calculator.py #Copyright 2020, Gregory Happ, All rights reserved. print("Copyright 2020, Gregory Happ, All rights reserved.") print() #Probability of Default (PD) calculator!!! import numpy as np import pandas as pd import sklearn from sklearn...
code_fim
hard
{ "lang": "python", "repo": "ghappy112/Probability_of_Default-SVM", "path": "/PD_Calculator.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: yuanhuiru/xnr2 path: /xnr_0429/xnr/timed_python_files/clean_data_sencond/facebook_history_feedback_mappings.py asticsearch import Elasticsearch import sys import json reload(sys) sys.path.append('../../') from global_utils import es_xnr_2 as es from global_utils import facebook_history_feedb...
code_fim
hard
{ "lang": "python", "repo": "yuanhuiru/xnr2", "path": "/xnr_0429/xnr/timed_python_files/clean_data_sencond/facebook_history_feedback_mappings.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if not es.indices.exists(index=index_name): es.indices.create(index=index_name, body=index_info, ignore=400) # 好友列表 def facebook_history_feedback_friends_mappings(index_name, index_type): ## 粉丝提醒及回粉 index_info = { 'settings': { 'number_of_replicas': 0, 'n...
code_fim
hard
{ "lang": "python", "repo": "yuanhuiru/xnr2", "path": "/xnr_0429/xnr/timed_python_files/clean_data_sencond/facebook_history_feedback_mappings.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> params :- purchase order - string returns :- True or False as Order confirms """ order = self.purchase_details[purchase_order] order['state'] = 'Done' for product in order['products']: pro_data = self.products_data[product['name']] p...
code_fim
hard
{ "lang": "python", "repo": "maulikb-emipro/Python-Training", "path": "/Test1/purchase.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: maulikb-emipro/Python-Training path: /Test1/purchase.py import datetime import re class Purchase: """ This class used to store purchase of products """ purchase_details = {} def create_purchase_order(self, products, vendor_name): """ func :- Used to create new ...
code_fim
hard
{ "lang": "python", "repo": "maulikb-emipro/Python-Training", "path": "/Test1/purchase.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> check = [[0, 1], [1, 1], [1, 0], [1, -1], [0, -1], [-1, -1], [-1, 0], [-1, 1]] for i in range(1, 65): for j in range(1, 65): if img[i, j] == 255: flag = 0 num = 0 cnt = 0 for k in range(9): if img[i + check[k % 8][0], j + check[k % 8][1]] == 255: cnt += 1 if fla...
code_fim
hard
{ "lang": "python", "repo": "yichunlo/Computer_Vision", "path": "/hw7/hw7.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: yichunlo/Computer_Vision path: /hw7/hw7.py import numpy as np import cv2 import sys np.set_printoptions(threshold = sys.maxsize) def ds(img): ret = np.zeros((66, 66), np.int) for i in range(64): for j in range(64): if img[i * 8, j * 8] >= 128: ret[i + 1, j + 1] = 255 else: ret[...
code_fim
hard
{ "lang": "python", "repo": "yichunlo/Computer_Vision", "path": "/hw7/hw7.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: iamanx17/dslearn path: /Generic tree/largest.py from GenericTree import takeinput, prindata <|fim_suffix|> if root is None: return 0 lrg=root.data for child in root.children: if child.data>lrg: lrg=child.data maxchild=largestdata(child) if m...
code_fim
easy
{ "lang": "python", "repo": "iamanx17/dslearn", "path": "/Generic tree/largest.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> return lrg root=takeinput() prindata(root)<|fim_prefix|># repo: iamanx17/dslearn path: /Generic tree/largest.py from GenericTree import takeinput, prindata <|fim_middle|> def largestdata(root): if root is None: return 0 lrg=root.data for child in root.children: if child...
code_fim
hard
{ "lang": "python", "repo": "iamanx17/dslearn", "path": "/Generic tree/largest.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # Allow for time to load time.sleep(3) # Create Beautiful Soup object html = browser.html soup = BeautifulSoup(html, "html.parser") # Read table from url and turn into DataFrame tables = pd.read_html(url) tables[0] df = tables[0] # Change column headers to Stat an...
code_fim
hard
{ "lang": "python", "repo": "nwchappel/web-scraping-challenge", "path": "/Missions_to_Mars/scrape_mars.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: nwchappel/web-scraping-challenge path: /Missions_to_Mars/scrape_mars.py import time from splinter import Browser from bs4 import BeautifulSoup import pandas as pd def scrape(): # Create dictionary to store results results = {} # Create path to local chrome driver executable_pat...
code_fim
hard
{ "lang": "python", "repo": "nwchappel/web-scraping-challenge", "path": "/Missions_to_Mars/scrape_mars.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: krsnadatra/Contoh-Program path: /2019/day_04.py from itertools import groupby from glen import glen # generator length def non_decreasing(start, end): number = list(str(start)) # Generate first non-decreasing number for i, (digit1, digit2) in enumerate(zip(number, number[1:])): ...
code_fim
medium
{ "lang": "python", "repo": "krsnadatra/Contoh-Program", "path": "/2019/day_04.py", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|>start, end = 134564, 585159 # Part 1 passwords = tuple(filter(has_adjacent, non_decreasing(start, end))) print(len(passwords)) # Part 2 print(glen(filter(has_pair, passwords)))<|fim_prefix|># repo: krsnadatra/Contoh-Program path: /2019/day_04.py from itertools import groupby from glen import glen # gen...
code_fim
medium
{ "lang": "python", "repo": "krsnadatra/Contoh-Program", "path": "/2019/day_04.py", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_suffix|> def main(): "main function" if len(sys.argv) < 2: print("USAGE: compress.py pipeline_name") exit() pipeline_name = sys.argv[1] pipeline_version = sys.argv[2] output_filename = "roslin-{}-pipeline-v{}.tgz".format( pipeline_name, pipeline_version ) ...
code_fim
hard
{ "lang": "python", "repo": "mskcc/roslin-variant", "path": "/build/scripts/compress.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def main(): "main function" if len(sys.argv) < 2: print("USAGE: compress.py pipeline_name") exit() pipeline_name = sys.argv[1] pipeline_version = sys.argv[2] output_filename = "roslin-{}-pipeline-v{}.tgz".format( pipeline_name, pipeline_version ) ...
code_fim
hard
{ "lang": "python", "repo": "mskcc/roslin-variant", "path": "/build/scripts/compress.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: mskcc/roslin-variant path: /build/scripts/compress.py #!/usr/bin/env python3 import sys import subprocess import os script_path = os.path.dirname(os.path.realpath(__file__)) root_dir = os.path.abspath(os.path.join(script_path,os.pardir,os.pardir)) def compress(output_filename): "compress" ...
code_fim
hard
{ "lang": "python", "repo": "mskcc/roslin-variant", "path": "/build/scripts/compress.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: bopopescu/intelligent-code-completion path: /token_lstm/data.py import os import torch import sys sys.path.append('../tokenizer') import tokenizer import operator import random RAW_DATA_PATH = '../../intelligent-code-completion/raw_data/' REMOVE_THRESHOLD = 10 class Dictionary(object): def ...
code_fim
hard
{ "lang": "python", "repo": "bopopescu/intelligent-code-completion", "path": "/token_lstm/data.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def tokenize(self, path): """Tokenizes a text file.""" assert os.path.exists(path) tokens = 0 maxLen = 0 # Find code path and create dictionary with open(path, 'r') as f: for i, line in enumerate(f): filename = line....
code_fim
hard
{ "lang": "python", "repo": "bopopescu/intelligent-code-completion", "path": "/token_lstm/data.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> """Tokenizes a text file.""" assert os.path.exists(path) tokens = 0 maxLen = 0 # Find code path and create dictionary with open(path, 'r') as f: for i, line in enumerate(f): filename = line.strip() code_path = RAW_...
code_fim
hard
{ "lang": "python", "repo": "bopopescu/intelligent-code-completion", "path": "/token_lstm/data.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> for i in range(0, n): if used[i] == 1: continue if i > 0 and nums[i] == nums[i - 1] and used[i - 1] == 0: continue used[i] = 1 helper(track + [nums[i]]) used[i] = 0 res = [] n = len(nums) ...
code_fim
hard
{ "lang": "python", "repo": "yuchen-he/algorithm016", "path": "/leetcode/editor/cn/[47]全排列 II.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: yuchen-he/algorithm016 path: /leetcode/editor/cn/[47]全排列 II.py # 给定一个可包含重复数字的序列,返回所有不重复的全排列。 # # 示例: # # 输入: [1,1,2] # 输出: # [ # [1,1,2], # [1,2,1], # [2,1,1] # ] # Related Topics 回溯算法 # 👍 492 👎 0 # leetcode submit region begin(Prohibit modification and deletion) class Solutio...
code_fim
hard
{ "lang": "python", "repo": "yuchen-he/algorithm016", "path": "/leetcode/editor/cn/[47]全排列 II.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>for n in range(1,101): S.append(S[n-1] + addval) addval += 4 print(S[bigN-1])<|fim_prefix|># repo: OrderFromChaos/ICPC path: /remote_practice/dp/A.py # Idea: added squares are (inner square - last step) + 4 bigN = int(input()) <|fim_middle|>S = [1] addval = 4
code_fim
easy
{ "lang": "python", "repo": "OrderFromChaos/ICPC", "path": "/remote_practice/dp/A.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: OrderFromChaos/ICPC path: /remote_practice/dp/A.py # Idea: added squares are (inner square - last step) + 4 bigN = int(input()) <|fim_suffix|>for n in range(1,101): S.append(S[n-1] + addval) addval += 4 print(S[bigN-1])<|fim_middle|>S = [1] addval = 4
code_fim
easy
{ "lang": "python", "repo": "OrderFromChaos/ICPC", "path": "/remote_practice/dp/A.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: managai/moolah path: /enjoying/migrations/0003_auto_20151109_2022.py # -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models from django.conf import settings <|fim_suffix|> dependencies = [ migrations.swappable_dependency(settings.AUT...
code_fim
medium
{ "lang": "python", "repo": "managai/moolah", "path": "/enjoying/migrations/0003_auto_20151109_2022.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('enjoying', '0002_auto_20151108_0949'), ] operations = [ migrations.CreateModel( name='Allowance', fields=[ ('id', models.AutoField(verbose_name='ID', ...
code_fim
medium
{ "lang": "python", "repo": "managai/moolah", "path": "/enjoying/migrations/0003_auto_20151109_2022.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#output on display print ('------------------------*********------------------------') n = "Name: %s \n"%(dict_q['name']) s = "Surname: %s \n"%(dict_q['surname']) a = "Age: %i \n" %(dict_q['age']) c = "City: %s \n" %(dict_q['city']) g = "Game: %s \n" %(dict_q['game']) print(n) print(s) print(a) print(c) p...
code_fim
hard
{ "lang": "python", "repo": "vovcoolaka/Programming-Basics", "path": "/homeworks/vera.zbitneva_cemupamuda/homework-4/homework-4.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#date of birth import datetime print('Enter your date of birth') year = int(input("Year-> ")) month = int(input("Month-> ")) day = int(input("Day-> ")) dob = datetime.date(year,month,day) print (dob) print ('------------------------*********------------------------') #--IF--,--Range-- print ('Your horo...
code_fim
medium
{ "lang": "python", "repo": "vovcoolaka/Programming-Basics", "path": "/homeworks/vera.zbitneva_cemupamuda/homework-4/homework-4.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: vovcoolaka/Programming-Basics path: /homeworks/vera.zbitneva_cemupamuda/homework-4/homework-4.py #Create dictionaries dict_q = { 'name' : str(input("Enter your name: ")), 'surname':str(input("Enter youre surname: ")), 'age':int(input("How old are you? ")), 'city':str(input("Where ...
code_fim
hard
{ "lang": "python", "repo": "vovcoolaka/Programming-Basics", "path": "/homeworks/vera.zbitneva_cemupamuda/homework-4/homework-4.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.bpf_text= b""" #include <net/sock.h> BPF_HASH(tcpsendmsg_sock, struct sock *); int kprobe__vfs_open(struct pt_regs *ctx, struct sock *sk, struct msghdr *msg, size_t size) { //struct sock * sk= (struct sock *)ctx->di; FI...
code_fim
medium
{ "lang": "python", "repo": "caozoux/python-me", "path": "/prj/mebbc/module/net/vfs.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: caozoux/python-me path: /prj/mebbc/module/net/vfs.py from __future__ import print_function from bcc import ArgString, BPF, USDT from bcc import BPF from bpfbase import KprobeBase class bpfvfs_open(KprobeBase): <|fim_suffix|> self.bpf_text= b""" #include <net/sock.h> BPF_HA...
code_fim
medium
{ "lang": "python", "repo": "caozoux/python-me", "path": "/prj/mebbc/module/net/vfs.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: numeroband/lageweb path: /pyscumm/images.py from bitparser import BitParser from struct import unpack_from from numpy import zeros, unpackbits, uint8 from textures import Texture class ImageDecoder: def __init__(self, res, width, height, paletteOff, trans): self.res = res sel...
code_fim
hard
{ "lang": "python", "repo": "numeroband/lageweb", "path": "/pyscumm/images.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.emptyMask = True self.res = res self.img = Texture(width, height, mask=True) off = res.off + 8 first = unpack_from('<H', res.data, off)[0] numStripes = width / 8 fmt = '{:d}H'.format(numStripes) offsets = unpack_from(fmt, res.data, off) ...
code_fim
hard
{ "lang": "python", "repo": "numeroband/lageweb", "path": "/pyscumm/images.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>class MaskDecoder: def __init__(self, res, width, height): self.emptyMask = True self.res = res self.img = Texture(width, height, mask=True) off = res.off + 8 first = unpack_from('<H', res.data, off)[0] numStripes = width / 8 fmt = '{:d}H'.format...
code_fim
hard
{ "lang": "python", "repo": "numeroband/lageweb", "path": "/pyscumm/images.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: EvgeniiTitov/old-ml-digits path: /helpers/general.py import os import typing as t import matplotlib.pyplot as plt from pydantic import BaseModel from pydantic import validator def visualise_training_results( acc_history: t.Sequence[float], loss_history: t.Sequence[float] ) -> None: plt...
code_fim
hard
{ "lang": "python", "repo": "EvgeniiTitov/old-ml-digits", "path": "/helpers/general.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if not os.path.exists(classes_path): raise FileNotFoundError("Failed to locate the classes txt") if not os.path.splitext(classes_path)[-1].lower() in [".txt"]: raise Exception("Model classes must be a txt file") return classes_path<|fim_prefix|># repo: Evgen...
code_fim
hard
{ "lang": "python", "repo": "EvgeniiTitov/old-ml-digits", "path": "/helpers/general.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if not os.path.exists(weights): raise FileNotFoundError("Failed to locate the model weights") if not os.path.splitext(weights)[-1].lower() in [".pth", ".pt"]: raise Exception( "Incorrect weights. Expected a pytorch ext: .pth or .pt" ) ...
code_fim
hard
{ "lang": "python", "repo": "EvgeniiTitov/old-ml-digits", "path": "/helpers/general.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># process primes = [] for n in N: if(myprime.checkprime(n)): primes.append(n) # Output print("-" * 50) print("PRIMES : ", primes)<|fim_prefix|># repo: mindful-ai/15032021PYLVC path: /day_02/livedemo/extractprimes.py # Get "some" numbers from the user and separate the primes ...
code_fim
medium
{ "lang": "python", "repo": "mindful-ai/15032021PYLVC", "path": "/day_02/livedemo/extractprimes.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: mindful-ai/15032021PYLVC path: /day_02/livedemo/extractprimes.py # Get "some" numbers from the user and separate the primes <|fim_suffix|> n = input(" --> ") if(n == "q"): break elif(n.isdigit()): N.append(int(n)) print(N) # process primes = [] for n in...
code_fim
medium
{ "lang": "python", "repo": "mindful-ai/15032021PYLVC", "path": "/day_02/livedemo/extractprimes.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>N = [] while True: n = input(" --> ") if(n == "q"): break elif(n.isdigit()): N.append(int(n)) print(N) # process primes = [] for n in N: if(myprime.checkprime(n)): primes.append(n) # Output print("-" * 50) print("PRIMES : ", primes)<|fim_p...
code_fim
medium
{ "lang": "python", "repo": "mindful-ai/15032021PYLVC", "path": "/day_02/livedemo/extractprimes.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def get_gene_class(self, nth): gene = self[nth] if gene != -1: x = gene // timeslots_num return list(classprof_time.keys())[x].split('-')[1] def is_gene_time_valid(self, nth): gene = self[nth] if gene != -1: return self.gene_valu...
code_fim
hard
{ "lang": "python", "repo": "atenagm1375/AI-Project2018", "path": "/Chromosome.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: atenagm1375/AI-Project2018 path: /Chromosome.py # import collections import random from file_decode import * class Chromosome(list): gene_values = np.ravel([list(classprof_time[i]) for i in classprof_time]) gene_range = range(-1, len(gene_values)) def __init__(self, remove=False):...
code_fim
hard
{ "lang": "python", "repo": "atenagm1375/AI-Project2018", "path": "/Chromosome.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: kuzentio/top30 path: /scraper/admin.py from django.contrib import admin from scraper.models import Company class CompanyAdmin(admin.ModelAdmin): list_display = [ field.name for field in Company._meta.fields if field.name not in ['id', 'site'] ] class Meta: model = C...
code_fim
medium
{ "lang": "python", "repo": "kuzentio/top30", "path": "/scraper/admin.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def __init__(self, *args, **kwargs): self.list_display.append('company_url') super(CompanyAdmin, self).__init__(*args, **kwargs) def company_url(self, company): return '<a href="{0}">{1}</a>'.format(company.site, company.site) company_url.allow_tags = True admin.sit...
code_fim
medium
{ "lang": "python", "repo": "kuzentio/top30", "path": "/scraper/admin.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if not len(message.params) > 2: self.bot.ircsock.say(target, "`@help <target>` where target may be a plugin name or a config setting") return None term = message.params[2] # TODO Fuzzy search (*) in term if term in self.bot.config: _help = self.bot.config.get_help(term) if re...
code_fim
hard
{ "lang": "python", "repo": "Ferus/WhergBot3.0", "path": "/Plugins/Help/Help.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Ferus/WhergBot3.0 path: /Plugins/Help/Help.py #!/usr/bin/env python """ Help Plugin Provides @help for all plugins and config settings """ import re from plugin import BasicPlugin class Plugin(BasicPlugin): def __init__(self, bot): self.bot = bot self.name = "help" self.priority = 50 ...
code_fim
hard
{ "lang": "python", "repo": "Ferus/WhergBot3.0", "path": "/Plugins/Help/Help.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if term in self.bot.config: _help = self.bot.config.get_help(term) if re.search(r"(^\(\S+?\))", _help): # config option help # > If there are capturing groups in the separator and it matches at the # start of the string, the result will start with an empty string. # gg re.sp...
code_fim
hard
{ "lang": "python", "repo": "Ferus/WhergBot3.0", "path": "/Plugins/Help/Help.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: tzyl/ctci-python path: /chapter11/11.5.py # Given a sorted array of strings which is interspersed with empty # strings, write a method to find the location of a given string. # Modified binary search to move middle to closest non-empty string. # Worst case O(n). def search_sparse(strings,...
code_fim
hard
{ "lang": "python", "repo": "tzyl/ctci-python", "path": "/chapter11/11.5.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>if __name__ == '__main__': test = ["a", "", "", "", "b", ""] print search_sparse(test, "b") print search_sparse(test, "a") print search_sparse(test, "c") test2 = ["at", "", "", "", "ball", "", "", "car", "", "", "dad", "", ""] print search_sparse(test2, "at") print searc...
code_fim
hard
{ "lang": "python", "repo": "tzyl/ctci-python", "path": "/chapter11/11.5.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.CreateModel( name='Condition', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('field_id', models.PositiveIntegerField(verbose_name='La field_id del ca...
code_fim
medium
{ "lang": "python", "repo": "camiloforero/complex_hooks", "path": "/migrations/0004_condition.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: camiloforero/complex_hooks path: /migrations/0004_condition.py # -*- coding: utf-8 -*- # Generated by Django 1.9 on 2016-04-22 20:39 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion <|fim_suffix|> dependencies = [ ('co...
code_fim
medium
{ "lang": "python", "repo": "camiloforero/complex_hooks", "path": "/migrations/0004_condition.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ### Compile the models by supplying a loss funciton and an optimizer. self.model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) def make_vectorizer(self, examples, **kwargs): examples = dataset...
code_fim
hard
{ "lang": "python", "repo": "spacelis/hrnn4sim", "path": "/hrnn4sim/seqsim_rnn.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: spacelis/hrnn4sim path: /hrnn4sim/seqsim_rnn.py #!/usr/bin/env python # -*- coding: utf-8 -*- """ This is a basic RNN implementation of address matching network using LSTM cells. """ # pylint: disable=invalid-name from itertools import chain from keras.layers.core import K from keras.models i...
code_fim
hard
{ "lang": "python", "repo": "spacelis/hrnn4sim", "path": "/hrnn4sim/seqsim_rnn.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Similarity models based on RNN. """ def __init__(self, state_size=256, **kwargs): super(SeqSimRNN, self).__init__(**kwargs) self.state_size = 256 def build(self): ''' Build a RNN based model. ''' K.set_session(self.session) A = Input(shape=(None,)) ...
code_fim
hard
{ "lang": "python", "repo": "spacelis/hrnn4sim", "path": "/hrnn4sim/seqsim_rnn.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> elements = range(1, n+1) NN = reduce(operator.mul, elements) # n! k, result = (k-1) % NN, '' while len(elements) > 0: NN = NN / len(elements) i, k = k / NN, k % NN result += str(elements.pop(i)) return result def getPermutati...
code_fim
hard
{ "lang": "python", "repo": "liseyko/CtCI", "path": "/leetcode/p0060 - Permutation Sequence.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: liseyko/CtCI path: /leetcode/p0060 - Permutation Sequence.py import math class Solution: def getPermutation(self, n, k): """ :type n: int :type k: int :rtype: str """ if not n: return "" r = [] nums = [str(i) for i in range(1,n+...
code_fim
hard
{ "lang": "python", "repo": "liseyko/CtCI", "path": "/leetcode/p0060 - Permutation Sequence.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Grzegorz-Giedrojc/motosell path: /motosellapp/migrations/0018_oferta_status.py # Generated by Django 3.1 on 2020-08-12 08:50 from django.db import migrations, models <|fim_suffix|> dependencies = [ ('motosellapp', '0017_remove_oferta_status'), ] operations = [ migr...
code_fim
easy
{ "lang": "python", "repo": "Grzegorz-Giedrojc/motosell", "path": "/motosellapp/migrations/0018_oferta_status.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> dependencies = [ ('motosellapp', '0017_remove_oferta_status'), ] operations = [ migrations.AddField( model_name='oferta', name='status', field=models.CharField(choices=[('aktualny', 'aktualny'), ('nieaktualny', 'nieaktualny')], default='aktu...
code_fim
easy
{ "lang": "python", "repo": "Grzegorz-Giedrojc/motosell", "path": "/motosellapp/migrations/0018_oferta_status.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> operations = [ migrations.AddField( model_name='oferta', name='status', field=models.CharField(choices=[('aktualny', 'aktualny'), ('nieaktualny', 'nieaktualny')], default='aktualny', max_length=32), ), ]<|fim_prefix|># repo: Grzegorz-Giedrojc/mot...
code_fim
medium
{ "lang": "python", "repo": "Grzegorz-Giedrojc/motosell", "path": "/motosellapp/migrations/0018_oferta_status.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Andrewah1/comp110-21f-workspace path: /exercises/ex02/count_letters.py """Counting letters in a string.""" <|fim_suffix|>letter = str(input("What letter do you want to seach for?: ")) word = str(input("Enter a word: ")) i: int = 0 maximun: int = len(word) letter_count: int = 0 while i < maximun:...
code_fim
easy
{ "lang": "python", "repo": "Andrewah1/comp110-21f-workspace", "path": "/exercises/ex02/count_letters.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> letter = str(input("What letter do you want to seach for?: ")) word = str(input("Enter a word: ")) i: int = 0 maximun: int = len(word) letter_count: int = 0 while i < maximun: if word[i] == letter: letter_count = letter_count + 1 i = i + 1 print("Count:", letter_count)<|fim_prefix|># repo...
code_fim
easy
{ "lang": "python", "repo": "Andrewah1/comp110-21f-workspace", "path": "/exercises/ex02/count_letters.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: RitaAsagwara/GDAL-Python path: /gdal_translate2.py #------------------------------------------------------------------------------- # Name: Convert ZMap to Geotiff # Purpose: Convert Petrel Raster ZMap grid to Geotiff # # Author: rasagwara # # Created: 03/07/2015 # Copyright:...
code_fim
medium
{ "lang": "python", "repo": "RitaAsagwara/GDAL-Python", "path": "/gdal_translate2.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> translateFile = ' '.join([gdal_translate, cmd, proj, input, output]) subprocess.call(translateFile) print translateFile if __name__ == '__main__': main()<|fim_prefix|># repo: RitaAsagwara/GDAL-Python path: /gdal_translate2.py #------------------------------------------------------------...
code_fim
medium
{ "lang": "python", "repo": "RitaAsagwara/GDAL-Python", "path": "/gdal_translate2.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># 소숫점 print("{0:f}".format(5/3)) # 소숫점 특정 자리수까지만 표시 print("{0:.2f}".format(5/3))<|fim_prefix|># repo: yewon-kim/sparta-8 path: /practice/0530_Python/8-2_output_format.py # 총 10칸 기준 오른쪽 정렬 print("{0: >10}".format(500)) # +/- 표시 print("{0: >+10}".format(500)) print("{0: >+10}".format(-500)) # 왼쪽 정렬, 빈칸은...
code_fim
medium
{ "lang": "python", "repo": "yewon-kim/sparta-8", "path": "/practice/0530_Python/8-2_output_format.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: yewon-kim/sparta-8 path: /practice/0530_Python/8-2_output_format.py # 총 10칸 기준 오른쪽 정렬 print("{0: >10}".format(500)) # +/- 표시 print("{0: >+10}".format(500)) print("{0: >+10}".format(-500)) # 왼쪽 정렬, 빈칸은 "_"로 채움 print("{0:_<+10}".format(500)) # 콤마 찍기 print("{0:,}".format(1000000000)) <|fim_suffi...
code_fim
medium
{ "lang": "python", "repo": "yewon-kim/sparta-8", "path": "/practice/0530_Python/8-2_output_format.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: YukiT1990/Dynamic-Programming-LeetCode path: /ClimbingStairs.py # 1. Climbing Stairs # 70. Climbing Stairs <|fim_suffix|> def climbStairs(self, n: int) -> int: if n <= 3: return n results = [0 for _ in range(46)] results[1] = 1 results[2] = 2 ...
code_fim
easy
{ "lang": "python", "repo": "YukiT1990/Dynamic-Programming-LeetCode", "path": "/ClimbingStairs.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if n <= 3: return n results = [0 for _ in range(46)] results[1] = 1 results[2] = 2 for i in range(3, n + 1): results[i] = results[i - 1] + results[i - 2] return results[n]<|fim_prefix|># repo: YukiT1990/Dynamic-Programming-LeetCode p...
code_fim
easy
{ "lang": "python", "repo": "YukiT1990/Dynamic-Programming-LeetCode", "path": "/ClimbingStairs.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: wangyy20151029/AI path: /test_blog/test_case/blog_home/BasePage.py #cdding:utf-8 from selenium.webdriver.support.wait import WebDriverWait from selenium import webdriver class Action(object): def __init__(self,selenium_driver,base_url,pagetitle): self.base_url=base_url self....
code_fim
hard
{ "lang": "python", "repo": "wangyy20151029/AI", "path": "/test_blog/test_case/blog_home/BasePage.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> try: loc=getattr(self,"_%s" %loc) if click_first: self.find_element(*loc).click() if clear_first: self.find_element(*loc).clear() self.find_element(*loc).send_keys(vaule) except AttributeError: print(u"%s页面中未能找到%s元...
code_fim
hard
{ "lang": "python", "repo": "wangyy20151029/AI", "path": "/test_blog/test_case/blog_home/BasePage.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: aemann01/mockcommunity path: /scripts/slice_fasta.py #!/usr/bin/python3 '''Read in fasta file and coordinates file (e.g., output of rnammer), pulls sequences and slices to given coordinates ''' <|fim_suffix|>coord = pd.read_csv("rnammer_16s.txt", sep="\t", header=None) records = SeqIO.index("al...
code_fim
medium
{ "lang": "python", "repo": "aemann01/mockcommunity", "path": "/scripts/slice_fasta.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>for i in range(len(coord[0])): if coord[3][i] > coord[4][i]: x = coord[4][i] y = coord[3][i] else: x = coord[3][i] y = coord[4][i] print(">",records[coord[0][i]].id, sep="") print(records[coord[0][i]].seq[x:y])<|fim_prefix|># repo: aemann01/mockcommunity pa...
code_fim
medium
{ "lang": "python", "repo": "aemann01/mockcommunity", "path": "/scripts/slice_fasta.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def select(self, keep): """Apply same indexing to all tensors in container""" for key, value in self.__dict__.items(): self.__dict__[key] = value[keep] return self def __str__(self): to_str = '' for key, tensor in self.__dict__.items(): ...
code_fim
hard
{ "lang": "python", "repo": "conanhung/mask_rcnn-1", "path": "/mrcnn/structs/tensor_container.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>class ZipTest(TestCase): """ Test Zips """ def setUp(self): self.file = open('{}/file.txt'.format(settings.MEDIA_ROOT), "a") self.file.write("some data") self.file.close() def test_zip_duplicate_name(self): zip_file1 = zipfile.ZipFile('{}/zip1.zip'.for...
code_fim
medium
{ "lang": "python", "repo": "sitn/geoshop2", "path": "/back/api/tests/test_zip.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|># repo: sitn/geoshop2 path: /back/api/tests/test_zip.py import zipfile from unittest import TestCase from pathlib import Path from django.conf import settings from api.helpers import _zip_them_all <|fim_suffix|> _zip_them_all('{}/full_zip.zip'.format(settings.MEDIA_ROOT), ['zip1.zip', 'zip2.zip...
code_fim
hard
{ "lang": "python", "repo": "sitn/geoshop2", "path": "/back/api/tests/test_zip.py", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> zip_file1 = zipfile.ZipFile('{}/zip1.zip'.format(settings.MEDIA_ROOT), 'w', zipfile.ZIP_DEFLATED) zip_file1.write(self.file.name, Path(self.file.name).name) zip_file1.close() zip_file2 = zipfile.ZipFile('{}/zip2.zip'.format(settings.MEDIA_ROOT), 'w', zipfile.ZIP_DEFLATED) ...
code_fim
hard
{ "lang": "python", "repo": "sitn/geoshop2", "path": "/back/api/tests/test_zip.py", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> def load_and_map_checkpoint(model, model_dir, remap): path = os.path.join(model_dir, 'model_checkpoint') print("Loading parameters %s from %s" % (remap.keys(), model_dir)) checkpoint = torch.load(path) new_state_dict = model.state_dict() for name, value in remap.items(): # TOD...
code_fim
hard
{ "lang": "python", "repo": "sidarth164/RecoEdge", "path": "/fedrec/utilities/saver_utils.py", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }