text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Osso/smartytotwig path: /tests/test_smarty_grammar.py
"""
It's easy to screw up other rules when modifying the underlying grammar.
These unit tests test various smarty statements, to make refactoring the
grammar more sane.
"""
from smartytotwig import parse_string
from smartytotwig.twig_printer i... | code_fim | hard | {
"lang": "python",
"repo": "Osso/smartytotwig",
"path": "/tests/test_smarty_grammar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
"""
:type sentence: str
:rtype: bool
"""<|fim_prefix|># repo: sidmahurkar/Leetcode-Practice path: /Python/easy/1832.py
class Solution(object):
def checkIfPangram(self, sentence):
<|fim_middle|> for i in sentence:
a.append(i)
... | code_fim | medium | {
"lang": "python",
"repo": "sidmahurkar/Leetcode-Practice",
"path": "/Python/easy/1832.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sidmahurkar/Leetcode-Practice path: /Python/easy/1832.py
class Solution(object):
def checkIfPangram(self, sentence):
<|fim_suffix|>
"""
:type sentence: str
:rtype: bool
"""<|fim_middle|>
for i in sentence:
a.append(i)
... | code_fim | medium | {
"lang": "python",
"repo": "sidmahurkar/Leetcode-Practice",
"path": "/Python/easy/1832.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>admin.site.register(Category)
admin.site.register(Ingredient)<|fim_prefix|># repo: Posdelan/graphQL_cookbook path: /cookbook/cookbook/ingredients/admin.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
<|fim_middle|>from django.contrib import admin
from cookbook.ingredients.models impor... | code_fim | medium | {
"lang": "python",
"repo": "Posdelan/graphQL_cookbook",
"path": "/cookbook/cookbook/ingredients/admin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Posdelan/graphQL_cookbook path: /cookbook/cookbook/ingredients/admin.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
<|fim_suffix|>admin.site.register(Category)
admin.site.register(Ingredient)<|fim_middle|>from django.contrib import admin
from cookbook.ingredients.models impor... | code_fim | medium | {
"lang": "python",
"repo": "Posdelan/graphQL_cookbook",
"path": "/cookbook/cookbook/ingredients/admin.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: irk2adm/pythontutor path: /11/11_Pedigree.py
# Задача «Родословная: подсчет уровней»
# В генеалогическом древе у каждого человека, кроме родоначальника, есть ровно один родитель.
# Каждом элементу дерева сопоставляется целое неотрицательное число, называемое высотой. У родоначальника высота равна... | code_fim | medium | {
"lang": "python",
"repo": "irk2adm/pythontutor",
"path": "/11/11_Pedigree.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>heights = {}
for man in set(p_tree.keys()).union(set(p_tree.values())):
heights[man] = height(man)
for key, value in sorted(heights.items()):
print(key, value)<|fim_prefix|># repo: irk2adm/pythontutor path: /11/11_Pedigree.py
# Задача «Родословная: подсчет уровней»
# В генеалогическом древе у к... | code_fim | medium | {
"lang": "python",
"repo": "irk2adm/pythontutor",
"path": "/11/11_Pedigree.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> difference = 0
deliveries_1st = data['innings'][0]['1st innings']['deliveries']
deliveries_2nd = data['innings'][1]['2nd innings']['deliveries']
for d in deliveries_1st:
for k, m in d.items():
if(m.get('extras') != None):
for e in m['extras'].values():
... | code_fim | medium | {
"lang": "python",
"repo": "amrutasawant13/python_getting_started_project",
"path": "/q07_extras/build.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amrutasawant13/python_getting_started_project path: /q07_extras/build.py
# %load q07_extras/build.py
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
# Your Solution
def extras_runs(data):
<|fim_suffix|> difference = 0
deliv... | code_fim | medium | {
"lang": "python",
"repo": "amrutasawant13/python_getting_started_project",
"path": "/q07_extras/build.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> difference = inning2_extras - inning1_extras
return difference
# print(inning1_extras)
# print(inning2_extras)
extras_runs(data)<|fim_prefix|># repo: amrutasawant13/python_getting_started_project path: /q07_extras/build.py
# %load q07_extras/build.py
# Default Imports
from greyatomlib.pyt... | code_fim | hard | {
"lang": "python",
"repo": "amrutasawant13/python_getting_started_project",
"path": "/q07_extras/build.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>total = 0
for i in range(n):
if v[i] > c[i]:
total += (v[i] - c[i])
print(total)<|fim_prefix|># repo: kotaro0522/python path: /procon20190427/b.py
n = int(input())
v = [int(i) for i in input().split()]
<|fim_middle|>c = [int(i) for i in input().split()]
| code_fim | easy | {
"lang": "python",
"repo": "kotaro0522/python",
"path": "/procon20190427/b.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kotaro0522/python path: /procon20190427/b.py
n = int(input())
v = [int(i) for i in input().split()]
<|fim_suffix|>for i in range(n):
if v[i] > c[i]:
total += (v[i] - c[i])
print(total)<|fim_middle|>c = [int(i) for i in input().split()]
total = 0
| code_fim | easy | {
"lang": "python",
"repo": "kotaro0522/python",
"path": "/procon20190427/b.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fjl121029xx/MyPyspark path: /ml/10-lr/lr_roc_auc.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'fjl'
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
import... | code_fim | hard | {
"lang": "python",
"repo": "fjl121029xx/MyPyspark",
"path": "/ml/10-lr/lr_roc_auc.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
column = ['Sample code number', 'Clump Thickness ', 'Uniformity of Cell Size', 'Uniformity of Cell Shape',
'Marginal Adhesion', 'Single Epithelial Cell Size ', 'Bare Nuclei ',
'Bland Chromatin', 'Normal Nucleoli', 'Mitoses', 'Class']
lr = LRR... | code_fim | hard | {
"lang": "python",
"repo": "fjl121029xx/MyPyspark",
"path": "/ml/10-lr/lr_roc_auc.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#3. 훈련
model.fit(x_train, y_train)
#4. 평가, 예측
acc = model.score(x_test, y_test)
print("acc : ", acc)
print("최적의 매개변수 : ", model.best_estimator_)
# acc : 0.9666666666666667
# 최적의 매개변수 : Pipeline(steps=[('scaler', MinMaxScaler()),
# ('XGB',
# XGBClassifier(base_score=0... | code_fim | hard | {
"lang": "python",
"repo": "MJK0211/bit_seoul",
"path": "/ml/m26_homework1_xgb_iris.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MJK0211/bit_seoul path: /ml/m26_homework1_xgb_iris.py
# pipe라인 까지 구성할 것
import numpy as np
import pandas as pd
from sklearn.datasets import load_iris
from xgboost import XGBClassifier, XGBRegressor, plot_importance
from sklearn.datasets import load_boston
from sklearn.model_selection import trai... | code_fim | hard | {
"lang": "python",
"repo": "MJK0211/bit_seoul",
"path": "/ml/m26_homework1_xgb_iris.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#4. 평가, 예측
acc = model.score(x_test, y_test)
print("acc : ", acc)
print("최적의 매개변수 : ", model.best_estimator_)
# acc : 0.9666666666666667
# 최적의 매개변수 : Pipeline(steps=[('scaler', MinMaxScaler()),
# ('XGB',
# XGBClassifier(base_score=0.5, booster='gbtree',
# ... | code_fim | medium | {
"lang": "python",
"repo": "MJK0211/bit_seoul",
"path": "/ml/m26_homework1_xgb_iris.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abtheo/Genetic-Wifi-Optimisation path: /Genetics.py
import Maps
import numpy as np
#CONSTANT DECLARATIONS
SPOTNUM = 20
#Dimensions
TILESIZE = 10
MAPWIDTH = 64
MAPHEIGHT = 64
#Constants representing map resources
NONE = 0
LOW = 1
MED = 2
HIGH = 3
SPOT = 4
WALL = 5
#Class for Wifi hotspots
... | code_fim | hard | {
"lang": "python",
"repo": "abtheo/Genetic-Wifi-Optimisation",
"path": "/Genetics.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Class comprising the population
class iMap:
def __init__(self,tilemap,spotList=None):
if spotList == None:
self.spotList = self.generateSpots(SPOTNUM)
else:
self.spotList = spotList
self.tilemap = np.copy(tilemap)
self.fitness = 0
... | code_fim | hard | {
"lang": "python",
"repo": "abtheo/Genetic-Wifi-Optimisation",
"path": "/Genetics.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chojiwon1727/lab_python path: /lec07_file/file01.py
"""
os 모듈의 변수와 함수들
"""
import os
# CWD: Current Working Directory(현재 작업 디렉토리/폴더)
print(os.getcwd())
print(os.name)
if os.name == 'nt': # windows os인 경우
file_path = '.\\temp\\temp.txt'
else: # windows os가 아닌 경우
file_p... | code_fim | hard | {
"lang": "python",
"repo": "chojiwon1727/lab_python",
"path": "/lec07_file/file01.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>with os.scandir('.') as my_dir:
for entry in my_dir:
print(entry.name, '\t', entry.is_file())
# 파일(디렉토리) 이름 변경
try:
os.rename('temp', 'test')
except FileNotFoundError:
print('temp 폴더가 없음')
try:
os.rmdir('test')
except FileNotFoundError:
print('삭제 권한 없음')
try:
os.mkdir('t... | code_fim | medium | {
"lang": "python",
"repo": "chojiwon1727/lab_python",
"path": "/lec07_file/file01.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
cmdline.execute(['scrapy', 'crawl', 'bizvibe'])<|fim_prefix|># repo: haisimao/workspace path: /Bizvibe_Selenium_scrapy/Bizvibe_scrapy/manage.py
from scrapy import cmdline
<|fim_middle|>cmdline.execute(['scrapy', 'crawl', 'bizvibe'])
| code_fim | easy | {
"lang": "python",
"repo": "haisimao/workspace",
"path": "/Bizvibe_Selenium_scrapy/Bizvibe_scrapy/manage.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: haisimao/workspace path: /Bizvibe_Selenium_scrapy/Bizvibe_scrapy/manage.py
from scrapy import cmdline
<|fim_suffix|>if __name__ == '__main__':
cmdline.execute(['scrapy', 'crawl', 'bizvibe'])<|fim_middle|>cmdline.execute(['scrapy', 'crawl', 'bizvibe'])
| code_fim | easy | {
"lang": "python",
"repo": "haisimao/workspace",
"path": "/Bizvibe_Selenium_scrapy/Bizvibe_scrapy/manage.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangpengxu2020/TasNet path: /main.py
import torch
from torch import nn
# from tensorboardX import SummaryWriter
import time
import os
from MyDataset_HDF5 import MyDataset
from conv_tasnet import ConvTasNet
from conv_tasnet import Encoder
from conv_tasnet import Decoder
# class Custom... | code_fim | hard | {
"lang": "python",
"repo": "wangpengxu2020/TasNet",
"path": "/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> t1 = time.time()
for epoch in range(EPOCH):
for step, (s1, s2, mix) in enumerate(train_loader): # gives batch data
s1 = s1.to(DEVICE)
s2 = s2.to(DEVICE)
mix = mix.to(DEVICE)
out = TasNet(mix) # rnn DRNN
# loss = loss_... | code_fim | hard | {
"lang": "python",
"repo": "wangpengxu2020/TasNet",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Athira-Vijayan/Python path: /strings/search.py
#searching for a sstring in a group of strings
str=[]
n=int(input('How many strings?'))
for i<|fim_suffix|> print('Found at',i+1)
else:
print('Not found')
#if flag==False:
# print('Not found')<|fim_middle|> in range(n):
print('enetr str... | code_fim | medium | {
"lang": "python",
"repo": "Athira-Vijayan/Python",
"path": "/strings/search.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ey to search:')
flag=False
for i in range(len(str)):
if s==str[i]:
flag=True
print('Found at',i+1)
else:
print('Not found')
#if flag==False:
# print('Not found')<|fim_prefix|># repo: Athira-Vijayan/Python path: /strings/search.py
#searching for a sstring in a group of strings
s... | code_fim | medium | {
"lang": "python",
"repo": "Athira-Vijayan/Python",
"path": "/strings/search.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Found at',i+1)
else:
print('Not found')
#if flag==False:
# print('Not found')<|fim_prefix|># repo: Athira-Vijayan/Python path: /strings/search.py
#searching for a sstring in a group of strings
str=[]
n=int(input('How many strings?'))
for i in range(n):
print('enetr string:',end='')
... | code_fim | medium | {
"lang": "python",
"repo": "Athira-Vijayan/Python",
"path": "/strings/search.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Garavirod/Django-DRF-Projects path: /librarydj/librarydj/applications/book/migrations/0004_auto_20201119_2128.py
# Generated by Django 3.1.2 on 2020-11-19 21:28
<|fim_suffix|>
dependencies = [
('book', '0003_auto_20201030_1846'),
]
operations = [
migrations.AlterMode... | code_fim | medium | {
"lang": "python",
"repo": "Garavirod/Django-DRF-Projects",
"path": "/librarydj/librarydj/applications/book/migrations/0004_auto_20201119_2128.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('book', '0003_auto_20201030_1846'),
]
operations = [
migrations.AlterModelOptions(
name='book',
options={'ordering': ['title', 'date'], 'verbose_name': 'Libro', 'verbose_name_plural': 'Libros'},... | code_fim | easy | {
"lang": "python",
"repo": "Garavirod/Django-DRF-Projects",
"path": "/librarydj/librarydj/applications/book/migrations/0004_auto_20201119_2128.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def hitfinder1(rocket, target):
if rocket.ycor() < target.ycor() + 10 and rocket.ycor() > target.ycor() - 10 :
return 1
else:
return 0
def gameloop(lives,level):
while lives>0 and level<4:
update = gamelvl(level)
lives = lives - update
lev... | code_fim | hard | {
"lang": "python",
"repo": "seventhridge/mat2110",
"path": "/2017-Projects/3E-Aquilla-project/failed first project design.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: seventhridge/mat2110 path: /2017-Projects/3E-Aquilla-project/failed first project design.py
import turtle, math
turtle.setup(400,400)
wn=turtle.Screen()
wn.bgcolor("antique white")
rocket =turtle.Turtle()
target= turtle.Turtle()
#def loser():
#def winner():
angle = None
def fn_up(a):
... | code_fim | hard | {
"lang": "python",
"repo": "seventhridge/mat2110",
"path": "/2017-Projects/3E-Aquilla-project/failed first project design.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert '/srv/conda/envs/notebook/etc/dask' in dask.config.paths
assert dask.config.config['labextension']['factory']['class'] == 'KubeCluster'
assert 'worker-template' in dask.config.config['kubernetes']<|fim_prefix|># repo: pangeo-data/pangeo-stacks path: /pangeo-esip/binder/tests/test_dask_... | code_fim | hard | {
"lang": "python",
"repo": "pangeo-data/pangeo-stacks",
"path": "/pangeo-esip/binder/tests/test_dask_env.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> import dask
assert '/srv/conda/envs/notebook/etc/dask' in dask.config.paths
assert dask.config.config['labextension']['factory']['class'] == 'KubeCluster'
assert 'worker-template' in dask.config.config['kubernetes']<|fim_prefix|># repo: pangeo-data/pangeo-stacks path: /pangeo-esip/binder... | code_fim | medium | {
"lang": "python",
"repo": "pangeo-data/pangeo-stacks",
"path": "/pangeo-esip/binder/tests/test_dask_env.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pangeo-data/pangeo-stacks path: /pangeo-esip/binder/tests/test_dask_env.py
import pytest
@pytest.fixture(scope='module')
def client():
from dask.distributed import Client
with Client(n_workers=4) as dask_client:
yield dask_client
def test_check_dask_version(client):
<|fim_suffi... | code_fim | medium | {
"lang": "python",
"repo": "pangeo-data/pangeo-stacks",
"path": "/pangeo-esip/binder/tests/test_dask_env.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/PowerReporter path: /plugins/__init__.py
__author__ = "Tiaonmmn.ZMZ"
__all__ = ['mounting', 'hashFile', 'detectOS', 'timezoneInfo', 'computerName', 'samParse', 'lastLogon', 'startTime',
'shutdownTime', 'netwo<|fim_suffix|>'customShellFolder', 'usbInfo', 'printers', 'miscFil... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/PowerReporter",
"path": "/plugins/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>'customShellFolder', 'usbInfo', 'printers', 'miscFiles', 'remoteLogin', 'defaultBrowser']<|fim_prefix|># repo: pombredanne/PowerReporter path: /plugins/__init__.py
__author__ = "Tiaonmmn.ZMZ"
__all__ = ['mounting', 'hashFile', 'detectOS', 'timezoneInfo'<|fim_middle|>, 'computerName', 'samParse', 'lastLog... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/PowerReporter",
"path": "/plugins/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alex-wenzel/oasis path: /backend/alembic/versions/69b610fddc4b_remove_first_name_and_user_name_from_.py
"""Remove first name and user name from users
Revision ID: 69b610fddc4b
Revises: 91a50206245d
Create Date: 2020-08-08 06:02:19.659170
<|fim_suffix|>def upgrade():
# ### commands auto gene... | code_fim | hard | {
"lang": "python",
"repo": "alex-wenzel/oasis",
"path": "/backend/alembic/versions/69b610fddc4b_remove_first_name_and_user_name_from_.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"users", sa.Column("username", mysql.VARCHAR(length=64), nullable=True)
)
op.add_column(
"users",
sa.Column("first_name", mysql.VARCHAR(length=128), nullable=True),
)
... | code_fim | hard | {
"lang": "python",
"repo": "alex-wenzel/oasis",
"path": "/backend/alembic/versions/69b610fddc4b_remove_first_name_and_user_name_from_.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>c2 = TCanvas("c2", "ratio 2")
c2.Clear()
rp2 = TRatioPlot(h2,h2)
rp2.Draw()
g2 = rp2.GetLowerRefGraph()
g2.SetLineColor(ROOT.kBlue)
g2.SetFillColor(ROOT.kBlue)
#g2.SetFillColorAlpha(ROOT.,0.5)
g2.SetLineWidth(2)
h0.SetTitle("")
h0.GetXaxis().SetTitle("p_{T}^{min} [TeV]")
h0.GetYaxis().SetTitle("#sigma ... | code_fim | hard | {
"lang": "python",
"repo": "selvaggi/PlottingMacros",
"path": "/macros/dijetJesBands.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: selvaggi/PlottingMacros path: /macros/dijetJesBands.py
import ROOT
from ROOT import TFile, TRatioPlot, TCanvas, gPad, TLegend
import numpy as np
import math
from array import array
try:
input = raw_input
except:
pass
def fillTH1errors(h,hup,hdown):
for i in xrange(0,h.GetNbinsX()):
... | code_fim | hard | {
"lang": "python",
"repo": "selvaggi/PlottingMacros",
"path": "/macros/dijetJesBands.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Adhokshajan/CovidTracker path: /CovidTracker/main.py
from tkinter import font
from tkinter.constants import NONE
import requests
import bs4
import tkinter as tk
def get_html_data(url):
data = requests .get(url)
return data
def get_covid_data():
url = "https://www.worl... | code_fim | hard | {
"lang": "python",
"repo": "Adhokshajan/CovidTracker",
"path": "/CovidTracker/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
root = tk.Tk()
root.geometry("900x700")
root.title("Covid Tracker")
f = ("poppins" , 25 , "bold")
banner = tk.PhotoImage(file="image.png")
bannerlabel = tk.Label(root , image=banner)
bannerlabel.pack()
textfield = tk.Entry(root, width = 50 )
textfield.pack()
mainlabel = ... | code_fim | hard | {
"lang": "python",
"repo": "Adhokshajan/CovidTracker",
"path": "/CovidTracker/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>g = T.grad(z, [x])
g_f = function([x], g)
print("Original:", f([[1, 2, 3]]) )
print("Original Gradient:", g_f([[1, 2, 3]]) )<|fim_prefix|># repo: zfy1989lee/MachineLearning path: /05Deep Learning with Python- A Hands-on Introduction/ch4Introduction to Theano/i10gradients.py
import theano.tensor as T
fro... | code_fim | medium | {
"lang": "python",
"repo": "zfy1989lee/MachineLearning",
"path": "/05Deep Learning with Python- A Hands-on Introduction/ch4Introduction to Theano/i10gradients.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zfy1989lee/MachineLearning path: /05Deep Learning with Python- A Hands-on Introduction/ch4Introduction to Theano/i10gradients.py
import theano.tensor as T
from theano import function
from theano import shared
import numpy
x = T.dmatrix('x')
y = shared(numpy.array([[4, 5, 6]]))
z = T.sum(((x * x... | code_fim | easy | {
"lang": "python",
"repo": "zfy1989lee/MachineLearning",
"path": "/05Deep Learning with Python- A Hands-on Introduction/ch4Introduction to Theano/i10gradients.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nandansn/pythonlab path: /durgasoft/chapter47/random-example.py
from random import *
for i in range(10):
print(random())
<|fim_suffix|>for i in range(10):
print(uniform(i,10)) #generate the float value, within the range. not inclusive of start and end values.
for i in range(10)... | code_fim | medium | {
"lang": "python",
"repo": "nandansn/pythonlab",
"path": "/durgasoft/chapter47/random-example.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(10):
print(uniform(i,10)) #generate the float value, within the range. not inclusive of start and end values.
for i in range(10):
print('random numbers')
print(randrange(1,11,3)) # generate the random number with step value<|fim_prefix|># repo: nandansn/pythonlab path: /d... | code_fim | medium | {
"lang": "python",
"repo": "nandansn/pythonlab",
"path": "/durgasoft/chapter47/random-example.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def neighbor(network,
geometry,
throat_prop='',
mode='min',
**kwargs):
r"""
Adopt the minimum seed value from the neighboring throats
"""
Ps = geometry.pores()
data = geometry[throat_prop]
neighborTs = network.find_neighbor_throat... | code_fim | hard | {
"lang": "python",
"repo": "gitter-badger/OpenPNM",
"path": "/OpenPNM/Geometry/models/pore_misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def random(geometry,
seed=None,
num_range=[0,1],
**kwargs):
r"""
Assign random number to pore bodies
note: should this be called 'poisson'?
"""
range_size = num_range[1]-num_range[0]
range_min = num_range[0]
_sp.random.seed(seed)
value = _... | code_fim | hard | {
"lang": "python",
"repo": "gitter-badger/OpenPNM",
"path": "/OpenPNM/Geometry/models/pore_misc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gitter-badger/OpenPNM path: /OpenPNM/Geometry/models/pore_misc.py
r"""
===============================================================================
pore_misc -- miscillaneous and generic functions to apply to pores
===============================================================================... | code_fim | hard | {
"lang": "python",
"repo": "gitter-badger/OpenPNM",
"path": "/OpenPNM/Geometry/models/pore_misc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SemaMolchanov/self_study path: /Algorithms and Data Structures/Algorithms/Sorting Algorithms/selection_sort.py
def find_smallest(arr):
smallest_element = arr[0]
smallest_index = 0
for i in range(1, len(arr)):
if arr[i] < smallest:
smallest = arr[i]
s... | code_fim | medium | {
"lang": "python",
"repo": "SemaMolchanov/self_study",
"path": "/Algorithms and Data Structures/Algorithms/Sorting Algorithms/selection_sort.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>numbers = list(map(int, input().split()))
print(selection_sort(numbers))<|fim_prefix|># repo: SemaMolchanov/self_study path: /Algorithms and Data Structures/Algorithms/Sorting Algorithms/selection_sort.py
def find_smallest(arr):
smallest_element = arr[0]
smallest_index = 0
for i in range(... | code_fim | medium | {
"lang": "python",
"repo": "SemaMolchanov/self_study",
"path": "/Algorithms and Data Structures/Algorithms/Sorting Algorithms/selection_sort.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sorted_arr = []
for i in range(len(arr)):
smallest = find_smallest(arr)
sorted_arr.append(arr.pop(smallest))
return sorted_arr
numbers = list(map(int, input().split()))
print(selection_sort(numbers))<|fim_prefix|># repo: SemaMolchanov/self_study path: /Algorithms and Data St... | code_fim | easy | {
"lang": "python",
"repo": "SemaMolchanov/self_study",
"path": "/Algorithms and Data Structures/Algorithms/Sorting Algorithms/selection_sort.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asiqurrahman/Trading-Web path: /users/migrations/0002_profile_title2.py
# Generated by Django 3.1.5 on 2021-03-14 16:41
from django.db import migrations, models
import django.utils.timezone
<|fim_suffix|> dependencies = [
('users', '0001_initial'),
]
operations = [
... | code_fim | easy | {
"lang": "python",
"repo": "asiqurrahman/Trading-Web",
"path": "/users/migrations/0002_profile_title2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('users', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='profile',
name='title2',
field=models.CharField(default=django.utils.timezone.now, max_length=100),
),
]<|fim_prefix|># repo: asiqurrah... | code_fim | easy | {
"lang": "python",
"repo": "asiqurrahman/Trading-Web",
"path": "/users/migrations/0002_profile_title2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.after_request
def add_header(response):
response.cache_control.max_age = 31536000
if 'service-worker.js' in request.path:
response.cache_control.max_age = 0
return response
@app.route('/', methods=["GET"])
def get_home():
# needs the index to be in the dist folder to work
... | code_fim | hard | {
"lang": "python",
"repo": "jzlotek/drexel-tms-parser",
"path": "/src/webapp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return response
@app.route('/', methods=["GET"])
def get_home():
# needs the index to be in the dist folder to work
return send_from_directory('../dist', 'index.html')
@app.route('/static/<path:path>', methods=["GET"])
def get_file_static(path):
# needs the index to be in the dist folder... | code_fim | hard | {
"lang": "python",
"repo": "jzlotek/drexel-tms-parser",
"path": "/src/webapp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if not os.path.exists(load_results_dir):
os.makedirs(load_results_dir)
#Fixed random seeds.
rng = np.random.RandomState(args.seed)
theano_rng = MRG_RandomStreams(rng.randint(2 ** 15))
lasagne.random.set_rng(np.random.RandomState(rng.randint(2 ** 15)))
#Load Terraria dataset.
if tdg_train:
print... | code_fim | hard | {
"lang": "python",
"repo": "samanthastahlke/terraria-deligan",
"path": "/SpriteGAN/dg_terraria.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, p in enumerate(gen_params):
p.set_value(param_dict[fepoch][i])
print("Loaded generator parameters.")
noise = theano_rng.normal(size=noise_dim)
sample_input = th.tensor.zeros(noise_dim)
print("Setting up sampling...")
gen_layers[0].input... | code_fim | hard | {
"lang": "python",
"repo": "samanthastahlke/terraria-deligan",
"path": "/SpriteGAN/dg_terraria.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samanthastahlke/terraria-deligan path: /SpriteGAN/dg_terraria.py
# DeLiGAN implementation for the Terraria dataset.
# Based heavily on the code from Gurumurthy, Sarvadevabhatla, and Babu (2017).
import argparse
import time
import numpy as np
import theano as th
import theano.tensor as T
from the... | code_fim | hard | {
"lang": "python",
"repo": "samanthastahlke/terraria-deligan",
"path": "/SpriteGAN/dg_terraria.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ymean[i] = np.mean(y)
Ynorm[i, idx] = y - Ymean[i]
return Ynorm, Ymean<|fim_prefix|># repo: junwon1994/Coursera-ML path: /ex8/normalizeRatings.py
import numpy as np
def normalizeRatings(Y, R):
<|fim_middle|> """normalized Y so that each movie has a rating of 0 on average,
an... | code_fim | hard | {
"lang": "python",
"repo": "junwon1994/Coursera-ML",
"path": "/ex8/normalizeRatings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jyotirm0y/kattis path: /imageprocessing.py
h, w, n, m = map(int, input().split())
image = []
for _ in range(h):
image.append(list(map(int, input().split())))
<|fim_suffix|>r = [[0 for i in range(w-m+1)] for j in range(h-n+1)]
for j in range(h-n+1):
for i in range(w-m+1):
for y i... | code_fim | medium | {
"lang": "python",
"repo": "Jyotirm0y/kattis",
"path": "/imageprocessing.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>r = [[0 for i in range(w-m+1)] for j in range(h-n+1)]
for j in range(h-n+1):
for i in range(w-m+1):
for y in range(n):
for x in range(m):
r[j][i] += image[j+y][i+x] * kernel[y][x]
for row in r:
print(' '.join([str(x) for x in row]))<|fim_prefix|># repo: Jyotirm... | code_fim | medium | {
"lang": "python",
"repo": "Jyotirm0y/kattis",
"path": "/imageprocessing.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(self.data)
s1=Stack([3])
s1.push([4])
s1.printStack()
s1.push([6,7])
s1.printStack()
print(s1.pop())
s1.printStack()
'''
append adds its argument as a single element to the end of a list.
The length of the list itself will increase by one.
extend iterates over its argument adding each elem... | code_fim | medium | {
"lang": "python",
"repo": "mike03052000/python",
"path": "/Training/HackRank/Level-1/Stack-1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mike03052000/python path: /Training/HackRank/Level-1/Stack-1.py
class Stack():
def __init__(self,n):
self.data=[]
self.data.extend(n)
def pop(self):
return self.data.pop()
<|fim_suffix|># Extends list by appending elements from the iterable.
x = [1, 2, 3]
x.exte... | code_fim | hard | {
"lang": "python",
"repo": "mike03052000/python",
"path": "/Training/HackRank/Level-1/Stack-1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: feieryouyiji/subject_share path: /subject_orm/curd.py
async def execute(sql, args, autocommit=True):
log(sql)
global __pool
with (await __pool) as conn:
if not autocommit:<|fim_suffix|>s)
affect = cur.rowcount
await cur.close()
if not auto... | code_fim | hard | {
"lang": "python",
"repo": "feieryouyiji/subject_share",
"path": "/subject_orm/curd.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> except BaseException as e:
if not autocommit:
await conn.rollback()
raise e
return affect<|fim_prefix|># repo: feieryouyiji/subject_share path: /subject_orm/curd.py
async def execute(sql, args, autocommit=True):
log(sql)
global __pool
with ... | code_fim | hard | {
"lang": "python",
"repo": "feieryouyiji/subject_share",
"path": "/subject_orm/curd.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oskarkk/minecraft-tg path: /users.py
filename = 'data/users.csv'
def get():
try:
with open(filename, 'r+') as f:
# remove newlines just in case
x = f.read().replace('\n', '')
# if empty file return empty list,
# not list with an empty ... | code_fim | hard | {
"lang": "python",
"repo": "oskarkk/minecraft-tg",
"path": "/users.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def remove(id):
id = str(id)
id_list = get()
# do antyhing only if user is on the list
if id in id_list:
id_list.remove(id)
save(id_list)<|fim_prefix|># repo: oskarkk/minecraft-tg path: /users.py
filename = 'data/users.csv'
def get():
try:
with open(filename,... | code_fim | medium | {
"lang": "python",
"repo": "oskarkk/minecraft-tg",
"path": "/users.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> baseline, follow_up = load((bl[number], fu[number]))
mask, affine = load_mask(la[number])
baseline = central_crop(baseline)
follow_up = central_crop(follow_up)
mask = central_crop(mask)
my_model = gessert_net(fusion_type='stack')
lr_schedule = tf.keras.optimizers.schedules.Ex... | code_fim | hard | {
"lang": "python",
"repo": "vganapati/New_lesion_segmentation_MS",
"path": "/results.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vganapati/New_lesion_segmentation_MS path: /results.py
import pickle
import os
import numpy as np
import matplotlib.pyplot as plt
from itertools import islice
from matplotlib.ticker import MaxNLocator
from model import gessert_net
from preprocess import show_slices, get_filenames
import nibabel a... | code_fim | hard | {
"lang": "python",
"repo": "vganapati/New_lesion_segmentation_MS",
"path": "/results.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def run(self):
# Initialize networktables
team = ""
while team == "":
team = input("Enter team number or 'sim': ")
if team == "sim":
NetworkTables.initialize(server="localhost")
else:
NetworkTables.startClientTeam(int(team))... | code_fim | hard | {
"lang": "python",
"repo": "Oblarg/robot-characterization",
"path": "/arm-characterization/data_logger.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Use listeners to receive the data
NetworkTables.addConnectionListener(
self.connectionListener, immediateNotify=True
)
NetworkTables.addEntryListener(self.valueChanged)
# Wait for a connection notification, then continue on the path
print("Wai... | code_fim | hard | {
"lang": "python",
"repo": "Oblarg/robot-characterization",
"path": "/arm-characterization/data_logger.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Oblarg/robot-characterization path: /arm-characterization/data_logger.py
#!/usr/bin/env python3
#
# Adapted from the pynetworktables json_logger example program
#
# While this is designed to work with the robot.py example in this directory,
# because the transport uses NetworkTables you can use i... | code_fim | hard | {
"lang": "python",
"repo": "Oblarg/robot-characterization",
"path": "/arm-characterization/data_logger.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: moff4/KFrame path: /kframe/plugins/cache.py
#!/usr/bin/env python3
import time
import json
from threading import Thread
from ..base.plugin import Plugin
class Cache(Plugin):
"""
kwargs:
auto_clean_in_new_thread - if True -> create new thread
timeout - inter... | code_fim | hard | {
"lang": "python",
"repo": "moff4/KFrame",
"path": "/kframe/plugins/cache.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def clean(self, nodename: str) -> int:
"""
delete old rows from node
return number of deleted rows
"""
if nodename not in self._d:
return 0
k = len(self._d[nodename])
_time = time.time()
for key in list(self._d[nodenam... | code_fim | hard | {
"lang": "python",
"repo": "moff4/KFrame",
"path": "/kframe/plugins/cache.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chicagomegagames/my_kind_of_town_scripts path: /distributions.py
from collections import OrderedDict
import random
# height and weight numbers derived from (with minor changes)
# https://www2.census.gov/library/publications/2010/compendia/statab/130ed/tables/11s0205.pdf
male_heights = OrderedDi... | code_fim | hard | {
"lang": "python",
"repo": "chicagomegagames/my_kind_of_town_scripts",
"path": "/distributions.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(0, len(reversed_keys) - 1):
a = reversed_keys[i]
b = reversed_keys[i + 1]
percent = int(data[a] * 10) - int(data[b] * 10)
for j in range(0, percent):
sample.append(a)
return sample
male_height_samples = create_sample(male_heights)
male... | code_fim | hard | {
"lang": "python",
"repo": "chicagomegagames/my_kind_of_town_scripts",
"path": "/distributions.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jokel64/parcelcopter path: /ref_codes/object_det_color_server.py
#! /usr/bin/env python2
import rospy
import numpy as np
import cv2
from sub_topics.sub_zed_image_color import ZED_Image_Color
from sub_topics.sub_zed_depth_image import ZED_Depth_Image
from sub_topics.sub_zed_point_cloud import Z... | code_fim | hard | {
"lang": "python",
"repo": "Jokel64/parcelcopter",
"path": "/ref_codes/object_det_color_server.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def srv_callback(self, request):
# call to cal the pix positin
self.object_detection()
# response of the server
response = ObjectLocationResponse()
# string loc_type
# ---
# bool success
# float64 distance
# object_det_srv_msg/P... | code_fim | hard | {
"lang": "python",
"repo": "Jokel64/parcelcopter",
"path": "/ref_codes/object_det_color_server.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jsaric/quiz-manager path: /gui/windows/overview_window.py
from PyQt5.QtWidgets import QMainWindow, QTableView, QHeaderView
from models.league_results_model import LeagueResultsModel
<|fim_suffix|> super(LeagueOverviewWindow, self).__init__(parent)
self.resize(900, 600)
sel... | code_fim | medium | {
"lang": "python",
"repo": "jsaric/quiz-manager",
"path": "/gui/windows/overview_window.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(LeagueOverviewWindow, self).__init__(parent)
self.resize(900, 600)
self.table_view = QTableView()
self.table_view.setModel(LeagueResultsModel(league))
self.setCentralWidget(self.table_view)
self.table_view.resizeColumnsToContents()
self.table_v... | code_fim | medium | {
"lang": "python",
"repo": "jsaric/quiz-manager",
"path": "/gui/windows/overview_window.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sebbacon/PublicMail path: /mail/management/commands/sample.py
import os
from django.core.management.base import BaseCommand
from django.core.management.base import CommandError
from django.db import transaction
class Command(BaseCommand):
def handle(self, *args, **options):
<|fim_suffix|> ... | code_fim | medium | {
"lang": "python",
"repo": "sebbacon/PublicMail",
"path": "/mail/management/commands/sample.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> transaction.enter_transaction_management()
transaction.managed(True)
transaction.commit()<|fim_prefix|># repo: sebbacon/PublicMail path: /mail/management/commands/sample.py
import os
from django.core.management.base import BaseCommand
from django.core.management.base import Comma... | code_fim | hard | {
"lang": "python",
"repo": "sebbacon/PublicMail",
"path": "/mail/management/commands/sample.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not args or (args and args[0] not in ('load')):
raise CommandError("USAGE: ./manage.py %s load" % \
os.path.basename(__file__).split('.')[0])
transaction.enter_transaction_management()
transaction.managed(True)
transaction.commit()<|fim_p... | code_fim | medium | {
"lang": "python",
"repo": "sebbacon/PublicMail",
"path": "/mail/management/commands/sample.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diazona/Modulo path: /modulo/actions/__init__.py
alue> is a
deterministic function of the argument. It returns True from handles(req) for all
requests, but if its constituent class (the parameter given in cls) doesn't actually
handle the request, attempting to create an instance of Op... | code_fim | hard | {
"lang": "python",
"repo": "diazona/Modulo",
"path": "/modulo/actions/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diazona/Modulo path: /modulo/actions/__init__.py
ass(cls, Action):
return NotImplemented
elif cls.__name__.startswith('OptAction'):
return cls
else:
return type('OptAction_%s' % hash_iterable([cls]), (OptAction,), {'handler_class': cls})
class ActionMetaclass(type... | code_fim | hard | {
"lang": "python",
"repo": "diazona/Modulo",
"path": "/modulo/actions/__init__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def derive(cls, <property1>, <property2>, ..., **kwargs):
return super(<class>, cls).derive(<property1>=<property1>, <property2>=<property2>, ..., **kwargs)
Just replace ``property1``, ``property2``, etc. in all three spots with the name of
each property, and `... | code_fim | hard | {
"lang": "python",
"repo": "diazona/Modulo",
"path": "/modulo/actions/__init__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ruhee/advent-of-code-2017 path: /06/run.py
#! /usr/bin/python
import csv
from itertools import cycle, islice
with open('input.tsv', 'r') as tsvfile:
reader = csv.reader(tsvfile, delimiter='\t')
for row in reader:
row = [int(item) for item in row]
results = []
current_item = 0
... | code_fim | hard | {
"lang": "python",
"repo": "ruhee/advent-of-code-2017",
"path": "/06/run.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, v in islice(cycle(enumerate(current_list, current_item+1)), current_value):
index_to_modify = i
if i > (len(current_list) - 1):
index_to_modify = i - len(current_list)
current_list[index_to_modify] += 1
results.append(list(current_list))
num_of_... | code_fim | hard | {
"lang": "python",
"repo": "ruhee/advent-of-code-2017",
"path": "/06/run.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key
"""
idx = key % 1000
if not self.map[idx]:
return -1
else:
curr = self.map[idx]
while curr:
if c... | code_fim | hard | {
"lang": "python",
"repo": "akauntotesuto888/Leetcode-Lintcode-Python",
"path": "/706.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def remove(self, key: int) -> None:
"""
Removes the mapping of the specified value key if this map contains a mapping for the key
"""
idx = key % 1000
if not self.map[idx]:
return
elif self.map[idx].key == key:
self.map[idx] = sel... | code_fim | hard | {
"lang": "python",
"repo": "akauntotesuto888/Leetcode-Lintcode-Python",
"path": "/706.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akauntotesuto888/Leetcode-Lintcode-Python path: /706.py
class Node:
def __init__(self, key, val):
self.key = key
self.val = val
self.next = None
class MyHashMap:
def __init__(self):
"""
Initialize your data structure here.
"""
sel... | code_fim | hard | {
"lang": "python",
"repo": "akauntotesuto888/Leetcode-Lintcode-Python",
"path": "/706.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
n1, k1 = map(int, input().split())
lst1 = list(map(int, input().split()))
print(*trees_interval(n1, k1, lst1))<|fim_prefix|># repo: darioradio1man/yandex_training path: /lesson5/cut_trees.py
from collections import *
def trees_interval(n, k, lst):
left = 0
segments = Counter()
best_resolut... | code_fim | hard | {
"lang": "python",
"repo": "darioradio1man/yandex_training",
"path": "/lesson5/cut_trees.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: darioradio1man/yandex_training path: /lesson5/cut_trees.py
from collections import *
def trees_interval(n, k, lst):
left = 0
segments = Counter()
best_resolutions = [0, n]
<|fim_suffix|>
n1, k1 = map(int, input().split())
lst1 = list(map(int, input().split()))
print(*trees_interval... | code_fim | hard | {
"lang": "python",
"repo": "darioradio1man/yandex_training",
"path": "/lesson5/cut_trees.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>n1, k1 = map(int, input().split())
lst1 = list(map(int, input().split()))
print(*trees_interval(n1, k1, lst1))<|fim_prefix|># repo: darioradio1man/yandex_training path: /lesson5/cut_trees.py
from collections import *
def trees_interval(n, k, lst):
left = 0
segments = Counter()
best_resoluti... | code_fim | hard | {
"lang": "python",
"repo": "darioradio1man/yandex_training",
"path": "/lesson5/cut_trees.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ('item_group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests', to='item.ItemGroup')),
('requested_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='requests', to=settings.AUTH_USER_MODEL)),
('req... | code_fim | hard | {
"lang": "python",
"repo": "VikasKumarRoy/Inventory-Manager-API",
"path": "/item/migrations/0001_initial.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VikasKumarRoy/Inventory-Manager-API path: /item/migrations/0001_initial.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2020-03-13 05:55
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
... | code_fim | hard | {
"lang": "python",
"repo": "VikasKumarRoy/Inventory-Manager-API",
"path": "/item/migrations/0001_initial.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JMLizano/AOC2019 path: /day10/part1.py
import math
from collections import namedtuple, defaultdict
from heapq import heappush, heappop
from typing import Generator, Tuple, List, Set
_INPUT_FILE = 'input.txt'
Point = namedtuple('Point', ['x', 'y'])
def read_input(input_file: str) -> Generator... | code_fim | hard | {
"lang": "python",
"repo": "JMLizano/AOC2019",
"path": "/day10/part1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
asteroids = list(read_input(input_file=_INPUT_FILE))
angles = {ast: compute_visibility_angles(ast, asteroids) for ast in asteroids}
space_station_location = max(angles.items(), key=lambda x: len(x[1]))
print(f"Best position for space station location: {space_stat... | code_fim | medium | {
"lang": "python",
"repo": "JMLizano/AOC2019",
"path": "/day10/part1.py",
"mode": "spm",
"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.