code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
"""
An wrapper around openid's fetcher to be used in django.
"""
from openid import fetchers
class UrlfetchFetcher(fetchers.HTTPFetcher):
def fetch(self, url, body=None, headers=None):
return fetchers.fetch(body, headers)
| normal | {
"blob_id": "14e247b7b586242bfc17507fece3c60b7b8a3025",
"index": 9604,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass UrlfetchFetcher(fetchers.HTTPFetcher):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass UrlfetchFetcher(fetchers.HTTPFetcher):\n\n def fetch(self, url, body=None, h... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('All users are: ', list_users(api_key, region))
<|reserved_special_token_0|>
enroll_user(api_key, region, wav_path, profile_id)
print(f'Likelihood that {wav_path} came from this subject')
identify_user(api_key, region, wav_p... | flexible | {
"blob_id": "5195dcf262c0be08f83cf66e79d48e51811a67a0",
"index": 6866,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('All users are: ', list_users(api_key, region))\n<mask token>\nenroll_user(api_key, region, wav_path, profile_id)\nprint(f'Likelihood that {wav_path} came from this subject')\nident... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
from sklearn.feature_extraction.text import TfidfVectorizer
import sentimentAnalysis as sA
import sys
import os
import numpy as np
from sklearn import decomposition
from gensim import corpora, models
if len(sys.argv) > 1:
keyword = sys.argv[1]
else:
keyword = 'data'
... | normal | {
"blob_id": "ee47b60274ed2eb53a05203e0086d7815bcaaa6e",
"index": 7759,
"step-1": "# -*- coding: utf-8 -*-\r\n\r\nfrom sklearn.feature_extraction.text import TfidfVectorizer\r\nimport sentimentAnalysis as sA\r\nimport sys\r\nimport os\r\nimport numpy as np\r\nfrom sklearn import decomposition\r\nfrom gensim impor... | [
0
] |
from django.db import models
from django.contrib.auth.models import AbstractUser, BaseUserManager
class UserManager(BaseUserManager):
#Necesar pentru a scoate username de la required
def create_user(self, email, password, **kwargs):
user = self.model(email=email, **kwargs)
user.set_password(... | normal | {
"blob_id": "85b8ffe1bca879acd86251e4662b33648b713588",
"index": 7243,
"step-1": "<mask token>\n\n\nclass Utilizator(AbstractUser):\n \"\"\" Tabel info utilizator \n nume - extras automat din email ([nume]@gmail.com)\n email - se va loga cu emailul\n parola -... | [
4,
5,
6,
7,
9
] |
password = ["123456", "1111"]
pw = input("รหัสผ่านคือ>>>")
for data in password:
if data != pw:
pass
else:
print("พบข้อมูลรหัสผ่านนี้")
print("แล้วเจอกันใหม่")
| normal | {
"blob_id": "6f05b1352e776e20d6a9e0eb457d8914cbfc2d22",
"index": 2779,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor data in password:\n if data != pw:\n pass\n else:\n print('พบข้อมูลรหัสผ่านนี้')\nprint('แล้วเจอกันใหม่')\n",
"step-3": "password = ['123456', '1111']\npw = inpu... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def main(argv):
logging.basicConfig(format='%(levelname)s: %(message)s', level='INFO',
handlers=[colors.ColorizingStreamHandler(sys.stderr)])
try:
args = parse_args(argv)
except Exception as exc:
logging.exception(exc)
return 1
try:
... | flexible | {
"blob_id": "72d1a0689d4cc4f78007c0cfa01611e95de76176",
"index": 3908,
"step-1": "<mask token>\n\n\ndef main(argv):\n logging.basicConfig(format='%(levelname)s: %(message)s', level='INFO',\n handlers=[colors.ColorizingStreamHandler(sys.stderr)])\n try:\n args = parse_args(argv)\n except Ex... | [
1,
2,
3,
4,
5
] |
import numpy as np
import pandas as pd
import xgboost as xgb
from sklearn.metrics import confusion_matrix
USE_MEMMAP = True
data = pd.read_csv( 'dataset.csv' ).as_matrix()
X = data[ :, 0:-1 ]
y = data[ :, -1 ]
if USE_MEMMAP:
Xmm = np.memmap( 'X.mmap', dtype=X.dtype, mode='w+', shape=X.shape )
ymm = np.memmap( ... | normal | {
"blob_id": "e2682a5cab95914e7567431cb04c3fb542eda3bf",
"index": 4353,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif USE_MEMMAP:\n Xmm = np.memmap('X.mmap', dtype=X.dtype, mode='w+', shape=X.shape)\n ymm = np.memmap('y.mmap', dtype=y.dtype, mode='w+', shape=y.shape)\n np.copyto(Xmm, X)\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for dict in waypoints:
print(dict)
<|reserved_special_token_1|>
waypoints = [{'lat': 106.72888}, {'lon': 0.69622}, {'name': 'Kepulauan Riau'}]
for dict in waypoints:
print(dict)
<|reserved_special_token_1|>
# Make an... | flexible | {
"blob_id": "5eee3953193e0fc9f44b81059ce66997c22bc8f1",
"index": 6960,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor dict in waypoints:\n print(dict)\n",
"step-3": "waypoints = [{'lat': 106.72888}, {'lon': 0.69622}, {'name': 'Kepulauan Riau'}]\nfor dict in waypoints:\n print(dict)\n",
"ste... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
print(4 / 2, 4 / 3, 4 / 4)
print(5 / 2, 5 / 3, 5 / 4)
print(4 // 2, 4 // 3, 4 // 4)
print(5 // 2, 5 // 3, 5 // 4)
print(4.0 / 2, 4 / 3.0, 4.0 / float(4))
print(5.0 / 2, 5 / 3.0, 5.0 / float(4))
print(4.0 // 2, 4 // 3.0, 4.0 // float(4))
print(5.0 // 2, 5 // 3... | flexible | {
"blob_id": "988e1f0631c434cbbb6d6e973792a65ebbd9405e",
"index": 9474,
"step-1": "<mask token>\n",
"step-2": "print(4 / 2, 4 / 3, 4 / 4)\nprint(5 / 2, 5 / 3, 5 / 4)\nprint(4 // 2, 4 // 3, 4 // 4)\nprint(5 // 2, 5 // 3, 5 // 4)\nprint(4.0 / 2, 4 / 3.0, 4.0 / float(4))\nprint(5.0 / 2, 5 / 3.0, 5.0 / float(4))\np... | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "c10e1cf2f1ce5b11d19ddddbfc3dc9652d830a3c",
"index": 1132,
"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 = [('web', '0005... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
import socket
name = socket.gethostname()
| normal | {
"blob_id": "79c043fc862e77bea5adc3f1c6bb9a6272f19c75",
"index": 78,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nname = socket.gethostname()\n",
"step-3": "import socket\nname = socket.gethostname()\n",
"step-4": "#!/usr/bin/env python\n\nimport socket\n\nname = socket.gethostname()\n",
"step-5"... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
from __future__ import absolute_import, division, print_function
from .core import Bag, Item, from_sequence, from_filenames
from ..context import set_options
| flexible | {
"blob_id": "4e77c7ac784ec235e9925004069131d16717e89a",
"index": 9676,
"step-1": "<mask token>\n",
"step-2": "from __future__ import absolute_import, division, print_function\nfrom .core import Bag, Item, from_sequence, from_filenames\nfrom ..context import set_options\n",
"step-3": null,
"step-4": null,
... | [
0,
1
] |
import random
import numpy as np
import matplotlib.pyplot as plt
import torchvision
def plot_image(img, ax, title):
ax.imshow(np.transpose(img, (1,2,0)) , interpolation='nearest')
ax.set_title(title, fontsize=20)
def to_numpy(image, vsc):
return torchvision.utils.make_grid(
image.view(1, vsc.c... | normal | {
"blob_id": "ae27f97b5633309d85b9492e1a0f268847c24cd5",
"index": 9366,
"step-1": "<mask token>\n\n\ndef plot_image(img, ax, title):\n ax.imshow(np.transpose(img, (1, 2, 0)), interpolation='nearest')\n ax.set_title(title, fontsize=20)\n\n\n<mask token>\n\n\ndef plot_encoding(image, vsc, latent_sz, alpha=Non... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def task_goodbye():
pygame.mixer.music.load('../sounds/despicable.wav')
pygame.mixer.music.play()
def task_hello():
pygame.mixer.music.load('../sounds/mday.wav')
pygame.mixer.music.play()
def task_doh():
print('SOUNDPLAYER DOH!')
pygame.mixer.music.load('../sou... | flexible | {
"blob_id": "9852d2a15047b110c7f374fd75e531c60c954724",
"index": 3920,
"step-1": "<mask token>\n\n\ndef task_goodbye():\n pygame.mixer.music.load('../sounds/despicable.wav')\n pygame.mixer.music.play()\n\n\ndef task_hello():\n pygame.mixer.music.load('../sounds/mday.wav')\n pygame.mixer.music.play()\... | [
4,
5,
6,
8,
9
] |
#!/usr/bin/env python
#-*- coding:utf8 -*-
# Power by null 2018-09-19 18:41:17
from codebase.mod.mod_test import test_f
| normal | {
"blob_id": "7c4709eaa5123b44e6355c6a60932f286e3b1cf5",
"index": 7450,
"step-1": "<mask token>\n",
"step-2": "from codebase.mod.mod_test import test_f\n",
"step-3": "#!/usr/bin/env python\n#-*- coding:utf8 -*-\n# Power by null 2018-09-19 18:41:17\n\nfrom codebase.mod.mod_test import test_f\n",
"step-4": nu... | [
0,
1,
2
] |
import os
import tensorflow as tf
import torch
from tqdm import tqdm
from glob import glob
import numpy as np
from collections.abc import Iterable
from utils.hparams import HParam
#from utils.audio import Audio
#import librosa
#python encoder_inference.py --in_dir training_libri_mel/train/ --gpu_str 5
#python tfrecord... | normal | {
"blob_id": "df40b0628d6a180a98cd385145ee7c65ecb78256",
"index": 270,
"step-1": "<mask token>\n\n\nclass TFRecordProducer:\n\n def remove_list(self, list1, list2):\n i, j = 0, 0\n tmp_list1 = []\n tmp_list2 = []\n while i < len(list1) and j < len(list2):\n item1 = int(li... | [
4,
5,
6,
9,
10
] |
<|reserved_special_token_0|>
def mediaCreeper():
"""
Settings for mediaCreeper file
"""
ccPrefix = True
inFilename = u'mediacreeper.csv'
outFilename = u'MediaCreeper.json'
run(inFilename, outFilename, ccPrefix)
def run(inFilename, outFilename, ccPrefix, mappingFile=None, source=
u'ht... | flexible | {
"blob_id": "5a5b2d0ade5b66981218b4ecf15a2253b7d665f9",
"index": 3273,
"step-1": "<mask token>\n\n\ndef mediaCreeper():\n \"\"\"\n Settings for mediaCreeper file\n \"\"\"\n ccPrefix = True\n inFilename = u'mediacreeper.csv'\n outFilename = u'MediaCreeper.json'\n run(inFilename, outFilename, ... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def computational_graph(op):
if op is None:
return 'None'
res = f'{op.__class__.__name__} at {hex(id(op))}:'
if op.__class__.__name__ == 'AccumulateGrad':
res += f'variable at {hex(id(op.variable))}'
... | flexible | {
"blob_id": "faafc7cfd900d3f6fd6df30af5580f71eecfb279",
"index": 8298,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef computational_graph(op):\n if op is None:\n return 'None'\n res = f'{op.__class__.__name__} at {hex(id(op))}:'\n if op.__class__.__name__ == 'AccumulateGrad':\n ... | [
0,
1,
2,
3
] |
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
import dbindexer
dbindexer.autodiscover() #This needs to happen before anything else, hence strange import ordering
urlpatterns = patterns('harvester.views'... | normal | {
"blob_id": "9fc9d766915bcefde4f0ba5c24cb83e33fc66272",
"index": 1094,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndbindexer.autodiscover()\n<mask token>\n",
"step-3": "<mask token>\ndbindexer.autodiscover()\nurlpatterns = patterns('harvester.views', url('^$', 'home', name='home'),\n url('^settin... | [
0,
1,
2,
3,
4
] |
##class Human:
## pass
##hb1-HB("Sudhir")
##hb2=HB("Sreenu")
class Student:
def __init__(self,name,rollno):
self.name=name
self.rollno=rollno
std1=Student("Siva",123)
| normal | {
"blob_id": "97656bca3ce0085fb2f1167d37485fb7ee812730",
"index": 4825,
"step-1": "<mask token>\n",
"step-2": "class Student:\n <mask token>\n\n\n<mask token>\n",
"step-3": "class Student:\n\n def __init__(self, name, rollno):\n self.name = name\n self.rollno = rollno\n\n\n<mask token>\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
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
if len(sys.argv) != 5:
print('Usage: {0} model_file feat_dir feat_dim output_file'.format(
sys.argv[0]))
print('model_file -- path of the trained svm file')
print(... | flexible | {
"blob_id": "385dccfab4d7c37d10d968658b51e231691a7b49",
"index": 1556,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n if len(sys.argv) != 5:\n print('Usage: {0} model_file feat_dir feat_dim output_file'.format(\n sys.argv[0]))\n print('model_file -... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
cap = cv2.VideoCapture()
while True:
ret, frame = cap.read()
cv2.imshow(frame)
<|reserved_special_token_1|>
import cv2
import numpy as np
if __name__ == '__main__':
cap = c... | flexible | {
"blob_id": "14f309d478de6de5a0b493503176941fdfa8b702",
"index": 110,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n cap = cv2.VideoCapture()\n while True:\n ret, frame = cap.read()\n cv2.imshow(frame)\n",
"step-3": "import cv2\nimport numpy as np\nif __... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class SmashbotspainConfig(AppConfig):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class SmashbotspainConfig(AppConfig):
name = 'smashbotspain'
<|reserved_special_token_1|... | flexible | {
"blob_id": "e714755d660ba809f7958cad4f0b9f95b0a0ffdc",
"index": 9320,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass SmashbotspainConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass SmashbotspainConfig(AppConfig):\n name = 'smashbotspain'\n",
"step-4": "from djan... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
classifier.add(Convolution2D(32, 3, 3, border_mode='same', input_shape=(64,
64, 3), activation='relu'))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Convolution2D(32, 3, 3, border_mode='same', activation='relu... | flexible | {
"blob_id": "b0aeede44a4b54006cf0b7d541d5b476a7178a93",
"index": 6155,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nclassifier.add(Convolution2D(32, 3, 3, border_mode='same', input_shape=(64,\n 64, 3), activation='relu'))\nclassifier.add(MaxPooling2D(pool_size=(2, 2)))\nclassifier.add(Convolution2D(... | [
0,
1,
2,
3,
4
] |
from datetime import datetime
from django.core import mail
from entity_event import context_loader
from entity_emailer.models import Email
from entity_emailer.utils import get_medium, get_from_email_address, get_subscribed_email_addresses, \
create_email_message, extract_email_subject_from_html_content
class E... | normal | {
"blob_id": "d1dc807ecc92d9108db2c9bd00ee9781e174a1aa",
"index": 558,
"step-1": "<mask token>\n\n\nclass EntityEmailerInterface(object):\n <mask token>\n <mask token>\n\n @staticmethod\n def convert_events_to_emails():\n \"\"\"\n Converts unseen events to emails and marks them as seen.\... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class Game(object):
<|reserved_special_token_0|>
def game_loop(self):
while not self.won():
hunches = []
for player, data in self.player_data.items():
print('Jogador: {}'.format(player))
if data[3]:
... | flexible | {
"blob_id": "52f3000514fd39083daa6316d551f1685c7cea23",
"index": 6792,
"step-1": "<mask token>\n\n\nclass Game(object):\n <mask token>\n\n def game_loop(self):\n while not self.won():\n hunches = []\n for player, data in self.player_data.items():\n print('Jogador... | [
7,
10,
11,
12,
13
] |
# ----------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License
# ----------------------------------------------------------------------
"""Contains the Plugin object"""
import itertools
import os
import sys
... | normal | {
"blob_id": "d8befc4a79176aefcccd3dceddf04ca965601e5c",
"index": 2856,
"step-1": "<mask token>\n\n\n@Interface.staticderived\nclass Plugin(PluginBase):\n <mask token>\n <mask token>\n\n @staticmethod\n @Interface.override\n def Generate(open_file_func, global_custom_structs, global_custom_enums,\n... | [
8,
9,
10,
11,
15
] |
#!/usr/bin/env python
from pymongo import GEO2D
from GlobalConfigs import eateries
eateries.create_index([("eatery_coordinates", GEO2D)])
eateries.ensure_index([("eatery_coordinates", pymongo.GEOSPHERE)])
for e in eateries.find({"eatery_coordinates": {"$near": [latitude, longitude]}}).limit(5):
print e.get... | normal | {
"blob_id": "59de17ea4e714e17e3a7dd966bd0d93ba73f4503",
"index": 5306,
"step-1": "#!/usr/bin/env python\n\nfrom pymongo import GEO2D\nfrom GlobalConfigs import eateries\n\neateries.create_index([(\"eatery_coordinates\", GEO2D)]) \neateries.ensure_index([(\"eatery_coordinates\", pymongo.GEOSPHERE)])\n\nfor e in ... | [
0
] |
#! /usr/local/env python
#coding:utf-8
import urllib.request
import urllib.error
try:
urllib.request.urlopen("http://blog.csdn.net/jo_andy")
except urllib.error.URLError as e:
if hasattr(e,"code"):
print(e.code)
if hasattr(e,'reason'):
print(e.reason) | normal | {
"blob_id": "2ffd0de2888872cfa664919fcfc54b8e60b03280",
"index": 5256,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n urllib.request.urlopen('http://blog.csdn.net/jo_andy')\nexcept urllib.error.URLError as e:\n if hasattr(e, 'code'):\n print(e.code)\n if hasattr(e, 'reason'):\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def squeezed(client_name):
return client_name.replace('Индивидуальный предприниматель', 'ИП')
def get_kkm_filled_fn(max_fill=80):
LOGIN_URL = 'https://pk.platformaofd.ru/auth/login'
API_URL = 'https://pk.platformaofd.ru/api/monitoring'
session = requests.Session()
pr... | flexible | {
"blob_id": "cd2e03666a890d6e9ea0fcb45fe28510d684916d",
"index": 83,
"step-1": "<mask token>\n\n\ndef squeezed(client_name):\n return client_name.replace('Индивидуальный предприниматель', 'ИП')\n\n\ndef get_kkm_filled_fn(max_fill=80):\n LOGIN_URL = 'https://pk.platformaofd.ru/auth/login'\n API_URL = 'ht... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class ListingForm(forms.Form):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class ListingForm(forms.Form):
text = forms.CharField(max_length=50, widget=forms.TextInput(attrs... | flexible | {
"blob_id": "3f23a50f44ba17c9b0241a4e3b0e939afeb1f5f0",
"index": 3092,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ListingForm(forms.Form):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ListingForm(forms.Form):\n text = forms.CharField(max_length=50, widget=forms.TextInput(at... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
"""
Project Euler - Problem XX
...
"""
# Imports
import time
# Global variables
# Lamda functions
# Functions
# Main functions
def main():
print('Output')
# Execute code
start = time.time()
if __name__ == "__main__":
main()
end = time.time()
print('Run time: {}'.format(end - start... | normal | {
"blob_id": "cdb07241e08f8ac85a427c5b2bc3effca3917c85",
"index": 2188,
"step-1": "<mask token>\n\n\ndef main():\n print('Output')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n print('Output')\n\n\n<mask token>\nif __name__ == '__main__':\n main()\n<mask token>\nprint('Run time: {}'.... | [
1,
2,
3,
4,
5
] |
#!usr/bin/python
# -*- coding:UTF-8 -*-
'''
Introduction:
Implementation of Stack
Created on: Oct 28, 2014
@author: ICY
'''
#-------------------------FUNCTION---------------------------#
class Stack(object):
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
... | normal | {
"blob_id": "6fa9dfadc60108e1718c6688f07de877b0ac0afd",
"index": 5885,
"step-1": "<mask token>\n\n\nclass Stack(object):\n\n def __init__(self):\n self.items = []\n\n def is_empty(self):\n return self.items == []\n\n def clear(self):\n self.items = []\n\n def push(self, item):\n ... | [
7,
8,
9,
10,
11
] |
#!/usr/bin/env python3
"""Test telegram_menu package."""
| normal | {
"blob_id": "8d4ffed90e103e61a85a54d6163770966fb2e5c9",
"index": 5049,
"step-1": "<mask token>\n",
"step-2": "#!/usr/bin/env python3\n\n\"\"\"Test telegram_menu package.\"\"\"\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
class FeaturesBuilder(object):
<|reserved_special_token_0|>
def getClusterCentures(self):
start_time = datetime.now()
feature_getter = FeatureGetter()
des_list = []
des_matrix = np.zeros((1, 128))
if self.img_paths != None:
for ... | flexible | {
"blob_id": "630011b188548df9e55b6f1ddbefa08e322b9cba",
"index": 169,
"step-1": "<mask token>\n\n\nclass FeaturesBuilder(object):\n <mask token>\n\n def getClusterCentures(self):\n start_time = datetime.now()\n feature_getter = FeatureGetter()\n des_list = []\n des_matrix = np.z... | [
5,
7,
8,
10,
12
] |
left_motor = 1563872856371375
right_motor = 7567382956378165
servo = 9275392915737265
def autonomous_setup():
print("Autonomous mode has started!")
Robot.run(autonomous_actions)
def autonomous_main():
pass
async def autonomous_actions():
print("Autonomous action sequence started")
await Actions.s... | normal | {
"blob_id": "a2d23c05e1ca04d25f5f5012881c4000e6316cb9",
"index": 2504,
"step-1": "left_motor = 1563872856371375\nright_motor = 7567382956378165\nservo = 9275392915737265\n\ndef autonomous_setup():\n print(\"Autonomous mode has started!\")\n Robot.run(autonomous_actions)\n\ndef autonomous_main():\n pass\... | [
0
] |
from django.contrib import admin
from coupon.models import Coupon, Games
admin.site.register(Coupon)
admin.site.register(Games)
| normal | {
"blob_id": "6c10213c2e866ec84f229aa426c7122aa817d167",
"index": 4239,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(Coupon)\nadmin.site.register(Games)\n",
"step-3": "from django.contrib import admin\nfrom coupon.models import Coupon, Games\nadmin.site.register(Coupon)\nadmin.site... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def get_config(path_to_config: str) ->Dict[str, Any]:
"""Get config.
Args:
path_to_config (str): Path to config.
Returns:
Dict[str, Any]: Config.
"""
with open(path_to_config, mode='r') as f... | flexible | {
"blob_id": "c85d7e799a652e82bfaf58e1e8bfa9c4606a8ecb",
"index": 917,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_config(path_to_config: str) ->Dict[str, Any]:\n \"\"\"Get config.\n\n Args:\n path_to_config (str): Path to config.\n\n Returns:\n Dict[str, Any]: Config... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
while not hashlib.md5('{}{}'.format(hash, int).encode('utf-8')).hexdigest(
).startswith('000000'):
print('Nope luck for {}{}'.format(hash, int))
int += 1
print('Key: {}{}'.format(hash, int))
print('Number: {}').format(... | flexible | {
"blob_id": "9ae9fd6da5c3d519d87af699dd4ea9b564a53d79",
"index": 5481,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile not hashlib.md5('{}{}'.format(hash, int).encode('utf-8')).hexdigest(\n ).startswith('000000'):\n print('Nope luck for {}{}'.format(hash, int))\n int += 1\nprint('Key: {}{}'... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@app.route('/my/<name>/<age>')
def my(name, age):
name = 'saral'
age = '20'
return 'my name is {} and age is {}'.format(name, age)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
app = Flask('__name__')
... | flexible | {
"blob_id": "3817770a80f8ab16322485522be18edd6b3f5516",
"index": 179,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@app.route('/my/<name>/<age>')\ndef my(name, age):\n name = 'saral'\n age = '20'\n return 'my name is {} and age is {}'.format(name, age)\n",
"step-3": "<mask token>\napp = ... | [
0,
1,
2,
3,
4
] |
#CartPoleStarter
import gym
## Defining the simulation related constants
NUM_EPISODES = 1000
def simulate():
## Initialize the "Cart-Pole" environment
env = gym.make('CartPole-v0')
for episode in range(NUM_EPISODES):
done = False
# Reset the environment
obv = env.reset()
... | normal | {
"blob_id": "3c79c528cc19380af8f2883b9e35855e29b151a3",
"index": 7975,
"step-1": "<mask token>\n\n\ndef simulate():\n env = gym.make('CartPole-v0')\n for episode in range(NUM_EPISODES):\n done = False\n obv = env.reset()\n initial_action = 0\n total_reward = 0\n steps = 0... | [
1,
2,
3,
4,
5
] |
from . import mongo
col = mongo.cli['Cupidbot']['timer']
async def add_time(chat, time):
return col.insert_one({'chat': chat, 'time': time})
async def get_time(chat):
return col.find_one({'chat': chat})
async def update_time(chat, time):
return col.update_one({'chat': chat}, {'$set': {'chat': chat, 't... | normal | {
"blob_id": "e4ce10f5db56e4e2e1988da3cee542a4a09785a8",
"index": 5381,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nasync def add_time(chat, time):\n return col.insert_one({'chat': chat, 'time': time})\n\n\nasync def get_time(chat):\n return col.find_one({'chat': chat})\n\n\nasync def update_... | [
0,
1,
2,
3
] |
from . import common_wizard
| normal | {
"blob_id": "1844cfb3e174454e0e95d91e4e55679caddcd56e",
"index": 1963,
"step-1": "<mask token>\n",
"step-2": "from . import common_wizard\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
from selenium import webdriver
import time
import math
def calc(x):
return str(math.log(abs(12*math.sin(int(x)))))
try:
br = webdriver.Chrome();
lk = 'http://suninjuly.github.io/get_attribute.html'
br.get(lk)
#собираю
treasure=br.find_element_by_id('treasure')
valuex = treasure.get_attribute('valuex')
radio_... | normal | {
"blob_id": "2a92c47231b75a441660fed80a9bce9a35695af5",
"index": 1222,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef calc(x):\n return str(math.log(abs(12 * math.sin(int(x)))))\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef calc(x):\n return str(math.log(abs(12 * math.sin(int(x))... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def get_random_player(file_name):
def need_s(num):
return 's' if num != 1 else ''
csv.field_size_limit(sys.maxsize)
res = pd.read_csv(file_name, header=None)
r = np.random.randint(0, len(res.values))
... | flexible | {
"blob_id": "ac178d4e009a40bde5d76e854edc6f6ae8422610",
"index": 1106,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_random_player(file_name):\n\n def need_s(num):\n return 's' if num != 1 else ''\n csv.field_size_limit(sys.maxsize)\n res = pd.read_csv(file_name, header=None)... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class SecondaryStructureExtractorTest(unittest.TestCase):
<|reserved_special_token_0|>
def test1(self):
pdb = self.pdb.filter(ContainsLProteinChain()).flatMap(
StructureToPolymerChains()).filter(ContainsLProteinChain())
seq = secondaryStructureExtracto... | flexible | {
"blob_id": "480e6ae9eee70b2da58ca5624a43d8f5dcae1d33",
"index": 1207,
"step-1": "<mask token>\n\n\nclass SecondaryStructureExtractorTest(unittest.TestCase):\n <mask token>\n\n def test1(self):\n pdb = self.pdb.filter(ContainsLProteinChain()).flatMap(\n StructureToPolymerChains()).filter(... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def FindTests():
"""Finds golden files and returns Test cases for each."""
for root, _, files in os.walk(GOLDEN_CASES_DIR):
path_parts = root.split('/')
if path_parts[-3] == 'golden':
language = path_parts[-2]
variant = path_parts[-1]
... | flexible | {
"blob_id": "2294951af6ad7a5e752285194d0586c79c49ef87",
"index": 4254,
"step-1": "<mask token>\n\n\ndef FindTests():\n \"\"\"Finds golden files and returns Test cases for each.\"\"\"\n for root, _, files in os.walk(GOLDEN_CASES_DIR):\n path_parts = root.split('/')\n if path_parts[-3] == 'gold... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "a048396019aa7603a20535a3ce4bc9770509097d",
"index": 2291,
"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 = [('excursions'... | [
0,
1,
2,
3,
4
] |
from marshmallow import fields, post_load
from rebase.common.schema import RebaseSchema, SecureNestedField
from rebase.views.bid_limit import BidLimitSchema
class TicketSetSchema(RebaseSchema):
id = fields.Integer()
bid_limits = SecureNestedField(BidLimitSchema, exclude=('ticket_set',),
only=('id', 'p... | normal | {
"blob_id": "5ebc4f61810f007fd345b52531f7f4318820b9c8",
"index": 6333,
"step-1": "<mask token>\n\n\nclass TicketSetSchema(RebaseSchema):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass TicketSetSchema(RebaseSchem... | [
1,
2,
4,
5
] |
from django.apps import AppConfig
class ClassromConfig(AppConfig):
name = 'classrom'
| normal | {
"blob_id": "a995305cb5589fa0cbb246ae3ca6337f4f2c3ca1",
"index": 8798,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ClassromConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ClassromConfig(AppConfig):\n name = 'classrom'\n",
"step-4": "from django.apps import ... | [
0,
1,
2,
3
] |
r, n = map(int, input().split())
if r == n:
print("too late")
else:
l = list(range(1, r+1))
for _ in range(n):
l.remove(int(input()))
print(l[0])
| normal | {
"blob_id": "381d3f0890a2916d2e0a21a6a47a5f87afde622d",
"index": 9241,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif r == n:\n print('too late')\nelse:\n l = list(range(1, r + 1))\n for _ in range(n):\n l.remove(int(input()))\n print(l[0])\n",
"step-3": "r, n = map(int, input().s... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
try:
conn = psycopg2.connect(
'host=127.0.0.1 dbname=studentdb user=student password=student')
except psycopg2.Error as e:
print('Error: Could not make connection to the Postgres database')
print(e)
try:
cu... | flexible | {
"blob_id": "70964ac617847dd4bf4a60a142afc94d0f284a24",
"index": 7621,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n conn = psycopg2.connect(\n 'host=127.0.0.1 dbname=studentdb user=student password=student')\nexcept psycopg2.Error as e:\n print('Error: Could not make connection to t... | [
0,
1,
2,
3,
4
] |
# coding:utf-8
import jieba
import os
import sys
import math
reload(sys)
sys.setdefaultencoding('utf-8')
from sklearn import feature_extraction
from sklearn.feature_extraction.text import TfidfTransformer
from sklearn.feature_extraction.text import CountVectorizer
#import csv
#import pandas
#import numpy
sente... | normal | {
"blob_id": "1a7e83fe9528b177246d6374ddaf2a76a0046e83",
"index": 200,
"step-1": "<mask token>\n\n\ndef cos_dist(a, b):\n if len(a) != len(b):\n return None\n part_up = 0.0\n a_sq = 0.0\n b_sq = 0.0\n for a1, b1 in zip(a, b):\n part_up += a1 * b1\n a_sq += a1 ** 2\n b_sq... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def replace_tokens(text, replace_dict=None):
pattern = re.compile('|'.join(DELETE))
text = re.sub(pattern, '', text)
return text
def read_txt(file_path, encoding):
with open(os.path.join(DATA_PATH, file_path), 'r', encoding=encoding,
errors='replace') as f:
... | flexible | {
"blob_id": "5fd54de3b2f9c2e18a283d016fc16e0e622dc6a0",
"index": 8415,
"step-1": "<mask token>\n\n\ndef replace_tokens(text, replace_dict=None):\n pattern = re.compile('|'.join(DELETE))\n text = re.sub(pattern, '', text)\n return text\n\n\ndef read_txt(file_path, encoding):\n with open(os.path.join(D... | [
6,
7,
10,
11,
12
] |
from django.db import models
# from rest_framework import permissions
from drawAppBackend import settings
# from django.contrib.auth.models import AbstractUser
# Create your models here.
class DrawApp(models.Model):
title = models.CharField(max_length=120)
description = models.TextField()
completed = mo... | normal | {
"blob_id": "fa566eb77b17830acad8c7bfc2b958760d982925",
"index": 7623,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass DrawApp(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass SavedDrawings(models.Model):\n username = models.ForeignKey(settings... | [
0,
3,
4,
5,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def run_GLM(raw, design_matrix, noise_model='ar1', bins=100, n_jobs=1,
verbose=0):
"""
Run GLM on data using supplied design matrix.
This is a wrapper function for nilearn.stats.first_level_model.run_glm.
P... | flexible | {
"blob_id": "8279c6d5f33d5580bef20e497e2948461a1de62c",
"index": 7951,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef run_GLM(raw, design_matrix, noise_model='ar1', bins=100, n_jobs=1,\n verbose=0):\n \"\"\"\n Run GLM on data using supplied design matrix.\n\n This is a wrapper functio... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# author: MSJ
# date: 2021/3/11
# desc:冒泡排序
def bubble_sort(arr):
for i in range(1, len(arr)):
for j in range(0, len(arr) - i):
if arr[j] > arr[j + 1]:
tmp = arr[j]
arr[j] = arr[j + 1]
arr[j + 1] = tmp
... | normal | {
"blob_id": "6682c864a3da6f2c894a3a40359726b4eb97d040",
"index": 6109,
"step-1": "<mask token>\n",
"step-2": "def bubble_sort(arr):\n for i in range(1, len(arr)):\n for j in range(0, len(arr) - i):\n if arr[j] > arr[j + 1]:\n tmp = arr[j]\n arr[j] = arr[j + 1]... | [
0,
1,
2,
3
] |
# Generated by Django 3.1.6 on 2021-02-05 00:27
import django.core.validators
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main_app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='tea',
... | normal | {
"blob_id": "db920f4aadfb53bb26c5ba1fb182f12b95e14a2f",
"index": 7899,
"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 = [('main_app', ... | [
0,
1,
2,
3,
4
] |
class TreeNode(object):
"""
Implementation of a TreeNode
A TreeNode is a Node with a value and a list of children. Each child is also
a TreeNode
Class invariants:
- self.value: The value for this TreeNode : Any
- self.children: The list of children for this Node : TreeNode List
"""
d... | normal | {
"blob_id": "f7e2fc7b5420b90f733a9520b75555bd869cea98",
"index": 7929,
"step-1": "class TreeNode(object):\n <mask token>\n <mask token>\n\n def add_child(self, value):\n \"\"\"\n Adds a value to the list of children for this node\n\n Parameter value: the value to add to the Tree \n Preco... | [
4,
5,
6,
7
] |
#!/usr/bin/python3
def square_matrix_simple(matrix=[]):
'''This function will compute the square root of all integers in
a matrix. '''
new_matrix = []
for index in matrix:
jndex = 0
new_row = []
while jndex < len(index):
... | normal | {
"blob_id": "b090e92fe62d9261c116529ea7f480daf8b3e84e",
"index": 6543,
"step-1": "<mask token>\n",
"step-2": "def square_matrix_simple(matrix=[]):\n \"\"\"This function will compute the square root of all integers in\n a matrix. \"\"\"\n new_matrix = ... | [
0,
1,
2
] |
import copy
import six
from eclcli.common import command
from eclcli.common import utils
from eclcli.storage.storageclient import exceptions
class ListVolumeType(command.Lister):
def get_parser(self, prog_name):
parser = super(ListVolumeType, self).get_parser(prog_name)
parser.add_argument(
... | normal | {
"blob_id": "c73bea686786a30f298500968cfd01e2d5125d75",
"index": 4013,
"step-1": "<mask token>\n\n\nclass ListVolumeType(command.Lister):\n <mask token>\n <mask token>\n\n\nclass ShowVolumeType(command.ShowOne):\n\n def get_parser(self, prog_name):\n parser = super(ShowVolumeType, self).get_parse... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class TestAuth:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def test_env_file(self):
assert login.check_env() == True
def test_create_env_file(self):
home = os.path.expanduser('~')
env_file = '{}/.neo.env'.format(home)
env_fi... | flexible | {
"blob_id": "dfe7f0e25f340601886334c61a50806491a4ae2b",
"index": 8621,
"step-1": "<mask token>\n\n\nclass TestAuth:\n <mask token>\n <mask token>\n\n def test_env_file(self):\n assert login.check_env() == True\n\n def test_create_env_file(self):\n home = os.path.expanduser('~')\n ... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class BigCNN(Module):
def __init__(self, h_in, w_in, channels_in):
super(BigCNN, self).__init__()
self.h_out, self.w_out = h_in, w_in
self.conv1 = Conv2d(channels_in, 64, 8, stride=2)
self.h_out, self.w_out = conv2d_out_dims(self.conv1, self.h_out,
... | flexible | {
"blob_id": "6f6d3fbb9a6a118e0f4026a7f9054b90b8cf2fca",
"index": 5677,
"step-1": "<mask token>\n\n\nclass BigCNN(Module):\n\n def __init__(self, h_in, w_in, channels_in):\n super(BigCNN, self).__init__()\n self.h_out, self.w_out = h_in, w_in\n self.conv1 = Conv2d(channels_in, 64, 8, strid... | [
14,
16,
19,
22,
24
] |
from django.db import models
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from model_utils.models import TimeStampedModel
user = settings.AUTH_USER_MODEL
commment_lenght = settings.COMMENT_LENGTH
# Entity Comment
class Comment(TimeStampedModel):
"""
Text comment po... | normal | {
"blob_id": "68ea462f56ba029a7c977d9c8b94e6f913336fb7",
"index": 4680,
"step-1": "<mask token>\n\n\nclass Cigarette(models.Model):\n <mask token>\n user = models.ForeignKey(user, blank=False, null=False, related_name=\n 'user_cigarettes')\n cigarette_date = models.DateField(_('cigarette date'), a... | [
6,
12,
16,
17,
19
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
EvinceRelation('different from')
<|reserved_special_token_1|>
from utils import *
EvinceRelation('different from')
<|reserved_special_token_1|>
from utils import *
EvinceRelation("different from")
| flexible | {
"blob_id": "4f15e2743b33e2f672cd258172da852edb7e4118",
"index": 2103,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nEvinceRelation('different from')\n",
"step-3": "from utils import *\nEvinceRelation('different from')\n",
"step-4": "from utils import *\n\nEvinceRelation(\"different from\")\n\n",
... | [
0,
1,
2,
3
] |
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index_view, name='accounts.index'),
url(r'^login/$', views.login_view, name='accounts.login'),
url(r'^logout/$', views.logout_view, name='accounts.logout'),
url(r'^registro/$', views.registro_usuario_view, name='accou... | normal | {
"blob_id": "b4d09b6d8ad5f0584f74adc0fd8116265bb6649b",
"index": 4641,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('^$', views.index_view, name='accounts.index'), url(\n '^login/$', views.login_view, name='accounts.login'), url('^logout/$',\n views.logout_view, name='accounts.... | [
0,
1,
2,
3
] |
import sqlite3
from flask_restful import Resource, reqparse
from flask_jwt import JWT, jwt_required
#import base64
import datetime
import psycopg2
class User:
def __init__(self, _id, username, password, user_name, address, contact):
self.id = _id
self.username = username
self.password =... | normal | {
"blob_id": "84d154afe206fd2c7381a2203affc162c28e21c1",
"index": 5863,
"step-1": "<mask token>\n\n\nclass PresOrder(Resource):\n <mask token>\n parser.add_argument('username', type=str, required=True, help=\n 'This field cannot be left blank.')\n parser.add_argument('pres', type=str, required=Tru... | [
5,
8,
9,
10,
12
] |
import falcon
import json
from sqlalchemy.exc import SQLAlchemyError
from db import session
import model
import util
class AchievementGrant(object):
def on_post(self, req, resp):
"""
Prideleni achievementu
Format dat:
{
"users": [ id ],
"task": (null|id),... | normal | {
"blob_id": "89ec04280ecfdfcba1923e2742e31d34750f894f",
"index": 4536,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass AchievementGrant(object):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass AchievementGrant(object):\n\n def on_post(self, req, resp):\n \"\"\"\n Prid... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if users:
for user in users:
if user == 'admin':
print(f'Hello, {user}, would you like to see a status report?')
else:
print(f'Hello, {user}, thank you for logging in again')
else:
p... | flexible | {
"blob_id": "c355be4e05d1df7f5d6f2e32bbb5a8086babe95b",
"index": 7946,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif users:\n for user in users:\n if user == 'admin':\n print(f'Hello, {user}, would you like to see a status report?')\n else:\n print(f'Hello, {use... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('sub_adjuster', '0002_parameters'),
]
operations = [
migrations.AlterField(
model_name='subtitles',
n... | normal | {
"blob_id": "156203042ed8a9bde0e9d8587ea3d37de6bcfdf7",
"index": 5155,
"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 = [('sub_adjuste... | [
0,
1,
2,
3,
4
] |
n, x = map(int, input().split())
m = [int(input()) for _ in range(n)]
m.sort()
x -= sum(m)
print(n + x // m[0])
| normal | {
"blob_id": "0ff398775fd13fb5fbd23bf2359bb31dff6bd38c",
"index": 9821,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nm.sort()\nx -= sum(m)\nprint(n + x // m[0])\n",
"step-3": "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\nm.sort()\nx -= sum(m)\nprint(n + x // m[0])\n",
"ste... | [
0,
1,
2
] |
# Make coding more python3-ish
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import os
import pwd
import sys
from string import ascii_letters, digits
from ConfigParser import SafeConfigParser
# copied from utils, avoid circular reference fun :)
def mk_boolean(value):
if... | normal | {
"blob_id": "63bd8a15dd489844968f46c4b0ffe157d567537a",
"index": 8044,
"step-1": "<mask token>\n\n\ndef get_config(p, section, key, env_var, default, boolean=False, integer=\n False, floating=False, islist=False):\n \"\"\" return a configuration variable with casting \"\"\"\n value = _get_config(p, sect... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def __map2list(mp):
if len(mp.keys()) == 0:
return []
lst = [None] * max(mp.keys())
for idx in mp.keys():
lst[idx - 1] = mp[idx]
return lst
def __translate_keys(translation_schema):
def f(obj):
schema = translation_schema.get(type(obj))
... | flexible | {
"blob_id": "9f6e5c219f7b668720b5379dde912ff22ef434d1",
"index": 9072,
"step-1": "<mask token>\n\n\ndef __map2list(mp):\n if len(mp.keys()) == 0:\n return []\n lst = [None] * max(mp.keys())\n for idx in mp.keys():\n lst[idx - 1] = mp[idx]\n return lst\n\n\ndef __translate_keys(translati... | [
4,
5,
6,
7,
8
] |
#!/usr/bin/python2
# -*- coding: UTF-8 -*-
# coding: utf-8
#!/usr/bin/env python
'''
发布轨迹信息
path.x; path.y; c_speed;
'''
import numpy as np
import matplotlib.pyplot as plt
import copy
import math
from cubic_spline import Spline2D
from polynomials import QuarticPolynomial, QuinticPolynomial
import time
import... | normal | {
"blob_id": "4647a7d0996ceeef4f39cf3182ac3944d25cb349",
"index": 8197,
"step-1": "<mask token>\n\n\nclass FrenetPath:\n\n def __init__(self):\n self.t = []\n self.d = []\n self.d_d = []\n self.d_dd = []\n self.d_ddd = []\n self.s = []\n self.s_d = []\n s... | [
20,
21,
24,
25,
27
] |
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
sess = tf.Session()
# 1.one-shot iterator
dataset = tf.data.Dataset.range(100)
iterator = dataset.make_one_shot_iterator()
next_element = iterator.get_next()
for i in range(100):
value = sess.run(next_element)
# print(value)
assert i == v... | normal | {
"blob_id": "4d4dd451d83d8d602c6264e77f52e5e143aef307",
"index": 6239,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(100):\n value = sess.run(next_element)\n assert i == value\n<mask token>\nsess.run(iterator.initializer, feed_dict={max_value: 10})\nfor i in range(10):\n value = ... | [
0,
1,
2,
3,
4
] |
## n.b. uses python 3 wordseg virtualenv (wordseg needs Py3)
# e.g. $ source ~/venvs/Py3/wordseg/bin/activate
## wordseg: see https://wordseg.readthedocs.io
from __future__ import division
import io, collections, os, glob, csv, re
from scipy.stats import entropy
from copy import deepcopy
# get username
impo... | normal | {
"blob_id": "4ba0affd3cbdc2652274213a8d410b541fb3edb4",
"index": 4584,
"step-1": "<mask token>\n\n\ndef process_corpus(lcount, text, language, corpus, child, utts, owus, pdict,\n bdict):\n owu = owus / utts\n lineout1 = [language, corpus, child, utts, owu]\n ordered = sorted(pdict.items(), key=lambda... | [
1,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@click.command()
@click.option('--name', prompt='Your name')
def hello(name):
print('hello', name)
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@click.command()
@click.option(... | flexible | {
"blob_id": "19c1a50cf19f04a9e0d0163a9383cb900bca1d38",
"index": 9862,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@click.command()\n@click.option('--name', prompt='Your name')\ndef hello(name):\n print('hello', name)\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\n@click.command()\n@click... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for _ in range(t):
n = int(input())
arr = list(map(int, stdin.readline().strip().split()))
d = defaultdict(int)
maxnum = 0
for num in arr:
d[num] += 1
if num > maxnum:
maxnum = num
... | flexible | {
"blob_id": "789f098fe9186d2fbda5417e9938930c44761b83",
"index": 6760,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(t):\n n = int(input())\n arr = list(map(int, stdin.readline().strip().split()))\n d = defaultdict(int)\n maxnum = 0\n for num in arr:\n d[num] += 1\n ... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
import re
class Solution:
def __new__(self, p):
nr_counts, nr_consonants, replaced = self.count_vowels_consonants(self, p)
inversed = ''.join(c.lower() if c.isupper() else c.upper() for c in p)
replaced_by_ = p.replace(' ' ,'-')
combined_queries = str(nr_counts) + ' ' + str(nr_conso... | normal | {
"blob_id": "ec9de8d54113806ab327f05e077edefa74258adb",
"index": 2662,
"step-1": "<mask token>\n\n\nclass Solution:\n\n def __new__(self, p):\n nr_counts, nr_consonants, replaced = self.count_vowels_consonants(self,\n p)\n inversed = ''.join(c.lower() if c.isupper() else c.upper() for... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class survey:
<|reserved_special_token_0|>
class index:
def GET(self):
i = web.input(enter=None)
date = datetime.datetime.now().ctime()
hour = datetime.datetime.now().hour
return render.index(i.enter, date, hour)
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "07a0ba3ded8a2d4a980cfb8e3dbd6fd491ea24b0",
"index": 1842,
"step-1": "<mask token>\n\n\nclass survey:\n <mask token>\n\n\nclass index:\n\n def GET(self):\n i = web.input(enter=None)\n date = datetime.datetime.now().ctime()\n hour = datetime.datetime.now().hour\n retu... | [
3,
4,
5,
7,
8
] |
import random
from connectfour.agents.monte_carlo import Node, MTCS
from connectfour.agents.agent import Agent
MAX_DEPTH = 3
class MonteCarloAgent(Agent):
def __init__(self, name):
super().__init__(name)
def get_move(self, board):
best_move = self.find_best_move(board)
return self._... | normal | {
"blob_id": "e99cf5a7058db984b323af1375003e4e21e36612",
"index": 9305,
"step-1": "<mask token>\n\n\nclass MonteCarloAgent(Agent):\n <mask token>\n <mask token>\n <mask token>\n\n def _find_move_from_new_board_state(self, old, new):\n \"\"\"\n Making a move in Connect Four makes exactly ... | [
5,
8,
9,
10,
11
] |
class Config(object):
DEBUG = False
TESTING = False
SQLALCHEMY_TRACK_MODIFICATIONS = False
class Production(Config):
SQLALCHEMY_DATABASE_URI = '<Production DB URL>'
class Development(Config):
# psql postgresql://Nghi:nghi1996@localhost/postgres
DEBUG = True
SQLALCHEMY_DATABASE_URI = 'pos... | normal | {
"blob_id": "e99d557808c7ae32ebfef7e7fb2fddb04f45b13a",
"index": 6091,
"step-1": "<mask token>\n\n\nclass Production(Config):\n <mask token>\n\n\nclass Development(Config):\n DEBUG = True\n SQLALCHEMY_DATABASE_URI = 'postgresql://Nghi:nghi1996@localhost/postgres'\n SQLALCHEMY_ECHO = False\n JWT_SE... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
class Adaline:
<|reserved_special_token_0|>
def fit(self, X, Y):
X = np.hstack((np.ones((X.shape[0], 1)), X))
self.w = np.random.uniform(-1, 1, (X.shape[1], 1))
for n in range(self.n_iter):
y = X.dot(self.w)
error = Y - y
... | flexible | {
"blob_id": "02e711dfc122007c74949cd9f86e2aeb9d334871",
"index": 329,
"step-1": "<mask token>\n\n\nclass Adaline:\n <mask token>\n\n def fit(self, X, Y):\n X = np.hstack((np.ones((X.shape[0], 1)), X))\n self.w = np.random.uniform(-1, 1, (X.shape[1], 1))\n for n in range(self.n_iter):\n... | [
2,
3,
4,
5,
6
] |
from email.mime.text import MIMEText
import smtplib
def init_mail(server, user, pwd, port=25):
server = smtplib.SMTP(server, port)
server.starttls()
server.login(user, pwd)
return server
def send_email(mconn, mailto, mailfrom, mailsub, msgbody):
msg = MIMEText(msgbody)
msg['Subject'] = mails... | normal | {
"blob_id": "ec604aea28dfb2909ac9e4b0f15e6b5bbe1c3446",
"index": 2934,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef send_email(mconn, mailto, mailfrom, mailsub, msgbody):\n msg = MIMEText(msgbody)\n msg['Subject'] = mailsub\n msg['To'] = mailto\n msg['From'] = mailfrom\n mconn.se... | [
0,
1,
2,
3
] |
#!/usr/bin/python3
#coding:utf-8
"""
Author: Xie Song
Email: 18406508513@163.com
Copyright: Xie Song
License: MIT
"""
import torch
def get_sgd_optimizer(args, model):
opimizer = torch.optim.SGD(model.parameters(),lr=args.lr,weight_decay=1e-4)
return opimizer | normal | {
"blob_id": "5dca187cfe221f31189ca9a9309ece4b9144ac66",
"index": 2812,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_sgd_optimizer(args, model):\n opimizer = torch.optim.SGD(model.parameters(), lr=args.lr, weight_decay\n =0.0001)\n return opimizer\n",
"step-3": "<mask token>\n... | [
0,
1,
2,
3
] |
import json
import random
import uuid
from collections import OrderedDict
import docker
from .db_utils import DBUtils
from .models import DynamicDockerChallenge
class DockerUtils:
@staticmethod
def add_new_docker_container(user_id, challenge_id, flag, port):
configs = DBUtils.get_all_configs()
... | normal | {
"blob_id": "e2e2e746d0a8f6b01e6f54e930c7def2d48c2d62",
"index": 4653,
"step-1": "<mask token>\n\n\nclass DockerUtils:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass DockerUtils:\n <mask token>\n\n @staticmethod\n def remove_current_docker_container(user_id, is_retry=False)... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
print(
'vtkGraph: Building a graph using Unstructured Grid & dumping it in a vtk file, vertex.vtu, to be visualized using ParaView'
)
pointSource = vtk.vtkPointSource()
pointS... | flexible | {
"blob_id": "de7515cb71c8e30018b14baf8846648d0c76a592",
"index": 7461,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n print(\n 'vtkGraph: Building a graph using Unstructured Grid & dumping it in a vtk file, vertex.vtu, to be visualized using ParaView'\n )\n ... | [
0,
1,
2,
3
] |
import streamlit as st
from streamlit.components.v1 import components
from streamlit.report_thread import get_report_ctx
from util.session import *
from multipage import MultiPage
from pages import register
def app(page):
if not login_status():
title_container = st.empty()
remail_input_container = ... | normal | {
"blob_id": "41cfd558824b6561114a48a694b1e6e6a7cb8c05",
"index": 7,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef app(page):\n if not login_status():\n title_container = st.empty()\n remail_input_container = st.empty()\n rpw_input_container = st.empty()\n rregister... | [
0,
1,
2,
3
] |
import random
#liste de choix possibles
liste = ["rock", "paper", "scissors"]
#si le joueur veut jouer il répond y
answer = "y"
while answer == "y":
#choix du joueur
user_choice = input("rock,paper,scissors ?")
#verifie si le joueur a mis la réponse correcte
if user_choice in liste :
#choix d... | normal | {
"blob_id": "61232ec951cf378798220c00280ef2d351088d06",
"index": 8633,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile answer == 'y':\n user_choice = input('rock,paper,scissors ?')\n if user_choice in liste:\n prog = random.choice(liste)\n print(\"computer's choice :\", prog)\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def solution(num):
if num < 10:
num = str(num) + str(0)
else:
num = str(num)
cycle_val = 0
new_num = ''
temp_num = num[:]
while new_num != num:
sum_num = int(temp_num[0]) + int(temp_num[1])
new_num = tem... | flexible | {
"blob_id": "cec772f1e470aae501aa7c638ec4cbb565848804",
"index": 9258,
"step-1": "<mask token>\n",
"step-2": "def solution(num):\n if num < 10:\n num = str(num) + str(0)\n else:\n num = str(num)\n cycle_val = 0\n new_num = ''\n temp_num = num[:]\n while new_num != num:\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('hello, World! From SIG Python - Gaurangi Rawat')
<|reserved_special_token_0|>
print('volume=', volume)
<|reserved_special_token_0|>
print(email_msg)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('hello,... | flexible | {
"blob_id": "150e0180567b74dfcd92a6cd95cf6c6bf36f6b5d",
"index": 4228,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('hello, World! From SIG Python - Gaurangi Rawat')\n<mask token>\nprint('volume=', volume)\n<mask token>\nprint(email_msg)\n",
"step-3": "<mask token>\nprint('hello, World! From SI... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class RegisterFile:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class Memory:
def __init__(self):
self.dicti = {}
for i in range(0, 1021):
... | flexible | {
"blob_id": "1913bbffd8c3c9864a8eeba36c6f06e30d2dd2c8",
"index": 4740,
"step-1": "<mask token>\n\n\nclass RegisterFile:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Memory:\n\n def __init__(self):\n self.dicti = {}\n for i in range(0, 1021)... | [
7,
10,
11,
13,
15
] |
from django.apps import AppConfig
class PyrpgConfig(AppConfig):
name = 'PyRPG'
| normal | {
"blob_id": "f8bf7e2d8f06bbd00f04047153833c07bf483fd3",
"index": 259,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass PyrpgConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass PyrpgConfig(AppConfig):\n name = 'PyRPG'\n",
"step-4": "from django.apps import AppConfig\... | [
0,
1,
2,
3
] |
import re
# Wordcount: count the occurrences of each word in that phrase.
def word_count(phrase):
phrase = re.sub(r'\W+|_', ' ', phrase.lower(), flags=re.UNICODE)
word_list = phrase.split()
wordfreq = [word_list.count(p) for p in word_list]
return dict(zip(word_list, wordfreq))
| normal | {
"blob_id": "e12905efa0be7d69e2719c05b40d18c50e7e4b2e",
"index": 4933,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef word_count(phrase):\n phrase = re.sub('\\\\W+|_', ' ', phrase.lower(), flags=re.UNICODE)\n word_list = phrase.split()\n wordfreq = [word_list.count(p) for p in word_list]... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def inplace_quick_sort(S, start, end):
if start > end:
return
pivot = S[end]
left = start
right = end - 1
while left <= right:
while left <= right and S[left] < pivot:
left += 1
while left <= right and p... | flexible | {
"blob_id": "2a09711e3e487c5d7790af592ff2eb03bb53cff2",
"index": 5068,
"step-1": "<mask token>\n",
"step-2": "def inplace_quick_sort(S, start, end):\n if start > end:\n return\n pivot = S[end]\n left = start\n right = end - 1\n while left <= right:\n while left <= right and S[left]... | [
0,
1,
2,
3
] |
import db
data = {'python book': ['10.09.2019', 200, 50, False]}
def test_insert_and_get_db(data):
db.insert(data)
result = db.get_db()
return result == data
if __name__ == '__main__':
print(
f' Test insert dict in to db, and get dict from db is {test_insert_and_get_db(data)}'
)
... | normal | {
"blob_id": "d5cb875dc31ca3dd7b165206415c346a076dd6e4",
"index": 2901,
"step-1": "<mask token>\n\n\ndef test_insert_and_get_db(data):\n db.insert(data)\n result = db.get_db()\n return result == data\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_insert_and_get_db(data):\n db.insert(dat... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def rbinarysearch(l, k, begin, end):
if begin == end:
if l[begin] == k:
return 1
else:
return 0
if end - begin == 1:
if l[end] == k or l[begin] == k:
return 1
... | flexible | {
"blob_id": "7171edc3eecd2f0cdebd914e89a7a7e0353ddf63",
"index": 9209,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef rbinarysearch(l, k, begin, end):\n if begin == end:\n if l[begin] == k:\n return 1\n else:\n return 0\n if end - begin == 1:\n if ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if user_sample[0].get('milesRan') >= user_sample[1].get('milesGoal'):
message = client.messages.create(body='Oh, no! ' + user_sample[0].get(
'name') +
' surpassed your running goal this week. Get moving to keep... | flexible | {
"blob_id": "67eb9985fc0ae9a00ce84a2460b69b00df1c9096",
"index": 3310,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif user_sample[0].get('milesRan') >= user_sample[1].get('milesGoal'):\n message = client.messages.create(body='Oh, no! ' + user_sample[0].get(\n 'name') +\n ' surpassed y... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# coding: utf-8
# HR Employee Retension Rate, predicting an employee likely to leave or not.
# In[ ]:
import numpy as np # 数组常用库
import pandas as pd # 读入csv常用库
from patsy import dmatrices # 可根据离散变量自动生成哑变量
from sklearn.linear_model import LogisticRegression # sk-learn库Logistic Regression模型
from skl... | normal | {
"blob_id": "a1bf4b941b845b43ec640b19a001e290b46c488c",
"index": 7021,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndata\ndata.describe()\ndata.dtypes\npd.crosstab(data.salary, data.left)\npd.crosstab(data.salary, data.left).plot(kind='bar')\nplt.show()\n<mask token>\nprint(q)\nprint(q.sum(1))\nprint(q... | [
0,
1,
2,
3,
4
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.