code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import tkinter
import webbrowser
ventana = tkinter.Tk()
ventana.geometry("1920x1080")
def test():
webbrowser.open_new_tab('Test.html')
boton1 = tkinter.Button(ventana,text ="WEB", width = 10, height=5, command = test );
boton2 = tkinter.Button(ventana,text ="boton2", width = 10, height=5);
boton3 = tkint... | normal | {
"blob_id": "8bf330dc7bee65ac9478722233477ebe5d0286c2",
"index": 1102,
"step-1": "<mask token>\n\n\ndef test():\n webbrowser.open_new_tab('Test.html')\n\n\n<mask token>\n",
"step-2": "<mask token>\nventana.geometry('1920x1080')\n\n\ndef test():\n webbrowser.open_new_tab('Test.html')\n\n\n<mask token>\nbo... | [
1,
2,
3,
4,
5
] |
import gym
import random
import numpy as np
import statistics
from collections import Counter
import tflearn
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
#setup the Cartpole environment
env = gym.make("CartPole-v0")
env.reset()
#----------Expl... | normal | {
"blob_id": "7789e54acc02fe0277ff80ce14efbcdc4ee6e7f1",
"index": 8009,
"step-1": "<mask token>\n\n\ndef explore_cartpole():\n for i_episode in range(2):\n observation = env.reset()\n for t in range(100):\n env.render()\n print(observation)\n action = env.action_s... | [
2,
5,
6,
7,
8
] |
import time,random,os
from tkinter import *
def restart():
root.destroy()
os.startfile(r"data\programs\game with tkinter.py")
def disableButton():
global l,restartButton,start
b1.config(state="disabled")
b2.config(state="disabled")
b3.config(state="disabled")
b4.config(state="disabled"... | normal | {
"blob_id": "e70c5c9a62faa4c501c0f103ce0a0a419aaf4301",
"index": 2096,
"step-1": "<mask token>\n\n\ndef restart():\n root.destroy()\n os.startfile('data\\\\programs\\\\game with tkinter.py')\n\n\ndef disableButton():\n global l, restartButton, start\n b1.config(state='disabled')\n b2.config(state=... | [
11,
12,
14,
15,
18
] |
from django.contrib import admin
from django.urls import path, include
from accounts import views
urlpatterns = [
path('google/login', views.google_login),
path('google/callback/', views.google_callback),
path('accounts/google/login/finish/', views.GoogleLogin.as_view(), name = 'google_login_todjango'),
]... | normal | {
"blob_id": "68319663aad13b562e56b8ee25f25c7b548417df",
"index": 4739,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('google/login', views.google_login), path(\n 'google/callback/', views.google_callback), path(\n 'accounts/google/login/finish/', views.GoogleLogin.as_view(), na... | [
0,
1,
2,
3
] |
import re
import datetime as dt
from datetime import datetime
import time
import random
import json
import sys
import requests
import os
import pickle
import cv2
import numpy as np
import cPickle
import multiprocessing as mp
import math
root = "/datasets/sagarj/instaSample6000/"
# post_dir = root + "/"
videos_dir = r... | normal | {
"blob_id": "ac978accc821600ad8def04b9c7423fbe6759e43",
"index": 6203,
"step-1": "import re\nimport datetime as dt\nfrom datetime import datetime\nimport time\nimport random\nimport json\nimport sys\nimport requests\nimport os\nimport pickle\nimport cv2\nimport numpy as np\nimport cPickle\nimport multiprocessing... | [
0
] |
#! /usr/bin/env python
import os
import glob
import math
from array import array
import sys
import time
import subprocess
import ROOT
mass=[600,700,800,900,1000]
cprime=[01,02,03,05,07,10]
BRnew=[00,01,02,03,04,05]
for i in range(len(mass)):
for j in range(len(cprime)):
for k in range(len(BRnew)):
... | normal | {
"blob_id": "a9e5d4d48f96974da772f47a4c20ebc96bc31d85",
"index": 8740,
"step-1": "#! /usr/bin/env python\nimport os\nimport glob\nimport math\nfrom array import array\nimport sys\nimport time\nimport subprocess\nimport ROOT\n\nmass=[600,700,800,900,1000]\ncprime=[01,02,03,05,07,10]\nBRnew=[00,01,02,03,04,05]\n\n... | [
0
] |
from model.area import AreaModel
from flask_restful import Resource, reqparse
from flask_jwt import jwt_required
class Area(Resource):
pareser = reqparse.RequestParser()
pareser.add_argument('name',
type = str,
required = True,
help = 'Area name is required')
@jwt_required()
def get(self,... | normal | {
"blob_id": "4dcc0261abdb783c60471736567faf7db8b56190",
"index": 9548,
"step-1": "<mask token>\n\n\nclass Area(Resource):\n <mask token>\n pareser.add_argument('name', type=str, required=True, help=\n 'Area name is required')\n\n @jwt_required()\n def get(self, name):\n area = AreaModel... | [
5,
6,
7,
8,
9
] |
#!/usr/bin/python
#
# Author: Johnson Kachikaran (johnsoncharles26@gmail.com)
# Date: 7th August 2016
# Google Drive API:
# https://developers.google.com/drive/v3/reference/
# https://developers.google.com/resources/api-libraries/documentation/drive/v3/python/latest/
"""
Includes functions to integrate with a u... | normal | {
"blob_id": "033719313f92aaf3c62eb1b07a9aa08f13c7bb6e",
"index": 2600,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_metadata(file_id, user_settings=None):\n \"\"\"\n Obtains the metadata of a file\n\n :param str file_id: the identifier of the file whose metadata is needed\n :par... | [
0,
2,
3,
4,
5
] |
# Start the HTML and Javascript code
print '''
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["treemap"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
'''
... | normal | {
"blob_id": "0e112ecfd4ccf762234dff564dd6f3987418dedd",
"index": 1033,
"step-1": "# Start the HTML and Javascript code\nprint '''\n<html>\n <head>\n <script type=\"text/javascript\" src=\"https://www.google.com/jsapi\"></script>\n <script type=\"text/javascript\">\n google.load(\"visualization\", \"1... | [
0
] |
'''
vetor = ["pares de pregos ligados por uma linha"]
indice do vetor representa os pregos na vertical, e o
inteiro em cada pos, os pregos na horizontal.
i(vertical) e j(horizontal) entao:
vetor[i] = j
pregos a(vertical) e pregos b(horizontal)
se a>i and b<j or a<i and b>j
a e i(são indices) b e j(são os elemnt... | normal | {
"blob_id": "fe081a422db6b7f10c89179beab852c6b74ec687",
"index": 2795,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef merge(p, n):\n global vet\n global aux\n if n <= 1:\n return 0\n c = merge(p, n // 2) + merge(p + n // 2, n - n // 2)\n d, a, b = 0, 0, n // 2\n while d <... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: Dang Kai
# @Date: 2018-10-30 15:52:57
# @Last Modified time: 2018-11-10 09:09:21
# @E-mail: 1370465454@qq.com
# @Description:
from time import sleep
import sys
sys.path.append('../')
from common.encapsulation import BasePage
class IndexPage:
def login(self... | normal | {
"blob_id": "463f50567c9dd4b7b47a84eea715541cec5d3cb5",
"index": 2110,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass IndexPage:\n\n def login(self, username, password):\n BasePage.open_url(self, self.base_url)\n BasePage.send_key(self, 'css', '#username', username)\n Ba... | [
0,
2,
3,
4,
5
] |
"""
Copyright (C) 2018-2020 Intel Corporation
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 required by applicable law or agreed to i... | normal | {
"blob_id": "ce28462621a423c6661c672cf92d7e9c91875cfa",
"index": 8247,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass InterpFrontExtractor(FrontExtractorOp):\n <mask token>\n <mask token>\n\n @classmethod\n def extract(cls, node):\n proto_layer = node.pb\n param = prot... | [
0,
2,
3,
4,
5
] |
thisdict = {"brand": "ford", "model": "Mustang", "year": 1964}
module = thisdict["modal"]
print("model:", module)
thisdict = {"brand": "ford", "model": "Mustang", "year": 1964}
module = thisdict.get["modal"]
print("model:", module) | normal | {
"blob_id": "3d854c83488eeafa035ccf5d333eeeae63505255",
"index": 6908,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('model:', module)\n<mask token>\nprint('model:', module)\n",
"step-3": "thisdict = {'brand': 'ford', 'model': 'Mustang', 'year': 1964}\nmodule = thisdict['modal']\nprint('model:',... | [
0,
1,
2,
3
] |
from api.serializers.cart import CartSerializer
from api.serializers.product import ProductSerializer, ProductPopular
from api.serializers.type import TypeSerializer
from api.serializers.user import UserCreationSerializer, UserSerializer
from api.serializers.history import HistorySerializer
from api.serializers.order i... | normal | {
"blob_id": "f0ff15a2392b439a54c5ec304192117c08978755",
"index": 4930,
"step-1": "<mask token>\n",
"step-2": "from api.serializers.cart import CartSerializer\nfrom api.serializers.product import ProductSerializer, ProductPopular\nfrom api.serializers.type import TypeSerializer\nfrom api.serializers.user import... | [
0,
1
] |
# Generated by Django 2.2.6 on 2019-12-23 16:38
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Pages', '0014_auto_20191223_2032'),
]
operations = [
migrations.AlterField(
model_name='dept',
... | normal | {
"blob_id": "d09984c6e6a0ce82389dbbbade63507e9687355d",
"index": 771,
"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 = [('Pages', '001... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*-coding:utf-8-*-
# Author:SemaseMing <blog.v-api.cn>
# Email: admin@v-api.cn
# Time: 2016-10-19 11:56
import gevent
def foo():
print('Running in foo')
gevent.sleep(0)
print('Explicit context switch to foo ageni')
def bar():
print('Explicit context to bar')
gevent.sleep... | normal | {
"blob_id": "7f131e17f4fbd7d6b333a51dae557ddb07c30046",
"index": 9077,
"step-1": "<mask token>\n\n\ndef bar():\n print('Explicit context to bar')\n gevent.sleep(0)\n print('Implicit contenxt switch back to bar')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef foo():\n print('Running in foo')... | [
1,
2,
3,
4,
5
] |
def main():
a, b = map(int, input().split())
diff = abs(max(b, a) - min(a, b))
if diff % 2 != 0:
print("IMPOSSIBLE")
else:
bigger = max(a, b)
ans = bigger - (diff//2)
print(ans)
if __name__ == "__main__":
main()
| normal | {
"blob_id": "f73cbc25152a63bb6552e2cd8272c67a1f4277ba",
"index": 9044,
"step-1": "<mask token>\n",
"step-2": "def main():\n a, b = map(int, input().split())\n diff = abs(max(b, a) - min(a, b))\n if diff % 2 != 0:\n print('IMPOSSIBLE')\n else:\n bigger = max(a, b)\n ans = bigger... | [
0,
1,
2,
3
] |
# Testing
import sys, os
sys.dont_write_bytecode = True
import argparse, socket
from requestframe import RequestFrame
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--header-mutate-level", type=int, choices=range(11), nargs='?', help="Set the mutation level for the headers ... | normal | {
"blob_id": "350a79d6cead6814ad48292b14a204e753dc938c",
"index": 4363,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n parser = argparse.ArgumentParser()\n parser.add_argument('--header-mutate-level', type=int, choices=range(11\n ), nargs='?', help=\n 'Set ... | [
0,
1,
2,
3,
4
] |
import math
import time
def calculate_time(func):
def inner_fn(*args, **kwargs):
start = time.time()
func(*args, **kwargs)
end = time.time()
print("Time taken to execute \'{}\' function is: {} seconds".format(func.__name__, round(end - start, 2)))
return i... | normal | {
"blob_id": "7c9c13974e1deeb55f08c9e251e8c876cedcad6b",
"index": 2484,
"step-1": "<mask token>\n\n\n@calculate_time\ndef factorial(num):\n time.sleep(2)\n print(math.factorial(num))\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef calculate_time(func):\n\n def inner_fn(*args, **kwargs):\n ... | [
1,
2,
3,
4,
5
] |
from flask import Flask, jsonify, request, send_file, render_template
from flask_cors import CORS
from twilio.rest import Client
import autocomplete
from gtts import gTTS
import os
# Set up the model.
autocomplete.load()
app = Flask(__name__)
CORS(app)
# The application
@app.route("/")
def index():
return render_tem... | normal | {
"blob_id": "8980ac4db2657d3dbd2b70b33a4d13a077d4590e",
"index": 2266,
"step-1": "<mask token>\n\n\nclass InvalidUsage(Exception):\n status_code = 400\n\n def __init__(self, message, status_code=None, payload=None):\n Exception.__init__(self)\n self.message = message\n if status_code i... | [
7,
9,
10,
11,
13
] |
#!/usr/bin/python
#_*_ coding: utf-8 _*_
import MySQLdb as mdb
import sys
con = mdb.connect("localhost","testuser","testdB","testdb")
with con:
cur = con.cursor()
cur.execute("UPDATE Writers SET Name = %s WHERE Id = %s ",
("Guy de manupassant", "4"))
print "Number of rows updated: %d "% cur.... | normal | {
"blob_id": "94a84c7143763c6b7ccea1049cdec8b7011798cd",
"index": 6569,
"step-1": "#!/usr/bin/python\n#_*_ coding: utf-8 _*_\n\nimport MySQLdb as mdb\nimport sys\n\ncon = mdb.connect(\"localhost\",\"testuser\",\"testdB\",\"testdb\")\n\nwith con:\n cur = con.cursor()\n\n cur.execute(\"UPDATE Writers SET Name... | [
0
] |
def chess():
row = 0
line = 0
chess1 = []
chess2 = []
for line in range(3):
x1 = (0,line)
chess1.append(x1)
for line in range(3):
x2 = (1,line)
chess2.append(x2)
print(chess1)
print(chess2)
for x in range(len(chess1))
if chess2[x][1] != chess1[... | normal | {
"blob_id": "7d0d1a53a249167edade24a4e9305c95288a8574",
"index": 4851,
"step-1": "def chess():\n row = 0\n line = 0\n chess1 = []\n chess2 = []\n for line in range(3):\n x1 = (0,line)\n chess1.append(x1)\n for line in range(3):\n x2 = (1,line)\n chess2.append(x2)\n ... | [
0
] |
# Generated by Django 2.0.5 on 2018-07-12 11:08
import assessment.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('assessment', '0006_auto_20180712_1428'),
]
operations = [
migrations.AlterModelManagers(
name='season',... | normal | {
"blob_id": "adff75857a1de24267e771c599e4d89486a6ad32",
"index": 7439,
"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 = [('assessment'... | [
0,
1,
2,
3,
4
] |
# Generated by Django 3.2.7 on 2021-09-11 19:38
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('cryptocurrency', '0012_rename_cancel_exists_order_cancel_exist'),
]
operations = [
migrations.AlterField(
model_name='order',
... | normal | {
"blob_id": "de347b41cd88947690cb42e043880a80d81e2c5c",
"index": 436,
"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 = [('cryptocurren... | [
0,
1,
2,
3,
4
] |
class Queue:
def __init__(self):
self.head = None
self.tail = None
class Node:
def __init__(self, data):
self.data = data
self.next = None
def isEmpty(self):
return self.head is None
def peek(self):
return self.head.data if self.head i... | normal | {
"blob_id": "1aca1cf11d64374d0e0786e74c16567a4c5a1dec",
"index": 6452,
"step-1": "class Queue:\n\n def __init__(self):\n self.head = None\n self.tail = None\n\n\n class Node:\n\n def __init__(self, data):\n self.data = data\n self.next = None\n <mask token>\n\n... | [
3,
4,
5,
6,
7
] |
import sys
def digit_sum(x):
sum = 0
while x != 0:
sum = sum + x % 10
x = x // 10
return sum
for i in sys.stdin:
test_num = int(i)
if test_num == 0:
break
count = 11
while digit_sum(test_num) != digit_sum(count * test_num):
count = count + 1
print('{}'... | normal | {
"blob_id": "0d37b6f0ea8854f9d4d4cd2ff235fa39bab7cc12",
"index": 6549,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef digit_sum(x):\n sum = 0\n while x != 0:\n sum = sum + x % 10\n x = x // 10\n return sum\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef digit_sum(x... | [
0,
1,
2,
3
] |
# -------------------------------------------
# MODULES
# -------------------------------------------
import sys
import platform
if(platform.system()== "Windows"):
dir_sep = "\\"
else:
dir_sep = "/"
import time
import os
import numpy as np
import subprocess
import math
from mathutils import Vector
try:
from CifFi... | normal | {
"blob_id": "e14319e705a3c1cdf85e0a2fe77c211e2afa9baa",
"index": 9880,
"step-1": "<mask token>\n\n\nclass Crysdata:\n\n def __init__(self, F, cb):\n self.start = time.time()\n print('Draw timer started')\n self.name = F\n self.cell = Cell(cb)\n self.atoms = readEl(cb)\n ... | [
20,
32,
41,
42,
51
] |
#!/usr/bin/env python
from __future__ import print_function, division, unicode_literals
import os
import sys
import json
import logging
import tempfile
import itertools
import traceback
import subprocess as sp
from os.path import basename
from datetime import datetime
from argparse import ArgumentParser, FileType
PRE... | normal | {
"blob_id": "ac19ae96d8262cadd43314c29198fccbc008c1b5",
"index": 6590,
"step-1": "#!/usr/bin/env python\n\nfrom __future__ import print_function, division, unicode_literals\nimport os\nimport sys\nimport json\nimport logging\nimport tempfile\nimport itertools\nimport traceback\nimport subprocess as sp\nfrom os.p... | [
0
] |
import pandas as pd
import numpy as np
import datetime as dt
def sum_unique(x):
return np.unique(x).shape[0]
def analyze_count(data):
"""real time, vk, itemid, action"""
dsct_vk = pd.unique(data['vk'])
dsct_itemid = pd.unique(data['itemid'])
print 'number of user:', dsct_vk.shape
print ... | normal | {
"blob_id": "1db16ae1fc6546575150187432265ac1cf834ec2",
"index": 1809,
"step-1": "import pandas as pd\nimport numpy as np\nimport datetime as dt\n\ndef sum_unique(x):\n return np.unique(x).shape[0]\n\ndef analyze_count(data):\n \n \"\"\"real time, vk, itemid, action\"\"\"\n\n dsct_vk = pd.unique(data... | [
0
] |
import math
z = 1j
cosinus_real = math.cos(z.real)
cosinus_imaginary = math.cos(z.imag)
sinus_real = math.sin(z.real)
sinus_imag = math.sin(z.imag)
print (cosinus_real)
print (cosinus_imaginary)
print (sinus_real)
print (sinus_imag)
| normal | {
"blob_id": "7ea608b73f592cffc7723b4319cf1a87b3e9b443",
"index": 4220,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(cosinus_real)\nprint(cosinus_imaginary)\nprint(sinus_real)\nprint(sinus_imag)\n",
"step-3": "<mask token>\nz = 1.0j\ncosinus_real = math.cos(z.real)\ncosinus_imaginary = math.cos(... | [
0,
1,
2,
3,
4
] |
import code2
print ("Main en code1: %s\n" % __name__)
| normal | {
"blob_id": "ecbc1da3efb39300b60aeb47897fb01b6bd7af31",
"index": 6028,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Main en code1: %s\\n' % __name__)\n",
"step-3": "import code2\nprint('Main en code1: %s\\n' % __name__)\n",
"step-4": "\nimport code2\nprint (\"Main en code1: %s\\n\" % __name_... | [
0,
1,
2,
3
] |
import glob
import html
import os
import re
import sys
import textwrap
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
import pycountry
import requests
from pyd2v import D2V
from pymediainfo import MediaInfo, Track
from pynfogen.formatter import CustomFormats
class NFO:
AUDIO... | normal | {
"blob_id": "e434d5519e3ba4255ed928769070de391cb0955b",
"index": 3462,
"step-1": "<mask token>\n\n\nclass NFO:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __repr__(self) ->str:\n return '<{c} {attrs}>'.format(c=self.__class__.__name__, attrs=' '.\n ... | [
14,
16,
18,
19,
22
] |
import pandas as pd
# 데이터 로드
train_data = pd.read_csv('./dataset/train_park_daycare.csv')
cctv = pd.read_csv("./dataset/cctv_origin.csv", encoding="EUC-KR")
## 데이터 전처리
# 데이터 추출
cctv = cctv.iloc[1:, :2]
# 구 매핑
gu_dict_num = {'용산구': 0, '양천구': 1, '강동구': 2, '관악구': 3, '노원구': 4, '영등포': 5, '영등포구': 5, '마포구': 6, '서초구': 7, '성... | normal | {
"blob_id": "ea2e9399a8384600d8457a9de3f263db44dc883d",
"index": 752,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in cctv['구분']:\n gu_list.append(gu_dict_num[i])\n<mask token>\ncctv.drop(['구분'], axis=1, inplace=True)\n<mask token>\nprint(new_data.info())\nnew_data.to_csv('./dataset/train_add_... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/8/15 下午5:04
# @Author : Zessay
from .ffm import *
from .fm import *
from .utils import *
from .base_model import *
from .base_trainer import *
from .logger import *
from .metric import *
from .input_fn import * | normal | {
"blob_id": "bbdb07a81d785bdf067707c4e56622a2ada76b7b",
"index": 1692,
"step-1": "<mask token>\n",
"step-2": "from .ffm import *\nfrom .fm import *\nfrom .utils import *\nfrom .base_model import *\nfrom .base_trainer import *\nfrom .logger import *\nfrom .metric import *\nfrom .input_fn import *\n",
"step-3"... | [
0,
1,
2
] |
from typing import Sequence
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np
def plot3D(X, Y, Z, proporcao=1, espelharZ = False):
fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_xlabel('X ')
ax.set_ylabel('Y ')
ax.set_zlabel('Z ')
np.floor
col... | normal | {
"blob_id": "ff20b65f35614415ad786602c0fc2cabd08124fb",
"index": 4065,
"step-1": "<mask token>\n\n\ndef limitZ(Z, limit=10):\n for i in range(len(Z)):\n for j in range(len(Z[i])):\n if Z[i][j] > limit:\n Z[i][j] = np.inf\n if Z[i][j] < -limit:\n Z[i][... | [
2,
3,
4,
5,
6
] |
from proxmin import nmf
from proxmin.utils import Traceback
from proxmin import operators as po
from scipy.optimize import linear_sum_assignment
import numpy as np
import matplotlib.pyplot as plt
import time
from functools import partial
# initialize and run NMF
import logging
logging.basicConfig()
logger ... | normal | {
"blob_id": "0edc0c2f86bda0122d4b231eed700d7a5b08ec1e",
"index": 8279,
"step-1": "<mask token>\n\n\ndef generateComponent(m):\n \"\"\"Creates oscillating components to be mixed\"\"\"\n freq = 25 * np.random.random()\n phase = 2 * np.pi * np.random.random()\n x = np.arange(m)\n return np.cos(x / fr... | [
3,
4,
6,
7,
8
] |
class Solution:
# @param num, a list of integer
# @return an integer
def rob(self, num):
n = len(num)
if n == 0:
return 0
if(n == 1):
return num[0]
f = [0] * n
f[0] = num[0]
f[1] = max(num[0],num[1])
for i in xrange(2,n):
... | normal | {
"blob_id": "bca0baaffefed6917939614defadf9960ffa4727",
"index": 8062,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def rob(self, num):\n n = len(num)\n if n == 0:\n return 0\n if n == 1:\n return num... | [
0,
1,
2,
3
] |
from sys import exit
def hard():
print("Nice! Let's try something harder")
print("Could you calculate this for me?")
print("4 * 35 + 18 / 2 = ")
aws = input(">")
while True:
if aws == "176":
print("Nice, you correctly answer all the questions")
exit(0)
els... | normal | {
"blob_id": "5d05351cd6cd6c0d216e8bc09308532605bfd26e",
"index": 3007,
"step-1": "<mask token>\n\n\ndef easy():\n print('Ok, seems like you are not good at math.')\n print('What about this.')\n print('Say you have 10 apples, your Mom gave you another 2.')\n print('How many apples you have now?')\n ... | [
2,
3,
4,
5,
6
] |
import numpy as np
class Constants():
DNN_DEFAULT_ACTIVATION = 'relu'
DNN_DEFAULT_KERNEL_REGULARIZATION = [0, 5e-5]
DNN_DEFAULT_BIAS_REGULARIZATION = [0, 5e-5]
DNN_DEFAULT_LOSS = 'mean_squared_error'
DNN_DEFAULT_VALIDATION_SPLIT = 0.2
DNN_DEFAULT_EPOCHS = 100
DNN_DEFAULT_CHECKPOINT_PERIOD =... | normal | {
"blob_id": "b2bb7393bf7955f5de30c59364b495b8f888e178",
"index": 4073,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Constants:\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 ... | [
0,
1,
2,
3,
4
] |
""" AuthService class module.
"""
from urllib.parse import urlencode
from http.client import HTTPConnection, HTTPResponse, HTTPException
from dms2021sensor.data.rest.exc import NotFoundError
class AuthService():
""" REST client to connect to the authentication service.
"""
def __init__(self, host: str, ... | normal | {
"blob_id": "1438a268780217e647999ba031aa4a50a6912d2f",
"index": 3069,
"step-1": "<mask token>\n\n\nclass AuthService:\n <mask token>\n <mask token>\n\n def __get_connection(self) ->HTTPConnection:\n \"\"\" Creates a new connection to the authentication server.\n ---\n Returns:\n ... | [
2,
3,
5,
6,
7
] |
from youtube_transcript_api import YouTubeTranscriptApi
transcript_list = YouTubeTranscriptApi.list_transcripts('i8pOulVUz0A')
transcript = transcript_list.find_transcript(['en'])
transcript = transcript.fetch()
with open("transcript.txt", 'w') as f:
for line in transcript:
f.write(line['text']+ '\n') | normal | {
"blob_id": "c2d6e4286e1b9d6dc852bde994da60d353e03e5c",
"index": 8031,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('transcript.txt', 'w') as f:\n for line in transcript:\n f.write(line['text'] + '\\n')\n",
"step-3": "<mask token>\ntranscript_list = YouTubeTranscriptApi.list_trans... | [
0,
1,
2,
3,
4
] |
# 문제 풀이 진행중..(나중에 재도전)
import collections
class Solution(object):
def removeStones(self, stones):
"""
:type stones: List[List[int]]
:rtype: int
"""
# 전체 연결점 개수 확인한다.
# 개수가 적은 것 부터 처리한다
# # 연결된 게 0개인 애들은 제외
#
# data init
stones_share_li... | normal | {
"blob_id": "896329a8b14d79f849e4a8c31c697f3981395790",
"index": 3327,
"step-1": "<mask token>\n\n\nclass Solution(object):\n\n def removeStones(self, stones):\n \"\"\"\n :type stones: List[List[int]]\n :rtype: int\n \"\"\"\n stones_share_list = []\n for i in range(le... | [
2,
3,
4,
5,
6
] |
tej="votary"
for i in range(5):
print(tej[i])
| normal | {
"blob_id": "1f385fda1bdc0008ff91b935998c95c8ffcbd297",
"index": 2797,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(5):\n print(tej[i])\n",
"step-3": "tej = 'votary'\nfor i in range(5):\n print(tej[i])\n",
"step-4": "tej=\"votary\"\nfor i in range(5):\n\tprint(tej[i])\n",
"st... | [
0,
1,
2,
3
] |
__author__ = 'Joe'
import sys
sys.path.insert(0,'../src/')
import grocery_functions
import unittest
class TestGroceryFuncs(unittest.TestCase):
def test_getRecipeNames(self):
recipe_names = grocery_functions.get_recipe_names("test-recipes")
self.assertTrue(recipe_names[0] == "Cajun Chicken & Rice"... | normal | {
"blob_id": "c4fbf206482a04f3e2d2aa98a0dbf525a176c4e7",
"index": 1087,
"step-1": "<mask token>\n\n\nclass TestGroceryFuncs(unittest.TestCase):\n\n def test_getRecipeNames(self):\n recipe_names = grocery_functions.get_recipe_names('test-recipes')\n self.assertTrue(recipe_names[0] == 'Cajun Chicke... | [
4,
8,
12,
14,
15
] |
"""config URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.2/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-based ... | normal | {
"blob_id": "786bc5d44115b46bd246e85e85c8f8c1f20737b9",
"index": 7921,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nrouter.register('species', views.SpeciesViewSet)\nrouter.register('com_names', views.Com_NamesViewSet)\nrouter.register('photos', views.PhotosViewSet)\n<mask token>\nif settings.DEBUG:\n ... | [
0,
1,
2,
3,
4
] |
import pytest
from pandas import (
Index,
NaT,
)
import pandas._testing as tm
def test_astype_str_from_bytes():
# https://github.com/pandas-dev/pandas/issues/38607
idx = Index(["あ", b"a"], dtype="object")
result = idx.astype(str)
expected = Index(["あ", "a"], dtype="object")
tm.assert_inde... | normal | {
"blob_id": "13b2fea09f5a4300563dd8870fe1841b47756b36",
"index": 9972,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_astype_invalid_nas_to_tdt64_raises():\n idx = Index([NaT.asm8] * 2, dtype=object)\n msg = 'Cannot cast Index to dtype timedelta64\\\\[ns\\\\]'\n with pytest.raises(T... | [
0,
1,
2,
3,
4
] |
from os import environ
import boto3
from flask import Flask, redirect
from flask_sqlalchemy import SQLAlchemy
from json import load
from pathlib import Path
path = Path(__file__).parent
db = SQLAlchemy()
with open(path / "../schemas.json", "r") as fp:
schemas = load(fp)
with open(path / "../config.json", "r"... | normal | {
"blob_id": "631904ae96584bd19756f9335175a419397ac252",
"index": 8562,
"step-1": "<mask token>\n\n\n@app.route('/')\ndef redirect_to_swagger():\n return redirect('/swagger', 302)\n",
"step-2": "<mask token>\nwith open(path / '../schemas.json', 'r') as fp:\n schemas = load(fp)\nwith open(path / '../config... | [
1,
2,
3,
4,
5
] |
# A perfect number is a number for which the sum of its proper divisors is exactly equal to the number.
# For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28,
# which means that 28 is a perfect number.
#
# A number whose proper divisors are less than the number is called deficient a... | normal | {
"blob_id": "8ca77ed608108a9aa693acb686156e661794d7ab",
"index": 394,
"step-1": "# A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. \r\n# For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, \r\n# which means that 28 is a perfect... | [
0
] |
import dlib
import cv2
import imageio
import torch
from PIL import Image
from model import AgeGenderModel
from mix_model import MixModel
from torchvision.transforms import transforms
from tqdm import tqdm
from retinaface.pre_trained_models import get_model
transform = transforms.Compose([
transforms.Resize((112,... | normal | {
"blob_id": "1cc14836808d70c1e53a9ca948a52776ebc89f4a",
"index": 4624,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmodel.load_state_dict(ckpt['model_state_dict'])\nmodel.eval()\nmodel.to(device)\n<mask token>\nmodel_face.eval()\n<mask token>\nfor img in tqdm(video):\n if img is not None:\n a... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from contextlib import suppress
import asyncio
import shutil
from aiohttp import web
from bot import app
from var import var
from logger import update_logging_files
loop = asyncio.get_event_loop()
def import_handlers():
from deezer import handlers, callback_handle... | normal | {
"blob_id": "d957fd5fbcdcf2e549323677185eabb8a50536c6",
"index": 5716,
"step-1": "<mask token>\n\n\ndef import_handlers():\n from deezer import handlers, callback_handlers\n from spotify import handlers, integration, callback_handlers\n from vk import handlers, callback_handlers\n from soundcloud imp... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/python2.7
import os, sys
COMPILER = "gcc"
SRC_DIR = "../src"
INCLUDE_DIR = "../src"
BIN_DIR = "../bin"
BIN_NAME = False
CFLAGS = ["-O3", "-Wall", "-Wextra", "--std=c89", "-pedantic"]
DLIBS = ["ws2_32"] if os.name == "nt" else []
DEFINES = []
def strformat(fmt, var):
for k in... | normal | {
"blob_id": "1b4c86fe3aae25aeec6cd75fa8177983ce9d14a2",
"index": 1819,
"step-1": "#!/usr/bin/python2.7\nimport os, sys\n\nCOMPILER = \"gcc\"\nSRC_DIR = \"../src\"\nINCLUDE_DIR = \"../src\"\nBIN_DIR = \"../bin\"\nBIN_NAME = False\nCFLAGS = [\"-O3\", \"-Wall\", \"-Wextra\", \"--std=c89\", \"-ped... | [
0
] |
import smart_imports
smart_imports.all()
class LogicTests(utils_testcase.TestCase):
def setUp(self):
super(LogicTests, self).setUp()
game_logic.create_test_map()
self.account_1 = self.accounts_factory.create_account()
self.account_1_items = prototypes.AccountItemsPrototype.ge... | normal | {
"blob_id": "89e5e82c073f7f87c00fc844c861c6c5cbe6a695",
"index": 8893,
"step-1": "<mask token>\n\n\nclass LogicTests(utils_testcase.TestCase):\n\n def setUp(self):\n super(LogicTests, self).setUp()\n game_logic.create_test_map()\n self.account_1 = self.accounts_factory.create_account()\n ... | [
5,
6,
7,
8,
9
] |
#the method of same name present in any class, it is call by anywhere
#object of different type is responds to same methods
class pycharm:
def execute(self):
print("COde check")
print("compile")
class MyEditor:
def execute(self):
print("Spell Cheack")
print("Auto COmpile")
... | normal | {
"blob_id": "3ec162070f79ae38d6ae3ceb858c15b6e39f7027",
"index": 9870,
"step-1": "<mask token>\n\n\nclass MyEditor:\n\n def execute(self):\n print('Spell Cheack')\n print('Auto COmpile')\n print('COde check')\n print('compile')\n\n\nclass laptop:\n\n def code(self, ide):\n ... | [
4,
6,
7,
8,
9
] |
import pandas as pd
import numpy as np
import json
from pprint import pprint
from shapely.geometry import shape, Point
from geopy.geocoders import Nominatim
from geopy.exc import GeocoderTimedOut
from geopy.exc import GeocoderServiceError
import collections
from matplotlib import pyplot as plt
import time
import csv
... | normal | {
"blob_id": "c1bb2052b3f623c6787ba080dff2dc81f4d6f55e",
"index": 1818,
"step-1": "import pandas as pd\nimport numpy as np\nimport json\nfrom pprint import pprint\nfrom shapely.geometry import shape, Point\nfrom geopy.geocoders import Nominatim\nfrom geopy.exc import GeocoderTimedOut\nfrom geopy.exc import Geocod... | [
0
] |
""" Generate test pads for padder. """
# usage: python gen.py > pads.txt
import random
pad = ""
count = 0
# The pad chars MUST match the character set used by padder.
# See the 'characters' variable in 'main.hpp' for more
# information.
chars = "abcdefghijklmnopqrstuvwxyz0123456789-"
print "#", "Pad"
while count... | normal | {
"blob_id": "2cdcd6976a1ec99b927adcedc48c36bbda1b4e18",
"index": 1005,
"step-1": "\"\"\" Generate test pads for padder. \"\"\"\n\n# usage: python gen.py > pads.txt\n\nimport random\n\npad = \"\"\ncount = 0\n\n# The pad chars MUST match the character set used by padder.\n# See the 'characters' variable in 'main... | [
0
] |
"""Unit tests for misc. ticket functions."""
from pdm_utils.classes import bundle
from pdm_utils.classes import genome
from pdm_utils.classes import ticket
from pdm_utils.classes import eval
from pdm_utils.functions import tickets
from pdm_utils.constants import constants
import unittest
class TestTicketFunctions... | normal | {
"blob_id": "d8ba2557e20920eaadd2fd35f0ebdf1b4a5b33da",
"index": 9010,
"step-1": "<mask token>\n\n\nclass TestTicketFunctions1(unittest.TestCase):\n\n def setUp(self):\n self.required_keys = constants.IMPORT_TABLE_STRUCTURE['required']\n self.optional_keys = constants.IMPORT_TABLE_STRUCTURE['opt... | [
22,
24,
27,
39,
40
] |
# -- coding: utf-8 --
from django.conf.urls import url
from myapp.view import views
from myapp.view import story
from myapp.view import img # 添加
from myapp.view import login
from myapp.view import tuling
from myapp.view import utilView
from myapp.view.wechat import wechat_modules
from myapp.view import router
urlpatt... | normal | {
"blob_id": "373c102018fdcc5211263304c368c2e8beef3257",
"index": 720,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('get_img_api$', router.get_img_api), url('add_book$',\n views.add_book), url('show_books$', views.show_books), url('add_story$',\n story.add_story), url('show_stor... | [
0,
1,
2,
3
] |
import random
from z3 import *
def combine(iter):
tmp_list = [i for i in iter]
res = tmp_list[0]
for i in tmp_list[1:]:
res += i
return res
def co_prime(num1, num2):
for num in range(2, min(num1, num2) + 1):
if num1 % num == 0 and num2 % num == 0:
return False
re... | normal | {
"blob_id": "81fce5314a7611de11648e412151112e29271871",
"index": 4626,
"step-1": "<mask token>\n\n\nclass FormulaTemplate:\n\n def __init__(self, vi, w, k, h, m, timeout=3000000):\n self.k = k\n self.h = h\n self.m = m\n self.w = w\n self.vi = vi\n n = len(vi)\n ... | [
11,
14,
15,
16,
22
] |
from django import forms
from django.core import validators
class NameSearch(forms.Form):
name = forms.CharField(label='Search By Name')
| normal | {
"blob_id": "7620ff333422d0354cc41c2a66444c3e8a0c011f",
"index": 1606,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass NameSearch(forms.Form):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass NameSearch(forms.Form):\n name = forms.CharField(label='Search By Name')\n",
"step-4": "f... | [
0,
1,
2,
3
] |
import torch
from torch import nn
import torch.nn.functional as F
import numpy as np
from config_pos import config
from backbone.resnet50 import ResNet50
from backbone.fpn import FPN
from module.rpn import RPN
from layers.pooler import roi_pooler
from det_oprs.bbox_opr import bbox_transform_inv_opr
from det_oprs.bbox_... | normal | {
"blob_id": "6ac13665c2348bf251482f250c0fcc1fc1a8af75",
"index": 4721,
"step-1": "<mask token>\n\n\nclass Network(nn.Module):\n\n def __init__(self):\n super().__init__()\n self.resnet50 = ResNet50(config.backbone_freeze_at, False)\n self.FPN = FPN(self.resnet50, 2, 6)\n self.RPN =... | [
5,
6,
7,
8,
11
] |
from time import strftime
from Stats.SQL.Compteur import compteurSQL
from Stats.SQL.Rapports import rapportsSQL
from Stats.SQL.Daily import dailySQL
from Stats.SQL.CompteurP4 import compteurJeuxSQL
from Stats.SQL.Historique import histoSQL, histoSQLJeux
from Stats.SQL.ConnectSQL import connectSQL
tableauMois={"01":"ja... | normal | {
"blob_id": "19ff064f8c27b9796eb435c7d2b9ebf87ee90ad6",
"index": 7982,
"step-1": "<mask token>\n\n\ndef exeObj(count, idObj, id, obj, guild, nom):\n dateID = int(strftime('%y') + strftime('%m') + strftime('%d'))\n connexionGL, curseurGL = connectSQL(guild.id, nom, 'Stats', 'GL', '')\n connexion, curseur... | [
2,
3,
4,
5,
6
] |
import sys
import time
import math
from neopixel import *
count = int(sys.argv[1])
percent = int(sys.argv[2])
# LED strip configuration:
LED_COUNT = count # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (must support PWM!).
LED_FREQ_HZ = 800000 # LED signal frequency in he... | normal | {
"blob_id": "5ff7a3843314dfd3914c5e96164385d61fbe7fa5",
"index": 684,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef setPixel(strip):\n for i in range(count):\n if i < lightUp:\n strip.setPixelColor(i, Color(0, 255, 0))\n strip.show()\n else:\n st... | [
0,
2,
3,
4,
5
] |
# -*- coding: utf-8 -*-
from .log_config import LogBase
import os
__all__ = ['MyLog']
class MyLog(LogBase):
"""
功能:
将日志分日志等级记录,并自动压缩2019-11-11.info.log.gz
参数:
:param dir_path: 日志记录的路径,默认是当前路径下的log文件夹
:param logger_name: logger对象的名字
:param info_name: 保存inf... | normal | {
"blob_id": "3a9987ac326131878b80cb819e3d06ce2f4cb054",
"index": 8461,
"step-1": "<mask token>\n\n\nclass MyLog(LogBase):\n <mask token>\n <mask token>\n\n def get_logger(self):\n return self._get_logger()\n\n @staticmethod\n def type_need(parm, type_):\n if not isinstance(parm, type... | [
3,
5,
6,
7,
8
] |
import sys
heights = []
for i in range(10):
line = sys.stdin.readline()
height = int(line)
heights.append(height)
heights.sort()
heights.reverse()
for i in range(3):
print(heights[i])
| normal | {
"blob_id": "3e48de2e3b12965de1b3b5cb6c3cf68c90ec6212",
"index": 2274,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(10):\n line = sys.stdin.readline()\n height = int(line)\n heights.append(height)\nheights.sort()\nheights.reverse()\nfor i in range(3):\n print(heights[i])\n",
... | [
0,
1,
2,
3
] |
def primeiras_ocorrencias(str):
dic = {}
for i, letra in enumerate(str):
if letra not in dic:
dic[letra] = i
return dic
| normal | {
"blob_id": "bb1a6815649eb9e79e2ab1e110ea8acd8adce5aa",
"index": 3379,
"step-1": "<mask token>\n",
"step-2": "def primeiras_ocorrencias(str):\n dic = {}\n for i, letra in enumerate(str):\n if letra not in dic:\n dic[letra] = i\n return dic\n",
"step-3": null,
"step-4": null,
"s... | [
0,
1
] |
num=int(input("Enter the number: "))
table=[num*i for i in range(1,11)]
print(table)
with open("table.txt","a") as f:
f.write(f"{num} table is: {str(table)}")
f.write('\n') | normal | {
"blob_id": "657ac500c40ddbd29f5e3736a78ed43e7d105478",
"index": 9417,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(table)\nwith open('table.txt', 'a') as f:\n f.write(f'{num} table is: {str(table)}')\n f.write('\\n')\n",
"step-3": "num = int(input('Enter the number: '))\ntable = [(num * ... | [
0,
1,
2,
3
] |
import re
BASICPATTERN = '[!/](%s)\s{,1}(.*)' # example "/animefind baka" -> (animefind, baka)
# returns compiled BASICPATTERN for each given string
def basicRegex(strings):
if not isinstance(strings,list):
return []
ans = []
for string in strings:
pattern = re.compile(BASICPATTERN % st... | normal | {
"blob_id": "1a28aea824752d18cbd462693f8f8980dba4974e",
"index": 9387,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef basicRegex(strings):\n if not isinstance(strings, list):\n return []\n ans = []\n for string in strings:\n pattern = re.compile(BASICPATTERN % string.strip(... | [
0,
1,
2,
3,
4
] |
# bot.py
import os
import shutil
import discord
import youtube_dl
from discord.ext import commands
import urllib.parse
import urllib.request
import re
import dotenv
from pathlib import Path # Python 3.6+ only
from dotenv import load_dotenv
env_path = Path('.') / '.env'
load_dotenv(dotenv_path=env_path)
client = disc... | normal | {
"blob_id": "94ca18088664393fdfdc68bfb8bcad8b78e9e36a",
"index": 7887,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nload_dotenv(dotenv_path=env_path)\n<mask token>\n\n\n@botCommand.event\nasync def on_ready():\n print(f'{client.user} is connected to the following guild:\\n')\n\n\n@botCommand.command... | [
0,
1,
2,
3,
4
] |
from django.db.models import Q, Avg
from django.http import JsonResponse
from rest_framework import permissions
from rest_framework.authtoken.models import Token
from rest_framework.authtoken.views import ObtainAuthToken
from rest_framework.decorators import action
from rest_framework.response import Response
from rest... | normal | {
"blob_id": "9e8b5cebd48b3b98e421c896d9835ada5ec4166e",
"index": 2740,
"step-1": "<mask token>\n\n\nclass RestaurantViewSet(ModelViewSet):\n serializer_class = RestaurantSerializer\n permission_classes = [permissions.IsAuthenticatedOrReadOnly]\n queryset = Restaurant.objects.all()\n\n def _get_recomm... | [
34,
40,
41,
42,
56
] |
# https://github.com/jscancella/NYTribuneOCRExperiments/blob/master/findText_usingSums.py
import os
import io
from pathlib import Path
import sys
os.environ['OPENCV_IO_ENABLE_JASPER']='True' # has to be set before importing cv2 otherwise it won't read the variable
import numpy as np
import cv2
import subprocess
from ... | normal | {
"blob_id": "91d240b02b9d7a6c569656337521482d57918754",
"index": 4333,
"step-1": "<mask token>\n\n\ndef adaptative_thresholding(img, threshold):\n I = img\n gray = cv2.cvtColor(I, cv2.COLOR_BGR2GRAY)\n orignrows, origncols = gray.shape\n M = int(np.floor(orignrows / 16) + 1)\n N = int(np.floor(ori... | [
6,
7,
8,
11,
13
] |
from django.test import TestCase
# Create your tests here.
def Add_course(self,user):
| normal | {
"blob_id": "7fc239e7f44c5f6a8e5bebe3e4910aee4d8e4af3",
"index": 9266,
"step-1": "from django.test import TestCase\n\n# Create your tests here.\n\ndef Add_course(self,user):\n\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
#!/usr/bin/python3
experiment_name = "nodes10"
wall = "wall2"
wall_image = "irati_110"
mr_dif_policy = True
spn_dif_policy = True
destination_ip = "2001:40b0:7500:286:84:88:81:57"
| normal | {
"blob_id": "78db25586f742b0a20bc3fad382b0d4f1a271841",
"index": 3970,
"step-1": "<mask token>\n",
"step-2": "experiment_name = 'nodes10'\nwall = 'wall2'\nwall_image = 'irati_110'\nmr_dif_policy = True\nspn_dif_policy = True\ndestination_ip = '2001:40b0:7500:286:84:88:81:57'\n",
"step-3": "#!/usr/bin/python3... | [
0,
1,
2
] |
from fgpio import GPIO
import boards
| normal | {
"blob_id": "f66f79cd4132b23c082149a3a1d887f661fd7ee5",
"index": 7247,
"step-1": "<mask token>\n",
"step-2": "from fgpio import GPIO\nimport boards\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
# %%
import pandas as pd
import numpy as np
from dataprep.eda import plot
from dataprep.eda import plot_correlation
from dataprep.eda import plot_missing
import matplotlib.pyplot as plt
import seaborn as sns
sns.set(style="whitegrid", color_codes=True)
sns.set(font_scale=1)
# %%
# Minimal Processing
wines = pd.read... | normal | {
"blob_id": "79e8ed64058dda6c8d7bacc08727bc978088ad2d",
"index": 4963,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsns.set(style='whitegrid', color_codes=True)\nsns.set(font_scale=1)\n<mask token>\nwines.columns\nwines.drop(columns='Unnamed: 0', inplace=True)\nwines.dropna(axis='index', subset=['price... | [
0,
1,
2,
3,
4
] |
import pandas as pd
import os
from appia.processors.core import normalizer
from math import ceil
class Experiment:
def __init__(self, id) -> None:
self.id = id
self.version = 4
self._hplc = None
self._fplc = None
@property
def hplc(self):
try:
return se... | normal | {
"blob_id": "754b34028780231c7eccb98cdf3e83bd615d843f",
"index": 5276,
"step-1": "<mask token>\n\n\nclass Experiment:\n <mask token>\n <mask token>\n\n @hplc.setter\n def hplc(self, df):\n if isinstance(df, pd.DataFrame) or df is None:\n try:\n self._hplc = df.sort_va... | [
11,
14,
19,
20,
21
] |
try:
from setuptools import setup
from setuptools import find_packages
has_setup_tools = true
except ImportError:
from distutils.core import setup
has_setup_tools = false
with open("README.md", "r") as fh:
long_description = fh.read()
if has_setup_tools is True:
packages = setuptools.find_... | normal | {
"blob_id": "5d988d159902e4a4cb17ee0ec61153de2dda4691",
"index": 9120,
"step-1": "<mask token>\n",
"step-2": "try:\n from setuptools import setup\n from setuptools import find_packages\n has_setup_tools = true\nexcept ImportError:\n from distutils.core import setup\n has_setup_tools = false\nwit... | [
0,
1,
2
] |
import os
import numpy as np
from . import tmp_dir_fixture
from . import TEST_SAMPLE_DATA
def test_tensor_dataset_functional():
from dtoolai.data import TensorDataSet
tds_uri = os.path.join(TEST_SAMPLE_DATA, "example_tensor_dataset")
tds = TensorDataSet(tds_uri)
assert tds.name == "example_tenso... | normal | {
"blob_id": "97dfcce6e82ef33334b49de72bb126150dfef196",
"index": 2844,
"step-1": "<mask token>\n\n\ndef test_create_tensor_dataset_from_arrays(tmp_dir_fixture):\n pass\n",
"step-2": "<mask token>\n\n\ndef test_image_dataset_functional():\n from dtoolai.data import ImageDataSet\n ids_uri = 'http://bit.... | [
1,
2,
3,
4,
5
] |
import pytest
from debbiedowner import make_it_negative, complain_about
def test_negativity():
assert make_it_negative(8) == -8
assert complain_about('enthusiasm') == "I hate enthusiasm. Totally boring."
def test_easy():
assert 1 == 1
def test_cleverness():
assert make_it_negative(-3) == 3 | normal | {
"blob_id": "e73e40a63b67ee1a6cca53a328af05e3eb3d8519",
"index": 703,
"step-1": "<mask token>\n\n\ndef test_negativity():\n assert make_it_negative(8) == -8\n assert complain_about('enthusiasm') == 'I hate enthusiasm. Totally boring.'\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_negativity... | [
1,
2,
3,
4,
5
] |
name = input("Введите ваше имя ")
print("Добрый день,", name)
| normal | {
"blob_id": "e44c4b2c3b60d34d4540ec2d3a782c777c52fbc0",
"index": 8662,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Добрый день,', name)\n",
"step-3": "name = input('Введите ваше имя ')\nprint('Добрый день,', name)\n",
"step-4": "name = input(\"Введите ваше имя \")\nprint(\"Добрый день,\", n... | [
0,
1,
2,
3
] |
#!/usr/bin/env python2
import os
import sys
import textwrap
COMMAND = (
'convert -size 1920x1080 canvas:"rgb(149, 1, 1)" '
'-font Dejavu-Sans-Bold -pointsize {0} -gravity center -stroke none '
'-fill white -annotate 0 "{1}" -size 1920x1080 "{2}.png"'
)
def makeimage(text, point_size=100, width=30):
t... | normal | {
"blob_id": "a486ec6b27a6b84e454a1bed096be9fe22d91612",
"index": 1561,
"step-1": "<mask token>\n\n\ndef makeimage(text, point_size=100, width=30):\n tw = textwrap.TextWrapper(width=width)\n text = '\\n'.join(a.replace('\\\\n', '\\n') for a in tw.wrap(text))\n filename = ''.join(c for c in text.replace('... | [
2,
3,
4,
5,
6
] |
import smtplib
from email.message import EmailMessage
from functools import wraps
from threading import Thread
import flask_login
from flask import flash, current_app
from togger import db
from togger.auth.models import User, Role
from togger.calendar.models import Calendar
def get_user(username):
if username i... | normal | {
"blob_id": "fab3e524edf6783775fabf402f9148bf31ac06d6",
"index": 2914,
"step-1": "<mask token>\n\n\ndef get_user_by_id(id):\n if id is None:\n return\n user = User.query.filter(User.alias_id == id).first()\n return user\n\n\n<mask token>\n\n\ndef update_user(first_name, last_name):\n user = fl... | [
11,
12,
13,
15,
16
] |
import os
import pytest
def get_client():
from apiserver import app, is_caching_enabled
app.config['TESTING'] = True
app.enable_cache(is_caching_enabled())
return app.test_client()
@pytest.fixture
def client():
os.environ['FLASK_ENV'] = 'testing'
yield get_client()
@pytest.fixture
def clie... | normal | {
"blob_id": "c0b5a0605bdfcb7cb84211d3ad0d24f78f838cdf",
"index": 5421,
"step-1": "<mask token>\n\n\n@pytest.fixture\ndef client():\n os.environ['FLASK_ENV'] = 'testing'\n yield get_client()\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_client():\n from apiserver import app, is_caching_ena... | [
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding:utf-8 _*-
"""
:Author :weijinlong
:Time: :2020/1/10 17:22
:File :graph.py
:content:
"""
import tensorflow as tf
from .base import TFLayer
class TFModel(TFLayer):
def build_model(self):
raise NotImplementedError
def add_outputs(self, *a... | normal | {
"blob_id": "cdabb4a118cb0ef55c271a446fa190a457ebe142",
"index": 7383,
"step-1": "<mask token>\n\n\nclass TFCompile(TFLayer):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass TFComModel(TFModel, TFCompile):\n \"\"\"\n 基于TensorFlow的复合模型,即使用一个算子构建模型的和模型的编译\n \"\"\"\n\n def build_model(s... | [
5,
8,
10,
11,
13
] |
import math
def sieve(limit):
ans = []
a = [1] * limit
a[0] = a[1] = 0
for i in range(2, limit):
if a[i] == 0:
continue
ans.append(i)
for j in range(i*i, limit, i):
a[j] = 0;
return ans
is_square = lambda x: int(math.sqrt(x) + 1e-9) ** 2 == x
N = 10... | normal | {
"blob_id": "ff6dc347637a81c9f6a541775646b4901d719790",
"index": 9478,
"step-1": "<mask token>\n\n\ndef sieve(limit):\n ans = []\n a = [1] * limit\n a[0] = a[1] = 0\n for i in range(2, limit):\n if a[i] == 0:\n continue\n ans.append(i)\n for j in range(i * i, limit, i)... | [
1,
2,
3,
4,
5
] |
"""
"""
import os
import json
import csv
cutoff = float(input("Tolerance (decimal)? "))
docpath = "C:/Users/RackS/Documents/"
out = open("isosegmenter_scoring_error"+str(cutoff*100)+".csv", 'w', encoding='UTF-8')
summary = open("isosegmenter_score_summary_error"+str(cutoff*100)+".txt", 'w', encoding='UTF-8')
out.write... | normal | {
"blob_id": "af2aa236f6bfc582093faf868a374be1ebdfabf2",
"index": 1235,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nout.write('SEQUENCE_ID,TYPE,DOMAINS,TP,FP,FN,Sens,PPV,Jaccard\\n')\n<mask token>\nfor file in os.listdir(docpath + 'isoSegmenter100'):\n if file.endswith('.csv') and 'E' in file:\n ... | [
0,
1,
2,
3,
4
] |
import renderdoc as rd
from typing import List
import rdtest
class D3D12_Resource_Mapping_Zoo(rdtest.TestCase):
demos_test_name = 'D3D12_Resource_Mapping_Zoo'
def test_debug_pixel(self, x, y, test_name):
pipe: rd.PipeState = self.controller.GetPipelineState()
if not pipe.GetShaderReflection(... | normal | {
"blob_id": "565888d771f53934805555390e48d4886a43bdb6",
"index": 189,
"step-1": "<mask token>\n\n\nclass D3D12_Resource_Mapping_Zoo(rdtest.TestCase):\n <mask token>\n <mask token>\n\n def check_capture(self):\n if not self.controller.GetAPIProperties().shaderDebugging:\n rdtest.log.suc... | [
2,
3,
4,
5,
6
] |
"""
Platformer Game
"""
import arcade
import os
from Toad_arcade import Toad
# Constants
SCREEN_WIDTH = 1920
SCREEN_HEIGHT = 1080
SCREEN_TITLE = "PyToads - Battletoads reimplementation"
# Constants used to scale our sprites from their original size
CHARACTER_SCALING = 1
TILE_SCALING = 0.5
COIN_SCALING = 0.5
MOVEMENT_S... | normal | {
"blob_id": "28d8f9d9b39c40c43a362e57a7907c0a38a6bd05",
"index": 748,
"step-1": "<mask token>\n\n\nclass MyGame(arcade.Window):\n <mask token>\n\n def __init__(self, width, height, title):\n \"\"\"\n Initializer\n \"\"\"\n super().__init__(width, height, title)\n file_pat... | [
6,
7,
9,
12,
13
] |
# coding: utf-8
'''
Programa : py02_variavel.py
Homepage : http://www
Autor : Helber Palheta <hpalheta@outlook.com>
Execução:
python py02_variavel.py
'''
#variável curso e sua atribuição
curso = "Introdução a Biopython!"
#função print
print("Nome do Curso: "+curso) | normal | {
"blob_id": "ad59c1f0038294144b1c63db5f048b0a6b5ebb89",
"index": 4654,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Nome do Curso: ' + curso)\n",
"step-3": "<mask token>\ncurso = 'Introdução a Biopython!'\nprint('Nome do Curso: ' + curso)\n",
"step-4": "# coding: utf-8\n'''\n \n Programa... | [
0,
1,
2,
3
] |
from trac.db import DatabaseManager
def do_upgrade(env, ver, cursor):
"""Change schema name from taskboard_schema to agiletools_version
"""
cursor.execute('UPDATE system SET name=%s WHERE name=%s',
("agiletools_version", "taskboard_schema"))
| normal | {
"blob_id": "56ed5bb22d77f4d8c061f97d832a60ed9a106549",
"index": 5231,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef do_upgrade(env, ver, cursor):\n \"\"\"Change schema name from taskboard_schema to agiletools_version\n \"\"\"\n cursor.execute('UPDATE system SET name=%s WHERE name=%s', ... | [
0,
1,
2,
3
] |
import math
import decimal
from typing import Union, List, Set
from sqlalchemy import text
from .model import BaseMixin
from ..core.db import db
Orders = List[Set(str, Union(str, int, decimal.Decimal))]
class BaseDBMgr:
def get_page(self, cls_:BaseMixin, filters:set, orders:Orders=list(), field:tuple=(), pag... | normal | {
"blob_id": "2c90c4e0b42a75d6d387b9b2d0118d8e991b5a08",
"index": 39,
"step-1": "<mask token>\n\n\nclass BaseDBMgr:\n\n def get_page(self, cls_: BaseMixin, filters: set, orders: Orders=list(),\n field: tuple=(), page: int=1, per_page: int=10) ->dict:\n \"\"\"获取分页数据\n @param BaseMixin cls 数... | [
3,
7,
8,
9,
11
] |
#!/usr/bin/python
#Autor: Jesus Fabian Cubas <jfabian@computer.org>
#if
sesion = 2
if sesion == 1 :
print 'estamos en la sesion 01'
elif sesion == 2 :
print 'estamos en la sesion 02'
else :
print 'no estamos en la sesion 01'
#while
edad = 0
while edad < 18 :
edad = edad + 1
print edad
#for
lista = ["a", "b", "c"... | normal | {
"blob_id": "64c4b64b6fb0cfa25c17f66243c60a5dc0166017",
"index": 7698,
"step-1": "#!/usr/bin/python\n#Autor: Jesus Fabian Cubas <jfabian@computer.org>\n\n#if\nsesion = 2\nif sesion == 1 :\n\tprint 'estamos en la sesion 01'\nelif sesion == 2 :\n\tprint 'estamos en la sesion 02'\nelse :\n\tprint 'no estamos en la ... | [
0
] |
from django.db import models
from datetime import datetime
# Message model for testing purposes
class Message(models.Model):
type = models.CharField(max_length=10)
body = models.CharField(max_length=50)
def __str__(self):
return self.type + ":" + self.body
# Company model
class Co... | normal | {
"blob_id": "47f6c4b3c279a065b8f21dab2faa71271db8d6ab",
"index": 6680,
"step-1": "<mask token>\n\n\nclass Company(models.Model):\n <mask token>\n\n @classmethod\n def create(cls, name):\n company = cls(name=name)\n return company\n\n def __str__(self):\n return self.name\n\n\ncla... | [
7,
8,
11,
12,
13
] |
class NumMatrix(object):
def __init__(self, matrix):
if matrix:
self.dp = [[0] * (len(matrix[0]) + 1) for i in range(len(matrix)+1)]
for i in xrange(1,len(matrix)+1):
for j in xrange(1,len(matrix[0])+1):
self.dp[i][j] = self.dp[i-1][j] + self.... | normal | {
"blob_id": "443ce5c2ec86b9f89ad39ef2ac6772fa002e7e16",
"index": 8377,
"step-1": "class NumMatrix(object):\n\n def __init__(self, matrix):\n if matrix:\n self.dp = [[0] * (len(matrix[0]) + 1) for i in range(len(matrix)+1)]\n for i in xrange(1,len(matrix)+1):\n for j... | [
0
] |
conf = {'PROJECT': 'WCCIA', 'NAS_FOLDER':
'Q:\\GROUPS\\CORP_JGS_DSE\\ATI\\quotations', 'DB_SERVER': '10.0.36.129',
'DB_PORT': '34000/'}
| normal | {
"blob_id": "fbce185671267bd70cf7b91696867b72dfcc8d5b",
"index": 1585,
"step-1": "<mask token>\n",
"step-2": "conf = {'PROJECT': 'WCCIA', 'NAS_FOLDER':\n 'Q:\\\\GROUPS\\\\CORP_JGS_DSE\\\\ATI\\\\quotations', 'DB_SERVER': '10.0.36.129',\n 'DB_PORT': '34000/'}\n",
"step-3": null,
"step-4": null,
"step... | [
0,
1
] |
import urllib3
import json
def download(url):
print('Downloading ', url)
userAgent = 'Mozilla/5.0 (Linux; U; Android 10; zh-cn; MI 9 Build/QKQ1.190825.002) AppleWebKit/533.1 (KHTML, like Gecko) Version/5.0 Mobile Safari/533.1'
userAgent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/5... | normal | {
"blob_id": "9d302ff2de8280bd8786794cdd533107d2a458bc",
"index": 5611,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef download(url):\n print('Downloading ', url)\n userAgent = (\n 'Mozilla/5.0 (Linux; U; Android 10; zh-cn; MI 9 Build/QKQ1.190825.002) AppleWebKit/533.1 (KHTML, like Ge... | [
0,
1,
2,
3,
4
] |
"""Proper parenthetics extra credit kata."""
from _que_structure import Q
def proper_parenthetics(string):
"""Return if parentheses are matching or not."""
if isinstance(string, str):
paren_q = Q()
for i in range(len(string)):
paren_q.enqueue(string[i])
opening_parens = 0
... | normal | {
"blob_id": "a28ece0db9bf0d4c3ab26207216b1da45f7aaa0f",
"index": 7582,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef proper_parenthetics(string):\n \"\"\"Return if parentheses are matching or not.\"\"\"\n if isinstance(string, str):\n paren_q = Q()\n for i in range(len(string... | [
0,
1,
2,
3
] |
import FWCore.ParameterSet.Config as cms
from RecoTracker.MeasurementDet.UpdaterService_cfi import *
from RecoTracker.MeasurementDet.MeasurementTrackerESProducer_cfi import *
| normal | {
"blob_id": "e79505e802a06f091bbb12708c45e04c4e80da60",
"index": 7618,
"step-1": "<mask token>\n",
"step-2": "import FWCore.ParameterSet.Config as cms\nfrom RecoTracker.MeasurementDet.UpdaterService_cfi import *\nfrom RecoTracker.MeasurementDet.MeasurementTrackerESProducer_cfi import *\n",
"step-3": null,
... | [
0,
1
] |
"""
CP1404 Practical
unreliable car test
"""
from unreliable_car import UnreliableCar
def main():
good_car = UnreliableCar("good car", 100, 80)
bad_car = UnreliableCar("bad car", 100, 10)
for i in range(10):
print("try to drive {} km".format(i))
print("{:10} drove {:2}km".format(good_car.... | normal | {
"blob_id": "f29ad02f3781c7a7d2a1f0c97626dd5c7ea2417e",
"index": 7867,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n good_car = UnreliableCar('good car', 100, 80)\n bad_car = UnreliableCar('bad car', 100, 10)\n for i in range(10):\n print('try to drive {} km'.format(i))... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from datetime import datetime
archivo = open("salida2.csv", "a+")
startTime = datetime.now()
def mergeSort(alist):
print("Splitting ",alist)
if len(alist)>1:
mid = len(alist)//2
lefthalf = alist[:mid]
righthalf = alist[mid:]
merge... | normal | {
"blob_id": "9e98c6b59433369bca3d4f7ae261f7e7ab3aae6b",
"index": 4161,
"step-1": "<mask token>\n\n\ndef mergeSort(alist):\n print('Splitting ', alist)\n if len(alist) > 1:\n mid = len(alist) // 2\n lefthalf = alist[:mid]\n righthalf = alist[mid:]\n mergeSort(lefthalf)\n m... | [
1,
2,
3,
4,
5
] |
from UI.Window import Window
class PolygonApplication:
def __init__(self):
self.window = Window(
"Détermination des périmètre, surface et centre de gravité d'un polygone"
)
self.window.addMouseClickListener(self.window.onClick)
def start(self):
self.window.sho... | normal | {
"blob_id": "795bd22fb805069b342915638c52900ea52a4939",
"index": 9321,
"step-1": "<mask token>\n\n\nclass PolygonApplication:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass PolygonApplication:\n <mask token>\n\n def start(self):\n self.window.show()\n",
"step-3": "<ma... | [
1,
2,
3,
4
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.