code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import re
_camel_words = re.compile(r"([A-Z][a-z0-9_]+)")
def _camel_to_snake(s):
""" Convert CamelCase to snake_case.
"""
return "_".join(
[
i.lower() for i in _camel_words.split(s)[1::2]
]
)
| normal | {
"blob_id": "6c9f9363a95ea7dc97ccb45d0922f0531c5cfec9",
"index": 6572,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef _camel_to_snake(s):\n \"\"\" Convert CamelCase to snake_case.\n \"\"\"\n return '_'.join([i.lower() for i in _camel_words.split(s)[1::2]])\n",
"step-3": "<mask token>\n... | [
0,
1,
2,
3,
4
] |
#anand python problem 2:29
#Write a function array to create an 2-dimensional array. The function should take both dimensions as arguments. Value of each element can be initialized to None:
#
def array_imp(row,col):
res=[[None]*col for i in range(row) ]
return res
if __name__=='__main__':
outs=array_imp(2,3)
p... | normal | {
"blob_id": "b5835b676eb8ac814086f7482f172f48e2ad5a0a",
"index": 8189,
"step-1": "#anand python problem 2:29\n#Write a function array to create an 2-dimensional array. The function should take both dimensions as arguments. Value of each element can be initialized to None:\n#\n\ndef array_imp(row,col):\n\tres=[[N... | [
0
] |
# Generated by Django 2.1.4 on 2019-01-11 11:58
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('devisa', '0021_auto_20190110_1256'),
]
operations = [
migrations.RemoveField(
model_name='entidade',
name='bairro',
... | normal | {
"blob_id": "34f79fa3de68b53f19220697815e5bae5270d056",
"index": 9274,
"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 = [('devisa', '0... | [
0,
1,
2,
3,
4
] |
def is_balanced(tree_root):
# Determine if the tree is superbalanced
if tree_root is None:
return True
nodeQ = [(tree_root, 0)]
depths = []
while len(nodeQ):
last_node, depth = nodeQ.pop()
if( not last_node.left ) and (not last_node.right ):
... | normal | {
"blob_id": "833c8234d829dfa1937392f0ad4952aeffa4e26d",
"index": 1150,
"step-1": "<mask token>\n",
"step-2": "def is_balanced(tree_root):\n if tree_root is None:\n return True\n nodeQ = [(tree_root, 0)]\n depths = []\n while len(nodeQ):\n last_node, depth = nodeQ.pop()\n if not... | [
0,
1,
2
] |
a = [5, 4, 3, 2, 1]
a = [1, 2, 3, 7, 5, 6, 4, 8, 9]
import time
sorted = True
for i in range(0, len(a)):
print('main')
sorted = True
for j in range(1, len(a) - i):
if a[j] < a[j - 1]:
a[j], a[j - 1] = a[j - 1], a[j]
print('inner')
print(a)
time.sleep(1... | normal | {
"blob_id": "30fbe52a5e3fb184a998fce43d716cffdaf0d2dc",
"index": 1790,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(0, len(a)):\n print('main')\n sorted = True\n for j in range(1, len(a) - i):\n if a[j] < a[j - 1]:\n a[j], a[j - 1] = a[j - 1], a[j]\n ... | [
0,
1,
2,
3
] |
import numpy as np
import cv2
from matplotlib import pyplot as plt
from matplotlib import cm
import imageio
# # Backpack values
# fx = 7190.247 # lense focal length
# baseline = 174.945 # distance in mm between the two cameras (values from middlebury)
# units = 0.001 # depth units... | normal | {
"blob_id": "14761cc2593556f58a7dc4e499db71456d7c7048",
"index": 3237,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nplt.imshow(imgL, cmap='gray')\nplt.axis('off')\nplt.show()\n<mask token>\nprint(disparity)\nplt.imshow(disparity)\nplt.axis('off')\nplt.show()\n<mask token>\nplt.imshow(depth)\nplt.show()... | [
0,
1,
2,
3,
4
] |
# This is a sample Python script.
# Press ⌃R to execute it or replace it with your code.
# Press Double ⇧ to search everywhere for classes, files, tool windows, actions, and settings.
import weather_forecast
from weather_forecast import forecast
from googlesearch import search
from youtube_search import YoutubeSearch... | normal | {
"blob_id": "60354f25f55136d4e873d118cfe048cf08c06e39",
"index": 1587,
"step-1": "<mask token>\n\n\ndef game():\n for i in range(1000):\n request = input('Auto-Bot at your service. Please state your request. '\n )\n if request == 'google':\n query = input('Search: ')\n ... | [
1,
2,
3,
4,
5
] |
#Las listas son similares a las tuplas
# con la diferencia de que permiten modificar los datos una vez creados
miLista = ['cadena', 21, 2.8, 'nuevo dato', 25]
print (miLista)
miLista[2] = 3.8 #el tercer elemento ahora es 3.8
print(miLista)
miLista.append('NuevoDato')
print(miLista)
| normal | {
"blob_id": "27ec06d084bf819383801be0351c04e7d1fc1752",
"index": 5176,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(miLista)\n<mask token>\nprint(miLista)\nmiLista.append('NuevoDato')\nprint(miLista)\n",
"step-3": "miLista = ['cadena', 21, 2.8, 'nuevo dato', 25]\nprint(miLista)\nmiLista[2] = 3.... | [
0,
1,
2,
3
] |
# Uses python3
import sys
from operator import attrgetter
from collections import namedtuple
Segment = namedtuple('Segment', 'start end')
def optimal_points(segments):
segments = sorted(segments, key=attrgetter('end'), reverse=True)
points = []
#write your code here
while len(segments) > 0:
... | normal | {
"blob_id": "c007dc2416d3f7c883c44dea5471927ea6f816d6",
"index": 3973,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef optimal_points(segments):\n segments = sorted(segments, key=attrgetter('end'), reverse=True)\n points = []\n while len(segments) > 0:\n segement = segments.pop()\n... | [
0,
2,
3,
4,
5
] |
import graphene
import f1hub.drivers.schema
import f1hub.results.schema
import f1hub.constructors.schema
import f1hub.races.schema
import f1hub.status.schema
import f1hub.circuits.schema
import f1hub.constructorresults.schema
import f1hub.constructorstandings.schema
import f1hub.driverstandings.schema
import f1hub.lap... | normal | {
"blob_id": "05e4bcc7323b908a7b45d766ada463ce172e25c4",
"index": 378,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Query(f1hub.drivers.schema.Query, f1hub.results.schema.Query, f1hub.\n constructors.schema.Query, f1hub.races.schema.Query, f1hub.status.\n schema.Query, f1hub.circuits.sch... | [
0,
1,
2,
3,
4
] |
from turtle import *
import time
import random
colormode(255)
class Ball(Turtle):
def __init__(self, x,y,dx,dy,r):
Turtle.__init__(self)
self.pu()
self.goto(x,y)
self.dx = dx
self.dy = dy
self.r = r
self.shape("circle")
self.shapesize(r/10)
r ... | normal | {
"blob_id": "17cd6746e58a7f33bc239c1420d51c6810ed02d8",
"index": 3575,
"step-1": "<mask token>\n\n\nclass Ball(Turtle):\n\n def __init__(self, x, y, dx, dy, r):\n Turtle.__init__(self)\n self.pu()\n self.goto(x, y)\n self.dx = dx\n self.dy = dy\n self.r = r\n s... | [
4,
5,
6,
7,
8
] |
'''
Given []int, most mostCompetitive subsequence is
a sublist of nums.
So we calculate a score, score is ∀ x ∈ nums, score += x_n - x_n-1
You can remove as many elements are you need to.
What is the mostCompetitive subsequence that you can come up with?
[1,3,5]
[1,3,4] ← More competitive
[1,2,5] ← More competiti... | normal | {
"blob_id": "f8b04f374e1c55d4985be793939f0ff9393c29e0",
"index": 2571,
"step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n def refined(self, nums, i, a, ans):\n if i >= len(nums):\n if len(a) == len(ans) and self.isMoreCompetitive(a, ans) == False:\n return Fals... | [
2,
3,
4,
5,
6
] |
import os
import torch
from collections import OrderedDict
from PIL import Image
import numpy as np
from matplotlib import pyplot as plt
from matplotlib import image as mplimg
from torch.nn.functional import upsample
import networks.deeplab_resnet as resnet
from mypath import Path
from dataloaders import helpers as h... | normal | {
"blob_id": "2c8b8e9767ac8400fb6390e0851d9df10df7cd8c",
"index": 8729,
"step-1": "<mask token>\n\n\ndef maskRCNN_model():\n config_file = (\n '/home/raj/data/Raj/IndividualProject/maskRCNN/configs/caffe2/e2e_mask_rcnn_R_50_FPN_1x_caffe2.yaml'\n )\n cfg.merge_from_file(config_file)\n cfg.me... | [
4,
5,
6,
7,
8
] |
# Generated by Django 3.1.6 on 2021-02-15 12:13
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Book',
fields=[
... | normal | {
"blob_id": "6239cb08509b8e84a88db95479af05845876d9b6",
"index": 1502,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T... | [
0,
1,
2,
3,
4
] |
# _*_ coding:utf-8 _*_
from __future__ import unicode_literals
from django.db import models
from django.core.urlresolvers import reverse
# Create your models here.
# 本文件中,用__unicode__代替了__str__,以免在admin界面中显示中文而引发错误。
# 参考:http://blog.csdn.net/jiangnanandi/article/details/3574007
# 或者另一个解决方案:http://blog.sina.com.cn/s... | normal | {
"blob_id": "49b007b723b9c43fb79d5dffa2546c856faf4937",
"index": 8625,
"step-1": "<mask token>\n\n\nclass SonMenu(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name = u'二级菜单'\n verbose_name_plural = u'二级菜单'\n <mask token>\n\n\nclass Img(model... | [
7,
8,
10,
11,
14
] |
import csv
import json
import re
import itertools
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
from networkx.algorithms import community
import snap
import numpy
# setting up data structures to map actor IDs to objects in order to increase run time.
csv.field_size_limit(100000000)
curr_act... | normal | {
"blob_id": "0934163fc6461e30a73c06e74b3a5e983ed2fa02",
"index": 4211,
"step-1": "<mask token>\n\n\nclass Movie:\n\n def __init__(self, id: int):\n self.actors = set()\n self.name = ''\n self.id = id\n self.year = 0\n\n def getName(self):\n return self.name\n\n def get... | [
7,
11,
17,
22,
26
] |
import unittest
import sys
from tests.jep_pipe import jep_pipe
from tests.jep_pipe import build_java_process_cmd
import jep
@unittest.skipIf(sys.platform.startswith("win"), "subprocess complications on Windows")
class TestSharedModules(unittest.TestCase):
def setUp(self):
pass
def test_shared_module... | normal | {
"blob_id": "39bc90f34cccebe9a8b1475e396caa1c14f6b2df",
"index": 9004,
"step-1": "<mask token>\n\n\n@unittest.skipIf(sys.platform.startswith('win'),\n 'subprocess complications on Windows')\nclass TestSharedModules(unittest.TestCase):\n\n def setUp(self):\n pass\n\n def test_shared_modules(self):... | [
3,
4,
5,
6,
7
] |
"""
This module provides functions to make WCSAxes work in SunPy.
"""
import matplotlib.pyplot as plt
from packaging.version import Version
import astropy.units as u
from astropy import __version__ as astropy_version
from astropy.visualization import wcsaxes
from sunpy.coordinates import HeliographicCarrington, Helio... | normal | {
"blob_id": "be1ef0aa3868985bf198781ee827bd447588df15",
"index": 606,
"step-1": "<mask token>\n\n\ndef is_wcsaxes(axes):\n \"\"\"\n Tests a `matplotlib.axes.Axes` object to see if it is an instance of\n `~astropy.visualization.wcsaxes.WCSAxes`.\n\n Parameters\n ----------\n axes : `matplotlib.a... | [
4,
5,
6,
7,
8
] |
#!/usr/bin/python
import xml.dom.minidom
import os
import matplotlib.pyplot as plt
import cPickle as p
import numpy as np
def modifyXML(name,numCar):
DOMTree = xml.dom.minidom.parse(name)
objects=DOMTree.getElementsByTagName('object')
for object in objects:
if object.getElementsByTagName('name')[0].childNodes[0].... | normal | {
"blob_id": "1c13a9ca3617dc6f1a1f1aa8249cce37062a449b",
"index": 8243,
"step-1": "#!/usr/bin/python\nimport xml.dom.minidom\nimport os\nimport matplotlib.pyplot as plt\nimport cPickle as p\nimport numpy as np\n\ndef modifyXML(name,numCar):\n\tDOMTree = xml.dom.minidom.parse(name)\n\tobjects=DOMTree.getElementsBy... | [
0
] |
import os
import json
import requests
from fin import myBuilder, myParser
import time
def open_config():
if os.path.isfile('fin/config.json') != True:
return ('no config found')
else:
print('config found')
with open('fin/config.json') as conf:
conf = json.load(conf)
return conf
conf = open_config()
logf... | normal | {
"blob_id": "e690587c9b056f8d5a1be6dd062a2aa32e215f50",
"index": 2328,
"step-1": "<mask token>\n\n\ndef open_config():\n if os.path.isfile('fin/config.json') != True:\n return 'no config found'\n else:\n print('config found')\n with open('fin/config.json') as conf:\n conf = json.loa... | [
3,
6,
7,
9,
11
] |
from __future__ import unicode_literals
from functools import partial
from django.contrib.auth import get_user_model
from .default_settings import settings
from . import signals
class AuditMiddleware(object):
"""
middleware to add the user from requests to ModelChange objects.
This is independent of req... | normal | {
"blob_id": "0e03a3b3401075384e580bc2bb8af1a106f1d238",
"index": 2141,
"step-1": "<mask token>\n\n\nclass AuditMiddleware(object):\n <mask token>\n <mask token>\n\n def process_response(self, request, response):\n signals.audit_presave.disconnect(dispatch_uid=(settings.\n DISPATCH_UID,... | [
2,
4,
5,
6,
7
] |
# Created by Yuexiong Ding
# Date: 2018/9/4
# Description:
| normal | {
"blob_id": "ddb139fa3fbfa1218459e3865150465a44a03bea",
"index": 6306,
"step-1": "# Created by Yuexiong Ding\n# Date: 2018/9/4\n# Description: \n\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
1
]
} | [
1
] |
'''
Created on May 17, 2016
@author: Shauryadeep Chaudhuri
'''
import json
import tornado
from engine import Constants as c
from engine.ResultGenerator import ResultGenerator
from ..ServerLogger import ServerLogger
class GetFromURL(tornado.web.RequestHandler):
'''
This class fetches the d... | normal | {
"blob_id": "5a13c7e3be8a0b5f3baf7106a938fc97f078c5bc",
"index": 7335,
"step-1": "<mask token>\n\n\nclass GetFromURL(tornado.web.RequestHandler):\n <mask token>\n <mask token>\n\n def get(self, index=None, schema=None, entry=None, query=None):\n query = dict()\n resultGenerator = ResultGen... | [
2,
3,
4,
5,
6
] |
import os
import csv
from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
from django.core.exceptions import ObjectDoesNotExist
from aec.apps.vocabulary.serializers import DictionarySerializer
from aec.apps.vocabulary.models import Word
from aec.apps.library.serializers i... | normal | {
"blob_id": "7d4d5ca14c3e1479059f77c6a7f8dcfad599443b",
"index": 4729,
"step-1": "import os\nimport csv\n\nfrom django.core.management.base import BaseCommand, CommandError\nfrom django.conf import settings\nfrom django.core.exceptions import ObjectDoesNotExist\n\nfrom aec.apps.vocabulary.serializers import Dict... | [
0
] |
import numpy,math,random
from scipy.io.wavfile import write
notes=[('c',32.7),('c#',34.65),('d',36.71),('d#',38.89),('e',41.2),('f',43.65),
('f#',46.25),('g',49),('g#',51.91),('a',55),('a#',58.27),('b',61.47)]
#notes={'c':32.7,'c#':34.65,'d':36.71,'d#':38.89,'e':41.2,'f':43.65,'f#':46.25,
# 'g':49,'g#':51.91,'a... | normal | {
"blob_id": "2ad1b44027b72499c1961f2d2b1c12c356c63d2b",
"index": 5350,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef make_wave(freq, time=1, amp=1, phase=0, samplerate=44100, bitspersample=16\n ):\n bytelist = []\n TwoPiDivSamplerate = 2 * math.pi / samplerate\n increment = TwoPiDivS... | [
0,
2,
3,
4,
5
] |
from multiprocessing import Process, Pipe
from time import sleep
from os import getpid
def ponger(pipe, response):
while True:
msg = pipe.recv()
print(f"{getpid()} receiving: {msg}")
sleep(1)
pipe.send(response)
if __name__ == '__main__':
ping_conn, pong_conn = Pipe()
Pr... | normal | {
"blob_id": "aac9960dafc9e8d3a5670251fcc54eb8e34d4458",
"index": 9282,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef ponger(pipe, response):\n while True:\n msg = pipe.recv()\n print(f'{getpid()} receiving: {msg}')\n sleep(1)\n pipe.send(response)\n\n\n<mask token>... | [
0,
1,
2,
3,
4
] |
from . import utils
from . import objects
START = (0, 0)
STARTING_LIFE = 10
WHITE = (255, 255, 255)
class RoughLightGame:
def __init__(self, game_map, width, height, **kwargs):
self.map = game_map
self.width = width
self.height = height
self.objects = kwargs.get('objects', list... | normal | {
"blob_id": "5f089c3e67452fe6d14f96a70d792bc0d056b375",
"index": 9227,
"step-1": "<mask token>\n\n\nclass RoughLightGame:\n\n def __init__(self, game_map, width, height, **kwargs):\n self.map = game_map\n self.width = width\n self.height = height\n self.objects = kwargs.get('object... | [
4,
5,
6,
8,
10
] |
import easyocr
import cv2
import json
import numpy as np
import os
import os.path
import glob
def convert(o):
if isinstance(o, np.generic): return o.item()
raise TypeError
readers = [
easyocr.Reader(['la', 'en', 'de', 'fr', 'es', 'cs', 'is'], gpu = False),
#easyocr.Reader(['ch_tra'], g... | normal | {
"blob_id": "7057b882ca1ce2c08e9ba7add5f115636b9b319e",
"index": 8745,
"step-1": "<mask token>\n\n\ndef convert(o):\n if isinstance(o, np.generic):\n return o.item()\n raise TypeError\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef convert(o):\n if isinstance(o, np.generic):\n ret... | [
1,
2,
3,
4,
5
] |
from utils import *
import math
class State:
"This class represents the search state that will be used for ARA* search"
def __init__(self, x, y, theta, parent=None, parent_action=None, g=float('inf'), h=float('inf')):
self.x = x
self.y = y
self.theta = theta % (2*math.pi)
self.g... | normal | {
"blob_id": "c8f899958ce19e7e2bf1307a685e65873695f140",
"index": 9028,
"step-1": "<mask token>\n\n\nclass State:\n <mask token>\n\n def __init__(self, x, y, theta, parent=None, parent_action=None, g=\n float('inf'), h=float('inf')):\n self.x = x\n self.y = y\n self.theta = theta... | [
8,
9,
10,
11,
12
] |
import sys
sys.path.append('/usr/local/anaconda3/lib/python3.6/site-packages')
from numpy import sin, linspace
x = linspace(0, 4, 101)
y = sin(x)
from numpy import sin, linspace
plt.grid()
plt.xlabel('x')
plt.ylabel('f(x)')
plt.title('Funkcija $sin(x)$ un tās izvitzījums rindā')
plt.plot(x, y2)
plt.plot(x, y2, color ... | normal | {
"blob_id": "1dcea61908753777604d99235407981e89c3b9d4",
"index": 4452,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.append('/usr/local/anaconda3/lib/python3.6/site-packages')\n<mask token>\nplt.grid()\nplt.xlabel('x')\nplt.ylabel('f(x)')\nplt.title('Funkcija $sin(x)$ un tās izvitzījums rindā')... | [
0,
1,
2,
3,
4
] |
import os
from test.test_unicode_file_functions import filenames
def writeUniquerecords(dirpath,filenames):
sourcepath=os.path.join(dirpath,filenames)
with open(sourcepath,'r') as fp:
lines= fp.readlines()
destination_lines=[]
for line in lines:
if line not in destination_l... | normal | {
"blob_id": "4ed730369cf065936569a8515de44042829c2143",
"index": 1201,
"step-1": "<mask token>\n\n\ndef writeUniquerecords(dirpath, filenames):\n sourcepath = os.path.join(dirpath, filenames)\n with open(sourcepath, 'r') as fp:\n lines = fp.readlines()\n destination_lines = []\n for li... | [
1,
2,
3,
4,
5
] |
# -*- coding: utf-8 -*-
'''
一球从100米高度自由落下
每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?
求两个东西, 1是经过了多少米, 2是反弹多高
1: 100 100+50+50 100+50+50+25+25
2: 100 100/2=50 50/2=25 25/2=2
'''
import math
start_height = 100
rebound_rate = 0.5
meter_list = [100]
def rebound(time):
m = start_height*(r... | normal | {
"blob_id": "f25d86e857970854b2239ce0ab5280132b89280e",
"index": 6900,
"step-1": "# -*- coding: utf-8 -*-\n'''\n 一球从100米高度自由落下\n 每次落地后反跳回原高度的一半;再落下,求它在第10次落地时,共经过多少米?第10次反弹多高?\n\n 求两个东西, 1是经过了多少米, 2是反弹多高\n 1: 100 100+50+50 100+50+50+25+25\n 2: 100 100/2=50 50/2=25 25/2=2\n'''\nimport math\n\n... | [
0
] |
import MySQLdb
from MySQLdb import escape_string as thwart
"""
"""
class DatabaseConnection:
def __init__(self, address, user, password, database):
self.address = address
self.user = user
self.password = password
self.database = database
"""
"""
def connect(self):
... | normal | {
"blob_id": "c6502d6b589fa75dfbd5946a1097e77fc0b472c4",
"index": 1126,
"step-1": "<mask token>\n\n\nclass DatabaseConnection:\n <mask token>\n <mask token>\n\n def connect(self):\n self.conn = MySQLdb.connect(host=self.address, port=3306, user=self\n .user, passwd=self.password, db=sel... | [
5,
6,
7,
8,
11
] |
from manimlib.imports import *
class A_Scroller(Scene):
CONFIG={
"camera_config":{"background_color":"#FFFFFF"}
}
def construct(self):
text_1 = Text("3493", color="#DC3832")
text_2 = Text("3646", color="#221F20").shift(2*RIGHT)
text_3 = Text("4182", color="#2566AD").shift(4*RIGHT)
text_4 = Te... | normal | {
"blob_id": "97c97f18d1b93dc54538a0df7badafd961fdcb9c",
"index": 3588,
"step-1": "<mask token>\n\n\nclass A_Scroller(Scene):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass A_Scroller(Scene):\n <mask token>\n\n def construct(self):\n text_1 = Text('3493', color='#DC3832'... | [
1,
2,
3,
4,
5
] |
#coding=utf-8
i=1
s=0
while s<=8848:
s=s+(2**i)*0.2*10**(-3)
i=i+1
print '对折次数:',i
| normal | {
"blob_id": "98a384392d0839ddf12f3374c05929bc5e32987b",
"index": 9242,
"step-1": "#coding=utf-8\ni=1\ns=0\nwhile s<=8848:\n\ts=s+(2**i)*0.2*10**(-3)\n\ti=i+1\nprint '对折次数:',i\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 18 23:54:17 2015
@author: rein
@license: MIT
@version: 0.1
"""
from __future__ import print_function
import numpy as np
import footballpy.processing.ragged_array as ra
""" Ranking dictionary necessary to determine the column number
of each player.
The type ... | normal | {
"blob_id": "81ae5bbc8e3e712ee4f54656bc28f385a0b4a29f",
"index": 6059,
"step-1": "<mask token>\n\n\ndef sort_position_data(pos, type='A'):\n \"\"\"Sorts the position data according to player positions.\n\n As the final matrix should contain the player according to their\n position starting from left to ... | [
5,
8,
9,
10,
11
] |
from ryu.base import app_manager
from ryu.controller import ofp_event
from ryu.controller.handler import MAIN_DISPATCHER
from ryu.controller.handler import set_ev_cls
from ryu.ofproto import ofproto_v1_0
from ryu.lib.mac import haddr_to_bin
from ryu.lib.packet import packet
from ryu.lib.packet import ethernet
from ryu... | normal | {
"blob_id": "86d032a3cd67118eb46073c996f1c9a391f8dfe0",
"index": 1608,
"step-1": "<mask token>\n\n\nclass SimpleSwitch(app_manager.RyuApp):\n <mask token>\n <mask token>\n <mask token>\n print('PACKET_OUT...')\n",
"step-2": "<mask token>\n\n\nclass SimpleSwitch(app_manager.RyuApp):\n\n def __ini... | [
1,
3,
4,
5,
6
] |
def fibonacci(n):
'''returns the nth number of the Fibonacci
sequence. where the first position is indexed at 0.
n must be an iteger greater than or equal to 0'''
#these are the first two numbers in the sequence.
fib = [0,1]
#If the users enters a number less than 2 then just get that number fr... | normal | {
"blob_id": "ca75e23d91eef8a5c5b78c0ea7c903b80640af25",
"index": 7957,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef sum_series(n, x=0, y=1):\n \"\"\"sum_series returns the nth number of the Fibonacci, the Lucas sequence\n or the Foo sequence where the first position is indexed at 0. ... | [
0,
1,
2,
3,
4
] |
import requests
import json
import pandas as pd
from sqlalchemy import create_engine
from sqlalchemy.types import VARCHAR,INT,FLOAT,BIGINT
import time
from tqdm import tqdm
#数据库联接设置
connect_info = 'mysql+pymysql://root:rootroot@localhost:3306/db1?charset=UTF8MB4'
engine = create_engine(connect_info)
sql = '''
s... | normal | {
"blob_id": "a95e64877a1fc9f8109f1293b4ae9176f4f64647",
"index": 3090,
"step-1": "<mask token>\n\n\ndef sentiment(text):\n global url\n global headers\n body = {'text': text}\n try:\n r = requests.post(url, headers=headers, data=json.dumps(body))\n dic = r.json()\n except Exception a... | [
1,
2,
3,
4,
5
] |
from admin_tools.dashboard.modules import DashboardModule
from nodes.models import Node
from slices.models import Slice
class MyThingsDashboardModule(DashboardModule):
"""
Controller dashboard module to provide an overview to
the user of the nodes and slices of its groups.
"""
title="My Things"
... | normal | {
"blob_id": "90324392e763ac6ea78c77b909c4bea667d45e6c",
"index": 5896,
"step-1": "<mask token>\n\n\nclass MyThingsDashboardModule(DashboardModule):\n <mask token>\n <mask token>\n <mask token>\n\n def init_with_context(self, context):\n user = context['request'].user\n slices = Slice.ob... | [
2,
4,
5,
6,
7
] |
import pandas as pd
import requests
import re
from bs4 import BeautifulSoup
from datetime import datetime
nbaBoxUrl = 'https://www.basketball-reference.com/boxscores/'
boxScoreClass = 'stats_table'
def getBoxScoreLinks():
page = requests.get(nbaBoxUrl)
soup = BeautifulSoup(page.content, 'html.parser')
ga... | normal | {
"blob_id": "2b3983fd6a8b31604d6d71dfca1d5b6c2c7105e0",
"index": 4818,
"step-1": "<mask token>\n\n\ndef getBoxScoreLinks():\n page = requests.get(nbaBoxUrl)\n soup = BeautifulSoup(page.content, 'html.parser')\n gameLinks = []\n data = soup.findAll('td', {'class': 'right gamelink'})\n for div in da... | [
8,
9,
11,
12,
15
] |
# x = 10
#
# def increment():
# x += 1
#
# ^^ Non-working code
x = 10
def increment(number):
number += 1
return number
# If we want to change a global variable,
# we have to do it like this
x = increment(x) | normal | {
"blob_id": "a0460b100a750b685f3e831a19379b0e26da4b35",
"index": 7368,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef increment(number):\n number += 1\n return number\n\n\n<mask token>\n",
"step-3": "x = 10\n\n\ndef increment(number):\n number += 1\n return number\n\n\nx = increment... | [
0,
1,
2,
3
] |
from django.contrib import admin
from .models import User
# Register your models here.
@admin.register(User)
class AuthorizationUserAdmin(admin.ModelAdmin):
exclude = ['open_id']
pass
| normal | {
"blob_id": "d3585e7b761fa7b2eeaacf09f84bb6a4abc1cf02",
"index": 6806,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@admin.register(User)\nclass AuthorizationUserAdmin(admin.ModelAdmin):\n <mask token>\n pass\n",
"step-3": "<mask token>\n\n\n@admin.register(User)\nclass AuthorizationUserAdm... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# Item pipelines
import logging
import hashlib
from wsgiref.handlers import format_date_time
import time
import itertools
import psycopg2
from psycopg2.extensions import AsIs
from psycopg2.extras import Json
import requests
from scrapy import signals
from scrapy.pipelines.files import FilesPip... | normal | {
"blob_id": "d08e4c85890dab7cb421fa994ef1947d8919d58f",
"index": 8547,
"step-1": "<mask token>\n\n\nclass UpYunStore(object):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, uri):\n assert uri.startswith('upyun://')\n self.session = requests.Session()\n self.b... | [
7,
8,
11,
14,
20
] |
from mathmodule import *
import sys
print("Welcome to my basic \'Calculator\'")
print("Please choose your best option (+, -, *, /) ")
# user input part
while True:
try:
A = int(input("Now Enter your first Value="))
break
except:
print("Oops!", sys.exc_info()[0], "occurred.")
while True:
mathoparet... | normal | {
"blob_id": "1cca94040cdd8db9d98f587c62eff7c58eae7535",
"index": 6974,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(\"Welcome to my basic 'Calculator'\")\nprint('Please choose your best option (+, -, *, /) ')\nwhile True:\n try:\n A = int(input('Now Enter your first Value='))\n b... | [
0,
1,
2,
3
] |
from django.db import models
class ProdutoManager(models.Manager):
def for_categoria(self, categoria):
return self.filter(categoria=categoria)
| normal | {
"blob_id": "d698fa1b43387ee0b73687df2764c30e04ee6fd0",
"index": 2814,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ProdutoManager(models.Manager):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass ProdutoManager(models.Manager):\n\n def for_categoria(self, categoria):\n re... | [
0,
1,
2,
3
] |
print('Hi, I am Nag')
| normal | {
"blob_id": "0ca751e050244fd85c8110d02d5e7a79eb449ada",
"index": 8542,
"step-1": "<mask token>\n",
"step-2": "print('Hi, I am Nag')\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
import bpy
class TILA_Config_LogElement(bpy.types.PropertyGroup):
name: bpy.props.StringProperty(default='')
icon: bpy.props.StringProperty(default='BLANK1')
class TILA_Config_LogList(bpy.types.UIList):
bl_idname = "TILA_UL_Config_log_list"
def draw_item(self, context, layout, data, item, icon, active_data, ac... | normal | {
"blob_id": "7fa7a632078ce4f0052e3cadf11d5efd47a1fad5",
"index": 831,
"step-1": "<mask token>\n\n\nclass TILA_Config_LogList(bpy.types.UIList):\n <mask token>\n <mask token>\n\n\nclass TILA_Config_SatusList(bpy.types.UIList):\n bl_idname = 'TILA_UL_Config_status_list'\n\n def draw_item(self, context,... | [
12,
13,
14,
15,
17
] |
""" Guess the number! """
import random, generic
def check_answer(player_guess, guess_value):
"""
Compares a player's guess and the number to guess
Returns True if the player guessed correctly
Returns False by default
"""
end_game = False
if player_guess > guess_value:
print('guess too high!')
elif playe... | normal | {
"blob_id": "a1e54a0f593149c1d97e64342c99f0ab8aa28fa9",
"index": 6215,
"step-1": "<mask token>\n\n\ndef check_answer(player_guess, guess_value):\n \"\"\"\n\tCompares a player's guess and the number to guess\n\tReturns True if the player guessed correctly\n\tReturns False by default\n\t\"\"\"\n end_game = F... | [
3,
5,
6,
7,
8
] |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 31 13:42:47 2018
@author: zhan
"""
from scipy.spatial.distance import pdist, squareform, cdist
import numpy as np
import scipy.io as sci
import os,sys
import datetime
###################################################################
# I_tr:featur... | normal | {
"blob_id": "db140bf66f3e3a84a60a6617ea4c03cc6a1bc56d",
"index": 6271,
"step-1": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jan 31 13:42:47 2018\n\n@author: zhan\n\"\"\"\nfrom scipy.spatial.distance import pdist, squareform, cdist\nimport numpy as np\nimport scipy.io as sci\nimport ... | [
0
] |
from rest_framework import serializers
from core.models import Curriculo
class CurriculoSerializer(serializers.ModelSerializer):
class Meta:
model = Curriculo
fields = ('id','name', 'description','image','create_at','update_at') | normal | {
"blob_id": "029f4f015f558dbd4d6096b00c53f5f0fe69883d",
"index": 1322,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass CurriculoSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Curriculo\n fields = 'id', 'name', 'description', 'image', 'create_at', 'update_at... | [
0,
1,
2,
3
] |
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
DIM Station Test
~~~~~~~~~~~~~~~~
Unit test for DIM Station
"""
import unittest
from dimp import ID, NetworkID
class StationTestCase(unittest.TestCase):
def test_identifier(self):
print('\n---------------- %s' % self)
str1 = 'gsp... | normal | {
"blob_id": "533d0b883a0bbbb148f04826e4c0a2bcc31732e9",
"index": 6702,
"step-1": "<mask token>\n\n\nclass StationTestCase(unittest.TestCase):\n\n def test_identifier(self):\n print('\\n---------------- %s' % self)\n str1 = 'gsp-s001@x77uVYBT1G48CLzW9iwe2dr5jhUNEM772G'\n id1 = ID(str1)\n ... | [
3,
4,
5,
6,
7
] |
import pytest
import json
import os.path
import importlib
import jsonpickle
from fixture.application import Application
fixture = None
config = None
@pytest.fixture
def app(request):
global fixture
global config
browser = request.config.getoption("--browser")
if config is None:
conf_file_pat... | normal | {
"blob_id": "0c0fb3bfb81be5ef6a60584eafeefec61f171679",
"index": 9124,
"step-1": "<mask token>\n\n\n@pytest.fixture(scope='session', autouse=True)\ndef stop(request):\n global fixture\n\n def finalizer():\n fixture.session.ensure_logout()\n fixture.destroy()\n request.addfinalizer(finalize... | [
4,
5,
6,
7,
9
] |
30. Convertir P libras inglesas a D dólares y C centavos. Usar el tipo de cambio $2.80 = 1 libra
p=2.80
x=int(input("Desea convertir sus libras a dolar(1) o a centavos(2)"))
if x == 1:
d=float(input("¿Cuantas libras desea convertir a dólar?\n"))
conversion = (d/p)
if x == 2:
c=float(input("¿Cuan... | normal | {
"blob_id": "ebc2acbcbab787b07c97b0a4ea8fbaeb9d8e30aa",
"index": 9770,
"step-1": "30. Convertir P libras inglesas a D dólares y C centavos. Usar el tipo de cambio $2.80 = 1 libra\r\np=2.80\r\n\r\nx=int(input(\"Desea convertir sus libras a dolar(1) o a centavos(2)\"))\r\n\r\nif x == 1:\r\n d=float(input(\"¿Cu... | [
0
] |
# 来源知乎 https://zhuanlan.zhihu.com/p/51987247
# 博客 https://www.cnblogs.com/yangecnu/p/Introduce-Binary-Search-Tree.html
"""
二叉查找树 (Binary Search Tree, BST)
特点 : left < root < right
若任意节点的左子树不空,则左子树上所有结点的 值均小于它的根结点的值;
若任意节点的右子树不空,则右子树上所有结点的值均大于它的根结点的值;
任意节点的左、右子树也分别为二叉查找树;
没有键值相等的节点(no ... | normal | {
"blob_id": "fa46bd784dcfeee4f9012ffb6ab6731d2764c9fa",
"index": 8484,
"step-1": "<mask token>\n\n\nclass BinarySearchTree:\n <mask token>\n\n def __init__(self):\n self._root = None\n\n def __str__(self):\n \"\"\" yield 迭代器 \"\"\"\n tree2list = [x.data for x in self._generate_node(... | [
15,
19,
26,
31,
34
] |
from django.contrib.auth.models import User
from django.db import models
class QueuedSpace(models.Model):
""" Stores space json for possible further editing before being sent to the server.
q_etag should update on every save so conflicts can be checked for in queued items.
"""
space_id = models.In... | normal | {
"blob_id": "ff09993a4f8fed65fa00c065eb5cfa41e7f9dcc1",
"index": 4411,
"step-1": "<mask token>\n\n\nclass QueuedSpace(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\n def __unicode__(self):\n ... | [
2,
3,
4,
5,
6
] |
# -*- coding: utf-8 -*-
from wordcloud import WordCloud, ImageColorGenerator
import numpy as np
from PIL import Image
def word2cloud(text: str, mask_image: Image=None):
if mask_image == None:
wc = WordCloud(font_path='simhei.ttf', width=800, height=600, mode='RGBA',
background_color=... | normal | {
"blob_id": "f9310aa6c26ec10041dac272fa17ac21f74c21ac",
"index": 9326,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef word2cloud(text: str, mask_image: Image=None):\n if mask_image == None:\n wc = WordCloud(font_path='simhei.ttf', width=800, height=600, mode=\n 'RGBA', backgr... | [
0,
1,
2,
3
] |
from sys import stdin
Read = stdin.readline
INF = int(1e9)
n, m = map(int, Read().split())
graph = [[INF] * (n+1) for _ in range(n+1)]
for i in range(1, n+1):
for j in range(1, n+1):
if i == j:
graph[i][j] = 0
for _ in range(m):
a, b = map(int, Read().split())
graph[a][b] = 1
for k i... | normal | {
"blob_id": "6ec39aa712c8abe610418e410883ff168d73126d",
"index": 3292,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, n + 1):\n for j in range(1, n + 1):\n if i == j:\n graph[i][j] = 0\nfor _ in range(m):\n a, b = map(int, Read().split())\n graph[a][b] = 1\nfo... | [
0,
1,
2,
3,
4
] |
def fonct(valeur, a= None):
if type(a) is list:
a.append(valeur)
# a+= valeur
elif type(a) is tuple:
a += tuple((valeur,))
elif type(a) is str:
a += str(valeur)
elif type(a) is set:
a.add(valeur)
el... | normal | {
"blob_id": "2a13fffa105a5dd546c30c892e59888eb6ead996",
"index": 4645,
"step-1": "<mask token>\n",
"step-2": "def fonct(valeur, a=None):\n if type(a) is list:\n a.append(valeur)\n elif type(a) is tuple:\n a += tuple((valeur,))\n elif type(a) is str:\n a += str(valeur)\n elif ty... | [
0,
1,
2,
3
] |
import pynucastro as pyna
rl = pyna.ReacLibLibrary()
h_burn = rl.linking_nuclei(["h1", "he4",
"c12", "c13",
"n13", "n14", "n15",
"o14", "o15", "o16","o17","o18",
"f17", "f18","f19",
... | normal | {
"blob_id": "39b07f1a515787e80a1fb822e67e19e2301b894a",
"index": 3285,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nrc.write_network()\n<mask token>\ncomp.set_solar_like()\nrc.plot(outfile='cno_extras.png', rho=1000000.0, T=100000000.0, comp=comp,\n Z_range=[1, 13], N_range=[1, 13])\nrc.plot(outfile... | [
0,
1,
2,
3,
4
] |
import mxnet as mx
import numpy as np
import logging
# Example performance:
# INFO:root:Epoch[34] Train-accuracy=0.601388
# INFO:root:Epoch[34] Validation-accuracy=0.620949
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
# running device
dev = mx.gpu()
# batch size and input shape
batch_size = 64
data_sh... | normal | {
"blob_id": "e82b9aa0f7dc669b3d5622c093b766c7e168221c",
"index": 5757,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nlogger.setLevel(logging.DEBUG)\n<mask token>\nmodel.fit(X=train, eval_data=val, batch_end_callback=mx.callback.\n Speedometer(batch_size, 50), epoch_end_callback=mx.callback.\n do_c... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Script for converting the new csv files to the desirable json format
'''
import codecs
import json
import re
def creeper():
'''
Settings for creeper file
'''
ccPrefix = False
inFilename = u'creeper.csv'
outFilename = u'Creeper.json'
mappingFil... | normal | {
"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
] |
import numpy as np
z = np.linspace(2,10,5) #from 2 to 10, with 5 elements
# OUT: array( [ 2. , 4. , 6. , 8. , 10. ] )
np.random.seed(0)
z1 = np.random.randint(10, size = 6)
# OUT: array( [5, 0, 3, 3, 7, 9] )
z = np.array([1,2,3,4,5])
z < 3
# OUT: array([T,T,F,F,F])
z[z<3]
# OUT: array([1,2])
a = np.array([1,2,3,4,... | normal | {
"blob_id": "be5147efda879165107378527ebf44890c03be75",
"index": 6679,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnp.random.seed(0)\n<mask token>\nz < 3\nz[z < 3]\n<mask token>\na + b\na + 30\n<mask token>\nprint(a)\na.shape()\na.ndim()\na[0, 2]\na[0, :]\na[:, 1]\nnp.min(a)\nnp.zeros(5)\nnp.zeros_lik... | [
0,
1,
2,
3,
4
] |
"""
Kontrollülesanne 7.4c - Elutee number (tähtaeg 28.okt. (incl))
Maksimaalne failide arv: 1
Töö liik: Individuaaltöö
Numeroloogias peetakse tähtsaks elutee numbrit, mille arvutamiseks tuleb liita kokku sünnikuupäeva ja -aasta numbrid
nii, et jõutakse lõpuks ühe numbrini.
Näiteks, oletame, et sünnikuupäev on 15.05.... | normal | {
"blob_id": "971187dc0e0f02282c8945940d07c011e247667a",
"index": 9401,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef elutee(s):\n n = 0\n for i in s:\n if i != '.':\n n += int(i)\n if n < 10:\n return n\n else:\n return elutee(str(n))\n\n\n<mask token>... | [
0,
1,
2,
3,
4
] |
"""
Auxiliary functions for calculating the utility of achieving a certain data rate (for a UE).
Attention: The absolute reward that's achieved with different utilities cannot be compared directly (diff ranges)!
"""
import numpy as np
from deepcomp.util.constants import MIN_UTILITY, MAX_UTILITY
def linear_clipped_ut... | normal | {
"blob_id": "e3de072d6bce2ecc105306c06b9a9aa0362130ff",
"index": 6234,
"step-1": "<mask token>\n\n\ndef log_utility(curr_dr):\n \"\"\"\n More data rate increases the utility following a log function: High initial increase, then flattens.\n\n :param curr_dr: Current data rate\n :param factor: Factor t... | [
1,
2,
3,
4,
5
] |
import os
import log
import core
import time
__description__ = 'OS X Auditor'
__author__ = 'Atarimaster & @Jipe_'
__version__ = '0.5.0'
ROOT_PATH = '/'
Euid = str(os.geteuid())
Egid = str(os.getegid())
def generate_header():
header = {}
# Description(Audited By)
description = "Report generated by " + _... | normal | {
"blob_id": "547d67bce7eb05e55e02c73a22342ca572e89f39",
"index": 9959,
"step-1": "<mask token>\n\n\ndef GetAuditedSystemVersion():\n global OSX_VERSION\n SysVersion = 'Unknown system version'\n SystemVersionPlist = False\n SystemVersionPlist = core.UniversalReadPlist(\n '/System/Library/CoreSe... | [
2,
3,
4,
5,
6
] |
#coding: utf-8
import logging
from threading import Thread
from ldap import SCOPE_BASE
from seafevents.ldap_syncer.ldap_conn import LdapConn
from seafevents.ldap_syncer.utils import bytes2str, add_group_uuid_pair
from seaserv import get_group_dn_pairs
logger = logging.getLogger(__name__)
def migrate_dn_pairs(set... | normal | {
"blob_id": "8cc0393082448bb8f61068b5c96e89ef3aee77ed",
"index": 235,
"step-1": "<mask token>\n\n\nclass LdapSync(Thread):\n\n def __init__(self, settings):\n Thread.__init__(self)\n self.settings = settings\n\n def run(self):\n if self.settings.enable_group_sync:\n migrate_... | [
9,
10,
11,
12,
13
] |
# =============>This is a Normal mathematical tasks<==========
x = 7
x = 7 // 3 # rounds the number = 2 ans class int
#x = 7 / 3 # gives the floating number = 2.33333335 ans class float
#x = 7 % 3 # gives the reminder = 1 ans class int
#print("x is {}" .format(x))
#print(type(x))
# ================>This is how to ... | normal | {
"blob_id": "62a7958ba5ebb6da866d6ef156e52136df22f235",
"index": 107,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('x is {}'.format(x))\nprint(type(x))\n<mask token>\nprint('x is {}'.format(x))\nprint(type(x))\n",
"step-3": "x = 7\nx = 7 // 3\n<mask token>\nx = 0.1 + 0.1 + 0.1 - 0.3\nprint('x i... | [
0,
1,
2,
3,
4
] |
"""
Flask app for testing the OpenID Connect extension.
"""
import json
from unittest.mock import MagicMock, Mock
from flask import Flask, g
import flask_oidc
from tests.json_snippets import *
oidc = None
def index():
return "too many secrets", 200, {
'Content-Type': 'text/plain; charset=utf-8'
}
... | normal | {
"blob_id": "ef3fa538828315845de5e2f7d4949f690e44276e",
"index": 6009,
"step-1": "<mask token>\n\n\ndef index():\n return 'too many secrets', 200, {'Content-Type':\n 'text/plain; charset=utf-8'}\n\n\ndef get_at():\n return oidc.get_access_token(), 200, {'Content-Type':\n 'text/plain; charset=... | [
10,
11,
13,
15,
19
] |
'''
Дано предложение, в котором имеются буквы с и т. Определить, какая из них встречается
позже (при просмотре слова слева направо). Если таких букв несколько, то должны
учитываться последние из них. Оператор цикла с условием не использовать.
'''
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
if __name__ == '__main__'... | normal | {
"blob_id": "4bad45f8c135463fadea9b3eed52ab045a51e8db",
"index": 2520,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n text = input('Введите предложение: ')\n x1 = text.index('с')\n x2 = text.index('т')\n if x1 > x2:\n print(\"Бурква 'с' встречается позже\")... | [
0,
1,
2
] |
#!/usr/bin/env python
from django import template
from django.conf import settings
from django.utils.html import format_html
register = template.Library()
@register.simple_tag
def website_title():
return settings.WEBSITE_TITLE
def split_page(result_obj):
"""
分页模块,后台传入一个分页结果集就可以
:param result_obj:
... | normal | {
"blob_id": "c2c51dcd05c21e91e591de25fc2de034c88c48a1",
"index": 9052,
"step-1": "<mask token>\n\n\ndef split_page(result_obj):\n \"\"\"\n 分页模块,后台传入一个分页结果集就可以\n :param result_obj:\n :return:\n \"\"\"\n return_str = '<nav>'\n return_str += \"<ul class='pagination pull-right'>\"\n if resul... | [
2,
3,
4,
5,
6
] |
# coding: utf-8
# In[5]:
import os
import numpy as np
import pandas as pd
from PIL import Image
import argparse
import time
import shutil
from sklearn.metrics import accuracy_score, mean_squared_error
import torch
import torch.optim
from torch.utils.data import Dataset, DataLoader
from torch.autograd import Variab... | normal | {
"blob_id": "f3a3746c48617754aad5ae8d0d7a0b8908c34562",
"index": 7852,
"step-1": "<mask token>\n\n\nclass ProtestDataset(Dataset):\n <mask token>\n <mask token>\n\n def __len__(self):\n return len(self.label_frame)\n <mask token>\n\n\nclass ProtestDatasetEval(Dataset):\n \"\"\"\n dataset... | [
20,
21,
22,
25,
35
] |
x = int(input('masukkan'))
y = int(input('masukkan'))
def jumlah(x, y):
hasil = x + y
return hasil
print('hasil dari', x, '+', y, '=', jumlah(x, y))
k = jumlah(2, 4) + 1
print(k)
| normal | {
"blob_id": "d8482da6b9983d990da980c3a5edab0c49a28229",
"index": 2219,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef jumlah(x, y):\n hasil = x + y\n return hasil\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef jumlah(x, y):\n hasil = x + y\n return hasil\n\n\nprint('hasil da... | [
0,
1,
2,
3
] |
import math
import random
import time
import numpy as np
class NeuralNetwork:
digits = [
[
1,1,1,1,1,
1,0,0,0,1,
1,0,0,0,1,
1,0,0,0,1,
1,1,1,1,1
],
[
0,0,1,0,0,
0,0,1,0,0,
0,0,1,0,0,
... | normal | {
"blob_id": "0af45914c8c111a42b0b9684f5f0ee19ef5eeb70",
"index": 7548,
"step-1": "<mask token>\n\n\nclass NeuralNetwork:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def withSeed(self, seed):\n self.seed = seed\n return self\n <mask token>\n\n def withMinErro... | [
7,
12,
13,
14,
19
] |
# Copyright 2015 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
# in compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed ... | normal | {
"blob_id": "445e91edbeb88a3e300761342b28369fd9833fbb",
"index": 5727,
"step-1": "<mask token>\n\n\nclass TestCases(unittest.TestCase):\n\n def test_chart_cell(self):\n t = [{'country': 'US', 'quantity': 100}, {'country': 'ZA',\n 'quantity': 50}]\n IPython.get_ipython().user_ns = {}\n... | [
3,
4,
5,
6,
7
] |
from math import *
from numpy import *
from random import *
import numpy as np
import matplotlib.pyplot as plt
from colorama import Fore, Back, Style
from gridworld import q_to_arrow
N_ROWS = 6
N_COLUMNS = 10
class State(object):
def __init__(self, i, j, is_cliff=False, is_goal=False):
self.i = i
... | normal | {
"blob_id": "cb2e800cc2802031847b170a462778e5c0b3c6f9",
"index": 40,
"step-1": "<mask token>\n\n\nclass State(object):\n\n def __init__(self, i, j, is_cliff=False, is_goal=False):\n self.i = i\n self.j = j\n self.is_cliff = is_cliff\n self.is_goal = is_goal\n self.q_values =... | [
14,
16,
20,
21,
22
] |
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from prettytable import PrettyTable
from time import sleep
from customization import *
import urllib.request,json
chrome_options=webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--inco... | normal | {
"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
] |
a=[[*map(int,input().split())]for _ in range(int(input()))]
a.sort()
s=0
l0,h0=a[0]
for l,h in a:
if h0<h:s+=(l-l0)*h0;l0,h0=l,h
l1,h1=a[-1]
for l,h in a[::-1]:
if h>h1:s+=(l1-l)*h1;l1,h1=l,h
s+=(l1-l0+1)*h1
print(s) | normal | {
"blob_id": "62dab85b7ab5fdae8117827b2f56bccf99615cb7",
"index": 7341,
"step-1": "<mask token>\n",
"step-2": "<mask token>\na.sort()\n<mask token>\nfor l, h in a:\n if h0 < h:\n s += (l - l0) * h0\n l0, h0 = l, h\n<mask token>\nfor l, h in a[::-1]:\n if h > h1:\n s += (l1 - l) * h1\n... | [
0,
1,
2,
3
] |
'''
config -- config manipulator module for share
@author: shimarin
@copyright: 2014 Walbrix Corporation. All rights reserved.
@license: proprietary
'''
import json,argparse
import oscar,groonga
def parser_setup(parser):
parser.add_argument("base_dir")
parser.add_argument("operations", nargs="*")
... | normal | {
"blob_id": "8b4590cf2d8c040b6ab31c63baff0d83ab818641",
"index": 5423,
"step-1": "'''\nconfig -- config manipulator module for share\n\n@author: shimarin\n\n@copyright: 2014 Walbrix Corporation. All rights reserved.\n\n@license: proprietary\n'''\n\nimport json,argparse\nimport oscar,groonga\n\ndef parser... | [
0
] |
# program name: an2_colour.py
# no optional arguments: Uses Wine data to display information about the relationship of
# various attributes with colour and hue
print('========================================================================================')
print('===================================================... | normal | {
"blob_id": "594479c22cada665dcdc76737085ce342d7d5faf",
"index": 1480,
"step-1": "<mask token>\n\n\ndef convert_type(data_value):\n try:\n return int(data_value)\n except ValueError:\n try:\n return float(data_value)\n except ValueError:\n return data_value\n\n\n<... | [
5,
6,
7,
8,
9
] |
n, k = [int(input()) for _ in range(2)]
ans = 1
for _ in range(n):
ans = min(ans * 2, ans + k)
print(ans)
| normal | {
"blob_id": "bb730606c7357eeb605292d5b9c05e8e8a797ea2",
"index": 5461,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(n):\n ans = min(ans * 2, ans + k)\nprint(ans)\n",
"step-3": "n, k = [int(input()) for _ in range(2)]\nans = 1\nfor _ in range(n):\n ans = min(ans * 2, ans + k)\npri... | [
0,
1,
2
] |
# Spelling bee NYT puzzle solver
with open('words.txt') as words_fh:
# Converts strips and lowercases lexicon (space seperated txt file)
# Use set to remove duplicates (decasing)
lexicon = set(list(map(lambda x: x.strip().lower(), words_fh.readlines())))
# NOTE: Could add a CLI to allow users to input... | normal | {
"blob_id": "aacd5d671090c3305a53d62c3c6c25d4c033f42d",
"index": 6420,
"step-1": "<mask token>\n",
"step-2": "with open('words.txt') as words_fh:\n lexicon = set(list(map(lambda x: x.strip().lower(), words_fh.readlines())))\n<mask token>\nprint(sorted_valid_words)\n",
"step-3": "with open('words.txt') as ... | [
0,
1,
2,
3
] |
# Visit 2.12.3 log file
ScriptVersion = "2.12.3"
if ScriptVersion != Version():
print "This script is for VisIt %s. It may not work with version %s" % (ScriptVersion, Version())
visit.ShowAllWindows()
visit.ShowAllWindows()
visit.OpenDatabase("test.vtk", 0)
# The UpdateDBPluginInfo RPC is not supported in the VisIt... | normal | {
"blob_id": "6d0cfc9d5bbc45bfa356c45a7cdb9f4822b03e0a",
"index": 2983,
"step-1": "# Visit 2.12.3 log file\nScriptVersion = \"2.12.3\"\nif ScriptVersion != Version():\n print \"This script is for VisIt %s. It may not work with version %s\" % (ScriptVersion, Version())\nvisit.ShowAllWindows()\nvisit.ShowAllWind... | [
0
] |
from xai.brain.wordbase.verbs._essay import _ESSAY
#calss header
class _ESSAYED(_ESSAY, ):
def __init__(self,):
_ESSAY.__init__(self)
self.name = "ESSAYED"
self.specie = 'verbs'
self.basic = "essay"
self.jsondata = {}
| normal | {
"blob_id": "dc2cbbaca3c35f76ac09c93a2e8ad13eb0bdfce6",
"index": 4086,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass _ESSAYED(_ESSAY):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass _ESSAYED(_ESSAY):\n\n def __init__(self):\n _ESSAY.__init__(self)\n self.name = 'ES... | [
0,
1,
2,
3,
4
] |
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
import bootcamp_utils
import numba
@numba.jit(nopython=True)
def backtrack_steps():
"""
Compute the number of steps it takes a 1d random walker starting
at zero to get to +1.
"""
# Initialize p... | normal | {
"blob_id": "00a2992af78f9edadd3f4cbc7d073c1f74fcd9a2",
"index": 2810,
"step-1": "<mask token>\n\n\n@numba.jit(nopython=True)\ndef backtrack_steps():\n \"\"\"\n Compute the number of steps it takes a 1d random walker starting\n at zero to get to +1.\n \"\"\"\n x = 0\n n_steps = 0\n while x <... | [
2,
3,
4,
5,
6
] |
import smtplib
import subprocess
import time
class NotifyError(Exception):
def __init__(self, message):
self.message = message
class Notification(object):
def __init__(self, config, dry_run):
self.dry_run = dry_run
self.notifications = {}
def submit(self, recipient, message):
... | normal | {
"blob_id": "01849a6bf5ce5eb75c549af28312f61711ad2494",
"index": 4425,
"step-1": "<mask token>\n\n\nclass Notification(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass SendMail(Notification):\n\n def __init__(self, config, dry_run)... | [
11,
12,
15,
20,
21
] |
import cv2
import sys
# Load the Haar cascades
face_cascade = cv2.CascadeClassifier('./haar_cascades/haarcascade_frontalface_default.xml')
eyes_cascade = cv2.CascadeClassifier('./haar_cascades/haarcascade_eye.xml')
capture = cv2.VideoCapture(0)
_, image = capture.read()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
... | normal | {
"blob_id": "4d707e23f66e8b6bea05a5901d3d8e459247c6c1",
"index": 3840,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncapture.release()\ncv2.destroyAllWindows()\n<mask token>\nif len(faces) >= 1:\n sys.stdout.write('1')\nelse:\n sys.stdout.write('0')\n",
"step-3": "<mask token>\nface_cascade = cv... | [
0,
1,
2,
3,
4
] |
from math import log
result = []
formula = int(input("For exit press 0\nChoose the formula #1 #2 #3: "))
while (formula >= 0) and (formula <= 3):
a = float(input("Enter a:"))
min_x = float(input("Enter minx:"))
max_x = float(input("Enter maxx:"))
step = int(input("Enter steps:"))
x = min_x
if... | normal | {
"blob_id": "44c4a1f4b32b45fd95eb8b0a42a718d05d967e04",
"index": 2536,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile formula >= 0 and formula <= 3:\n a = float(input('Enter a:'))\n min_x = float(input('Enter minx:'))\n max_x = float(input('Enter maxx:'))\n step = int(input('Enter steps... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 15 15:36:38 2021
@author: mav24
"""
import pandas as pd
import numpy as np
from sklearn.preprocessing import QuantileTransformer, StandardScaler, PowerTransformer, MaxAbsScaler
from sklearn.cross_decomposition import PLSRegression
from sklearn.en... | normal | {
"blob_id": "4a17db6b65e1615b0d519581b3e63bc34ad16093",
"index": 1288,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndata.drop(columns=drop, inplace=True)\n<mask token>\nmodel.fit(X_train, Y_train)\n<mask token>\nprint('With Standar Scaler')\nprint(f'The R2 accuracy is: {r2(Y_test, pred_test)}')\nprint(... | [
0,
1,
2,
3,
4
] |
import os
import logging
from datetime import datetime
import torch
from naruto_skills.training_checker import TrainingChecker
from data_for_train import is_question as my_dataset
from model_def.lstm_attention import LSTMAttention
from utils import pytorch_utils
from train.new_trainer import TrainingLoop, TrainingLog... | normal | {
"blob_id": "77884dd72f5efe91fccad27e6328c4ad34378be2",
"index": 6953,
"step-1": "<mask token>\n\n\ndef target2_text(first_input, *params):\n return first_input\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef input2_text(first_input, *params):\n return my_dataset.voc.idx2docs(first_input)\n\n\ndef... | [
1,
2,
3,
4,
5
] |
import matplotlib.pyplot as plt
import numpy as np
steps = 10
num_tests = 100
res = []
with open('txt.txt', 'r') as f:
data = f.readlines()
line = 0
for i in range(10, 110, 10):
agg = 0
for j in range(num_tests):
agg += int(data[line])
line += 1
res.append(... | normal | {
"blob_id": "176ffac7ad47f5c43a24acc664631f8353ec5100",
"index": 967,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('txt.txt', 'r') as f:\n data = f.readlines()\n line = 0\n for i in range(10, 110, 10):\n agg = 0\n for j in range(num_tests):\n agg += int(data[... | [
0,
1,
2,
3,
4
] |
from django import template
register = template.Library()
@register.filter(name='range')
def filter_range(start, end=None):
if end is None:
return range(start)
else:
return range(start, end)
| normal | {
"blob_id": "f733885eed5d1cbf6e49db0997655ad627c9d795",
"index": 599,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@register.filter(name='range')\ndef filter_range(start, end=None):\n if end is None:\n return range(start)\n else:\n return range(start, end)\n",
"step-3": "<mask... | [
0,
1,
2,
3
] |
import sys
import random
#import matplotlib.pyplot as plt
import numpy as np
import time
class Waterfilling:
"""
initializes x and r with optimal flow allocations
and link fair share rates for traffic matrix routes and link
capacities c, and level with number of levels
after running the waterfillin... | normal | {
"blob_id": "93e534e8d425510b59310dcbfc5bca9cc32f245e",
"index": 9798,
"step-1": "import sys\nimport random\n#import matplotlib.pyplot as plt\nimport numpy as np\nimport time\n\nclass Waterfilling:\n \"\"\"\n initializes x and r with optimal flow allocations\n and link fair share rates for traffic matri... | [
0
] |
no = int(input("Enter a number: "))
no = str(no)
rev = no[::-1]
if no==rev:
print(f"{no}--->{rev} Input is a palindrome")
else:
print(f"{no}--->{rev} Input is not a palindrome")
| normal | {
"blob_id": "020a41e7d3cc3f5adf3a38a6852dac6037595372",
"index": 2043,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif no == rev:\n print(f'{no}--->{rev} Input is a palindrome')\nelse:\n print(f'{no}--->{rev} Input is not a palindrome')\n",
"step-3": "no = int(input('Enter a number: '))\nno = s... | [
0,
1,
2,
3
] |
# Copyright (c) 2016 EMC Corporation
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless requir... | normal | {
"blob_id": "2d48a343ca7f0f8ba7de8b520aad71d774d9b4ba",
"index": 9302,
"step-1": "<mask token>\n\n\nclass VirtualArray(common.CoprHDResource):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def varray_list(self, vdcname=None):\n \"\"\"Returns all the varrays in a vdc.\n\n ... | [
2,
4,
5,
6,
7
] |
version = (2, 5, 8)
version_string = ".".join(str(v) for v in version)
release_date = "2015.12.27"
| normal | {
"blob_id": "28077af0759e062078f7b9d1f7bbbb93c62835cb",
"index": 5063,
"step-1": "<mask token>\n",
"step-2": "version = 2, 5, 8\nversion_string = '.'.join(str(v) for v in version)\nrelease_date = '2015.12.27'\n",
"step-3": "version = (2, 5, 8)\nversion_string = \".\".join(str(v) for v in version)\n\nrelease_... | [
0,
1,
2
] |
import tkinter as tk
from pickplace import PickPlace
import sys
import math
from tkinter import messagebox
import os
DEBUG = False
class GerberCanvas:
file_gto = False
file_gtp = False
units = 0
units_string = ('i', 'm')
"""
my canvas
"""
def __init__(self, frame):
self.x_fo... | normal | {
"blob_id": "6b2f10449909d978ee294a502a376c8091af06e0",
"index": 1285,
"step-1": "<mask token>\n\n\nclass GerberCanvas:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, frame):\n self.x_format = ''\n self.y_format = ''\n self... | [
18,
19,
20,
23,
25
] |
from base import *
try:
from .prod_local import *
except:
pass
# we currently don't have an interface that allows an administrator
# to create a repository for another user. Until we have added this
# capability, allow users to create repos.
ELEMENTARY_ALLOW_REPO_CREATION = True
| normal | {
"blob_id": "709271b98fc2b40c763522c54488be36968f02d8",
"index": 346,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n from .prod_local import *\nexcept:\n pass\n<mask token>\n",
"step-3": "<mask token>\ntry:\n from .prod_local import *\nexcept:\n pass\nELEMENTARY_ALLOW_REPO_CREATION =... | [
0,
1,
2,
3,
4
] |
import tkinter as tk
from tkinter import Tk, BOTH,RIGHT,LEFT,END
from tkinter.ttk import Frame, Label, Style,Entry
from tkinter.ttk import Frame, Button, Style
import random
import time
class StartPage(tk.Frame):
def __init__(self, master):
tk.Frame.__init__(self, master)
tk.Frame.configu... | normal | {
"blob_id": "4e6401672d4762b444bb679e4cc39ada04193a26",
"index": 1882,
"step-1": "<mask token>\n\n\nclass PageOne(tk.Frame):\n\n def __init__(self, master):\n tk.Frame.__init__(self, master)\n frame_left = Frame(self)\n self.frame_left = frame_left\n frame_left.pack(fill=BOTH, side... | [
11,
12,
15,
17,
18
] |
#!/usr/bin/env python
#
# Copyright 2017-2021 University Of Southern California
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless... | normal | {
"blob_id": "12fd4e3bfb6821205a9b65b4d236b4158ec4ef1e",
"index": 7345,
"step-1": "<mask token>\n\n\nclass Version(BaseVersion):\n\n def __init__(self, connection):\n super().__init__(connection)\n\n def update(self, force=False):\n \"\"\"\n\n :param force:\n :return:\n \"... | [
3,
4,
5,
6,
7
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.