code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
from django.test import TestCase, SimpleTestCase
from django.urls import reverse, resolve
from .views import profile, order_history
""" Url Testing """
class TestUrls(SimpleTestCase):
def test_profile_resolves(self):
url = reverse('profile')
self.assertEqual(resolve(url).func, profile)
def t... | normal | {
"blob_id": "5dc6b54357df87077d8159192cd52697b2616db8",
"index": 9186,
"step-1": "<mask token>\n\n\nclass TestUrls(SimpleTestCase):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass TestUrls(SimpleTestCase):\n\n def test_profile_resolves(self):\n url = reverse('profile')\n ... | [
1,
2,
3,
4,
5
] |
import sys
a = 3
b = 4
c = 5.66
d = 8.0
e = complex(c,d)
f = complex(float(a),float(b))
print("a is type:",type(a))
print("c is type:",type(c))
print("e is type:",type(e))
print(a + b)
print(d / c)
print(b / a)
#2个除约成整型
print(b // a)
print(e)
print(e + f)
print(sys.float_info) | normal | {
"blob_id": "2876c9f8db0395143b165b855b22e364e3cc8121",
"index": 9008,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('a is type:', type(a))\nprint('c is type:', type(c))\nprint('e is type:', type(e))\nprint(a + b)\nprint(d / c)\nprint(b / a)\nprint(b // a)\nprint(e)\nprint(e + f)\nprint(sys.float_... | [
0,
1,
2,
3,
4
] |
# -*- encoding: utf-8 -*-
"""
Created by eniocc at 11/10/2020
"""
import ctypes
from py_dss_interface.models.Base import Base
class MonitorsS(Base):
"""
This interface can be used to read/write certain properties of the active DSS object.
The structure of the interface is as follows:
CStr Monit... | normal | {
"blob_id": "f6f0dcb806fbc1e14c0907dd500fdc6a609a19f7",
"index": 5598,
"step-1": "<mask token>\n\n\nclass MonitorsS(Base):\n <mask token>\n <mask token>\n <mask token>\n\n def monitors_write_name(self, argument) ->str:\n \"\"\"Sets the active Monitor object by name.\"\"\"\n result = cty... | [
3,
4,
6,
7,
9
] |
def say_hi(argument):
return f"Hello {argument}"
def call_func(some_func, argument):
return some_func(argument)
def main(argument):
"""docstring"""
return call_func(say_hi, argument)
if __name__ == "__main__":
print(main(1)) | normal | {
"blob_id": "2a3c3112122dee5574a1569155287ea3e5f8c7b2",
"index": 6120,
"step-1": "<mask token>\n\n\ndef call_func(some_func, argument):\n return some_func(argument)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef call_func(some_func, argument):\n return some_func(argument)\n\n\ndef main(argument):... | [
1,
2,
3,
4,
5
] |
"""
Faça um algoritmo que solicita ao usuário as notas de três provas. Calcule a média aritmética e
informe se o aluno foi Aprovado ou Reprovado (o aluno é considerado aprovado com a média igual ou superior a 6).
"""
nota1 = float(input("Digite sua primeira nota: "))
nota2 = float(input("Digite sua segunda nota:... | normal | {
"blob_id": "033d1b39dd3ebaa81c8c6c52386909acf076ef47",
"index": 2011,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif media >= 6:\n print('Parabéns!! Você foi aprovado.')\nelse:\n print('Que pena!! Você foi reprovado.')\n",
"step-3": "<mask token>\nnota1 = float(input('Digite sua primeira nota... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
# -*-coding:utf-8-*-
__author__ = '李晓波'
from linux import sysinfo
#调用相应收集处理函数
def LinuxSysInfo():
#print __file__
return sysinfo.collect()
def WindowsSysInfo():
from windows import sysinfo as win_sysinfo
return win_sysinfo.collect()
| normal | {
"blob_id": "30a2e4aa88b286179e2870205e90fab4a7474e12",
"index": 2969,
"step-1": "<mask token>\n\n\ndef LinuxSysInfo():\n return sysinfo.collect()\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef LinuxSysInfo():\n return sysinfo.collect()\n\n\ndef WindowsSysInfo():\n from windows import sysinfo ... | [
1,
2,
3,
4,
5
] |
from os import getenv
config_env = {'api_port': int(getenv('API_PORT')), 'psg_uri': getenv('PSG_URI')
}
| normal | {
"blob_id": "21dd3d1deb00e9bc09803d01f1c05673ea8d25d2",
"index": 3771,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nconfig_env = {'api_port': int(getenv('API_PORT')), 'psg_uri': getenv('PSG_URI')\n }\n",
"step-3": "from os import getenv\nconfig_env = {'api_port': int(getenv('API_PORT')), 'psg_uri'... | [
0,
1,
2
] |
# from suiron.core.SuironIO import SuironIO
# import cv2
# import os
# import time
# import json
# import numpy as np
# suironio = SuironIO(serial_location='/dev/ttyUSB0', baudrate=57600, port=5050)
# if __name__ == "__main__":
# while True:
# # suironio.record_inputs()
# print('turn90')
# suiro... | normal | {
"blob_id": "bf8ffe603b7c1e90deed6a69500ea5b7671e7270",
"index": 879,
"step-1": "<mask token>\n\n\ndef visualize_data(filename, width=72, height=48, depth=3, cnn_model=None):\n \"\"\"\n When cnn_model is specified it'll show what the cnn_model predicts (red)\n as opposed to what inputs it actually recei... | [
1,
2,
3,
4,
5
] |
import random
import math
import time
import pygame
pygame.init()
scr = pygame.display.set_mode((700,700))
enemies = []
#music = pygame.mixer.music.load('ENERGETIC CHIPTUNE Thermal - Evan King.mp3')
#pygame.mixer.music.play(-1)
hit = []
class Player:
def __init__(self):
self.x = 275
sel... | normal | {
"blob_id": "54e04d740ef46fca04cf4169d2e7c05083414bd8",
"index": 11,
"step-1": "<mask token>\n\n\nclass Player:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Bullet:\n\n def __init__(self, color):\n self.x = 0\n self.y = 0\n self.angle = 0\n self.color = color\n\... | [
14,
17,
19,
20,
21
] |
#rules used for pattern matching
# #1. x='[abc]' either a,b or c
#eg:
# import re
# x="[abc]"
# matcher=re.finditer(x,"abt cq5kz")
# for match in matcher:
# print(match.start())
# print(match.group())
#2. x='[^abc]' except abc
#eg:
# import re
# x="[^abc]"
# matcher=re.finditer(x,"abt cq5kz")
# for match in ... | normal | {
"blob_id": "1ddc261cf174c109583fd0ead1f537673d29090a",
"index": 1433,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor match in matcher:\n print(match.start())\n print(match.group())\n",
"step-3": "<mask token>\nx = '[a-zA-Z]'\nmatcher = re.finditer(x, 'abtABIkz')\nfor match in matcher:\n p... | [
0,
1,
2,
3,
4
] |
'''
@author: Victor Barrera Burgos
Created on 09 Feb 2014
Description: This script permits the obtention of the
methylation profile of a CpGRegion indicating the
methylation status of each CpG dinucleotide.
Addition on 02 March 2014
Description: permits the obtention of the
methylation profile of the whole genome usi... | normal | {
"blob_id": "67509ce426fd572b22d5059d98e5439e87cdc591",
"index": 4541,
"step-1": "'''\n@author: Victor Barrera Burgos\nCreated on 09 Feb 2014\nDescription: This script permits the obtention of the\nmethylation profile of a CpGRegion indicating the \nmethylation status of each CpG dinucleotide.\n\nAddition on 02 ... | [
0
] |
'''''''''''''''''''''''''''''
> Filename: lv6.py
> Author: Kadrick, BoGwon Kang
> Created at: 2021/10/11 16:07
> Description: zip
'''''''''''''''''''''''''''''
import zipfile
import re
# open zipfile
zfile = zipfile.ZipFile('./channel.zip')
# check list
'''
print(zfile.namelist())
print(zfile.read("readme.txt"))
prin... | normal | {
"blob_id": "b1fe7e318c361930c8ad00758bcb86597fd8f3bd",
"index": 2567,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n answer = zfile.read(nothing).decode('utf-8')\n comments += zfile.getinfo(nothing).comment.decode('utf-8')\n print(answer)\n findRet = re.findall(target, answer)\... | [
0,
1,
2,
3,
4
] |
import cv2
import numpy as np
frameWidth = 640
frameHeight = 480
# capturing Video from Webcam
cap = cv2.VideoCapture(0)
cap.set(3, frameWidth)
cap.set(4, frameHeight)
cap.set(10, 150)
myColors = [[20,40,40,70,255,255],
[100,169,121,135,255,255],
[0, 90, 90, 41, 255, 255]]
color_value = [[25... | normal | {
"blob_id": "836c1d2083d18c68fe551278d2df4155edc64c8c",
"index": 5298,
"step-1": "<mask token>\n\n\ndef find_color(img, color_value, myColors):\n hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)\n count = 0\n new_points = []\n for color in myColors:\n lower = np.array(color[0:3])\n upper = np... | [
3,
4,
5,
6,
7
] |
# myapp/serializers.py
from rest_framework import serializers
from rest_framework.authtoken.models import Token
from .models import *
# Serializers define the API representation.
class GeneralSerializer(serializers.ModelSerializer):
class Meta:
model = None
fields = '__all__'
class V2OfUsersSeri... | normal | {
"blob_id": "44cbe1face91d3ac7edcd93d0b470bce90c8b674",
"index": 2916,
"step-1": "<mask token>\n\n\nclass MeasurementsSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Measurements\n fields = '__all__'\n <mask token>\n\n\nclass CountSerializer(serializers.Serializer):\n ... | [
9,
10,
11,
12,
15
] |
import unittest
from collections import Counter
class Solution(object):
def findOriginalArray(self, changed):
"""
:type changed: List[int]
:rtype: List[int]
"""
n = len(changed)
if n % 2 != 0:
return []
freq = Counter(changed)
changed.so... | normal | {
"blob_id": "d5acda0d5d066d381a7f6310eb4fe6280d7e84de",
"index": 5309,
"step-1": "<mask token>\n\n\nclass TestSolution(unittest.TestCase):\n\n def test_findOriginalArray(self):\n solution = Solution()\n self.assertEqual(solution.findOriginalArray([1, 3, 4, 2, 6, 8]), [1,\n 3, 4])\n\n\... | [
2,
3,
5,
6
] |
# -*- encoding: utf-8 -*-
# @Version : 1.0
# @Time : 2018/8/29 9:59
# @Author : wanghuodong
# @note : 生成一个简单窗口
import sys
from PyQt5.QtWidgets import QApplication, QWidget
if __name__ == '__main__':
'''所有的PyQt5应用必须创建一个应用(Application)对象。sys.argv参数是一个来自命令行的参数列表。Python脚本可以在shell中运行'''
app = QApplic... | normal | {
"blob_id": "6ff300bbd7866466d1992445e46c5ee54f73d0d7",
"index": 9167,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n \"\"\"所有的PyQt5应用必须创建一个应用(Application)对象。sys.argv参数是一个来自命令行的参数列表。Python脚本可以在shell中运行\"\"\"\n app = QApplication(sys.argv)\n \"\"\"Qwidget组件是PyQt5中所有用户... | [
0,
1,
2,
3
] |
import shell
def executeUpgrade():
shell.executeCommand('pkg upgrade')
def executeInstall(pkg_name):
shell.executeCommand('pkg install ' + pkg_name)
def executeRemove(pkg_name):
shell.executeCommand('pkg remove ' + pkg_name)
shell.executeCommand('pkg autoremove')
def executeFindByName(name):
... | normal | {
"blob_id": "db55a603615c7d896569ada84f3110dd6c0ce45f",
"index": 1250,
"step-1": "<mask token>\n\n\ndef executeUpgrade():\n shell.executeCommand('pkg upgrade')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef executeUpgrade():\n shell.executeCommand('pkg upgrade')\n\n\n<mask token>\n\n\ndef execute... | [
1,
2,
3,
4,
5
] |
from PyQt5.QtWidgets import *
import sys
import math
Data = ''
class Button:
def __init__(self, text, results):
self.b = QPushButton(str(text))
self.text = text
self.results = results
self.b.clicked.connect(lambda: self.handleInput(
self.text)) # Important because we ... | normal | {
"blob_id": "b08cface601ee07125090f3ae03a3120974688f2",
"index": 8765,
"step-1": "<mask token>\n\n\nclass Widget2:\n\n def setup(self, MainWindow, res):\n self.widget = QWidget()\n self.grid = QGridLayout()\n self.results = QLineEdit()\n self.results.setText(res)\n row = 3\n... | [
8,
9,
11,
13,
17
] |
# -*- coding: utf-8 -*-
"""
Animation practical output
The code that follows builds on the "Communications.py" file
Additional code that follows has in part been modified from that of
https://www.geog.leeds.ac.uk/courses/computing/practicals/python/agent-framework/part8/index.html
https://www.geog.leeds.ac.uk/courses... | normal | {
"blob_id": "4ea266d4f4c18efbba4204d7301652f8966c18a5",
"index": 9724,
"step-1": "<mask token>\n\n\ndef gen_function(b=[0]):\n a = 0\n global carry_on\n while (a < 100) & carry_on:\n yield a\n a = a + 1\n\n\n<mask token>\n",
"step-2": "<mask token>\nwith open('in.txt', newline='') as ras... | [
1,
3,
4,
5,
6
] |
speak = 'speak'
def hacker():
try:
raise speak # go to hacker's except
print 'not reached'
except speak:
print 'Hello world!'
raise speak # go to primate's except
def primate():
try:
hacker()
print 'not reached'
except speak:
... | normal | {
"blob_id": "644d0a0d88f1a051e004d271359dcc3df855bd77",
"index": 9020,
"step-1": "speak = 'speak'\n\ndef hacker():\n try:\n raise speak # go to hacker's except \n print 'not reached'\n except speak:\n print 'Hello world!'\n raise speak # go to primate's... | [
0
] |
# Benthic Parameters - USEPA OPP defaults from EXAMS
benthic_params = {
"depth": 0.05, # benthic depth (m)
"porosity": 0.65, # benthic porosity
"bulk_density": 1, # bulk density, dry solid mass/total vol (g/cm3)
"froc": 0, # benthic organic carbon fraction
"doc": 5, # benthic dissolved organic ... | normal | {
"blob_id": "5890525b16b42578ac06e7ab2170c5613feea0a5",
"index": 6494,
"step-1": "<mask token>\n\n\ndef partition_benthic(reach, runoff, runoff_mass, erosion_mass):\n from .parameters import soil, stream_channel, benthic\n try:\n reach = self.region.flow_file.fetch(reach)\n q, v, l = reach.q,... | [
1,
3,
4,
5,
6
] |
from adventurelib import *
from horror import *
from dating import *
from popquiz import *
from comedy import *
from island import *
start()
| normal | {
"blob_id": "8a37299154aded37147e1650cbf52a5cdf7d91da",
"index": 4225,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nstart()\n",
"step-3": "from adventurelib import *\nfrom horror import *\nfrom dating import *\nfrom popquiz import *\nfrom comedy import *\nfrom island import *\nstart()\n",
"step-4":... | [
0,
1,
2
] |
""" Compiled: 2020-09-18 10:38:52 """
#__src_file__ = "extensions/AppWorkspaceTools/etc/FAppWorkspaceDesignerNodes.py"
""" Compiled: 2018-06-07 17:06:19 """
#__src_file__ = "extensions/AppWorkspaceTools/etc/FAppWorkspaceDesignerNodes.py"
import acm
import FUxCore
import Contracts_AppConfig_Messages_AppWorkspace as Ap... | normal | {
"blob_id": "f80de2b069cf1dee2e665556262c6e84ce04b208",
"index": 1244,
"step-1": "<mask token>\n\n\nclass MainViewNode(NodeBase):\n <mask token>\n\n def Label(self):\n return 'Main View'\n <mask token>\n\n\nclass DockSectionNode(NodeBase):\n\n def __init__(self, label, icon, contents, settings... | [
15,
37,
38,
44,
48
] |
# Copyright 2021 The JAX Authors.
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | normal | {
"blob_id": "79c8e87e1d247eef8dd1ca8e307bbe6d25bf48e2",
"index": 8172,
"step-1": "<mask token>\n\n\nclass PickleTest(jtu.JaxTestCase):\n\n def testPickleOfDeviceArray(self):\n x = jnp.arange(10.0)\n s = pickle.dumps(x)\n y = pickle.loads(s)\n self.assertArraysEqual(x, y)\n s... | [
6,
9,
10,
11,
13
] |
from django.urls import path
from jobscrapper.views import *
urlpatterns = [
path('', home_vacancies_view, name="vacancy-home"),
path('list/', vacancies_view, name="vacancy"),
] | normal | {
"blob_id": "3ee20391d56d8c429ab1bd2f6b0e5b261721e401",
"index": 7965,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', home_vacancies_view, name='vacancy-home'), path(\n 'list/', vacancies_view, name='vacancy')]\n",
"step-3": "from django.urls import path\nfrom jobscrapper.vie... | [
0,
1,
2,
3
] |
from Crypto.PublicKey import DSA
from Crypto.Signature import DSS
from Crypto.Hash import SHA256
import os
import time
kB = 1024 # 1kB
with open('small_file.txt', 'wb') as f:
f.write(os.urandom(kB))
mB = 10485760 # 1GB
with open('large_file.txt', 'wb') as f:
f.write(os.urandom(mB))
Begin = time.time()
key = ... | normal | {
"blob_id": "d24bbfc3587a2a79891a11e00ec865498c01c286",
"index": 2101,
"step-1": "<mask token>\n\n\ndef DSA_2048(filename, key):\n with open(filename, 'rb') as f:\n message = f.read()\n hash_obj = SHA256.new(message)\n signer = DSS.new(key, 'fips-186-3')\n signature = signer.sign(h... | [
1,
2,
3,
4,
5
] |
from flask import render_template, request, current_app
from . import main
from .. import db, cache
from ..models import Content
from ..utils import make_cache_key
import requests
@main.route('/')
def index():
return render_template("templates/index.html")
@main.route('/link')
@cache.cached(key_prefix=make_cach... | normal | {
"blob_id": "c4096cfae7182875a79ba7837187cd94b4379922",
"index": 1100,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@main.route('/link')\n@cache.cached(key_prefix=make_cache_key, timeout=60)\ndef get_link():\n url = request.args.get('url')\n params = {'video': True, 'audio': True, 'screenshot... | [
0,
1,
2,
3,
4
] |
import argparse
from train import train
from test import infer
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--mode', type=str, default='train',
help='could be either infer or train')
parser.add_argument('--model_dir', type=str, default='model',
... | normal | {
"blob_id": "f0fa85f240b74b003ade767ffe8642feacdfaa32",
"index": 5807,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n parser = argparse.ArgumentParser()\n parser.add_argument('--mode', type=str, default='train', help=\n 'could be either infer or train')\n pars... | [
0,
1,
2,
3
] |
from django.db import models
#from publicservants import models
from django.utils.encoding import smart_unicode
# Create your models here.
class Score(models.Model):
#score ID - publicservant ID plus score
#sID = models.ManyToOneRel(field=PublicServant.psID)
#PS Score at time t
pst = models.Inte... | normal | {
"blob_id": "8c166dd4cb091dcd2d80b5ae3085b5dee77564e0",
"index": 1227,
"step-1": "<mask token>\n\n\nclass Score(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask t... | [
1,
2,
3,
4,
5
] |
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from typing import List
from sqlalchemy.sql.functions import current_date, current_user
from db.session import get_db
from db.models.jobs import Job
from schemas.jobs import JobCreate, ShowJob
from db.repository.jobs impo... | normal | {
"blob_id": "e8092faed22607f9c8f18a79709022037ff647bf",
"index": 9625,
"step-1": "<mask token>\n\n\n@router.post('/create-job', response_model=ShowJob)\ndef create_job(job: JobCreate, db: Session=Depends(get_db), current_user:\n User=Depends(get_current_user_from_token)):\n owner_id = current_user.id\n ... | [
4,
5,
6,
7,
8
] |
# -*- coding: utf-8 -*-
"""
current_models - library of ionic current models implemented in Python
Created on Mon Apr 10 16:30:04 2017
@author: Oliver Britton
"""
import os
import sys
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
import seaborn as sns
" Voltage clamp generator function... | normal | {
"blob_id": "012ab947f7a2c9d44f54464b3e477582ffcf3d77",
"index": 5589,
"step-1": "<mask token>\n\n\ndef nav17vw(Y, t, voltage_clamp_func, voltage_clamp_params):\n \"\"\" Human Nav 1.7 from Vasylyev Waxman \"\"\"\n v = voltage_clamp_func(t, voltage_clamp_params)\n m = Y[0]\n h = Y[1]\n alpha_m = 10... | [
12,
13,
14,
15,
18
] |
# Generated by Django 3.2.3 on 2021-05-29 16:37
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('logi... | normal | {
"blob_id": "6285d1665bacbff746f44f42ce65981f937fff64",
"index": 4189,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
import datetime,os
def GetDatetimeFromMyFormat(l):
# l = "2018-5-17 19:18:45"
l_words = l.split()
l_days = l_words[0].split('-')
l_times = l_words[1].split(':')
out = datetime.datetime(int(l_days[0]),int(l_days[1]),int(l_days[2]),int(l_times[0]),int(l_times[1]),int(l_times[2]))
return out
| normal | {
"blob_id": "6767302869d73d041e2d7061722e05484d19f3e0",
"index": 4752,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef GetDatetimeFromMyFormat(l):\n l_words = l.split()\n l_days = l_words[0].split('-')\n l_times = l_words[1].split(':')\n out = datetime.datetime(int(l_days[0]), int(l_da... | [
0,
1,
2,
3
] |
#! /usr/bin/env python
from game_calc import *
def game(screen, clock):
running = True
time = 0
WHITE = (255,255,255)
BLUE = (0,0,205)
upper_border = pygame.Rect(12,44,1000,20)
right_border = pygame.Rect(992,60,20,648)
left_border = pygame.Rect(12,60,20,648)
down_border = pygame.Rect(12... | normal | {
"blob_id": "83815acb0520c1f8186b0b5c69f8597b1b6a552a",
"index": 8051,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef game(screen, clock):\n running = True\n time = 0\n WHITE = 255, 255, 255\n BLUE = 0, 0, 205\n upper_border = pygame.Rect(12, 44, 1000, 20)\n right_border = pygam... | [
0,
1,
2,
3
] |
import socket
from threading import Thread
from ast import literal_eval
clients = {}
addresses = {}
host = '127.0.0.1'
port = 5678
active = []
addr = (host, port)
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server.bind(addr)
groups = []
def broadcast(msg, prefix=""): # prefix is for name identificatio... | normal | {
"blob_id": "9f02313b6f91f83e3a8b4af8d9447b1d8f3558f6",
"index": 4430,
"step-1": "<mask token>\n\n\ndef broadcast(msg, prefix=''):\n \"\"\"Broadcasts a message to all the clients.\"\"\"\n for sock in clients:\n sock.send(bytes(prefix, 'utf8') + msg)\n\n\ndef broadcast_file(msg):\n for sock in cli... | [
5,
6,
7,
8,
9
] |
#!/usr/bin/env python
#python
import os
import math
import sys
import time
import re
import cPickle
import random
#eman
try:
import EMAN
except:
print "EMAN module did not get imported"
#scipy
import numpy
#appion
from appionlib import appionScript
from appionlib import appiondata
from appionlib import apDisplay
fro... | normal | {
"blob_id": "49887a3914fa0021a03d89721aa47cded95d54f6",
"index": 9605,
"step-1": "#!/usr/bin/env python\n\n#python\nimport os\nimport math\nimport sys\nimport time\nimport re\nimport cPickle\nimport random\n#eman\ntry:\n\timport EMAN\nexcept:\n\tprint \"EMAN module did not get imported\"\n#scipy\nimport numpy\n#... | [
0
] |
import inspect
import json
import os
import re
import urllib.request
from functools import wraps
from ..errors import NotFoundError
class API:
def __init__(self, base_url, version=1):
self.BASE = base_url or 'https://api.starlist.pro/v{}'.format(version)
self.PROFILE = self.BASE + '/player'
... | normal | {
"blob_id": "3f3db7e8813f49fe0265e110236b6dc4fed6cd1b",
"index": 7214,
"step-1": "<mask token>\n\n\nclass API:\n\n def __init__(self, base_url, version=1):\n self.BASE = base_url or 'https://api.starlist.pro/v{}'.format(version)\n self.PROFILE = self.BASE + '/player'\n self.CLUB = self.BA... | [
2,
3,
4,
5,
6
] |
# Generated by Django 2.0.4 on 2018-06-09 05:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('lists', '0004_auto_20180608_1835'),
]
operations = [
migrations.AlterModelOptions(
name='todo',
options={'ordering':... | normal | {
"blob_id": "b27913d2cd29f174d79652af6da2846e397373fc",
"index": 1549,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('lists', '00... | [
0,
1,
2,
3,
4
] |
# Jython/Walk_comprehension.py
import os
restFiles = [os.path.join(d[0], f) for d in os.walk(".")
for f in d[2] if f.endswith(".java") and
"PythonInterpreter" in open(os.path.join(d[0], f)).read()]
for r in restFiles:
print(r)
| normal | {
"blob_id": "61085eecc8fd0b70bc11e5a85c3958ba3b905eaf",
"index": 3118,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor r in restFiles:\n print(r)\n",
"step-3": "<mask token>\nrestFiles = [os.path.join(d[0], f) for d in os.walk('.') for f in d[2] if f\n .endswith('.java') and 'PythonInterpreter... | [
0,
1,
2,
3,
4
] |
import numpy as np
#read data from file
#read data from file
theFile = open('datapri.txt','r')
temp = []
#n la so phan tu cua mang mau
n = int(theFile.readline().format())
for val in theFile.read().split():
temp.append(int(val))
theFile.close()
arr = np.random.rand(n,n)
k = 0
for i in range(n):
for j in range... | normal | {
"blob_id": "aa801bc8398cdf69a15d04188dd8429e4624150e",
"index": 5574,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor val in theFile.read().split():\n temp.append(int(val))\ntheFile.close()\n<mask token>\nfor i in range(n):\n for j in range(n):\n arr[i, j] = temp[k]\n k = k + 1\n<... | [
0,
1,
2,
3,
4
] |
import datetime
from flask import request
from flask_babel import _
from markupsafe import escape
from app import app
from app.data_access.audit_log_controller import create_audit_log_confirmation_entry
from app.data_access.user_controller import user_exists, create_user
from app.data_access.user_controller_errors im... | normal | {
"blob_id": "cddb16a305f74eb1a3f2854208f8508c4a7a8953",
"index": 649,
"step-1": "<mask token>\n\n\nclass UnlockCodeRequestMultiStepFlow(MultiStepFlow):\n <mask token>\n\n def __init__(self, endpoint):\n super(UnlockCodeRequestMultiStepFlow, self).__init__(title=_(\n 'form.auth-request.tit... | [
3,
4,
5,
6,
7
] |
from django.db import models
class Course(models.Model):
cid = models.CharField(max_length=100)
title = models.CharField(max_length=500)
link = models.CharField(max_length=300)
| normal | {
"blob_id": "226fc85dc8b6d549fddef0ca43ad629875ac0717",
"index": 3080,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Course(models.Model):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Course(models.Model):\n cid = models.CharField(max_length... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import sys
from dkfileutils.path import Path
def line_endings(fname):
"""Return all line endings in the file.
"""
_endings = {line[-2:] for line in open(fname, 'rb').readlines()}
res = set()
for e in _endings:
if e.en... | normal | {
"blob_id": "be279fe44b0d52c9d473e08d8b9c28d5b6386b45",
"index": 5184,
"step-1": "<mask token>\n\n\ndef line_endings(fname):\n \"\"\"Return all line endings in the file.\n \"\"\"\n _endings = {line[-2:] for line in open(fname, 'rb').readlines()}\n res = set()\n for e in _endings:\n if e.end... | [
3,
4,
5,
6,
7
] |
import graph as Graph
def BFS(graph: Graph.Graph, start, end):
visited = set()
parent = dict()
parent[start] = None
queue = []
queue.append(start)
visited.add(start)
while queue:
current = queue.pop(0)
if current == end:
break
for v in graph.neighbors(cu... | normal | {
"blob_id": "5c5f00084f37837b749e1fbb52a18d515e09ba06",
"index": 773,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef BFS(graph: Graph.Graph, start, end):\n visited = set()\n parent = dict()\n parent[start] = None\n queue = []\n queue.append(start)\n visited.add(start)\n while... | [
0,
1,
2
] |
"""@brief the routes for Flask application
"""
import hashlib
import json
import time
import requests
from flask import render_template, url_for
from soco import SoCo
from app import app
app.config.from_pyfile("settings.py")
sonos = SoCo(app.config["SPEAKER_IP"])
def gen_sig():
"""@brief return the MD5 checksum... | normal | {
"blob_id": "86f33895e9ae0e026d7d6e40e611796b2dc2c713",
"index": 8394,
"step-1": "<mask token>\n\n\ndef gen_sig():\n \"\"\"@brief return the MD5 checksum \"\"\"\n return hashlib.md5((app.config['ROVI_API_KEY'] + app.config[\n 'ROVI_SHARED_SECRET'] + repr(int(time.time()))).encode('utf-8')\n )... | [
16,
17,
18,
20,
23
] |
import math
# 1
long_phrase = 'Насколько проще было бы писать программы, если бы не заказчики'
short_phrase = '640Кб должно хватить для любых задач. Билл Гейтс (по легенде)'
def compare (long, short):
print(len(long)>len(short))
compare(long_phrase, short_phrase)
# 2.1
text = 'Если программист в 9-00 утра на работе... | normal | {
"blob_id": "f29637cd670524baebac6549962a1c50fc1b91c6",
"index": 6835,
"step-1": "<mask token>\n\n\ndef compare(long, short):\n print(len(long) > len(short))\n\n\n<mask token>\n\n\ndef exchange(a, b):\n b = b - a\n a = a + b\n b = a - b\n print('a=', a, 'b=', b)\n\n\n<mask token>\n",
"step-2": "... | [
2,
3,
4,
5,
6
] |
# coding=utf-8
"""
@Author: Freshield
@Contact: yangyufresh@163.com
@File: a1_test_call.py
@Time: 2021-01-20 17:40
@Last_update: 2021-01-20 17:40
@Desc: None
@==============================================@
@ _____ _ _ _ _ @
@ | __|___ ___ ___| |_|_|___| |_| | @
@ | __| ... | normal | {
"blob_id": "325770130473153d092d3058587e9666625e12d0",
"index": 5670,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(r.url)\nprint(r.text)\n<mask token>\nprint(r.text)\nprint(r.url)\n<mask token>\nprint(r.text)\nprint(r)\n",
"step-3": "<mask token>\nurl = 'https://www.baidu.com'\nurl = 'http://w... | [
0,
1,
2,
3,
4
] |
# Generates an infinite series of odd numbers
def odds():
n = 1
while True:
yield n
n += 2
def pi_series():
odd_nums = odds()
approximation = 0
while True:
approximation += (4 / next(odd_nums))
yield approximation
approxim... | normal | {
"blob_id": "26ef7de89e2e38c419310cc66a33d5dc0575fc0d",
"index": 5012,
"step-1": "def odds():\n n = 1\n while True:\n yield n\n n += 2\n\n\n<mask token>\n",
"step-2": "def odds():\n n = 1\n while True:\n yield n\n n += 2\n\n\ndef pi_series():\n odd_nums = odds()\n ... | [
1,
2,
3,
4,
5
] |
a=input("Please enter the elements with spaces between them:").split()
n=len(a)
for i in range(n):
a[i]=int(a[i])
for i in range(n-1):
for j in range(n-i-1):
if a[j]>a[j+1]:
a[j],a[j+1]=a[j+1],a[j]
print("Sortes array :",a) | normal | {
"blob_id": "5c2a6802e89314c25f0264bbe2bc7ed2689a255a",
"index": 782,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(n):\n a[i] = int(a[i])\nfor i in range(n - 1):\n for j in range(n - i - 1):\n if a[j] > a[j + 1]:\n a[j], a[j + 1] = a[j + 1], a[j]\nprint('Sortes ar... | [
0,
1,
2,
3
] |
class Solution(object):
def twoSum(self, numbers, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
idx1 = 0
idx2 = len(numbers)-1
while(idx1<idx2): # can also use a for-loop: for num in numbers:
left = numbers[id... | normal | {
"blob_id": "51b3beee8659bccee0fbb64b80fdce18b693674b",
"index": 9481,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n",
"step-3": "class Solution(object):\n\n def twoSum(self, numbers, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n ... | [
0,
1,
2,
3
] |
"""updateimage URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-b... | normal | {
"blob_id": "b3b5f7eeb81e10a51eb0322bc5278d33ee5f8e97",
"index": 9222,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('^$', jsonre_data), url('^serialize/$', SerializeView.\n as_view()), url('^serialize/$', SerializeView.as_view()), url('^all/$',\n Serializeall.as_view()), url('^... | [
0,
1,
2,
3
] |
import sys
import time
import numpy as np
import vii
import cnn
from cnn._utils import (FLOAT_DTYPE,
_multi_convolve_image,
_opencl_multi_convolve_image,
_relu_max_pool_image,
_opencl_relu_max_pool_image)
GROUPS = 25, 20... | normal | {
"blob_id": "8ec257d5dfe84e363e3c3aa5adee3470c20d1765",
"index": 5866,
"step-1": "<mask token>\n\n\n@probe_time\ndef opencl_multi_convolve_image(*args):\n return _opencl_multi_convolve_image(*args)\n\n\n<mask token>\n\n\ndef multi_convolve_image(data, kernel, bias, dil_x, dil_y):\n if device < 0:\n ... | [
2,
6,
7,
9,
12
] |
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 9 20:06:32 2020
@author: Supriyo
"""
import networkx as nx
import matplotlib.pyplot as plt
g=nx.Graph()
#l=[1,2,3]
# g.add_node(1)
# g.add_node(2)
# g.add_node(3)
# g.add_nodes_from(l)
# g.add_edge(1,2)
# g.add_edge(2,3)
#... | normal | {
"blob_id": "3bfa9d42e3fd61cf6b7ffaac687f66c2f4bc073e",
"index": 3906,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnx.draw(g)\nnx.draw(h)\nplt.show()\nnx.write_gexf(g, 'test.gexf')\n",
"step-3": "<mask token>\ng = nx.Graph()\ng = nx.complete_graph(10)\nh = nx.gnp_random_graph(10, 0.5)\nnx.draw(g)\nn... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.7 on 2017-12-13 02:06
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import uuid
class Migration(migrations.Migration):
initial = True
dependencies = [
('stores', '0001_initial'),
... | normal | {
"blob_id": "e95de58828c63dc8ae24efff314665a308f6ce0c",
"index": 983,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = Tr... | [
0,
1,
2,
3,
4
] |
t = int(input())
while t:
x = list(map(int, input().split()))
x.sort()
if(x[0]+x[1]==x[2]):
print("YES")
else:
print("NO")
t-=1 | normal | {
"blob_id": "d1200006b8d7a18b11b01eff4fbf38d9dfd8958e",
"index": 5758,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile t:\n x = list(map(int, input().split()))\n x.sort()\n if x[0] + x[1] == x[2]:\n print('YES')\n else:\n print('NO')\n t -= 1\n",
"step-3": "t = int(inp... | [
0,
1,
2,
3
] |
from pprint import pprint
from collections import Counter
from copy import deepcopy
class Sudoku():
def __init__(self, grid):
'''
Initializes the grid
'''
self.grid = grid
self.sub_grid = self.create_sub_grid(self.grid)
def create_sub_grid(self, ... | normal | {
"blob_id": "4032503bba8a1dd273015d503f52b6ea2d932d1d",
"index": 3564,
"step-1": "<mask token>\n\n\nclass Sudoku:\n\n def __init__(self, grid):\n \"\"\"\n Initializes the grid\n \"\"\"\n self.grid = grid\n self.sub_grid = self.create_sub_grid(self.grid)\n\n def create... | [
10,
12,
13,
14,
15
] |
seq = input('write a sequence of numbers: ')
print(seq.split(','))
print(tuple(seq.split(',')))
| normal | {
"blob_id": "be867d600f5f267986368f5573006f63004dbf9e",
"index": 5094,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(seq.split(','))\nprint(tuple(seq.split(',')))\n",
"step-3": "seq = input('write a sequence of numbers: ')\nprint(seq.split(','))\nprint(tuple(seq.split(',')))\n",
"step-4": null... | [
0,
1,
2
] |
from django.shortcuts import render
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
from .models import Document, Organization, UserProfile, Shop
#from .forms import DocUploadForm, ShopEditForm
from django.shortcuts import render_to_response, get_object_or_404
fro... | normal | {
"blob_id": "d2c5d306591216e100b5bd8e8822b24fd137d092",
"index": 9208,
"step-1": "<mask token>\n\n\nclass DocUploadForm(forms.ModelForm):\n tags = forms.ModelMultipleChoiceField(queryset=Tag.objects.all())\n\n\n class Meta:\n model = Document\n exclude = ['organization', 'private_user', 'is_p... | [
23,
24,
32,
34,
37
] |
#!/usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author:tom_tao626
@license: Apache Licence
@file: 17.列表中的元素统计.py
@time: 2020/12/09
@contact: tp320670258@gmail.com
@site: xxxx.suizhu.net
@software: PyCharm
"""
# collections.Counter()
from collections import Counter
list1 = ['a', 'b', 'b', 'c', 'd', 'e', 'a', ... | normal | {
"blob_id": "f2c592a0ea38d800510323a1001c646cdbecefff",
"index": 3009,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(count)\nprint(count['b'])\nprint(count.most_common(1))\nprint(count.items())\n",
"step-3": "<mask token>\nlist1 = ['a', 'b', 'b', 'c', 'd', 'e', 'a', 'b', 'e']\ncount = Counter(li... | [
0,
1,
2,
3,
4
] |
from django import forms
from . import models
class PhotoForm(forms.Form):
image = forms.ImageField()
| normal | {
"blob_id": "3983f8dfb9c7b7e664af05857a0f6fe380154424",
"index": 3684,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass PhotoForm(forms.Form):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass PhotoForm(forms.Form):\n image = forms.ImageField()\n",
"step-4": "from django import form... | [
0,
1,
2,
3
] |
import numpy as np
from random import randint
def combinacaoDeEmbralhamento(qtdeLinhas):
while True:
a = randint(0,qtdeLinhas)
b = randint(0,qtdeLinhas)
if a == b :
continue
else:
break
resp = [[a,b]]
return resp
def embaralhaMatriz(x):
for i in range(qtdeLinhas):
print(i)
combinacaoDeEmbralha... | normal | {
"blob_id": "28ed494939d0928bf3ad4f07f58186374e925426",
"index": 7024,
"step-1": "<mask token>\n\n\ndef combinacaoDeEmbralhamento(qtdeLinhas):\n while True:\n a = randint(0, qtdeLinhas)\n b = randint(0, qtdeLinhas)\n if a == b:\n continue\n else:\n break\n ... | [
2,
3,
4,
5,
6
] |
import sys, warnings
if sys.version_info[0] < 3:
warnings.warn("At least Python 3.0 is required to run this program", RuntimeWarning)
else:
print('Normal continuation')
| normal | {
"blob_id": "a6d5552fa0648fcf9484a1498e4132eb80ecfc86",
"index": 2304,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif sys.version_info[0] < 3:\n warnings.warn('At least Python 3.0 is required to run this program',\n RuntimeWarning)\nelse:\n print('Normal continuation')\n",
"step-3": "im... | [
0,
1,
2,
3
] |
import configparser
import shutil
def get_imagemagick_path():
config = configparser.ConfigParser()
config.read("settings/settings.ini")
return config['commands'].get('convert', shutil.which("convert"))
# try:
# except KeyError:
# EXIV2_PATH = shutil.which("exiv2")
| normal | {
"blob_id": "5fa9c9908d4aea507cf0ca8287a6b8e5b391470a",
"index": 9297,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_imagemagick_path():\n config = configparser.ConfigParser()\n config.read('settings/settings.ini')\n return config['commands'].get('convert', shutil.which('convert'))\... | [
0,
1,
2,
3
] |
from django.core.urlresolvers import reverse
from django.contrib.auth.decorators import login_required
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseForbidden, HttpResponseServerError
from django.shortcuts import render
from django.template import RequestContext
import json
import datetime
... | normal | {
"blob_id": "d583661accce8c058f3e6b8568a09b4be1e58e4e",
"index": 4877,
"step-1": "<mask token>\n\n\ndef lookup_and_render(request):\n try:\n dbres = esgfDatabaseManager.lookupUserSubscriptions(request.user)\n except Exception as e:\n error_cond = str(e)\n print(traceback.print_exc())\n... | [
4,
5,
6,
7,
8
] |
from flask import request, json, Response, Blueprint
from ..models.DriverModel import DriverModel, DriverSchema
driver_api = Blueprint('drivers', __name__)
driver_schema = DriverSchema()
@driver_api.route('/', methods=['POST'])
def create():
req_data = request.get_json()
data, error = driver_schema.load(req_... | normal | {
"blob_id": "ee7820d50b5020a787fbaf012480e8c70bc0ee41",
"index": 1690,
"step-1": "<mask token>\n\n\n@driver_api.route('/<int:driver_id>', methods=['PUT'])\ndef update(driver_id):\n req_data = request.get_json()\n data, error = driver_schema.load(req_data, partial=True)\n if error:\n return custom... | [
2,
5,
7,
9,
10
] |
#-*- coding: utf8 -*-
#Programa: 04-palindromo
#Objetivo:Un Numero Palindromo es aquel numero que se lee igual, de izquierda a derecha y viceversa
#El palindromo mas grande que se pued obtener por el producto de dos numeos de dos digitos
# es: 9009 que es igual a 91x99.
#Encuentre el pali... | normal | {
"blob_id": "45f9d5ac0fa7d9259c1d53b92c030559f3bfda89",
"index": 7161,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef multiplicaciones():\n \"\"\"\n Funcion se encargara de crear las multiplicaciones entre 999 y 100\n\n mediante dos ciclos for.\n \"\"\"\n ultimo_palindromo = 0\n ... | [
0,
1,
2,
3,
4
] |
import requests
from requests.adapters import HTTPAdapter
from requests.exceptions import ConnectionError, Timeout, RequestException
# import from `requests` because Jarvis / some platforms still have old urllib3
from requests.packages.urllib3.util.retry import Retry
def retryable_session(retries=3, backoff_factor=0.5... | normal | {
"blob_id": "603708c830dadb6f1a3e5de00536d558f448b5fb",
"index": 1352,
"step-1": "<mask token>\n\n\nclass Getter(object):\n <mask token>\n\n def __call__(self, url, **kwargs):\n try:\n return self._inner_call(url, **kwargs)\n except (Timeout, ConnectionError, RequestException) as e... | [
5,
6,
7,
8,
9
] |
#-*-coding:utf-8-*-
from Classify import get_train_data
import sys
'''
获取训练集数据
'''
get_train_data(sys.argv[1], sys.argv[2]) | normal | {
"blob_id": "513aff6cf29bbce55e2382943767a9a21df2e98e",
"index": 5080,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nget_train_data(sys.argv[1], sys.argv[2])\n",
"step-3": "from Classify import get_train_data\nimport sys\n<mask token>\nget_train_data(sys.argv[1], sys.argv[2])\n",
"step-4": "#-*-codi... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
'''
=======================================================================
AutoTest Team Source File.
Copyright(C), Changyou.com
-----------------------------------------------------------------------
Created: 2017/3/2 by ChengLongLong
----------------------------------------------------... | normal | {
"blob_id": "38f7c529cd0a8d85de266c6a932e6c8342aee273",
"index": 4969,
"step-1": "<mask token>\n",
"step-2": "# -*- coding: utf-8 -*-\n'''\n=======================================================================\nAutoTest Team Source File.\nCopyright(C), Changyou.com\n------------------------------------------... | [
0,
1
] |
import os
import logging
from flask import Flask
from flask_orator import Orator
from flask_jwt_extended import JWTManager
from dotenv import load_dotenv
load_dotenv(verbose=True)
app = Flask(__name__)
app.secret_key = os.getenv('SECRET_KEY')
app.config['JSON_SORT_KEYS'] = False
app.config['ORATOR_DATABASES'] = {
... | normal | {
"blob_id": "f20e2227821c43de17c116d8c11233eda53ab631",
"index": 9967,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return os.getenv('DB_HOST')\n",
"step-2": "<mask token>\nload_dotenv(verbose=True)\n<mask token>\nif bool(os.getenv('IS_DEV')):\n logger = logging.getLogger('orator.connecti... | [
1,
2,
3,
4,
5
] |
import abc
import math
import random
from typing import Union, Tuple
import numpy as np
from scipy import stats
from . import Rectangle, Line, Point, Shape
__all__ = ['get_critical_angle', 'Paddle', 'Ball', 'Snell', 'Canvas']
EPSILON = 1e-7
def get_critical_angle(s0: float, s1: float) -> Union[float, None]:
"... | normal | {
"blob_id": "42d2be7544d2afb9580841422ae35e1a5621df52",
"index": 6459,
"step-1": "<mask token>\n\n\nclass TrajectoryRectangle(TrajectoryBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @property\n def top_left(self) ->Line:\n \"\"\"\n Line representing the tr... | [
46,
51,
75,
76,
83
] |
#import getCanditatemap() from E_18_hacksub
import operator, pdb, collections, string
ETAOIN = """ etaoinsrhldcumgyfpwb.,vk0-'x)(1j2:q"/5!?z346879%[]*=+|_;\>$#^&@<~{}`""" #order taken from https://mdickens.me/typing/theory-of-letter-frequency.html, with space added at the start, 69 characters overall
length = 128
#ETA... | normal | {
"blob_id": "63a9060e9933cc37b7039833be5f071cc7bf45bf",
"index": 7873,
"step-1": "<mask token>\n\n\ndef getLettercount(mess):\n charcount = getCanditatemap()\n for char in mess:\n if char in charcount:\n charcount[char] += 1\n return charcount\n\n\n<mask token>\n\n\ndef englishFreqMatc... | [
2,
3,
5,
6,
7
] |
from random import shuffle, choice
from typing import Dict, List, Tuple
note_to_midi: Dict[int, int] = {
1: 0,
2: 2,
3: 4,
4: 5,
5: 7,
6: 9,
7: 11,
}
midi_to_note: Dict[int, int] = {
0: 1,
2: 2,
4: 3,
5: 4,
7: 5,
9: 6,
11: 7,
}
class Note:
num: int
@c... | normal | {
"blob_id": "d70f77713abf4b35db9de72c1edbf4bf4580b2a4",
"index": 8795,
"step-1": "<mask token>\n\n\nclass Note:\n num: int\n\n @classmethod\n def choice(cls, *args: int):\n return Note(choice(args))\n\n @classmethod\n def from_midi(cls, midi: int, root: int):\n note = midi_to_note.ge... | [
24,
26,
28,
33,
34
] |
#! /usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'raek'
web = '910d59f0-30bd-495b-a54c-bf5addc81a8a'
app = '21ec74fb-e941-43be-8772-a2f8dc6ccc4f' | normal | {
"blob_id": "cce645073ba117b9e297dfccf5a39710b0c6cd14",
"index": 8479,
"step-1": "<mask token>\n",
"step-2": "__author__ = 'raek'\nweb = '910d59f0-30bd-495b-a54c-bf5addc81a8a'\napp = '21ec74fb-e941-43be-8772-a2f8dc6ccc4f'\n",
"step-3": "#! /usr/bin/python\n# -*- coding: utf-8 -*-\n__author__ = 'raek'\n\nweb ... | [
0,
1,
2
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2015-2016 Applatix, Inc. All rights reserved.
#
'''
cAdvisor CLI. Used by axstats temporarily before moving to Heapster
'''
import requests
import logging
import time
logger = logging.getLogger(__name__)
CHECK_LIVELINESS_INTERVAL = 5
CONNECTION_TIMEOUT = 5
... | normal | {
"blob_id": "87f672919f6019e549508b239c798301d5f549bd",
"index": 7667,
"step-1": "<mask token>\n\n\nclass AXCadvisorClient(object):\n\n def __init__(self, ip):\n self._wait_interval = 60\n self._url_prefix = 'http://{ip}:{port}/api/v2.0/'.format(ip=ip,\n port=4194)\n self.wait_... | [
5,
6,
7,
8,
11
] |
import pytest
import responses
from auctioneer import constants, controllers, entities
from common.http import UnExpectedResult
def test_keywordbid_rule_init(kwb_rule, account):
assert kwb_rule.get_max_bid_display() == kwb_rule.max_bid * 1_000_000
assert kwb_rule.get_bid_increase_percentage_display() == kwb_... | normal | {
"blob_id": "e0435b0b34fc011e7330ab8882865131f7f78882",
"index": 922,
"step-1": "<mask token>\n\n\ndef test_keywordbid_rule_init(kwb_rule, account):\n assert kwb_rule.get_max_bid_display() == kwb_rule.max_bid * 1000000\n assert kwb_rule.get_bid_increase_percentage_display(\n ) == kwb_rule.bid_increa... | [
3,
4,
6,
7,
8
] |
# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# 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.apache.org/licenses/LICENSE-2.0
#
# Unless requ... | normal | {
"blob_id": "dccdca65cce2959b07657636e23e7c9ab8a4f96c",
"index": 1382,
"step-1": "<mask token>\n\n\nclass MoneyFst(GraphFst):\n <mask token>\n\n def __init__(self, decimal: GraphFst, deterministic: bool=True):\n super().__init__(name='money', kind='verbalize', deterministic=\n determinist... | [
2,
3,
4,
5,
6
] |
'''
Author: ulysses
Date: 1970-01-01 08:00:00
LastEditTime: 2020-08-03 15:44:57
LastEditors: Please set LastEditors
Description:
'''
from pyspark.sql import SparkSession
from pyspark.sql.functions import split, explode
if __name__ == "__main__":
spark = SparkSession\
.builder\
.appName('StructedS... | normal | {
"blob_id": "991260c268d53fbe73e9bff9990ac536ed802d7a",
"index": 6887,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n spark = SparkSession.builder.appName('StructedSocketWordCount').master(\n 'local[4]').getOrCreate()\n sc = spark.sparkContext\n sc.setLogLevel... | [
0,
1,
2,
3
] |
user_schema = {
'id': {
'type': 'string',
'required': True,
'coerce': (str, lambda x: x.lower())
},
'latitude':{
'type': 'float',
'required': True,
'min': -60.0,
'max': 10,
'coerce': (float, lambda x: round(x, 5))
},
'longitude':{
... | normal | {
"blob_id": "bf41ab20b9fae9f19efdc58852e48d9b735f34c3",
"index": 1645,
"step-1": "<mask token>\n",
"step-2": "user_schema = {'id': {'type': 'string', 'required': True, 'coerce': (str, \n lambda x: x.lower())}, 'latitude': {'type': 'float', 'required': True,\n 'min': -60.0, 'max': 10, 'coerce': (float, la... | [
0,
1,
2
] |
import copy
import numpy as np
from PySide2.QtCore import QItemSelectionModel, QObject, Signal
from PySide2.QtWidgets import (
QComboBox, QLineEdit, QSizePolicy, QTableWidgetItem
)
from hexrd.constants import chargestate
from hexrd.material import Material
from hexrd.ui.periodic_table_dialog import PeriodicTabl... | normal | {
"blob_id": "ec2be72f81d260c491cdc31b68b34401fb49b91e",
"index": 2660,
"step-1": "<mask token>\n\n\nclass MaterialSiteEditor(QObject):\n <mask token>\n\n def __init__(self, site, parent=None):\n super().__init__(parent)\n loader = UiLoader()\n self.ui = loader.load_file('material_site_... | [
39,
40,
47,
54,
57
] |
import re
import gpxpy
def extract_gpx_data(gpx_file_path, attribute='elevation'):
"""Reads in a GPX file and returns a list of values
for a specified GPX attribute.
Parameters
----------
gpx_file_path : str
File path to the GPX file (.gpx extension).
attribute: str
Name of t... | normal | {
"blob_id": "cc6d18785eff0406ff7f38f18f15476375e31b76",
"index": 9254,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef extract_gpx_data(gpx_file_path, attribute='elevation'):\n \"\"\"Reads in a GPX file and returns a list of values\n for a specified GPX attribute.\n\n Parameters\n ----... | [
0,
1,
2,
3
] |
from odoo import models, fields, api
class Aceptar_letras_wizard(models.TransientModel):
_name = 'aceptar_letras_wizard'
_description = "Aceptar letras"
def _get_letras(self):
if self.env.context and self.env.context.get('active_ids'):
return self.env.context.get('active_ids')
... | normal | {
"blob_id": "4ad3390f8f2c92f35acde507be7a7b713af997f2",
"index": 5092,
"step-1": "<mask token>\n\n\nclass Aceptar_letras_wizard(models.TransientModel):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @api.multi\n def aceptar_letras(self):\n active_ids = self.env.context.g... | [
2,
3,
4,
5,
6
] |
# https://www.acmicpc.net/problem/3584
import sys, collections
input = sys.stdin.readline
N = int(input())
for _ in range(N):
n = int(input())
arr = collections.defaultdict(list)
parent = [i for i in range(n + 1)]
for i in range(n - 1):
a, b = map(int, input().split())
arr[a].append(b)
... | normal | {
"blob_id": "d60a2d4c819f701e8e439b8839415aa2838df185",
"index": 6415,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(N):\n n = int(input())\n arr = collections.defaultdict(list)\n parent = [i for i in range(n + 1)]\n for i in range(n - 1):\n a, b = map(int, input().spli... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 29 20:33:32 2013
@author: ste
"""
#Convert input file for graph from adjacency list version, where each line is
#vertex adjacent adjacent adjacent ...
#to edge representation where each line is
#tail head
edges=[]
with open("/Users/ste/Desktop/Ste/Python/AlgorithmsCours... | normal | {
"blob_id": "1b7b94a0331e2462f83f4f77bcfaefbeefdf24f4",
"index": 3754,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('/Users/ste/Desktop/Ste/Python/AlgorithmsCourse/KargerMinCut.txt'\n ) as v_list_file:\n for line in v_list_file:\n node = map(int, line.split())\n for adjace... | [
0,
1,
2,
3
] |
#-*- coding: UTF-8 -*-
#Author Motuii
'''
* ┏┓ ┏┓
* ┏┛┻━━━┛┻┓
* ┃ ┃
* ┃ ━ ┃
* ┃ ┳┛ ┗┳ ┃
* ┃ ┃
* ┃ ┻ ┃
* ┃ ┃
* ┗━┓ ┏━┛
* ┃ ┃ 神兽保佑
* ┃ ┃ 代码无BUG!
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛
*
'''
n... | normal | {
"blob_id": "131caf50cc8682cf180168a1b136b1dcdd70fa76",
"index": 6837,
"step-1": "#-*- coding: UTF-8 -*-\n#Author Motuii\n'''\n * ┏┓ ┏┓ \n * ┏┛┻━━━┛┻┓ \n * ┃ ┃ \n * ┃ ━ ┃ \n * ┃ ┳┛ ┗┳ ┃ \n * ┃ ┃ \n * ┃ ┻ ┃ \n * ┃ ┃ \n * ┗━┓ ┏━┛ \n * ┃ ┃ 神兽保佑 \n * ┃ ┃ 代码无BUG! \n ... | [
0
] |
import asyncio
import secrets
import pytest
from libp2p.host.ping import ID, PING_LENGTH
from libp2p.tools.factories import pair_of_connected_hosts
@pytest.mark.asyncio
async def test_ping_once():
async with pair_of_connected_hosts() as (host_a, host_b):
stream = await host_b.new_stream(host_a.get_id(),... | normal | {
"blob_id": "0233b46da3b9351f110ffc7f8622ca8f9ee9944d",
"index": 3000,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.mark.asyncio\nasync def test_ping_once():\n async with pair_of_connected_hosts() as (host_a, host_b):\n stream = await host_b.new_stream(host_a.get_id(), (ID,))\n ... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 *-*
import MySQLdb
conn = MySQLdb.connect('localhost', 'ABarbara', 'root', '1dawabarbara') # Abro la conexión
def crearTabla(query): # Le paso la cadena que realizará el create como parámetro.
cursor = conn.cursor() #En un cursor (de la conexión) almaceno lo que quiero enviar a la base de da... | normal | {
"blob_id": "8a2b7376369513ce403a2542fb8c6d5826b2169b",
"index": 9949,
"step-1": "# -*- coding: utf-8 *-*\nimport MySQLdb \n\nconn = MySQLdb.connect('localhost', 'ABarbara', 'root', '1dawabarbara') # Abro la conexión \n\ndef crearTabla(query): # Le paso la cadena que realizará el create como parámetro.\n\tcurs... | [
0
] |
import preprocessing
import tokenization
import vectorspacemodel
import pickle
import collections
import os
import math
import operator
from itertools import islice
def take(n, iterable):
# "Return first n items of the iterable as a list"
return list(islice(iterable, n))
directory = os.getcwd()
... | normal | {
"blob_id": "1630a3d0becac195feee95a1c3b23568612a48d2",
"index": 3194,
"step-1": "<mask token>\n\n\ndef take(n, iterable):\n return list(islice(iterable, n))\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef take(n, iterable):\n return list(islice(iterable, n))\n\n\n<mask token>\nwith open('D_INDEXE... | [
1,
2,
3,
4,
5
] |
# coding=utf-8
# __author__ = 'lyl'
import json
import csv
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
def read_json(filename):
"""
读取json格式的文件
:param filename: json文件的文件名
:return: [{}, {}, {}, {}, {},{} ......]
"""
return json.loads(open(filename).read())
def... | normal | {
"blob_id": "7531480f629c1b3d28210afac4ef84b06edcd420",
"index": 3825,
"step-1": "<mask token>\n\n\ndef write_csv(filename, data_list):\n \"\"\"\n 将python对象 [{}, {}. {}, {} ...] 写入到csv文件中\n :param filename: 生成的csv文件名\n :param data_list: [{}, {}. {}, {} ...]\n :return: None\n \"\"\"\n with ... | [
1,
3,
4,
5,
6
] |
import sys
import pysolr
import requests
import logging
import json
import datetime
from urlparse import urlparse
from django.conf import settings
from django.utils.html import strip_tags
from aggregator.utils import mercator_to_llbbox
def get_date(layer):
"""
Returns a date for Solr. A date can be detected... | normal | {
"blob_id": "6eb59f62a1623f308e0eda4e616be4177a421179",
"index": 2254,
"step-1": "import sys\nimport pysolr\nimport requests\nimport logging\nimport json\nimport datetime\n\nfrom urlparse import urlparse\nfrom django.conf import settings\nfrom django.utils.html import strip_tags\n\nfrom aggregator.utils import m... | [
0
] |
from rest_framework import viewsets
from .serializers import UserSerializer
from .models import UserCustom
class UserViewSet(viewsets.ModelViewSet):
"""
API endpoint that allows users to be viewed or edited.
"""
queryset = UserCustom.objects.all()
serializer_class = UserSerializer
| normal | {
"blob_id": "fadf16792822926cb7b7386291e52ce44693baf8",
"index": 2053,
"step-1": "<mask token>\n\n\nclass UserViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass UserViewSet(viewsets.ModelViewSet):\n <mask token>\n queryset = UserCu... | [
1,
2,
3,
4
] |
def part_1() -> int:
start = 382345
end = 843167
total = 0
for number in range(start, end + 1):
if check_number(str(number)):
total += 1
return total
def check_number(problem_input: str) -> bool:
previous = 0
double = False
for current in range(1, len(problem_inpu... | normal | {
"blob_id": "c46495eebbe796253f56b7472d5548b41c5d0bc4",
"index": 2411,
"step-1": "def part_1() ->int:\n start = 382345\n end = 843167\n total = 0\n for number in range(start, end + 1):\n if check_number(str(number)):\n total += 1\n return total\n\n\n<mask token>\n\n\ndef check_nu... | [
3,
4,
5,
6,
7
] |
######################################################################
#
# Write something here to recognize your own file
#
# Copyright: MIT License
#
######################################################################
def multiply(value):
return value * 5
if __name__ == "__main__":
a = [0, 1, 2, 3, 4, 5... | normal | {
"blob_id": "0778b25363d50e699edf48b92f1104ab57c03172",
"index": 2015,
"step-1": "<mask token>\n",
"step-2": "def multiply(value):\n return value * 5\n\n\n<mask token>\n",
"step-3": "def multiply(value):\n return value * 5\n\n\nif __name__ == '__main__':\n a = [0, 1, 2, 3, 4, 5]\n new_empty_list ... | [
0,
1,
2,
3
] |
import numpy as np
import cv2
import time
from itertools import chain, compress
from collections import defaultdict, namedtuple
class FeatureMetaData(object):
"""
Contain necessary information of a feature for easy access.
"""
def __init__(self):
self.id = None # int
... | normal | {
"blob_id": "02f196623907703255bf149db0435104d086da97",
"index": 8292,
"step-1": "<mask token>\n\n\nclass ImageProcessor(object):\n <mask token>\n\n def __init__(self, config):\n self.config = config\n self.is_first_img = True\n self.next_feature_id = 0\n self.detector = cv2.Fas... | [
18,
20,
23,
25,
31
] |
import requests
import re
import time
import os
import argparse
import json
url = "https://contactform7.com/captcha/"
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Safari/605.1.15',
'Content-Type': "multipart/form-data; boun... | normal | {
"blob_id": "6990b5f34af654b4e1a39c3d73b6822fa48e4835",
"index": 9159,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nap.add_argument('-o', '--output', required=True, help='Path to save the images'\n )\nap.add_argument('-n', '--number', required=False, default=500, help=\n 'number of images to down... | [
0,
1,
2,
3,
4
] |
'''
Given an infinite sorted array (or an array with unknown size), find if a given number ‘key’ is present in the array. Write a function to return the index of the ‘key’ if it is present in the array, otherwise return -1.
Since it is not possible to define an array with infinite (unknown) size, you will be provided ... | normal | {
"blob_id": "a9efa258c223460b2b79861acdde89161706ad9a",
"index": 8770,
"step-1": "<mask token>\n\n\nclass ArrayReader:\n\n def __init__(self, arr):\n self.arr = arr\n\n def get(self, index):\n if index > len(self.arr):\n return math.inf\n return self.arr[index]\n\n\n<mask to... | [
4,
5,
7,
8,
9
] |
'''
Module for interaction with database
'''
import sqlite3
from enum import Enum
DB_NAME = 'categories.db'
class State(Enum):
ok = True
error = False
def get_db_connection():
try:
global connection
connection = sqlite3.connect(DB_NAME)
cursor = connection.cursor()
exce... | normal | {
"blob_id": "9b3c2604b428295eda16030b45cf739e714f3d00",
"index": 1614,
"step-1": "<mask token>\n\n\nclass State(Enum):\n ok = True\n error = False\n\n\n<mask token>\n\n\ndef close_db_connection():\n try:\n connection.close()\n except Exception:\n print('Error closing connection')\n\n\nd... | [
7,
8,
10,
11,
12
] |
# -*- coding: utf-8 -*-
"""The app module, containing the app factory function."""
from flask import Flask, render_template
from flask_cors import CORS
from flask_misaka import Misaka
from flask_mailman import Mail
from flask_talisman import Talisman
from werkzeug.middleware.proxy_fix import ProxyFix
from micawber.pro... | normal | {
"blob_id": "2257f73a290dfd428a874e963c26e51f1c1f1efa",
"index": 927,
"step-1": "<mask token>\n\n\ndef register_extensions(app):\n \"\"\"Register Flask extensions.\"\"\"\n assets.init_app(app)\n hashing.init_app(app)\n cache.init_app(app)\n db.init_app(app)\n login_manager.init_app(app)\n mi... | [
5,
9,
10,
12,
14
] |
from eval_lib.classification_results import analyze_one_classification_result
from eval_lib.classification_results import ClassificationBatches
from eval_lib.cloud_client import CompetitionDatastoreClient
from eval_lib.cloud_client import CompetitionStorageClient
from eval_lib.dataset_helper import DatasetMetadata
from... | normal | {
"blob_id": "64935ae910d5f330722b637dcc5794e7e07ab52d",
"index": 8375,
"step-1": "<mask token>\n",
"step-2": "from eval_lib.classification_results import analyze_one_classification_result\nfrom eval_lib.classification_results import ClassificationBatches\nfrom eval_lib.cloud_client import CompetitionDatastoreC... | [
0,
1
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import random
import sys
def sequential_search(my_list, search_elt):
found = False
start_time = time.time()
for elt in my_list:
if search_elt == elt:
found = True
break
return (time.time() - start_time), found
def ordered_sequential_... | normal | {
"blob_id": "f3a34d1c37165490c77ccd21f428718c8c90f866",
"index": 4057,
"step-1": "<mask token>\n\n\ndef sequential_search(my_list, search_elt):\n found = False\n start_time = time.time()\n for elt in my_list:\n if search_elt == elt:\n found = True\n break\n return time.ti... | [
6,
7,
9,
10,
11
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.