code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
from mcpi.minecraft import Minecraft from time import sleep import random mc = Minecraft.create() myID=mc.getPlayerEntityId("Baymax1112") mineral = [14,15,16,56,73,129,57] while True: sleep(0.5) r=random.choice(mineral) x,y,z = mc.entity.getTilePos(myID) mc.setBlocks(x+1,y+3,z+1,x-1,y-3,z-1,r)
normal
{ "blob_id": "b28ae19f31ae746f901dea645dfeaa211a15cd31", "index": 1879, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n sleep(0.5)\n r = random.choice(mineral)\n x, y, z = mc.entity.getTilePos(myID)\n mc.setBlocks(x + 1, y + 3, z + 1, x - 1, y - 3, z - 1, r)\n", "step-3": "<mask...
[ 0, 1, 2, 3, 4 ]
""" Compare 1-D analytical sphere solution to 1-D numerical and 3-D Comsol solutions for transient heat conduction in solid sphere with constant k and Cp. Assumptions: Convection boundary condition at surface. Symmetry about the center of the solid. Heat transfer via radiation assumed to be negligable. Particle does n...
normal
{ "blob_id": "15ca54aff4c688733c9c514ba5856e6bf29a3292", "index": 8345, "step-1": "<mask token>\n\n\ndef despine():\n ax = py.gca()\n ax.spines['top'].set_visible(False)\n ax.spines['right'].set_visible(False)\n py.tick_params(axis='both', bottom='off', top='off', left='off', right=\n 'off')\n\...
[ 1, 2, 3, 4, 5 ]
import numpy as np from sklearn.naive_bayes import BernoulliNB X = np.array([[1, 2, 3, 3], [1, 3, 4, 4], [2, 4, 5, 5]]) y = np.array([1, 2, 3]) """ alpha: 平滑系数 binarize: 将特征二值化的阈值 fit_prior: 使用数据拟合先验概率 """ clf = BernoulliNB(alpha=2.0, binarize=3.0, fit_prior=True) clf.fit(X, y) print("class_prior:", clf.class_prior) ...
normal
{ "blob_id": "98a1fab8cee91f37ceee2cfd868d3a5756a055b0", "index": 7628, "step-1": "<mask token>\n", "step-2": "<mask token>\nclf.fit(X, y)\nprint('class_prior:', clf.class_prior)\nprint('class_count_:', clf.class_count_)\nprint('class_log_prior_:', clf.class_log_prior_)\nprint('feature_count_:', clf.feature_cou...
[ 0, 1, 2, 3, 4 ]
from flask import logging from flask_sqlalchemy import SQLAlchemy from passlib.apps import custom_app_context as pwd_context logger = logging.getLogger(__name__) db = SQLAlchemy() # flask-sqlalchemy class User(db.Model): __tablename__ = 'users' id = db.Column(db.Integer, primary_key=True) username = db...
normal
{ "blob_id": "e976f7e423d75f7fc8a3d5cd597bdd9358ae317e", "index": 5243, "step-1": "<mask token>\n\n\nclass User(db.Model):\n __tablename__ = 'users'\n id = db.Column(db.Integer, primary_key=True)\n username = db.Column(db.String(32), index=True)\n password_hash = db.Column(db.String(128))\n\n def h...
[ 11, 13, 15, 16, 17 ]
list_1 = ['color','white','black']#taking the colors of t-shirts as input list_2 = ['short','medium','large','xl']#taking sizes of t-shirts as input for color in list_1: for size in list_2: #using cartesien product asking to give output as the combinations of color and size of t-shirts we ...
normal
{ "blob_id": "6cba431650ee8b74baa8310c144321b2e587155e", "index": 2163, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor color in list_1:\n for size in list_2:\n print(color, size)\n<mask token>\nlist_3.reverse()\nprint(list_3)\n", "step-3": "list_1 = ['color', 'white', 'black']\nlist_2 = ['...
[ 0, 1, 2, 3 ]
import sys sys.path.insert(0, ".")
normal
{ "blob_id": "b95eadd60093d5235dc0989205edff54ef611215", "index": 2399, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.insert(0, '.')\n", "step-3": "import sys\nsys.path.insert(0, '.')\n", "step-4": "\nimport sys\n\nsys.path.insert(0, \".\")", "step-5": null, "step-ids": [ 0, 1, ...
[ 0, 1, 2, 3 ]
import RPi.GPIO as GPIO import numpy as np import array import time import json import LED_GPIO as led import BUTTON_GPIO as btn import parseJson as gjs rndBtnState = False interval = .1 rndbtn = gjs.getJsonRnd() gpioValues = gjs.getJsonData() strArray = gpioValues[0] btnArray = gpioValues[1] ledArray = gpioValue...
normal
{ "blob_id": "1b741b34649193b64479724670244d258cfbbdfc", "index": 5055, "step-1": "import RPi.GPIO as GPIO\nimport numpy as np\nimport array\nimport time\nimport json\n\nimport LED_GPIO as led \nimport BUTTON_GPIO as btn\nimport parseJson as gjs\n\nrndBtnState = False\ninterval = .1\n\nrndbtn = gjs.getJsonRnd()\n...
[ 0 ]
from django.shortcuts import render from rest_framework import status, viewsets , response from . import models from . import serializers # Create your views here. class TodoViewset(viewsets.ModelViewSet): queryset = models.Todo.objects.all() serializer_class = serializers.TodoSerializer
normal
{ "blob_id": "1c668cf6f145b85a09b248fefda46e928de64e41", "index": 5041, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TodoViewset(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TodoViewset(viewsets.ModelViewSet):\n queryset = models.Todo....
[ 0, 1, 2, 3, 4 ]
"""Admin module for Django.""" from django.contrib import admin from django.utils.translation import gettext_lazy as _ from django_q.conf import Conf, croniter from django_q.models import Failure, OrmQ, Schedule, Success from django_q.tasks import async_task class TaskAdmin(admin.ModelAdmin): """model admin for ...
normal
{ "blob_id": "5aebebb7f22e094a1a897b3266ff07d59400b76c", "index": 2209, "step-1": "<mask token>\n\n\nclass ScheduleAdmin(admin.ModelAdmin):\n \"\"\"model admin for schedules\"\"\"\n list_display = ('id', 'name', 'func', 'schedule_type', 'repeats',\n 'cluster', 'next_run', 'last_run', 'success')\n ...
[ 10, 21, 22, 23, 26 ]
import tensorflow.contrib.slim as slim import tensorflow as tf from tensorflow.python.framework import dtypes from tensorflow.python.ops import random_ops from tensorflow.python.ops import init_ops import numpy as np WEIGHT_DECAY = 0.0005 class ScaledVarianceUniform(init_ops.Initializer): """Initializer that genera...
normal
{ "blob_id": "9da6bfa614d64956a302abbfeeea30c0339e9db3", "index": 5583, "step-1": "<mask token>\n\n\nclass ConvLayer(object):\n <mask token>\n\n def apply(self, h):\n if self.activation_fn == False:\n if self.normalizer_fn == False:\n if self.dropout == False:\n ...
[ 19, 21, 23, 33, 35 ]
#OpenCV create samples commands #opencv_createsamples -img watch5050.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 1950 #opencv_createsamples -info info/info.lst -num 1950 -w 20 -h 20 -vec positives.vec #Training command #opencv_traincascade -data data -vec p...
normal
{ "blob_id": "62e0c3b6095a65a4508eddfa9c0a1cb31d6c917b", "index": 8887, "step-1": "#OpenCV create samples commands\r\n#opencv_createsamples -img watch5050.jpg -bg bg.txt -info info/info.lst -pngoutput info -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 1950\r\n#opencv_createsamples -info info/info.lst -num 195...
[ 1 ]
# 作者:西岛闲鱼 # https://github.com/globien/easy-python # https://gitee.com/globien/easy-python # 用蒙特卡洛法计算圆周率,即,往一个正方形里扔豆子,计算有多少比例的豆子扔在了该正方形的内切圆中 import random num_all = 0 #随机点总计数器 num_cir = 0 #随机点在圆内的计数器 num_halt = 10000000 #每产生这么多个随机点后,计算并打印一次目前的结果 print("将进行无限计算,请用Ctrl_C或其他方式强制退出!!!") input("按回车(Enter...
normal
{ "blob_id": "5d9afef2a748782659b82b329ea08d5815162cbc", "index": 3744, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('将进行无限计算,请用Ctrl_C或其他方式强制退出!!!')\ninput('按回车(Enter)键开始...')\nprint('开始计算...,退出请用Ctrl_C或其他强制退出方式...')\nprint(\"\"\"\n实验次数 计算结果\"\"\")\nwhile 1:\n for i in range(num_halt):\n...
[ 0, 1, 2, 3, 4 ]
def addnumber(i,j): sum= i+j print(sum) num1 = int(input("Enter 1st number")) num2 = int(input("Enter 2nd number")) z = addnumber(num1,num2)
normal
{ "blob_id": "2350c2ab05499f1b40ba61f2101c51d9581d57f6", "index": 8668, "step-1": "<mask token>\n", "step-2": "def addnumber(i, j):\n sum = i + j\n print(sum)\n\n\n<mask token>\n", "step-3": "def addnumber(i, j):\n sum = i + j\n print(sum)\n\n\nnum1 = int(input('Enter 1st number'))\nnum2 = int(inp...
[ 0, 1, 2, 3 ]
''' Binary_to_C Converts any binary data to an array of 'char' type to be used inside of a C program. The reason to want to do that, is to emulate a 'Windows Resource System' on Linux. Linux does not allow inclusion of binary data in application (I am OK with that, I like that actually). Windows, however, does. On...
normal
{ "blob_id": "c9f29a92ec8627593b54f7d9569dcfd589fa7fff", "index": 5811, "step-1": "'''\nBinary_to_C\n\tConverts any binary data to an array of 'char' type to be used inside of a C program.\n\tThe reason to want to do that, is to emulate a 'Windows Resource System' on Linux.\n\tLinux does not allow inclusion of bi...
[ 0 ]
import os import json from .utils import * def _unique_predict(solve_list): valid_solve_list = filter(lambda x: x[0] is not None, solve_list) valid_solve_list = sorted(valid_solve_list, key=lambda x: x[0]) unique_solve_list = list() current_no = -1 for e in valid_solve_list: if current_no ...
normal
{ "blob_id": "00a1b5f20f15994a659eda56201ba7c45d49a4db", "index": 4186, "step-1": "<mask token>\n\n\ndef _unique_predict(solve_list):\n valid_solve_list = filter(lambda x: x[0] is not None, solve_list)\n valid_solve_list = sorted(valid_solve_list, key=lambda x: x[0])\n unique_solve_list = list()\n cur...
[ 3, 4, 5, 6, 7 ]
# coding: utf-8 from pyquery import PyQuery as pq html = ''' <div id="container"> <ul class="list"> <li class="item-0">first item</li> <li class="item-1"><a href="link2.html">second item</a></li> <li class="item-0 active"><a href="link3.html">third item</a></li> ...
normal
{ "blob_id": "02ab822dacb26d623a474fa45ebb034f9c1291b8", "index": 1604, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a, type(a))\nprint(a.attr('href'))\nprint(a.attr.href)\n", "step-3": "<mask token>\nhtml = \"\"\"\n <div id=\"container\">\n <ul class=\"list\">\n <li class=\...
[ 0, 1, 2, 3, 4 ]
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 pymysql pymysql.install_as_MySQLdb() # from keras.models import load_model # from keras.models import Model # from ai import settings # # print('load model ...') # model = load_model(settings.MODEL_PATH) # model = Model(inputs=model.input, outputs=model.get_layer('dnsthree').output) # print('load done.')
normal
{ "blob_id": "b7d3af29e024b0b2cf5d2c054290f799eae7fed1", "index": 4476, "step-1": "<mask token>\n", "step-2": "<mask token>\npymysql.install_as_MySQLdb()\n", "step-3": "import pymysql\npymysql.install_as_MySQLdb()\n", "step-4": "import pymysql\n\npymysql.install_as_MySQLdb()\n\n# from keras.models import lo...
[ 0, 1, 2, 3 ]
from django.conf import settings from django.db import migrations, models import django_otp.plugins.otp_totp.models class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( nam...
normal
{ "blob_id": "2e448176a755828e5c7c90e4224102a285098460", "index": 4852, "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 = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- from odoo import models, fields, api class ResPartner(models.Model): _inherit = 'res.partner' purchase_type = fields.Many2one('purchase.order.type', string='Purchase Order Type')
normal
{ "blob_id": "f26b127b4d968c1a168a57825a5acfffbf027bef", "index": 3372, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ResPartner(models.Model):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ResPartner(models.Model):\n _inherit = 'res.partner'\n purchase_type...
[ 0, 1, 2, 3, 4 ]
207. Course Schedule Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1] Given the total number of courses and a list of prerequisite pairs, is it possible for you to finish all courses? For example: 2, [[1,0]] There are a total of...
normal
{ "blob_id": "34aa08b9a5a89d3fca129271a9e812e2382ca88e", "index": 4196, "step-1": "207. Course Schedule \n\nSome courses may have prerequisites, for example to take course 0 you have to first take course 1, \nwhich is expressed as a pair: [0,1]\n\nGiven the total number of courses and a list of prerequisite pairs...
[ 0 ]
# 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 ]
# -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html from sqlalchemy import create_engine, MetaData, Table class DoubanPipeline(object): conn = None film_table = None ...
normal
{ "blob_id": "5ef6b2ff89ee1667ddb01b1936557f1f11a49910", "index": 4673, "step-1": "# -*- coding: utf-8 -*-\n\n# Define your item pipelines here\n#\n# Don't forget to add your pipeline to the ITEM_PIPELINES setting\n# See: http://doc.scrapy.org/en/latest/topics/item-pipeline.html\nfrom sqlalchemy import create_eng...
[ 0 ]
#Diagonal Traverse #Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. #Example: #Input: #[ # [ 1, 2, 3 ], # [ 4, 5, 6 ], # [ 7, 8, 9 ] #] #Output: [1,2,4,7,5,3,6,8,9] #Explanation: #Note: # The total number of elements of the given...
normal
{ "blob_id": "0a5ea7ad0ee34c8a3f0299908c61fa0a09139d2f", "index": 8558, "step-1": "#Diagonal Traverse\n#Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal\norder as shown in the below image.\n#Example:\n#Input:\n#[\n# [ 1, 2, 3 ],\n# [ 4, 5, 6 ],\n# [ 7, 8, 9 ]\n#]...
[ 0 ]
# https://www.acmicpc.net/problem/2751 # n 개 수가 주어짐 # 목표 오름차순정렬 # 첫 줄 n개 # 둘째줄부터 n개의 줄에 수가 주어짐 세로로 # 출력 오름차순 정렬한 결과를 한 줄에 하나씩 출력한다? n=int(input()) n_list=[int(input()) for _ in range(n)] # print(n_list) nn_list = [] # 인덱스 2개 관리 mid_idx = len(n_list) //2 left_idx = 0 right_idx = mid_idx +1 while left_idx <= mid...
normal
{ "blob_id": "fb5508b1b5aa36c4921358d6ca7f96fc7d565241", "index": 5104, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile left_idx <= mid_idx and right_idx <= n - 1:\n if n_list[left_idx] < n_list[right_idx]:\n nn_list.append(n_list[left_idx])\n left_idx += 1\n elif n_list[left_idx]...
[ 0, 1, 2, 3 ]
import unittest """ Find the largest 0 to 9 pandigital that can be formed by concatenating products Take the number 6 and multiply it by each of 1273 and 9854: 6 × 1273 = 7638 6 × 9854 = 59124 By concatenating these products we get the 1 to 9 pandigital 763859124. We will call 763859124 the "concatenated product of ...
normal
{ "blob_id": "cb08b95e3b9c80fb74d4415b3798ddbb36cd76e7", "index": 419, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Test(unittest.TestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Test(unittest.TestCase):\n\n def test(self):\n pass\n", "step-4": "import unittest...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.1.7 on 2021-03-19 14:38 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('news', '0002_auto_202103...
normal
{ "blob_id": "8b4bc312bf4b64f98c4f84f4bf89984291be0428", "index": 6033, "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 = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
#Program to create and store Employee Salary Records in a file import os def appendEmployee(eno,name,basic): fh=open("Employee.txt","a") hra=basic*0.10 da=basic*0.73 gross=basic+hra+da tax=gross*0.3 net=gross-tax line=str(eno)+","+name+","+str(basic)+","+str(hra)+","+str(da)+","+str(gross)+","+str(tax)+","+str...
normal
{ "blob_id": "5b6241907cc97f82d6c6e0a461f4f71a9a567204", "index": 5395, "step-1": "<mask token>\n\n\ndef displayEmployees():\n fh = open('Employee.txt', 'r')\n for line in fh:\n emp = line.split(',')\n print('\\nEmployee No:', emp[0], '\\nEmployee Name:', emp[1],\n '\\nBasic:', emp[...
[ 3, 5, 6, 7, 8 ]
from __future__ import with_statement from fabric.api import * from fabric.colors import * from fabric.utils import puts from fabric.context_managers import shell_env env.hosts = ['git@tweetset.com'] def deploy(): "deploys the project to the server" with prefix('source /srv/django-envs/tweetset/bin/activate')...
normal
{ "blob_id": "6111c9730c556ab3ab95f7685ffa135a2bbeb2ca", "index": 5950, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef deploy():\n \"\"\"deploys the project to the server\"\"\"\n with prefix('source /srv/django-envs/tweetset/bin/activate'):\n with shell_env(DJANGO_SETTINGS_MODULE='twe...
[ 0, 1, 2, 3, 4 ]
''' Note: a TimeOutException appear when distance even 0. ''' import smbus import time #slave arduino address address_arduino = 0x04 bus = smbus.SMBus(1) #get a measure by i2c def getUSMeasure(): bus.write_byte(address_arduino, 1) distance = bus.read_byte(address_arduino) return distance #request rotate...
normal
{ "blob_id": "6fa7aef7c2b91de409a0e8574e362efefa642ee7", "index": 1715, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef getUSMeasure():\n bus.write_byte(address_arduino, 1)\n distance = bus.read_byte(address_arduino)\n return distance\n\n\ndef forward():\n bus.write_byte(address_arduino...
[ 0, 2, 3, 6, 7 ]
#! /usr/bin/env python # -*- conding:utf-8 -*- import MySQLdb import os import commands from common import logger_init from logging import getLogger import re from db import VlanInfo,Session,WafBridge def getVlan(): # get vlan data from t_vlan session=Session() vlanport=[] for info in session.query(VlanIn...
normal
{ "blob_id": "cd564ebb51cf91993d2ed1810707aead44c19a6b", "index": 6959, "step-1": "<mask token>\n\n\ndef getVlan():\n session = Session()\n vlanport = []\n for info in session.query(VlanInfo):\n a = []\n a.append(info.nets)\n a.append(info.vlan_id)\n vlanport.append(a)\n in...
[ 3, 4, 5, 6, 7 ]
import abc try: import cPickle as pickle except ImportError: import pickle from typing import * T = TypeVar('T') class BaseSerializer(Generic[T]): """ The serializer is responsible for converting complex python data types into primitive types that can be sent over zmq ports via msgpack. ""...
normal
{ "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 ]
def ex7(*siruri, x=1, flag=True): res = () for sir in siruri: chars = [] for char in sir: if ord(char) % x == (not flag): chars.append(char) res += (chars,) return res print(ex7("test", "hello", "lab002", x=2, flag=False))
normal
{ "blob_id": "90a402cccf383ed6a12b70ecdc3de623e6e223f9", "index": 8365, "step-1": "<mask token>\n", "step-2": "def ex7(*siruri, x=1, flag=True):\n res = ()\n for sir in siruri:\n chars = []\n for char in sir:\n if ord(char) % x == (not flag):\n chars.append(char)\n ...
[ 0, 1, 2, 3 ]
#coding: utf8 import sqlite3 from random import shuffle import argparse def wordCount(db): words = {} for sent, labels in iterReviews(db): for word in sent: if word not in words: words[word] = 1 else: words[word] += 1 return words def filt...
normal
{ "blob_id": "04867e8911f7cb30af6cefb7ba7ff34d02a07891", "index": 7970, "step-1": "<mask token>\n\n\ndef wordCount(db):\n words = {}\n for sent, labels in iterReviews(db):\n for word in sent:\n if word not in words:\n words[word] = 1\n else:\n words...
[ 3, 5, 6, 7, 8 ]
''' Sample Input 1 5 1 2 3 2 1 Sample Output 3 ''' for _ in range(int(input())): noe = int(input()) arr = [int(x) for x in input().split()] left = arr[0] rite = sum(arr) - left mins = abs(rite - left) for i in range(1, noe-1): left += arr[i] rite -= arr[i] print(left, rit...
normal
{ "blob_id": "825f3b930fee319314d520a32c2f9dcd718505ab", "index": 2424, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(int(input())):\n noe = int(input())\n arr = [int(x) for x in input().split()]\n left = arr[0]\n rite = sum(arr) - left\n mins = abs(rite - left)\n for i i...
[ 0, 1, 2 ]
You are given a 2 x N board, and instructed to completely cover the board with the following shapes: Dominoes, or 2 x 1 rectangles. Trominoes, or L-shapes. For example, if N = 4, here is one possible configuration, where A is a domino, and B and C are trominoes. A B B C A B C C Given an in...
normal
{ "blob_id": "834fa5d006188da7e0378246c1a019da6fa413d2", "index": 4882, "step-1": "You are given a 2 x N board, and instructed to completely cover the board with\nthe following shapes:\n\n Dominoes, or 2 x 1 rectangles.\n Trominoes, or L-shapes.\n For example, if N = 4, here is one possible configuration...
[ 0 ]
import sys sys.path.append('../') from IntcodeComputer.intcode import Program if __name__ == '__main__': fn = 'input.txt' with open(fn) as f: program = Program([int(i) for i in f.readline().split(',')]) program.run() result = program.instructions
normal
{ "blob_id": "a54c8ab63c1e0f50d254d6c97ca3f167db7142e9", "index": 4956, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('../')\n<mask token>\nif __name__ == '__main__':\n fn = 'input.txt'\n with open(fn) as f:\n program = Program([int(i) for i in f.readline().split(',')])\n ...
[ 0, 1, 2 ]
from django.contrib.staticfiles.storage import CachedFilesMixin from storages.backends.s3boto3 import S3Boto3Storage class CachedS3Storage(CachedFilesMixin, S3Boto3Storage): pass StaticRootS3BotoStorage = lambda : CachedS3Storage(location='static') MediaRootS3BotoStorage = lambda : S3Boto3Storage(location='medi...
normal
{ "blob_id": "e99ff1c75d5108efc8d587d4533c34eeb15c6978", "index": 9425, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CachedS3Storage(CachedFilesMixin, S3Boto3Storage):\n pass\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass CachedS3Storage(CachedFilesMixin, S3Boto3Storage):\n p...
[ 0, 1, 2, 3 ]
import retro # pip install gym-retro import numpy as np # pip install numpy #import cv2 # pip install opencv-python import neat # pip install neat-python import pickle # pip install cloudpickle import os import multiprocessing import cv2 import time env = retro.make(game='Pong-...
normal
{ "blob_id": "36e350e0d578e169efaafb9e311566d71d6bc59e", "index": 1438, "step-1": "<mask token>\n\n\ndef eval_genome(genome, config):\n net = neat.nn.FeedForwardNetwork.create(genome, config)\n env.reset()\n ob, _, _, _ = env.step(env.action_space.sample())\n inx = int(ob.shape[0] / 8)\n iny = int(...
[ 3, 4, 5, 6, 7 ]
# Generated by Django 3.2.9 on 2021-11-10 13:36 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('settings', '0003_auto_20210814_2246'), ] operations = [ migrations.AlterField( model_name='building', name='id', ...
normal
{ "blob_id": "9dfbf14a2005aad87be82e5e482c6b0347f32f2c", "index": 8007, "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 = [('settings', ...
[ 0, 1, 2, 3, 4 ]
from collections import defaultdict def solution(tickets): # 출발지가 키, 목적지가 value 인 딕셔너리 생성 routes = defaultdict(list) for t in tickets: routes[t[0]].append(t[1]) # 알파벳 빠른순으로 정렬해야함으로 reverse=True for r in routes: routes[r].sort(reverse=True) # 시작 위치 ICN stack = ['ICN'] ...
normal
{ "blob_id": "15c6841052882406d7c7b6cd05c0186c6a4a5924", "index": 2021, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solution(tickets):\n routes = defaultdict(list)\n for t in tickets:\n routes[t[0]].append(t[1])\n for r in routes:\n routes[r].sort(reverse=True)\n stack...
[ 0, 1, 2, 3, 4 ]
""" Convert file containing histograms into the response function """ import h5py import wx import numpy as np import matplotlib.pyplot as plt ############################################################################# # Select the file cantoning histograms, # which will be converted to response function app = wx.A...
normal
{ "blob_id": "c4898f3298c2febed476f99fe08bc5386527a47e", "index": 9344, "step-1": "<mask token>\n", "step-2": "<mask token>\nif openFileDialog.ShowModal() == wx.ID_CANCEL:\n raise ValueError('HDF5 file is not selected')\n<mask token>\ndel app\nwith h5py.File(hist_filename, 'r') as F:\n for histogram in F[...
[ 0, 1, 2, 3, 4 ]
from .start_node import StartNode from .character_appearance import CharacterAppearance from .character_disappearance import CharacterDisappearance from .replica import Replica from .end_node import EndNode from .choice import Choice from .set_landscape import SetLandscape from .add_item import AddItem from .switch_by_...
normal
{ "blob_id": "cd6e15daa2360ead47f0bac95843b1c030164996", "index": 6879, "step-1": "<mask token>\n", "step-2": "from .start_node import StartNode\nfrom .character_appearance import CharacterAppearance\nfrom .character_disappearance import CharacterDisappearance\nfrom .replica import Replica\nfrom .end_node impor...
[ 0, 1 ]
from torch.utils.data import IterableDataset, DataLoader from torch import nn from torch.nn import functional as F from triplet_training_generator import get_train_test_apikeys, training_generator from pathlib import Path from transformers import AutoModel import torch from tqdm import tqdm import pandas as pd MEMMAP_...
normal
{ "blob_id": "650f00dd9740d62546eb58724e6e5a74398b3e59", "index": 2522, "step-1": "<mask token>\n\n\nclass DataGenerator(IterableDataset):\n <mask token>\n <mask token>\n\n\nclass CrossEncoderModel(torch.nn.Module):\n\n def __init__(self):\n super(CrossEncoderModel, self).__init__()\n self....
[ 4, 7, 9, 10, 11 ]
#!/usr/bin/env python3 # Licensed under the Apache License, Version 2.0 or the MIT License. # SPDX-License-Identifier: Apache-2.0 OR MIT # Copyright Tock Contributors 2023. # Prints out the source locations of panics in a Tock kernel ELF # # This tool attempts to trace all panic locations in a Tock kernel ELF by # tr...
normal
{ "blob_id": "8c0a4d5a86d9ebd38ea05efb5b5b570368ce1449", "index": 1336, "step-1": "<mask token>\n\n\ndef matches_panic_funcs(name):\n \"\"\"If the passed name contains one of the known panic_functions,\n return the match\n \"\"\"\n for func in panic_functions:\n if func in name:\n re...
[ 7, 10, 11, 12, 13 ]
from gymnasium.spaces import Box, Discrete import numpy as np from typing import Optional, TYPE_CHECKING, Union from ray.rllib.env.base_env import BaseEnv from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.tf.tf_action_dist import Categorical,...
normal
{ "blob_id": "b2b47b394eadebda5c51e89abd27832f9dbd4c8c", "index": 4193, "step-1": "<mask token>\n\n\n@PublicAPI\nclass ParameterNoise(Exploration):\n <mask token>\n\n def __init__(self, action_space, *, framework: str, policy_config: dict,\n model: ModelV2, initial_stddev: float=1.0, random_timesteps...
[ 16, 17, 20, 21, 22 ]
from django.urls import path from .views import PasswordList urlpatterns = [ path('', PasswordList.as_view()), ]
normal
{ "blob_id": "0f3430cbfc928d26dc443fde518881923861f2e3", "index": 3188, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', PasswordList.as_view())]\n", "step-3": "from django.urls import path\nfrom .views import PasswordList\nurlpatterns = [path('', PasswordList.as_view())]\n", "st...
[ 0, 1, 2, 3 ]
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # # Code generated by aaz-dev-tools # --------------------------------...
normal
{ "blob_id": "8197d918b86f0e38fb4320434b61aa4186853af9", "index": 1131, "step-1": "<mask token>\n\n\n@register_command('sig gallery-application version show')\nclass Show(AAZCommand):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ...
[ 5, 8, 9, 10, 16 ]
"""Base class for an array of annotated genomic regions.""" import logging from typing import Callable, Dict, Iterable, Iterator, Mapping, Optional, Sequence, Union from collections import OrderedDict import numpy as np import pandas as pd from .chromsort import sorter_chrom from .intersect import by_ranges, into_ran...
normal
{ "blob_id": "0b833276ca10118f2d60e229ff03400b03915958", "index": 2429, "step-1": "<mask token>\n\n\nclass GenomicArray:\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, data_table: Optional[Union[Sequence, pd.DataFrame]],\n meta_dict: Optional[Mapping]=None):\n if dat...
[ 36, 38, 48, 49, 55 ]
# coding: utf-8 # In[50]: ## Description ## Adds the Fibonacci numbers smaller than 4 million ## Weekly Journal ## When using while True, "break" MUST be used to avoid infinite loops ## Questions ## None fib=[1,2] counter=1 while True: if fib[counter]>4000000: flag=0 break else: f...
normal
{ "blob_id": "e2572b48f7183353ba2aab0500130dc8a71a0b22", "index": 5286, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n if fib[counter] > 4000000:\n flag = 0\n break\n else:\n fib.append(fib[counter] + fib[counter - 1])\n counter += 1\n<mask token>\nprint(tot...
[ 0, 1, 2, 3 ]
import pandas as pd import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ['SimHei'] def get_ratings(file_path): # 图书的ISBN中可能包含字符,所以在使用pandas读取文件时,需要指定编码 ratings = pd.read_table(file_path, header=0, sep=';', encoding='ISO-8859-1') print('前5条数据:\n{}\n'.format(rating...
normal
{ "blob_id": "be5178f013e639d5179ed1af380dd7a63044bff2", "index": 5636, "step-1": "<mask token>\n\n\ndef get_ratings(file_path):\n ratings = pd.read_table(file_path, header=0, sep=';', encoding='ISO-8859-1'\n )\n print('前5条数据:\\n{}\\n'.format(ratings.head(5)))\n print('总的数据条数:\\n{}\\n'.format(rati...
[ 1, 2, 3, 4, 5 ]
from introduction import give_speech from staring import stare_at_people from dow_jones import visualize_dow_jones from art_critic import give_art_critiques from hipster import try_hipster_social_interaction from empathy import share_feelings_with_everyone from slapstick import perform_slapstick_humor from ending impor...
normal
{ "blob_id": "d218b72d1992a30ad07a1edca1caf04b7b1985f6", "index": 7834, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef performance():\n give_speech()\n visualize_dow_jones()\n give_art_critiques()\n stare_at_people()\n try_hipster_social_interaction()\n share_feelings_with_everyo...
[ 0, 1, 2, 3 ]
import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart import base64 import configobj import datetime import os config = configobj.ConfigObj('.env') port = 2525 smtp_server = "smtp.mailtrap.io" login = config['SMTP_USERNAME'] password = config['SMTP_PASSWORD'] sender_email...
normal
{ "blob_id": "a21ac29911931bb71460175cba584e0011fa2ece", "index": 1055, "step-1": "<mask token>\n\n\ndef send():\n global last_index_sent\n global last_sent\n DIR = './videos'\n videosToSend = len([name for name in os.listdir(DIR) if os.path.isfile(\n os.path.join(DIR, name))])\n for i in ra...
[ 1, 2, 3, 4, 5 ]
from django.shortcuts import render # Create your views here. def test_petite_vue(request): return render(request, 'petite_vue_app/test-form.html')
normal
{ "blob_id": "709f2425bc6e0b0b650fd6c657df6d85cfbd05fe", "index": 84, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_petite_vue(request):\n return render(request, 'petite_vue_app/test-form.html')\n", "step-3": "from django.shortcuts import render\n\n\ndef test_petite_vue(request):\n r...
[ 0, 1, 2, 3 ]
from django.db import models from django.contrib.auth.models import User from django.core.validators import MaxValueValidator, MinValueValidator class Person(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='person') age = models.PositiveSmallIntegerField() bio = mode...
normal
{ "blob_id": "6de9fffd91d2f7602f7c681253211077704ba8c4", "index": 2039, "step-1": "<mask token>\n\n\nclass Product(models.Model):\n title = models.CharField(max_length=32)\n description = models.TextField(max_length=360)\n price = models.IntegerField()\n image = models.CharField(max_length=255, null=T...
[ 6, 7, 9, 10, 12 ]
from Bio.PDB import * import urllib.request import numpy as np import pandas as pd from math import sqrt import time import os import heapq from datetime import datetime dir_path = os.getcwd() peptidasesList = pd.read_csv("./MCSA_EC3.4_peptidases.csv") peptidasesList = peptidasesList[peptidasesList.iloc[:, 4] == "res...
normal
{ "blob_id": "67b1cdfa514aac4fdac3804285ec8d0aebce944d", "index": 6068, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(len(peptidasesList))\n<mask token>\nfor i in range(len(peptidasesList)):\n if peptidasesList.loc[i, 'PDB'] not in bindingSiteDic:\n bindingSiteDic[peptidasesList.loc[i, 'P...
[ 0, 1, 2, 3, 4 ]
from bs4 import BeautifulSoup import requests import pymongo client = pymongo.MongoClient('localhost', 27017) ku = client['ku'] url_list1 = ku['url_list_index'] start_url="http://news.ccsu.cn/index.htm" url_host="http://news.ccsu.cn/" def get_channel_urls(url): wb_data = requests.get(url) wb_data.encoding = 'ut...
normal
{ "blob_id": "4791b210f328dff5d48ff5afc381a98a5a1a2b7b", "index": 1969, "step-1": "<mask token>\n\n\ndef get_channel_urls(url):\n wb_data = requests.get(url)\n wb_data.encoding = 'utf-8'\n soup = BeautifulSoup(wb_data.text, 'lxml')\n links = soup.select('body > div.navWrap.clearfix > div > ul > li > a...
[ 1, 2, 3, 4, 5 ]
# Write a program to accept a no & count number of zeros in it.(int=32bits) def countOfZeros(num): cnt = 0 while(num!=0): cnt+=1 num = num&(num-1) return (32-cnt) def main(): num = eval(input('Enter number to count zeros in it\'s binary: ')) print('Assumung int...
normal
{ "blob_id": "7affd79fb0bb47283bbd9a7fbcaa0ba43aa8e6a6", "index": 106, "step-1": "<mask token>\n", "step-2": "def countOfZeros(num):\n cnt = 0\n while num != 0:\n cnt += 1\n num = num & num - 1\n return 32 - cnt\n\n\n<mask token>\n", "step-3": "def countOfZeros(num):\n cnt = 0\n w...
[ 0, 1, 2, 3, 4 ]
# This simulation obtains dose on a cylindical disk phantom at various # distances from a 14MeV photon source. Dose in millisieverts is found # and compared to the yearly limit # The model is built to have a human tissue and human height and volume which # is typically referred to as a phantom. # source details based...
normal
{ "blob_id": "28bf11cb4205dd186b84cc7b7c8b9009f35fe408", "index": 7415, "step-1": "<mask token>\n", "step-2": "<mask token>\nmat_tissue.add_element('O', 0.079013)\nmat_tissue.add_element('C', 0.32948)\nmat_tissue.add_element('H', 0.546359)\nmat_tissue.add_element('N', 0.008619)\nmat_tissue.add_element('Mg', 0.0...
[ 0, 1, 2, 3, 4 ]
from datetime import datetime from unittest import TestCase from vpnmupd import versions class TestClass01(TestCase): """Software dependency versions compared""" def setUp(self) -> None: super().setUp() self.any_string = "Some string containing v1.1.1" def test_case01(self): """...
normal
{ "blob_id": "21d2de5719fafd94605f31bc07231644f4be18c5", "index": 8749, "step-1": "<mask token>\n\n\nclass TestClass01(TestCase):\n <mask token>\n <mask token>\n\n def test_case01(self):\n \"\"\"Version extraction\"\"\"\n version = versions.extract_version(self.any_string)\n self.ass...
[ 4, 5, 8, 9, 10 ]
import errno import os import shutil from calendar import monthrange from datetime import datetime, timedelta from pavilion import output from pavilion import commands from pavilion.status_file import STATES from pavilion.test_run import TestRun, TestRunError, TestRunNotFoundError class CleanCommand(commands.Command...
normal
{ "blob_id": "18aafb71d7e6f5caa2f282126c31eb052c08ad3c", "index": 4307, "step-1": "<mask token>\n\n\nclass CleanCommand(commands.Command):\n <mask token>\n\n def __init__(self):\n super().__init__('clean', 'Clean up Pavilion working directory.',\n short_help='Clean up Pavilion working dire...
[ 4, 5, 6, 7, 8 ]
# module for comparing stats and making recommendataions """ Read team names from user input, retrieve features of teams from MySQL DB, compute odds of winning and recommend features to care """ import numpy as np import pandas as pd import matplotlib.pyplot as plt import pymysql as mdb def FeatureImprove(tgtName, yo...
normal
{ "blob_id": "e5f8301ae22e99c967b2ff3d791379deba7d154a", "index": 2341, "step-1": "# module for comparing stats and making recommendataions\n\"\"\"\nRead team names from user input, retrieve features of teams from MySQL DB, compute odds of winning and recommend features to care\n\"\"\"\n\nimport numpy as np\nimpo...
[ 0 ]
def create_meme(word): return f'this is your meme NEW VERSION {word}'
normal
{ "blob_id": "32b3e65add5fb44320898b682e8f94f1460a32e7", "index": 628, "step-1": "<mask token>\n", "step-2": "def create_meme(word):\n return f'this is your meme NEW VERSION {word}'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
# Game Tebak Angka from random import randint nyawa = 3 angka_rahasia = randint(0,10) limit = 0 print(f"Selamat datang di Game Tebak angka") while nyawa > limit: print(f"Percobaan anda tersisa {nyawa}") jawaban = int(input("Masukkan angka 0-10 = ")) if jawaban == angka_rahasia: ...
normal
{ "blob_id": "d4b01b015723950a4d8c3453d736cd64f306d27b", "index": 2940, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(f'Selamat datang di Game Tebak angka')\nwhile nyawa > limit:\n print(f'Percobaan anda tersisa {nyawa}')\n jawaban = int(input('Masukkan angka 0-10 = '))\n if jawaban == ang...
[ 0, 1, 2, 3, 4 ]
''' Confeccionar un programa que genere un número aleatorio entre 1 y 100 y no se muestre. El operador debe tratar de adivinar el número ingresado. Cada vez que ingrese un número mostrar un mensaje "Gano" si es igual al generado o "El número aleatorio el mayor" o "El número aleatorio es menor". Mostrar cuando gana el j...
normal
{ "blob_id": "8498ba69e4cc5c5f480644ac20d878fb2a632bee", "index": 5128, "step-1": "<mask token>\n\n\ndef generar_numero_aleatorio():\n return random.randint(1, 100)\n\n\ndef es_el_numero(resp_usuario, resp_correc):\n return resp_usuario == resp_correc\n\n\ndef numero_dado_es_mayor(resp_usuario, resp_correc)...
[ 5, 6, 7, 9, 10 ]
# [백준] https://www.acmicpc.net/problem/11053 가장 긴 증가하는 부분 수열 # 일단 재귀식으로 풀어보기 # 이분탐색 어떻게 할 지 모르겠다 import sys N = int(sys.stdin.readline().strip()) A = list(map(int, sys.stdin.readline().split())) def recur(): if A[i] < A[i-1]:
normal
{ "blob_id": "afccf460bcf04f38b8c66177c86debd39a1b165f", "index": 5159, "step-1": "# [백준] https://www.acmicpc.net/problem/11053 가장 긴 증가하는 부분 수열\n# 일단 재귀식으로 풀어보기\n# 이분탐색 어떻게 할 지 모르겠다\n\nimport sys\n\nN = int(sys.stdin.readline().strip())\nA = list(map(int, sys.stdin.readline().split()))\n\ndef recur():\n\n if A...
[ 0 ]
import os, sys sys.path.append('./Pytorch-UNet/') import torch from torch import optim import torchvision.transforms as transforms import torchvision.datasets as dset import wandb from datasets import parse_dataset_args, create_dataset from wt_utils import wt, create_filters, load_checkpoint, load_weights from argumen...
normal
{ "blob_id": "fbd5c7fa335d6bde112e41a55d15aee31e3ebaf7", "index": 2759, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('./Pytorch-UNet/')\n<mask token>\nif __name__ == '__main__':\n logger = Logger()\n torch.backends.cudnn.benchmark = True\n args = parse_args()\n logger.update_...
[ 0, 1, 2, 3 ]
# coding: utf-8 # In[1]: import pandas as pd import numpy as np import itertools # Save a nice dark grey as a variable almost_black = '#262626' import matplotlib import seaborn as sns import matplotlib.pyplot as plt from matplotlib.colors import ListedColormap sns.set() get_ipython().magic('matplotlib inline') # I...
normal
{ "blob_id": "f2786e445bdf66cf6bb66f4cde4c7b2bf819d8aa", "index": 3299, "step-1": "<mask token>\n", "step-2": "<mask token>\nsns.set()\nget_ipython().magic('matplotlib inline')\n<mask token>\nif header_included:\n header = 0\n<mask token>\nfor item in combinations:\n index = ax[i]\n x_vis = X[:, [featu...
[ 0, 1, 2, 3, 4 ]
"""You are given a string . Your task is to find out if the string contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters.""" s = raw_input() print(any(i.isalnum()for i in s)) print(any(i.isalpha()for i in s)) print(any(i.isdigit()for i in s)) print(any(i.islow...
normal
{ "blob_id": "f29fa3d796d9d403d6bf62cb28f5009501c55545", "index": 3650, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(any(i.isalnum() for i in s))\nprint(any(i.isalpha() for i in s))\nprint(any(i.isdigit() for i in s))\nprint(any(i.islower() for i in s))\nprint(any(i.isupper() for i in s))\n<mask t...
[ 0, 1, 2, 3 ]
# Generated by Django 3.1.6 on 2021-04-03 20:16 import django.contrib.postgres.fields from django.db import migrations, models import enrolments.validators class Migration(migrations.Migration): dependencies = [ ("enrolments", "0007_merge_20210320_1853"), ] operations = [ migrations.Add...
normal
{ "blob_id": "dbea2b1555368460b7d14369d2dfe4f0a01f9e4f", "index": 8423, "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 = [('enrolments'...
[ 0, 1, 2, 3, 4 ]
import re class Zout: def __init__(self, aline): self.Str = aline self.Var = '' self.StN = '' self.ZN = '' self.ZName = '' self.Motion = '' self.Ztype = '' self.tozout(aline) def tozout(self, aline): """transform station sta...
normal
{ "blob_id": "71ebc6e9218085e887eda7843b5489837ed45c97", "index": 880, "step-1": "<mask token>\n\n\nclass Zouts:\n <mask token>\n\n def search(self, StN, ZN, Motion):\n for elem in self.elements:\n print('elem:')\n print(str(type(elem.StN)) + str(type(StN)))\n print(e...
[ 3, 6, 7, 10, 11 ]
# 10.13.20 - sjg # Exercise 15 - solution A # Write a function called greatestCommomFactor that, #given two distinct positive integers, #returns the greatest common factor of those two values #Input: greatestCommonFactor(9,12) #Output: 3 #Input: greatestCommonFactor(6,18) #Output: 6 #Input: greatestCommonFactor(11...
normal
{ "blob_id": "a3f6ea649fc5e60b0f8353b1404912d060686b99", "index": 9550, "step-1": "<mask token>\n", "step-2": "def greatestCommonFactor(posInt1, posInt2):\n range_posInt1 = list(range(1, posInt1 + 1))\n factors_posInt1 = []\n for i in range_posInt1:\n if posInt1 % i == 0:\n factors_po...
[ 0, 1, 2, 3 ]
from room import Room from player import Player from item import Item # Declare all the rooms room = { 'outside': Room("Outside Cave Entrance", "North of you, the cave mount beckons"), 'foyer': Room("Foyer", """Dim light filters in from the south. Dusty passages run north and east."""...
normal
{ "blob_id": "beb536b6d8883daaa7e41da03145dd98aa223cbf", "index": 5036, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n print('\\nPlayer Items:')\n for item in player.items:\n print('\\t', item)\n print('Room - ', player.current_room)\n print('Items in Room:')\n for item...
[ 0, 1, 2, 3, 4 ]
def watch(): print("시청하다") watch() print("tv.py의 module 이름은",__name__) #name은 __main__으로 나옴
normal
{ "blob_id": "b9622bede471c76ae36d3f59130d2be113310d4c", "index": 7045, "step-1": "<mask token>\n", "step-2": "def watch():\n print('시청하다')\n\n\n<mask token>\n", "step-3": "def watch():\n print('시청하다')\n\n\nwatch()\nprint('tv.py의 module 이름은', __name__)\n", "step-4": "def watch():\n print(\"시청하다\")\...
[ 0, 1, 2, 3 ]
""" Tests based on: https://github.com/pydata/xarray/blob/071da2a900702d65c47d265192bc7e424bb57932/xarray/tests/test_backends_file_manager.py """ import concurrent.futures import gc import pickle from unittest import mock import pytest from rioxarray._io import URIManager def test_uri_manager_mock_write(): mock...
normal
{ "blob_id": "8fe71e87512dfd2ccfcd21c9c175cb50274d9661", "index": 1867, "step-1": "<mask token>\n\n\ndef test_uri_manager_mock_write():\n mock_file = mock.Mock()\n opener = mock.Mock(spec=open, return_value=mock_file)\n manager = URIManager(opener, 'filename')\n f = manager.acquire()\n f.write('con...
[ 5, 6, 7, 8, 9 ]
from django.db import models #from ingredients.models import * class Unit(models.Model): short_name = models.CharField(max_length=20) full_name = models.CharField(max_length=255, null=True) weight_in_grams = models.FloatField(default=1.0) def __str__(self): return f"{self.short_name}"
normal
{ "blob_id": "fa880adcb9f009ffc206de59e8284ac6350fef4c", "index": 5948, "step-1": "<mask token>\n\n\nclass Unit(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Unit(models.Model):\n <mask token>\n <mask token>\n <mask token>\...
[ 1, 2, 3, 4, 5 ]
vozrast=int(input("сколько вам лет?")) print ("через 10 лет вам бóдет", vozrast+10)
normal
{ "blob_id": "8e3f23733235d73fab14e80ee0a3706ae351c7a2", "index": 4525, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('через 10 лет вам бóдет', vozrast + 10)\n", "step-3": "vozrast = int(input('сколько вам лет?'))\nprint('через 10 лет вам бóдет', vozrast + 10)\n", "step-4": "vozrast=int(input(\...
[ 0, 1, 2, 3 ]
import pymongo import redis import json from time import time user_timeline_mongodb = "mongodb://user-timeline-mongodb.sdc-socialnetwork-db.svc.cluster.local:27017/" user_timeline_redis = "user-timeline-redis.sdc-socialnetwork-db.svc.cluster.local" def handle(req): """handle a request to the function Args: ...
normal
{ "blob_id": "37969899aa646f4cdd7a5513f17d26b334870f1b", "index": 6598, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef handle(req):\n \"\"\"handle a request to the function\n Args:\n req (str): request body\n \"\"\"\n start = time()\n event = json.loads(req)\n user_id = ev...
[ 0, 1, 2, 3, 4 ]
''' Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Note: A leaf is a node with no children. ''' # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val...
normal
{ "blob_id": "fa081ccd8081f5c3319f482b7d8abd7415d8e757", "index": 1273, "step-1": "'''\nGiven a binary tree, find its maximum depth.\n\nThe maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.\n\nNote: A leaf is a node with no children.\n\n'''\n\n\n\n# Def...
[ 0 ]
import requests seesion = requests.Session() header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.104 Safari/537.36 Core/1.53.3387.400 QQBrowser/9.6.11984.400' } cookie = {'Cookie': '_ga=GA1.2.1866009938.1500885157; xmuuid=XMGUEST-B6484440-71B...
normal
{ "blob_id": "8c652f30cd256912512b6b91d1682af7da0ff915", "index": 8265, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(html.decode('utf-8'))\n", "step-3": "<mask token>\nseesion = requests.Session()\nheader = {'User-Agent':\n 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like...
[ 0, 1, 2, 3 ]
def add_route_distance(routes, cities, source): c = source.split() citykey = c[0] + ':' + c[2] cities.add(c[0]) routes[citykey] = c[4] def get_route_distance(routes, source, dest): if (source+":"+dest in routes): return routes[source+":"+dest] else: return routes[dest+":"+sourc...
normal
{ "blob_id": "810e9e4b18ff8cb388f9e16607b8ab3389a9831d", "index": 7402, "step-1": "<mask token>\n\n\ndef get_route_distance(routes, source, dest):\n if source + ':' + dest in routes:\n return routes[source + ':' + dest]\n else:\n return routes[dest + ':' + source]\n\n\n<mask token>\n", "step...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # Created with YooLiang Technology (侑良科技). # Author: Qi-Liang Wen (温啓良) # Web: http://www.yooliang.com/ # Date: 2015/7/12. from monkey import BasicModel from monkey import Fields class WebInformationModel(BasicModel): class Meta: label_name = { "...
normal
{ "blob_id": "3d55a5b4e332523025f65e5f5859f4633f4ee9a3", "index": 7501, "step-1": "<mask token>\n\n\nclass WebInformationModel(BasicModel):\n\n\n class Meta:\n label_name = {'title': u'通用名稱', 'name': u'識別碼',\n 'domain_registration': u'網域註冊地', 'domain_registration_price':\n u'網域註冊費用...
[ 1, 2, 3, 4, 5 ]
#!/home/liud/anaconda3/envs/python/bin/python # -*- coding: utf-8 -*- ''' 线性回归 公式:W = 1/(xTx) * xT * y ''' #导入的包 import numpy as np from numpy import linalg from numpy import corrcoef from sklearn import linear_model import matplotlib.pyplot as plt #加载数据 def loadDataSet(filename): xList = [] yList = [] with open(...
normal
{ "blob_id": "a6eab1e5e7985de917d707c904fcd90f223c108c", "index": 2559, "step-1": "#!/home/liud/anaconda3/envs/python/bin/python\n# -*- coding: utf-8 -*-\n'''\n\t线性回归\n\t公式:W = 1/(xTx) * xT * y\n'''\n#导入的包\nimport numpy as np\nfrom numpy import linalg\nfrom numpy import corrcoef\nfrom sklearn import linear_model\...
[ 0 ]
__version__ = "alph 1.0"
normal
{ "blob_id": "2c4eb07a32c6903ae31006f42c13c55e6cc42eb5", "index": 5245, "step-1": "<mask token>\n", "step-2": "__version__ = 'alph 1.0'\n", "step-3": "__version__ = \"alph 1.0\"\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
import subprocess from flask import Flask, render_template, request from subprocess import Popen, PIPE, check_output def toggle_relay(value): session = subprocess.Popen("./relay " + value, stdout=PIPE, stderr=PIPE, shell=True) stdout, stderr = session.communicate() if stderr: raise Exception("Error...
normal
{ "blob_id": "18d1722529a63f9a1696b09c40dabb1c68ed55f4", "index": 3423, "step-1": "<mask token>\n\n\ndef toggle_relay(value):\n session = subprocess.Popen('./relay ' + value, stdout=PIPE, stderr=PIPE,\n shell=True)\n stdout, stderr = session.communicate()\n if stderr:\n raise Exception('Err...
[ 2, 3, 4, 5, 6 ]
########################################################### # 2019-02-07: 删除了marginalized prior # ########################################################### import sys,os import numpy as np import matplotlib.pylab as plt from scipy.linalg import eig from scipy.stats import norm, kstest, normaltest # use default col...
normal
{ "blob_id": "ac35672661e1dd0b97567ae4335f537dc69f98f7", "index": 6240, "step-1": "<mask token>\n\n\ndef read_jla_mock(mock_filename):\n fp = open(mock_filename, 'r')\n lines = fp.readlines()\n fp.close()\n jla = []\n for line in lines:\n sn = line.split()\n temp = []\n temp.ap...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Created on Fri Oct 5 17:05:12 2018 @author: Shane """ import math import scipy.integrate as integrate import random import numpy as np import sympy as sym ''' Question 1 plug and play into formula for VC generalization ''' print('Question 1') error = 0.05 for N in [400000,420000,4400...
normal
{ "blob_id": "abe53120a485f608431142c6b9452666fcd72dbf", "index": 7464, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Question 1')\n<mask token>\nfor N in [400000, 420000, 440000, 460000, 480000]:\n print(4 * (2 * N) ** 10 * math.exp(-(1 / 8) * error ** 2 * N))\n<mask token>\nprint('Question 2'...
[ 0, 1, 2, 3, 4 ]
from Crypto.Hash import SHA512 from Crypto.PublicKey import RSA from Crypto import Random from collections import Counter from Tkinter import Tk from tkFileDialog import askopenfilename import ast import os import tkMessageBox from Tkinter import Tk from tkFileDialog import askopenfilename import Tkinter import tkSimpl...
normal
{ "blob_id": "da696961fea72e1482beae73c19b042b94d93886", "index": 1660, "step-1": "<mask token>\n\n\ndef read_file_all(file_name):\n filename = os.path.join(fileDir, str(file_name))\n with open(filename, 'r') as f:\n read_data = f.readlines()\n return read_data\n\n\n<mask token>\n\n\ndef selec...
[ 3, 9, 10, 11, 12 ]
#!/usr/bin/env python import argparse import sys import logging import vafator from vafator.power import DEFAULT_FPR, DEFAULT_ERROR_RATE from vafator.hatchet2bed import run_hatchet2bed from vafator.ploidies import PloidyManager from vafator.annotator import Annotator from vafator.multiallelic_filter import Mul...
normal
{ "blob_id": "1651865f120ba4fe440549567a8d9903e5455788", "index": 5774, "step-1": "<mask token>\n\n\ndef annotator():\n parser = argparse.ArgumentParser(description='vafator v{}'.format(\n vafator.VERSION), formatter_class=argparse.\n ArgumentDefaultsHelpFormatter, epilog=epilog)\n parser.add_...
[ 3, 4, 5, 6, 7 ]
"""4. Начните работу над проектом «Склад оргтехники». Создайте класс, описывающий склад. А также класс «Оргтехника», который будет базовым для классов-наследников. Эти классы — конкретные типы оргтехники (принтер, сканер, ксерокс). В базовом классе определить параметры, общие для приведенных типов. В классах-наследника...
normal
{ "blob_id": "03bc377bef1de7d512b7982a09c255af1d82fb7d", "index": 3905, "step-1": "<mask token>\n\n\nclass Whouse:\n <mask token>\n\n def get_tech_to_whouse(self, equip: Equipment):\n if self.total == self.max_volume:\n raise OverflowError('Склад заполнен!')\n self.storage[self.add_...
[ 9, 11, 12, 16, 17 ]
### we prepend t_ to tablenames and f_ to fieldnames for disambiguity import uuid crud.settings.formstyle="table2cols" ######################################## db.define_table('t_form', Field('id','id', represent=lambda id:SPAN(id,' ',A('view',_href=URL('form_read',args=id)))), Field('f_name', type=...
normal
{ "blob_id": "e2e275c48f28843931412f8e620f1be90289b40c", "index": 8184, "step-1": "<mask token>\n", "step-2": "<mask token>\ndb.define_table('t_form', Field('id', 'id', represent=lambda id: SPAN(id,\n ' ', A('view', _href=URL('form_read', args=id)))), Field('f_name', type\n ='string', label=T('Name')), Fi...
[ 0, 1, 2, 3, 4 ]
STATUS_CHOICES = ( (-1, 'Eliminado'), (0, 'Inactivo'), (1, 'Activo'), ) USERTYPES_CHOICES = () #-- Activation Request Values ACTIVATION_CHOICES = ( (1, 'Activacion'), (2, 'Solicitud Password'), (3, 'Invitacion'), ) #-- Activation Status Values ACTIVATIONSTATUS_CHOICES = ( (-1, 'Expirado...
normal
{ "blob_id": "200552b638d6b1a6879b455837677b82689e0069", "index": 5479, "step-1": "<mask token>\n", "step-2": "STATUS_CHOICES = (-1, 'Eliminado'), (0, 'Inactivo'), (1, 'Activo')\nUSERTYPES_CHOICES = ()\nACTIVATION_CHOICES = (1, 'Activacion'), (2, 'Solicitud Password'), (3,\n 'Invitacion')\nACTIVATIONSTATUS_C...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- """Utilities for reading BEL Script.""" import time from typing import Iterable, Mapping, Optional, Set from .constants import ( ANNOTATION_PATTERN_FMT, ANNOTATION_URL_FMT, NAMESPACE_PATTERN_FMT, NAMESPACE_URL_FMT, format_annotation_list, ) __all__ = [ 'make_knowledge_header', ] de...
normal
{ "blob_id": "46b8d0ba58d4bf17021b05fc03bd480802f65adf", "index": 6132, "step-1": "<mask token>\n\n\ndef make_knowledge_header(name: str, version: Optional[str]=None,\n description: Optional[str]=None, authors: Optional[str]=None, contact:\n Optional[str]=None, copyright: Optional[str]=None, licenses: Optio...
[ 3, 4, 5, 6, 7 ]
# Class 1: Flight which contains the flight number(f_id), its origin and destination, the number of stops between the # origin and destination and the type of airlines(f_type) class Flight(): # INIT CONSTRUCTOR def __init__(self, f_id, f_origin, f_destination, no_of_stops, flight_type, p_id, p_type): s...
normal
{ "blob_id": "95a2f5abb37642651316a8954a4289e5b04e4916", "index": 4357, "step-1": "<mask token>\n\n\nclass Passenger(Person):\n <mask token>\n <mask token>\n\n def __init__(self, p_id, p_type, p_gender, p_name, p_phonenumber, f_id,\n pno, f_origin, f_destination, no_of_stops, flight_type):\n ...
[ 5, 7, 13, 16, 17 ]
print raw_input().count(raw_input())
normal
{ "blob_id": "2d4b0e7b430ffb5d236300079ded4b848e6c6485", "index": 3602, "step-1": "print raw_input().count(raw_input())", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
from __future__ import division import re import sys import six from six.moves import queue import os import io from google.cloud import language from google.cloud.language import enums from google.cloud.language import types from google.cloud import speech as speech1 from google.cloud.speech import enums as enums2 fr...
normal
{ "blob_id": "6868a8b5d36403f1417301acdca5f5dc9e45c682", "index": 9849, "step-1": "<mask token>\n\n\nclass Google_Cloud:\n <mask token>\n\n def sentiment(self):\n google_sentiment = self.client.analyze_sentiment(self.document\n ).document_sentiment\n sent = {}\n sent['sentime...
[ 7, 8, 10, 11, 14 ]
import os from sources.lol.status import LOLServerStatusCollector from util.abstract.feed import Feed from util.abstract.handler import Handler from util.functions.load_json import load_json class LoLServerStatusHandler(Handler): def load_servers(self): servers_filepath = os.path.join(os.path.dirname(__f...
normal
{ "blob_id": "493552469943e9f9f0e57bf92b874c8b67943de5", "index": 6751, "step-1": "<mask token>\n\n\nclass LoLServerStatusHandler(Handler):\n\n def load_servers(self):\n servers_filepath = os.path.join(os.path.dirname(__file__),\n '../../data/lol/status.json')\n return load_json(server...
[ 3, 4, 5, 6 ]
import pandas as pd from bokeh.models import ColumnDataSource, LinearColorMapper, HoverTool from bokeh.plotting import figure from bokeh.transform import transform from sklearn.metrics import confusion_matrix from reporter.settings import COLORS from reporter.metrics import Metric class ConfusionMatrix(Metric): d...
normal
{ "blob_id": "9a2002b5ff0fe41f2b5b568f4c278d4376bf4fb1", "index": 6117, "step-1": "<mask token>\n\n\nclass ConfusionMatrix(Metric):\n <mask token>\n <mask token>\n\n def draw(self, size=400):\n index_label = 'Predicted'\n column_label = 'Actual'\n matrix = self.generate_data()\n ...
[ 2, 3, 4, 5, 6 ]
from django.contrib import admin from django.urls import path from .views import NewsCreateListView, NewsDetailGenericView urlpatterns = [ path('news/', NewsCreateListView.as_view()), path('news_detailed/<int:id>/', NewsDetailGenericView.as_view()), ]
normal
{ "blob_id": "afdb14d60374049753b3c980c717a13456c7ff5c", "index": 9745, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('news/', NewsCreateListView.as_view()), path(\n 'news_detailed/<int:id>/', NewsDetailGenericView.as_view())]\n", "step-3": "from django.contrib import admin\nfrom...
[ 0, 1, 2, 3 ]
#!/bin/python3 def solveMeFirst(a,b): return a + b print(solveMeFirst(int(input()),int(input())))
normal
{ "blob_id": "5d55c586c57de8f287d9f51f0cb1f188c8046c29", "index": 2977, "step-1": "<mask token>\n", "step-2": "def solveMeFirst(a, b):\n return a + b\n\n\n<mask token>\n", "step-3": "def solveMeFirst(a, b):\n return a + b\n\n\nprint(solveMeFirst(int(input()), int(input())))\n", "step-4": "#!/bin/pytho...
[ 0, 1, 2, 3 ]