text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """
更新 details 表
:return:
"""
cursor = None
conn = None
try:
li = get_city_details()
print(f"{time.asctime()}开始更新历史数据")
conn, cursor = get_conn()
# update_sql = "update country_details set update_time=%s,confirm=%s,confirm_add=%s,dead=%s,heal=%s,... | code_fim | hard | {
"lang": "python",
"repo": "tangyiyong/cov-19",
"path": "/后端/updata.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tangyiyong/cov-19 path: /后端/updata.py
# coding: utf-8
# Author:南岛鹋
# Blog: www.ndmiao.cn
# Date :2021/2/27 21:09
# Tool :PyCharm
import sys
import pymysql
import time
import json
import traceback #追踪异常
import requests
def get_conn():
"""
:return: 连接,游标
"""
# 创建连接
conn = py... | code_fim | hard | {
"lang": "python",
"repo": "tangyiyong/cov-19",
"path": "/后端/updata.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('{0:d}:{1:d}:{2:d}'.format(horas, minutos, n))<|fim_prefix|># repo: quatroka/urionlinejudge path: /iniciante/python/1019.py
# -*- coding: utf-8 -*-
<|fim_middle|>n = int(input())
horas = n // 3600
n %= 3600
minutos = n // 60
n %= 60
| code_fim | medium | {
"lang": "python",
"repo": "quatroka/urionlinejudge",
"path": "/iniciante/python/1019.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quatroka/urionlinejudge path: /iniciante/python/1019.py
# -*- coding: utf-8 -*-
<|fim_suffix|>print('{0:d}:{1:d}:{2:d}'.format(horas, minutos, n))<|fim_middle|>n = int(input())
horas = n // 3600
n %= 3600
minutos = n // 60
n %= 60
| code_fim | medium | {
"lang": "python",
"repo": "quatroka/urionlinejudge",
"path": "/iniciante/python/1019.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(size):
for p in range(size):
if i==p:
A[i][p]+=hyp #Lambda is addded to diagonals
B=np.dot(des_mat.T,y)
W=np.linalg.solve(A,B)
#Setting X1 and X2 values for 3-D graph plotting
X1=np.linspace(-18,18,200)
X2=np.linspace(-18,18,200)
X1,X2 = np.meshgrid(X1,X2)
fx=[]
... | code_fim | hard | {
"lang": "python",
"repo": "ranjith1604/PRML-Assigns",
"path": "/Assignment 1/Task 2/assign1_reg.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> des_mat=np.empty((size,int(((power+2)*(power+1))/2)))
hyp=1 #Hyperparameter lambda
for i in range(size):
ct=0
for p in range(power+1):
tp=p
while tp>=0:
des_mat[i][ct]=(x1[i]**tp)*(x2[i]**(p-tp)) #Constructing the design matrix
tp=tp-1
ct=ct+1
#Obtaining the W Matrix
A=np.... | code_fim | hard | {
"lang": "python",
"repo": "ranjith1604/PRML-Assigns",
"path": "/Assignment 1/Task 2/assign1_reg.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ranjith1604/PRML-Assigns path: /Assignment 1/Task 2/assign1_reg.py
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
def calci(X1,X2,W,power): #function to find the output for an input
ct=0
val=0
for p in range(power+1):
tp=p
while tp>=0:
val=val+W[ct]*(X1**tp)*... | code_fim | hard | {
"lang": "python",
"repo": "ranjith1604/PRML-Assigns",
"path": "/Assignment 1/Task 2/assign1_reg.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
app = QApplication(sys.argv)
currentModule = sys.modules[__name__]
ltrEditor = ltr_properties.LtrEditor("data", currentModule, serializerIndent=4)
ltrEditor.addCustomEditorMapping(Color, ltr_properties.EditorColor)
ltrEditor.addCustomEditorMapping(Vector, l... | code_fim | hard | {
"lang": "python",
"repo": "LtRandolph/ltr_properties",
"path": "/example/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: email-beacon/SimpleAppEngineApp path: /main.py
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | code_fim | hard | {
"lang": "python",
"repo": "email-beacon/SimpleAppEngineApp",
"path": "/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Display existing guestbook entries and a form to add new entries.
if (os.getenv('SERVER_SOFTWARE') and
os.getenv('SERVER_SOFTWARE').startswith('Google App Engine/')):
db = MySQLdb.connect(unix_socket='/cloudsql/' + _INSTANCE_NAME, db='simplegaeapp', user='root')
... | code_fim | hard | {
"lang": "python",
"repo": "email-beacon/SimpleAppEngineApp",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cursor = db.cursor()
user_request = UserRequest(self.request.get("api_key"), self.request.get("user_id"),
self.request.get("encoded_user_email"))
# Not required
user_request.beacon_id = self.request.get("beacon_id")
user_request.g... | code_fim | hard | {
"lang": "python",
"repo": "email-beacon/SimpleAppEngineApp",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Godsmith/adventofcode2017 path: /day8.py
from util import input_rows
def largest_value(instructions):
largest_ever = 0
for name in register_names(instructions):
locals()[name] = 0
for instruction in instructions:
exec(translate(instruction))
largest_ever = ma... | code_fim | medium | {
"lang": "python",
"repo": "Godsmith/adventofcode2017",
"path": "/day8.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def register_names(instructions):
return {instruction.split()[0] for instruction in instructions}
def translate(instruction):
instruction = instruction.replace('inc', '+=').replace('dec', '-=')
left, right = instruction.split(' if ')
return f'if {right}: {left}'
if __name__ == '__main... | code_fim | medium | {
"lang": "python",
"repo": "Godsmith/adventofcode2017",
"path": "/day8.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HanPong/PythonPractise path: /SimpleGUI.py
from tkinter import *
window=Tk()#创建一个窗口
label<|fim_suffix|>pack()#把标签放进窗口中
button.pack()
window.mainloop()<|fim_middle|>=Label(window,text="Welcome to Python")#创建一个标签,小构建类
button=Button(window,text="Click me")
label. | code_fim | medium | {
"lang": "python",
"repo": "HanPong/PythonPractise",
"path": "/SimpleGUI.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>构建类
button=Button(window,text="Click me")
label.pack()#把标签放进窗口中
button.pack()
window.mainloop()<|fim_prefix|># repo: HanPong/PythonPractise path: /SimpleGUI.py
from tkinter import *
window=Tk()#创建一个窗口
label<|fim_middle|>=Label(window,text="Welcome to Python")#创建一个标签,小 | code_fim | easy | {
"lang": "python",
"repo": "HanPong/PythonPractise",
"path": "/SimpleGUI.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> heal = randrange(5)
if heal == 4:
hero.health -= self.power
self.health += self.power
print(f"{self} does {self.power} damage to you and healed for 2!")
elif heal != 4:
hero.health -= self.power
print(f"{self} does {self.p... | code_fim | medium | {
"lang": "python",
"repo": "jtessensohn/python-rpg-project",
"path": "/medic.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def attack(self, hero):
heal = randrange(5)
if heal == 4:
hero.health -= self.power
self.health += self.power
print(f"{self} does {self.power} damage to you and healed for 2!")
elif heal != 4:
hero.health -= self.power
... | code_fim | medium | {
"lang": "python",
"repo": "jtessensohn/python-rpg-project",
"path": "/medic.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jtessensohn/python-rpg-project path: /medic.py
from random import randrange
from character import Character
class Medic(Character):
def __init__(self, level = 1, health = 10, power = 2):
<|fim_suffix|> def attack(self, hero):
heal = randrange(5)
if heal == 4:
h... | code_fim | medium | {
"lang": "python",
"repo": "jtessensohn/python-rpg-project",
"path": "/medic.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> segment = ['X', 'O', -1]
self.assertFalse(self.Play.all_equals(segment), test_all_equals)
segment = ['X', 'O', 'O']
self.assertFalse(self.Play.all_equals(segment), test_all_equals)
segment = ['O', 'O', -1]
self.assertFalse(self.Play.all_equals(segment), te... | code_fim | hard | {
"lang": "python",
"repo": "zilohumberto/Tic-Tac-Toe",
"path": "/backend/tests/test_utils.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> segment = ['X', 'O', 'O']
self.assertFalse(self.Play.all_equals(segment), test_all_equals)
segment = ['O', 'O', -1]
self.assertFalse(self.Play.all_equals(segment), test_all_equals)
segment = ['X', 'X', -1]
self.assertFalse(self.Play.all_equals(segment), te... | code_fim | hard | {
"lang": "python",
"repo": "zilohumberto/Tic-Tac-Toe",
"path": "/backend/tests/test_utils.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zilohumberto/Tic-Tac-Toe path: /backend/tests/test_utils.py
import unittest
from backend import utils
from backend.messages import (
test_clean_positions,
test_all_equals,
test_get_segments,
)
class UtilsTest(unittest.TestCase):
def __init__(self, methodName='runTest'):
... | code_fim | hard | {
"lang": "python",
"repo": "zilohumberto/Tic-Tac-Toe",
"path": "/backend/tests/test_utils.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kdsian/CarND-P1-LaneLines path: /P1.py
#importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from scipy import stats
<|fim_suffix|>plt.imsave("test-after.png", image)
#plt.savefig('test-after.png')
#mpimg.imsave('test_images/line... | code_fim | hard | {
"lang": "python",
"repo": "kdsian/CarND-P1-LaneLines",
"path": "/P1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>plt.imsave("test-after.png", image)
#plt.savefig('test-after.png')
#mpimg.imsave('test_images/lines-', line_image)<|fim_prefix|># repo: kdsian/CarND-P1-LaneLines path: /P1.py
#importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
from scipy ... | code_fim | hard | {
"lang": "python",
"repo": "kdsian/CarND-P1-LaneLines",
"path": "/P1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>df = pd.read_csv(r'https://archive.ics.uci.edu/ml/machine-learning-databases/00479/' +
r'SomervilleHappinessSurvey2015.csv',
encoding="'UTF-16'")
df = df.rename(columns={'D':'happy', 'X1':'info', 'X2':'housing', 'X3':'schools',
'X4':'police'... | code_fim | medium | {
"lang": "python",
"repo": "DavidSmolinski/portfolio",
"path": "/websites/msh/ratings/make_model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DavidSmolinski/portfolio path: /websites/msh/ratings/make_model.py
# This makes the model pickle file for making predictions. I ran this here to
# use the project's sklearn version and avoid this error:
# "ValueError: Buffer dtype mismatch, expected 'ITYPE_t' but got 'long long'"
# I used a ... | code_fim | medium | {
"lang": "python",
"repo": "DavidSmolinski/portfolio",
"path": "/websites/msh/ratings/make_model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Declare the existence of sub-parsers.
subparsers = parser.add_subparsers(
title="sub-commands",
description="valid cellbender commands",
dest="tool")
for tool_name in TOOL_NAME_LIST:
module_argparse_str_list = ["cellbender", tool_name.replace("-", "_"), "argp... | code_fim | hard | {
"lang": "python",
"repo": "Elhl93/CellBender",
"path": "/cellbender/base_cli.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
"""Parse command-line arguments and run specified tool.
Note: Does not take explicit input arguments, but uses sys.argv inputs
from the command line.
"""
parser = get_populated_argparser()
cli_dict = generate_cli_dictionary()
# Parse arguments.
if len(sys.ar... | code_fim | hard | {
"lang": "python",
"repo": "Elhl93/CellBender",
"path": "/cellbender/base_cli.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Elhl93/CellBender path: /cellbender/base_cli.py
"""Command-line tool functionality.
Parses arguments and determines which tool should be called.
"""
import sys
import argparse
from abc import ABC, abstractmethod
from typing import Dict
import importlib
# New tools should be added to this lis... | code_fim | hard | {
"lang": "python",
"repo": "Elhl93/CellBender",
"path": "/cellbender/base_cli.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test1():
start = datetime.time(hour=1, minute=30)
end = datetime.time(hour=4, minute=45)
time_now = datetime.datetime.combine(date, zero_time)
curr_date = time_now
for x in range(sheet1.max_row):
insert_hours(start, end, curr_date, sheet1)
curr_date += datetime.timedelta(days=1)
de... | code_fim | hard | {
"lang": "python",
"repo": "rodriguez/work-shift-scheduler",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rodriguez/work-shift-scheduler path: /main.py
import datetime
from functions import *
zero_time = datetime.time(hour=0, minute=0, second=0)
filename = 'init.xlsx'
# filename = 'new-init.xlsx'
workbook = op.load_workbook(filename)
sheet1 = workbook.active
<|fim_suffix|> date = date_parser()
... | code_fim | hard | {
"lang": "python",
"repo": "rodriguez/work-shift-scheduler",
"path": "/main.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> date = date_parser()
if date == False:
return False
time = time_parser()
if time == False:
return False
initialize(sheet1)
log_hours(date, time)
# main1()
test1()
# print_sheet(sheet1)
workbook.save('new-' + filename)
# workbook.save(filename)
workbook.close()<|fim_prefix|># repo: r... | code_fim | hard | {
"lang": "python",
"repo": "rodriguez/work-shift-scheduler",
"path": "/main.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> After pull command executed, tool will return one Report instance.
If there is no instance to pull, just return empty Report.
Args:
args: Namespace object from argparse.parse_args.
Returns:
A Report instance.
"""
cfg = config.GetAcloudConfig(args)
if args.inst... | code_fim | hard | {
"lang": "python",
"repo": "ZYHGOD-1/Aosp11",
"path": "/tools/acloud/pull/pull.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZYHGOD-1/Aosp11 path: /tools/acloud/pull/pull.py
# Copyright 2019 - The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.a... | code_fim | hard | {
"lang": "python",
"repo": "ZYHGOD-1/Aosp11",
"path": "/tools/acloud/pull/pull.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
download_folder: String of download folder path.
"""
utils.PrintColorString(
"Download logs to folder: %s \nYou can look into log files to check "
"AVD issues." % download_folder)
def GetDownloadLogFolder(instance):
"""Get the download log folder accroding t... | code_fim | hard | {
"lang": "python",
"repo": "ZYHGOD-1/Aosp11",
"path": "/tools/acloud/pull/pull.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fangguo1/HyperMine path: /src/ranking_model/main_predict.py
import itertools
from utils import load_embedding, Results, Metrics, save_model, load_model, load_directional_supervision, load_element_pairs, load_pair_features
from model import PointNet, PairNet, TripletNet, PairNetWithPairFeatures, T... | code_fim | hard | {
"lang": "python",
"repo": "fangguo1/HyperMine",
"path": "/src/ranking_model/main_predict.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Construct testing set
f_pred = options["pred_pairs_file_in"]
print("!!! Loading term pairs for prediction from: {}".format(f_pred))
pred_pairs = load_element_pairs(f_pred, with_label=False)
print("Number of term pairs for prediction: {}".format(len(pred_pairs)))
# Construct mode... | code_fim | hard | {
"lang": "python",
"repo": "fangguo1/HyperMine",
"path": "/src/ranking_model/main_predict.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser(description='End-to-end inference')
parser.add_argument(
'--cfg',
dest='cfg',
help='cfg model file (/path/to/model_config.yaml)',
default=None,
type=str
)
parser.add_argument(
'--wts',
dest='weights',
... | code_fim | hard | {
"lang": "python",
"repo": "helenrensiyu/detectron2",
"path": "/projects/DensePose/infer_vid.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: helenrensiyu/detectron2 path: /projects/DensePose/infer_vid.py
# Copyright (c) Facebook, Inc. and its affiliates.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
######################################... | code_fim | hard | {
"lang": "python",
"repo": "helenrensiyu/detectron2",
"path": "/projects/DensePose/infer_vid.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aametwally/redun path: /examples/memoization_patterns/map_reduce.py
"""
Example of a map-reduce type operation where a list of A_i is mapped to a list of B_i
and then reduced to produce C.
The B_i are stored in intermediate values, and we wish to delete them after C has been computed.
In this ex... | code_fim | hard | {
"lang": "python",
"repo": "aametwally/redun",
"path": "/examples/memoization_patterns/map_reduce.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Loads all the files in a list and concatenates the first line of each
"""
b_strings = [file.read() for file in files]
# Concatenate
c_val = " ".join(b_strings)
return c_val
@task()
def use_c(c_val: str) -> str:
"""
Prints a string
"""
print(c_val)
re... | code_fim | hard | {
"lang": "python",
"repo": "aametwally/redun",
"path": "/examples/memoization_patterns/map_reduce.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return b_file
@task()
def delete_b_files(intermediate_files: List[File]) -> None:
"""
Deletes a list of files
"""
for f in intermediate_files:
f.remove()
@task()
def reduce_b_files_into_c(files: [List[File]]) -> str:
"""
Loads all the files in a list and concatenate... | code_fim | hard | {
"lang": "python",
"repo": "aametwally/redun",
"path": "/examples/memoization_patterns/map_reduce.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def part2(input):
if input:
decoder_packets = [[[2]], [[6]]]
ordered_packets = [] + decoder_packets
for packet in [eval(line) for line in input.strip().split('\n') if line]:
found = False
for i, other in enumerate(ordered_packets):
if... | code_fim | hard | {
"lang": "python",
"repo": "Bl00drav3n/AdventOfCode",
"path": "/2022/13/code.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if input:
decoder_packets = [[[2]], [[6]]]
ordered_packets = [] + decoder_packets
for packet in [eval(line) for line in input.strip().split('\n') if line]:
found = False
for i, other in enumerate(ordered_packets):
if compare_lists(packet,... | code_fim | hard | {
"lang": "python",
"repo": "Bl00drav3n/AdventOfCode",
"path": "/2022/13/code.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bl00drav3n/AdventOfCode path: /2022/13/code.py
test_input = '''
[1,1,3,1,1]
[1,1,5,1,1]
[[1],[2,3,4]]
[[1],4]
[9]
[[8,7,6]]
[[4,4],4,4]
[[4,4],4,4,4]
[7,7,7,7]
[7,7,7]
[]
[3]
[[[]]]
[[]]
[1,[2,[3,[4,[5,6,7]]]],8,9]
[1,[2,[3,[4,[5,6,0]]]],8,9]
'''
def compare_integers(left, right):
if ... | code_fim | hard | {
"lang": "python",
"repo": "Bl00drav3n/AdventOfCode",
"path": "/2022/13/code.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cache-rules/nerd_herder path: /nerd_herder/talk_proposals/admin.py
from django.contrib import admin
from .models import TalkProposal, AudienceChoice
class AudienceChoiceModelAdmin(admin.ModelAdmin):
model = AudienceChoice
list_display = ("label", "created")
ordering = ("label", )
... | code_fim | hard | {
"lang": "python",
"repo": "cache-rules/nerd_herder",
"path": "/nerd_herder/talk_proposals/admin.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
admin.site.register(AudienceChoice, AudienceChoiceModelAdmin)
admin.site.register(TalkProposal, TalkProposalModelAdmin)<|fim_prefix|># repo: cache-rules/nerd_herder path: /nerd_herder/talk_proposals/admin.py
from django.contrib import admin
from .models import TalkProposal, AudienceChoice
class Audie... | code_fim | hard | {
"lang": "python",
"repo": "cache-rules/nerd_herder",
"path": "/nerd_herder/talk_proposals/admin.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> h = MembershipHercules.objects.all()
h.delete()
with open('herculesnr.txt', 'rU') as csvfile:
data = csv.reader(csvfile, delimiter=',')
for row in data:
p = MembershipHercules(herculesnr=str(row[0]))
p.save()
csvfile.close
# dan de spelers.
def ImportPlayers():
# de boel eerst leeggooien.
... | code_fim | hard | {
"lang": "python",
"repo": "bteeuwen/mijnhercules",
"path": "/scripts/ims.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bteeuwen/mijnhercules path: /scripts/ims.py
import sys
import csv
from members.models import Team, Player, Pass, MembershipHercules
from django.contrib.auth.models import User
from guardian.shortcuts import assign
#### TODO:
## sportlink nieuw bestand nieuwste spelers importeren.
# reguliere exp... | code_fim | hard | {
"lang": "python",
"repo": "bteeuwen/mijnhercules",
"path": "/scripts/ims.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># dan de spelers.
def ImportPlayers():
# de boel eerst leeggooien.
p = Player.objects.all()
p.delete()
u = User.objects.all().exclude(id=1)
u.delete()
with open('spelers.txt', 'rb') as csvfile:
data = csv.reader(csvfile, delimiter=',')
success = 0
failed = 0
p1 = Player.objects.all()
for r... | code_fim | hard | {
"lang": "python",
"repo": "bteeuwen/mijnhercules",
"path": "/scripts/ims.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fabiogeraci/ML-Projects path: /Custom-GridSearch/data_mining_mains.py
import pandas as pd
import numpy as np
from mining_tools import my_tools
from testimbalance import abalone_input
from imbalance_tools import handle_imbalance
from create_dendogram import my_dendogram
#Check the class ab... | code_fim | hard | {
"lang": "python",
"repo": "fabiogeraci/ML-Projects",
"path": "/Custom-GridSearch/data_mining_mains.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Dealing with class imbalance
#Balanced sampling technique as described in the project report
hi=handle_imbalance()
abalone_balanced=hi.simple_oversample_undersample(x.values.astype(np.float),y)
abalone_smote=hi.modified_smote(x.values.astype(np.float),y,2)
y_abalone=abalone_balanced[:,-1]
x_abalone... | code_fim | medium | {
"lang": "python",
"repo": "fabiogeraci/ML-Projects",
"path": "/Custom-GridSearch/data_mining_mains.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>y_smote=abalone_smote[:,-1]
x_smote=abalone_smote[:,:-1]
x_smote=pd.DataFrame(data=x_smote[0:,0:])
#input from pulser dataset
data=pd.read_csv('HTRU_2.csv')
y_htru=data.iloc[:,-1].values.astype(np.float)
x_htru=data.iloc[:,:-1]
#This class takes feature vector & target as input along with the S... | code_fim | hard | {
"lang": "python",
"repo": "fabiogeraci/ML-Projects",
"path": "/Custom-GridSearch/data_mining_mains.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># search the repetitions
total_dupes = 0
total_triples = 0
# examine each box
for box_num in box_ids:
tag_summary = Counter(box_num)
if 2 in tag_summary.values():
total_dupes += 1
if 3 in tag_summary.values():
total_triples += 1
# examine tags' similarity
chars_evidence = {}
f... | code_fim | medium | {
"lang": "python",
"repo": "dragonesse/aoc",
"path": "/2018/day02.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dragonesse/aoc path: /2018/day02.py
import sys;
from collections import Counter
print("Day 2 puzzle: Inventory Management System");
#read input
puzzle_file = "";
if(len(sys.argv) == 1):
print ("Please provide input file as argument!");
sys.exit();
else:
puzzle_file = sys.argv[1];
... | code_fim | hard | {
"lang": "python",
"repo": "dragonesse/aoc",
"path": "/2018/day02.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_search(self):
index = Trie.build(WORDS_FILENAME)
tests = [
['a', 'c'],
['a', 'ab', 'bb', 'bc', 'c'],
['a', 'aa', 'ab', 'bb', 'bc', 'c'],
]
paths = list(search(index, 'a', 'c'))
self.assertEqual(paths, tests)
#limit
paths2 = list(search(index, 'a', ... | code_fim | hard | {
"lang": "python",
"repo": "jorgebg/intercom.io",
"path": "/words/tests.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jorgebg/intercom.io path: /words/tests.py
import unittest
import os
from itertools import combinations_with_replacement
from query import search, levenshtein
from index import Trie, DEFAULT_FILENAME
WORDS_FILENAME = '/tmp/words'
WORDS_CONTENT = "aa ab bb bc c".replace(' ', "\n")
WORDS = WORDS... | code_fim | hard | {
"lang": "python",
"repo": "jorgebg/intercom.io",
"path": "/words/tests.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if abs(lendiff) is 1:
if lendiff > 0:
a, b = b, a
for i in range(len(a)):
if a[i] != b[i]:
for j in range(i, len(a)):
if a[j] != b[j+1]:
return False
return True
return False
if __name__ == '__main__':
with open(WORDS_FILENAME, 'wt') as file:
... | code_fim | hard | {
"lang": "python",
"repo": "jorgebg/intercom.io",
"path": "/words/tests.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
dependencies = [
('foods', '0010_auto_20190818_1434'),
]
operations = [
migrations.AlterField(
model_name='recipeingredient',
name='quantity',
field=models.CharField(max_length=255, null=True),
),
migrations.AlterField(
... | code_fim | medium | {
"lang": "python",
"repo": "KubeljK/heckatlon2019backend",
"path": "/heckatlonbackend/apps/foods/migrations/0011_auto_20190818_1444.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KubeljK/heckatlon2019backend path: /heckatlonbackend/apps/foods/migrations/0011_auto_20190818_1444.py
# Generated by Django 2.2.4 on 2019-08-18 14:44
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('foods', '0010_auto_20190818_1434'),
]
operations ... | code_fim | medium | {
"lang": "python",
"repo": "KubeljK/heckatlon2019backend",
"path": "/heckatlonbackend/apps/foods/migrations/0011_auto_20190818_1444.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: b2220333/osdemo path: /__main__.py
import logging, sys
from osdemo.core.kernel import Kernel
from osdemo.shell.commands import Commands
<|fim_suffix|> shell = Shell()
shell.addCommand("load", Commands(k).load)
shell.addCommand("scheduler", Commands(k).scheduler)
shell.addCommand("... | code_fim | hard | {
"lang": "python",
"repo": "b2220333/osdemo",
"path": "/__main__.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> shell = Shell()
shell.addCommand("load", Commands(k).load)
shell.addCommand("scheduler", Commands(k).scheduler)
shell.addCommand("memory", Commands(k).memory)
ShellFrame(shell).start()<|fim_prefix|># repo: b2220333/osdemo path: /__main__.py
import logging, sys
from osdemo.core.kernel ... | code_fim | hard | {
"lang": "python",
"repo": "b2220333/osdemo",
"path": "/__main__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
logging.basicConfig(format='%(asctime)s | %(message)s', level=logging.INFO)
k = Kernel()
shell = Shell()
shell.addCommand("load", Commands(k).load)
shell.addCommand("scheduler", Commands(k).scheduler)
shell.addCommand("memory", Commands(k).memory)
Sh... | code_fim | medium | {
"lang": "python",
"repo": "b2220333/osdemo",
"path": "/__main__.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chengmingzhang/python_luffy path: /爬虫/爬取笔趣阁小说_元尊_追加更新章节抓取.py
# coding=utf-8
# time:2019-06-03
import requests
from pyquery import PyQuery as pq
def user_if_exits():
global url_list
url_list = []
with open(file='url_list.txt', mode='r', encoding='utf-8') as u:
data = u.readl... | code_fim | hard | {
"lang": "python",
"repo": "chengmingzhang/python_luffy",
"path": "/爬虫/爬取笔趣阁小说_元尊_追加更新章节抓取.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for link in links.items():
url = 'http://www.xbiquge.la' + link.attr.href
if url in url_list:
pass
else:
with open(file='url_list.txt', mode='a+', encoding='utf-8') as u:
u.write(url)
u.write('\n')
response = r... | code_fim | medium | {
"lang": "python",
"repo": "chengmingzhang/python_luffy",
"path": "/爬虫/爬取笔趣阁小说_元尊_追加更新章节抓取.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DeMonDesigns/nibblebee path: /nibble_bee/urls.py
"""nibble_bee URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
... | code_fim | medium | {
"lang": "python",
"repo": "DeMonDesigns/nibblebee",
"path": "/nibble_bee/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># original urls
# url(r'^upload/', staff_member_required(views.upload), name='ckeditor_upload'),
# url(r'^browse/', never_cache(staff_member_required(views.browse)), name='ckeditor_browse'),
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)<|fim_prefix|># repo: DeMonDesigns/nib... | code_fim | hard | {
"lang": "python",
"repo": "DeMonDesigns/nibblebee",
"path": "/nibble_bee/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kpapirio/DSSG_Samples path: /Code_Samples/Extreme_Computing_hadoop/task1/combiner1.py
#!/usr/bin/python
import sys
prev = ""
total = 0
doc_prev = ""
for line in sys.stdin:
token, docID, count = line.strip().split()
count = int(count)
if prev == token:
if doc_prev... | code_fim | medium | {
"lang": "python",
"repo": "kpapirio/DSSG_Samples",
"path": "/Code_Samples/Extreme_Computing_hadoop/task1/combiner1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> prev, doc_prev, total, " "
prev = token
doc_prev = docID
total = count
else:
if prev:
print prev, doc_prev, total, " "
prev = token
doc_prev = docID
total = count
if prev == token:
print prev, docID, total, " "<|fim_prefix|># repo: kpapiri... | code_fim | medium | {
"lang": "python",
"repo": "kpapirio/DSSG_Samples",
"path": "/Code_Samples/Extreme_Computing_hadoop/task1/combiner1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Sets an entity as the target of the camera."""
self.target = entity
def Update(self):
"""Updates the camera."""
if self.mode == "follow" and self.target != None:
self.position = (self.target.mapLocation[0] - (self.target.size[0])/2) - (settings.SCREEN_WIDTH/2), (self.target.mapLocation[1... | code_fim | medium | {
"lang": "python",
"repo": "jeffgamedev/shooterpy",
"path": "/src/Camera.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jeffgamedev/shooterpy path: /src/Camera.py
import settings
class Camera(object):
def __init__(self, renderer):
"""Constructor."""
self.position = 0, 0
self.lastPosition = 0, 0
self.mode = "follow"
self.target = None
self.bounds = 0, 0, settings.SCREEN_WIDTH, settings.SCREEN_HEIGHT ... | code_fim | medium | {
"lang": "python",
"repo": "jeffgamedev/shooterpy",
"path": "/src/Camera.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='Comuna',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nombre', models.CharField(max_length=50)),
],
),
... | code_fim | hard | {
"lang": "python",
"repo": "dfuentes887/Ferme",
"path": "/core/migrations/0001_initial.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dfuentes887/Ferme path: /core/migrations/0001_initial.py
# Generated by Django 3.1.2 on 2021-04-02 19:46
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|>
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
... | code_fim | hard | {
"lang": "python",
"repo": "dfuentes887/Ferme",
"path": "/core/migrations/0001_initial.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DUMBALINYOLO/DJANGO-REACT-FOR-ENTREPRENEURS-COURSE path: /summary_python/decorators.py
from functools import wraps
def debug(func):
# func is a function being wrapped
@wraps(func)
def wrapper(*args, **kwargs):
print(func.__qualname__)
return func(*args, **kwargs)
return wrapper
@debug... | code_fim | medium | {
"lang": "python",
"repo": "DUMBALINYOLO/DJANGO-REACT-FOR-ENTREPRENEURS-COURSE",
"path": "/summary_python/decorators.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(subtract(10, 90))
print(multiply(10, 90))
print(divide(10, 90))
print(power(10, 90))
print(help(debug))<|fim_prefix|># repo: DUMBALINYOLO/DJANGO-REACT-FOR-ENTREPRENEURS-COURSE path: /summary_python/decorators.py
from functools import wraps
def debug(func):
# func is a function being wrapped
... | code_fim | medium | {
"lang": "python",
"repo": "DUMBALINYOLO/DJANGO-REACT-FOR-ENTREPRENEURS-COURSE",
"path": "/summary_python/decorators.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
print(add(10, 90))
print(subtract(10, 90))
print(multiply(10, 90))
print(divide(10, 90))
print(power(10, 90))
print(help(debug))<|fim_prefix|># repo: DUMBALINYOLO/DJANGO-REACT-FOR-ENTREPRENEURS-COURSE path: /summary_python/decorators.py
from functools import wraps
def debug(func):
# func is a fu... | code_fim | medium | {
"lang": "python",
"repo": "DUMBALINYOLO/DJANGO-REACT-FOR-ENTREPRENEURS-COURSE",
"path": "/summary_python/decorators.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JibinJoseph2000/HackerRank path: /python/Birthday_Candles.py
def birthdayCakeCandles(ar):
<|fim_suffix|>
ar_count = int(input())
ar = list(map(int, input().rstrip().split(' ')))
birthdayCakeCandles(ar)<|fim_middle|> ar.sort()
max=ar[len(ar)-1]
x=0
for i in ar:
i... | code_fim | medium | {
"lang": "python",
"repo": "JibinJoseph2000/HackerRank",
"path": "/python/Birthday_Candles.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
ar_count = int(input())
ar = list(map(int, input().rstrip().split(' ')))
birthdayCakeCandles(ar)<|fim_prefix|># repo: JibinJoseph2000/HackerRank path: /python/Birthday_Candles.py
def birthdayCakeCandles(ar):
<|fim_middle|> ar.sort()
max=ar[len(ar)-1]
x=0
for i in ar:
i... | code_fim | medium | {
"lang": "python",
"repo": "JibinJoseph2000/HackerRank",
"path": "/python/Birthday_Candles.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
]
operations = [
migrations.CreateModel(
name='Shellies',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('shelly_id', models.CharField(max_length=100)),
('shelly_name', mod... | code_fim | hard | {
"lang": "python",
"repo": "nicx/shellyupdater",
"path": "/shellyupdater/updates/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarekPopowicz/PyQt5Application path: /Logic/Model/device_model.py
class Device:
def __init__(self,
d_id=0,
d_task_id=0,
d_device_type='',
<|fim_suffix|>'):
self.id = d_id
self.task_id = d_task_id
self.device_type ... | code_fim | hard | {
"lang": "python",
"repo": "MarekPopowicz/PyQt5Application",
"path": "/Logic/Model/device_model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>'):
self.id = d_id
self.task_id = d_task_id
self.device_type = d_device_type
self.device_width = d_device_width
self.device_long = d_device_long
self.regulation_type = d_regulation_type
self.notice = d_notice<|fim_prefix|># repo: MarekPopowicz/PyQt5A... | code_fim | hard | {
"lang": "python",
"repo": "MarekPopowicz/PyQt5Application",
"path": "/Logic/Model/device_model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ti3r/django-cms-events path: /cmsplugin_events/cms_plugins.py
from sekizai.context import SekizaiContext
from django.utils.translation import ugettext as _
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
import datetime
import calendar
from models import EventLis... | code_fim | hard | {
"lang": "python",
"repo": "ti3r/django-cms-events",
"path": "/cmsplugin_events/cms_plugins.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class EventRegistrationPlugin(CMSPluginBase):
model = EventRegistryPlugin
name = _('Event Registration Form')
render_template = 'cmsplugin_events/register.html'
module = 'events'
def render(self, context, instance, placeholder):
request = context['request']
if request... | code_fim | hard | {
"lang": "python",
"repo": "ti3r/django-cms-events",
"path": "/cmsplugin_events/cms_plugins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = EventRegistryPlugin
name = _('Event Registration Form')
render_template = 'cmsplugin_events/register.html'
module = 'events'
def render(self, context, instance, placeholder):
request = context['request']
if request.method == 'POST' and "cmsplugin_events_registe... | code_fim | hard | {
"lang": "python",
"repo": "ti3r/django-cms-events",
"path": "/cmsplugin_events/cms_plugins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChaoticCross12/Advent-of-Code path: /day2_1.py
eachLine = input()
counter, wrongPass, totIn = 0, 0, 1
while True:
lower = int(eachLine[0 : eachLine.find('-')])
upper = int(eachLine[(eachLine.find('-') + 1) : eachLine.find(' ')])
letterToCount = eachLine[eachLine.find(' ') + 1]
pa... | code_fim | medium | {
"lang": "python",
"repo": "ChaoticCross12/Advent-of-Code",
"path": "/day2_1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
eachLine = input()
totIn += 1
if eachLine == '':
break
print(counter, totIn - 1)<|fim_prefix|># repo: ChaoticCross12/Advent-of-Code path: /day2_1.py
eachLine = input()
counter, wrongPass, totIn = 0, 0, 1
while True:
lower = int(eachLine[0 : eachLine.find('-')])
upper = int... | code_fim | medium | {
"lang": "python",
"repo": "ChaoticCross12/Advent-of-Code",
"path": "/day2_1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: medabkasm/arch_from_scratch path: /test.py
def equation(x1,x2,y1,y2,x):
a = (y2 - y1) / (x2 - x1)
b = y1 - x1*a
y = a * x + b
return y
with open("valeurs_short_waves.txt","w") as file:
file.write("x1,x2,y1,y2,x,y\n")
while True:
x1 = float(input("x1 : "))
... | code_fim | medium | {
"lang": "python",
"repo": "medabkasm/arch_from_scratch",
"path": "/test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> y1 = float(input("y1 : "))
y2 = float(input("y2 : "))
x = float(input("x : "))
y = equation(x1,x2,y1,y2,x)
print("y = ",y)
print()
file.write(str(x1)+","+str(x2)+","+str(y1)+","+str(y2)+","+str(x)+","+str(y))
file.write("\n")<|fim_prefix|># repo... | code_fim | medium | {
"lang": "python",
"repo": "medabkasm/arch_from_scratch",
"path": "/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
arr = [1, 2, 3, 4, 5]
print(arr)
reverse(arr)
print(arr)
if __name__=="__main__":
main()<|fim_prefix|># repo: minhyeong-joe/coding-interview path: /Array/ReverseInPlace.py
'''
Given a list, reverse the order without using extra arrays.
'''
def reverse(arr):
left ... | code_fim | medium | {
"lang": "python",
"repo": "minhyeong-joe/coding-interview",
"path": "/Array/ReverseInPlace.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> reverse(arr)
print(arr)
if __name__=="__main__":
main()<|fim_prefix|># repo: minhyeong-joe/coding-interview path: /Array/ReverseInPlace.py
'''
Given a list, reverse the order without using extra arrays.
'''
<|fim_middle|>def reverse(arr):
left = 0
right = len(arr)-1
print(left... | code_fim | hard | {
"lang": "python",
"repo": "minhyeong-joe/coding-interview",
"path": "/Array/ReverseInPlace.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: minhyeong-joe/coding-interview path: /Array/ReverseInPlace.py
'''
Given a list, reverse the order without using extra arrays.
'''
<|fim_suffix|> while left < right:
arr[left] = arr[left] + arr[right]
arr[right] = arr[left] - arr[right]
arr[left] = arr[left] - arr[right... | code_fim | medium | {
"lang": "python",
"repo": "minhyeong-joe/coding-interview",
"path": "/Array/ReverseInPlace.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AVS18/eyantra-covid-updates path: /donor/views.py
from django.shortcuts import render,redirect
from pharmacy.models import Medicine,Order
from django.contrib import messages
from patient.models import Bill
from .models import PlasmaProfile,DonorRequest
def searchMedicine(request):
if request.... | code_fim | hard | {
"lang": "python",
"repo": "AVS18/eyantra-covid-updates",
"path": "/donor/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> order = Order.objects.get(id=oid)
bill = Bill.objects.get(id = order.billing.id)
bill.amount = int(0.25*bill.amount)
bill.description +="-Cancelled"
bill.save()
order.status="Cancelled"
order.save()
storage = messages.get_messages(request)
storage.used = True
messag... | code_fim | hard | {
"lang": "python",
"repo": "AVS18/eyantra-covid-updates",
"path": "/donor/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gwynforthewyn/kata path: /tests/test_two_sum.py
from kata import two_sum as ts
def test_two_sum_success():
nums, target = [2,7,11,15], 9
summer = ts.Solution()
<|fim_suffix|> nums, target = [3, 3], 6
# assert summer.twoSum(nums, target) == [0, 1]<|fim_middle|> # assert summer... | code_fim | medium | {
"lang": "python",
"repo": "gwynforthewyn/kata",
"path": "/tests/test_two_sum.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> nums, target = [3,2,4], 6
assert summer.twoSum(nums, target) == [1,2]
nums, target = [3, 3], 6
# assert summer.twoSum(nums, target) == [0, 1]<|fim_prefix|># repo: gwynforthewyn/kata path: /tests/test_two_sum.py
from kata import two_sum as ts
def test_two_sum_success():
nums, target... | code_fim | easy | {
"lang": "python",
"repo": "gwynforthewyn/kata",
"path": "/tests/test_two_sum.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cdsire/python2code path: /03重定向.py
# encoding:utf-8
import urllib2
'''
# 判断有没有重定向
response = urllib2.urlopen("http://www.baidu.cn")
print response.geturl() == "http://www.baidu.cn"
'''
class RedirectHandler(urllib2.HTTPRedirectHandler):
<|fim_suffix|>opener = urllib2.build_opener(RedirectHan... | code_fim | hard | {
"lang": "python",
"repo": "cdsire/python2code",
"path": "/03重定向.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>opener = urllib2.build_opener(RedirectHandler)
opener.open("http://www.baidu.cn/")<|fim_prefix|># repo: cdsire/python2code path: /03重定向.py
# encoding:utf-8
import urllib2
'''
# 判断有没有重定向
response = urllib2.urlopen("http://www.baidu.cn")
print response.geturl() == "http://www.baidu.cn"
'''
<|fim_middle... | code_fim | hard | {
"lang": "python",
"repo": "cdsire/python2code",
"path": "/03重定向.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ion, unicode_literals
TIMER_DELAY = 0.1
MOMENTARY_DELAY = 0.3
MOMENTARY_DELAY_TICKS = int(MOMENTARY_DELAY / TIMER_DELAY)<|fim_prefix|># repo: aarkwright/ableton_devices path: /MIDI Remote Scripts/_Framework/Defaults.py
# uncompyle6 version 3.3.5
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.7... | code_fim | hard | {
"lang": "python",
"repo": "aarkwright/ableton_devices",
"path": "/MIDI Remote Scripts/_Framework/Defaults.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aarkwright/ableton_devices path: /MIDI Remote Scripts/_Framework/Defaults.py
# uncompyle6 version 3.3.5
# Python bytecode 2.7 (62211)
# Decompiled from: Python 3.7.3 (default, Apr 24 2019, 15:29:51<|fim_suffix|>te Scripts\_Framework\Defaults.py
# Compiled at: 2018-11-30 15:48:11
from __future__ i... | code_fim | medium | {
"lang": "python",
"repo": "aarkwright/ableton_devices",
"path": "/MIDI Remote Scripts/_Framework/Defaults.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>n m:
print(m[v])
break<|fim_prefix|># repo: ankitpriyarup/online-judge path: /dmoj/bts19/p1.py
n = int(input())
m = {len(s): s for s in input().split()}
x = input()
for v<|fim_middle|> in range(len(x), -1, -1):
if v i | code_fim | easy | {
"lang": "python",
"repo": "ankitpriyarup/online-judge",
"path": "/dmoj/bts19/p1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ankitpriyarup/online-judge path: /dmoj/bts19/p1.py
n = int(input())
m = {len(s): s for s<|fim_suffix|> in range(len(x), -1, -1):
if v in m:
print(m[v])
break<|fim_middle|> in input().split()}
x = input()
for v | code_fim | easy | {
"lang": "python",
"repo": "ankitpriyarup/online-judge",
"path": "/dmoj/bts19/p1.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.