code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
# -*- coding: utf8 -*- from django.db import models import custom_fields import datetime #import mptt # Create your models here. class Message(models.Model): user = models.ForeignKey('User') time = models.DateTimeField(auto_now=True,auto_now_add=True) text = models.TextField() #true если это ответ подд...
normal
{ "blob_id": "64fd597918fe8133d53d1df741512cd2e49a111d", "index": 1252, "step-1": "<mask token>\n\n\nclass Ticket(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ...
[ 20, 22, 27, 29, 32 ]
# Copyright 2014 The Oppia Authors. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
normal
{ "blob_id": "8a848eece6a3ed07889ba208068de4bfa0ad0bbf", "index": 6744, "step-1": "# Copyright 2014 The Oppia Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the Li...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in ip_net.hosts(): host_add = str(i) toping = subprocess.Popen(['ping', '-n', '3', host_add], stdout=PIPE) output = toping.communicate()[0] hostalive = toping.returncode if hostalive == 0: print(h...
flexible
{ "blob_id": "414fb437783fcfb55f542f072aaf3a8bb02b441e", "index": 8275, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in ip_net.hosts():\n host_add = str(i)\n toping = subprocess.Popen(['ping', '-n', '3', host_add], stdout=PIPE)\n output = toping.communicate()[0]\n hostalive = toping.re...
[ 0, 1, 2, 3, 4 ]
import argparse import pickle import pandas as pd from pyspark.sql.session import SparkSession parser = argparse.ArgumentParser() parser.add_argument('--rs', type=str, nargs='+') args = parser.parse_args() ss = SparkSession.builder.getOrCreate() post_df = None for f in args.rs: df = ss.read.json(f).select('id', 'su...
normal
{ "blob_id": "e6b3def6ed6f2523d88912832a876caf2742b786", "index": 7572, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('--rs', type=str, nargs='+')\n<mask token>\nfor f in args.rs:\n df = ss.read.json(f).select('id', 'subreddit', 'subreddit_id', 'title')\n post_df = df if post_df...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(1, 11): if fave_fast_food in d: d[fave_fast_food] += 1 else: d[fave_fast_food] = 1 count += 1 fave_fast_food = input('Fave fast food restaurant: ') for k, v in d.items(): print('F...
flexible
{ "blob_id": "a494b3469682a909b76e67e1b78ad25affe99f24", "index": 8688, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(1, 11):\n if fave_fast_food in d:\n d[fave_fast_food] += 1\n else:\n d[fave_fast_food] = 1\n count += 1\n fave_fast_food = input('Fave fast food r...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_babi_en(get_10k=False): data_dir = 'datasets/tasks_1-20_v1-2/en/' if get_10k == True: data_dir = 'datasets/tasks_1-20_v1-2/en-10k/' maybe_download( 'https://s3.amazonaws.com/text-datasets/babi...
flexible
{ "blob_id": "7a4d04bd60b5f5555982af372145f9f4bcd83ca2", "index": 8194, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_babi_en(get_10k=False):\n data_dir = 'datasets/tasks_1-20_v1-2/en/'\n if get_10k == True:\n data_dir = 'datasets/tasks_1-20_v1-2/en-10k/'\n maybe_download(\n ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def calcula_norma(x): lista = [] for e in x: lista.append(e ** 2) v = sum(lista) ** (1 / 2) return v <|reserved_special_token_1|> def calcula_norma(x): lista=[] for e in x: lista.append(e**2) v=(sum(lista)**(1/2)...
flexible
{ "blob_id": "7346992d69250240207a0fc981d0adc245e69f87", "index": 5206, "step-1": "<mask token>\n", "step-2": "def calcula_norma(x):\n lista = []\n for e in x:\n lista.append(e ** 2)\n v = sum(lista) ** (1 / 2)\n return v\n", "step-3": "def calcula_norma(x):\n lista=[]\n for e in x:\n...
[ 0, 1, 2 ]
import keras from keras.applications import VGG16 from keras.preprocessing.image import ImageDataGenerator from keras.models import Model import matplotlib.pyplot as plt from keras.callbacks import History import numpy as np import os import cPickle as pickle import scipy from scipy import spatial def getM...
normal
{ "blob_id": "461b2de86907047df53c3857c6b0397e77de3fcd", "index": 5139, "step-1": "import keras\r\nfrom keras.applications import VGG16\r\nfrom keras.preprocessing.image import ImageDataGenerator\r\nfrom keras.models import Model\r\nimport matplotlib.pyplot as plt\r\nfrom keras.callbacks import History\r\nimport ...
[ 0 ]
from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential, Model from keras.applications import InceptionV3 from keras.callbacks import ModelCheckpoint from keras.optimizers import SGD from keras.layers import Flatten,Dense,Dropout from keras.preprocessing.image import img_to_a...
normal
{ "blob_id": "17a442a85b910ff47c2f3f01242b7f64a6237146", "index": 9380, "step-1": "from keras.preprocessing.image import ImageDataGenerator\r\nfrom keras.models import Sequential, Model\r\nfrom keras.applications import InceptionV3\r\nfrom keras.callbacks import ModelCheckpoint\r\nfrom keras.optimizers import SG...
[ 0 ]
import torch import numpy as np import h5py from torch.utils.data import Dataset, DataLoader from config import PARAS """ Be careful: We use log mel-spectrogram for training, while the mask generated is for power mel-spectrogram """ def create_gt_mask(vocal_spec, bg_spec): """ Take in log spectrogram and ret...
normal
{ "blob_id": "1133d3cf900e31278dc491565c99969a116e6c83", "index": 1998, "step-1": "<mask token>\n\n\nclass TorchData(Dataset):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef create_gt_mask(vocal_spec, bg_spec):\n \"\"\"\n Take in log spectrogra...
[ 1, 6, 8, 9, 10 ]
class Meta(type): def __new__(meta, name, bases, class_dict): print(f'* Running {meta}.__new__ for {name}') print("Bases:", bases) print(class_dict) return type.__new__(meta, name, bases, class_dict) class MyClass(metaclass=Meta): stuff = 123 def foo(self): pass cl...
normal
{ "blob_id": "8f3abc5beaded94b6d7b93ac2cfcd12145d75fe8", "index": 522, "step-1": "<mask token>\n\n\nclass MySubClass(MyClass):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass MyClass2:\n stuff = 123\n\n def __init_subclass__(cls):\n super().__init_subclass__()\n print(f'* Runn...
[ 8, 12, 14, 15, 17 ]
import os os.mkdir("作业") f=open("D:/six3/s/作业/tet.txt",'w+') for i in range(10): f.write("hello world\n") f.seek(0) s=f.read(100) print(s) f=open("D:/six3/s/作业/tet2.txt",'w+') for i in s: f.write(i) f.close()
normal
{ "blob_id": "5f5e314d2d18deb12a8ae757a117ef8fbb2ddad5", "index": 2391, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.mkdir('作业')\n<mask token>\nfor i in range(10):\n f.write('hello world\\n')\nf.seek(0)\n<mask token>\nprint(s)\n<mask token>\nfor i in s:\n f.write(i)\nf.close()\n", "step-3": "...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open('datasetParsing2DEF.csv') as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: if line_count == 0: print(f"Column names are {', '.join(row)}"...
flexible
{ "blob_id": "084579152a2cc7feb2c31e0209ce1e32f4905d81", "index": 5316, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('datasetParsing2DEF.csv') as csv_file:\n csv_reader = csv.reader(csv_file, delimiter=',')\n line_count = 0\n for row in csv_reader:\n if line_count == 0:\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for card in cards: try: number = int(card) if number % 2 == 0: print(card, 'is an even card.') except ValueError: print(card, 'can not be divided') <|reserved_special_token_1|> cards ...
flexible
{ "blob_id": "b5180a2dbe1f12e1bbc92874c67ea99c9a84a9ed", "index": 19, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor card in cards:\n try:\n number = int(card)\n if number % 2 == 0:\n print(card, 'is an even card.')\n except ValueError:\n print(card, 'can not be d...
[ 0, 1, 2, 3 ]
INITIAL_B = 0.15062677711161448 B_FACTOR = 5.0 INITIAL_GE = 0.22581915788215678 GE_BOUNDS = [1.0 / 10.0, 1.0 / 4.0] FIXED_P = 0.9401234488501574 INITIAL_GU = 0.2145066414796447 GU_BOUNDS = [1.0 / 15.0, 1.0 / 2.0] INITIAL_GI = 0.19235137989123863 GI_BOUNDS = [1.0 / 15.0, 1.0 / 5.0] INITIAL_GH = 0.044937075878220795...
normal
{ "blob_id": "47cf3045f2fa0f69759e09b1599e4afe953c06d8", "index": 5138, "step-1": "<mask token>\n", "step-2": "INITIAL_B = 0.15062677711161448\nB_FACTOR = 5.0\nINITIAL_GE = 0.22581915788215678\nGE_BOUNDS = [1.0 / 10.0, 1.0 / 4.0]\nFIXED_P = 0.9401234488501574\nINITIAL_GU = 0.2145066414796447\nGU_BOUNDS = [1.0 /...
[ 0, 1, 2 ]
<|reserved_special_token_0|> class MonitorList(tp.Generic[T], collections.UserList, Monitor): <|reserved_special_token_0|> def __init__(self, *args): collections.UserList.__init__(self, *args) Monitor.__init__(self) <|reserved_special_token_0|> <|reserved_special_token_0|> def __...
flexible
{ "blob_id": "0528d7761cbbf3dbe881ff05b81060f3d97e7f6c", "index": 742, "step-1": "<mask token>\n\n\nclass MonitorList(tp.Generic[T], collections.UserList, Monitor):\n <mask token>\n\n def __init__(self, *args):\n collections.UserList.__init__(self, *args)\n Monitor.__init__(self)\n <mask to...
[ 17, 20, 22, 23, 33 ]
ALPACA_KEY = 'Enter your apaca key here' ALPACA_SECRET_KEY = 'Enter your apaca secret key here' ALPACA_MARKET = 'enter alpaca market link here' TWILIO_KEY = 'enter your twilio key here' TWILIO_SECRET_KEY = 'enter your twilio secret key here' YOUR_PHONE_NUMBER = 'Enter your phone number' YOUR_TWILIO_NUMBER = 'Enter your...
normal
{ "blob_id": "10cb4b59d1e1e823c56ae5ceea0514b1c1904292", "index": 3769, "step-1": "<mask token>\n", "step-2": "ALPACA_KEY = 'Enter your apaca key here'\nALPACA_SECRET_KEY = 'Enter your apaca secret key here'\nALPACA_MARKET = 'enter alpaca market link here'\nTWILIO_KEY = 'enter your twilio key here'\nTWILIO_SECR...
[ 0, 1 ]
import os import unittest import json from flask_sqlalchemy import SQLAlchemy from app import create_app from models import * from dotenv import load_dotenv, find_dotenv load_dotenv(find_dotenv()) # auth tokens should be updated before running tests, # make sure update the tokens in setup.sh # read the README to kno...
normal
{ "blob_id": "bae4eb94d561f7aa810718840ff7c2de52cb0d6f", "index": 3228, "step-1": "<mask token>\n\n\nclass CastingAgencyTestCase(unittest.TestCase):\n <mask token>\n\n def setUp(self):\n \"\"\"Define test variables and initialize app.\"\"\"\n self.app = create_app()\n self.client = self...
[ 21, 30, 31, 35, 39 ]
"""IDQ Importer Exporter This script defines Import and Export functions through which it can communicate with a Informatica Model Repository. It also provides some related functions, such as: - Create IDQ folder - Check in IDQ components Parts by Laurens Verhoeven Parts by Jac. Beekers @Version: 20190...
normal
{ "blob_id": "09b14705a6905470058b5eecc6dd0bb214975c66", "index": 6408, "step-1": "<mask token>\n\n\ndef import_infadeveloper(**KeyWordArguments):\n \"\"\"Import IDQ Components\"\"\"\n KeyWordArguments['Tool'] = 'Import'\n ImportCommand = buildCommand.build(**KeyWordArguments)\n result = executeInfacm...
[ 10, 11, 12, 13, 14 ]
from django.shortcuts import render from django_filters.rest_framework import DjangoFilterBackend from django.views.decorators.csrf import csrf_exempt from rest_framework.parsers import JSONParser from django.http import JsonResponse, Http404 from .serializers import * from .models import * from .filter import * from r...
normal
{ "blob_id": "e0c6fb414d87c0a6377538089226e37b044edc70", "index": 8383, "step-1": "<mask token>\n\n\n@csrf_exempt\ndef TBGRApi(request, tbgrno=0):\n if request.method == 'GET':\n tbgrs = TBGR.objects.all()\n tbgrs_serializer = TBGRSerializer(tbgrs, many=True)\n return JsonResponse(tbgrs_se...
[ 3, 4, 5, 7, 8 ]
#!/usr/bin/env python from __future__ import print_function, division, unicode_literals import os import sys import json import logging import tempfile import itertools import traceback import subprocess as sp from os.path import basename from datetime import datetime from argparse import ArgumentParser, FileType PRE...
normal
{ "blob_id": "ac19ae96d8262cadd43314c29198fccbc008c1b5", "index": 6590, "step-1": "#!/usr/bin/env python\n\nfrom __future__ import print_function, division, unicode_literals\nimport os\nimport sys\nimport json\nimport logging\nimport tempfile\nimport itertools\nimport traceback\nimport subprocess as sp\nfrom os.p...
[ 0 ]
<|reserved_special_token_0|> class World(pyglet.window.Window): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def setup(self): self.width = 640 self.height = 480 self.rtri = 0.0 self.rquad = 0.0 ...
flexible
{ "blob_id": "5fc097518b6069131e1ca58fa885c6ad45ae143c", "index": 4741, "step-1": "<mask token>\n\n\nclass World(pyglet.window.Window):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def setup(self):\n self.width = 640\n self.height = 480\n self.rtri = 0.0\n ...
[ 9, 13, 15, 16, 17 ]
<|reserved_special_token_0|> class User: def __init__(self, name, id): self.name = name self.id = id def __repr__(self): return 'User({},{})'.format(self.name, self.id) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class User: def ...
flexible
{ "blob_id": "e8ef3a5e41e68b4d219aa1403be392c51cc010e6", "index": 7302, "step-1": "<mask token>\n\n\nclass User:\n\n def __init__(self, name, id):\n self.name = name\n self.id = id\n\n def __repr__(self):\n return 'User({},{})'.format(self.name, self.id)\n\n\n<mask token>\n", "step-2"...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open(filename, 'a') as handle: handle.write(str(current_time)) handle.write('\n') <|reserved_special_token_1|> <|reserved_special_token_0|> filename = 'record_time.txt' current_time = time.strftime('%a %H:%M:%S') w...
flexible
{ "blob_id": "1f0695f0e9745912d8ee3a87e6c9b1272e9ebbae", "index": 218, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(filename, 'a') as handle:\n handle.write(str(current_time))\n handle.write('\\n')\n", "step-3": "<mask token>\nfilename = 'record_time.txt'\ncurrent_time = time.strftime(...
[ 0, 1, 2, 3, 4 ]
import cv2 as cv import numpy as np from servo import * from func import * #import threading #import dlib # import socket # import struct # import pickle def constrain(val, minv, maxv): return min(maxv, max(minv, val)) KP = 0.22 KI = 0 KD = 0.17 last = 0 integral = 0 # constants SIZE = (400, 300) RECT = np.flo...
normal
{ "blob_id": "3ccbafbdc84447438c194288b1409e332bb2b479", "index": 3630, "step-1": "<mask token>\n\n\ndef constrain(val, minv, maxv):\n return min(maxv, max(minv, val))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef constrain(val, minv, maxv):\n return min(maxv, max(minv, val))\n\n\n<mask token>\nc...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def exportVSSD(path, camName, wantTris=False, renderdata=None): mainFileDict = {} mainFilePath = path mainFileStem = os.path.basename(path)[:-5] mainFileDir = os.path.dirname(path) resolution = pmc.ls('defaul...
flexible
{ "blob_id": "004a9cd0e459116bf3f88f3546ff4eded3dfb2a8", "index": 2512, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef exportVSSD(path, camName, wantTris=False, renderdata=None):\n mainFileDict = {}\n mainFilePath = path\n mainFileStem = os.path.basename(path)[:-5]\n mainFileDir = os.p...
[ 0, 1, 2 ]
# len(): tamanho da string # count(): conta quantas vezes um caractere aparece # lower(), upper() # replace(): substitui as letras por outra # split(): quebra uma string a partir dos espacos em branco a = len('Karen') print(a) b = 'Rainha Elizabeth'.count('a') print(b) c = 'karen nayara'.replace('a','@') print(c) d = ...
normal
{ "blob_id": "3079fdbe6319454ad166d06bda5670554a5746ee", "index": 1004, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a)\n<mask token>\nprint(b)\n<mask token>\nprint(c)\n<mask token>\nprint(d)\n", "step-3": "a = len('Karen')\nprint(a)\nb = 'Rainha Elizabeth'.count('a')\nprint(b)\nc = 'karen nayar...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class TimeEntry: <|reserved_special_token_0|> <|reserved_special_token_1|> class TimeEntry: def __init__(self, date, duration, togglproject='default toggl', tdproject='default td', togglID='NULL', tdID='Null'): self.duration = dura...
flexible
{ "blob_id": "bdf2c35c12820dd31bd242ce1b6dae7271ceb2b7", "index": 8433, "step-1": "<mask token>\n", "step-2": "class TimeEntry:\n <mask token>\n", "step-3": "class TimeEntry:\n\n def __init__(self, date, duration, togglproject='default toggl',\n tdproject='default td', togglID='NULL', tdID='Null'...
[ 0, 1, 2 ]
<|reserved_special_token_0|> @attr('unit') class TestScp(unittest.TestCase): <|reserved_special_token_0|> <|reserved_special_token_0|> @patch('paramiko.SSHClient') def test_scp_close(self, mock_connect): self.dev.bind(scp=SCP) self.dev.scp.open() self.assertEqual(self.dev.scp....
flexible
{ "blob_id": "65ea40ad1c1bf6bf23aed5316b91862c9cdc353d", "index": 5564, "step-1": "<mask token>\n\n\n@attr('unit')\nclass TestScp(unittest.TestCase):\n <mask token>\n <mask token>\n\n @patch('paramiko.SSHClient')\n def test_scp_close(self, mock_connect):\n self.dev.bind(scp=SCP)\n self.d...
[ 4, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('hello world') print('welcome to london') <|reserved_special_token_1|> print("hello world") print("welcome to london")
flexible
{ "blob_id": "cd322f9771f1ac90931a7229ffd5effd1cae1a54", "index": 7207, "step-1": "<mask token>\n", "step-2": "print('hello world')\nprint('welcome to london')\n", "step-3": "print(\"hello world\")\nprint(\"welcome to london\")", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
from load_blender_data import pose_spherical from misc import mse, mse2psnr, to8b import os import imageio import json import torch import torch.nn as nn import numpy as np import cv2 from torch.utils.data.dataset import Dataset from torch.utils.data.dataloader import DataLoader device = torch.device('cuda') if tor...
normal
{ "blob_id": "7180dc0d622fd449fcee32f2c50000d05ae2d8bb", "index": 6850, "step-1": "<mask token>\n\n\nclass BlenderDataset(Dataset):\n <mask token>\n <mask token>\n\n def get_coords2d(self, H, W):\n coord = np.linspace(0, 1, H, endpoint=False)\n coords = np.stack(np.meshgrid(coord, coord), -...
[ 6, 9, 12, 14, 16 ]
def foo(x, y=5): def bar(x): return x + 1 return bar(y * 2) print(foo(3))
normal
{ "blob_id": "80d1979c5767d0ff90f464651c9d0ca6d65effb2", "index": 6472, "step-1": "<mask token>\n", "step-2": "def foo(x, y=5):\n\n def bar(x):\n return x + 1\n return bar(y * 2)\n\n\n<mask token>\n", "step-3": "def foo(x, y=5):\n\n def bar(x):\n return x + 1\n return bar(y * 2)\n\n\...
[ 0, 1, 2 ]
<|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": "8ff7ace102b781b35fff0671e2c606bf662e2767", "index": 9851, "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 = [('education',...
[ 0, 1, 2, 3, 4 ]
""" # listbinmin.py # Sam Connolly 04/03/2013 #=============================================================================== # bin data according a given column in an ascii file of column data, such that # each bin has a minimum number of points, giving the bin of each data point as # a LIST. UNEVEN BINS. #========...
normal
{ "blob_id": "496c58e68d3ac78a3eb1272d61ca3603c5d843b6", "index": 4787, "step-1": "\"\"\"\n# listbinmin.py\n# Sam Connolly 04/03/2013\n\n#===============================================================================\n# bin data according a given column in an ascii file of column data, such that\n# each bin has ...
[ 0 ]
<|reserved_special_token_0|> class LRUCache: <|reserved_special_token_0|> <|reserved_special_token_0|> def put(self, key, value): if key in self.cache_map: old_node = self.cache_map.get(key) self.cache_list.remove(old_node) new_node = Node(key, value) ...
flexible
{ "blob_id": "898ff6e38e80419d61ec4bbde827e8ca729eb19a", "index": 5202, "step-1": "<mask token>\n\n\nclass LRUCache:\n <mask token>\n <mask token>\n\n def put(self, key, value):\n if key in self.cache_map:\n old_node = self.cache_map.get(key)\n self.cache_list.remove(old_node...
[ 2, 3, 4, 5 ]
import math n, m, a = map(int, input().split()) top = math.ceil(n / a) bottom = math.ceil(m / a) print(top * bottom)
normal
{ "blob_id": "6c426d2b165e01a7cec9f7ddbd96113ae05668f6", "index": 4898, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(top * bottom)\n", "step-3": "<mask token>\nn, m, a = map(int, input().split())\ntop = math.ceil(n / a)\nbottom = math.ceil(m / a)\nprint(top * bottom)\n", "step-4": "import math...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 import sys all_neighbors_coord = [] for i in range(-1, 2): for j in range(-1, 2): for k in range(-1, 2): if i != 0 or j != 0 or k != 0: all_neighbors_coord.append((i, j, k)) def add_coord(c1, c2): return (c1[0] + c2[0], c1[1] + c2[1], c1[2] + c2[2]) ...
normal
{ "blob_id": "e7060658ae1838b0870b2a3adb61c9f8d78c93c7", "index": 3245, "step-1": "<mask token>\n\n\nclass life:\n\n def __init__(self, world):\n self.world = world\n\n def get_world_size(self):\n xs = [c[0] for c in self.world]\n ys = [c[1] for c in self.world]\n zs = [c[2] for ...
[ 10, 11, 12, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def validate_locale(locale: t.Union[Locale, str]) ->Locale: if isinstance(locale, str): try: return Locale(locale) except ValueError: raise LocaleError(locale) if not isinstance(lo...
flexible
{ "blob_id": "779445aa22145d5076940ea5b214c25ad233dd0e", "index": 3087, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef validate_locale(locale: t.Union[Locale, str]) ->Locale:\n if isinstance(locale, str):\n try:\n return Locale(locale)\n except ValueError:\n ...
[ 0, 1, 2, 3, 4 ]
from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Upload class DocumentForm(forms.ModelForm): class Meta: model = Upload fields = ('document',)
normal
{ "blob_id": "e7b1ccbcbb81ff02561d858a4db54d49a2aa0f8a", "index": 6094, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass DocumentForm(forms.ModelForm):\n\n\n class Meta:\n model = Upload\n fields = 'document',\n", "step-3": "from django import forms\nfrom django.contrib.auth.mod...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for episode in range(num_episodes): state = env.reset() done = False rewards_current_episode = 0 for step in range(steps_per_episodes): exploration_rate_threshold = random.uniform(0, 1) if explorati...
flexible
{ "blob_id": "b791afec1c9fb214d1f3b4ec0ec67f905d96aabf", "index": 3249, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor episode in range(num_episodes):\n state = env.reset()\n done = False\n rewards_current_episode = 0\n for step in range(steps_per_episodes):\n exploration_rate_thres...
[ 0, 1, 2, 3, 4 ]
import urlparse def parse_url(url): """ Parse a url into a ParseResult() object then evolve that ParseResult() instance into an EasyUrl() object, finally return the EasyUrl() instance. """ url = urlparse.urlparse(url) #print url.__class__ return EasyUrl.EvolveParseResult(url) class ...
normal
{ "blob_id": "0d322bdaf1bfed2b76172cc4dfb1b9af52bdc641", "index": 8264, "step-1": "import urlparse\n\n\n\n\ndef parse_url(url):\n \"\"\" \n Parse a url into a ParseResult() object then evolve that ParseResult()\n instance into an EasyUrl() object, finally return the EasyUrl() instance.\n \"\"\"\n u...
[ 0 ]
<|reserved_special_token_0|> def sort_id(movies, titles): ids = [] for i in titles: try: movie_id = MovieDB.objects.get(title=i).id ids.append((i, movie_id)) except MovieDB.DoesNotExist: return [] return ids <|reserved_special_token_0|> def sort_name...
flexible
{ "blob_id": "1e84b28580b97e77394be0490f3d8db3d62a2ccb", "index": 1213, "step-1": "<mask token>\n\n\ndef sort_id(movies, titles):\n ids = []\n for i in titles:\n try:\n movie_id = MovieDB.objects.get(title=i).id\n ids.append((i, movie_id))\n except MovieDB.DoesNotExist:\n...
[ 3, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.28 on 2020-07-10 02:52 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('civictechprojects', '0036_auto_20200708_2251'), ] operations = [ migration...
normal
{ "blob_id": "99154212d8d5fdb92cd972c727791158d09e3e2c", "index": 3789, "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 = [('civictechpr...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class CoursesDetailView(DetailView): <|reserved_special_token_0|> <|reserved_special_token_0|> def get_context_data(self, *args, object_list=None, **kwargs): context = super(CoursesDetailView, self).get_context_data(*args, ** kwargs) print(context)...
flexible
{ "blob_id": "aaa9665ac6d639e681fddd032058f490ce36d12a", "index": 7684, "step-1": "<mask token>\n\n\nclass CoursesDetailView(DetailView):\n <mask token>\n <mask token>\n\n def get_context_data(self, *args, object_list=None, **kwargs):\n context = super(CoursesDetailView, self).get_context_data(*ar...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class DataGenerator(IterableDataset): <|reserved_special_token_0|> <|reserved_special_token_0|> class CrossEncoderModel(torch.nn.Module): def __init__(self): super(CrossEncoderModel, self).__init__() self.bert = AutoModel.from_pretrained('distilbert-base-cas...
flexible
{ "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 ]
import copy import sys import os from datetime import datetime,timedelta from dateutil.relativedelta import relativedelta import numpy as np import pandas import tsprocClass as tc import pestUtil as pu #update parameter values and fixed/unfixed #--since Joe is so pro-America... tc.DATE_FMT = '%m/%d/%Y' #--build ...
normal
{ "blob_id": "c060cdb7730ba5c4d2240b65331f5010cac222fa", "index": 8721, "step-1": "import copy\nimport sys\nimport os\nfrom datetime import datetime,timedelta\nfrom dateutil.relativedelta import relativedelta\nimport numpy as np\nimport pandas\n\nimport tsprocClass as tc \nimport pestUtil as pu \n\n#update param...
[ 0 ]
''' Compress images ''' from PIL import Image def resizeImage(image_file): try: # get the image's width and height in pixels img = Image.open(image_file) width, height = img.size # get the largest dimension max_dim = max(img.size) if max_dim > 1000: # resize the image using the largest side as dime...
normal
{ "blob_id": "1b43125c2ebffd0a268a4a0ffdbbf407de7b0374", "index": 7486, "step-1": "''' Compress images '''\n\nfrom PIL import Image\n\n\ndef resizeImage(image_file):\n\ttry:\n\t\t# get the image's width and height in pixels\n\t\timg = Image.open(image_file)\n\t\twidth, height = img.size\n\n\t\t# get the largest d...
[ 0 ]
<|reserved_special_token_0|> class TelaLisatrClientes: <|reserved_special_token_0|> def init_components(self, lista_clientes): layout = [[sg.Text('Dados do cliente')], [sg.Listbox(values= lista_clientes, size=(60, 10))], [sg.Submit()]] self.__window = sg.Window('Lista de clientes'...
flexible
{ "blob_id": "624b34d160ea6db4f5249544f1614a20f506ca9e", "index": 895, "step-1": "<mask token>\n\n\nclass TelaLisatrClientes:\n <mask token>\n\n def init_components(self, lista_clientes):\n layout = [[sg.Text('Dados do cliente')], [sg.Listbox(values=\n lista_clientes, size=(60, 10))], [sg....
[ 2, 3, 4, 5, 6 ]
def read_int(): return int(input().strip()) def read_ints(): return list(map(int, input().strip().split(' '))) def solve(): K, S = read_ints() # X+Y+Z = S # 0 <= X,Y,Z <= K total = 0 for X in range(K+1): if S-X < 0: break # Y+Z=S-X Y_min = max(S-X-K,...
normal
{ "blob_id": "46b1fc975fbeedcafaa66c85c378e2249a495647", "index": 8827, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef read_ints():\n return list(map(int, input().strip().split(' ')))\n\n\ndef solve():\n K, S = read_ints()\n total = 0\n for X in range(K + 1):\n if S - X < 0:\n ...
[ 0, 2, 3, 4, 5 ]
# USAGE # python predict_video.py --model model/activity.model --label-bin model/lb.pickle --input example_clips/lifting.mp4 --output output/lifting_128avg.avi --size 128 # python predict_video.py --model model/road_activity.model --label-bin model/rd.pickle --input example_clips/fire_footage.mp4 --ou # tput output/fir...
normal
{ "blob_id": "ccfcc5b644d592090786ceb35a85124c9d3275ad", "index": 5719, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('Main_page.html')\n\n\n@app.route('/prediction.html')\ndef predict():\n return render_template('prediction.html')\n\n\n@app.route('/About_us.html')\ndef...
[ 4, 5, 6, 7, 8 ]
import itertools import unittest from pylev3 import Levenshtein TEST_DATA = [ ('classic', "kitten", "sitting", 3), ('same', "kitten", "kitten", 0), ('empty', "", "", 0), ('a', "meilenstein", "levenshtein", 4), ('b', "levenshtein", "frankenstein", 6), ('c', "confide", "deceit", 6), ('d', "...
normal
{ "blob_id": "892d6662e4276f96797c9654d15c96a608d0835a", "index": 8927, "step-1": "<mask token>\n\n\nclass Tests(unittest.TestCase):\n\n def test_singleton(self):\n lev1, lev2 = Levenshtein(), Levenshtein()\n self.assertIs(lev1, lev2)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Tes...
[ 2, 3, 4, 5, 7 ]
import torch.nn as nn from torch.autograd import Variable import torch import string all_letters = string.ascii_letters + " .,;'" n_letters = len(all_letters) #Find letter index from all_letters, e.g. "a" = 0 def letterToIndex(letter): return all_letters.find(letter) #Only for demonstation def letterToTensor(let...
normal
{ "blob_id": "aa24442624aebeb2777f16a826cf59859d7870ba", "index": 8744, "step-1": "<mask token>\n\n\ndef letterToIndex(letter):\n return all_letters.find(letter)\n\n\n<mask token>\n\n\nclass RNN(nn.Module):\n\n def __init__(self, input_size, hidden_size, output_size):\n super(RNN, self).__init__()\n ...
[ 6, 7, 10, 11, 13 ]
<|reserved_special_token_0|> def get_changelog(): with open(os.path.join(here, 'CHANGELOG'), encoding='utf-8') as f: text = f.read() header_matches = list(re.finditer('^=+$', text, re.MULTILINE)) text = text[:header_matches[5].start()] lines = text.splitlines()[:-1] return '=========\nChan...
flexible
{ "blob_id": "c81889cf4d87933b562aa4618bc5185a8d213107", "index": 8075, "step-1": "<mask token>\n\n\ndef get_changelog():\n with open(os.path.join(here, 'CHANGELOG'), encoding='utf-8') as f:\n text = f.read()\n header_matches = list(re.finditer('^=+$', text, re.MULTILINE))\n text = text[:header_ma...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> cv2.imshow('image', img) cv2.waitKey(0) cv2.destroyAllWindows() plt.imshow(img, cmap='gray', interpolation='bicubic') plt.show() <|reserved_special_token_1|> <|reserved_special_token_0|> img = cv2.imread('test.jpg', cv2.IMREAD_...
flexible
{ "blob_id": "34ccaaf5eb47afd556588cd94cddbddaee1f0b53", "index": 2851, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.imshow('image', img)\ncv2.waitKey(0)\ncv2.destroyAllWindows()\nplt.imshow(img, cmap='gray', interpolation='bicubic')\nplt.show()\n", "step-3": "<mask token>\nimg = cv2.imread('test....
[ 0, 1, 2, 3, 4 ]
import unittest import TicTacToe class pVpTestCase(unittest.TestCase): # def test_something(self): # self.assertEqual(True, False) def twoplayer_setup(self): game1 = TicTacToe.Game() player1 = TicTacToe.Player('X', game1) player2 = TicTacToe.Player('O', game1) return (g...
normal
{ "blob_id": "de0521db3909054c333ac3877ff0adf15ab180fb", "index": 1732, "step-1": "<mask token>\n\n\nclass CvPTestCase(unittest.TestCase):\n\n def onecompplayer_setup(self):\n game1 = TicTacToe.Game()\n computer1 = TicTacToe.Computer('X', game1)\n player2 = TicTacToe.Player('O', game1)\n ...
[ 13, 15, 17, 20, 22 ]
#!/usr/bin/env python3 # coding=utf-8 import fire import json import os import time import requests import time import hashlib import random root_path, file_name = os.path.split(os.path.realpath(__file__)) ip_list_path = ''.join([root_path, os.path.sep, 'ip_list.json']) class ProxySwift(object): ...
normal
{ "blob_id": "0ff96b2314927d7b3e763242e554fd561f3c9343", "index": 5872, "step-1": "<mask token>\n\n\nclass ProxySwift(object):\n <mask token>\n\n def requerst_get(self, url, data, *p, **kwargs):\n SecretKey = '3JCx8fAF7Bpq5Aj4t9wS7cfVB7hpXZ7j'\n PartnerID = '2017061217350058'\n TimeStam...
[ 9, 10, 13, 14, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> model.fit(data_train, label_train) <|reserved_special_token_0|> print(model.score(data_test, label_test)) print(accuracy_score(label_test, predictions)) print(accuracy_score(label_test, predictions, normalize=False)) print(metrics...
flexible
{ "blob_id": "33365d5ce5d2a7d28b76a7897de25e1f35d28855", "index": 6269, "step-1": "<mask token>\n", "step-2": "<mask token>\nmodel.fit(data_train, label_train)\n<mask token>\nprint(model.score(data_test, label_test))\nprint(accuracy_score(label_test, predictions))\nprint(accuracy_score(label_test, predictions, ...
[ 0, 1, 2, 3, 4 ]
from tornado import gen import rethinkdb as r from .connection import connection from .utils import dump_cursor @gen.coroutine def get_promotion_keys(): conn = yield connection() result = yield r.table('promotion_keys').run(conn) result = yield dump_cursor(result) return result @gen.coroutine def p...
normal
{ "blob_id": "66cdfdfa797c9991e5cb169c4b94a1e7041ca458", "index": 4772, "step-1": "<mask token>\n\n\n@gen.coroutine\ndef pop_promotion_key(promotion_key):\n conn = yield connection()\n result = yield r.table('promotion_keys').get(promotion_key).delete(\n return_changes=True).run(conn)\n if result[...
[ 1, 2, 3, 4, 5 ]
# put your python code here a = int(input()) b = int(input()) # and i = 1 if a == b: print(a) else: while True: if i // a > 0 and i % a == 0 and i // b > 0 and i % b == 0: print(i) break else: i += 1
normal
{ "blob_id": "af5ebdcd818fdf9c607240733b7b5dbb793cf55e", "index": 7328, "step-1": "<mask token>\n", "step-2": "<mask token>\nif a == b:\n print(a)\nelse:\n while True:\n if i // a > 0 and i % a == 0 and i // b > 0 and i % b == 0:\n print(i)\n break\n else:\n ...
[ 0, 1, 2, 3 ]
import pytest from components import models pytestmark = pytest.mark.django_db def test_app_models(): assert models.ComponentsApp.allowed_subpage_models() == [ models.ComponentsApp, models.BannerComponent, ] def test_app_required_translatable_fields(): assert models.ComponentsApp.get_r...
normal
{ "blob_id": "b1622aa65422fcb69a16ad48a26fd9ed05b10382", "index": 8882, "step-1": "<mask token>\n\n\ndef test_app_models():\n assert models.ComponentsApp.allowed_subpage_models() == [models.\n ComponentsApp, models.BannerComponent]\n\n\n<mask token>\n\n\n@pytest.mark.django_db\ndef test_set_slug(en_loca...
[ 2, 3, 4, 5, 6 ]
# (1) Obtain your values here (https://core.telegram.org/api/obtaining_api_id) api_id = 000000 api_hash = '00000000000000000000000' phone = '+000000000000' username = 'theone' project_id = 000000000
normal
{ "blob_id": "a5646a5d42dbf6e70e9d18f28513ee2df68a28b1", "index": 6886, "step-1": "<mask token>\n", "step-2": "api_id = 0\napi_hash = '00000000000000000000000'\nphone = '+000000000000'\nusername = 'theone'\nproject_id = 0\n", "step-3": "# (1) Obtain your values here (https://core.telegram.org/api/obtaining_ap...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(numbers) print(numbers[1]) print(numbers[-1]) <|reserved_special_token_0|> print(numbers) del numbers[1] print(numbers) numbers.append(17) print(numbers) numbers.insert(2, 5) print(numbers) numbers.sort() print(numbers) <|...
flexible
{ "blob_id": "34d3eebf6ccb19f891ccbb16db47cd6412f1cb0f", "index": 1155, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(numbers)\nprint(numbers[1])\nprint(numbers[-1])\n<mask token>\nprint(numbers)\ndel numbers[1]\nprint(numbers)\nnumbers.append(17)\nprint(numbers)\nnumbers.insert(2, 5)\nprint(number...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python """ Update the expected test outputs and inputs for rsmsummarize and rsmcompare tests. This script assumes that you have already run `nose2 -s tests` and ran the entire test suite. By doing so, the output has been generated under the given outputs directory. And that is what will be used to gener...
normal
{ "blob_id": "7e20c61fa30ea93e69a2479e70449638eb52b7bb", "index": 2964, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n parser = argparse.ArgumentParser(prog='update_test_files.py')\n parser.add_argument('--tests', dest='tests_dir', required=True, help=\n 'The path to the exi...
[ 0, 1, 2, 3, 4 ]
from __future__ import print_function, absolute_import, division import os import h5py import glob import copy import numpy as np from tqdm import tqdm # from utils.pose import draw_skeleton from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D import poseutils.camera_utils as cameras from pose...
normal
{ "blob_id": "cf6dffb28e37003212d3e3402dee58a57a7d9869", "index": 5192, "step-1": "<mask token>\n\n\nclass TDPWDataset(object):\n\n def __init__(self, path, center_2d=False, load_metrics=None, skel_norm=\n False):\n super(TDPWDataset, self).__init__()\n self.cameras = None\n self._d...
[ 5, 8, 10, 11, 15 ]
# -*- coding: utf-8 -*- class Task: def __init__(self): self.title = '' self.subtasks = [] def set_title(self, title): self.title = title def set_subtasks(self, subtasks): self.subtasks = subtasks
normal
{ "blob_id": "3cf2ffbc8163c2a447016c93ff4dd13e410fff2b", "index": 7353, "step-1": "<mask token>\n", "step-2": "class Task:\n <mask token>\n <mask token>\n\n def set_subtasks(self, subtasks):\n self.subtasks = subtasks\n", "step-3": "class Task:\n\n def __init__(self):\n self.title = ...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def largo(l, n): i = 0 cuenta = 1 valor1 = 0 valor2 = 0 while cuenta < n + 1 or cuenta == n + 1: a = l[i] b = l[i + 1] if a == b: cuenta += 1 valor1 = a ...
flexible
{ "blob_id": "f3b697e20f60e51d80d655ddf4809aa9afdfcd69", "index": 7495, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef largo(l, n):\n i = 0\n cuenta = 1\n valor1 = 0\n valor2 = 0\n while cuenta < n + 1 or cuenta == n + 1:\n a = l[i]\n b = l[i + 1]\n if a == b:\n...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.1 on 2020-08-28 14:03 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('api_rest', '0004_auto_20200828_0749'), ] operations = [ migrations.RemoveField( model_name='event', name='user_id', ...
normal
{ "blob_id": "bfd8385e8f4886b91dde59c04785134b9cd6a2b6", "index": 3893, "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 = [('api_rest', ...
[ 0, 1, 2, 3, 4 ]
from .base import * # noqa from .base import env # exemple https://github.com/pydanny/cookiecutter-django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/config/settings/production.py # GENERAL # ------------------------------------------------------------------------------ # https://docs.djangoproject.com/en/dev/r...
normal
{ "blob_id": "836df02495ee581f138050be6b7a7a076ea899eb", "index": 4966, "step-1": "<mask token>\n", "step-2": "<mask token>\nSECRET_KEY = env('DJANGO_SECRET_KEY')\nALLOWED_HOSTS = [x.split(':') for x in env.list('DJANGO_ALLOWED_HOSTS')]\nADMINS = [x.split(':') for x in env.list('DJANGO_ADMINS')]\nDATABASES['def...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class TestPanel(wx.Panel): def __init__(self, parent, log): self.log = log wx.Panel.__init__(self, parent, -1) b1 = wx.Button(self, -1, 'Create and Show a MiniFrame', (50, 50)) self.Bind(wx.EVT_BUTTON, self.OnButton1, b1) b2 = wx.Button(self, -...
flexible
{ "blob_id": "b041e9577af72d2bcee3dda0cc78fa12800d53bd", "index": 2286, "step-1": "<mask token>\n\n\nclass TestPanel(wx.Panel):\n\n def __init__(self, parent, log):\n self.log = log\n wx.Panel.__init__(self, parent, -1)\n b1 = wx.Button(self, -1, 'Create and Show a MiniFrame', (50, 50))\n ...
[ 12, 14, 16, 19, 22 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class CurriculoSerializer(serializers.ModelSerializer): class Meta: model = Curriculo fields = 'id', 'name', 'description', 'image', 'create_at', 'update_at' <|reserved_special_token_1|> from rest_framew...
flexible
{ "blob_id": "029f4f015f558dbd4d6096b00c53f5f0fe69883d", "index": 1322, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CurriculoSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Curriculo\n fields = 'id', 'name', 'description', 'image', 'create_at', 'update_at...
[ 0, 1, 2, 3 ]
# Import smtplib for the actual sending function import smtplib # Import the email modules we'll need from email.message import EmailMessage # Open the plain text file whose name is in textfile for reading. with open("testfile.txt") as fp: # Create a text/plain message msg = EmailMessage() msg.set_content...
normal
{ "blob_id": "9feb24da78113310509664fa9efcf5f399be5335", "index": 5914, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('testfile.txt') as fp:\n msg = EmailMessage()\n msg.set_content('test')\n<mask token>\ns.send_message(msg)\ns.quit()\n", "step-3": "<mask token>\nwith open('testfile.txt...
[ 0, 1, 2, 3, 4 ]
""" This file goes through the data to find the frequencies of words in the corpus """ import csv import time, datetime import calendar from collections import defaultdict import chardet import re REVIEW_ID_COL = 0; USER_ID_COL = 1 BUSINESS_ID_COL = 2 STARS_COL = 3 DATE_COL = 4 TEXT_COL = 5 USEFUL_CO...
normal
{ "blob_id": "ba54b3a148a34ced74a337665ddd5f2d9084553b", "index": 1489, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('yelp_review.csv', encoding='utf8') as csvfile:\n wordFrequencies = defaultdict(int)\n\n def beautifyDate(res):\n dt = time.strptime(res, '%Y-%m-%d')\n retur...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> brick.sound.beep() wait(1000) motor_a.run_target(500, 720) wait(1000) brick.sound.beep(1000, 500) <|reserved_special_token_1|> <|reserved_special_token_0|> motor_a = Motor(Port.A) brick.sound.beep() wait(1000) motor_a.run_targe...
flexible
{ "blob_id": "f6ebc3c37a69e5ec49d91609db394eec4a94cedf", "index": 9982, "step-1": "<mask token>\n", "step-2": "<mask token>\nbrick.sound.beep()\nwait(1000)\nmotor_a.run_target(500, 720)\nwait(1000)\nbrick.sound.beep(1000, 500)\n", "step-3": "<mask token>\nmotor_a = Motor(Port.A)\nbrick.sound.beep()\nwait(1000...
[ 0, 1, 2, 3, 4 ]
# drop data to file filter import tarr.compiler_base def format_data(data): return '{0.id}: {0.payload}'.format(data) class WRITE_TO_FILE(tarr.compiler_base.Instruction): @property def __name__(self): return 'POINT OF INTEREST - WRITE("{}")'.format(self.filename) def __init__(self, filenam...
normal
{ "blob_id": "75393d39b147097a7ac1d82938ac102491ea9441", "index": 8469, "step-1": "<mask token>\n\n\nclass WRITE_TO_FILE(tarr.compiler_base.Instruction):\n\n @property\n def __name__(self):\n return 'POINT OF INTEREST - WRITE(\"{}\")'.format(self.filename)\n\n def __init__(self, filename, formatte...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def draw_chat(id, smooth_id, main_mode, my_name, chat_day_data, main_plot, pie_plot, list_chats_plot): min_in_day = 1440 possible_smooth = [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 30, 32, 36, 40,...
flexible
{ "blob_id": "b297a09ee19bb8069eb65eb085903b3219c6fe5a", "index": 7971, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef draw_chat(id, smooth_id, main_mode, my_name, chat_day_data, main_plot,\n pie_plot, list_chats_plot):\n min_in_day = 1440\n possible_smooth = [1, 2, 3, 4, 5, 6, 8, 9, 10, ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open('./roc.txt', 'r') as fin: with open('./roc_shuffle.txt', 'w') as fout: tmp = [] for k, line in enumerate(fin): i = k + 1 if i % 6 == 0: idx = [0] + np.random.pe...
flexible
{ "blob_id": "2aec0581413d4fb0ffb4090231fde0fed974bf18", "index": 27, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('./roc.txt', 'r') as fin:\n with open('./roc_shuffle.txt', 'w') as fout:\n tmp = []\n for k, line in enumerate(fin):\n i = k + 1\n if i % 6 ...
[ 0, 1, 2, 3 ]
import os error_msg = '''The default transformer cannot handle slashes (subdirectories); try another transformer in vlermv.transformers.''' def to_path(key): if isinstance(key, tuple): if len(key) == 1: key = key[0] else: raise ValueError(error_msg) if '/' in key or '\...
normal
{ "blob_id": "e4ff6d689a7da5b16786fd59d6a4707b9b6e3e7d", "index": 8076, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef to_path(key):\n if isinstance(key, tuple):\n if len(key) == 1:\n key = key[0]\n else:\n raise ValueError(error_msg)\n if '/' in key or '\...
[ 0, 2, 3, 4, 5 ]
from selenium import webdriver import time def test_check_error_page_1(): try: link = "http://suninjuly.github.io/registration1.html" browser = webdriver.Chrome() browser.get(link) # Проверяем Fisrt name* field_text = browser.find_element_by_xpath( '//body/div/f...
normal
{ "blob_id": "83ebebbb6191295adcb58b003bf1c3bcc6fb189f", "index": 7405, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_check_error_page_1():\n try:\n link = 'http://suninjuly.github.io/registration1.html'\n browser = webdriver.Chrome()\n browser.get(link)\n fiel...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def greedy(s, k): m_1 = random.choice(list(s.keys())) medoids = {m_1: s[m_1]} dimensions = list(range(len(s[m_1]))) s.pop(m_1) dist = {} for x in s: dist[x] = Manhattan_segmental_dist.manhattan_se...
flexible
{ "blob_id": "9a02bd0bc14494db033c032003aa5baea111ea8c", "index": 7185, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef greedy(s, k):\n m_1 = random.choice(list(s.keys()))\n medoids = {m_1: s[m_1]}\n dimensions = list(range(len(s[m_1])))\n s.pop(m_1)\n dist = {}\n for x in s:\n ...
[ 0, 1, 2, 3 ]
import tensorflow as tf import bbox_lib def hard_negative_loss_mining(c_loss, negative_mask, k): """Hard negative mining in classification loss.""" # make sure at least one negative example k = tf.maximum(k, 1) # make sure at most all negative. k = tf.minimum(k, c_loss.shape[-1]) neg_c_loss = ...
normal
{ "blob_id": "6e17fef4507c72190a77976e4a8b2f56880f2d6f", "index": 4895, "step-1": "<mask token>\n\n\ndef hard_negative_loss_mining(c_loss, negative_mask, k):\n \"\"\"Hard negative mining in classification loss.\"\"\"\n k = tf.maximum(k, 1)\n k = tf.minimum(k, c_loss.shape[-1])\n neg_c_loss = c_loss * ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class SpiderForCROWDCUBETest(unittest.TestCase): def setUp(self): logging.basicConfig(level=logging.INFO) self.spider = SpiderForCROWDCUBE() self.spider.initDriver() <|reserved_special_token_0|> <|reserved_special_token_0|> def test_downloadCompan...
flexible
{ "blob_id": "45856b4c5cbf1d3b414ad769135b2d974bc0a22b", "index": 7120, "step-1": "<mask token>\n\n\nclass SpiderForCROWDCUBETest(unittest.TestCase):\n\n def setUp(self):\n logging.basicConfig(level=logging.INFO)\n self.spider = SpiderForCROWDCUBE()\n self.spider.initDriver()\n <mask to...
[ 3, 4, 6, 7, 8 ]
<|reserved_special_token_0|> class Script(BaseScript): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|>...
flexible
{ "blob_id": "40b3c403f99044eb61740d62eda15ddd08b0f739", "index": 1980, "step-1": "<mask token>\n\n\nclass Script(BaseScript):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <m...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> explore_patterns = [url('^$', views.explore), url('^(?P<model_type>\\w+)/$', views.get_by_model_type), url('^(?P<model_type>\\w+)/(?P<id>\\w+)/$', views.get_by_model_id), url( '^(?P<model_type>\\w+)/(?P<id>\\w+)/downlo...
flexible
{ "blob_id": "89078ddd7dad3a2727b66566457b9ac173abe607", "index": 8506, "step-1": "<mask token>\n", "step-2": "<mask token>\nexplore_patterns = [url('^$', views.explore), url('^(?P<model_type>\\\\w+)/$',\n views.get_by_model_type), url('^(?P<model_type>\\\\w+)/(?P<id>\\\\w+)/$',\n views.get_by_model_id), ...
[ 0, 1, 2, 3 ]
import torch import random from itertools import product from Struct import Action class Agent(object): """the agent""" def __init__(self, q, epsilon=0.8, discount=0.9, learningRate=0.5, traceDecay=0.3): # action set possibleChangesPerMagnet = (1e-2, 1e-3, 0, -1e-2, -1e-3) # possible...
normal
{ "blob_id": "63edbbbad9561ddae005d2b5e22a089819dc34c5", "index": 1821, "step-1": "<mask token>\n\n\nclass Agent(object):\n <mask token>\n\n def __init__(self, q, epsilon=0.8, discount=0.9, learningRate=0.5,\n traceDecay=0.3):\n possibleChangesPerMagnet = 0.01, 0.001, 0, -0.01, -0.001\n ...
[ 8, 9, 10, 12, 13 ]
__version__ = '0.2.11' # This list defines all the modules that will be loaded if a user invokes # from climLab import * # totally out of date! #__all__ = ["constants", "thermo", "orbital_table", # "long_orbital_table", "insolation", "ebm", # "column", "convadj"] #from climlab import radiatio...
normal
{ "blob_id": "8251a9c798b3cdc2f374d0a0406ccfaa11b7c5e3", "index": 5699, "step-1": "<mask token>\n", "step-2": "__version__ = '0.2.11'\n<mask token>\n", "step-3": "__version__ = '0.2.11'\nfrom climlab.utils import constants\nfrom climlab.utils import thermo, legendre\nfrom climlab.model.column import GreyRadia...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class Application(tk.Frame): <|reserved_special_token_0|> <|reserved_special_token_0|> def show_win(self): msg = 'YOU WIN!' mb.showinfo('Information', msg) self.makePlayButtons() def move(self, num): def move2(self=self, num=num): ...
flexible
{ "blob_id": "f29bc0263f8bb1d59ab2442347727d9d3233ec77", "index": 9893, "step-1": "<mask token>\n\n\nclass Application(tk.Frame):\n <mask token>\n <mask token>\n\n def show_win(self):\n msg = 'YOU WIN!'\n mb.showinfo('Information', msg)\n self.makePlayButtons()\n\n def move(self, ...
[ 5, 7, 8, 9, 11 ]
<|reserved_special_token_0|> def download_install_deb(package_path, package_url): download_file(package_path, package_url) install_debian_package_binary(package_path) remove_file(package_path) <|reserved_special_token_0|> def write_file(path, data, mode='w'): if os.path.exists(path) and mode is no...
flexible
{ "blob_id": "f546eb40ee8a7308ded62532731561029e5ec335", "index": 7870, "step-1": "<mask token>\n\n\ndef download_install_deb(package_path, package_url):\n download_file(package_path, package_url)\n install_debian_package_binary(package_path)\n remove_file(package_path)\n\n\n<mask token>\n\n\ndef write_f...
[ 4, 6, 7, 8, 10 ]
<|reserved_special_token_0|> class MainHandler(BaseHandler): <|reserved_special_token_0|> def get(self): """Returns the root endpoint of the API.""" self.write( '{"error": "cryptochat-server main page, please refer to /api/message/new or /api/message/updates"}' ) cla...
flexible
{ "blob_id": "9f8d79d141d414c1256e39f58e59f97711acfee4", "index": 4915, "step-1": "<mask token>\n\n\nclass MainHandler(BaseHandler):\n <mask token>\n\n def get(self):\n \"\"\"Returns the root endpoint of the API.\"\"\"\n self.write(\n '{\"error\": \"cryptochat-server main page, plea...
[ 17, 19, 22, 25, 31 ]
# -*- coding: utf-8 -*- """Code handling the concurrency of data analysis."""
normal
{ "blob_id": "2e23225ec4cd693f5e9460a13d64206f184a86a0", "index": 3043, "step-1": "<mask token>\n", "step-2": "# -*- coding: utf-8 -*-\n\"\"\"Code handling the concurrency of data analysis.\"\"\"\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> class V_test_abstract(V): def __init__(self): super(V_test_abstract, self).__init__() <|reserved_special_token_0|> def forward(self): z = self.beta[:self.dim] r1_local = self.beta[self.dim:2 * self.dim] r2_local = self.beta[2 * self.dim:3 * se...
flexible
{ "blob_id": "27e9e63338d422b5fca6f7a67fa3d255602a3358", "index": 225, "step-1": "<mask token>\n\n\nclass V_test_abstract(V):\n\n def __init__(self):\n super(V_test_abstract, self).__init__()\n <mask token>\n\n def forward(self):\n z = self.beta[:self.dim]\n r1_local = self.beta[self...
[ 3, 4, 5, 6, 7 ]
# MegEngine is Licensed under the Apache License, Version 2.0 (the "License") # # Copyright (c) 2014-2020 Megvii Inc. All rights reserved. # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY ...
normal
{ "blob_id": "a83230e71cc1bcc843d00487746f16114d304eec", "index": 4908, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef mge_to_caffe(mge_fpath, prototxt='out.prototxt', caffemodel=\n 'out.caffemodel', outspec=None, use_empty_blobs=False):\n assert isinstance(mge_fpath, str), 'mge_fpath must b...
[ 0, 1, 2, 3 ]
#!/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 ]
import spacy from vaderSentiment import vaderSentiment from flask import Flask, render_template, request app = Flask(__name__) @app.route('/') def hello(): return render_template('index.html') @app.route('/',methods=['POST']) def func(): st=request.form["review"] if(st==''): return render_temp...
normal
{ "blob_id": "2d7f7cb66480ecb8335949687854554679026959", "index": 9988, "step-1": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return render_template('index.html')\n\n\n@app.route('/', methods=['POST'])\ndef func():\n st = request.form['review']\n if st == '':\n return render_template('index...
[ 4, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- """ Created on Tue Dec 31 05:48:57 2019 @author: emama """ import datetime as dt t = dt.datetime.today() print(t)
normal
{ "blob_id": "b1fbc8f3616b70e5d35898fd895c37e838c87dc9", "index": 9293, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(t)\n", "step-3": "<mask token>\nt = dt.datetime.today()\nprint(t)\n", "step-4": "<mask token>\nimport datetime as dt\nt = dt.datetime.today()\nprint(t)\n", "step-5": "# -*- co...
[ 0, 1, 2, 3, 4 ]
print("hello world") print("lol") print("new changes in vis")
normal
{ "blob_id": "6c88e55a76cbd84cee0ebd6c51d930cc2da100d2", "index": 2945, "step-1": "<mask token>\n", "step-2": "print('hello world')\nprint('lol')\nprint('new changes in vis')\n", "step-3": "print(\"hello world\")\nprint(\"lol\")\nprint(\"new changes in vis\")", "step-4": null, "step-5": null, "step-ids"...
[ 0, 1, 2 ]
import pytest from apistar import App, Route, TestClient, exceptions from apistar_request_id import RequestId, RequestIdHooks def index() -> dict: return {} def fail() -> dict: raise exceptions.BadRequest("fail") def fail_2() -> dict: raise RuntimeError("fail") routes = [ Route("/", method="GET...
normal
{ "blob_id": "f41ab6813fb7067089abe223b9006adde40630cd", "index": 1941, "step-1": "<mask token>\n\n\ndef index() ->dict:\n return {}\n\n\n<mask token>\n\n\n@pytest.fixture\ndef client(app):\n return TestClient(app)\n\n\ndef test_request_id_can_be_autogenerated(client):\n response = client.get('/')\n a...
[ 6, 9, 10, 11, 12 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> s.connect((HOST, PORT)) <|reserved_special_token_1|> <|reserved_special_token_0|> HOST = '127.0.0.1' PORT = 4444 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) <|reserved_special_token_1|> impo...
flexible
{ "blob_id": "14a39b9aa56777c8198794fe2f51c9a068500743", "index": 4075, "step-1": "<mask token>\n", "step-2": "<mask token>\ns.connect((HOST, PORT))\n", "step-3": "<mask token>\nHOST = '127.0.0.1'\nPORT = 4444\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.connect((HOST, PORT))\n", "step-4": "imp...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TGAbstractRegistry(ABC): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class TGAbstractRegistry(ABC): def __init__(self): self.rule_engine = TGLoggingRuleEngin...
flexible
{ "blob_id": "d499b4e189a0c3c6efa6a07871dbc6c2996a2dcb", "index": 2245, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TGAbstractRegistry(ABC):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TGAbstractRegistry(ABC):\n\n def __init__(self):\n self.rule_engine = TGLoggingRule...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> admin.site.register(Post) <|reserved_special_token_1|> from django.contrib import admin from trips.models import Post admin.site.register(Post)
flexible
{ "blob_id": "a8197a4f0bb84e734696bf43fa976c76732d75b8", "index": 9863, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Post)\n", "step-3": "from django.contrib import admin\nfrom trips.models import Post\nadmin.site.register(Post)\n", "step-4": null, "step-5": null, "step-ids":...
[ 0, 1, 2 ]
config_info = {'n_input': 1, 'num_layers': 1, 'features': 20, 'sequence_length': 1344, 'num_steps': None, 'lstm_size': None, 'batch_size': None, 'init_learning_rate': None, 'learning_rate_decay': None, 'init_epoch': None, 'max_epoch': None, 'dropout_rate': None}
normal
{ "blob_id": "8ede786526f4b730173777d9d3b9c7e4554fc887", "index": 2443, "step-1": "<mask token>\n", "step-2": "config_info = {'n_input': 1, 'num_layers': 1, 'features': 20,\n 'sequence_length': 1344, 'num_steps': None, 'lstm_size': None,\n 'batch_size': None, 'init_learning_rate': None, 'learning_rate_dec...
[ 0, 1 ]