code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import os, time
def counter(count): # run in new process
for i in range(count):
time.sleep(1) # simulate real work
print('[%s] => %s' % (os.getpid(), i))
import pdb;pdb.set_trace()
for i in range(5):
pid= os.fork()
if pid !... | normal | {
"blob_id": "fd564d09d7320fd444ed6eec7e51afa4d065ec4d",
"index": 6945,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef counter(count):\n for i in range(count):\n time.sleep(1)\n print('[%s] => %s' % (os.getpid(), i))\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef counter... | [
0,
1,
2,
3,
4
] |
from tkinter import *
global math
root = Tk()
root.title("Calculator")
e = Entry(root,width=60,borderwidth=5)
e.grid(columnspan=3)
def button_click(number):
#e.delete(0, END)
current = e.get()
e.delete(0, END)
e.insert(0, str(current) + str(number))
def button_clear():
e.delete(0, END)
... | normal | {
"blob_id": "e6320bc1c344c87818a4063616db0c63b7b8be49",
"index": 1294,
"step-1": "<mask token>\n\n\ndef button_click(number):\n current = e.get()\n e.delete(0, END)\n e.insert(0, str(current) + str(number))\n\n\ndef button_clear():\n e.delete(0, END)\n\n\ndef button_add():\n first_number = e.get()... | [
7,
8,
9,
10,
11
] |
<|reserved_special_token_0|>
def train_model(model_name):
if model_name == 'LinearRegression':
model = LinearRegression()
model.fit(X_train, y_train)
score = model.score(X_test, y_test)
print(score)
if model_name == 'Lasso':
model = Lasso(alpha=1)
model.fit(X_tr... | flexible | {
"blob_id": "539726df0e631c7a8edabf50fd739ee0497e3e97",
"index": 5557,
"step-1": "<mask token>\n\n\ndef train_model(model_name):\n if model_name == 'LinearRegression':\n model = LinearRegression()\n model.fit(X_train, y_train)\n score = model.score(X_test, y_test)\n print(score)\n ... | [
1,
2,
3,
4,
5
] |
#-*- coding:UTF-8 -*-
year = int(input('请输入一个年份:'))
"""
if(year % 4) == 0:
if(year % 100) == 0:
if(year % 400) == 0:
print('{0}是润年'.format(year))
else:
print('{0}不是润年'.format(year))
else:
print('{0}是润年'.format(year))
else:
print('{0}不是润年'.format(year)) ... | normal | {
"blob_id": "78178ec8474a3deb876ab7d3950cd427d7a795d5",
"index": 2218,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif year % 4 == 0 and year % 100 != 0 or year % 400 == 0:\n print('{0}是润年'.format(year))\nelse:\n print('{0}不是润年'.format(year))\n",
"step-3": "year = int(input('请输入一个年份:'))\n<mask ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class PixelCNN(nn.Module):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class PixelCNN(nn.Module):
<|reserved_special_token_0|>
def forward(self, x):
"""
Args:
x: [batc... | flexible | {
"blob_id": "3185b6b1902099caed66ce6f97cd1b9940261fc1",
"index": 7533,
"step-1": "<mask token>\n\n\nclass PixelCNN(nn.Module):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass PixelCNN(nn.Module):\n <mask token>\n\n def forward(self, x):\n \"\"\"\n Args:\n ... | [
1,
2,
3,
4,
5
] |
from .models import Stock
from .serializers import StockSerializer
from rest_framework import generics
class StockListCreate(generics.ListCreateAPIView):
queryset = Stock.objects.all()
serializer_class = StockSerializer
| normal | {
"blob_id": "9adf18b3a65bf58dd4c22a6fe026d0dd868533fb",
"index": 5468,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass StockListCreate(generics.ListCreateAPIView):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass StockListCreate(generics.ListCreateAPIView):\n query... | [
0,
1,
2,
3
] |
times = np.linspace(0.0, 10.0, 100)
result = mesolve(H, psi0, times, [np.sqrt(0.05) * sigmax()], [sigmaz(), sigmay()])
fig, ax = plt.subplots()
ax.plot(times, result.expect[0]) # doctest: +SKIP
ax.plot(times, result.expect[1]) # doctest: +SKIP
ax.set_xlabel('Time') # doctest: +SKIP
ax.set_ylabel('Expectation values') #... | normal | {
"blob_id": "8474205d49aef2d18755fc1a25a82718962f4120",
"index": 6912,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nax.plot(times, result.expect[0])\nax.plot(times, result.expect[1])\nax.set_xlabel('Time')\nax.set_ylabel('Expectation values')\nax.legend(('Sigma-Z', 'Sigma-Y'))\nplt.show()\n",
"step-3... | [
0,
1,
2,
3
] |
from enum import Enum
from typing import List, Optional
from pydantic import BaseModel
class Sizes(str, Enum):
one_gram = "1g"
two_and_half_gram = "2.5g"
one_ounce = "1oz"
five_ounce = "5oz"
ten_ounce = "10oz"
class PriceSort(str, Enum):
gte = "gte"
lte = "lte"
class Metals(str, Enum):... | normal | {
"blob_id": "442c6c4894fc01d0f8142f3dcedfd51ba57aedd1",
"index": 3304,
"step-1": "<mask token>\n\n\nclass Metals(str, Enum):\n gold = 'gold'\n silver = 'silver'\n\n\nclass PriceFilter(BaseModel):\n type: PriceSort\n price: float\n\n\nclass ProductSearch(BaseModel):\n price: Optional[PriceFilter]\n... | [
4,
5,
8,
9,
10
] |
#!/usr/bin/env python3
import unittest
import solution
class TestMethods(unittest.TestCase):
def LinkedListFromArray(self, values):
if len(values) > 0:
headNode = solution.ListNode(values[0], None)
tailPtr = headNode
if len(values) > 1:
for value in val... | normal | {
"blob_id": "2a3f9c4518df337cfc5e4b1816e7b2b4af62c101",
"index": 8020,
"step-1": "<mask token>\n\n\nclass TestMethods(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def checkLinkedListsAreEqual(self, headNodeA, headNodeB):\n valuesA = self.linkedListToArray(headNodeA)\n ... | [
6,
8,
9,
10,
12
] |
from django.contrib import admin, messages
from django.conf.urls import url
from django.shortcuts import render
from django.contrib.sites.models import Site
from django.http import HttpResponseRedirect, HttpResponse
from website_data.models import *
from website_data.forms import *
import logging
# Get an instance of ... | normal | {
"blob_id": "614d6484678890df2ae0f750a3cad51a2b9bd1c6",
"index": 2315,
"step-1": "<mask token>\n\n\nclass WebsitePreferencesInstanceInline(admin.TabularInline):\n model = WebsitePreferences\n\n\nclass SiteAdmin(admin.ModelAdmin):\n list_filter = 'domain', 'name'\n inlines = [CustomSiteInstanceInline, We... | [
4,
10,
12,
14,
15
] |
class A():
def m(self):
print("Class A")
class B():
def m(self):
print("Class B")
class C(B, A):
print("class C")
obj1 = C()
obj1.m()
print(C.mro()) # Method Resolution Order based on convention of "OBJECT" super class
| normal | {
"blob_id": "3d59b8d6a34935ff332028443276f161430a981c",
"index": 9687,
"step-1": "<mask token>\n\n\nclass B:\n <mask token>\n\n\nclass C(B, A):\n print('class C')\n\n\n<mask token>\n",
"step-2": "class A:\n <mask token>\n\n\nclass B:\n\n def m(self):\n print('Class B')\n\n\nclass C(B, A):\n ... | [
2,
4,
6,
7,
8
] |
<|reserved_special_token_0|>
class NetworkDevice:
<|reserved_special_token_0|>
def __init__(self, **kwargs):
log.info('__init__')
self.ip = ''
self.username = ''
self.password = ''
self.device_type = ''
self.port = 22
self.timeout = 10
self._pro... | flexible | {
"blob_id": "87baaf4a1b48fa248c65d26cc44e819a2ede1140",
"index": 3736,
"step-1": "<mask token>\n\n\nclass NetworkDevice:\n <mask token>\n\n def __init__(self, **kwargs):\n log.info('__init__')\n self.ip = ''\n self.username = ''\n self.password = ''\n self.device_type = '... | [
9,
10,
12,
14,
15
] |
<|reserved_special_token_0|>
class AirflowSecurityManager(SecurityManagerOverride, SecurityManager,
LoggingMixin):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "47cee0c659976a2b74e2bb07f6c4d622ceab7362",
"index": 3866,
"step-1": "<mask token>\n\n\nclass AirflowSecurityManager(SecurityManagerOverride, SecurityManager,\n LoggingMixin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask tok... | [
33,
36,
40,
47,
49
] |
# Software Name: MOON
# Version: 5.4
# SPDX-FileCopyrightText: Copyright (c) 2018-2020 Orange and its contributors
# SPDX-License-Identifier: Apache-2.0
# This software is distributed under the 'Apache License 2.0',
# the text of which is available at 'http://www.apache.org/licenses/LICENSE-2.0.txt'
# or see the "LI... | normal | {
"blob_id": "af35075eaca9bba3d6bdb73353eaf944869cdede",
"index": 799,
"step-1": "<mask token>\n\n\ndef delete_pdp(pdp_id):\n from moon_manager.db_driver import PDPManager\n PDPManager.delete_pdp('', pdp_id)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef delete_pdp(pdp_id):\n from moon_manager.... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
@cache_control(public=True, max_age=ONE_MONTH)
def index(request):
return render(request, 'ajaxornot/index.html')
<|reserved_special_token_0|>
@cache_control(public=True, max_age=ONE_MONTH)
def view1(request):
context = {'items': get_data()}
return render(request, 'ajaxorn... | flexible | {
"blob_id": "e90fb3b6009dd4fb780649c04398b361fa1ae195",
"index": 8489,
"step-1": "<mask token>\n\n\n@cache_control(public=True, max_age=ONE_MONTH)\ndef index(request):\n return render(request, 'ajaxornot/index.html')\n\n\n<mask token>\n\n\n@cache_control(public=True, max_age=ONE_MONTH)\ndef view1(request):\n ... | [
7,
9,
14,
15,
17
] |
"""Woma objects for dealing with HTTP.
Request and Response inherit from webob's Request and Response objects, so see
http://docs.webob.org/en/latest/ for full documentation. The only things
documented here are the customizations.
"""
from webob import Request as BaseRequest
from webob import Response as BaseResponse... | normal | {
"blob_id": "ca11e9cf0bcfcbd714c45b5c95bd2c2044b65909",
"index": 384,
"step-1": "<mask token>\n\n\nclass Client(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Request(BaseRequest):\n \"\"\"A webob.Request with additional properti... | [
8,
11,
12,
14,
16
] |
operation = input('operation type: ').lower()
num1 = input("First number: ")
num2 = input("First number: ")
try:
num1, num2 = float(num1), float(num2)
if operation == 'add':
result = num1 + num2
print(result)
elif operation == 'subtract':
result = num1 - num2
print(result)
... | normal | {
"blob_id": "bafb6c09ecd0017428441e109733ebcb189863ad",
"index": 3598,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n num1, num2 = float(num1), float(num2)\n if operation == 'add':\n result = num1 + num2\n print(result)\n elif operation == 'subtract':\n result = num1 ... | [
0,
1,
2,
3
] |
# Copyright Contributors to the Pyro project.
# SPDX-License-Identifier: Apache-2.0
from collections import namedtuple
from functools import partial
import inspect
from itertools import product
import math
import os
import numpy as np
from numpy.testing import assert_allclose, assert_array_equal
import pytest
import ... | normal | {
"blob_id": "c5e7fdcbd4a9281597a35a180f2853caac68f811",
"index": 7562,
"step-1": "<mask token>\n\n\ndef my_kron(A, B):\n D = A[..., :, None, :, None] * B[..., None, :, None, :]\n ds = D.shape\n newshape = *ds[:-4], ds[-4] * ds[-3], ds[-2] * ds[-1]\n return D.reshape(newshape)\n\n\ndef _identity(x):\n... | [
97,
100,
123,
125,
137
] |
import oneflow as flow
import torch
def convert_torch_to_flow(model, torch_weight_path, save_path):
parameters = torch.load(torch_weight_path)
new_parameters = dict()
for key, value in parameters.items():
if "num_batches_tracked" not in key:
val = value.detach().cpu().numpy()
ne... | normal | {
"blob_id": "8a3cf65550893367b9001369111fa19a3e998d82",
"index": 9589,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef convert_torch_to_flow(model, torch_weight_path, save_path):\n parameters = torch.load(torch_weight_path)\n new_parameters = dict()\n for key, value in parameters.items():... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Config(object):
_DEFAULT = {'url': 'http://localhost:9999/notify', 'title':
'IRC Notification', 'activate_label': '', 'sound': ''}
def __init__(self):
self._opts = {}
for opt, value in self._DEFAULT.items():
if not weechat.config_is_set_p... | flexible | {
"blob_id": "0ae9ad7af26e3d19f2d3967c02611503c32aea70",
"index": 2593,
"step-1": "<mask token>\n\n\nclass Config(object):\n _DEFAULT = {'url': 'http://localhost:9999/notify', 'title':\n 'IRC Notification', 'activate_label': '', 'sound': ''}\n\n def __init__(self):\n self._opts = {}\n f... | [
5,
7,
9,
10,
12
] |
from django.contrib import admin
from .models import Sport
from .models import Action
admin.site.register(Sport)
admin.site.register(Action)
| normal | {
"blob_id": "ab38371ee3941e214344497b7e56786908a9b3d1",
"index": 2236,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(Sport)\nadmin.site.register(Action)\n",
"step-3": "from django.contrib import admin\nfrom .models import Sport\nfrom .models import Action\nadmin.site.register(Sport... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(1, 5):
with open('Desktop/' + str(i) + '.log', 'r') as r:
with open('Desktop/' + str(i) + '-clean.log', 'a+') as w:
for line in r:
if not any(s in line for s in no_list):
... | flexible | {
"blob_id": "f14a8d0d51f0baefe20b2699ffa82112dad9c38f",
"index": 6582,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, 5):\n with open('Desktop/' + str(i) + '.log', 'r') as r:\n with open('Desktop/' + str(i) + '-clean.log', 'a+') as w:\n for line in r:\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
{'name': 'EDC Analytic Entry', 'depends': ['stock_account',
'purchase_stock', 'account_accountant'], 'description': '\n ',
'author': 'Ejaftech', 'data': ['views/account_move_view.xml']}
<|reserved_special_token_1|>
# -*- coding: utf-8 -*-
{
'... | flexible | {
"blob_id": "797e7c1b3e8b41a167bfbedfb6a9449e6426ba22",
"index": 8570,
"step-1": "<mask token>\n",
"step-2": "{'name': 'EDC Analytic Entry', 'depends': ['stock_account',\n 'purchase_stock', 'account_accountant'], 'description': '\\n ',\n 'author': 'Ejaftech', 'data': ['views/account_move_view.xml']}\n"... | [
0,
1,
2
] |
# Generated by Django 2.0.3 on 2018-03-24 07:53
import django.core.files.storage
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('printers', '0001_initial'),
('devices', '0002_url'),
]
operations = [
migration... | normal | {
"blob_id": "d8df9a9f95a1d4a9aa34987ec1244cc6c0c7c610",
"index": 8048,
"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
] |
<|reserved_special_token_0|>
def merge(A, B):
C, m, n = [], len(A), len(B)
i, j = 0, 0
while i + j < m + n:
if i == m:
C.append(B[j])
j = j + 1
elif j == n:
C.append(A[i])
i = i + 1
elif A[i] < B[j]:
C.append(A[i])
... | flexible | {
"blob_id": "7b4c2689ad1d4601a108dd8aa6e3c4d1e9730dc5",
"index": 5257,
"step-1": "<mask token>\n\n\ndef merge(A, B):\n C, m, n = [], len(A), len(B)\n i, j = 0, 0\n while i + j < m + n:\n if i == m:\n C.append(B[j])\n j = j + 1\n elif j == n:\n C.append(A[i]... | [
1,
2,
3,
4,
5
] |
from numpy import exp, array, dot
from read import normalized
class NeuralNetwork():
def __init__(self, layer1, layer2):
self.layer1 = layer1
self.layer2 = layer2
def __sigmoid(self, x):
return 1 / (1 + exp(-x))
def __sigmoid_derivative(self, x):
return x * (1 - x)
d... | normal | {
"blob_id": "8109fcc136b967e0ed4ca06077b32612605d5e5f",
"index": 1136,
"step-1": "<mask token>\n\n\nclass NeuralNetwork:\n\n def __init__(self, layer1, layer2):\n self.layer1 = layer1\n self.layer2 = layer2\n <mask token>\n <mask token>\n <mask token>\n\n def think(self, inputs):\n ... | [
3,
6,
8,
9,
10
] |
<|reserved_special_token_0|>
class Employee(models.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def __str__(self):
return self.name
class Meta:
ordering = ['name']
verbose_name = 'Empleado'
verbose_name_plural = '... | flexible | {
"blob_id": "df25b51010fdbcbf1a8949a7a755a3a982bbf648",
"index": 6352,
"step-1": "<mask token>\n\n\nclass Employee(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.name\n\n\n class Meta:\n ordering = ['name']\n verbose_name = 'Em... | [
7,
8,
18,
19,
20
] |
# Runtime: 44 ms, faster than 62.95% of Python3 online submissions for Rotate List.
# Memory Usage: 13.9 MB, less than 6.05% of Python3 online submissions for Rotate List.
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class... | normal | {
"blob_id": "a79c9799ed237a943ae3d249a4d66eb2f8693e83",
"index": 1896,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def rotateRight(self, head: ListNode, k: int) ->ListNode:\n if head is None or head.next is None or k == 0:\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('config.json') as config_file:
initdata = json.load(config_file)
<|reserved_special_token_0|>
pend.updCartesian()
pend.updEnergies()
<|reserved_special_token_0|>
if method == 1:
for n in range(nCycles):
t... | flexible | {
"blob_id": "c2b6e51622681ac916e860ed4ff5715808dff102",
"index": 9725,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('config.json') as config_file:\n initdata = json.load(config_file)\n<mask token>\npend.updCartesian()\npend.updEnergies()\n<mask token>\nif method == 1:\n for n in range(n... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def preprocess_data(data, sample_rate=160, ac_freq=60, hp_freq=0.5, bp_low=
2, bp_high=60, notch=False, hp_filter=False, bp_filter=False,
artifact_removal=False, normalize=False):
if notch:
data = notch_filter(data, ac_freq, sample_rate)
if hp_filter:
data ... | flexible | {
"blob_id": "5f1cbe1019f218d2aad616ea8bbe760ea760534c",
"index": 9359,
"step-1": "<mask token>\n\n\ndef preprocess_data(data, sample_rate=160, ac_freq=60, hp_freq=0.5, bp_low=\n 2, bp_high=60, notch=False, hp_filter=False, bp_filter=False,\n artifact_removal=False, normalize=False):\n if notch:\n ... | [
4,
6,
7,
8,
9
] |
import sys
import os
import csv
import urllib2, socket, time
import gzip, StringIO
import re, random, types
from bs4 import BeautifulSoup
from datetime import datetime
import json
from HTMLParser import HTMLParser
class MLStripper(HTMLParser):
def __init__(self):
self.reset()
self.fed = []
def ... | normal | {
"blob_id": "2d444c00e4dbdcb143d19752cd1a751169de73d3",
"index": 5746,
"step-1": "import sys\nimport os\nimport csv\nimport urllib2, socket, time\nimport gzip, StringIO\nimport re, random, types\nfrom bs4 import BeautifulSoup\nfrom datetime import datetime\nimport json\nfrom HTMLParser import HTMLParser\n\nclass... | [
0
] |
<|reserved_special_token_0|>
class SolveItCommand(sublime_plugin.TextCommand):
<|reserved_special_token_0|>
def run(self, _):
window = self.view.window()
window.show_input_panel('Enter ContestID & ProblemID : ', '', self.
on_done, self.on_change, self.on_cancel)
def on_done(s... | flexible | {
"blob_id": "9767014992981001bd2e8dece67525650c05a2a8",
"index": 4018,
"step-1": "<mask token>\n\n\nclass SolveItCommand(sublime_plugin.TextCommand):\n <mask token>\n\n def run(self, _):\n window = self.view.window()\n window.show_input_panel('Enter ContestID & ProblemID : ', '', self.\n ... | [
4,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('商品编码.txt', 'rt') as f:
data = f.read()
<|reserved_special_token_0|>
for x in data:
if count < 3:
count += 1
continue
x = x.split(',')
column = 0
for e in x:
if row == 0 and co... | flexible | {
"blob_id": "59a8a4cf4b04a191bfb70fd07668141dbfeda790",
"index": 6822,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('商品编码.txt', 'rt') as f:\n data = f.read()\n<mask token>\nfor x in data:\n if count < 3:\n count += 1\n continue\n x = x.split(',')\n column = 0\n fo... | [
0,
1,
2,
3
] |
class Solution:
def projectionArea(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""
res = 0
for i in grid:
res += max(i)
for j in i:
if j:
res += 1
for k in zip(*grid):
res +=... | normal | {
"blob_id": "62fc71e26ba3788513e5e52efc5f20453080837d",
"index": 8514,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def projectionArea(self, grid):\n \"\"\"\n :type grid: List[List[int]]\n :rtype: int\n \"\"\"\n ... | [
0,
1,
2
] |
# coding=utf-8
import base64
from sandcrawler.scraper import ScraperBase, SimpleScraperBase
class Hdmovie14Ag(SimpleScraperBase):
BASE_URL = 'http://www1.solarmovie.net'
OTHER_URLS = ['http://solarmovie.net', 'http://hdmovie14.ag']
SCRAPER_TYPES = [ ScraperBase.SCRAPER_TYPE_OSP, ]
LANGUAGE = 'eng'
... | normal | {
"blob_id": "27a12a0f5ea6120036b66ee1cdd903da868a037f",
"index": 952,
"step-1": "<mask token>\n\n\nclass Hdmovie14Ag(SimpleScraperBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def _fetch_search_url(self, search_term, media_type):\n ... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for t in sorted(list(permutations(s, int(k)))):
print(*t, sep='')
<|reserved_special_token_1|>
<|reserved_special_token_0|>
s, space, k = raw_input().partition(' ')
for t in sorted(list(permutations(s, int(k)))):
print(... | flexible | {
"blob_id": "37580939a0e58bdffb8cfad8252f339a7da4446e",
"index": 1130,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor t in sorted(list(permutations(s, int(k)))):\n print(*t, sep='')\n",
"step-3": "<mask token>\ns, space, k = raw_input().partition(' ')\nfor t in sorted(list(permutations(s, int(k)... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if v1 > 18 and v1 < 60:
print(v1)
elif v2 > 18 and v2 < 60:
print(v2)
elif v3 > 18 and v3 < 60:
print(v3)
<|reserved_special_token_1|>
v1 = int(input('Introdu virsta primei persoane'))
v2 = int(input('Introdu virsta... | flexible | {
"blob_id": "b8c749052af0061373808addea3ad419c35e1a29",
"index": 3324,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif v1 > 18 and v1 < 60:\n print(v1)\nelif v2 > 18 and v2 < 60:\n print(v2)\nelif v3 > 18 and v3 < 60:\n print(v3)\n",
"step-3": "v1 = int(input('Introdu virsta primei persoane'... | [
0,
1,
2,
3
] |
from typing import List, Tuple
from unittest import TestCase
from solutions.python.common.timing import decompose, parse_decomposed_duration, format_duration
class TestTiming(TestCase):
def test_decompose_ns(self):
# Given
duration: int = 234
# When
decomposition: List[Tuple[int... | normal | {
"blob_id": "afecbb46a98fbf6b5c26f5b6c8026aec035fadf1",
"index": 6696,
"step-1": "<mask token>\n\n\nclass TestTiming(TestCase):\n\n def test_decompose_ns(self):\n duration: int = 234\n decomposition: List[Tuple[int, str]] = decompose(duration)\n expected_decomposition: List[Tuple[int, str... | [
7,
11,
12,
16,
17
] |
import numpy
#calculate field of simple
def dipole(x, y, z, dx, dy, dz, mx, my, mz):
R = (x - dx)**2 + (y - dy)**2 + (z - dz)**2
return (3.0*(x - dx) * ((x - dx)*mx + (y - dy)*my + (z - dz)*mz) / R**2.5 - mx/R**1.5,
3.0*(y - dy) * ((x - dx)*mx + (y - dy)*my + (z - dz)*mz) / R**2.5 - my/R**1.5,
... | normal | {
"blob_id": "9d37d1618fb9d00d63b7ed58290c5ba1b8f106cd",
"index": 4599,
"step-1": "import numpy \n\n#calculate field of simple \ndef dipole(x, y, z, dx, dy, dz, mx, my, mz):\n R = (x - dx)**2 + (y - dy)**2 + (z - dz)**2\n return (3.0*(x - dx) * ((x - dx)*mx + (y - dy)*my + (z - dz)*mz) / R**2.5 - mx/R**1.5... | [
0
] |
from typing import Any, Dict, List
import numpy as np
from kedro.io import AbstractDataSet
from msrest.exceptions import HttpOperationError
from azureml.core import Workspace, Datastore
from azureml.data.data_reference import DataReference
class AZblob_datastore_data(AbstractDataSet):
"""``ImageDataSet`` loads /... | normal | {
"blob_id": "eb981a2d7f0ff5e6cc4a4a76f269c93c547965ba",
"index": 715,
"step-1": "from typing import Any, Dict, List\n\nimport numpy as np\n\nfrom kedro.io import AbstractDataSet\nfrom msrest.exceptions import HttpOperationError\nfrom azureml.core import Workspace, Datastore\nfrom azureml.data.data_reference impo... | [
0
] |
#! /usr/bin/env python
import RPIO
import sys
RPIO.setwarnings(False)
gpio = int(sys.argv[1])
RPIO.setup(gpio, RPIO.OUT)
input_value = RPIO.input(gpio)
print input_value | normal | {
"blob_id": "382597628b999f2984dba09405d9ff3dd2f35872",
"index": 6765,
"step-1": "#! /usr/bin/env python\n\nimport RPIO\nimport sys\n\nRPIO.setwarnings(False)\n\ngpio = int(sys.argv[1])\n\nRPIO.setup(gpio, RPIO.OUT)\ninput_value = RPIO.input(gpio)\n\nprint input_value",
"step-2": null,
"step-3": null,
"ste... | [
0
] |
#-*- coding: utf-8 -*-
#############################################################################
# #
# Copyright (c) 2008 Rok Garbas <rok@garbas.si> #
# ... | normal | {
"blob_id": "d0f9dd0a06023dd844b0bf70dff360f6bb46c152",
"index": 4412,
"step-1": "<mask token>\n\n\nclass MonthYearWidget(DateWidget):\n \"\"\" Month and year widget \"\"\"\n zope.interface.implementsOnly(IMonthYearWidget)\n klass = u'monthyear-widget'\n value = '', '', 1\n\n\n<mask token>\n",
"ste... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class Pygments(Directive):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def run(self):
self.assert_has_content()
tr... | flexible | {
"blob_id": "d3dcef6a1a6bcfc1161c4de46081703b8fe7016d",
"index": 9606,
"step-1": "<mask token>\n\n\nclass Pygments(Directive):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def run(self):\n self.assert_has_content()\n try:\n ... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def update_album(user, imgur_client, reddit_client):
return
<|reserved_special_token_0|>
def is_gif(url):
return True
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def respond_to_comment(comment, album_user, album_url, num_images... | flexible | {
"blob_id": "ca009022832963934230e356f9ea9eaedac7378b",
"index": 1745,
"step-1": "<mask token>\n\n\ndef update_album(user, imgur_client, reddit_client):\n return\n\n\n<mask token>\n\n\ndef is_gif(url):\n return True\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef respond_to_comment(comment, album_... | [
2,
6,
7,
8,
9
] |
from redis3barScore import StudyThreeBarsScore
from redisUtil import RedisTimeFrame
def test_score1() -> None:
package = {'close': 13.92,
'high': 14.57,
'low': 12.45,
'open': 13.4584,
'symbol': 'FANG',
'timestamp': 1627493640000000000,
... | normal | {
"blob_id": "ec64ddd01034debadb6674e71125f673f5de8367",
"index": 567,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_score1() ->None:\n package = {'close': 13.92, 'high': 14.57, 'low': 12.45, 'open': 13.4584,\n 'symbol': 'FANG', 'timestamp': 1627493640000000000, 'trade_count': \n ... | [
0,
1,
2,
3
] |
from functiona import *
total = totalMarks(85, 67, 56, 45, 78)
avg = average(total)
grade = findGrade(avg)
print(grade)
print(total)
print(avg)
| normal | {
"blob_id": "05f77472625e902b66c4a97a4c640835826bd494",
"index": 3635,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(grade)\nprint(total)\nprint(avg)\n",
"step-3": "<mask token>\ntotal = totalMarks(85, 67, 56, 45, 78)\navg = average(total)\ngrade = findGrade(avg)\nprint(grade)\nprint(total)\npri... | [
0,
1,
2,
3
] |
#!/usr/bin/python
import sys
import os
import sqlite3
from matplotlib import pyplot as plt
import numpy as np
def main():
if len(sys.argv) < 2:
print('usage: sqlite_file ...')
sys.exit()
db_filenames = sys.argv[1:]
num_of_dbs = len(db_filenames)
conn = sqlite3.connect(":memory:")
c... | normal | {
"blob_id": "b24ce9ed2df11df4cbf47949915685c09ec7543a",
"index": 7070,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n if len(sys.argv) < 2:\n print('usage: sqlite_file ...')\n sys.exit()\n db_filenames = sys.argv[1:]\n num_of_dbs = len(db_filenames)\n conn = sq... | [
0,
1,
2,
3,
4
] |
import pandas as pd
import numpy as np
df = pd.DataFrame([['Hospital1', '2019-10-01'], ['Hospital2', '2019-10-01'],
['Hospital3', '2019-10-01'], ['Hospital1', '2019-10-01'], ['Hospital2',
'2019-10-02'], ['Hospital3', '2019-10-02'], ['Hospital2', '2019-10-03'],
['Hospital2', '2019-10-04'], ['Hospital3', '201... | normal | {
"blob_id": "8d8f1f0dbb76b5c536bd1a2142bb61c51dd75075",
"index": 9573,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(pd.pivot_table(df, values='Date', index='Hospital_Name', aggfunc=np.size)\n )\nprint(df2.sum())\n",
"step-3": "<mask token>\ndf = pd.DataFrame([['Hospital1', '2019-10-01'], ['H... | [
0,
1,
2,
3
] |
CARD_SIZE = (70, 90)
SPACING = 3 | normal | {
"blob_id": "b8ebbef7403a71d6165a5462bc08e2634b4cebc5",
"index": 4287,
"step-1": "<mask token>\n",
"step-2": "CARD_SIZE = 70, 90\nSPACING = 3\n",
"step-3": "CARD_SIZE = (70, 90)\nSPACING = 3",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
<|reserved_special_token_0|>
class API:
def __init__(self, base_url, version=1):
self.BASE = base_url or 'https://api.starlist.pro/v{}'.format(version)
self.PROFILE = self.BASE + '/player'
self.CLUB = self.BASE + '/club'
self.LEADERBOARD = self.BASE + '/leaderboards'
self.... | flexible | {
"blob_id": "3f3db7e8813f49fe0265e110236b6dc4fed6cd1b",
"index": 7214,
"step-1": "<mask token>\n\n\nclass API:\n\n def __init__(self, base_url, version=1):\n self.BASE = base_url or 'https://api.starlist.pro/v{}'.format(version)\n self.PROFILE = self.BASE + '/player'\n self.CLUB = self.BA... | [
2,
3,
4,
5,
6
] |
work_hours = 8
work_days = 5
pay_periods = 2
total = work_hours * work_days * pay_periods
rate = 17
pay = total * rate
print(pay)
# variables
name = "josh"
age = 30
# float
weight = 160.5
# list
kill_streak = [3, 5, 1, 9] # [90.9] list can contain sub lists
# range
players = list(range(1,10))
odds =... | normal | {
"blob_id": "af2ef3c77cefe675f3d30c3234401f0f9bda3505",
"index": 8916,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(pay)\n<mask token>\nprint(odds)\nprint(type(name), type(age), type(weight), type(kill_streak))\n<mask token>\nprint(mean)\n<mask token>\nprint(tens)\n<mask token>\nprint(average_age... | [
0,
1,
2,
3
] |
class Solution:
def maximumTime(self, time: str) ->str:
ans = ''
for i in range(5):
if time[i] != '?':
ans += time[i]
continue
if i == 0:
if time[1] in ['0', '1', '2', '3', '?']:
ans += '2'
e... | normal | {
"blob_id": "e7494104ab98df2b640f710fa69584802b3e1259",
"index": 3032,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def maximumTime(self, time: str) ->str:\n ans = ''\n for i in range(5):\n if time[i] != '?':\n ... | [
0,
1,
2
] |
#!/usr/bin/env python
from __future__ import division
from __future__ import print_function
import numpy as np
from mpi4py import MPI
from parutils import pprint
comm = MPI.COMM_WORLD
pprint("-"*78)
pprint(" Running on %d cores" % comm.size)
pprint("-"*78)
comm.Barrier()
# Prepare a vector of N=5 elements to be ... | normal | {
"blob_id": "839b3ebffebce95de25f75edc67a647bd1318268",
"index": 5077,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npprint('-' * 78)\npprint(' Running on %d cores' % comm.size)\npprint('-' * 78)\ncomm.Barrier()\n<mask token>\nif comm.rank == 0:\n A = np.arange(N, dtype=np.float64)\nelse:\n A = np... | [
0,
1,
2,
3,
4
] |
import sys, os
class Extractor:
def __init__(self, prefix=''):
self.variables = {}
self.prefix = os.path.basename(prefix)
'''
Returns the variable name if a variable with
the value <value> is found.
'''
def find_variable_name(self, value):
for var, val in self.v... | normal | {
"blob_id": "dffcaf47ec8e0daa940e7047f11681ef3eabc772",
"index": 8591,
"step-1": "<mask token>\n\n\nclass Extractor:\n\n def __init__(self, prefix=''):\n self.variables = {}\n self.prefix = os.path.basename(prefix)\n <mask token>\n\n def find_variable_name(self, value):\n for var, v... | [
4,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def parser_stop(func):
@wraps(func)
def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
stdout = result['stdout']
"""
stdout: строки разделены
"""
data = stdout... | flexible | {
"blob_id": "4af573fa17f86ee067b870dce1f6ee482d1b14ff",
"index": 8281,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef parser_stop(func):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n result = func(*args, **kwargs)\n stdout = result['stdout']\n \"\"\"\n stdou... | [
0,
1,
2,
3
] |
import turtle
from turtle import color
import random
screen = turtle.Screen()
screen.setup(width=500, height=400)
colours = ["red", "pink", "blue", "purple", "black", "green"]
y_pos = [100, 60, 20, -20, -60, -100]
user_bet = screen.textinput(title="Make your bet",
prompt="Which turtle will ... | normal | {
"blob_id": "f3aaa6ae7a9a57946bdb035a4d52e84541c1a292",
"index": 5934,
"step-1": "<mask token>\n\n\nclass Racer(turtle.Turtle):\n\n def __init__(self, color, x, y):\n super().__init__(shape='turtle')\n self.color(color)\n self.penup()\n self.goto(x=x, y=y)\n\n def race(self):\n ... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
ctypes.cdll.LoadLibrary(so_filepath)
<|reserved_special_token_0|>
print('The sum of %.1f and %.1f is %.1f' % (x, y, a))
<|reserved_special_token_0|>
print('Subtracting %.1f from %.1f is %.1f' % (x, y, b))
<|reserved_special_toke... | flexible | {
"blob_id": "12ecfd2750f79fd19355665b6e57c2103a3cac3e",
"index": 4257,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nctypes.cdll.LoadLibrary(so_filepath)\n<mask token>\nprint('The sum of %.1f and %.1f is %.1f' % (x, y, a))\n<mask token>\nprint('Subtracting %.1f from %.1f is %.1f' % (x, y, b))\n",
"ste... | [
0,
1,
2,
3,
4
] |
import numpy
import matplotlib.pyplot as plt
numpy.random.seed(2)
# create datasets
x = numpy.random.normal(3, 1, 100)
y = numpy.random.normal(150, 40, 100) / x
# displaying original dataset
plt.scatter(x, y)
plt.title("Original dataset")
plt.xlabel("Minutes")
plt.ylabel("Spent money")
plt.show()
# train dataset wi... | normal | {
"blob_id": "9fd985e9675514f6c8f3ac5b91962eb744e0e82c",
"index": 6514,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnumpy.random.seed(2)\n<mask token>\nplt.scatter(x, y)\nplt.title('Original dataset')\nplt.xlabel('Minutes')\nplt.ylabel('Spent money')\nplt.show()\n<mask token>\nplt.scatter(train_x, trai... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class TestCommon(TestCase):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class TestCommon(TestCase):
def test_get_method_config(self):
job = create_test_job(predict... | flexible | {
"blob_id": "824038a56e8aaf4adf6ec813a5728ab318547582",
"index": 1638,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass TestCommon(TestCase):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass TestCommon(TestCase):\n\n def test_get_method_config(self):\n job = create_test_job(pr... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for Images in Faces:
lv_FaceId = Images['FaceId']
lv_ImageId = Images['ImageId']
lv_ExternalImageId = Images['ExternalImageId'],
lv_Names = ExternalImageId.split('_')
lv_Firstname = lv_Names[0]
lv_Surname =... | flexible | {
"blob_id": "6369c692e358c0dfd1193c6e961ecf9b521ea9ba",
"index": 4649,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor Images in Faces:\n lv_FaceId = Images['FaceId']\n lv_ImageId = Images['ImageId']\n lv_ExternalImageId = Images['ExternalImageId'],\n lv_Names = ExternalImageId.split('_')\... | [
0,
1,
2,
3,
4
] |
from google.cloud import vision
from google.cloud.vision import types
from google.oauth2 import service_account
import os
# import re
import io
import pdf2image
import tempfile
import datetime
# Google API
credentials = service_account.Credentials.from_service_account_file("APIKey.json")
client = vision.ImageAnnot... | normal | {
"blob_id": "be69a9981fe6b53c3b9c4d2893913e4f9f7efb26",
"index": 6697,
"step-1": "<mask token>\n\n\ndef boxes_to_obj(self, bound):\n return {'x1': bound.vertices[0].x, 'x2': bound.vertices[1].x, 'y1':\n bound.vertices[0].y, 'y2': bound.vertices[2].y}\n\n\ndef generateTempFolder(self, prifx, src):\n ... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
class RedArrow(ReporterPlugin):
<|reserved_special_token_0|>
def start(self):
self.addMenuItem()
self.options = {'extremum_calculate_badness': False,
'extremum_ignore_badness_below': 0,
'smooth_connection_max_distance': 4,
'frac... | flexible | {
"blob_id": "229d7378695f7e00176eb7c3962519af3db1b7e1",
"index": 4461,
"step-1": "<mask token>\n\n\nclass RedArrow(ReporterPlugin):\n <mask token>\n\n def start(self):\n self.addMenuItem()\n self.options = {'extremum_calculate_badness': False,\n 'extremum_ignore_badness_below': 0,\... | [
7,
10,
12,
13,
14
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
browser.get(website)
<|reserved_special_token_0|>
find_link.click()
<|reserved_special_token_0|>
input_first_name.send_keys('Timur')
<|reserved_special_token_0|>
input_last_name.send_keys('Atabaev')
<|reserved_special_token_0|>
in... | flexible | {
"blob_id": "aa17e22bc13436333b1db4aee41eeced373119a8",
"index": 5704,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nbrowser.get(website)\n<mask token>\nfind_link.click()\n<mask token>\ninput_first_name.send_keys('Timur')\n<mask token>\ninput_last_name.send_keys('Atabaev')\n<mask token>\ninput_city.send... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"blob_id": "ba336094d38a47457198919ce60969144a8fdedb",
"index": 5374,
"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 = [('RMS', '0001... | [
0,
1,
2,
3,
4
] |
from django.contrib import admin
from . import models
admin.site.register(models.Comentario)
# Register your models here.
| normal | {
"blob_id": "d7d94cfed0b819297069c3434c70359a327403cd",
"index": 718,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(models.Comentario)\n",
"step-3": "from django.contrib import admin\nfrom . import models\nadmin.site.register(models.Comentario)\n",
"step-4": "from django.contrib ... | [
0,
1,
2,
3
] |
# Generated by Django 2.2.3 on 2019-07-11 22:04
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app1', '0002_property_details'),
]
operations = [
migrations.AlterField(
model_name='property_details',
name='flat_t... | normal | {
"blob_id": "8cdd7646dbf23259e160186f332b5cb02b67291b",
"index": 5121,
"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 = [('app1', '000... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('README.md', 'r') as f:
long_description = f.read()
setuptools.setup(name='unitreport', version='0.1.1', author='annahadji',
author_email='annahadji@users.noreply.github.com', description=
'A small unittest-b... | flexible | {
"blob_id": "7a243f5e24d81d3395cc790dface5e795b9c04e6",
"index": 4495,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('README.md', 'r') as f:\n long_description = f.read()\nsetuptools.setup(name='unitreport', version='0.1.1', author='annahadji',\n author_email='annahadji@users.noreply.git... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Menu:
<|reserved_special_token_0|>
def get_menu(self, type, openid):
try:
if type == 'mine':
self.sql = (
"SELECT * FROM get_menu WHERE openid='%s' order by watch DESC "
% openid)
s... | flexible | {
"blob_id": "4fa9d16f979acf3edce05a209e1c6636e50fc315",
"index": 222,
"step-1": "<mask token>\n\n\nclass Menu:\n <mask token>\n\n def get_menu(self, type, openid):\n try:\n if type == 'mine':\n self.sql = (\n \"SELECT * FROM get_menu WHERE openid='%s' ord... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('./all-news.json') as f:
allNews = json.load(f)
<|reserved_special_token_0|>
with open('./recent-news.js', 'w') as f:
f.write("document.write('\\\n")
f.write('<ul>\\\n')
for value in allNews.values():
... | flexible | {
"blob_id": "6097840cdf4b42efaca3e197f88703d927abe889",
"index": 2548,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('./all-news.json') as f:\n allNews = json.load(f)\n<mask token>\nwith open('./recent-news.js', 'w') as f:\n f.write(\"document.write('\\\\\\n\")\n f.write('<ul>\\\\\\n'... | [
0,
1,
2,
3,
4
] |
x = str(input("please input your name:"))
y = int(input("please input your age:"))
p = int(2017-y+100)
print("your name is:"+x)
print (p) | normal | {
"blob_id": "929f580e8e559f8309e19f72208bf4ff0d537668",
"index": 4935,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('your name is:' + x)\nprint(p)\n",
"step-3": "x = str(input('please input your name:'))\ny = int(input('please input your age:'))\np = int(2017 - y + 100)\nprint('your name is:' +... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class HDF5_Parser(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def read_file(self, file_obj, **kwargs):
return h5py.File(file_obj.name, mode='r')
<|reserved_special_token_1|>
<|... | flexible | {
"blob_id": "0beb5c5c5db9247d66a5a49cfff7282ead52a9b7",
"index": 716,
"step-1": "<mask token>\n\n\nclass HDF5_Parser(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def read_file(self, file_obj, **kwargs):\n return h5py.File(file_obj.name, mode='r')\n",
"step-2": ... | [
2,
3,
4,
5,
6
] |
def emphasize(sentence):
words = sentence.split(" ")
for i, word in enumerate(words):
words[i] = word[0].upper() + word[1:].lower()
return " ".join(words)
exp1 = "Hello World"
ans1 = emphasize("hello world")
assert ans1 == exp1, f"expected {exp1}, got {ans1}"
exp2 = "Good Morning"
ans2 = emphasiz... | normal | {
"blob_id": "518dcdca8f5e6b42624083e4327143dfba59b2ba",
"index": 9785,
"step-1": "<mask token>\n",
"step-2": "def emphasize(sentence):\n words = sentence.split(' ')\n for i, word in enumerate(words):\n words[i] = word[0].upper() + word[1:].lower()\n return ' '.join(words)\n\n\n<mask token>\n",
... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from hilma import Mesh, loadPly, savePly
mesh = Mesh()
loadPly("head.ply", mesh)
verts = []
faces = []
edges = []
uvs = ... | normal | {
"blob_id": "c02af2ecd980da4ceff133c13072ad7c6b724041",
"index": 5329,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nloadPly('head.ply', mesh)\n<mask token>\nfor v in mesh.getVertices():\n verts.append((v.x, v.y, v.z))\nfor t in mesh.getTrianglesIndices():\n faces.append((t.x, t.y, t.z))\nfor e in... | [
0,
1,
2,
3,
4
] |
from django.conf import settings
from django.contrib import messages
from django.shortcuts import redirect, render
from django.urls import reverse
from django.views.generic import DetailView, ListView, View
from assessments.models import (Mine, Company,
QuestionCategory, Question, Assessment, Response)
class Home... | normal | {
"blob_id": "d296e528d399ee772039777d139a1d8271711ee9",
"index": 2146,
"step-1": "<mask token>\n\n\nclass AssessmentList(ListView):\n model = Assessment\n\n\nclass AssessmentDetail(DetailView):\n model = Assessment\n\n\nclass AnswerQuestions(ListView):\n model = Question\n\n def post(self, request):\... | [
11,
14,
16,
17,
20
] |
import torch
import torch.nn as nn
import torchvision
import torchvision.transforms as transforms
import numpy as np
import matplotlib.pyplot as plt
def weights_init(m):
if type(m) == nn.Linear:
m.weight.data.normal_(0.0, 1e-3)
m.bias.data.fill_(0.)
def update_lr(optimizer, lr):
for param_gr... | normal | {
"blob_id": "0553bd4c7261197a1a80c5551305a16e7bfdc761",
"index": 2398,
"step-1": "<mask token>\n\n\ndef weights_init(m):\n if type(m) == nn.Linear:\n m.weight.data.normal_(0.0, 0.001)\n m.bias.data.fill_(0.0)\n\n\ndef update_lr(optimizer, lr):\n for param_group in optimizer.param_groups:\n ... | [
5,
6,
8,
9,
11
] |
<|reserved_special_token_0|>
class RiskType(models.Model):
<|reserved_special_token_0|>
name = models.CharField(max_length=255)
created = models.DateTimeField(default=timezone.now)
modified = models.DateTimeField(auto_now=True)
class Meta:
ordering = 'name',
def __str__(self):
... | flexible | {
"blob_id": "635b75bc12718bccdfb9d04a54476c93fa4685ce",
"index": 4661,
"step-1": "<mask token>\n\n\nclass RiskType(models.Model):\n <mask token>\n name = models.CharField(max_length=255)\n created = models.DateTimeField(default=timezone.now)\n modified = models.DateTimeField(auto_now=True)\n\n\n c... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class TestUbuntuMock(TestOnUbuntu):
def _should_skip(self):
pass
def _dpkg_query_s(self):
from textwrap import dedent
if self._installed:
return Output(stdout=dedent(
"""
Package: sg3-uti... | flexible | {
"blob_id": "b3c1843a742a82bca61650ab89ea8afdf3c9010d",
"index": 6667,
"step-1": "<mask token>\n\n\nclass TestUbuntuMock(TestOnUbuntu):\n\n def _should_skip(self):\n pass\n\n def _dpkg_query_s(self):\n from textwrap import dedent\n if self._installed:\n return Output(stdout=... | [
27,
33,
43,
46,
53
] |
from django.apps import AppConfig
class Sharem8Config(AppConfig):
name = 'ShareM8'
| normal | {
"blob_id": "fd4d785d933c3a200f4aba094ecfe1e1c76737a5",
"index": 7629,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Sharem8Config(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Sharem8Config(AppConfig):\n name = 'ShareM8'\n",
"step-4": "from django.apps import App... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
@pytest.fixture
def static(tmpdir):
return Static(str(tmpdir))
def test_static_fixture(static, tmpdir):
assert isinstance(static, Static)
assert str(static.path) == str(tmpdir)
<|reserved_special_token_0|>
def test_error_on_missing_dir():
err = FileNotFoundError if v... | flexible | {
"blob_id": "9a7994a1e51c9cf7fe7d8b50ab26fa3d789fc8e5",
"index": 1012,
"step-1": "<mask token>\n\n\n@pytest.fixture\ndef static(tmpdir):\n return Static(str(tmpdir))\n\n\ndef test_static_fixture(static, tmpdir):\n assert isinstance(static, Static)\n assert str(static.path) == str(tmpdir)\n\n\n<mask toke... | [
4,
7,
8,
9,
10
] |
from arcgis.geocoding import geocode
from arcgis.gis import GIS
import pandas as pd
import Point_v1
"""
This module is used to get the location information of different companies from arcgis API.
"""
def crawl(file):
gis = GIS()
map = gis.map("United States")
map
# read all kinds of job files
jo... | normal | {
"blob_id": "902159d9ad3a1e36b69142518007b5d4bcaef0f3",
"index": 1320,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef crawl(file):\n gis = GIS()\n map = gis.map('United States')\n map\n job_df = pd.read_csv(Point_v1.CONSULTING_FILE).append(pd.read_csv(\n Point_v1.DS_FILE)).appe... | [
0,
1,
2,
3
] |
import numpy as np
import cv2 as cv
import random
import time
random.seed(0)
def displayImage(winName, img):
""" Helper function to display image
arguments:
winName -- Name of display window
img -- Source Image
"""
cv.imshow(winName, img)
cv.waitKey(0)
################################... | normal | {
"blob_id": "f7886f8d98ad0519f4635064f768f25dad101a3d",
"index": 2612,
"step-1": "<mask token>\n\n\ndef displayImage(winName, img):\n \"\"\" Helper function to display image\n arguments:\n winName -- Name of display window\n img -- Source Image\n \"\"\"\n cv.imshow(winName, img)\n cv.wai... | [
7,
8,
10,
12,
13
] |
# 213. 打家劫舍 II
# 你是一个专业的小偷,计划偷窃沿街的房屋,每间房内都藏有一定的现金。这个地方所有的房屋都 围成一圈 ,这意味着第一个房屋和最后一个房屋是紧挨着的。
# 同时,相邻的房屋装有相互连通的防盗系统,如果两间相邻的房屋在同一晚上被小偷闯入,系统会自动报警 。
# 给定一个代表每个房屋存放金额的非负整数数组,计算你 在不触动警报装置的情况下 ,能够偷窃到的最高金额。
class Solution:
# 86.24%, 15.46%
def rob(self, nums) -> int:
n = len(nums)
if n == 0:
... | normal | {
"blob_id": "59b2c9d279168a806e59fb7529ab12d7b86107bc",
"index": 5340,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n\n def helper(self, nums, n):\n if n == 1:\n return nums[0]\n dp = [0] * n\n dp[0] = nums[0]\n dp[1] = max(nums[0], nums[1])... | [
0,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def load_yaml_config(config_path: str) ->Dict:
with open(config_path, 'r') as stream:
return yaml.load(stream)
def get_optimizer(model: nn.Module, optim_config: Dict) ->optim.Optimizer:
return optim.Adam(model.parameters(), **optim_config)
def save_checkpoint(model: nn... | flexible | {
"blob_id": "e8a36bd7826c5d71cf8012ea82df6c127dd858fc",
"index": 549,
"step-1": "<mask token>\n\n\ndef load_yaml_config(config_path: str) ->Dict:\n with open(config_path, 'r') as stream:\n return yaml.load(stream)\n\n\ndef get_optimizer(model: nn.Module, optim_config: Dict) ->optim.Optimizer:\n retu... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def kmeansplus(X, K, n_iter):
n = X.shape[0]
idx = np.zeros(X.shape[0])
distance = np.zeros(n * K).reshape(n, K)
centers = np.zeros(X.shape[1] * K).reshape(K, -1)
pr = np.repeat(1 / n, n)
centers[0, :] = X[np.random.choice(np.arange(n), 1, p=pr),]
distance[:, 0... | flexible | {
"blob_id": "10bf7959f178d3b5c0ce6e97253e665d32363af7",
"index": 6015,
"step-1": "<mask token>\n\n\ndef kmeansplus(X, K, n_iter):\n n = X.shape[0]\n idx = np.zeros(X.shape[0])\n distance = np.zeros(n * K).reshape(n, K)\n centers = np.zeros(X.shape[1] * K).reshape(K, -1)\n pr = np.repeat(1 / n, n)\... | [
1,
2,
3,
4,
5
] |
import numpy as np
import tensorflow as tf
x_data = np.random.rand(100)
y_data = x_data * 10 + 5
#构造线性模型
b = tf.Variable(0.)
k = tf.Variable(0.)
y=k*x_data+b
#二次代价函数 square求平方
loss= tf.reduce_mean(tf.square(y_data-y))
#定义一个梯度下降法来进行训练的优化器
optimizer=tf.train.GradientDescentOptimizer(.2)
train=optimizer.minimize(... | normal | {
"blob_id": "ba7f66a0f9cf1028add778315033d596e10d6f16",
"index": 3197,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith tf.Session() as ss:\n ss.run(init)\n for step in range(201):\n ss.run(train)\n if step % 10 == 0:\n print(step, ss.run([k, b]))\n",
"step-3": "<mask ... | [
0,
1,
2,
3,
4
] |
class HashTableEntry:
"""
Hash Table entry, as a linked list node.
"""
def __init__(self, key, value):
self.key = key
self.value = value
self.next = None
class HashTable:
"""
A hash table that with `capacity` buckets
that accepts string keys
Implement this.
... | normal | {
"blob_id": "7e58fe636e6d835d7857a49900bbc127b52f63d9",
"index": 6112,
"step-1": "<mask token>\n\n\nclass HashTable:\n <mask token>\n\n def __init__(self, capacity):\n self.capacity = capacity\n self.storage = [None] * capacity\n self.numberOfItems = 0\n\n def fnv1(self, key):\n ... | [
6,
11,
13,
15,
16
] |
def longest(s1, s2):
# your code
s=s1+s2
st="".join(sorted(set(s)))
return st
longest("xyaabbbccccdefww","xxxxyyyyabklmopq")
| normal | {
"blob_id": "7d54d5fd855c7c03d2d4739e8ad4f9ab8772ca2b",
"index": 3977,
"step-1": "<mask token>\n",
"step-2": "def longest(s1, s2):\n s = s1 + s2\n st = ''.join(sorted(set(s)))\n return st\n\n\n<mask token>\n",
"step-3": "def longest(s1, s2):\n s = s1 + s2\n st = ''.join(sorted(set(s)))\n re... | [
0,
1,
2,
3
] |
import shelve
arguments = ["self", "info", "args", "world"]
minlevel = 2
helpstring = "moneyreset"
def main(connection, info, args, world) :
"""Resets a users money"""
money = shelve.open("money-%s.db" % (world.hostnicks[connection.host]), writeback=True)
money[info["sender"]] = {"money":100000, "maxmoney"... | normal | {
"blob_id": "95021cc01c0b85b512fd466797d4d128472773c3",
"index": 2943,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(connection, info, args, world):\n \"\"\"Resets a users money\"\"\"\n money = shelve.open('money-%s.db' % world.hostnicks[connection.host],\n writeback=True)\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
@bp.route('/captcha/')
def CaptchaView():
text, image = Captcha.gene_graph_captcha()
cacheuntil.set(text.lower(), text.lower())
out = BytesIO()
image.save(out, 'png')
out.seek(0)
resp = make_response(out.read())
resp.content_type = 'image/png'
return resp
... | flexible | {
"blob_id": "856beaf3b9dad333d5b48c1be3a8ad917f8d020c",
"index": 3634,
"step-1": "<mask token>\n\n\n@bp.route('/captcha/')\ndef CaptchaView():\n text, image = Captcha.gene_graph_captcha()\n cacheuntil.set(text.lower(), text.lower())\n out = BytesIO()\n image.save(out, 'png')\n out.seek(0)\n res... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class Knn(object):
<|reserved_special_token_0|>
def __init__(self, TrainingData):
self.TrainingData = TrainingData
self.nFeatures = self.TrainingData.shape[1] - 1
self.data = TrainingData[:, 0:self.nFeatures].astype(float)
self.FeatureRange = []
... | flexible | {
"blob_id": "5e0affbd295d7237784cd8e72926afeda6456500",
"index": 7080,
"step-1": "<mask token>\n\n\nclass Knn(object):\n <mask token>\n\n def __init__(self, TrainingData):\n self.TrainingData = TrainingData\n self.nFeatures = self.TrainingData.shape[1] - 1\n self.data = TrainingData[:,... | [
4,
5,
7,
8,
9
] |
# -*- coding: utf-8 -*-
class Library(object):
def __init__(self, backend):
self._backend = backend
@property
def cache(self):
return self._backend.cache
def cache_key(self, key):
return self._backend.cache_key(key)
def get_url(self, track):
raise NotImplemented... | normal | {
"blob_id": "ccee0e3c47fd3809e0670be24aaa6fd0a9bad3bc",
"index": 888,
"step-1": "class Library(object):\n <mask token>\n <mask token>\n\n def cache_key(self, key):\n return self._backend.cache_key(key)\n <mask token>\n",
"step-2": "class Library(object):\n <mask token>\n <mask token>\n... | [
2,
3,
4,
5,
6
] |
data_dir = "../data"
output_dir = './'
valid_id = dict()
for category in ("beauty", "fashion", "mobile"):
with open("%s/%s_data_info_val_competition.csv" % (data_dir, category), "r") as infile:
next(infile)
for line in infile:
curr_id = line.strip().split(',')[0]
valid_id[cu... | normal | {
"blob_id": "82556291c456b9e43e4e589ea4a77d320430344b",
"index": 7478,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor category in ('beauty', 'fashion', 'mobile'):\n with open('%s/%s_data_info_val_competition.csv' % (data_dir, category), 'r'\n ) as infile:\n next(infile)\n for ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def get_choice_times(behavior_filename, verbose=False):
"""Calculates the choice time for each trial in the logfile"""
state_num2names = MCwatch.behavior.db.get_state_num2names()
resp_win_num = dict([(v, k) for k, v ... | flexible | {
"blob_id": "78761eda403ad8f54187e5858a23c23d3dd79b09",
"index": 8821,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_choice_times(behavior_filename, verbose=False):\n \"\"\"Calculates the choice time for each trial in the logfile\"\"\"\n state_num2names = MCwatch.behavior.db.get_state_... | [
0,
1,
2,
3,
4
] |
from .routes import generate_routes
| normal | {
"blob_id": "06339e9cd506f147d03c54aee82473e233b4ec2e",
"index": 8853,
"step-1": "<mask token>\n",
"step-2": "from .routes import generate_routes\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
from django.shortcuts import render
from django.http import Http404
from thermometer.models import Therm
def index(request):
therms = Therm.objects.all()
return render(request, 'thermometer/index.html', {
'therms': therms,
})
def fetchsquare(request, id):
try:
therm = Therm.objects.get(id=id)
except Therm.D... | normal | {
"blob_id": "504d4afc4b3e708d43110a2d85676fb745f1aba8",
"index": 9874,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef fetchsquare(request, id):\n try:\n therm = Therm.objects.get(id=id)\n except Therm.DoesNotExist:\n raise Http404('This item does not exist')\n return render... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
if __name__ == '__main__':
generations = 100
for generation in range(generations):
population = np.random.randint(0, 255, size=(200, 39), dtype=np.uint8)
print('Population\n', population, end='\n\n')
... | flexible | {
"blob_id": "99f50d393e750bd8fa5bee21d99f08d20b9f5fe9",
"index": 9102,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n generations = 100\n for generation in range(generations):\n population = np.random.randint(0, 255, size=(200, 39), dtype=np.uint8)\n print... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class City(BaseModel):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class City(BaseModel):
<|reserved_special_token_0|>
state_id = ''
name = ''
<|reserved_spe... | flexible | {
"blob_id": "3f2c1a83ae0dfdba202038a209b90162ccddee36",
"index": 6115,
"step-1": "<mask token>\n\n\nclass City(BaseModel):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass City(BaseModel):\n <mask token>\n state_id = ''\n name = ''\n",
"step-3": "<mask tok... | [
1,
2,
3,
4,
5
] |
from django.contrib.auth.models import User
from django_filters import (
NumberFilter,
DateTimeFilter,
AllValuesFilter
)
from rest_framework.response import Response
from rest_framework.reverse import reverse
from rest_framework import permissions
from rest_framework.throttling import ScopedRateThrottle
fr... | normal | {
"blob_id": "2908d34165fac272c9571be623855a0613c952f3",
"index": 5433,
"step-1": "<mask token>\n\n\nclass GameList(ListCreateAPIView):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def perform_create(self, serializer):\n ... | [
18,
25,
26,
27,
28
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
c.execute('SELECT * FROM example')
<|reserved_special_token_0|>
print('Content-Type:text/html; charset=utf-8')
print()
for i in records1.split('\n'):
print(i)
for i in records_dyn:
print(i)
for i in records1.split('\n'):
... | flexible | {
"blob_id": "b5fee01582a28085983c56b9c266ef7fd5c3c927",
"index": 5132,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nc.execute('SELECT * FROM example')\n<mask token>\nprint('Content-Type:text/html; charset=utf-8')\nprint()\nfor i in records1.split('\\n'):\n print(i)\nfor i in records_dyn:\n print(... | [
0,
1,
2,
3,
4
] |
from .exenv import *
| normal | {
"blob_id": "9fea76b1612bd02f512072692090f8ef60e8a0fe",
"index": 1498,
"step-1": "<mask token>\n",
"step-2": "from .exenv import *\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.