text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Tiburocin/Cargo path: /app.py
from flask import Flask
from flask_restplus import Api, Resource, fields
from route_tienda import Tienda, TiendaById
from route_productos import Productos, ProductosById, CantidadProductos
<|fim_suffix|>api.add_resource(Tienda,"/api/V01/tienda")
api.add_resource(Pro... | code_fim | medium | {
"lang": "python",
"repo": "Tiburocin/Cargo",
"path": "/app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># @socketio.on("new_message")
# def sent_message(json):
# """Handle a new message being sent"""
# # Log the timestamp
# my_time = time.strftime('%H:%M:%S on %d/%m/%y')
# # Assemble data into a dict
# my_data = {"user": json["user"], "msg" : json["msg"], "my_time": my_time}
# # Add ... | code_fim | hard | {
"lang": "python",
"repo": "shamsow/ai-tictactoe",
"path": "/app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shamsow/ai-tictactoe path: /app.py
import os
import time
import json
from flask import Flask, render_template, request
from flask_socketio import SocketIO, emit
# from helper import *
from helper import winner, terminal, minimax, initial_state, result
# Use /python3 app.py/ to run
app = Flask(... | code_fim | hard | {
"lang": "python",
"repo": "shamsow/ai-tictactoe",
"path": "/app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@socketio.on("get_ai_move")
def generate_ai_move(board):
"""Determine the optimal move for the AI to make and the send it"""
if terminal(board): # if the game is over, do nothing
pass
else:
move = minimax(board) # use minimax algorithm to generate optimal move
res = r... | code_fim | hard | {
"lang": "python",
"repo": "shamsow/ai-tictactoe",
"path": "/app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: guinslym/sp_ask_presence_alert path: /log_setup.py
#Python STD package
import time
from pytz import timezone
from datetime import datetime
import random
from pprint import pprint as print
import os
import logging
from logging.handlers import RotatingFileHandler
import sys
<|fim_suffix|> # htt... | code_fim | medium | {
"lang": "python",
"repo": "guinslym/sp_ask_presence_alert",
"path": "/log_setup.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # https://tutorialedge.net/python/python-logging-best-practices/
log_formatter = logging.Formatter('%(asctime)s %(levelname)-8s [%(filename)s:%(funcName)s:%(lineno)d] %(message)s')
logFile = './log.log'
my_handler = RotatingFileHandler(
logFile, mode='a', maxBytes=5*1024*1024,
... | code_fim | medium | {
"lang": "python",
"repo": "guinslym/sp_ask_presence_alert",
"path": "/log_setup.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pacellig/personal path: /primitive_roots.py
from fractions import gcd
import random
# Computes Euler's totient for n.
def phi(n):
b=n-1
c=0
while b:
if not gcd(n,b)-1:
c+=1
b-=1
return c
# Computes the factorization of n.
def find_prime_factors(n... | code_fim | hard | {
"lang": "python",
"repo": "pacellig/personal",
"path": "/primitive_roots.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> prim_roots = []
phi_n = phi(n)
prime_factors = find_prime_factors(phi_n)
k = len(prime_factors)
for i in range(1,n):
found = True
for j in range(1,k):
ai = pow(i, phi_n/prime_factors[j],n)
if ai == 1:
found = False
... | code_fim | hard | {
"lang": "python",
"repo": "pacellig/personal",
"path": "/primitive_roots.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
#TODO: Use environment variables for this!
app.run(host='0.0.0.0', port=5000)<|fim_prefix|># repo: aric49/meowww path: /init.py
from flask import Flask, flash, redirect, render_template, request, session, abort
import requests, json
app = Flask(__name__)
<|fim_middle|>... | code_fim | hard | {
"lang": "python",
"repo": "aric49/meowww",
"path": "/init.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aric49/meowww path: /init.py
from flask import Flask, flash, redirect, render_template, request, session, abort
import requests, json
app = Flask(__name__)
<|fim_suffix|> GetMeCats = requests.get("https://api.thecatapi.com/v1/images/search")
CatsJson = GetMeCats.json()
CatImage = Cats... | code_fim | easy | {
"lang": "python",
"repo": "aric49/meowww",
"path": "/init.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: windyStreet/MYPROJECT path: /loamp/func/autoUpdate/Controler.py
#!/usr/bin/env python
# !-*- coding:utf-8 -*-
import projectupdate
import FormatPrint
import getopt
import sys
import TomcatFunc
import HealthCheck
import platformFunc
import MailFunc
class Controler(object):
def __init__(self... | code_fim | hard | {
"lang": "python",
"repo": "windyStreet/MYPROJECT",
"path": "/loamp/func/autoUpdate/Controler.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 帮助
def help():
print ("-h,--help")
print (
"-m:,--method=,will be run method:platformReplaceResource|platformupdate|platformSendMail|platformDelUpdateFile|update|updateMailConf|rollBack|starttomcat|killtomcat|startHealthCheck|stopHealthCheck|restartHealthCheck|healthCheckOnce|healthCheck... | code_fim | hard | {
"lang": "python",
"repo": "windyStreet/MYPROJECT",
"path": "/loamp/func/autoUpdate/Controler.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># 关闭tomcat
def tomatKill():
FormatPrint.printDebug("tomatKill")
FormatPrint.printInfo("关闭tocmat" + str(tomcatTag))
TomcatFunc.killTomcat(path, tomcatTag)
# 启动健康检查服务
def startHealthCheck():
FormatPrint.printDebug("startHealCheck")
if HealthCheck.startHealthCheck(projectName):
... | code_fim | hard | {
"lang": "python",
"repo": "windyStreet/MYPROJECT",
"path": "/loamp/func/autoUpdate/Controler.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mjpost/bibsearch path: /resources/parse_pmlr_web.py
#!/usr/bin/env python
import os.path
import re
import sys
import urllib.request
import yaml
def download_file(url, fname_out=None) -> None:
"""
Downloads a file to a location.
"""
<|fim_suffix|>def main():
volume_re = re.compi... | code_fim | hard | {
"lang": "python",
"repo": "mjpost/bibsearch",
"path": "/resources/parse_pmlr_web.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> volume_re = re.compile("""<a href="([^"]*)"><b>(Volume .*)</b></a>""")
volumes = {}
base_url = """http://proceedings.mlr.press/"""
for l in download_file("http://proceedings.mlr.press/").split("\n"):
match = volume_re.search(l)
if match:
volumes[match.group(2)] ... | code_fim | hard | {
"lang": "python",
"repo": "mjpost/bibsearch",
"path": "/resources/parse_pmlr_web.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lionsrc/WaltonAnalytics path: /Tools/EveryWM.py
from datetime import datetime
from flatten_json import flatten
from time import gmtime, strftime
import time
import requests
import os
import json
import sys
import random
import csv
reload(sys)
sys.setdefaultencoding('utf-8')
import threading
proxi... | code_fim | hard | {
"lang": "python",
"repo": "lionsrc/WaltonAnalytics",
"path": "/Tools/EveryWM.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> StoreChoice = random.choice(ListOfStores)
ListOfStores.remove(StoreChoice)
return str(StoreChoice)
def SaveToCSV(store):
prevsku = len(sku)
keys = sku[0].keys()
with open(directory + str(store) + '.csv', 'wb') as output_file:
dict_writer = csv.DictWriter(output_file, keys)
dict_writer.writeheade... | code_fim | hard | {
"lang": "python",
"repo": "lionsrc/WaltonAnalytics",
"path": "/Tools/EveryWM.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class DiseaseStatusMigrationTest(BasePatientRegistrationMigrationTest):
migrate_from = '0223_merge_20210427_1419'
migrate_to = '0224_change_disease_status_from_recover_to_recovered'
def create_patient(self):
data = self.data.copy()
data.pop('medical_history', [])
data.... | code_fim | hard | {
"lang": "python",
"repo": "Basharckr/care",
"path": "/care/facility/tests/test_migrations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class DiseaseStatusMigrationTest(BasePatientRegistrationMigrationTest):
migrate_from = '0223_merge_20210427_1419'
migrate_to = '0224_change_disease_status_from_recover_to_recovered'
def create_patient(self):
data = self.data.copy()
data.pop('medical_history', [])
data... | code_fim | hard | {
"lang": "python",
"repo": "Basharckr/care",
"path": "/care/facility/tests/test_migrations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Basharckr/care path: /care/facility/tests/test_migrations.py
from django.test import TransactionTestCase
from django.apps import apps
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
from care.facility.models.patient_base import DiseaseStatusEnum
from ... | code_fim | hard | {
"lang": "python",
"repo": "Basharckr/care",
"path": "/care/facility/tests/test_migrations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Now the experiment (different kernels) start
for kName in list(config.EXPERIMENTS.keys()):
print(kName)
inputs = ef.ExperimentInput(kName, data, config.EXPERIMENTS[kName],
config.LIKELIHOOD_EXPERIMENT.get(kName, config.LIKEL... | code_fim | hard | {
"lang": "python",
"repo": "iamthejao/automatic_forecasting",
"path": "/experiment_fit_gpflow.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iamthejao/automatic_forecasting path: /experiment_fit_gpflow.py
import os
from pathlib import Path
import pandas as pd
import time
import experiment_config_gpflow as config
import experiment_funcs_gpflow as ef
import warnings
warnings.filterwarnings(action='ignore', module='GPy')
records = pd.D... | code_fim | hard | {
"lang": "python",
"repo": "iamthejao/automatic_forecasting",
"path": "/experiment_fit_gpflow.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> strSelectSC += "(resn " + Res + " & resi " + Num
if Chn != '-':
strSelectSC += " & chain " + Chn
else:
strSelectSC += " & chain ''"
strSe... | code_fim | hard | {
"lang": "python",
"repo": "lmorency/NRGsuite",
"path": "/FlexAID/UpdateScreen.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lmorency/NRGsuite path: /FlexAID/UpdateScreen.py
ovich, R.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) ... | code_fim | hard | {
"lang": "python",
"repo": "lmorency/NRGsuite",
"path": "/FlexAID/UpdateScreen.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> text_file.close()
except IOError:
self.CriticalError("Could not write PDB ligand file.")
return 1
return 0
'''=========================================================================
UpdateLigandFlexibility: ... | code_fim | hard | {
"lang": "python",
"repo": "lmorency/NRGsuite",
"path": "/FlexAID/UpdateScreen.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asishraz/algorithm path: /leetcode_sum.py
n = int(input())
lists = [int(input()) for x in range(n)]
target = int(input())
<|fim_suffix|>for i in range(1,len(lists)):
if first + lists[i] == target:
final_list.append(first)
final_list.append(lists[i])<|fim_middle|>first = lis... | code_fim | easy | {
"lang": "python",
"repo": "asishraz/algorithm",
"path": "/leetcode_sum.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(1,len(lists)):
if first + lists[i] == target:
final_list.append(first)
final_list.append(lists[i])<|fim_prefix|># repo: asishraz/algorithm path: /leetcode_sum.py
n = int(input())
lists = [int(input()) for x in range(n)]
target = int(input())
<|fim_middle|>first = lis... | code_fim | easy | {
"lang": "python",
"repo": "asishraz/algorithm",
"path": "/leetcode_sum.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kyog02/DeepLearningStudy path: /math_library.py
import numpy as np
import matplotlib.pylab as plt
# 微分
# 誤差を含んでいないため、使用しない
def diff(func,x):
h = 1e-4
return (func(x+h) - func(x))/h
# 数値微分
# 数値微分には誤差が含まれるため、
def numrerical_diff(func,x):
h = 1e-4 # 0.0001
return (func(x+h) - fun... | code_fim | medium | {
"lang": "python",
"repo": "kyog02/DeepLearningStudy",
"path": "/math_library.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 3.0**2.0 + x1**2.0
# 偏微分は式に変数が2つ以上ある場合に、1つの変数の微分を求めること
# print(numrerical_diff(func2_tmp1,3.0))
# print(numrerical_diff(func2_tmp2,4.0))
# print(numerical_gradient(func2,np.array([3.0,4.0,3.0])))
# print(numerical_gradient(func2,np.array([0.0,2.0])))<|fim_prefix|># repo: kyog02/DeepLearningS... | code_fim | hard | {
"lang": "python",
"repo": "kyog02/DeepLearningStudy",
"path": "/math_library.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joshua-han/hello-world path: /largest and smallest.py
smallest=None
for number in[22,1,44,55,76]:
if smallest is None:
smal<|fim_suffix|>lest
largest=None
for value in[1,23,33,56,34]:
if largest is None:
largest=value
elif largest<value:
largest=valu... | code_fim | medium | {
"lang": "python",
"repo": "joshua-han/hello-world",
"path": "/largest and smallest.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>largest=value
elif largest<value:
largest=value
print'largest',largest<|fim_prefix|># repo: joshua-han/hello-world path: /largest and smallest.py
smallest=None
for number in[22,1,44,55,76]:
if smallest is None:
smallest=number
elif number<smallest:
smallest=num... | code_fim | medium | {
"lang": "python",
"repo": "joshua-han/hello-world",
"path": "/largest and smallest.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FranklinDX3906/Project-Code-for-a-Course-Named-Communication-Network-Theory-in-UESTC path: /Project1/Project1.py
# -*- coding: utf-8 -*-
def PrintAllTheRoute (graph,s,d): #s表示初始点,d表示终结点
stack = [s] #用于DFS之中存储路径点
HasBeenConsideredByItsFather = {s:set([])} #用于判断是否已被父节点考虑
i=0
wh... | code_fim | hard | {
"lang": "python",
"repo": "FranklinDX3906/Project-Code-for-a-Course-Named-Communication-Network-Theory-in-UESTC",
"path": "/Project1/Project1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nConsideredByItsFather[stack[-1]].add(PointOut)#将刚刚出栈的点计入栈顶元素的“考虑”的dict内
else:
pass
return 0
'''
graph = {'A':['B','G'],
'B':['A','G','C'],
'C':['B','F','D','E'],
'D':['C','E'],
'E':['D','C','F'],
'F':['C','E',... | code_fim | hard | {
"lang": "python",
"repo": "FranklinDX3906/Project-Code-for-a-Course-Named-Communication-Network-Theory-in-UESTC",
"path": "/Project1/Project1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pyplot.axis([0, 1100, 0, 1100000])
# pyplot.show()
pyplot.savefig("squares_ploy.png",bbox_inches="tight")<|fim_prefix|># repo: shangguanyunluo/pygal_update path: /pygal_update01/scatter_squares05.py
# encoding: utf-8
'''
Created on 2018年9月13日
@author: Administrator
'''
from matplotlib import pyplot
x_... | code_fim | medium | {
"lang": "python",
"repo": "shangguanyunluo/pygal_update",
"path": "/pygal_update01/scatter_squares05.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shangguanyunluo/pygal_update path: /pygal_update01/scatter_squares05.py
# encoding: utf-8
'''
Created on 2018年9月13日
@author: Administrator
'''
from matplotlib import pyplot
x_values = list(range(1, 1001))
y_values = [x ** 2 for x in x_values]
pyplot.scatter(x_values, y_values, c=y_values, edg... | code_fim | medium | {
"lang": "python",
"repo": "shangguanyunluo/pygal_update",
"path": "/pygal_update01/scatter_squares05.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pyplot.title("Square Numbers", fontsize=14)
pyplot.xlabel("Value")
pyplot.ylabel("Squares of Numbers")
pyplot.axis([0, 1100, 0, 1100000])
# pyplot.show()
pyplot.savefig("squares_ploy.png",bbox_inches="tight")<|fim_prefix|># repo: shangguanyunluo/pygal_update path: /pygal_update01/scatter_squares05.py
# ... | code_fim | medium | {
"lang": "python",
"repo": "shangguanyunluo/pygal_update",
"path": "/pygal_update01/scatter_squares05.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sptechguru/Python-Core-Basics-Programs path: /opertors.py
# Artemtic opertos
#
print("Addition is a :",50+6)
print("subtractio is a :",50-6)
print("50*6 is a :",50*6)
print("50**6 is a :",50**6)
print("50/6 is a :",50/6)
print("50//6 is a :",50//6)
<|fim_suffix|>i=5
print(" Equal:",i==5)
# mem... | code_fim | medium | {
"lang": "python",
"repo": "sptechguru/Python-Core-Basics-Programs",
"path": "/opertors.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
i=4
print(" Greater Equal:",i<=5)
i=5
print(" Equal:",i==5)
# membership opertors
list = [2,8,5,8,81,3,5,58,60,60]
print(22 in list)
print(2220 is not list)
# Bitwise opertors
# 0=00
# 1=01
# 2=10
# 3=11
print(0&1)
print(0|1)<|fim_prefix|># repo: sptechguru/Python-Core-Basics-Programs path: /operto... | code_fim | medium | {
"lang": "python",
"repo": "sptechguru/Python-Core-Basics-Programs",
"path": "/opertors.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Static method who read all projects
:param response: Request response
"""
STORED_ID['project_id'] = response.json()["id"]
@staticmethod
def delete_stored_project():
"""
Static method for delete a project.
"""
client = Req... | code_fim | hard | {
"lang": "python",
"repo": "Warchino/api_test_pivotal_team1",
"path": "/core/utils/project_helper.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Warchino/api_test_pivotal_team1 path: /core/utils/project_helper.py
"""Helper for projects of pivotal tracker"""
import json
import string
from random import choices
from core.logger.singleton_logger import SingletonLogger
from core.rest_client.request_manager import RequestManager
from definiti... | code_fim | hard | {
"lang": "python",
"repo": "Warchino/api_test_pivotal_team1",
"path": "/core/utils/project_helper.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Static method for delete all projects.
"""
client = RequestManager()
client.set_method("GET")
client.set_endpoint("/projects")
response = client.execute_request()
for project in response.json():
try:
ProjectHel... | code_fim | hard | {
"lang": "python",
"repo": "Warchino/api_test_pivotal_team1",
"path": "/core/utils/project_helper.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: malexit240/django-questions path: /polls/views.py
from django.shortcuts import render
from django.http import (HttpResponse, Http404,
HttpResponseRedirect, HttpRequest)
from .models import Question, Choice
from django.template import loader
from django.shortcuts import ge... | code_fim | hard | {
"lang": "python",
"repo": "malexit240/django-questions",
"path": "/polls/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ChoiceCreate(CreateView):
template_name = 'polls/detail.html'
model = Choice
fields = ['question','choice_text']
@require_GET
def index(request: HttpRequest):
return render(request, 'polls/index.html', {
"lastest_question_list": Question.objects.order_by('-pub_date')[:5]
... | code_fim | hard | {
"lang": "python",
"repo": "malexit240/django-questions",
"path": "/polls/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IgorxutStepikOrg/AlgorithmsTheoryAndPracticeMethods path: /Module4_1/Step9/python/solution.py
def main():
points, tmp, result, lines = list(), list(), list(), dict()
n = int(input())
for num in range(n):
l, r = map(int, input().split())
points.append([l, 1, num]) # ... | code_fim | hard | {
"lang": "python",
"repo": "IgorxutStepikOrg/AlgorithmsTheoryAndPracticeMethods",
"path": "/Module4_1/Step9/python/solution.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> tmp.clear()
print("{0}\n{1}".format(len(result), " ".join(map(str, result))))
if __name__ == "__main__":
main()<|fim_prefix|># repo: IgorxutStepikOrg/AlgorithmsTheoryAndPracticeMethods path: /Module4_1/Step9/python/solution.py
def main():
points, tmp, result, lines = list(... | code_fim | hard | {
"lang": "python",
"repo": "IgorxutStepikOrg/AlgorithmsTheoryAndPracticeMethods",
"path": "/Module4_1/Step9/python/solution.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tjjgo/ForbiddenIsland path: /title.py
#--------------------------------Imports---------------------------------------#
try: import Tkinter as Tk
except ImportError: import tkinter as Tk
import os
if False:
import gameScreen
#------------------------------Root--------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "tjjgo/ForbiddenIsland",
"path": "/title.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> os.chdir("./Assets")
os.startfile("ForbiddenIslandTM-RULES.pdf")
"""def canvasEvent(e):
def isInBox(e, x1,y1, x2,y2):
return False
if isInBox(e, 100,100, 125,125):
play_the_game()
elif isInBox(e, 150,150, 175,175):
open_rulebook()
else:
print("Inval... | code_fim | medium | {
"lang": "python",
"repo": "tjjgo/ForbiddenIsland",
"path": "/title.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: b04902036/ctf path: /2018/asis_final/crypto/nsa/test.py
#!/usr/bin/python
from pwn import *
from hashlib import *
import string
poss = string.printable
host = '146.185.131.214'
port = 52709
<|fim_suffix|> for a in poss:
for b in poss:
for c in poss:
for d i... | code_fim | medium | {
"lang": "python",
"repo": "b04902036/ctf",
"path": "/2018/asis_final/crypto/nsa/test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ops = ' %&()*+-/<>^|~'
nude = expr.translate(None, ops)
try:
flag, val = True, eval(expr)
except:
flag, val = False, None
return set(nude) == set(num) and flag, val
r.interactive()<|fim_prefix|># repo: b04902036/ctf path: /2018/asis_final/crypto/nsa/test.py
#!/usr/bin/... | code_fim | hard | {
"lang": "python",
"repo": "b04902036/ctf",
"path": "/2018/asis_final/crypto/nsa/test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>enthe', 'Assen')
hashmap.set(provinces, 'Gelderland', 'Nijmegen')
hashmap.set(provinces, 'Overijssel', 'Enschede')
hashmap.list(provinces)
print '-' * 10
print hashmap.get(provinces, 'Drenthe')<|fim_prefix|># repo: abigailStev/learn_python_the_hard_way path: /ex39_test1.py
import hashmap
provinces = ha... | code_fim | hard | {
"lang": "python",
"repo": "abigailStev/learn_python_the_hard_way",
"path": "/ex39_test1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abigailStev/learn_python_the_hard_way path: /ex39_test1.py
import hashmap
provinces = hashmap.new()
# Dutch provinces; key is province name, value is its largest city
hashmap.set(provinces, 'North Holland', 'Amsterdam')
hashmap.set(provinces, 'South Holland', 'Rotterdam')
hashmap.set(provinces, ... | code_fim | medium | {
"lang": "python",
"repo": "abigailStev/learn_python_the_hard_way",
"path": "/ex39_test1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param data_frequency:
:param assets:
:param bar_count:
:return:
Available Frequencies
---------------------
'1m', '5m', '15m', '30m', '1h', '3h', '6h', '12h', '1D', '7D', '14D',
'1M'
"""
freq_match = re.match(r'([0-9].*)(m... | code_fim | hard | {
"lang": "python",
"repo": "darwinli/buylowsellhigh_catalyst",
"path": "/catalyst/exchange/bitfinex/bitfinex.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: darwinli/buylowsellhigh_catalyst path: /catalyst/exchange/bitfinex/bitfinex.py
nce': '{0:f}'.format(time.time() * 1000000),
# convert to string
'options': {}
}
if data is None:
payload_dict = payload_object
else:
payload_dic... | code_fim | hard | {
"lang": "python",
"repo": "darwinli/buylowsellhigh_catalyst",
"path": "/catalyst/exchange/bitfinex/bitfinex.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if is_list:
ohlc_bars = []
# We can to list candles from old to new
for candle in reversed(candles):
ohlc = ohlc_from_candle(candle)
ohlc_bars.append(ohlc)
ohlc_map[asset] = ohlc_bars
... | code_fim | hard | {
"lang": "python",
"repo": "darwinli/buylowsellhigh_catalyst",
"path": "/catalyst/exchange/bitfinex/bitfinex.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: getsentry/changes path: /migrations/versions/2191c871434_add_snapshot_model.py
"""Add snapshot model
Revision ID: 2191c871434
Revises: 19168fe64c41
Create Date: 2014-07-17 17:21:42.915797
"""
# revision identifiers, used by Alembic.
revision = '2191c871434'
down_revision = '19168fe64c41'
from... | code_fim | medium | {
"lang": "python",
"repo": "getsentry/changes",
"path": "/migrations/versions/2191c871434_add_snapshot_model.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> op.create_table(
'snapshot',
sa.Column('id', sa.GUID(), nullable=False),
sa.Column('project_id', sa.GUID(), nullable=False),
sa.Column('build_id', sa.GUID(), nullable=True),
sa.Column('status', sa.Enum(), server_default='0', nullable=False),
sa.ForeignKe... | code_fim | medium | {
"lang": "python",
"repo": "getsentry/changes",
"path": "/migrations/versions/2191c871434_add_snapshot_model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>nuisances['singleTopToTTbar'] = {
'name': 'singleTopToTTbar',
'skipCMS': 1,
'kind': 'weight',
'type': 'shape',
'samples': {
'top': [
'isSingleTop * 1.0816 + isTTbar',
'isSingleTop * 0.9184 + isTTbar']
}
}
## Top pT reweighting uncertainty
# nuisances['To... | code_fim | hard | {
"lang": "python",
"repo": "latinos/PlotsConfigurations",
"path": "/Configurations/VBSjjlnu/Full2018v6s5/conf_fit_v2/nuisances.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nuisances['eff_m'] = {
'name' : 'CMS_eff_m_2018',
'kind' : 'weight',
'type' : 'shape',
'samples' : dict((skey, id_syst_mu) for skey in mc),
'cuts': phase_spaces_tot_mu
}
nuisances['muonpt'] = {
'name' :... | code_fim | hard | {
"lang": "python",
"repo": "latinos/PlotsConfigurations",
"path": "/Configurations/VBSjjlnu/Full2018v6s5/conf_fit_v2/nuisances.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: latinos/PlotsConfigurations path: /Configurations/VBSjjlnu/Full2018v6s5/conf_fit_v2/nuisances.py
# # nuisances
# #FIXME: TO BE UPDATED FOR 2018!
# # name of samples here must match keys in samples.py
mc =["DY", "top", "VV", "VVV", "VBF-V", "top", "VBS", "Wjets"]
phase_spaces_boost = []
phase... | code_fim | hard | {
"lang": "python",
"repo": "latinos/PlotsConfigurations",
"path": "/Configurations/VBSjjlnu/Full2018v6s5/conf_fit_v2/nuisances.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from docopt import docopt
if __name__ == "__main__":
arguments = docopt(
__doc__,
version="1.0")
features_file = arguments["<features>"]
data_file = arguments["<data-bed>"]
output_file = arguments["<output-txt>"]
features = []
with open(features_file, 'r') as fh... | code_fim | hard | {
"lang": "python",
"repo": "jorenretel/selene",
"path": "/manuscript/case2/1_train_with_online_sampler/data/create_TF_intervals_file.py",
"mode": "spm",
"license": "BSD-3-Clause-Clear",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(data_file, 'r') as read_fh, \
open(output_file, 'w+') as write_fh:
for line in read_fh:
cols = line.strip().split('\t')
if cols[-1] not in only_TF_features:
continue
write_fh.write("{0}\t{1}\t{2}\n".format(
... | code_fim | hard | {
"lang": "python",
"repo": "jorenretel/selene",
"path": "/manuscript/case2/1_train_with_online_sampler/data/create_TF_intervals_file.py",
"mode": "spm",
"license": "BSD-3-Clause-Clear",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bilkitty/LearningOnTheSide path: /common/rollouts.py
import numpy as np
from timeit import default_timer as timer
from utils import RefreshScreen
from metrics import Metrics
from time import sleep
SCREEN_REFRESH_COUNT = 20
SCREEN_REFRESH_COUNT_EPOCHS = 50
def Train(envWrapper, agent, verbose... | code_fim | hard | {
"lang": "python",
"repo": "bilkitty/LearningOnTheSide",
"path": "/common/rollouts.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(headerText)
episodicMetrics = []
globalStart = timer()
for i in np.arange(agent.maxEpisodes):
epoch = 0
totalReward = 0
frames = []
done = False
state = envWrapper.Reset()
# Console update for progress on # completed rollouts
... | code_fim | hard | {
"lang": "python",
"repo": "bilkitty/LearningOnTheSide",
"path": "/common/rollouts.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Console update for individual rollout progress
if verbose and epoch % (agent.maxEpochs / SCREEN_REFRESH_COUNT_EPOCHS) == 0:
RefreshScreen(mode="human")
qv = agent.GetValue(state, action)
print(headerText)
print(f"Tra... | code_fim | hard | {
"lang": "python",
"repo": "bilkitty/LearningOnTheSide",
"path": "/common/rollouts.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for case, strS in enumerate(inputS):
S = list(strS)
flipCount = 0 #reset for each S in inputs
while not allHappy(S):
backCount = findBackCount(S)
frontPlus = findFrontPlus(S)
if frontPlus > 0:
#flip front +'s to -'s before the bigger flip
frontS = S[0:frontPlus:]
backS = S[fr... | code_fim | hard | {
"lang": "python",
"repo": "DaHuO/Supergraph",
"path": "/codes/CodeJamCrawler/16_0_2_neat/16_0_2_tkargul1_Revenge.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DaHuO/Supergraph path: /codes/CodeJamCrawler/16_0_2_neat/16_0_2_tkargul1_Revenge.py
#!/usr/bin/env python
__author__ = "Thomas Kargul"
def revenge():
numOfInput = int(raw_input()) # 1 <= T <= 100
inputS = [] #list of strings
for i in range(numOfInput):
inp = raw_input()
inputS.append(inp)... | code_fim | hard | {
"lang": "python",
"repo": "DaHuO/Supergraph",
"path": "/codes/CodeJamCrawler/16_0_2_neat/16_0_2_tkargul1_Revenge.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mss12138/Python-Crash-Course-Homework path: /chapter06/6-1.py
person = {
'first_name': 'zoctopus',
'last_n<|fim_suffix|>st_name'])
print(person['age'])
print(person['city'])<|fim_middle|>ame': 'zhang',
'age': 21,
'city': 'chengdu',
}
print(person['first_name'])
print(person['... | code_fim | medium | {
"lang": "python",
"repo": "mss12138/Python-Crash-Course-Homework",
"path": "/chapter06/6-1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>st_name'])
print(person['age'])
print(person['city'])<|fim_prefix|># repo: mss12138/Python-Crash-Course-Homework path: /chapter06/6-1.py
person = {
'first_name': 'zoctopus',
'last_name': 'zhang',
'age': 21,
'city': 'chengdu',<|fim_middle|>
}
print(person['first_name'])
print(person['... | code_fim | easy | {
"lang": "python",
"repo": "mss12138/Python-Crash-Course-Homework",
"path": "/chapter06/6-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.room = 4
def __repr__(self):
return "Welcome to Room 4. Use w to move to Room 2, or a to move to Room 3."
class Game:
def __init__(self):
name = input("What is your name, adventurer? ")
self.player = Player(name, 1)
def play_game... | code_fim | hard | {
"lang": "python",
"repo": "med10d/Code_Suggestions",
"path": "/adventure_Suggestions.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: med10d/Code_Suggestions path: /adventure_Suggestions.py
class Player:
def __init__(self, name, room):
self.name = name
self.room = room
self.moves = 0
# Your code works great for allowing the user to navigate to the different rooms in your adventure game. These commen... | code_fim | hard | {
"lang": "python",
"repo": "med10d/Code_Suggestions",
"path": "/adventure_Suggestions.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif move == "d".lower():
if room == room_2.room or room == room_4.room:
print("There's nowhere to go! Try a different direction.")
print("")
elif room == room_1.room:
room = room_2.room
... | code_fim | hard | {
"lang": "python",
"repo": "med10d/Code_Suggestions",
"path": "/adventure_Suggestions.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: harrym85/python_bootcamp path: /Variables.py
# Variables
# Basics types
# Operation on numbers
# Operation on string
<|fim_suffix|>
number1 = 10
number2 = 7
string1 = "hello"
# + - / * % ** //
print(number1 + number2)
print(number1 - number2)
print(number1 * number2)
print(number1 / number2)
... | code_fim | easy | {
"lang": "python",
"repo": "harrym85/python_bootcamp",
"path": "/Variables.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(number1 + number2)
print(number1 - number2)
print(number1 * number2)
print(number1 / number2)
print(number1 % number2)
print(number1 ** number2)
print(number1 // number2)<|fim_prefix|># repo: harrym85/python_bootcamp path: /Variables.py
# Variables
# Basics types
# Operation on numbers
# Operation ... | code_fim | medium | {
"lang": "python",
"repo": "harrym85/python_bootcamp",
"path": "/Variables.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>number1 = 10
number2 = 7
string1 = "hello"
# + - / * % ** //
print(number1 + number2)
print(number1 - number2)
print(number1 * number2)
print(number1 / number2)
print(number1 % number2)
print(number1 ** number2)
print(number1 // number2)<|fim_prefix|># repo: harrym85/python_bootcamp path: /Variables.py... | code_fim | easy | {
"lang": "python",
"repo": "harrym85/python_bootcamp",
"path": "/Variables.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.post(request, *args, **kwargs)
def get_success_url(self):
return reverse('charts')
deco_user=[all_account_permission]
@method_decorator(deco_user,name='dispatch')
class ChartsList(LoginRequiredMixin,ListView):
redirect_field_name = 'next'
login_url = reverse_la... | code_fim | hard | {
"lang": "python",
"repo": "kyomoeliezer/mtelemko",
"path": "/account-account-back/views.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kyomoeliezer/mtelemko path: /account-account-back/views.py
from django.shortcuts import render
from django.conf import settings
from django.core.files.storage import FileSystemStorage
from django.urls import reverse_lazy
from django.views.generic import CreateView,ListView,UpdateView,View,FormVie... | code_fim | hard | {
"lang": "python",
"repo": "kyomoeliezer/mtelemko",
"path": "/account-account-back/views.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wallravit/card-matching-game path: /api/repositories/user_repository.py
from logging import Logger
from typing import Optional
from api.models import UserModel
from api.schemas import user_schemas
from sqlalchemy.orm import Session
class UserRepository:
def __init__(self, logger: Logger) -... | code_fim | hard | {
"lang": "python",
"repo": "wallravit/card-matching-game",
"path": "/api/repositories/user_repository.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_user(self, db: Session, username: str) -> user_schemas.UserInDB:
return db.query(UserModel).filter(UserModel.username == username).first()<|fim_prefix|># repo: wallravit/card-matching-game path: /api/repositories/user_repository.py
from logging import Logger
from typing import Optiona... | code_fim | hard | {
"lang": "python",
"repo": "wallravit/card-matching-game",
"path": "/api/repositories/user_repository.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>\.com']
videoregex = []
liveregex = []<|fim_prefix|># repo: ArchiveTeam/NewsGrabber-Services path: /services/web__motors_dz_com.py
refresh = 43200
version = 20161106.01
<|fim_middle|>
urls = ['http://www.motors-dz.com/']
regex = [r'^https?:\/\/[^\/]*motors-dz | code_fim | medium | {
"lang": "python",
"repo": "ArchiveTeam/NewsGrabber-Services",
"path": "/services/web__motors_dz_com.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ArchiveTeam/NewsGrabber-Services path: /services/web__motors_dz_com.py
refresh = 43200
version = 20161106.01
<|fim_suffix|>\.com']
videoregex = []
liveregex = []<|fim_middle|>
urls = ['http://www.motors-dz.com/']
regex = [r'^https?:\/\/[^\/]*motors-dz | code_fim | medium | {
"lang": "python",
"repo": "ArchiveTeam/NewsGrabber-Services",
"path": "/services/web__motors_dz_com.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>regex = [r'^https?:\/\/[^\/]*motors-dz\.com']
videoregex = []
liveregex = []<|fim_prefix|># repo: ArchiveTeam/NewsGrabber-Services path: /services/web__motors_dz_com.py
refresh = 43200
version = 20161106.01
<|fim_middle|>
urls = ['http://www.motors-dz.com/']
| code_fim | easy | {
"lang": "python",
"repo": "ArchiveTeam/NewsGrabber-Services",
"path": "/services/web__motors_dz_com.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rion5/Python_Gold_Badge_Challenges path: /challenge_1/menu.py
class MenuItem:
def __init__(self, meal_number: int, meal_name: str, pri<|fim_suffix|> self.description = description
self.ingredients = ingredients<|fim_middle|>ce : float, description: str, ingredients: list):
... | code_fim | medium | {
"lang": "python",
"repo": "Rion5/Python_Gold_Badge_Challenges",
"path": "/challenge_1/menu.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.description = description
self.ingredients = ingredients<|fim_prefix|># repo: Rion5/Python_Gold_Badge_Challenges path: /challenge_1/menu.py
class MenuItem:
def __init__(self, meal_number: int, meal_name: str, price : float, description: str, ingredients: list):
self.meal_n... | code_fim | medium | {
"lang": "python",
"repo": "Rion5/Python_Gold_Badge_Challenges",
"path": "/challenge_1/menu.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jaredasch/Softdev-Spring2019 path: /06_mongo/restaurants.py
# Jared Asch
# Softdev2 pd06
# K06 -- Yummy Mongo Py
# 2019-03-01
import pymongo
<|fim_suffix|> return list(collection.find({"address.zip": z}))
def findZipGrade(zip, grade):
return list(collection.find({"address.zip": zip, "gr... | code_fim | hard | {
"lang": "python",
"repo": "jaredasch/Softdev-Spring2019",
"path": "/06_mongo/restaurants.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def findZipGrade(zip, grade):
return list(collection.find({"address.zip": zip, "grades.0.grade": grade}))
def findZipScore(zip, score):
return list(collection.find({"address.zip": zip, "grades.0.score": {"$lt": score}}))
print(findBorough("Manhattan"))
print(findZip("10462"))
print(findZipGrade(... | code_fim | medium | {
"lang": "python",
"repo": "jaredasch/Softdev-Spring2019",
"path": "/06_mongo/restaurants.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(findBorough("Manhattan"))
print(findZip("10462"))
print(findZipGrade("10462", "A"))
print(findZipScore("10462", 10))<|fim_prefix|># repo: jaredasch/Softdev-Spring2019 path: /06_mongo/restaurants.py
# Jared Asch
# Softdev2 pd06
# K06 -- Yummy Mongo Py
# 2019-03-01
import pymongo
SERVER_IP = "142.9... | code_fim | medium | {
"lang": "python",
"repo": "jaredasch/Softdev-Spring2019",
"path": "/06_mongo/restaurants.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Crinibus/adventofcode path: /2021/dec3/dec3.py
import pathlib
from collections import Counter
def get_input():
root_path = pathlib.Path(__file__).parent.absolute()
with open(f"{root_path}/input.txt", "r") as input_file:
input_raw = input_file.readlines()
return [line.strip... | code_fim | hard | {
"lang": "python",
"repo": "Crinibus/adventofcode",
"path": "/2021/dec3/dec3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return bits_counter.most_common()[-1][0]
def get_answer_part_1(input_data):
num_bits = len(input_data[0])
gamma_rate_binary = ""
for i in range(num_bits):
gamma_rate_binary += get_most_common_bit(input_data, i)
gamma_rate = int(gamma_rate_binary, 2)
epsilon_rate_binar... | code_fim | medium | {
"lang": "python",
"repo": "Crinibus/adventofcode",
"path": "/2021/dec3/dec3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #print("args:",request.args.get)
#email = request.args.get('email')
print("email:",email)
return UserModel.get_by_email(email)
'''
def get(self):
return {"users": [x.json() for x in UserModel.get_list()]}
def post(self):
print(r... | code_fim | medium | {
"lang": "python",
"repo": "viswsank/pyrest2",
"path": "/Resources/UserResource.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: viswsank/pyrest2 path: /Resources/UserResource.py
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 4 10:50:08 2021
@author: hp
"""
from flask_restful import Resource, request
from Models.User import UserModel
class UserResource(Resource):
<|fim_suffix|> #print("args:",request.... | code_fim | medium | {
"lang": "python",
"repo": "viswsank/pyrest2",
"path": "/Resources/UserResource.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emilywz/newCoderFollow path: /signal.py
'''
信号测量的结果包括测量编号和测量值。存在信号测量结果丢弃及测量结果重复的情况。
1.测量编号不连续的情况,认为是测量结果丢弃。对应测量结果丢弃的情况,需要进行插值操作以更准确的评估信号。
采用简化的一阶插值方法,由丢失的测量结果两头的测量值算出两者中间的丢失值。
假设第M个测量结果的测量值为A,第N个测量结果的测量值为B。则需要进行(N-M-1)个测量结果的插值处理。
进行一阶线性插值估计的第N+i个测量结果的测量值为A+( (B-A)/(N-M) )*i (注:N的编号比M大。)
例如:只有... | code_fim | hard | {
"lang": "python",
"repo": "emilywz/newCoderFollow",
"path": "/signal.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>import math
def insertNum(M, N, signalList):
last_order,last_ordValue=signalList[-1][0],signalList[-1][1]
step=math.trunc((N-last_ordValue)/(M-last_order))
for j in range(1,M-last_order):
signalList.append([last_order+j,last_ordValue+step*j])
def signalOP():
group = input()
g... | code_fim | hard | {
"lang": "python",
"repo": "emilywz/newCoderFollow",
"path": "/signal.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> solmu = self.trie.loyda_seuraava_solmu([Savel(62)])
self.assertEqual(solmu, None)
def test_lisaa_b_ja_a_trieen_kasvattaa_b_maaraa(self):
aanet = [71, 69]
self.trie.lisaa_aanet_trieen(aanet)
self.assertEqual(self.trie.juurisolmu.lapset[1].maara, 2)
def test... | code_fim | hard | {
"lang": "python",
"repo": "Aikamoine/markovin-ketju-saveltaja",
"path": "/src/tests/trie_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aikamoine/markovin-ketju-saveltaja path: /src/tests/trie_test.py
import unittest
from trie.trie import Trie
from musiikkiluokat.aani import Aani
from musiikkiluokat.savel import Savel
class TrieTest(unittest.TestCase):
def setUp(self):
self.trie = Trie(4)
self.aani_a = Aani... | code_fim | medium | {
"lang": "python",
"repo": "Aikamoine/markovin-ketju-saveltaja",
"path": "/src/tests/trie_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_lisaa_b_ja_a_trieen_kasvattaa_b_maaraa(self):
aanet = [71, 69]
self.trie.lisaa_aanet_trieen(aanet)
self.assertEqual(self.trie.juurisolmu.lapset[1].maara, 2)
def test_lisaa_b_ja_a_trieen_lisaa_a_haaran(self):
self.assertEqual(len(self.trie.juurisolmu.lapset... | code_fim | hard | {
"lang": "python",
"repo": "Aikamoine/markovin-ketju-saveltaja",
"path": "/src/tests/trie_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sevilaybayatli/PYTHS19 path: /Ex14.py
#Exercise Question 4: Given a list iterate it and count the occurrence of each element and create a dictionary to show the count of each element
#Origigal list [11, 45, 8, 11, 23, 45, 23, 45, 89]
#Printing count of each item {11: 2, 45: 3, 8: 1, 23: 2, 89:... | code_fim | easy | {
"lang": "python",
"repo": "sevilaybayatli/PYTHS19",
"path": "/Ex14.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>origList= [11, 45, 8, 11, 23, 45, 23, 45, 89]
countDict=dict()
for i in origList:
countDict[i]=origList.count(i)
print(countDict)<|fim_prefix|># repo: sevilaybayatli/PYTHS19 path: /Ex14.py
#Exercise Question 4: Given a list iterate it and count the occurrence of each element and create a dictionary t... | code_fim | easy | {
"lang": "python",
"repo": "sevilaybayatli/PYTHS19",
"path": "/Ex14.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pleatcher/Projects path: /ScheduleGenerator/code/blocks/block.py
"""
Base class for data structures
"""
from tools.xl import read_dframe
class Block:
def __init__(self, *args, **kwargs):
# set properties
# named args first
for p in self.props_v:
val = kwar... | code_fim | medium | {
"lang": "python",
"repo": "pleatcher/Projects",
"path": "/ScheduleGenerator/code/blocks/block.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def prepare(cls, all_props):
cls.get_props(all_props[cls.__name__])
@classmethod
def aggregate(cls, *args):
key = args[0]
obj = dict(zip(cls.props_v, args))
return (key, obj)
@classmethod
def pcs_input(cls, **kwargs):
#from... | code_fim | hard | {
"lang": "python",
"repo": "pleatcher/Projects",
"path": "/ScheduleGenerator/code/blocks/block.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
Example Explanation
Explanation 1:
If we sort the sub-array A1, A2, then the whole array A gets sorted.
Explanation 2:
A is already sorted.
"""
class Solution:
# @param A : list of integers
# @return a list of integers
def subUnsort(self, A):
n = len(A)
left_index = -1
right_inde... | code_fim | hard | {
"lang": "python",
"repo": "arnabs542/Data-Structures-And-Algorithms",
"path": "/Sorting/Maximum Unsorted Subarray.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.