text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>## This is the sorted Word Count code
counts_rdd = applymapping1_rdd.flatMap(lambda line: line["text"].split(" ")) \
.map(lambda word: (word, 1)) \
.reduceByKey(lambda a, b: a + b) \
.sortBy(lambda x: -x[1])
## This is to merge all the files into one
counts_df = co... | code_fim | hard | {
"lang": "python",
"repo": "pharnoux/columbia-aiops-glue-helper",
"path": "/word-count-etl.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: callapena/zillow_cluster path: /model.py
import pandas as pd
import numpy as np
import scipy as sp
from sklearn.preprocessing import PowerTransformer, LabelEncoder, OneHotEncoder, QuantileTransformer, MinMaxScaler
from sklearn.cluster import KMeans
from collections import OrderedDict
from sklearn... | code_fim | hard | {
"lang": "python",
"repo": "callapena/zillow_cluster",
"path": "/model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>X4_train, test4 = validation(X3_train, y_train, test3, bool_features + neighbor_feats + amenities_feats)
X4_train = X4_train.drop(columns='logerror')
# MODEL
def evaluate(model, x_train, y_train):
y_pred = model.predict(x_train)
rmse = mean_squared_error(y_train, y_pred)**1/2
return rmse
de... | code_fim | hard | {
"lang": "python",
"repo": "callapena/zillow_cluster",
"path": "/model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mon0theist/Automate-The-Boring-Stuff path: /Chapter 04/characterPictureGrid1.py
# Character Picture Grid
#
# Say you have a list of lists where each value in the inner lists is a one-character string, like this:
#
#
# grid = [['.', '.', '.', '.', '.', '.'],
# ['.', 'O', 'O', '.', '.... | code_fim | hard | {
"lang": "python",
"repo": "mon0theist/Automate-The-Boring-Stuff",
"path": "/Chapter 04/characterPictureGrid1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for j in range(len(grid[0])): # this is basically functioning as the Y axis?
for i in range(0, len(grid)): # this is basically functioning as the X axis?
print(grid[i][j], end='') # keyword=end prevents a newline after every print()
print()
# I don't follow this at all.... :'(<|fim_p... | code_fim | hard | {
"lang": "python",
"repo": "mon0theist/Automate-The-Boring-Stuff",
"path": "/Chapter 04/characterPictureGrid1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> login_url = "https://www.douban.com/accounts/login"
html = response.text
soup = BeautifulSoup(html, "html.parser")
if len(response.xpath("//img[@id='captcha_image']/@src")) >0:
urlretrieve(response.xpath("//img[@id='captcha_image']/@src").extract()[0],
... | code_fim | hard | {
"lang": "python",
"repo": "shihongliang/Crawler",
"path": "/Crawler/spiders/douban.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> html = response.text
soup = BeautifulSoup(html, "html.parser")
names = soup.select(".article .mod .member-list .name a")
locations = soup.select(".article .mod .member-list .name .pl")
for name, location in zip(names, locations):
item = DoubanItem()
... | code_fim | hard | {
"lang": "python",
"repo": "shihongliang/Crawler",
"path": "/Crawler/spiders/douban.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shihongliang/Crawler path: /Crawler/spiders/douban.py
import json
import scrapy
import urllib.parse
from scrapy import Spider, Request
from bs4 import BeautifulSoup
from urllib.request import urlopen, urlretrieve
import re
import time
'''
from Crawler.items import DoubanItem
class doubanSpider(s... | code_fim | hard | {
"lang": "python",
"repo": "shihongliang/Crawler",
"path": "/Crawler/spiders/douban.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def inverted(self):
return NorthPolarTransform()
def _set_lim_and_transforms(self):
PolarAxes._set_lim_and_transforms(self)
self.transProjection = self.NorthPolarTransform()
self.transData = (
self.transScale +
self.transProjection ... | code_fim | hard | {
"lang": "python",
"repo": "tierney/directional_antennas",
"path": "/src/NorthPolarAxes.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> transform_non_affine = transform
def inverted(self):
return InvertedNorthPolarTransform()
class InvertedNorthPolarTransform(PolarAxes.InvertedPolarTransform):
def transform(self, xy):
x = xy[:, 0:1]
y = xy[:, 1:]
r = N.sqrt(x*x ... | code_fim | hard | {
"lang": "python",
"repo": "tierney/directional_antennas",
"path": "/src/NorthPolarAxes.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tierney/directional_antennas path: /src/NorthPolarAxes.py
#!/usr/bin/env python
import numpy as N
import matplotlib.pyplot as P
from matplotlib.projections import PolarAxes, register_projection
from matplotlib.transforms import Affine2D, Bbox, IdentityTransform
class NorthPolarAxes(PolarAxes):... | code_fim | hard | {
"lang": "python",
"repo": "tierney/directional_antennas",
"path": "/src/NorthPolarAxes.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: itsolutionscorp/AutoStyle-Clustering path: /all_data/exercism_data/python/leap/52ba301e73d64f29891e8538e24f375a.py
class is_leap_year(object):
'''Test if a number is leap year or not.'''
def __init__(self, year):
self.year = year
if (year <|fim_suffix|> True
else:
False
... | code_fim | medium | {
"lang": "python",
"repo": "itsolutionscorp/AutoStyle-Clustering",
"path": "/all_data/exercism_data/python/leap/52ba301e73d64f29891e8538e24f375a.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> True
else:
False
else:
True
else:
False<|fim_prefix|># repo: itsolutionscorp/AutoStyle-Clustering path: /all_data/exercism_data/python/leap/52ba301e73d64f29891e8538e24f375a.py
class is_leap_year(object):
'''Test if a number is leap year or <|fim_middle|>not.'''
def __ini... | code_fim | medium | {
"lang": "python",
"repo": "itsolutionscorp/AutoStyle-Clustering",
"path": "/all_data/exercism_data/python/leap/52ba301e73d64f29891e8538e24f375a.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
couleur=["yellow","blue","green","pink","violet","brown","grey","magenta"]
graphe1 = Graphe()
graphe1.ajouter_sommet("A")
graphe1.ajouter_sommet("B")
graphe1.ajouter_sommet("C")
graphe1.ajouter_sommet("D")
graphe1.ajouter_sommet("E")
graphe1.ajouter_sommet("F")
graphe1.ajouter_sommet("G")
graphe1... | code_fim | hard | {
"lang": "python",
"repo": "bros-bioinfo/bros-bioinfo.github.io",
"path": "/COURS/M1/SEMESTRE2/ALGO/grapheclass.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bros-bioinfo/bros-bioinfo.github.io path: /COURS/M1/SEMESTRE2/ALGO/grapheclass.py
# -*- coding: utf8 -*-
import os
import sys
class Graphe:
def __init__(self):
self.sommets = []
self.arcs = []
self.incidence = {}
self.adjacence = {}
self.couleur={}
... | code_fim | hard | {
"lang": "python",
"repo": "bros-bioinfo/bros-bioinfo.github.io",
"path": "/COURS/M1/SEMESTRE2/ALGO/grapheclass.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dcy1990/Python-Machine-Learning-by-Du-Chunyang path: /SVC/SVC.py
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 17 19:47:03 2018
@author: chuny
"""
<|fim_suffix|>df=pd.read_csv('Iris.csv')
df=df.drop(['Id'],axis=1)
X=df.values[:,0:4][1,1]
y=df.values[:,4]
X_train,X_test,y_train,y_test=train_t... | code_fim | medium | {
"lang": "python",
"repo": "dcy1990/Python-Machine-Learning-by-Du-Chunyang",
"path": "/SVC/SVC.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.4)
#
clf=SVC(kernel='linear')
clf.fit(X_train,y_train)
y_pred = clf.predict(X_test)
print(accuracy_score(y_test,y_pred))<|fim_prefix|># repo: dcy1990/Python-Machine-Learning-by-Du-Chunyang path: /SVC/SVC.py
# -*- coding: utf-8 -*-
"""
Created... | code_fim | medium | {
"lang": "python",
"repo": "dcy1990/Python-Machine-Learning-by-Du-Chunyang",
"path": "/SVC/SVC.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matt-j-harvey/Widefield_Analysis path: /build/lib/Trial_Aligned_Analysis/Test_Significance_Mixed_Effects_Model.py
import os
number_of_threads = 1
os.environ["OMP_NUM_THREADS"] = str(number_of_threads) # export OMP_NUM_THREADS=1
os.environ["OPENBLAS_NUM_THREADS"] = str(number_of_threads) # export... | code_fim | hard | {
"lang": "python",
"repo": "matt-j-harvey/Widefield_Analysis",
"path": "/build/lib/Trial_Aligned_Analysis/Test_Significance_Mixed_Effects_Model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pixel_index in tqdm(range(number_of_pixels), position=1, desc="Pixel", leave=True):
# Package Into Dataframe
pixel_activity = timepoint_activity[:, pixel_index]
pixel_dataframe = repackage_data_into_dataframe(pixel_activity, metadata_dataset)
#... | code_fim | hard | {
"lang": "python",
"repo": "matt-j-harvey/Widefield_Analysis",
"path": "/build/lib/Trial_Aligned_Analysis/Test_Significance_Mixed_Effects_Model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hjklnm4/garedn path: /BJ/수학계산2/bk5.py
def prime(x):
if x <= 1:
return False
elif x == 2:
return True
else:
for n in range(2,x):
if (x%n)==0:
return False
break
else:
continue
retur... | code_fim | medium | {
"lang": "python",
"repo": "hjklnm4/garedn",
"path": "/BJ/수학계산2/bk5.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(len(d)):
for j in range(i, i*2+1):
if prime(d[i]) == True:
count+=1
else:
continue
print(count)<|fim_prefix|># repo: hjklnm4/garedn path: /BJ/수학계산2/bk5.py
def prime(x):
if x <= 1:
return False
elif x == 2:
return True... | code_fim | medium | {
"lang": "python",
"repo": "hjklnm4/garedn",
"path": "/BJ/수학계산2/bk5.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.sala.es_vacia():
pass
#print('la sala de ' + self.nombre + ' esta vacia ')
else:
paciente=self.sala.desencolar()
print('Se ha atendido al paciente ' + paciente.nombre + ' en ' + self.nombre)
self.atender_pacientes()
... | code_fim | medium | {
"lang": "python",
"repo": "r0a91/Taller1Ciencias3Grupo81UD",
"path": "/Ejercicio1/dependencia.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def agregar_a_sala(self, paciente):
self.sala.encolar(paciente)<|fim_prefix|># repo: r0a91/Taller1Ciencias3Grupo81UD path: /Ejercicio1/dependencia.py
import cola
class Dependencia:
#clase que indica en donde se debe atender al paciente con su nombre y la sala de espera que es una cola de... | code_fim | hard | {
"lang": "python",
"repo": "r0a91/Taller1Ciencias3Grupo81UD",
"path": "/Ejercicio1/dependencia.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: r0a91/Taller1Ciencias3Grupo81UD path: /Ejercicio1/dependencia.py
import cola
class Dependencia:
#clase que indica en donde se debe atender al paciente con su nombre y la sala de espera que es una cola de pacientes
def __init__(self, nombre):
<|fim_suffix|> if self.sala.es_vacia():... | code_fim | medium | {
"lang": "python",
"repo": "r0a91/Taller1Ciencias3Grupo81UD",
"path": "/Ejercicio1/dependencia.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return distance + max (len(firstStrand), len(secondStrand)) - limit<|fim_prefix|># repo: itsolutionscorp/AutoStyle-Clustering path: /all_data/exercism_data/python/hamming/86e9165e1d7247b5989d58bea3c9599e.py
def hamming(firstStrand, secondStrand):
limit = min(len(firstStran<|fim_middle|>d), len(secondS... | code_fim | medium | {
"lang": "python",
"repo": "itsolutionscorp/AutoStyle-Clustering",
"path": "/all_data/exercism_data/python/hamming/86e9165e1d7247b5989d58bea3c9599e.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: itsolutionscorp/AutoStyle-Clustering path: /all_data/exercism_data/python/hamming/86e9165e1d7247b5989d58bea3c9599e.py
def hamming(firstStrand, secondStrand):
limit = min(len(firstStran<|fim_suffix|> return distance + max (len(firstStrand), len(secondStrand)) - limit<|fim_middle|>d), len(secondS... | code_fim | medium | {
"lang": "python",
"repo": "itsolutionscorp/AutoStyle-Clustering",
"path": "/all_data/exercism_data/python/hamming/86e9165e1d7247b5989d58bea3c9599e.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
random_pass_gerator()<|fim_prefix|># repo: mohansaimandalapu/Python-beginner-level-projects path: /Random password generator/random_pass_generator.py
from password_generator import PasswordGenerator
def random_pass_gerator():
<|fim_middle|> pwo = PasswordGenerator()
... | code_fim | easy | {
"lang": "python",
"repo": "mohansaimandalapu/Python-beginner-level-projects",
"path": "/Random password generator/random_pass_generator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mohansaimandalapu/Python-beginner-level-projects path: /Random password generator/random_pass_generator.py
from password_generator import PasswordGenerator
def random_pass_gerator():
<|fim_suffix|>
if __name__ == "__main__":
random_pass_gerator()<|fim_middle|> pwo = PasswordGenerator()
... | code_fim | easy | {
"lang": "python",
"repo": "mohansaimandalapu/Python-beginner-level-projects",
"path": "/Random password generator/random_pass_generator.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
random_pass_gerator()<|fim_prefix|># repo: mohansaimandalapu/Python-beginner-level-projects path: /Random password generator/random_pass_generator.py
from password_generator import PasswordGenerator
def random_pass_gerator():
<|fim_middle|> pwo = PasswordGenerator()
... | code_fim | easy | {
"lang": "python",
"repo": "mohansaimandalapu/Python-beginner-level-projects",
"path": "/Random password generator/random_pass_generator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mnick900/CSE-Fixed- path: /Guess game.py
import random
type = input("Do you want to manually change what the bounds are?\n Answer with(y/n)").upper()
while type != "Y" and type != "N":
type = input("Do you want to manually change what the bounds are?\n Answer with(y/n)").upper()
if type == "Y... | code_fim | hard | {
"lang": "python",
"repo": "mnick900/CSE-Fixed-",
"path": "/Guess game.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>.randint(1, 10)
print(num)
guess = int(input("Guess a number from 1-10"))
gum = 0
for i in range (4):
if guess < num:
print("Guess higher")
gum = gum + 1
guess = int(input("Guess a number from 1-10"))
e... | code_fim | hard | {
"lang": "python",
"repo": "mnick900/CSE-Fixed-",
"path": "/Guess game.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return '(%d, %d, %s, %d)' %(self.__speed, self.__gear, self.__color, self.__fuelratio)
def calcFuel(self, distance):
self.__distance = distance
return self.__distance / self.__fuelratio
myCar = Car()
myCar.setSpeed(3);
myCar.setGear(100);
myCar.setColor... | code_fim | hard | {
"lang": "python",
"repo": "youngseok-hwang/Python",
"path": "/자동차 클래스 작성.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: youngseok-hwang/Python path: /자동차 클래스 작성.py
class Car:
def __init__(self, speed=0, gear=1, color="white", fuelratio=0):
self.__speed = speed
self.__gear = gear
self.__color = color
self.__fuelratio = fuelratio
def setSpeed(self, speed):
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "youngseok-hwang/Python",
"path": "/자동차 클래스 작성.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.__gear = gear;
def setColor(self, color):
self.__color = color;
def setFuelratio(self, fuelratio):
self.__fuelratio = fuelratio;
def __str__(self):
return '(%d, %d, %s, %d)' %(self.__speed, self.__gear, self.__color, self.__fuelratio)
def calcFuel(s... | code_fim | medium | {
"lang": "python",
"repo": "youngseok-hwang/Python",
"path": "/자동차 클래스 작성.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Print the diff between current and desired job config
"""
print(">>>>>>>> Job config diff for %s <<<<<<<<" % app.name)
cfg_dicts = []
factory = TSimpleJSONProtocolFactory()
for cfg in app.current_job_config, app.desired_job_config:
if... | code_fim | hard | {
"lang": "python",
"repo": "fakeNetflix/uber-repo-peloton",
"path": "/tools/deploy/cluster.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Unset task resources to avoid confusing the job config differ
cfg_dict["taskConfig"]["resources"] = None
else:
cfg_dict = {}
cfg_dicts.append(cfg_dict)
if verbose:
for cfg_dict in cfg_dicts:
prin... | code_fim | hard | {
"lang": "python",
"repo": "fakeNetflix/uber-repo-peloton",
"path": "/tools/deploy/cluster.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fakeNetflix/uber-repo-peloton path: /tools/deploy/cluster.py
from __future__ import absolute_import
import yaml
import json
import json_delta
from prompter import yesno
from thrift import TSerialization
from thrift.protocol.TJSONProtocol import TSimpleJSONProtocolFactory
from aurora.client impo... | code_fim | hard | {
"lang": "python",
"repo": "fakeNetflix/uber-repo-peloton",
"path": "/tools/deploy/cluster.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> GraphScanner.__init__(self, input_str)
self.delimiters = Delimiters()
self.delimiters.append(["{", "}", "(", ")", "[", "]", ",", ":"])<|fim_prefix|># repo: alanmmckay/population_protocol_simulator path: /init_scanner.py
from graph_scanner import GraphScanner
from general_token imp... | code_fim | easy | {
"lang": "python",
"repo": "alanmmckay/population_protocol_simulator",
"path": "/init_scanner.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alanmmckay/population_protocol_simulator path: /init_scanner.py
from graph_scanner import GraphScanner
from general_token import GeneralToken, GeneralTokenType
from errors import GeneralError
from delimiters import Delimiters
<|fim_suffix|> def __init__(self, input_str):
GraphScanner.... | code_fim | easy | {
"lang": "python",
"repo": "alanmmckay/population_protocol_simulator",
"path": "/init_scanner.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for pulls_comment in pulls_comments:
if not isinstance(pulls_comment,dict):
continue
pulls_comment_dict[pulls_comment['user']['login']] = dict()
pulls_comment_dict[pulls_comment['user']['login']]['name'] = pulls_comment['user']['login']
filename = 'pr_comments.json'
with open(filename... | code_fim | medium | {
"lang": "python",
"repo": "tygkking/test",
"path": "/finalstruct-data/venv/aftercode/pr_comment.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tygkking/test path: /finalstruct-data/venv/aftercode/pr_comment.py
#python 3.6
# -*- coding:utf-8 -*-
__author__ = 'ZYH'
import json
import requests
from tqdm import tqdm
# headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.... | code_fim | medium | {
"lang": "python",
"repo": "tygkking/test",
"path": "/finalstruct-data/venv/aftercode/pr_comment.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chorry/py-rl path: /001.py
on = 0
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
TILES_ACROSS = 5 - 1
TILES_DOWN = 5 - 1
PLAYER_START_X = PLAYER_START_Y = 1
BLOCK_DARKNESS = 0
BLOCK_PLAYER = 1
BLOCK_FLOOR = 2
BLOCK_WALL = 3
BLOCK_TRAP = 4
@Singleton
class DisplayDevice:
def setScreen(self, sc... | code_fim | hard | {
"lang": "python",
"repo": "chorry/py-rl",
"path": "/001.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chorry/py-rl path: /001.py
print "handling from skillHandler"
#pickTarget if eligible
#applySkillEffect
#if duration > 0 : add to effect stack
pass
def pickTarget(self):
if self.skill.maxTargets() < 100:
#register target picker
... | code_fim | hard | {
"lang": "python",
"repo": "chorry/py-rl",
"path": "/001.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # draw active player border
text = self.fontPlayer.render(o.name, True, (255, 255, 255))
screen.blit(text, (xLeft + 1, yLeft + playerBoxHeight * .8))
idx = idx + 1
# draw players name
def drawEnemy(self, screen, obj):
self.interactiv... | code_fim | hard | {
"lang": "python",
"repo": "chorry/py-rl",
"path": "/001.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> transform("parabolic",
Matrix([sigma*tau, (tau**2 - sigma**2) / 2]),
[sigma, tau])
transform("bipolar",
Matrix([a*sinh(tau)/(cosh(tau)-cos(sigma)),
a*sin(sigma)/(cosh(tau)-cos(sigma))]),
[sigma, tau]
)
transform(... | code_fim | hard | {
"lang": "python",
"repo": "sympy/sympy",
"path": "/examples/advanced/curvilinear_coordinates.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sympy/sympy path: /examples/advanced/curvilinear_coordinates.py
#!/usr/bin/env python
"""
This example shows how to work with coordinate transformations, curvilinear
coordinates and a little bit with differential geometry.
It takes polar, cylindrical, spherical, rotating disk coordinates and ot... | code_fim | hard | {
"lang": "python",
"repo": "sympy/sympy",
"path": "/examples/advanced/curvilinear_coordinates.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> transform("cylindrical", Matrix([rho*cos(phi), rho*sin(phi), z]),
[rho, phi, z])
transform("spherical",
Matrix([rho*sin(theta)*cos(phi), rho*sin(theta)*sin(phi),
rho*cos(theta)]),
[rho, theta, phi],
recursive=True
... | code_fim | hard | {
"lang": "python",
"repo": "sympy/sympy",
"path": "/examples/advanced/curvilinear_coordinates.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.local_num = local_num
self.train_weight = train_weight # vector tensor
self.test_weight = test_weight # vector tensor
self.candidate_users = candidate_users
self.reg = model_conf['reg']
def train_model(self, dataset, evaluator, early_stop, logger, config):... | code_fim | hard | {
"lang": "python",
"repo": "renyi533/LOCA",
"path": "/model/LOCA_EASE.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: renyi533/LOCA path: /model/LOCA_EASE.py
import os
import math
import copy
import pickle
from time import time
import numpy as np
from scipy import sparse
import torch
from torch import dtype
import torch.nn as nn
import torch.nn.functional as F
from torch.autograd import Variable
from concurrent... | code_fim | hard | {
"lang": "python",
"repo": "renyi533/LOCA",
"path": "/model/LOCA_EASE.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>'Ram: ' +ram)
print('CPU: ' +cpu)
if antivirus==True:
print('Sei in possesso anche di un antivirus')<|fim_prefix|># repo: FrancescoGobbo/Python path: /funzioni1.py
def laptop_nuovo(ram,cpu,antivirus=False):
print('Il n<|fim_middle|>uovo laptop avrà le seguenti caratteristiche: ')
... | code_fim | medium | {
"lang": "python",
"repo": "FrancescoGobbo/Python",
"path": "/funzioni1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FrancescoGobbo/Python path: /funzioni1.py
def laptop_nuovo(ram,cpu,antivirus=False):
print('Il n<|fim_suffix|>rue:
print('Sei in possesso anche di un antivirus')<|fim_middle|>uovo laptop avrà le seguenti caratteristiche: ')
print('Ram: ' +ram)
print('CPU: ' +cpu)
if a... | code_fim | medium | {
"lang": "python",
"repo": "FrancescoGobbo/Python",
"path": "/funzioni1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lischero/Atcoder path: /ABC027/q3.py
# -*- coding:utf-8 -*-
import math, sys
N = int(input())
x = 1
depth = math.floor(math.log(N, 2))
if depth == 0:
print("Aoki<|fim_suffix|> x *= 2
else:
if tmp%2 == 0:
x *= 2
else:
x = 2*x+1
if x > N:
... | code_fim | medium | {
"lang": "python",
"repo": "Lischero/Atcoder",
"path": "/ABC027/q3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tmp%2 == 0:
print("Aoki")
sys.exit()
else:
print("Takahashi")
sys.exit()<|fim_prefix|># repo: Lischero/Atcoder path: /ABC027/q3.py
# -*- coding:utf-8 -*-
import math, sys
N = int(input())
x = 1
depth = math.floor(math.log(N, 2))
if depth == 0:
... | code_fim | hard | {
"lang": "python",
"repo": "Lischero/Atcoder",
"path": "/ABC027/q3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: InformaticsMskRu/informatics-mccme-ru path: /pynformatics/model/stars.py
"""Run model"""
from sqlalchemy.sql.expression import and_
from sqlalchemy import Table, Column, ForeignKey
from sqlalchemy.types import Integer, String, DateTime, Text, Unicode, Boolean
from sqlalchemy.orm import relations... | code_fim | medium | {
"lang": "python",
"repo": "InformaticsMskRu/informatics-mccme-ru",
"path": "/pynformatics/model/stars.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> __tablename__ = "mdl_stars"
__table_args__ = {'schema': 'moodle'}
id = Column(Integer, primary_key=True)
user_id = Column(Integer, ForeignKey('moodle.mdl_user.id'))
# user = relationship(SimpleUser, backref = backref('simpleuser1'), uselist=False, lazy=False, primaryjoin = user_id == S... | code_fim | medium | {
"lang": "python",
"repo": "InformaticsMskRu/informatics-mccme-ru",
"path": "/pynformatics/model/stars.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class NoteData(generics.RetrieveUpdateDestroyAPIView):
queryset = models.Note.objects.all()
serializer_class = serializers.NoteSerializer<|fim_prefix|># repo: jacobwi/django-notes-api path: /notes/views.py
from rest_framework import generics
from . import models
from . import serializers
... | code_fim | medium | {
"lang": "python",
"repo": "jacobwi/django-notes-api",
"path": "/notes/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jacobwi/django-notes-api path: /notes/views.py
from rest_framework import generics
from . import models
from . import serializers
<|fim_suffix|> queryset = models.Note.objects.all()
serializer_class = serializers.NoteSerializer
class NoteData(generics.RetrieveUpdateDestroyAPIVie... | code_fim | easy | {
"lang": "python",
"repo": "jacobwi/django-notes-api",
"path": "/notes/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>'''
#2번 코드 (제출 시, 시간초과 됨)
A, B, C= map(int, input().split())
x=1
if C<=B:
print(-1)
else:
while A>(C-B)*x:
x=x+1
print(int(x))
'''<|fim_prefix|># repo: gunhuikim/leetcode_problem_solving path: /break_even_point.py
'''
문제
월드전자는 노트북을 제조하고 판매하는 회사이다. 노트북 판매 대수에 상관없이 매년 임대료, 재산세,
보험료,... | code_fim | medium | {
"lang": "python",
"repo": "gunhuikim/leetcode_problem_solving",
"path": "/break_even_point.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: johan855/sf_crime_statistics path: /data_stream.py
import logging
import json
from pyspark.sql import SparkSession
from pyspark.sql.types import *
from pyspark import SparkConf, SparkContext
import pyspark.sql.functions as psf
# Create a schema for incoming resources
schema = StructType([
S... | code_fim | hard | {
"lang": "python",
"repo": "johan855/sf_crime_statistics",
"path": "/data_stream.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
logger = logging.getLogger(__name__)
# Create Spark in Standalone mode
spark = SparkSession \
.builder \
.master("local[*]") \
.config("spark.ui.port", 4040) \
.appName("KafkaSparkStructuredStreaming") \
.getOrCreate()
pr... | code_fim | hard | {
"lang": "python",
"repo": "johan855/sf_crime_statistics",
"path": "/data_stream.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.elapsed = time() - self._tstart
fail = exception_type is not None
if not self._disable:
if get_info("rich_text") and not get_info("building_doc"):
# New line, get back to previous line, and advance cursor to the end
# of the line. T... | code_fim | hard | {
"lang": "python",
"repo": "Joyvalley/limix",
"path": "/limix/_display/_display.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Joyvalley/limix path: /limix/_display/_display.py
import sys
from time import time
from ._core import blue, bold, pprint, red, width, wrap_text
def banner():
from limix import __version__
pyver = sys.version.split("\n")[0].strip()
return "Running Limix {} using Python {}.".format(... | code_fim | hard | {
"lang": "python",
"repo": "Joyvalley/limix",
"path": "/limix/_display/_display.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def listagem(request):
data = {} # Cria um dicionário vazio
data["transacoes"] = Transacao.objects.all() # objects é um manager pronto
# do Django que nos permitirá acessar os dados de determinado model
return render(request, "contas/listagem.html", data)
def home(request):
r... | code_fim | hard | {
"lang": "python",
"repo": "DiegoMeruoca/Django5-Create",
"path": "/controle_gastos/contas/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = {} # Cria um dicionário vazio
data["transacoes"] = Transacao.objects.all() # objects é um manager pronto
# do Django que nos permitirá acessar os dados de determinado model
return render(request, "contas/listagem.html", data)
def home(request):
return render(request, "c... | code_fim | medium | {
"lang": "python",
"repo": "DiegoMeruoca/Django5-Create",
"path": "/controle_gastos/contas/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DiegoMeruoca/Django5-Create path: /controle_gastos/contas/views.py
from django.shortcuts import render, redirect # Importa o redirect
from .models import Transacao # Importa o model
from .form import TransacaoForm # Importa a classe do form
<|fim_suffix|> data = {} # Cria um dicionário... | code_fim | medium | {
"lang": "python",
"repo": "DiegoMeruoca/Django5-Create",
"path": "/controle_gastos/contas/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SchoolPower/SchoolPower-Backend path: /localization/localize.py
import gettext
import os
from typing import Callable
dirname = os.path.dirname(__file__)
localedir = os.path.join(dirname, "locales")
<|fim_suffix|>
def use_localize(locale: str) -> Callable[[str], str]:
languages = ["en"] if ... | code_fim | hard | {
"lang": "python",
"repo": "SchoolPower/SchoolPower-Backend",
"path": "/localization/localize.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if "zh" in locale and "Hans" not in locale and ("Hant" in locale or "TW" in locale):
return "zh-Hant"
if "zh" in locale:
return "zh-Hans"
return locale
def use_localize(locale: str) -> Callable[[str], str]:
languages = ["en"] if locale is None else [get_equivalent_locale(... | code_fim | medium | {
"lang": "python",
"repo": "SchoolPower/SchoolPower-Backend",
"path": "/localization/localize.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
inputs self,save_path,frequency limits,save
saves a image as output
'''
plt.figure(figsize=(14, 5))
X = librosa.stft(self.signalData)
Xdb = librosa.amplitude_to_db(abs(X))
pylab.axis('off') # no axis
pylab.axes([0., 0., 1., 1.], frameon=False, xticks=[], yticks=[])... | code_fim | medium | {
"lang": "python",
"repo": "saisriteja/sashank_Teja_paperwork",
"path": "/Teja_work/teja_codes/plottings.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saisriteja/sashank_Teja_paperwork path: /Teja_work/teja_codes/plottings.py
import matplotlib.pyplot as plt
import librosa
import os
import matplotlib
import pylab
import librosa
import librosa.display
import numpy as np
<|fim_suffix|> '''
inputs self,save_path,frequency limits,save
... | code_fim | medium | {
"lang": "python",
"repo": "saisriteja/sashank_Teja_paperwork",
"path": "/Teja_work/teja_codes/plottings.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: i-jelly/Qangeloid path: /Search.py
# -*- coding:utf-8 -*-
import re
import time
import requests as rq
from bs4 import BeautifulSoup as bs
url = "https://zh.moegirl.org/index.php?search="
Header = {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,ima... | code_fim | medium | {
"lang": "python",
"repo": "i-jelly/Qangeloid",
"path": "/Search.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = rq.get(url + keywords,headers = Header)
while(int(res.status_code) != 200):
if(int(res.status_code) > 400):
return "爬虫错误"
page = bs(res.text,"html.parser")
if(len(page.select('p[class="mw-search-nonefound"]')) > 0):
return... | code_fim | medium | {
"lang": "python",
"repo": "i-jelly/Qangeloid",
"path": "/Search.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("num_of_point_in_mcg_json:")
print(dict(sorted(num_of_point_in_mcg_json.items())))
pp.pprint(num_of_point_in_mcg_json)
print("num_of_point_in_coco_json:")
print(dict(sorted(num_of_point_in_coco_json.items())))
pp.pprint(num_of_point_in_coco_json)
# pdb.set_trace()<|fim_prefix|># repo: henrywang1/mas... | code_fim | hard | {
"lang": "python",
"repo": "henrywang1/maskrcnn-few",
"path": "/test_mcg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: henrywang1/maskrcnn-few path: /test_mcg.py
import pdb
import json
from collections import Counter, defaultdict
num_of_point_in_mcg_json = defaultdict(int)
num_of_point_in_coco_json = defaultdict(int)
with open("datasets/coco/annotations/coco_train_mcg.json") as f:
myjson = json.load(f)
a... | code_fim | medium | {
"lang": "python",
"repo": "henrywang1/maskrcnn-few",
"path": "/test_mcg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
with open("datasets/coco/annotations/instances_train2017.json") as f:
myjson = json.load(f)
annotations = myjson["annotations"]
print("There are totoal {0} annotations".format(len(annotations)))
for i, ann in enumerate(annotations):
if ann["iscrowd"] == 1:
continue
... | code_fim | medium | {
"lang": "python",
"repo": "henrywang1/maskrcnn-few",
"path": "/test_mcg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leogulus/pisco_pipeline path: /pisco_redsequence.py
import sys
import os
import pandas as pd
import numpy as np
import subprocess
import shlex
from astropy.coordinates import SkyCoord
from astropy import units as u
from astropy.table import Table
import matplotlib.pyplot as plt
from matplotlib ... | code_fim | hard | {
"lang": "python",
"repo": "leogulus/pisco_pipeline",
"path": "/pisco_redsequence.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def find_offset(fname):
with open(fname) as f:
content = f.readlines()
content = [x.strip() for x in content]
band=[x.split(' ')[0][-1] for x in content[5:-1]]
corr=[float(x.split(' ')[1]) for x in content[5:-1]]
ecorr=[float(x.split(' ')[3]) for x in content[5:-1]]
return ... | code_fim | hard | {
"lang": "python",
"repo": "leogulus/pisco_pipeline",
"path": "/pisco_redsequence.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skrolikowski/Python-Game-Clones path: /test/decorator.py
import pyglet
import pybox
from pyglet.window import key, mouse
# ----------------------------
# General
# ----------------------------
@pybox.game.load
def load(win):
global window
window = win
@pybox.game.update
def update(dt)... | code_fim | hard | {
"lang": "python",
"repo": "skrolikowski/Python-Game-Clones",
"path": "/test/decorator.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># @pybox.game.mouse_press
# def mouse_press(x, y, button, modifiers):
# print(x, y, button)
# @pybox.game.mouse_release
# def mouse_release(x, y, button, modifiers):
# print(x, y, button)
# @pybox.game.mouse_scroll
# def on_mouse_scroll(x, y, scroll_x, scroll_y):
# print(x, y, scroll_x, scro... | code_fim | hard | {
"lang": "python",
"repo": "skrolikowski/Python-Game-Clones",
"path": "/test/decorator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># @pybox.game.show
# def show():
# print('shown')
# @pybox.game.move
# def move(x, y):
# print('moved', x, y)
# ----------------------------
# Keyboard
# ----------------------------
@pybox.game.key_press
def key_press(symbol, modifiers):
if symbol == key.ESCAPE:
window.close()
# @... | code_fim | hard | {
"lang": "python",
"repo": "skrolikowski/Python-Game-Clones",
"path": "/test/decorator.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diogoaurelio/archivingScript path: /archivingScript.py
import sys, os
from os import walk
from os import listdir
from os.path import isfile, join
import shutil
import time
import getopt
import re #RegEx
#import yaml
class ArchiveFiles:
def __init__(self, date):
#Initializes a dict ... | code_fim | hard | {
"lang": "python",
"repo": "diogoaurelio/archivingScript",
"path": "/archivingScript.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def Run(self):
"""Executes the job."""
src = 'testFolder'
dest = 'testFolder2'
self._backupLog('\n' + 'Starting Archiving Job - Archiving Files of date: ' + str(time.strftime("%Y-%m-%d")) + '\n' )
self._backupLog('Archiving Job Start Time: ' + str(time.strftime("%H:%M:%S")) + ... | code_fim | hard | {
"lang": "python",
"repo": "diogoaurelio/archivingScript",
"path": "/archivingScript.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _archiveDataByDate(self, src, dest):
"""Goes through files inside directory structure ."""
root = os.getcwd()
srcPath = join(root,src)
destPath = join(root,dest)
f = [] #Array with list of files in directory
fDate = [] #Array with list of files with ... | code_fim | hard | {
"lang": "python",
"repo": "diogoaurelio/archivingScript",
"path": "/archivingScript.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zy-sunshine/magicinstaller2 path: /src/mi/client/modules/network.py
# -*- python -*-
from mi.client.utils import _
from mi.client.utils import magicstep
class MIStep_network (magicstep.magicstep):
<|fim_suffix|> def check_ready(self):
return 1<|fim_middle|> def __init__(self, root... | code_fim | medium | {
"lang": "python",
"repo": "zy-sunshine/magicinstaller2",
"path": "/src/mi/client/modules/network.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> magicstep.magicstep.__init__(self, rootobj, 'network.xml')
def get_label(self):
return _("Network")
def check_ready(self):
return 1<|fim_prefix|># repo: zy-sunshine/magicinstaller2 path: /src/mi/client/modules/network.py
# -*- python -*-
from mi.client.utils import _
f... | code_fim | easy | {
"lang": "python",
"repo": "zy-sunshine/magicinstaller2",
"path": "/src/mi/client/modules/network.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_label(self):
return _("Network")
def check_ready(self):
return 1<|fim_prefix|># repo: zy-sunshine/magicinstaller2 path: /src/mi/client/modules/network.py
# -*- python -*-
from mi.client.utils import _
from mi.client.utils import magicstep
<|fim_middle|>class MIStep_net... | code_fim | medium | {
"lang": "python",
"repo": "zy-sunshine/magicinstaller2",
"path": "/src/mi/client/modules/network.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def save(self, commit=True):
user = super().save(commit=False)
user.username = self.cleaned_data['username']
user.email = self.cleaned_data['email']
user.subject = self.cleaned_data['subject']
user.messages = self.cleaned_data['messages']
if commit:
u... | code_fim | medium | {
"lang": "python",
"repo": "Arosebine/seyitech",
"path": "/seyitechapp/form.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = super().save(commit=False)
user.username = self.cleaned_data['username']
user.email = self.cleaned_data['email']
user.subject = self.cleaned_data['subject']
user.messages = self.cleaned_data['messages']
if commit:
user.save()
return Message... | code_fim | medium | {
"lang": "python",
"repo": "Arosebine/seyitech",
"path": "/seyitechapp/form.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Arosebine/seyitech path: /seyitechapp/form.py
from django import forms
from seyitechapp.models import *
class Msg(forms.ModelForm):
<|fim_suffix|> def save(self, commit=True):
user = super().save(commit=False)
user.username = self.cleaned_data['username']
user.email = self.cle... | code_fim | hard | {
"lang": "python",
"repo": "Arosebine/seyitech",
"path": "/seyitechapp/form.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def parse_beers(beer_list):
beers = []
for item in beer_list:
name = item.find("h3").get_text().strip()
info = item.findAll("p")
style = info[0].get_text().split("—")[0]
abv = info[0].get_text().split("—")[1]
desc = info[1].get_text()
beers.append(B... | code_fim | hard | {
"lang": "python",
"repo": "twbarber/chicago-tap-scraper",
"path": "/cts/taps/dryhop.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return format_html(u'<img src="%s" height="400" width="400"/>' % obj.image_url)
thumbnail.allow_tags = True
admin.site.register(Meme, MemeAdmin)<|fim_prefix|># repo: kpiaskowski/meme_feed path: /memes/admin.py
from django.contrib import admin
# Register your models here.
from django.utils... | code_fim | hard | {
"lang": "python",
"repo": "kpiaskowski/meme_feed",
"path": "/memes/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kpiaskowski/meme_feed path: /memes/admin.py
from django.contrib import admin
# Register your models here.
from django.utils.html import format_html
from .models import Meme
class MemeAdmin(admin.ModelAdmin):
<|fim_suffix|> return format_html(u'<img src="%s" height="400" width="400"/>' ... | code_fim | hard | {
"lang": "python",
"repo": "kpiaskowski/meme_feed",
"path": "/memes/admin.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def thumbnail(self, obj):
return format_html(u'<img src="%s" height="400" width="400"/>' % obj.image_url)
thumbnail.allow_tags = True
admin.site.register(Meme, MemeAdmin)<|fim_prefix|># repo: kpiaskowski/meme_feed path: /memes/admin.py
from django.contrib import admin
# Register your ... | code_fim | hard | {
"lang": "python",
"repo": "kpiaskowski/meme_feed",
"path": "/memes/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j in range(n):
temp=[a[i][j]]
sx , sy = i, j
ans = max(ans, solve(i+dd[0][0], j+dd[0][1], 0, 1))
print('#{} {}'.format(t+1, ans if ans!=0 else -1))<|fim_prefix|># repo: alb7979s/SW_Expert path: /2105_디저트카페.py
def solve(x, y, d, cnt):
res = 0
if d... | code_fim | hard | {
"lang": "python",
"repo": "alb7979s/SW_Expert",
"path": "/2105_디저트카페.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alb7979s/SW_Expert path: /2105_디저트카페.py
def solve(x, y, d, cnt):
res = 0
if d>3: return 0
if scope(x, y): return 0
if x == sx and y==sy: return cnt
if a[x][y] in temp: return 0
else: temp.append(a[x][y])
res = max(res, solve(x+dd[d][0], y+dd[d][1], d, cnt+1), solve(x+d... | code_fim | medium | {
"lang": "python",
"repo": "alb7979s/SW_Expert",
"path": "/2105_디저트카페.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if change[1:3] == '18':
return [-cdir[0],-cdir[1]]
elif change == 'R90' or change == 'L27':
return [cdir[1],-cdir[0]]
elif change == 'L90' or change == 'R27':
return [-cdir[1],cdir[0]]
ship = [0,0]
wp = [10,1]
for l in f.readlines():
if l[0] == 'N':
wp[1] +=... | code_fim | medium | {
"lang": "python",
"repo": "davhofer/AdventOfCode2020",
"path": "/AoC12.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davhofer/AdventOfCode2020 path: /AoC12.py
f = open('input12.txt','r')
pos = [0,0]
dir = [1,0]
def dir_change(cdir, change):
if change[1:3] == '18':
return [-cdir[0],-cdir[1]]
elif change == 'R90' or change == 'L27':
return [cdir[1],-cdir[0]]
elif change == 'L90' or cha... | code_fim | medium | {
"lang": "python",
"repo": "davhofer/AdventOfCode2020",
"path": "/AoC12.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> context['related_cases'] = related_cases
context['center_services'] = center_services
return context<|fim_prefix|># repo: Haykmartirosyan/Marketing-Website-Django path: /Cases/views.py
from django.shortcuts import render
from django.views import generic
from .models import *
from... | code_fim | hard | {
"lang": "python",
"repo": "Haykmartirosyan/Marketing-Website-Django",
"path": "/Cases/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Haykmartirosyan/Marketing-Website-Django path: /Cases/views.py
from django.shortcuts import render
from django.views import generic
from .models import *
from Services.models import ServiceItems
# Create your views here.
class Cases(generic.TemplateView):
template_name = "Cases/index.html"
... | code_fim | hard | {
"lang": "python",
"repo": "Haykmartirosyan/Marketing-Website-Django",
"path": "/Cases/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> center_services = ServiceItems.objects.order_by('-id')[:3]
related_cases = CaseItems.objects.all().order_by('-created')[:3]
context = super(single_case, self).get_context_data(**kwargs)
context['related_cases'] = related_cases
context['center_services'] = center_se... | code_fim | hard | {
"lang": "python",
"repo": "Haykmartirosyan/Marketing-Website-Django",
"path": "/Cases/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VaishnaviReddyGuddeti/Python_programs path: /Python_Modules/ImportFromModule.py
# You can choose to import only parts from a module, by using <|fim_suffix|>and one dictionary:
# Import only the person1 dictionary from the module:
from mymodule import person1
print(person1["age"])<|fim_middle|>t... | code_fim | medium | {
"lang": "python",
"repo": "VaishnaviReddyGuddeti/Python_programs",
"path": "/Python_Modules/ImportFromModule.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.