text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_suffix|> raw = ds_r[bb] labels = ds_l[bb] out_path = './data/small.n5' with z5py.File(out_path, 'a') as f: f.create_dataset('raw', data=raw, compression='gzip', chunks=ds_r.chunks) f.create_dataset('labels', data=labels, compression='gzip', chunks=ds_l.chunks) if __name__ == '__m...
code_fim
hard
{ "lang": "python", "repo": "JoOkuma/torch-em", "path": "/experiments/mito-em/prepare_train_data.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> itms=sorted(set(args[0].split(' '))) itms=[x for x in itms if x!=''] li=len(itms) if li>0: if li>self.maxlength: self.maxlength=li inputkws=[] for kw in itms: if len(kw)==0: print itms,...
code_fim
hard
{ "lang": "python", "repo": "openaire/iis", "path": "/iis-3rdparty-madis/src/main/resources/eu/dnetlib/iis/3rdparty/scripts/madis/functions/aggregate/mining.py", "mode": "spm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_prefix|># repo: openaire/iis path: /iis-3rdparty-madis/src/main/resources/eu/dnetlib/iis/3rdparty/scripts/madis/functions/aggregate/mining.py import re import itertools import setpath import functions import lib.jopts as jopts from operator import itemgetter import random __docformat__ = 'reStructuredText en' ...
code_fim
hard
{ "lang": "python", "repo": "openaire/iis", "path": "/iis-3rdparty-madis/src/main/resources/eu/dnetlib/iis/3rdparty/scripts/madis/functions/aggregate/mining.py", "mode": "psm", "license": "Zlib", "source": "the-stack-v2" }
<|fim_suffix|> # returns True if valid land def checkValid(self, grid, visited, x, y): if x < 0 or x >= len(grid): return False if y < 0 or y >= len(grid[0]): return False if (x,y) in visited: return False return grid[x][y] == 1 def checkLand(self, grid, x, y): ...
code_fim
hard
{ "lang": "python", "repo": "phibzy/Contests", "path": "/Leetcode/Aug20/300820/q3/q3.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if self.checkLand(grid, x-1, y): n+=1 if self.checkLand(grid, x+1, y): n+=1 if self.checkLand(grid, x, y-1): n+=1 if self.checkLand(grid, x, y+1): n+=1 l...
code_fim
hard
{ "lang": "python", "repo": "phibzy/Contests", "path": "/Leetcode/Aug20/300820/q3/q3.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: phibzy/Contests path: /Leetcode/Aug20/300820/q3/q3.py #!/usr/bin/python3 """ @author : Chris Phibbs @created : Sunday Aug 30, 2020 14:05:56 AEST @file : q3 """ class Solution: def minDays(self, grid: List[List[int]]) -> int: # bfs - find 1, run bfs. Then loop ...
code_fim
hard
{ "lang": "python", "repo": "phibzy/Contests", "path": "/Leetcode/Aug20/300820/q3/q3.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> self.name: str = name self.path: str = path self.filter: str = filter<|fim_prefix|># repo: JohannesHaering/WASA1 path: /msclassifier/src/domain/machinelearning/ModelInfo.py class ModelInfo: <|fim_middle|> def __init__(self, name: str, path: str, filter: str):
code_fim
easy
{ "lang": "python", "repo": "JohannesHaering/WASA1", "path": "/msclassifier/src/domain/machinelearning/ModelInfo.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: JohannesHaering/WASA1 path: /msclassifier/src/domain/machinelearning/ModelInfo.py class ModelInfo: <|fim_suffix|> self.name: str = name self.path: str = path self.filter: str = filter<|fim_middle|> def __init__(self, name: str, path: str, filter: str):
code_fim
easy
{ "lang": "python", "repo": "JohannesHaering/WASA1", "path": "/msclassifier/src/domain/machinelearning/ModelInfo.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: gurudarshan266/FSS-HW-Group-P path: /Project/results/f1/ivy_tune.py {'ivy': {'svm': ({'kernel': 'rbf', 'C': 10.0}, 0.034482758620689662, 0.035087719298245612), 'tuned_ensemble': ({'svm__C': 100000.0, 'rf__n_estimators': 101, 'cart__min_samples_leaf': 7, 'knn__n_neighbors': 2, 'rf__random_state': ...
code_fim
hard
{ "lang": "python", "repo": "gurudarshan266/FSS-HW-Group-P", "path": "/Project/results/f1/ivy_tune.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>33333337, 0.38095238095238099), 'cart': ({'max_depth': 50, 'random_state': 1542, 'max_features': 0.19183673469387758, 'min_samples_split': 13, 'min_samples_leaf': 5}, 0.31192660550458717, 0.2105263157894737), 'knn': ({'n_neighbors': 8, 'weights': 'uniform'}, 0.23529411764705882, 0.23749999999999996)}}<|fi...
code_fim
hard
{ "lang": "python", "repo": "gurudarshan266/FSS-HW-Group-P", "path": "/Project/results/f1/ivy_tune.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> elif root.left is not None and root.right is None: self.maxDepth_helper(root.left, cur_d += 1) elif root.right is not None and root.left is None: self.maxDepth_helper(root.right, cur_d += 1) else: self.maxDepth_helper(root.left, cur_d += 1) ...
code_fim
medium
{ "lang": "python", "repo": "nperera0/coding", "path": "/max_depth_tree.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if root.left is None and root.right is None: self.depth.append(cur_d) return elif root.left is not None and root.right is None: self.maxDepth_helper(root.left, cur_d += 1) elif root.right is not None and root.left is None: self.max...
code_fim
medium
{ "lang": "python", "repo": "nperera0/coding", "path": "/max_depth_tree.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: nperera0/coding path: /max_depth_tree.py ''' Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. ''' # Definition for a binary tree node. clas...
code_fim
medium
{ "lang": "python", "repo": "nperera0/coding", "path": "/max_depth_tree.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ChildishBob/nscc-learn path: /linear.py # Exercise 1 - linear.py import numpy as np import keras # Build the model model = keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])]) # Set the loss and optimizer function model.compile(optimizer='sgd', loss='mean_squared_error') # Initialize i...
code_fim
medium
{ "lang": "python", "repo": "ChildishBob/nscc-learn", "path": "/linear.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Fit the model model.fit(xs, ys, epochs=500) # Prediction dataIn = np.array([10.0], dtype=float) print(model.predict(dataIn,1,1))<|fim_prefix|># repo: ChildishBob/nscc-learn path: /linear.py # Exercise 1 - linear.py import numpy as np import keras # Build the model model = keras.Sequential([keras.layers...
code_fim
hard
{ "lang": "python", "repo": "ChildishBob/nscc-learn", "path": "/linear.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: dhivaab/AWSRemoteCommandRun path: /config.py SSMDocumentName ='AWS-RunPowerShellScript' InstanceId = ['i-081a7260c79feb260'] Querytimeoutseconds = 3600 OutputS3BucketName = 'hccake' OutputS3<|fim_suffix|>cret_access_key ='' workingdirectory =["c:\\"] executiontimeout =["3600"]<|fim_middle|>KeyPre...
code_fim
medium
{ "lang": "python", "repo": "dhivaab/AWSRemoteCommandRun", "path": "/config.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>cret_access_key ='' workingdirectory =["c:\\"] executiontimeout =["3600"]<|fim_prefix|># repo: dhivaab/AWSRemoteCommandRun path: /config.py SSMDocumentName ='AWS-RunPowerShellScript' InstanceId = ['i-081a7260c79f<|fim_middle|>eb260'] Querytimeoutseconds = 3600 OutputS3BucketName = 'hccake' OutputS3KeyPre...
code_fim
medium
{ "lang": "python", "repo": "dhivaab/AWSRemoteCommandRun", "path": "/config.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: WesternHAB/HABcode path: /ControlEverything_Methane_Ozone/Ozone/ADC121C_MQ131.py #!/usr/bin/python3 # Distributed with a free-will license. # Use it any way you want, profit or free, provided it fits in the licenses of its associated works. # ADC121C_MQ131 # This code is designed to work with the...
code_fim
hard
{ "lang": "python", "repo": "WesternHAB/HABcode", "path": "/ControlEverything_Methane_Ozone/Ozone/ADC121C_MQ131.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # ADC121C_MQ131 address, 0x50(80) # Read data back from 0x00(00), 2 bytes # raw_adc MSB, raw_adc LSB while True: data = bus.read_i2c_block_data(0x50, 0x00, 2) # Convert the data to 12-bits raw_adc = (data[0] & 0x0F) * 256 + data[1] ppm = (1.99 * raw_adc) / 4096.0 + 0.01 timestmp = ((str(da...
code_fim
hard
{ "lang": "python", "repo": "WesternHAB/HABcode", "path": "/ControlEverything_Methane_Ozone/Ozone/ADC121C_MQ131.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Mfuon2/btrealestate path: /listings/urls.py # This handle the url for routing <|fim_suffix|># Defines views to pass dynamic data to listings page urlpatterns = [ path('', views.index, name='listings'), path('<int:listing_id>', views.listing, name='listing'), path('search', views.search, na...
code_fim
easy
{ "lang": "python", "repo": "Mfuon2/btrealestate", "path": "/listings/urls.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Defines views to pass dynamic data to listings page urlpatterns = [ path('', views.index, name='listings'), path('<int:listing_id>', views.listing, name='listing'), path('search', views.search, name='search') ]<|fim_prefix|># repo: Mfuon2/btrealestate path: /listings/urls.py # This handle the url...
code_fim
easy
{ "lang": "python", "repo": "Mfuon2/btrealestate", "path": "/listings/urls.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: yexiaoguai/blogproject path: /movie/models.py # -*- coding: utf-8 -*- from __future__ import unicode_literals import markdown from django.db import models from django.contrib.auth.models import User from datetime import datetime class MovieRankings(models.Model): """ 各种电影排行榜. """ ...
code_fim
hard
{ "lang": "python", "repo": "yexiaoguai/blogproject", "path": "/movie/models.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # 观看的用户. # 用户一对多MovieHistory,可以看多个电影. user = models.ForeignKey(User) # 观看的电影. movie = models.ForeignKey(Movie) # 观看的时间. date = models.DateTimeField(auto_now_add=True) # 0表示用户观看了该电影,1表示收藏,2表示推荐. marked = models.IntegerField(blank=True, null=True) def __unicode__...
code_fim
hard
{ "lang": "python", "repo": "yexiaoguai/blogproject", "path": "/movie/models.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if math == "subtraction": e.insert(0, f_num - int(second_number)) if math == "multiplication": e.insert(0, f_num * int(second_number)) if math == "division": e.insert(0, f_num / int(second_number)) def button_subtract(): first_number = e.get() global f_num global math math = "...
code_fim
hard
{ "lang": "python", "repo": "mortazavian/calculator-python", "path": "/calculator.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: mortazavian/calculator-python path: /calculator.py from tkinter import * global math root = Tk() root.title("Calculator") e = Entry(root,width=60,borderwidth=5) e.grid(columnspan=3) def button_click(number): #e.delete(0, END) current = e.get() e.delete(0, END) e.insert(0, ...
code_fim
hard
{ "lang": "python", "repo": "mortazavian/calculator-python", "path": "/calculator.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Define fdsn client to get data from client = Client('http://fdsnws.raspberryshakedata.com') # Define start and end time orig_time = UTCDateTime(EQ_TIME) t1 = orig_time - T_START t2 = orig_time + T_END # Download and filfter data st = client.get_waveforms(NETWORK, STATION, "00", CHANNEL, ...
code_fim
hard
{ "lang": "python", "repo": "shicks-seismo/obspy_plotting", "path": "/plot_raspshake_event_waveforms_rays.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: shicks-seismo/obspy_plotting path: /plot_raspshake_event_waveforms_rays.py #!/usr/bin/env python """ Script to download and plot RaspberryShake station data Also computes and plots theoretical phase arrival times and raypaths. See https://docs.obspy.org/packages/obspy.taup.html for more info on ...
code_fim
hard
{ "lang": "python", "repo": "shicks-seismo/obspy_plotting", "path": "/plot_raspshake_event_waveforms_rays.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> mfcc_result = [] for info in phonemes_info: start, stop = (1000 * info['start'], 1000 * info['end']) segment = np.array(wav[start:stop].get_array_of_samples()) if ignore_shorter_phonemes and segment.size < phoneme_len: continue ...
code_fim
hard
{ "lang": "python", "repo": "eMaerthin/microevolution-lang-phones", "path": "/scripts/chains/mfcc_local.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: eMaerthin/microevolution-lang-phones path: /scripts/chains/mfcc_local.py import json import logging import numpy as np from python_speech_features import mfcc from format_converters import get_segment from schemas import * from chains.mfcc import Mfcc logger = logging.getLogger() class MfccLo...
code_fim
hard
{ "lang": "python", "repo": "eMaerthin/microevolution-lang-phones", "path": "/scripts/chains/mfcc_local.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: diogobaeder/project-euler path: /1/problem1.py #!/usr/bin/env python class Problem1(object): <|fim_suffix|> current_number = 1 total = 0 while current_number < threshold: if (current_number % 3 == 0) or (current_number % 5 == 0): total += current...
code_fim
easy
{ "lang": "python", "repo": "diogobaeder/project-euler", "path": "/1/problem1.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> current_number = 1 total = 0 while current_number < threshold: if (current_number % 3 == 0) or (current_number % 5 == 0): total += current_number current_number += 1 return total if __name__ == '__main__': problem1 = Problem1() ...
code_fim
easy
{ "lang": "python", "repo": "diogobaeder/project-euler", "path": "/1/problem1.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if __name__ == '__main__': problem1 = Problem1() print problem1.sum_below(1000) # == 233168<|fim_prefix|># repo: diogobaeder/project-euler path: /1/problem1.py #!/usr/bin/env python class Problem1(object): <|fim_middle|> def sum_below(self, threshold): current_number = 1 total...
code_fim
hard
{ "lang": "python", "repo": "diogobaeder/project-euler", "path": "/1/problem1.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: nb786/NaBooLo path: /textt/views.py # I Have Created this file -Nabeel from django.http import HttpResponse from django.shortcuts import render def index(request): return render(request,'index.html') def aboutme(request): return HttpResponse (" <a href='https://nb786.github.io/Ncoder/a...
code_fim
hard
{ "lang": "python", "repo": "nb786/NaBooLo", "path": "/textt/views.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if (charcount == "on"): analyzed = "" for char in djtext: analyzed = len(djtext) dics = {'purpose': 'Total no. of Character in your text are', 'analyzed_text': analyzed} if (removepunc != "on" and fullcaps != "on" and newlineremover != "on" and extraspaceremover != "on" and c...
code_fim
hard
{ "lang": "python", "repo": "nb786/NaBooLo", "path": "/textt/views.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p02272/s513789824.py A = [] ans = 0 def merge(left, mid, right): global A global ans n1 = mid - left n2 = right - mid l = [] r = [] for i in range(n1): l += [A[left + i]] for i in range(n2): r += [A[mid + i]] l += [10**18] r += [10**18] i ...
code_fim
medium
{ "lang": "python", "repo": "Aasthaengg/IBMdataset", "path": "/Python_codes/p02272/s513789824.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def main(): global ans global A n = int(input()) A = list(map(int,input().split())) Msort(0,n) print(" ".join(list(map(str,A)))) print(ans) main()<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p02272/s513789824.py A = [] ans = 0 def merge(left, mid, right): global A global ans...
code_fim
medium
{ "lang": "python", "repo": "Aasthaengg/IBMdataset", "path": "/Python_codes/p02272/s513789824.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def get_faces(shapes): # cmds.select(clear=True) # print(shapes) face_data = [] for shape in shapes: mSel = om2.MSelectionList() mSel.add(shape) mDagPath, mObj = mSel.getComponent(0) geo = om2.MItMeshPolygon(mDagPath, mObj) while not geo.isDone(): ...
code_fim
hard
{ "lang": "python", "repo": "shrimo/vfx_dev", "path": "/maya/general_lesson/lesson_v01.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def set_pos_vertex(shapes, up_y): spc = om2.MSpace.kWorld for shape in shapes: mSel = om2.MSelectionList() mSel.add(shape) mDagPath, mObj = mSel.getComponent(0) vtx = om2.MItMeshVertex(mDagPath, mObj) while not vtx.isDone(): vtx_pos = vtx.positio...
code_fim
hard
{ "lang": "python", "repo": "shrimo/vfx_dev", "path": "/maya/general_lesson/lesson_v01.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: shrimo/vfx_dev path: /maya/general_lesson/lesson_v01.py """ get poly data(face center, face id, etc), select face, create object by face data setPosition for vertex (random) import sys module_path = '/home/shrimo/Desktop/course/git/vfx_dev/maya/general_lesson' if module_path not in sys.path: ...
code_fim
hard
{ "lang": "python", "repo": "shrimo/vfx_dev", "path": "/maya/general_lesson/lesson_v01.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: leostellallc/postal path: /www/cgi-bin/is-admin.py #!/usr/bin/env python3 import cgitb import sys <|fim_suffix|>cgitb.enable() sys.stdout.write('Content-Type: application/octet-stream\n\n') sys.stdout.write('yes' if is_admin() else 'no') sys.stdout.flush()<|fim_middle|>from auth import is_admin ...
code_fim
easy
{ "lang": "python", "repo": "leostellallc/postal", "path": "/www/cgi-bin/is-admin.py", "mode": "psm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|>cgitb.enable() sys.stdout.write('Content-Type: application/octet-stream\n\n') sys.stdout.write('yes' if is_admin() else 'no') sys.stdout.flush()<|fim_prefix|># repo: leostellallc/postal path: /www/cgi-bin/is-admin.py #!/usr/bin/env python3 import cgitb import sys <|fim_middle|>from auth import is_admin ...
code_fim
easy
{ "lang": "python", "repo": "leostellallc/postal", "path": "/www/cgi-bin/is-admin.py", "mode": "spm", "license": "LicenseRef-scancode-warranty-disclaimer", "source": "the-stack-v2" }
<|fim_suffix|> # =================================================================== PreProcess feats = [col for col in raw.columns.values if col not in ['ID_code', 'target']] # =================================================================== Model train = raw[:len_train] test = raw[len_trai...
code_fim
hard
{ "lang": "python", "repo": "xins-yao/Kaggle_SCTP_31th_solution", "path": "/train_augement.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: xins-yao/Kaggle_SCTP_31th_solution path: /train_augement.py import gc import sys import time import warnings import multiprocessing import numpy as np import pandas as pd import lightgbm as lgb from os import path, makedirs from tqdm import tqdm from utils import Logger from dateti...
code_fim
hard
{ "lang": "python", "repo": "xins-yao/Kaggle_SCTP_31th_solution", "path": "/train_augement.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> 'num_leaves': 8, 'max_depth': -1, 'feature_fraction': 0.05, 'bagging_freq': 5, 'bagging_fraction': 0.4, 'min_data_in_leaf': 80, 'min_sum_hessian_in_leaf': 10.0, } print('model params:\n{}'.format(pd.Series(list(param.values()), index=...
code_fim
hard
{ "lang": "python", "repo": "xins-yao/Kaggle_SCTP_31th_solution", "path": "/train_augement.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: bbbales2/modal path: /experiments/generate_data.py #%% import numpy import time import scipy import os os.chdir('/home/bbales2/modal') import pyximport import seaborn pyximport.install(reload_support = True) import polybasisqu reload(polybasisqu) #from rotations import symmetry #from rotations ...
code_fim
hard
{ "lang": "python", "repo": "bbbales2/modal", "path": "/experiments/generate_data.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>dCdc44 = Kt.dot(dCdc44).dot(Kt.T) if True: dKdw, _ = polybasisqu.buildKM(dCdw, dp, pv, density) dKdx, _ = polybasisqu.buildKM(dCdx, dp, pv, density) dKdy, _ = polybasisqu.buildKM(dCdy, dp, pv, density) dKdz, _ = polybasisqu.buildKM(dCdz, dp, pv, density) dKdc11, _ = polybasisqu.build...
code_fim
hard
{ "lang": "python", "repo": "bbbales2/modal", "path": "/experiments/generate_data.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> ids = [] for i in names: try: actor_id = ActorDB.objects.get(name=i).id ids.append((i, actor_id)) except ActorDB.DoesNotExist: return [] return ids<|fim_prefix|># repo: matthewgoulet/moviemediaportal path: /rt/helper.py from django.contrib.auth.models import User from rt.models import Mov...
code_fim
hard
{ "lang": "python", "repo": "matthewgoulet/moviemediaportal", "path": "/rt/helper.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: matthewgoulet/moviemediaportal path: /rt/helper.py from django.contrib.auth.models import User from rt.models import Movie_Suggestion, MovieDB, ActorDB, TVDB def user_present(username): <|fim_suffix|>def sort_actor_id(actors, names): ids = [] for i in names: try: actor_id = ActorDB.object...
code_fim
hard
{ "lang": "python", "repo": "matthewgoulet/moviemediaportal", "path": "/rt/helper.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#Takes a list of MovieDB objects and their titles as Strings #Output a list of tuples containing the (title, id) def sort_id(movies, titles): ids = [] for i in titles: try: movie_id = MovieDB.objects.get(title=i).id ids.append((i, movie_id)) except MovieDB.DoesNotExist: return [] return id...
code_fim
medium
{ "lang": "python", "repo": "matthewgoulet/moviemediaportal", "path": "/rt/helper.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>@juju.requires_login def model_status(): """ Returns the FullStatus output of a model Returns: Dictionary of model status """ return juju.CLIENT.Client(request="FullStatus")<|fim_prefix|># repo: frankmalcolmkembery/conjure-up path: /conjureup/api/models.py """ Interfaces to Juju API ...
code_fim
hard
{ "lang": "python", "repo": "frankmalcolmkembery/conjure-up", "path": "/conjureup/api/models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> """ Returns the FullStatus output of a model Returns: Dictionary of model status """ return juju.CLIENT.Client(request="FullStatus")<|fim_prefix|># repo: frankmalcolmkembery/conjure-up path: /conjureup/api/models.py """ Interfaces to Juju API ModelManager """ from conjureup import j...
code_fim
hard
{ "lang": "python", "repo": "frankmalcolmkembery/conjure-up", "path": "/conjureup/api/models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: frankmalcolmkembery/conjure-up path: /conjureup/api/models.py """ Interfaces to Juju API ModelManager """ from conjureup import juju @juju.requires_login def list_models(user='user-admin'): <|fim_suffix|>@juju.requires_login def model_info(model): """ Returns information on select model ...
code_fim
hard
{ "lang": "python", "repo": "frankmalcolmkembery/conjure-up", "path": "/conjureup/api/models.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: mengyangbai/leetcode path: /dynamicprogramming/outofboundarypaths.py class Solution(object): def findPaths(self, m, n, N, i, j): """ :type m: int :type n: int :type N: int :type i: int :type j: int :rtype: int ""<|fim_suffix|>e(m...
code_fim
hard
{ "lang": "python", "repo": "mengyangbai/leetcode", "path": "/dynamicprogramming/outofboundarypaths.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>e(m)] for x in range(m): for y in range(n): for dx,dy in dz: nx,ny = x + dx, y+dy if 0 <= nx < m and 0 <= ny <n: ndp[nx][ny]= (ndp[nx][ny]+dp[x][y])%MOD else:...
code_fim
hard
{ "lang": "python", "repo": "mengyangbai/leetcode", "path": "/dynamicprogramming/outofboundarypaths.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: BlacksThunders/AirBnB_clone path: /console.py #!/usr/bin/python3 """ program of the command interpreter """ import cmd import models import re from models.base_model import BaseModel from models import storage from models.user import User from models.state import State from models.city import Ci...
code_fim
hard
{ "lang": "python", "repo": "BlacksThunders/AirBnB_clone", "path": "/console.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if (type(line) == str): arg_line = line.split() len_args = len(arg_line) if (self.check_if_created(arg_line, len_args) != 1): get_inst = arg_line[0] + "." + arg_line[1] dict_classes = models.storage.all() if get...
code_fim
hard
{ "lang": "python", "repo": "BlacksThunders/AirBnB_clone", "path": "/console.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def compress_image(data): with open(PATH.format(data['name']), 'wb+') as file: file.write(data['binary']) image = Image.open(PATH.format(data['name'])) new_img = image.resize((128, 128)) new_img.save(PATH.format(data['name'])) with open(PATH.format(data['name']), '...
code_fim
medium
{ "lang": "python", "repo": "VasuDholakiya2810/chat-application", "path": "/services/check_image.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: VasuDholakiya2810/chat-application path: /services/check_image.py """ Image Check / Compress Image""" import re import os from PIL import Image from common.constant import PATH <|fim_suffix|>def compress_image(data): with open(PATH.format(data['name']), 'wb+') as file: file.write(...
code_fim
medium
{ "lang": "python", "repo": "VasuDholakiya2810/chat-application", "path": "/services/check_image.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> with open(PATH.format(data['name']), 'wb+') as file: file.write(data['binary']) image = Image.open(PATH.format(data['name'])) new_img = image.resize((128, 128)) new_img.save(PATH.format(data['name'])) with open(PATH.format(data['name']), 'rb') as image_file: ...
code_fim
medium
{ "lang": "python", "repo": "VasuDholakiya2810/chat-application", "path": "/services/check_image.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: kiniou/simply-builder path: /bin/simply-createschroot #!/usr/bin/python import sys,os import argparse import subprocess from pprint import pprint chroot_start_path="/srv/chroot" chroots_conf="/etc/schroot/chroot.d" build_pkgs = 'build-essential fakeroot devscripts apt-utils' include = 'eatmyda...
code_fim
hard
{ "lang": "python", "repo": "kiniou/simply-builder", "path": "/bin/simply-createschroot", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if( os.path.ismount( start_path ) ) : print("%s is mounted" % start_path) else: print("%s is not mounted" % start_path) exit() complete_path = os.path.join(start_path,end_path) cmd = 'btrfs subvolume list "%s" > /dev/null 2>&1' % complete_path p = subprocess.P...
code_fim
hard
{ "lang": "python", "repo": "kiniou/simply-builder", "path": "/bin/simply-createschroot", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> with pytest.raises(IntegrityError): Page.objects.create(url=regex) @pytest.mark.skipif('connection.vendor == "mysql"', reason=MYSQL_REASON) def test_invalid_regex(): exception = IntegrityError if connection.vendor == 'sqlite' else DataError with pytest.raises(exception): Page...
code_fim
hard
{ "lang": "python", "repo": "vinayinvicible/django-regexfield", "path": "/tests/test_regexfield.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Page.objects.create(url='^/[a-z]*/$') assert Page.objects.filter(url__imatch='/path/') assert Page.objects.filter(url__imatch='/PATH/') @pytest.mark.skipif('connection.vendor == "mysql"', reason=MYSQL_REASON) @pytest.mark.parametrize('regex', ('', '.*', '.?', '[\w]*', '[\w]?')) def test_empt...
code_fim
hard
{ "lang": "python", "repo": "vinayinvicible/django-regexfield", "path": "/tests/test_regexfield.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: vinayinvicible/django-regexfield path: /tests/test_regexfield.py from __future__ import absolute_import, unicode_literals from django.db import DataError, IntegrityError, connection import pytest from .models import Page pytestmark = pytest.mark.django_db MYSQL_REASON = 'MySQL parses check c...
code_fim
hard
{ "lang": "python", "repo": "vinayinvicible/django-regexfield", "path": "/tests/test_regexfield.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: jalvaradosegura/folder_organizer path: /docs/config.py import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) <|fim_suffix|>FILES_DESTINATION = { 'images': ['.jpg', '.jpeg', '.png'], 'documents': ['.pdf', '.xlsx', '.docx', '.txt'], 'apps': ['.pkg', '.dmg', ...
code_fim
medium
{ "lang": "python", "repo": "jalvaradosegura/folder_organizer", "path": "/docs/config.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>FILES_DESTINATION = { 'images': ['.jpg', '.jpeg', '.png'], 'documents': ['.pdf', '.xlsx', '.docx', '.txt'], 'apps': ['.pkg', '.dmg', '.exe'], 'videos': ['.mp4', '.flv'], 'audios': ['.mp3'], 'compressions': ['.rar', '.zip'], 'scripts': ['.py', '.rb', '.js', '.html'], }<|fim_pref...
code_fim
medium
{ "lang": "python", "repo": "jalvaradosegura/folder_organizer", "path": "/docs/config.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>def test_004_when_df_is_named() -> None: """Tests what happens when df has a name.""" df = generate_test_data() df.name = "Named dataframe" skim(df)<|fim_prefix|># repo: lenamax2355/skimpy-1 path: /tests/test_main.py """Test cases for the __main__ module.""" import pytest from click.testi...
code_fim
hard
{ "lang": "python", "repo": "lenamax2355/skimpy-1", "path": "/tests/test_main.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: lenamax2355/skimpy-1 path: /tests/test_main.py """Test cases for the __main__ module.""" import pytest from click.testing import CliRunner from skimpy import __main__ from skimpy import generate_test_data from skimpy import skim @pytest.fixture def runner() -> CliRunner: """Fixture for inv...
code_fim
medium
{ "lang": "python", "repo": "lenamax2355/skimpy-1", "path": "/tests/test_main.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: RebeRobles/Dojo_Reads path: /dojo_book_app/apps.py from django.apps import AppConfig <|fim_suffix|> default_auto_field = 'django.db.models.BigAutoField' name = 'dojo_book_app'<|fim_middle|>class DojoBookAppConfig(AppConfig):
code_fim
easy
{ "lang": "python", "repo": "RebeRobles/Dojo_Reads", "path": "/dojo_book_app/apps.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: RebeRobles/Dojo_Reads path: /dojo_book_app/apps.py from django.apps import AppConfig <|fim_suffix|> default_auto_field = 'django.db.models.BigAutoField' name = 'dojo_book_app'<|fim_middle|> class DojoBookAppConfig(AppConfig):
code_fim
easy
{ "lang": "python", "repo": "RebeRobles/Dojo_Reads", "path": "/dojo_book_app/apps.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> default_auto_field = 'django.db.models.BigAutoField' name = 'dojo_book_app'<|fim_prefix|># repo: RebeRobles/Dojo_Reads path: /dojo_book_app/apps.py from django.apps import AppConfig <|fim_middle|>class DojoBookAppConfig(AppConfig):
code_fim
easy
{ "lang": "python", "repo": "RebeRobles/Dojo_Reads", "path": "/dojo_book_app/apps.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: hbcbh1999/yelpReviewQualityPredictor path: /Data/find_wrd_freq.py """ This file goes through the data to find the frequencies of words in the corpus """ import csv import time, datetime import calendar from collections import defaultdict import chardet import re REVIEW_ID_COL = 0; U...
code_fim
hard
{ "lang": "python", "repo": "hbcbh1999/yelpReviewQualityPredictor", "path": "/Data/find_wrd_freq.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> fieldNames = readCSV[0] print(fieldNames) readForOneHot = readCSV[1:] print ("Going through the words for the frequencies.") # Go through the set, finding the frequencies for row in readForOneHot: getAsciiFriendlyString(row[TEXT_COL], wordFrequencies) print (len(readForOneHot)) # W...
code_fim
hard
{ "lang": "python", "repo": "hbcbh1999/yelpReviewQualityPredictor", "path": "/Data/find_wrd_freq.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # In[20]: sb.catplot(x="Age", y="Sex", hue="Survived", col="Embarked", notch = False, palette = "Set2", data=data, kind="box", height=4, aspect=.7); # In[17]: sb.catplot(x="Age", y="Sex", hue="Survived",...
code_fim
medium
{ "lang": "python", "repo": "StevenBaez/MSDS", "path": "/410 - Titanic Discussion.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>import numpy as np import matplotlib # In[20]: sb.catplot(x="Age", y="Sex", hue="Survived", col="Embarked", notch = False, palette = "Set2", data=data, kind="box", height=4, aspect=.7); # In[17]: sb.catplot(x="Age", y=...
code_fim
medium
{ "lang": "python", "repo": "StevenBaez/MSDS", "path": "/410 - Titanic Discussion.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: StevenBaez/MSDS path: /410 - Titanic Discussion.py #!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd import numpy as np import seaborn as sb import matplotlib as mp data = pd.read_csv("/Users/stevenbaez/Desktop/train.csv") <|fim_suffix|> sb.catplot(x="Age", y="Sex", ...
code_fim
hard
{ "lang": "python", "repo": "StevenBaez/MSDS", "path": "/410 - Titanic Discussion.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>print("\n15. Sorting lists.") temp_list = [5,55,555] temp_list.sort() print("\tSorted list: " + str(temp_list)) temp_list.sort(reverse=True) print("\tSorted list: " + str(temp_list)) print("\tSorting lists by callable functions (inbuilt) e.g. len using 'key") temp_string = "I am a software tester." temp_s...
code_fim
hard
{ "lang": "python", "repo": "SandeepDhamale19/TestAutomation.Python.Basics", "path": "/3_Collections/1_Lists.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: SandeepDhamale19/TestAutomation.Python.Basics path: /3_Collections/1_Lists.py # Lists are sequence of objects # Mutable # Lists are represented within square brackets and items are seperated by commas #-----------------------------------Lists-----------------------------------# # Lists of Number...
code_fim
hard
{ "lang": "python", "repo": "SandeepDhamale19/TestAutomation.Python.Basics", "path": "/3_Collections/1_Lists.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Get specific elements within list: Slicing print("\n7. Get specific elements within list: Slicing") list_numbers = [1,2,3,4,5] sub_list_numbers = list_numbers[1:3] print("\tSub list: " + str(sub_list_numbers)) print("\tLast element in list: " + str(list_numbers[-1])) print("\tGet all elements in list ...
code_fim
hard
{ "lang": "python", "repo": "SandeepDhamale19/TestAutomation.Python.Basics", "path": "/3_Collections/1_Lists.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: uktrade/market-access-prototype path: /barriers/migrations/0012_auto_20171002_1441.py # -*- coding: utf-8 -*- # Generated by Django 1.11.4 on 2017-10-02 14:41 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import mptt.fields cl...
code_fim
hard
{ "lang": "python", "repo": "uktrade/market-access-prototype", "path": "/barriers/migrations/0012_auto_20171002_1441.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>officials in the country I am trying to export to'), ('SUPPORT_DESIRED_BROAD', 'Broader UK Government involvement'), ('SUPPORT_DESIRED_NOT_SURE', 'Not sure')], default=None, max_length=10, null=True)), ('confidentiality_issues_description', models.TextField(blank=True, null=True)), ...
code_fim
hard
{ "lang": "python", "repo": "uktrade/market-access-prototype", "path": "/barriers/migrations/0012_auto_20171002_1441.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: hhb123/NinaproCNN path: /trainCNNfdf.py from classNinapro import Ninapro import numpy as np import tensorflow as tf print(tf.__version__) Debug = True # for tensor dimensionality checking ninapro = Ninapro() ninapro.splitImagesLabels() # Train print('ninapro.TrainImages shape: ', ninapro.Trai...
code_fim
hard
{ "lang": "python", "repo": "hhb123/NinaproCNN", "path": "/trainCNNfdf.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|># Use an AdamOptimizer to train the network train = tf.train.AdamOptimizer(1e-1).minimize(cross_entropy) # Visualization directory graph_dir = 'sEMGCNN' import usefulFcns usefulFcns.BuildNewlyDir(graph_dir) # Train the model with tf.Session() as sess: sess.run(tf.global_variables_initializer()) ...
code_fim
hard
{ "lang": "python", "repo": "hhb123/NinaproCNN", "path": "/trainCNNfdf.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>with Printer(linegap=1) as printer: for pdf_file in files: printer.text(pdf_file)<|fim_prefix|># repo: lf-hernandez/auto-label-printer path: /main.py from requests import get from bs4 import BeautifulSoup, SoupStrainer import httplib2 import re from win32printing import Printer def getLinks(...
code_fim
hard
{ "lang": "python", "repo": "lf-hernandez/auto-label-printer", "path": "/main.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: lf-hernandez/auto-label-printer path: /main.py from requests import get from bs4 import BeautifulSoup, SoupStrainer import httplib2 import re from win32printing import Printer <|fim_suffix|> for element in document.findAll('a', href=re.compile(".pdf$")): links.append(element.get('href...
code_fim
medium
{ "lang": "python", "repo": "lf-hernandez/auto-label-printer", "path": "/main.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>files = [] for link in pdf_links: pdf_file = requests.get(url) files.append(pdf_file) with Printer(linegap=1) as printer: for pdf_file in files: printer.text(pdf_file)<|fim_prefix|># repo: lf-hernandez/auto-label-printer path: /main.py from requests import get from bs4 import Beauti...
code_fim
medium
{ "lang": "python", "repo": "lf-hernandez/auto-label-printer", "path": "/main.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> global startOfGame startOfGame = False #list of platforms global platforms platforms = [] starter_platform = platform([100, 700]) platforms.append(starter_platform) global p1 p1 = player() def draw(): global atStartUp if (atStartUp): curren...
code_fim
hard
{ "lang": "python", "repo": "priyamsahoo/Fallin-t", "path": "/Fallint.pyde", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>def startScreen(remainingTime): background(sb) fill(0) textAlign(CENTER, CENTER) textSize(40) fill(240,225,48) text("Welcome to Fallin't", width/2, 0.25*height/2) textSize(100) fill(50, 50, 50) text(ceil(remainingTime / 1000.0), width/2, 1.65*height/2)<|fim_prefix|># re...
code_fim
hard
{ "lang": "python", "repo": "priyamsahoo/Fallin-t", "path": "/Fallint.pyde", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: priyamsahoo/Fallin-t path: /Fallint.pyde from platform_class import * from player_class import * from functions import * delay = 3000 startOfGame = False # def keyPressed(): # startOfGame = True # print(startOfGame) # if (keyCode == 'B'): # print("I am pressed") # s...
code_fim
hard
{ "lang": "python", "repo": "priyamsahoo/Fallin-t", "path": "/Fallint.pyde", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> casas_decimais=18 if ((numero == 0) or (numero == 1)): return "O resultado eh: " + str(numero) elif (numero<0): return "A raiz nao existe no conjunto real" else: posicao = 0 casa_decimal = 10**posicao resultado_parcial = 0.0 while (-...
code_fim
hard
{ "lang": "python", "repo": "AiramL/Python-Exercicios", "path": "/raiz.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: AiramL/Python-Exercicios path: /raiz.py ''' Aluno: Lucas Airam Castro de Souza Resumo: Programa para calcular a raiz com a precis�o n de casas decimais def raiz(numero, casas_decimais=0): if ((numero == 0) or (numero == 1)): return "O resultado eh: " + str(numero) elif...
code_fim
hard
{ "lang": "python", "repo": "AiramL/Python-Exercicios", "path": "/raiz.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: PaulWThi/Cracking-the-Coding-Interview path: /1-4.py # Write function that determines if a string a palindrome off of any permutation def palinPerm(str): <|fim_suffix|> # The final set should either have 1 element or none return len(charSet) == 1 or len(charSet) == 0 response = "It is a pali...
code_fim
hard
{ "lang": "python", "repo": "PaulWThi/Cracking-the-Coding-Interview", "path": "/1-4.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> # The final set should either have 1 element or none return len(charSet) == 1 or len(charSet) == 0 response = "It is a palinPerm" if palinPerm("dadadad") else "No, not a palinPerm" print(response) # Time Complexity: O(N)<|fim_prefix|># repo: PaulWThi/Cracking-the-Coding-Interview path: /1-4.py # W...
code_fim
medium
{ "lang": "python", "repo": "PaulWThi/Cracking-the-Coding-Interview", "path": "/1-4.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> response = "It is a palinPerm" if palinPerm("dadadad") else "No, not a palinPerm" print(response) # Time Complexity: O(N)<|fim_prefix|># repo: PaulWThi/Cracking-the-Coding-Interview path: /1-4.py # Write function that determines if a string a palindrome off of any permutation def palinPerm(str): <|fim_...
code_fim
hard
{ "lang": "python", "repo": "PaulWThi/Cracking-the-Coding-Interview", "path": "/1-4.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|># repo: ymcat626/spider path: /04/pyquery/demo8.py # coding: utf-8 from pyquery import PyQuery as pq html = ''' <div id="container"> <ul class="list"> <li class="item-0">first it<|fim_suffix|>/li> <li class="item-1 active"><a href="link4.html">fourth item</a></li> ...
code_fim
medium
{ "lang": "python", "repo": "ymcat626/spider", "path": "/04/pyquery/demo8.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>> </ul </div> ''' # 获取属性 # 第一种方法 doc = pq(html) a = doc('.item-0.active a') print(a, type(a)) print(a.attr('href')) # 第二种方法 print(a.attr.href)<|fim_prefix|># repo: ymcat626/spider path: /04/pyquery/demo8.py # coding: utf-8 from pyquery import PyQuery as pq html = ''' <div id="containe...
code_fim
hard
{ "lang": "python", "repo": "ymcat626/spider", "path": "/04/pyquery/demo8.py", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> def test_can_create_under_landing_page(self): self.assertCanCreateAt(SetupGuideLandingPage, SetupGuidePage)<|fim_prefix|># repo: stuaxo/invest path: /setup_guide/tests/test_models.py from wagtail.tests.utils import WagtailPageTests from setup_guide.models import SetupGuideLandingPage, SetupGu...
code_fim
hard
{ "lang": "python", "repo": "stuaxo/invest", "path": "/setup_guide/tests/test_models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> def test_setup_guide_page_subpages(self): # A SetupGuidePage can only have other SetupGuidePage children self.assertAllowedSubpageTypes( SetupGuideLandingPage, {SetupGuidePage}) class SetupGuidePageTests(WagtailPageTests): def test_can_create_under_landing_page(self):...
code_fim
medium
{ "lang": "python", "repo": "stuaxo/invest", "path": "/setup_guide/tests/test_models.py", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: stuaxo/invest path: /setup_guide/tests/test_models.py from wagtail.tests.utils import WagtailPageTests from setup_guide.models import SetupGuideLandingPage, SetupGuidePage from home.models import HomePage <|fim_suffix|> def test_can_create_under_homepage(self): self.assertCanCreateAt...
code_fim
medium
{ "lang": "python", "repo": "stuaxo/invest", "path": "/setup_guide/tests/test_models.py", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|># repo: manojkumar-github/books path: /professional-python/part-1/Generators/generators-within-generators.py """ Python 3.3 introduces the new "yield from" statement to provide straightforward way for a generator to call out to other generators """ def gen1(): <|fim_suffix|>def full_gen(): yield fro...
code_fim
hard
{ "lang": "python", "repo": "manojkumar-github/books", "path": "/professional-python/part-1/Generators/generators-within-generators.py", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }