code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
from django.db import models
from django.contrib.contenttypes.models import ContentType
from widgy.generic import ProxyGenericForeignKey, ProxyGenericRelation
from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation
class Base(models.Model):
content_type = models.ForeignKey(ContentType)... | normal | {
"blob_id": "c70df1fab0db6f71d22a23836b11d66879879656",
"index": 6336,
"step-1": "<mask token>\n\n\nclass Related(models.Model):\n <mask token>\n <mask token>\n\n\nclass AbstractModel(models.Model):\n bases = ProxyGenericRelation(Base, content_type_field='content_type',\n object_id_field='content... | [
6,
7,
8,
9,
11
] |
import re
import requests
import numpy as np
import json
import os
from collections import OrderedDict
import pandas as pd
import json
import datetime
import time
#将数组写入json文件方便pandas的读取
def write_list_to_json(list, json_file_name, json_file_save_path):
os.chdir(json_file_save_path)
with open(json_file_name, 'w... | normal | {
"blob_id": "0677e12bc9733c76bff7ed3fe83e3800e64e9a10",
"index": 7633,
"step-1": "<mask token>\n\n\ndef getworld_data(url, header):\n headers = header\n res = requests.get(url, headers=headers)\n res.encoding = 'UTF-8'\n pattern = re.compile(\n '(\\'\\\\{\"(\\\\w+)\":{\"active\":(.*?),\"confir... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class MyLog(LogBase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def get_logger(self):
return self._get_logger()
@staticmethod
def type_need(parm, type_):
if not isinstance(parm, type_):
raise TypeError(f'expect {type_},but ... | flexible | {
"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
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class DrinkFilter(django_filters.FilterSet):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_spe... | flexible | {
"blob_id": "a096e811e50e25e47a9b76b1f813c51f4307bbfe",
"index": 331,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass DrinkFilter(django_filters.FilterSet):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n clas... | [
0,
1,
2,
3,
4
] |
import requests
import codecs
import urllib.request
import time
from bs4 import BeautifulSoup
from html.parser import HTMLParser
import re
import os
#input
Result_File="report.txt"
#deleting result file if exists
if os.path.exists(Result_File):
os.remove(Result_File)
#reading html file and parsing logic
f=codecs.o... | normal | {
"blob_id": "869bbc8da8cdb5de0bcaf5664b5482814daae53a",
"index": 6212,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif os.path.exists(Result_File):\n os.remove(Result_File)\n<mask token>\nwith open(Result_File, 'w') as r:\n r.write(\n 'OI_CE|Chng_in_OI_CE |Volume_CE|IV_CE|LTP_CE|NetChng_CE... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
g.parse('http://geographicknowledge.de/vocab/CoreConceptData.rdf#')
g.parse('./ontology.ttl', format='ttl')
sleep(0.5)
<|reserved_special_token_0|>
for result in results:
uri, geometry_type = result
gtypes[str(uri)] = str(... | flexible | {
"blob_id": "eb1fbe2de3c8548175eb3c8720353e466e3b68c7",
"index": 7336,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ng.parse('http://geographicknowledge.de/vocab/CoreConceptData.rdf#')\ng.parse('./ontology.ttl', format='ttl')\nsleep(0.5)\n<mask token>\nfor result in results:\n uri, geometry_type = re... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def skewness_log(df):
df['SalePrice_New'] = np.log(df['SalePrice'])
df['GrLivArea_New'] = np.log(df['GrLivArea'])
skewed_slPri = skew(df['SalePrice_New'])
skewness_grLiv = skew(df['GrLivArea_New'])
return ske... | flexible | {
"blob_id": "f5bd41f4aaff616a332d80ec44c364ffc91c58f0",
"index": 265,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef skewness_log(df):\n df['SalePrice_New'] = np.log(df['SalePrice'])\n df['GrLivArea_New'] = np.log(df['GrLivArea'])\n skewed_slPri = skew(df['SalePrice_New'])\n skewness_... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def isHarshad(n):
if n % findSum(n) == 0:
return True
return False
def findHarshad(low, high):
low = 500
high = 525
streak = 0
maxStreak = 0
for i in range(low, high + 1, 1):
if isHarshad(i):
streak = streak + 1
else:
... | flexible | {
"blob_id": "2a95a68d8570a314b2b6e5731d7a695e5d7e7b30",
"index": 6261,
"step-1": "<mask token>\n\n\ndef isHarshad(n):\n if n % findSum(n) == 0:\n return True\n return False\n\n\ndef findHarshad(low, high):\n low = 500\n high = 525\n streak = 0\n maxStreak = 0\n for i in range(low, hig... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in new:
n[i] = s.count(i)
<|reserved_special_token_0|>
for k, v in n.items():
cnt.append(v)
if cnt.count(max(cnt)) > 1:
print('?')
else:
print(max(n, key=n.get))
<|reserved_special_token_1|>
<|reserved_spe... | flexible | {
"blob_id": "5dcb20f52b5041d5f9ea028b383e0f2f10104af9",
"index": 9486,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in new:\n n[i] = s.count(i)\n<mask token>\nfor k, v in n.items():\n cnt.append(v)\nif cnt.count(max(cnt)) > 1:\n print('?')\nelse:\n print(max(n, key=n.get))\n",
"step... | [
0,
1,
2,
3,
4
] |
import os
import sys
import json
from subprocess import Popen, PIPE, STDOUT
from twisted.internet.task import deferLater
from twisted.internet import reactor
from autobahn.twisted.websocket import WebSocketServerFactory, WebSocketServerProtocol, listenWS
from utils import rsync
# TODO: Add Twisted logger
# TODO: Cre... | normal | {
"blob_id": "30251b7c2ce30b7fa899a5885707c078788d0106",
"index": 1956,
"step-1": "import os\nimport sys\nimport json\nfrom subprocess import Popen, PIPE, STDOUT\n\nfrom twisted.internet.task import deferLater\nfrom twisted.internet import reactor\nfrom autobahn.twisted.websocket import WebSocketServerFactory, We... | [
0
] |
import json
from django.db import models
from django.conf import settings
from django.core.serializers import serialize
# Create your models here.
def upload_updated_image(instance,filename):
return '/MyApi/{user}/{filename}'.format(user=instance.user,filename=filename)
class UpdateQueryset(models.QuerySet):
... | normal | {
"blob_id": "5749f30d1a1efd5404654d755bca4515adcf4bca",
"index": 1810,
"step-1": "<mask token>\n\n\nclass CRUD(models.Model):\n user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE\n )\n name = models.TextField(blank=True, null=True)\n content = models.TextField(blank=True,... | [
4,
8,
9,
10,
11
] |
from flask import Flask, render_template
from flask_ask import Ask, statement, question, session
import reverse_geocoder as rg
from geopy import distance
from geopy.geocoders import Nominatim
import requests
import time
'''
:::::::: ::::::::: ::: :::::::: :::::::::: ::: ::: ::: ::: ... | normal | {
"blob_id": "726f133bcf592315c42f8701be8308422ffbf0d9",
"index": 426,
"step-1": "<mask token>\n\n\ndef where_is_the_iss_now():\n iss_now_website = 'http://api.open-notify.org/iss-now.json'\n webby = requests.get(iss_now_website)\n data = webby.json()\n if data['iss_position']:\n longitude = da... | [
8,
9,
11,
12,
17
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
screen.setup(width=600, height=600)
screen.bgcolor('black')
screen.title('Snake Game')
screen.tracer(0)
<|reserved_special_token_0|>
screen.listen()
screen.onkey(snake.up, 'Up')
screen.onkey(snake.down, 'Down')
screen.onkey(snake.... | flexible | {
"blob_id": "cfc0ca0d8528937526f6c42721870f1739a2ae95",
"index": 5467,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nscreen.setup(width=600, height=600)\nscreen.bgcolor('black')\nscreen.title('Snake Game')\nscreen.tracer(0)\n<mask token>\nscreen.listen()\nscreen.onkey(snake.up, 'Up')\nscreen.onkey(snake... | [
0,
1,
2,
3,
4
] |
# pyre-ignore-all-errors
# Copyright (c) The Diem Core Contributors
# SPDX-License-Identifier: Apache-2.0
from wallet.storage import db_session, engine, Base
from wallet.storage.models import User, Account
from wallet.types import RegistrationStatus
from diem_utils.types.currencies import FiatCurrency
def clear_db(... | normal | {
"blob_id": "a6bd10723bd89dd08605f7a4abf17ccf9726b3f5",
"index": 8937,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef setup_fake_data() ->None:\n clear_db()\n fake_users = [User(username='sunmi', registration_status=\n RegistrationStatus.Registered, selected_fiat_currency=FiatCurrenc... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def bio_shortener(bio):
lines = []
x = len(bio) / 30
y = 0
Status = True
while Status:
y = y + 1
lines.append(bio[0:30])
lines.append('\n')
bio = bio[30:]
if y == int(x) + 1:
Status = False
A = ''.join(lines)
... | flexible | {
"blob_id": "e1c902ef340a0a5538b41a03cc93686e0dd31672",
"index": 8788,
"step-1": "<mask token>\n\n\ndef bio_shortener(bio):\n lines = []\n x = len(bio) / 30\n y = 0\n Status = True\n while Status:\n y = y + 1\n lines.append(bio[0:30])\n lines.append('\\n')\n bio = bio[3... | [
3,
4,
5,
6,
7
] |
class Solution(object):
def maxDistToClosest(self, seats):
"""
:type seats: List[int]
:rtype: int
"""
start = 0
end = 0
length = len(seats)
max_distance = 0
for i in range(len(seats)):
seat = seats[i]
if seat == 1:
... | normal | {
"blob_id": "2b8b502381e35ef8e56bc150114a8a4831782c5a",
"index": 3819,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n",
"step-3": "class Solution(object):\n\n def maxDistToClosest(self, seats):\n \"\"\"\n :type seats: List[int]\n :rtype: int\n ... | [
0,
1,
2
] |
import numpy as np
a = np.array([1, 2, 3])
b = np.r_[np.repeat(a, 3), np.tile(a, 3)]
print(b)
| normal | {
"blob_id": "f39945f35b13c0918c3ef06224bca65ae6166ebc",
"index": 5892,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(b)\n",
"step-3": "<mask token>\na = np.array([1, 2, 3])\nb = np.r_[np.repeat(a, 3), np.tile(a, 3)]\nprint(b)\n",
"step-4": "import numpy as np\na = np.array([1, 2, 3])\nb = np.r... | [
0,
1,
2,
3
] |
import os
import json
import random
chapter_mode = True
setname = 'test_other'
use_chapter = '_chapter'
minlen = 1000
maxlen = 1000
context = '_1000'
info_json = 'bookinfo{}_{}{}.json'.format(use_chapter, setname, context)
book_ID_mapping = {}
with open('speaker_book.txt') as fin:
for line in fin:
elems ... | normal | {
"blob_id": "3b41bd59c133bb04dae3aa48dc0699388d5bf3d4",
"index": 8346,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('speaker_book.txt') as fin:\n for line in fin:\n elems = line.split('|')\n ID = elems[0].lstrip().strip()\n speaker = elems[1].lstrip().strip()\n ... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# coding: utf-8
from os.path import dirname, abspath
PICKITEMSP = True
RAREP = True
REPAIRP = False
ITEMS = {
"legendary": ["#02CE01", # set
"#BF642F"], # legndary
"rare": ["#BBBB00"]
}
current_abpath = abspath(dirname(__file__)) + "/"
# Wi... | normal | {
"blob_id": "927b42326ad62f5e484fd7016c42a44b93609f83",
"index": 1296,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif current_abpath[-12:] == 'library.zip/':\n current_abpath = current_abpath[:-12]\n<mask token>\n\n\ndef get_item_colors():\n \"\"\"\n >>> get_item_colors()\n \"\"\"\n res... | [
0,
2,
3,
4,
5
] |
from datetime import datetime as dt
YEAR = dt.today().year
BINARY_LOCATION = {'binary_location': 'C:/Program Files (x86)/Google/Chrome/Application/chrome.exe'}
CHROME_DRIVER_PATH = r'C:\Users\pavithra\Downloads\chromedriver_win32\chromedriver.exe'
EXTRACTED_DIR = r'C:\Users\pavithra\Documents\fintuple-automation-proje... | normal | {
"blob_id": "95422348c8db9753830cc0a7c8785c05b44886b1",
"index": 842,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef enable_download(driver, directory):\n \"\"\"\n\n :param driver: Selenium web driver\n :param directory: Directory to store the file\n\n This function allows the Seleniu... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def results(request):
team1damage = 0
team2damage = 0
winner = run(1, 2)
team1 = Team.objects.get(pk=1)
team2 = Team.objects.get(pk=2)
player1 = Player.objects.get(pk=1)
player2 = Player.objects.get(p... | flexible | {
"blob_id": "e1829904cea51909b3a1729b9a18d40872e7c13c",
"index": 6163,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef results(request):\n team1damage = 0\n team2damage = 0\n winner = run(1, 2)\n team1 = Team.objects.get(pk=1)\n team2 = Team.objects.get(pk=2)\n player1 = Player.o... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
sys.path.append('coin_flipping_src')
<|reserved_special_token_0|>
plt.style.use('bmh')
<|reserved_special_token_0|>
plt.plot(x_coords, probablility_results, linewidth=2.5)
for _ in range(5):
plt.plot(x_coords, [monte_carlo(x, ... | flexible | {
"blob_id": "124d7da330aa7c869320e10f4f89cc1c872f85f2",
"index": 430,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.append('coin_flipping_src')\n<mask token>\nplt.style.use('bmh')\n<mask token>\nplt.plot(x_coords, probablility_results, linewidth=2.5)\nfor _ in range(5):\n plt.plot(x_coords, ... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
'''
** dmcalc **
Estimates the Dispersion Measure (DM) from the data in psrfits file format.
Returns the DM value with its uncertainty and reduced chi-square from tempo2
DM fit.
Dependencies
-------------
PSRCHIVE with python interface: http://psrchive.sourceforge.ne... | normal | {
"blob_id": "e464b465c4bc90c250c0ea02c17b7398d975964b",
"index": 1163,
"step-1": "<mask token>\n\n\ndef main():\n args = parser.parse_args()\n quiet = False\n if args.quiet:\n quiet = True\n tempo2 = True\n ptoa = False\n if args.print_toas:\n ptoa = True\n if not quiet:\n ... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class CreateExtraFeatures(BaseEstimator, TransformerMixin):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def transform(self, X, y=None):
X['hair_soul'] = X['hair_length'] * X['has_soul']
X['flesh_soul'] = X['rotting_flesh'] * X['has_soul']
... | flexible | {
"blob_id": "ccedca543fc4dee284a9243317d028ffdeac229d",
"index": 2923,
"step-1": "<mask token>\n\n\nclass CreateExtraFeatures(BaseEstimator, TransformerMixin):\n <mask token>\n <mask token>\n\n def transform(self, X, y=None):\n X['hair_soul'] = X['hair_length'] * X['has_soul']\n X['flesh_s... | [
6,
8,
9,
10,
12
] |
from flask import Flask,Blueprint
from .views import login
from flask_session import Session
import redis
app = Flask(__name__,template_folder='templates',static_url_path='static')
app.debug = True
print('app.root_path===',app.root_path)
print('app.static_url_path===',app.static_url_path)
app.secret_key('uaremyhero... | normal | {
"blob_id": "9d2fdf47b5c4b56cc0177a9c0a86b1ed57c88d49",
"index": 4151,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('app.root_path===', app.root_path)\nprint('app.static_url_path===', app.static_url_path)\napp.secret_key('uaremyhero')\n<mask token>\nSession(app)\napp.register_blueprint(login.logi... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
import mcvine.cli
from numpy import array
from mcvine_workflow.singlextal.resolution import use_res_comps as urc
beam_neutrons_path = '/SNS/users/p63/ORNL_public_research/MCViNE_Covmat_comparison/mcvine_resolution/beams/beam_30_1e9/out/neutrons'
instrument = urc.instrument('ARCS', '3.*meter', '13.... | normal | {
"blob_id": "de286b94e09db477e3d920a9eff1a299474baf20",
"index": 2614,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurc.run(beam_neutrons_path, instrument, samplexmlpath, psi, hkl2Q, pixel,\n t_m2p, Q, E, hkl_projection, Nbuffer=100000)\n",
"step-3": "<mask token>\nbeam_neutrons_path = (\n '/SN... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#Modules externes
import os
import re
import logging
import csv
import xml.etree.ElementTree as ET
from chardet import detect
#Modules maison
from Abes_Apis_Interface.AbesXml import AbesXml
from Alma_Apis_Interface import Alma_Apis_Records
from Alma_Apis_Interface import Alma... | normal | {
"blob_id": "1f94ef0aae1128089b34fc952766cc3927677cdf",
"index": 5698,
"step-1": "<mask token>\n\n\ndef get_encoding_type(file):\n with open(file, 'rb') as f:\n rawdata = f.read()\n return detect(rawdata)['encoding']\n\n\ndef item_change_location(item, location, call):\n \"\"\"Change location and... | [
3,
4,
5,
6,
7
] |
import requests
import json
from termcolor import cprint
from pathlib import Path
import os
def console_check(csl, f):
if csl == 'playstation-4':
f.write('\tdbo:computingPlatform dbpedia:PlayStation_4.')
if csl == 'playstation-3':
f.write('\tdbo:computingPlatform dbpedia:PlayStation... | normal | {
"blob_id": "b290763362af96f5af03fa31f4936339cef66a1d",
"index": 2062,
"step-1": "<mask token>\n\n\ndef console_check(csl, f):\n if csl == 'playstation-4':\n f.write('\\tdbo:computingPlatform dbpedia:PlayStation_4.')\n if csl == 'playstation-3':\n f.write('\\tdbo:computingPlatform dbpedia:Pla... | [
6,
7,
8,
9,
10
] |
from .base import BaseEngine
import re
class YandexSearch(BaseEngine):
base_url = "https://yandex.com"
search_url = "https://yandex.com/search/"
def get_params(self, query, **params):
params["text"] = query
params["p"] = None
return params
def next_url(self, soup):
if... | normal | {
"blob_id": "0ec3ca0f952dbc09c7a7a3e746c0aeab28ee9834",
"index": 6498,
"step-1": "<mask token>\n\n\nclass YandexSearch(BaseEngine):\n <mask token>\n <mask token>\n <mask token>\n\n def next_url(self, soup):\n if (regex := re.findall('\"(/search/\\\\?[^>]+p=[^\"]+)', str(soup))):\n r... | [
4,
5,
6,
7,
8
] |
#!/usr/bin/env python
# @HEADER
# ************************************************************************
#
# TriBITS: Tribal Build, Integrate, and Test System
# Copyright 2013 Sandia Corporation
#
# Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
# the U.S. Govern... | normal | {
"blob_id": "550f5ad4fef77d5795db0393ae0701f679143e72",
"index": 221,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif os.environ.get('MOCKPROGRAM_INOUT_FILE_OVERRIDE'):\n mockProgramInOutFilePath = os.environ.get('MOCKPROGRAM_INOUT_FILE_OVERRIDE'\n )\nelse:\n mockProgramInOutFilePath = '.m... | [
0,
1,
2,
3,
4
] |
<|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": "a7add26a919a41e52ae41c6b4c4079eadaa8aa1d",
"index": 851,
"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', '0036... | [
0,
1,
2,
3,
4
] |
''' extract package names from the Meteor guide and write them to packages-guide
Uses the content folder of https://github.com/meteor/guide '''
from collections import defaultdict
import os
import sys
import markdown
from bs4 import BeautifulSoup
def get_links_from_markdown(path, name):
try:
with op... | normal | {
"blob_id": "274185896ab5c11256d69699df69fc2c0dde4f2d",
"index": 987,
"step-1": "<mask token>\n\n\ndef get_links_from_markdown(path, name):\n try:\n with open(path, 'r') as file:\n md = file.read()\n html = markdown.markdown(md)\n soup = BeautifulSoup(html, 'html.parser... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
import os
import subprocess
import virtualenv
from templateserver import __version__ as version
DEFAULT_TEMPLATE_DIR = 'templates'
DEFAULT_MEDIA_DIR = 'media'
DEFAULT_STATIC_DIR = 'static'
DEFAULT_ENV_DIR = '.env'
DEFAULT_RUNSERVER_PATH = 'runserver.py'
RUNSERVER_TEMPLATE = os.path.abspath(os... | normal | {
"blob_id": "3f41cb1acbbb1a397ae1288bca1cbcd27c0d3f33",
"index": 5143,
"step-1": "# -*- coding: utf-8 -*-\nimport os\nimport subprocess\nimport virtualenv\nfrom templateserver import __version__ as version\n\n\nDEFAULT_TEMPLATE_DIR = 'templates'\nDEFAULT_MEDIA_DIR = 'media'\nDEFAULT_STATIC_DIR = 'static'\nDEFAUL... | [
0
] |
<|reserved_special_token_0|>
class Card:
def check_cat(self, string):
if 'Cat' in string:
return True
return False
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def steal(self, hand, player, arr... | flexible | {
"blob_id": "3b71ef6c3681b8c5e6aadf2d125c35cbf3a12661",
"index": 6248,
"step-1": "<mask token>\n\n\nclass Card:\n\n def check_cat(self, string):\n if 'Cat' in string:\n return True\n return False\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def steal(... | [
4,
6,
8,
10,
12
] |
from django.contrib import admin
from .models import Invite
class InviteAdmin(admin.ModelAdmin):
list_display = ('invitee', 'inviter', 'created_on', 'approved',
'rejected', 'used')
admin.site.register(Invite, InviteAdmin)
| normal | {
"blob_id": "fcb13b087b9c967ab16b64885411cc4aae98583c",
"index": 2130,
"step-1": "<mask token>\n\n\nclass InviteAdmin(admin.ModelAdmin):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass InviteAdmin(admin.ModelAdmin):\n list_display = ('invitee', 'inviter', 'created_on', 'approved',... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class Item(models.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>... | flexible | {
"blob_id": "efba815fe64cddb5315b17b2cbaf1d3fc38c11ee",
"index": 4995,
"step-1": "<mask token>\n\n\nclass Item(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <m... | [
2,
3,
4,
6,
7
] |
<|reserved_special_token_0|>
def cast_types(args):
args.epochs = int(args.epochs)
args.batch_size = int(args.batch_size)
args.input_shape = args.input_shape.split(' ')
for num in args.input_shape:
if num != '':
num = int(num)
args.input_shape = tuple(args.input_shape)
retur... | flexible | {
"blob_id": "fbac2d66f4d69a52c3df5d665b622659e4d8dacd",
"index": 5733,
"step-1": "<mask token>\n\n\ndef cast_types(args):\n args.epochs = int(args.epochs)\n args.batch_size = int(args.batch_size)\n args.input_shape = args.input_shape.split(' ')\n for num in args.input_shape:\n if num != '':\n ... | [
2,
3,
4,
5,
6
] |
from keras.preprocessing.text import text_to_word_sequence
from keras.models import Sequential
from keras.layers import Activation, TimeDistributed, Dense, RepeatVector, recurrent, Embedding
from keras.layers.recurrent import LSTM
from keras.optimizers import Adam, RMSprop
#from nltk import FreqDist
import numpy as np
... | normal | {
"blob_id": "2962ef1d7ecd4e8d472b9dc36664e4e8745391fd",
"index": 3616,
"step-1": "<mask token>\n\n\ndef load_data(train_source, train_dist, test_source, test_dist, max_len,\n vocab_size):\n \"\"\"\n fin = open(test_source, \"r\")\n data2 = fin.read()\n fin.close()\n fout = open(train_source, \"... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(len(s)):
ans[s[i]] = sa[i]
<|reserved_special_token_0|>
for k in ans:
S.add(k)
<|reserved_special_token_0|>
for i in range(1, len(L)):
s = L[i]
S = ''
for j in range(len(s)):
if s[j] == '... | flexible | {
"blob_id": "77b9b111cfb4d0b54e14b2aab81b7b05fd6bbccd",
"index": 8552,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(len(s)):\n ans[s[i]] = sa[i]\n<mask token>\nfor k in ans:\n S.add(k)\n<mask token>\nfor i in range(1, len(L)):\n s = L[i]\n S = ''\n for j in range(len(s)):\... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import pygtk
pygtk.require("2.0")
import gtk
from testarMsg import *
class tgApp(object):
def __init__(self):
builder = gtk.Builder()
builder.add_from_file("../tg.glade")
self.window = builder.get_object("window1")
self.text_area = buil... | normal | {
"blob_id": "6b6fac3bfb1b1478dd491fc4dd9c45a19aeb7bd8",
"index": 6102,
"step-1": "<mask token>\n\n\nclass tgApp(object):\n\n def __init__(self):\n builder = gtk.Builder()\n builder.add_from_file('../tg.glade')\n self.window = builder.get_object('window1')\n self.text_area = builder... | [
6,
8,
9,
10,
12
] |
from compass import models
from compass.models.MetabolicModel import MetabolicModel
def test_sbml_3():
model = models.load_metabolic_model("RECON1_xml")
assert isinstance(model, MetabolicModel)
assert len(model.reactions) == 3742
assert len(model.species) == 2766
def test_sbml_2():
model = model... | normal | {
"blob_id": "863bae04a90143ed942a478c4b71a2269e123bb5",
"index": 2980,
"step-1": "<mask token>\n\n\ndef test_mat():\n model = models.load_metabolic_model('RECON2_mat')\n assert isinstance(model, MetabolicModel)\n assert len(model.reactions) == 7440\n assert len(model.species) == 5063\n\n\ndef test_to... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
def _build_default_components_text():
text = ''
for c in DEFAULT_COMPONENTS:
text += c + '\n'
return text
<|reserved_special_token_0|>
def autentificate_user(request):
username = request.POST['username']
password = request.POST['password']
user = authen... | flexible | {
"blob_id": "fbbf27f063f6d866e5d0b1210ea9acaebb3bdfb4",
"index": 4398,
"step-1": "<mask token>\n\n\ndef _build_default_components_text():\n text = ''\n for c in DEFAULT_COMPONENTS:\n text += c + '\\n'\n return text\n\n\n<mask token>\n\n\ndef autentificate_user(request):\n username = request.PO... | [
8,
10,
13,
14,
16
] |
<|reserved_special_token_0|>
@MultiSerializer.register(lambda x: True)
class PickleSerializer(BaseSerializer):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def deserialize(self, data):
return pickle.loads(data)
@MultiSerializer.register(lambda x: is... | flexible | {
"blob_id": "94f5fa411f8a41985caaf4eb7ab1cb4e45439405",
"index": 1524,
"step-1": "<mask token>\n\n\n@MultiSerializer.register(lambda x: True)\nclass PickleSerializer(BaseSerializer):\n <mask token>\n <mask token>\n <mask token>\n\n def deserialize(self, data):\n return pickle.loads(data)\n\n\n... | [
18,
26,
32,
33,
37
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with con:
cur = con.cursor()
cur.execute('DROP TABLE IF EXISTS log')
cur.execute(
'CREATE TABLE log (msg_id text, u_id text, username text, first_name text, last_name text, msg text, ch_id text, day text)'
... | flexible | {
"blob_id": "1c31649ac75214a6d26bcb6d6822579be91e5074",
"index": 2748,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith con:\n cur = con.cursor()\n cur.execute('DROP TABLE IF EXISTS log')\n cur.execute(\n 'CREATE TABLE log (msg_id text, u_id text, username text, first_name text, last_n... | [
0,
1,
2,
3,
4
] |
'''
Function Description
Complete the extraLongFactorials function in the editor below. It should print the result and return.
extraLongFactorials has the following parameter(s):
n: an integer
Note: Factorials of
can't be stored even in a
long long variable. Big integers must be used for such calcu... | normal | {
"blob_id": "5c1ce46f45da33acf75a7f47add811b14d58414d",
"index": 1169,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef extraLongFactorials(n):\n print(math.factorial(n))\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef extraLongFactorials(n):\n print(math.factorial(n))\n\n\nif __name... | [
0,
1,
2,
3,
4
] |
file = open("yo.txt", "wr")
file.write("Yo")
| normal | {
"blob_id": "207b6e56b683c0b069c531a4c6076c2822814390",
"index": 512,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfile.write('Yo')\n",
"step-3": "file = open('yo.txt', 'wr')\nfile.write('Yo')\n",
"step-4": "file = open(\"yo.txt\", \"wr\")\n\nfile.write(\"Yo\")\n\n",
"step-5": null,
"step-ids":... | [
0,
1,
2,
3
] |
"""
Schema management for various object types (publisher, dataset etc). Loads
the jsonschema and allows callers to validate a dictionary against them.
"""
import os
import json
import pubtool.lib.validators as v
from jsonschema import validate, validators
from jsonschema.exceptions import ValidationError
SCHEMA = ... | normal | {
"blob_id": "c4f39f9212fbe0f591543d143cb8f1721c1f8e1e",
"index": 7056,
"step-1": "<mask token>\n\n\nclass ObjectValidationErrors(Exception):\n\n def __init__(self, errors):\n self.errors = errors\n\n\ndef _get_directory():\n p = os.path.dirname(__file__)\n p = os.path.join(p, os.pardir, os.pardir... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class ArgParser:
<|reserved_special_token_0|>
def add_parser_argument(self, parser, option_name, options):
params = self.prepare_params(options)
alias = params.pop('alias', None)
positional = params.pop('positional', False)
param_name = '--{}'.form... | flexible | {
"blob_id": "94559d9fd296acd468c33d6b0541b974575b8852",
"index": 4119,
"step-1": "<mask token>\n\n\nclass ArgParser:\n <mask token>\n\n def add_parser_argument(self, parser, option_name, options):\n params = self.prepare_params(options)\n alias = params.pop('alias', None)\n positional ... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def calculate_stats(dataloader: AtomsLoader, divide_by_atoms: Dict[str,
bool], atomref: Dict[str, torch.Tensor]=None) ->Dict[str, Tuple[torch.
Tensor, torch.Tensor]]:
"""
Use the incremental Welford algorithm des... | flexible | {
"blob_id": "b2944a95dbe25057155aaf6198a97d85b3bb620b",
"index": 6436,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef calculate_stats(dataloader: AtomsLoader, divide_by_atoms: Dict[str,\n bool], atomref: Dict[str, torch.Tensor]=None) ->Dict[str, Tuple[torch.\n Tensor, torch.Tensor]]:\n \... | [
0,
1,
2,
3,
4
] |
# As variáveis abaixo estão recebendo uma função anônima
contador_letras = lambda lista: [len(x) for x in lista]
lista_animais = ['cachorro', 'pato', 'marreco']
print(contador_letras(lista_animais))
| normal | {
"blob_id": "d13957c3d3f4d34279dc660d80ca91ca84ba4a77",
"index": 4504,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(contador_letras(lista_animais))\n",
"step-3": "contador_letras = lambda lista: [len(x) for x in lista]\nlista_animais = ['cachorro', 'pato', 'marreco']\nprint(contador_letras(list... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def home(request):
cursos = Curso.objects.order_by('numero')
return render_to_response('home.html', {'posts': posts})
<|reserved_special_token_1|>
from django.shortcuts import render
from django.shortcuts import rende... | flexible | {
"blob_id": "bd81f4431699b1750c69b0bbc82f066332349fbd",
"index": 8976,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef home(request):\n cursos = Curso.objects.order_by('numero')\n return render_to_response('home.html', {'posts': posts})\n",
"step-3": "from django.shortcuts import render\nf... | [
0,
1,
2,
3
] |
def multiply(num1, num2):
return num1 * num2
| normal | {
"blob_id": "e835e75f444e97ca948ce27504cc9149ea0092f6",
"index": 1946,
"step-1": "<mask token>\n",
"step-2": "def multiply(num1, num2):\n return num1 * num2\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
class Config:
""" Flask application config """
SECRET_KEY = secrets.token_bytes(64)
SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(DATABASE_PATH)
SQLALCHEMY_TRACK_MODIFICATIONS = False
CAPTURES_DIR = HASHCAT_WPA_CACHE_DIR / 'captures'
<|reserved_special_token_1|>
<... | flexible | {
"blob_id": "20d480517226cb7fbced765554a02fa5cbc29033",
"index": 6491,
"step-1": "<mask token>\n\n\nclass Config:\n \"\"\" Flask application config \"\"\"\n SECRET_KEY = secrets.token_bytes(64)\n SQLALCHEMY_DATABASE_URI = 'sqlite:///{}'.format(DATABASE_PATH)\n SQLALCHEMY_TRACK_MODIFICATIONS = False\n... | [
3,
4,
5,
6,
7
] |
from random import choice, random, randrange
from math import fsum
import os
import numpy as np
def mat17(N, ATOM_TYPES, ndenmax=0.04302, ndenmin=0.0000013905, xmax=51.2, xmin=25.6, ymax=51.2, ymin=25.6,
zmax=51.2, zmin=25.6, epmax=513.264, epmin=1.2580, sigmax=6.549291, sigmin=1.052342, qmax=0.0, qmin=0.0):
#epmax DE... | normal | {
"blob_id": "ba72af921a9562d748bcd65f1837ea8eb5da5697",
"index": 150,
"step-1": "from random import choice, random, randrange\nfrom math import fsum\nimport os\nimport numpy as np\n\ndef mat17(N, ATOM_TYPES, ndenmax=0.04302, ndenmin=0.0000013905, xmax=51.2, xmin=25.6, ymax=51.2, ymin=25.6,\nzmax=51.2, zmin=25.6,... | [
0
] |
<|reserved_special_token_0|>
def decrypt(message):
message = base64.urlsafe_b64decode(message)
iv = message[:16]
signed_data = message[16:36]
encrypted_data = message[36:]
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=backend)
print(f"iv {len(iv)} {hexlify(iv).decode('ascii')}")
... | flexible | {
"blob_id": "c33aedbd5aaa853131c297a9382b72c3c646a319",
"index": 4006,
"step-1": "<mask token>\n\n\ndef decrypt(message):\n message = base64.urlsafe_b64decode(message)\n iv = message[:16]\n signed_data = message[16:36]\n encrypted_data = message[36:]\n cipher = Cipher(algorithms.AES(key), modes.CB... | [
1,
2,
3,
4,
5
] |
'''
* @Author: Mohammad Fatha.
* @Date: 2021-09-17 19:50
* @Last Modified by: Mohammad Fatha
* @Last Modified time: 2021-09-17 19:55
* @Title: Gambler Game
'''
import random
def gamblerProblem():
"""
Description:
This function Simulates a gambler who start with stake and place fair 1 bets until
... | normal | {
"blob_id": "68904be892968d4a1d82a59a31b95a8133a30832",
"index": 8790,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef gamblerProblem():\n \"\"\"\n Description:\n This function Simulates a gambler who start with stake and place fair 1 bets until\n he/she goes broke (i.e. has no... | [
0,
1,
2,
3,
4
] |
import psycopg2
from .connection import get_connection
def get_clientes():
query = 'SELECT nombre, t_documento ,documento, telefono, direccion, correo, ciudad_circulacion, fecha_nacimiento, comercial, primas FROM clientes'
cursor = get_connection(query)
return cursor
def get_clientes_by_id(_id... | normal | {
"blob_id": "035a87ccf21d45b2c147da4315c2143bea1ff21d",
"index": 8173,
"step-1": "<mask token>\n\n\ndef add_cliente(parametros):\n query = (\n 'INSERT INTO clientes VALUES(%s,%s,%s,%s,%s,%s,%s,%s,NULL,NULL,%s,NULL,%s)'\n )\n get_connection(query, parametros)\n print('Datos almacenados')\n ... | [
1,
5,
7,
9,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Glo_EstadoPlan(models.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Glo_EstadoPlan(models.Model):
descripcion_estado = mo... | flexible | {
"blob_id": "b0a51877b59e14eefdd662bac468e8ce12343e6b",
"index": 3885,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Glo_EstadoPlan(models.Model):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Glo_EstadoPlan(models.Model):\n descripcion_estado = models.CharFie... | [
0,
1,
3,
4,
5
] |
<|reserved_special_token_0|>
class UserViewSet(viewsets.ModelViewSet):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class UserViewSet(viewsets.ModelViewSet):
<|reserved_special_token_0|>
querys... | flexible | {
"blob_id": "fadf16792822926cb7b7386291e52ce44693baf8",
"index": 2053,
"step-1": "<mask token>\n\n\nclass UserViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass UserViewSet(viewsets.ModelViewSet):\n <mask token>\n queryset = UserCu... | [
1,
2,
3,
4
] |
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
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def usage_list(self):
print('Available modules')
print('=================')
for module in sorted(self.list()):
if 'module' not in self.mods[module]:
self.import_module(module)
if not self.mods[module]['module'].__doc__:... | flexible | {
"blob_id": "d0eb6ea2e816ac59ae93684edb38ff3a49909633",
"index": 762,
"step-1": "<mask token>\n",
"step-2": "def usage_list(self):\n print('Available modules')\n print('=================')\n for module in sorted(self.list()):\n if 'module' not in self.mods[module]:\n self.import_modu... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class assignmentObject:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class assignmentObject:
def __init__(self, name, day):
self.name = name
self.day = day
... | flexible | {
"blob_id": "1673214215043644e1a878ed7c30b69064f1a022",
"index": 5375,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass assignmentObject:\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass assignmentObject:\n\n def __init__(self, name, day):\n self.name = name\n self.day ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns = [url('^send_message$', send_message, name='send_message'),
url('^$', index, name='index')]
<|reserved_special_token_1|>
from django.conf.urls import url
from .views import index, send_message
urlpatterns = [ur... | flexible | {
"blob_id": "6cc56f73e58366a3906da537cc27fdd5a066ee34",
"index": 2647,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [url('^send_message$', send_message, name='send_message'),\n url('^$', index, name='index')]\n",
"step-3": "from django.conf.urls import url\nfrom .views import index, ... | [
0,
1,
2,
3
] |
quilogramas = float ( input ( "Insira o peso em Kg:" ))
libras = quilogramas / 0 , 45
print ( libras ) | normal | {
"blob_id": "9c35e64fd773c79dc20e6b388478e892bda85788",
"index": 1599,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(libras)\n",
"step-3": "quilogramas = float(input('Insira o peso em Kg:'))\nlibras = quilogramas / 0, 45\nprint(libras)\n",
"step-4": "quilogramas = float ( input ( \"Insira o ... | [
0,
1,
2,
3
] |
from pypack.Animal import Animal
__author__ = 'igord'
def nl():
print("\n")
def main():
# print("Hello2")
# animal = Animal(45)
# animal.double_age()
# print(animal.age)
print("Start")
msg = "ana i mujica"
msg2 = msg.replace("a", "$")
print(msg)
print(msg2)
ivana = "iva... | normal | {
"blob_id": "b0cdf75ff00d72ada75990dd850546414bc11125",
"index": 1799,
"step-1": "<mask token>\n\n\ndef nl():\n print('\\n')\n\n\ndef main():\n print('Start')\n msg = 'ana i mujica'\n msg2 = msg.replace('a', '$')\n print(msg)\n print(msg2)\n ivana = 'ivana'\n print(ivana * 2)\n fruit =... | [
2,
3,
4,
5,
6
] |
# Importing the random library for random choice.
import random
getnum = int(input("Pick a number greater than 7: "))
# Error checking.
if (getnum < 7):
print("Error 205: Too little characters entered")
print("Run again using python passwordgenerator.py, or click the run button on your IDE.")
exit()
# A li... | normal | {
"blob_id": "c40bb410ad68808c2e0cc636820ec6a2ec2739b8",
"index": 4053,
"step-1": "<mask token>\n\n\ndef main(lista, getnum):\n password = ''\n for i in range(0, getnum):\n passchar = random.choice(lista)\n password = password + passchar\n print(password)\n passwordagain()\n\n\ndef passw... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(filtered_words)
<|reserved_special_token_0|>
print(' '.join(singles))
<|reserved_special_token_1|>
stop_words = ['the', 'an', 'is', 'there']
word_list = ['we', 'are', 'the', 'students']
filtered_words = [word for word in ... | flexible | {
"blob_id": "d14937aaa7a80d6b95825afa2a2d6ff8202e5f5c",
"index": 2498,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(filtered_words)\n<mask token>\nprint(' '.join(singles))\n",
"step-3": "stop_words = ['the', 'an', 'is', 'there']\nword_list = ['we', 'are', 'the', 'students']\nfiltered_words = [w... | [
0,
1,
2,
3,
4
] |
"""
Python asyncio Protocol extension for TCP use.
"""
import asyncio
import logging
import socket
class TcpTestProtocol(asyncio.Protocol):
"""
Extension of asyncio protocol for TCP data
"""
def __init__(self, test_stream=None, no_delay=False, window=None, server=None):
"""
Initialize ... | normal | {
"blob_id": "9f0e286268732e8cabb028b7c84f5ba72a6e8528",
"index": 3068,
"step-1": "<mask token>\n\n\nclass TcpTestProtocol(asyncio.Protocol):\n <mask token>\n <mask token>\n\n @property\n def socket_id(self):\n \"\"\"Return socket id\"\"\"\n return self._sock_id\n\n def set_owner(self... | [
9,
11,
12,
13,
15
] |
# -*- coding: utf-8 -*-
"""Testing constants for Bio2BEL FlyBase."""
import logging
import os
log = logging.getLogger(__name__)
dir_path = os.path.dirname(os.path.realpath(__file__))
TEST_FILE = os.path.join(dir_path, 'test_gene_map_table.tsv.gz')
| normal | {
"blob_id": "bad719d968b4e358f863b7ef13bc12127f726806",
"index": 682,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlog = logging.getLogger(__name__)\ndir_path = os.path.dirname(os.path.realpath(__file__))\nTEST_FILE = os.path.join(dir_path, 'test_gene_map_table.tsv.gz')\n",
"step-3": "<mask token>\ni... | [
0,
1,
2,
3
] |
x = 1
while x <= 24:
if x % 5 == 0:
x = x + 1
continue
print(x)
x = x + 1
| normal | {
"blob_id": "61cfc583cd87ac0528cb07f4e051392167414920",
"index": 1960,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile x <= 24:\n if x % 5 == 0:\n x = x + 1\n continue\n print(x)\n x = x + 1\n",
"step-3": "x = 1\nwhile x <= 24:\n if x % 5 == 0:\n x = x + 1\n ... | [
0,
1,
2
] |
# created by ahmad on 17-07-2019
# last updated on 21-07-2019
#recommended font size of console in pydroid is 12
from decimal import Decimal
def fromTen():
global fin
fin = num
nnum = num
base = base2
if count == 1:
nnum = sum(milst) + sum(mdlst)
Ipart = int(nnum)
Dpart = Dec... | normal | {
"blob_id": "9cf32e127664cb4c3290e665e35245acc936e064",
"index": 4090,
"step-1": "<mask token>\n\n\ndef fromTen():\n global fin\n fin = num\n nnum = num\n base = base2\n if count == 1:\n nnum = sum(milst) + sum(mdlst)\n Ipart = int(nnum)\n Dpart = Decimal(nnum - Ipart)\n strDpart =... | [
3,
5,
6,
7,
8
] |
import sys, os
def carp():
sys.stderr = sys.stdin
print "content-type: text/plain"
print
#carp()
import sesspool
import cornerhost.config
## set up session
pool = sesspool.SessPool("sess/sessions.db")
SESS = sesspool.Sess(pool, REQ, RES)
SESS.start()
ENG.do_on_exit(SESS.stop)
CLERK = cornerhost.config... | normal | {
"blob_id": "adae1d7cc2a866c9bc3cd21cb54a0191389f8083",
"index": 3914,
"step-1": "import sys, os\ndef carp():\n sys.stderr = sys.stdin\n print \"content-type: text/plain\"\n print \n#carp()\n\nimport sesspool\nimport cornerhost.config\n\n\n## set up session\npool = sesspool.SessPool(\"sess/sessions.db\"... | [
0
] |
import json
from tqdm import tqdm
from topic.topic import get_topic_scores, get_topic_similarity
user_weights = json.load(open('data/selected_user_weights.json', 'r', encoding='utf8'))
reviews = json.load(open('data/business_reviews_test.json', 'r', encoding='utf8'))
for business, business_reviews in reviews.items(... | normal | {
"blob_id": "be90447eb7c717ae0bae28fd7f10238be733648d",
"index": 3617,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor business, business_reviews in reviews.items():\n for target_user in user_weights:\n if target_user in business_reviews:\n target_stars = business_reviews[target_u... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
data.drop_duplicates(subset='ip', inplace=True, keep='first')
data.reset_index(drop=True, inplace=True)
<|reserved_special_token_0|>
cols.extend(sites)
<|reserved_special_token_0|>
attributes.set_index('userID', inplace=True)
for ... | flexible | {
"blob_id": "3b61d389eda85ddb4c96f93c977a33b91da579ce",
"index": 7900,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndata.drop_duplicates(subset='ip', inplace=True, keep='first')\ndata.reset_index(drop=True, inplace=True)\n<mask token>\ncols.extend(sites)\n<mask token>\nattributes.set_index('userID', in... | [
0,
1,
2,
3,
4
] |
from app import app
from flask import request
@app.route('/')
@app.route('/index')
def index():
return 'Hello world'
@app.route('/api_post', methods=['POST'])
def postJsonHandler():
print(request.is_json)
content = request.get_json()
print(content)
return 'JSON posted'
| normal | {
"blob_id": "9d8c4bf9f9279d5e30d0e9742cdd31713e5f4b9e",
"index": 2104,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@app.route('/')\n@app.route('/index')\ndef index():\n return 'Hello world'\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\n@app.route('/')\n@app.route('/index')\ndef index():\... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
import sys
def solve(n, k):
wrap = 2 ** n
snaps_that_matter = k % wrap
return snaps_that_matter == wrap - 1
def main():
lines = sys.stdin.readlines()
T = int(lines[0])
for i, line in enumerate(lines[1:]):
N, K = line.split(' ')
on = solve(int(N), int... | normal | {
"blob_id": "1803f634c8e833f4a92ae35bcfafb04dfd1d2305",
"index": 7661,
"step-1": "#!/usr/bin/env python\n\nimport sys\n\ndef solve(n, k):\n wrap = 2 ** n\n snaps_that_matter = k % wrap\n return snaps_that_matter == wrap - 1\n\ndef main():\n lines = sys.stdin.readlines()\n T = int(lines[0])\n \n... | [
0
] |
<|reserved_special_token_0|>
@app.route('/login', methods=['POST'])
def login() ->dict:
db_connection = db.get_connection()
db_cursor = db_connection.cursor(named_tuple=True)
data: dict = request.get_json()
query: str = (
'select DocenteDNI, Nombre, Apellido, Usuario from Docente where Usuario... | flexible | {
"blob_id": "ff6b7e2097d78b013f8f5989adee47156579cb9e",
"index": 6226,
"step-1": "<mask token>\n\n\n@app.route('/login', methods=['POST'])\ndef login() ->dict:\n db_connection = db.get_connection()\n db_cursor = db_connection.cursor(named_tuple=True)\n data: dict = request.get_json()\n query: str = (... | [
10,
11,
12,
14,
16
] |
from vkaudiotoken import get_vk_official_token
import requests
import json
import telebot
import urllib
import sys
#check start args
try:
if len(sys.argv) != 4:
raise Exception
botApiKey = sys.argv[1]
login = sys.argv[2]
password = sys.argv[3]
except:
print('Not enough arguments')
pr... | normal | {
"blob_id": "47817d6cf58ac54e501ed24ae3ababc821bdd5c8",
"index": 1949,
"step-1": "<mask token>\n\n\ndef getTracks(result):\n data = json.loads(result.content.decode('utf-8'))\n tracks = data['response']['items']\n tracks.reverse()\n return tracks\n\n\ndef getMp3FromM3u8(url):\n if url.find('index.... | [
3,
4,
5,
6,
7
] |
"""
This program takes information about students and their coursework and calculates their final grades based on the weight of each course factor
"""
def read_file(string_object):
""" Opens and reads through a file, returning none if it isnt found """
try:
return open(string_object,"r")
except Fil... | normal | {
"blob_id": "d8af8e36bd00fbfc966ef1c4dd0c6385cbb019ee",
"index": 2064,
"step-1": "<mask token>\n\n\ndef read_file(string_object):\n \"\"\" Opens and reads through a file, returning none if it isnt found \"\"\"\n try:\n return open(string_object, 'r')\n except FileNotFoundError:\n return No... | [
4,
5,
6,
8,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def load(indices, category='train'):
if category == 'train':
if max(indices) < len(X_train) and max(indices) < len(y_train):
return X_train[indices], y_train[indices]
else:
l = np.arra... | flexible | {
"blob_id": "8c364a518ab615803ea99520e90ee1dd24d37a8c",
"index": 2524,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef load(indices, category='train'):\n if category == 'train':\n if max(indices) < len(X_train) and max(indices) < len(y_train):\n return X_train[indices], y_trai... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
{'variables': {'chromium_code': 1}, 'includes': ['ots-common.gypi'],
'targets': [{'target_name': 'ots', 'type': '<(library)', 'sources': [
'<@(ots_sources)'], 'include_dirs': ['<@(ots_include_dirs)'],
'direct_dependent_settings': {'include_dirs': ... | flexible | {
"blob_id": "7413d4e98f79bf7b389a6305257833293714fc81",
"index": 1786,
"step-1": "<mask token>\n",
"step-2": "{'variables': {'chromium_code': 1}, 'includes': ['ots-common.gypi'],\n 'targets': [{'target_name': 'ots', 'type': '<(library)', 'sources': [\n '<@(ots_sources)'], 'include_dirs': ['<@(ots_include... | [
0,
1,
2
] |
from django.urls import path
from player.views import (
MusicListView, MusicPlayView, MusicPauseView, MusicUnPauseView,
NextSongView, PreviousSongView
)
urlpatterns = [
path('list/', MusicListView, name="music_list"),
path('play/<str:name>/', MusicPlayView, name="play_music"),
path('pause/', Music... | normal | {
"blob_id": "f23b002ec0eefa376890e255b1ac0137e3a1c989",
"index": 5338,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('list/', MusicListView, name='music_list'), path(\n 'play/<str:name>/', MusicPlayView, name='play_music'), path('pause/',\n MusicPauseView, name='pause_music'), ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
from viewController import *
from navigationController import *
from noticer import *
from Images import *
from fancyButton import *
from constants import *
from textObject import *
from UIButton import *
from UIView import *
from UIAlertView import *
<|res... | flexible | {
"blob_id": "7168a8eb401478aa26ee9033262bb5c8fe33f186",
"index": 7011,
"step-1": "<mask token>\n",
"step-2": "from viewController import *\nfrom navigationController import *\nfrom noticer import *\nfrom Images import *\nfrom fancyButton import *\nfrom constants import *\nfrom textObject import *\nfrom UIButto... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@login_required
def todo(request):
eartag_list = Animal.objects.filter(MouseID__isnull=True, Alive=True
).order_by('Strain', 'Background', 'Rack', 'Cage')
genotype_list = Animal.objects.filter(Genotype='N.D.', Al... | flexible | {
"blob_id": "89518f43934710ef2e7471a91128e20d2306d6f6",
"index": 9291,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@login_required\ndef todo(request):\n eartag_list = Animal.objects.filter(MouseID__isnull=True, Alive=True\n ).order_by('Strain', 'Background', 'Rack', 'Cage')\n genotype... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def pig_it(text):
return ' '.join(letter if letter == '!' or letter == '?' else letter[1:
] + letter[0] + 'ay' for letter in text.split(' '))
<|reserved_special_token_1|>
#Simple Pig Latin
def pig_it(text):
return " ".join( letter if letter... | flexible | {
"blob_id": "25641b3a9919db1f172fca22acf413062505de1b",
"index": 6894,
"step-1": "<mask token>\n",
"step-2": "def pig_it(text):\n return ' '.join(letter if letter == '!' or letter == '?' else letter[1:\n ] + letter[0] + 'ay' for letter in text.split(' '))\n",
"step-3": "#Simple Pig Latin\ndef pig_i... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class BaseDBMgr:
def get_page(self, cls_: BaseMixin, filters: set, orders: Orders=list(),
field: tuple=(), page: int=1, per_page: int=10) ->dict:
"""获取分页数据
@param BaseMixin cls 数据库模型实体类
@param set filters 查询条件
@param str order 排序
@param... | flexible | {
"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
] |
import pytest
from django_swagger_utils.drf_server.exceptions import NotFound
from unittest.mock import create_autospec
from content_management_portal.constants.enums import TextType
from content_management_portal.interactors.storages.storage_interface \
import StorageInterface
from content_management_portal.inter... | normal | {
"blob_id": "1c66ccb80383feeee96b3fb492ff63be1a67a796",
"index": 5496,
"step-1": "<mask token>\n\n\nclass TestQuestionInteractor:\n\n def test_question_create(self, questiondto):\n user_id = 1\n short_title = 'hello'\n content_type = 'HTML'\n content = 'hi'\n storage = creat... | [
2,
3,
4,
5,
6
] |
# difference between size an shape of an image
import cv2
img = cv2.imread('police.jpg')
print img.size # byte size; slightly larger than the file size
print img.shape # y,x or rows, cols
cv2.imshow("My Picture", img)
cv2.waitKey(0)
cv2.destroyAllWindows() | normal | {
"blob_id": "ba42c6af53329035f7ab72f3f1ac87cd90d9dc7f",
"index": 9408,
"step-1": "# difference between size an shape of an image\r\n\r\nimport cv2\r\n\r\nimg = cv2.imread('police.jpg')\r\nprint img.size # byte size; slightly larger than the file size\r\nprint img.shape # y,x or rows, cols\r\n\r\ncv2.imshow(\... | [
0
] |
#!/usr/bin/env python
__author__ = 'greghines'
import numpy as np
import matplotlib.pyplot as plt
import csv
import sys
import os
import pymongo
import matplotlib.cbook as cbook
import cPickle as pickle
sys.path.append("/home/greg/github/pyIBCC/python")
import ibcc
client = pymongo.MongoClient()
db = client['condor... | normal | {
"blob_id": "c025fccad9d37dff4db3a10455cbe7d92917d8f6",
"index": 6341,
"step-1": "#!/usr/bin/env python\n__author__ = 'greghines'\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport csv\nimport sys\nimport os\nimport pymongo\nimport matplotlib.cbook as cbook\nimport cPickle as pickle\n\nsys.path.append(... | [
0
] |
<|reserved_special_token_0|>
class Comment(models.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def __str__(self):
return self.user.username
class Comment_to_comment(models.Model):
user = models.ForeignKey... | flexible | {
"blob_id": "1257b90781a213ca8e07f67a33b8e847d0525653",
"index": 9354,
"step-1": "<mask token>\n\n\nclass Comment(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.user.username\n\n\nclass Comment_to_comment(models.Model):\n u... | [
7,
10,
11,
12,
13
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def nqueen(depth, n, history):
global cnt
if depth == n:
cnt += 1
else:
for i in range(n):
if i not in history:
for index, value in enumerate(history):
... | flexible | {
"blob_id": "b35686f7feec2c4a905007f3c105b6fa05b87297",
"index": 5365,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef nqueen(depth, n, history):\n global cnt\n if depth == n:\n cnt += 1\n else:\n for i in range(n):\n if i not in history:\n for inde... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def get_user_by_id(id):
if id is None:
return
user = User.query.filter(User.alias_id == id).first()
return user
<|reserved_special_token_0|>
def update_user(first_name, last_name):
user = flask_login.current_user
user.first_name = first_name
user.last_n... | flexible | {
"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
] |
<|reserved_special_token_0|>
class Service(InstanceSet):
<|reserved_special_token_0|>
def __str__(self):
return self.name
def __iter__(self):
return six.itervalues(self.instances)
def __len__(self):
return len(self.instances)
<|reserved_special_token_0|>
def identit... | flexible | {
"blob_id": "ba41f2a564f46032dbf72f7d17b2ea6deaa81b10",
"index": 4332,
"step-1": "<mask token>\n\n\nclass Service(InstanceSet):\n <mask token>\n\n def __str__(self):\n return self.name\n\n def __iter__(self):\n return six.itervalues(self.instances)\n\n def __len__(self):\n return... | [
12,
18,
20,
22,
26
] |
<|reserved_special_token_0|>
def tarjan():
timer = time.time
start = timer()
voldemortResult = authorStore.get('_authors')
allAuthors = voldemortResult[0][0]
nodes = {}
for author in allAuthors.get('content'):
nodeKey = str(author)
nodeValue = [authorStore.get(nodeKey)[0][0], -... | flexible | {
"blob_id": "bb2c684fd5b962c97c033d4b4c2027d52b7371fd",
"index": 499,
"step-1": "<mask token>\n\n\ndef tarjan():\n timer = time.time\n start = timer()\n voldemortResult = authorStore.get('_authors')\n allAuthors = voldemortResult[0][0]\n nodes = {}\n for author in allAuthors.get('content'):\n ... | [
2,
3,
4,
5,
6
] |
"""
Common, pure functions used by the D-BAS.
.. codeauthor:: Tobias Krauthoff <krauthoff@cs.uni-duesseldorf.de
"""
import hashlib
import locale
import os
import re
import warnings
from collections import defaultdict
from datetime import datetime
from enum import Enum, auto
from html import escape, unescape
from typi... | normal | {
"blob_id": "10a9437453371bd7472e93af1026c778b7983cf8",
"index": 1137,
"step-1": "<mask token>\n\n\nclass BubbleTypes(Enum):\n USER = auto()\n SYSTEM = auto()\n STATUS = auto()\n INFO = auto()\n\n def __str__(self):\n return str(self.value)\n\n\nclass Relations(Enum):\n UNDERMINE = 'unde... | [
29,
31,
47,
55,
60
] |
<|reserved_special_token_0|>
class IsingModel:
def __init__(self, image, J, rate, sigma):
self.width = image.shape[0]
self.height = image.shape[1]
self._J = J
self._rate = rate
self._sigma = sigma
self.image, self.logodds = self.presenting_image(image)
<|reserv... | flexible | {
"blob_id": "6aa74826f9ca0803fa8c1d5af1d4cec4980e2ce6",
"index": 9064,
"step-1": "<mask token>\n\n\nclass IsingModel:\n\n def __init__(self, image, J, rate, sigma):\n self.width = image.shape[0]\n self.height = image.shape[1]\n self._J = J\n self._rate = rate\n self._sigma =... | [
4,
5,
6,
7,
10
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution(object):
def minCostClimbingStairs(self, cost):
"""
:type cost: List[int]
:rtype: int
"... | flexible | {
"blob_id": "38363316cc9a8419a528bb78b9ad03682e24172d",
"index": 9823,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n\n\n<mask token>\n",
"step-3": "class Solution(object):\n\n def minCostClimbingStairs(self, cost):\n \"\"\"\n :type cost: List[int]\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class StatusParser:
def __init__(self):
self.board = np.memmap('../tmp/board', mode='r', dtype=np.int8,
shape=(20, 10))
self.combo = np.memmap('../tmp/combo', mode='r', dtype=np.int32,
shape=(1,))
self.lines = np.memmap('../tmp/lines', ... | flexible | {
"blob_id": "3668e8009dca4ea261bdfbd325331c338fdac5a9",
"index": 627,
"step-1": "<mask token>\n\n\nclass StatusParser:\n\n def __init__(self):\n self.board = np.memmap('../tmp/board', mode='r', dtype=np.int8,\n shape=(20, 10))\n self.combo = np.memmap('../tmp/combo', mode='r', dtype=n... | [
11,
12,
13,
15,
17
] |
FILE = "Luke"
NAME = "Luke Walker"
NATIONALITY = "American"
CLASS = "Manipulator"
WEAPON = ""
BIRTH = ""
BIRTH_LOCATION = ""
LETTER = "W"
RECRUITMENT_ORDER = 10
SUMMARY = ""
ABILITIES = ""
BACKSTORY = ""
HIGHLIGHTS = ""
SUMMONS = ("Tonberry", "Grimnir", "Griever", "Starlet")
| normal | {
"blob_id": "fa3ab879541c04e278317b11dd79e6e1b4319536",
"index": 7586,
"step-1": "<mask token>\n",
"step-2": "FILE = 'Luke'\nNAME = 'Luke Walker'\nNATIONALITY = 'American'\nCLASS = 'Manipulator'\nWEAPON = ''\nBIRTH = ''\nBIRTH_LOCATION = ''\nLETTER = 'W'\nRECRUITMENT_ORDER = 10\nSUMMARY = ''\nABILITIES = ''\nB... | [
0,
1,
2
] |
from rest_framework import generics
from animals.models import Location
from animals.serializers import LocationSerializer
class LocationList(generics.ListCreateAPIView):
queryset = Location.objects.all()
serializer_class = LocationSerializer
name = 'location-list'
class LocationDetail(generics.Retrieve... | normal | {
"blob_id": "245e407c9e92b3ac34389a48fcef4fc1b349ea18",
"index": 8252,
"step-1": "<mask token>\n\n\nclass LocationDetail(generics.RetrieveUpdateDestroyAPIView):\n queryset = Location.objects.all()\n serializer_class = LocationSerializer\n name = 'location'\n",
"step-2": "<mask token>\n\n\nclass Locati... | [
2,
3,
4,
5
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.