code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
import settings #from django.conf import settings from django.conf.urls import patterns, include, url from django.contrib import admin from django.conf.urls.static import static from django.contrib.staticfiles.urls import staticfiles_urlpatterns #admin.autodiscover() # Uncomment the next two lines to enable the admin...
normal
{ "blob_id": "acb85a16e45472dac61eed4162dc651f67a0e8ca", "index": 5400, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.autodiscover()\n<mask token>\n", "step-3": "<mask token>\nadmin.autodiscover()\nurlpatterns = patterns('', url('^media/(?P<path>.*)$',\n 'django.views.static.serve', {'document...
[ 0, 1, 2, 3, 4 ]
"""Code for constructing and executing Tasks""" from bcipy.tasks.rsvp.calibration.alert_tone_calibration import RSVPAlertToneCalibrationTask from bcipy.tasks.rsvp.calibration.inter_sequence_feedback_calibration import ( RSVPInterSequenceFeedbackCalibration ) from bcipy.tasks.rsvp.calibration.calibration import RSVP...
normal
{ "blob_id": "f2e6d23e6d8c5aa6e80a652dc6cb8bda45824d0c", "index": 1026, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef start_task(display_window, daq, exp_type, parameters, file_save,\n signal_model=None, language_model=None, fake=True, auc_filename=None):\n \"\"\"Creates a Task and starts e...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for s in f_s_list: os.system('python SKs_model.py ' + str(s) + ' 0 10000 0 relu') for train_end in g_end_list: os.system('python SKs_model.py 0.2 0 ' + str(train_end) + ' 0 relu') for train_begin, train_end in h_i_list: ...
flexible
{ "blob_id": "56a681015ea27e2c8e00ab8bcc8019d5987c4ee1", "index": 6949, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor s in f_s_list:\n os.system('python SKs_model.py ' + str(s) + ' 0 10000 0 relu')\nfor train_end in g_end_list:\n os.system('python SKs_model.py 0.2 0 ' + str(train_end) + ' 0 rel...
[ 0, 1, 2, 3, 4 ]
from backend.personal.models import User, UserState from rest_framework import status from rest_framework.decorators import api_view from rest_framework.response import Response from backend.personal.views import produceRetCode, authenticated from backend.utils.fetch.fetch import fetch_curriculum from backend.univinfo....
normal
{ "blob_id": "a33ddb999f7bb50688b33946046ba460cbbbd172", "index": 9181, "step-1": "<mask token>\n\n\n@api_view(['POST'])\n@authenticated\ndef fetchCurriculum(request):\n university = request.DATA['user'].university.shortname\n if university == 'Unknown':\n ret = produceRetCode('fail', 'university not...
[ 4, 6, 7, 8, 10 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @job def do_it_all(): do_something() <|reserved_special_token_1|> <|reserved_special_token_0|> @op def do_something(): return 'foo' @job def do_it_all(): do_something() <|reserved_special_token_1|> from dag...
flexible
{ "blob_id": "53cf6e97c3b71b1063d5b6bce5aa444933b69809", "index": 3229, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@job\ndef do_it_all():\n do_something()\n", "step-3": "<mask token>\n\n\n@op\ndef do_something():\n return 'foo'\n\n\n@job\ndef do_it_all():\n do_something()\n", "step-4"...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python from PyQt4 import QtCore, QtGui import sys import json import re from Interface_Recommended_Results import obtain_list try: _fromUtf8 = QtCore.QString.fromUtf8 except AttributeError: def _fromUtf8(s): return s try: _encoding = QtGui.QApplication.UnicodeUTF8 def _translate(co...
normal
{ "blob_id": "f5e57c95e2c86aeb83872b29324b0b73a41caa47", "index": 9001, "step-1": "<mask token>\n\n\nclass MyApp(QtGui.QMainWindow, Ui_MainWindow):\n\n def __init__(self):\n QtGui.QMainWindow.__init__(self)\n Ui_MainWindow.__init__(self)\n self.setupUi(self)\n star_list = ['1 Star a...
[ 6, 7, 9, 11, 12 ]
<|reserved_special_token_0|> class HFSFileEntryTest(shared_test_lib.BaseTestCase): <|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 tearDown(self): """C...
flexible
{ "blob_id": "520672f8607751b65fe9e4b975a9978ed0ab71b6", "index": 8242, "step-1": "<mask token>\n\n\nclass HFSFileEntryTest(shared_test_lib.BaseTestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def tearDown(self):\n \"\"\"Cleans up...
[ 18, 19, 20, 25, 27 ]
# -*- coding: utf-8 -*- { 'name': 'Islamic Datepicker', 'category': 'Extra Tools', 'author': 'Mostafa Mohamed', 'website': 'https://eg.linkedin.com/in/mostafa-mohammed-449a8786', 'price': 25.00, 'currency': 'EUR', 'version': '9.0.1.0.1', 'depends': ['base','web'], 'data': [ '...
normal
{ "blob_id": "51a4d8f1be7009b69f0b69bdd51a0077256304a9", "index": 7222, "step-1": "<mask token>\n", "step-2": "{'name': 'Islamic Datepicker', 'category': 'Extra Tools', 'author':\n 'Mostafa Mohamed', 'website':\n 'https://eg.linkedin.com/in/mostafa-mohammed-449a8786', 'price': 25.0,\n 'currency': 'EUR'...
[ 0, 1, 2 ]
import pytz from django.utils import timezone class TimezoneMiddleware(object): """ Middleware to get user's timezone and activate timezone if user timezone is not available default value 'UTC' is activated """ def process_request(self, request): user = request.user if hasattr(user, ...
normal
{ "blob_id": "839d4182663983a03975465d3909631bd6db1d83", "index": 9919, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TimezoneMiddleware(object):\n <mask token>\n\n def process_request(self, request):\n user = request.user\n if hasattr(user, 'profile'):\n user_tz ...
[ 0, 2, 3, 4 ]
import os, shutil, cv2 from PIL import Image INP_DIR = '/dataset/test_set_A_full' # Lọc thư mục data test ra thành 3 thư mục: None, Square (1:1), và phần còn lại (đã được crop ngay chính giữa) # Trả về path dẫn đến 3 thư mục nói trên def pre_proc(INP_DIR): INP_DIR = INP_DIR + '/' NONE_DIR = os.path.dirname(I...
normal
{ "blob_id": "4ad4cf46be735c6ac26b5b0953d4c2458f37496a", "index": 9372, "step-1": "<mask token>\n\n\ndef pre_proc(INP_DIR):\n INP_DIR = INP_DIR + '/'\n NONE_DIR = os.path.dirname(INP_DIR) + '_none'\n SQUARE_DIR = os.path.dirname(INP_DIR) + '_square'\n CROP_DIR = os.path.dirname(INP_DIR) + '_cropped'\n...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class SponsorType(models.Model): <|reserved_special_token_0|> <|reserved_special_token_0|> class Sponsor(models.Model): type = models.ForeignKey(SponsorType, on_delete=models.CASCADE, null=True) id = models.AutoField(primary_key=True) name = models.CharField(max_leng...
flexible
{ "blob_id": "81f0119f6f348f6d33e8d22f588fc8c2e0593d3c", "index": 1536, "step-1": "<mask token>\n\n\nclass SponsorType(models.Model):\n <mask token>\n <mask token>\n\n\nclass Sponsor(models.Model):\n type = models.ForeignKey(SponsorType, on_delete=models.CASCADE, null=True)\n id = models.AutoField(pri...
[ 5, 6, 7, 8, 9 ]
import torch import torch.optim as optim import torch.nn as nn import torch.utils.data as data from dataset import InsuranceAnswerDataset, DataEmbedding from model import Matcher from tools import Trainer, Evaluator from tools import save_checkpoint, load_checkpoint, get_memory_use def main(): batch_size = 64 ...
normal
{ "blob_id": "41f2a5ba0d7a726389936c1ff66a5724209ee99c", "index": 4099, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n batch_size = 64\n valid_batch_size = 8\n dataset_size = 500\n learning_rate = 0.001\n weight_decay = 0.0001\n epochs = 30\n show_frq = 20\n negat...
[ 0, 1, 2, 3, 4 ]
try: from setuptools import setup from setuptools import find_packages has_setup_tools = true except ImportError: from distutils.core import setup has_setup_tools = false with open("README.md", "r") as fh: long_description = fh.read() if has_setup_tools is True: packages = setuptools.find_...
normal
{ "blob_id": "5d988d159902e4a4cb17ee0ec61153de2dda4691", "index": 9120, "step-1": "<mask token>\n", "step-2": "try:\n from setuptools import setup\n from setuptools import find_packages\n has_setup_tools = true\nexcept ImportError:\n from distutils.core import setup\n has_setup_tools = false\nwit...
[ 0, 1, 2 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def GradientDescent(f, gradf, x0, epsilon, num_iter, line_search, disp= False, callback=None, **kwargs): x = x0.copy() iteration = 0 opt_arg = {'f': f, 'grad_f': gradf} for key in kwargs: opt_arg[key]...
flexible
{ "blob_id": "dca36de5556b120b8b93eac0ad7b971ad735d907", "index": 313, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef GradientDescent(f, gradf, x0, epsilon, num_iter, line_search, disp=\n False, callback=None, **kwargs):\n x = x0.copy()\n iteration = 0\n opt_arg = {'f': f, 'grad_f': gr...
[ 0, 1, 2, 3, 4 ]
n = int(input('Digite um número inteiro: ')) print(' O dobro de {} é {}'.format(n, n * 2)) print(' O triplo de {} é {}'.format(n, n * 3)) print(' A Raiz quadrada de {} é {}'.format(n, n * n))
normal
{ "blob_id": "c0ad3d642f28cb11a8225d4d011dbb241bd88432", "index": 1661, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(' O dobro de {} é {}'.format(n, n * 2))\nprint(' O triplo de {} é {}'.format(n, n * 3))\nprint(' A Raiz quadrada de {} é {}'.format(n, n * n))\n", "step-3": "n = int(input('Digite...
[ 0, 1, 2 ]
import sys if sys.hexversion < 0x03000000: from .foo import foo
normal
{ "blob_id": "485729398b51bebd16f38800c6100289b7b0b347", "index": 9023, "step-1": "<mask token>\n", "step-2": "<mask token>\nif sys.hexversion < 50331648:\n from .foo import foo\n", "step-3": "import sys\nif sys.hexversion < 50331648:\n from .foo import foo\n", "step-4": "\nimport sys\n\nif sys.hexver...
[ 0, 1, 2, 3 ]
import types import qt cfg = qt.cfgman cfg.remove_cfg('protocols') cfg.remove_cfg('samples') cfg.remove_cfg('setup') cfg.add_cfg('protocols') cfg.add_cfg('samples') cfg.add_cfg('setup') cfg['samples']['current'] = 'hans-sil13' cfg['protocols']['current'] = 'hans-sil13-default' print 'updating msmt params for {}'.for...
normal
{ "blob_id": "3f20438b0dd2ae8de470e5456dbb764eabf69645", "index": 8092, "step-1": "import types\nimport qt\ncfg = qt.cfgman\n\ncfg.remove_cfg('protocols')\ncfg.remove_cfg('samples')\ncfg.remove_cfg('setup')\ncfg.add_cfg('protocols')\ncfg.add_cfg('samples')\ncfg.add_cfg('setup')\n\ncfg['samples']['current'] = 'han...
[ 0 ]
import socket import sys TCP_IP = '192.168.149.129' TCP_PORT = 5005 BUFFER_SIZE = 2000 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((TCP_IP, TCP_PORT)) while 1: print 'user data:' content = sys.stdin.readline(); s.send(content) data = s.recv(BUFFER_SIZE) print "received data:", data s.clo...
normal
{ "blob_id": "5669476cc735f569263417b907e8f4a9802cd325", "index": 3189, "step-1": "import socket\nimport sys\nTCP_IP = '192.168.149.129'\nTCP_PORT = 5005\nBUFFER_SIZE = 2000\n\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM) \ns.connect((TCP_IP, TCP_PORT))\nwhile 1:\n print 'user data:'\n content = sys.st...
[ 0 ]
<|reserved_special_token_0|> def take(n, iterable): return list(islice(iterable, n)) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def take(n, iterable): return list(islice(iterable, n)) <|reserved_special_token_0|> with open('D_INDEXED_FILE/index', 'rb') as f...
flexible
{ "blob_id": "1630a3d0becac195feee95a1c3b23568612a48d2", "index": 3194, "step-1": "<mask token>\n\n\ndef take(n, iterable):\n return list(islice(iterable, n))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef take(n, iterable):\n return list(islice(iterable, n))\n\n\n<mask token>\nwith open('D_INDEXE...
[ 1, 2, 3, 4, 5 ]
import tkinter as tk import classejogo class Tabuleiro(): def __init__(self): self.jogo = classejogo.Jogo() self.window = tk.Tk() self.window.title("Jogo da Velha") self.window.geometry("300x360+100+100") self.window.rowconfigure(0, minsize=30, weight=1) self.window...
normal
{ "blob_id": "9cff227eeeaffda777668aa3b90e3839426da811", "index": 6683, "step-1": "<mask token>\n\n\nclass Tabuleiro:\n\n def __init__(self):\n self.jogo = classejogo.Jogo()\n self.window = tk.Tk()\n self.window.title('Jogo da Velha')\n self.window.geometry('300x360+100+100')\n ...
[ 9, 12, 15, 16, 18 ]
<|reserved_special_token_0|> class Madlib: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Madlib: <|reserved_special_token_0|> def get_madlib(self): madlib = """ Once there was a {0}. It {1} at the {2}. ...
flexible
{ "blob_id": "2b23237e697cb4ca8f1013d7be343c70fba9541d", "index": 6342, "step-1": "<mask token>\n\n\nclass Madlib:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Madlib:\n <mask token>\n\n def get_madlib(self):\n madlib = \"\"\"\n Once there was a {0}. It {1} at t...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> gen.add('segment_connect_normal_threshold', double_t, 0, 'threshold of normal to connect clusters', 0.9, 0.0, 1.0) gen.add('ewma_tau', double_t, 0, 'tau parameter of EWMA to connect clusters', 0.2, 0.0, 1.0) gen.add('outli...
flexible
{ "blob_id": "7127df5515e93e27b431c57bec1709475fec8388", "index": 5238, "step-1": "<mask token>\n", "step-2": "<mask token>\ngen.add('segment_connect_normal_threshold', double_t, 0,\n 'threshold of normal to connect clusters', 0.9, 0.0, 1.0)\ngen.add('ewma_tau', double_t, 0,\n 'tau parameter of EWMA to co...
[ 0, 1, 2, 3, 4 ]
import io import json import sys import time from coord_tools import get_elevation if len(sys.argv) != 3: print('Wrong number of arguments! Exiting.') infile_name = sys.argv[1] outfile_name = sys.argv[2] # Declare dict to hold coordinates node_coords = {} fail_count = 0 nodes_processed = 0 # Read in each node fro...
normal
{ "blob_id": "4744d594c0599f1aa807eefa0cb40a2a2a3c7926", "index": 6677, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv) != 3:\n print('Wrong number of arguments! Exiting.')\n<mask token>\nfor line in infile.readlines():\n fields = line.split()\n node_id = int(fields[0])\n lat =...
[ 0, 1, 2, 3, 4 ]
import sys from collections import defaultdict sys.setrecursionlimit(1200) def dfs(G, v, prev): t = [] s = 0 for x in G[v]: if x == prev: continue tmp = dfs(G, x, v) s += tmp[1] t.append(tmp[0] - tmp[1]) t.sort() t = t[:2] if len(t) < 2: return (s...
normal
{ "blob_id": "efa06d929e76a255afd9923b5340252c291a325c", "index": 3615, "step-1": "import sys\nfrom collections import defaultdict\nsys.setrecursionlimit(1200)\n\ndef dfs(G, v, prev):\n t = []\n s = 0\n for x in G[v]:\n if x == prev: continue\n tmp = dfs(G, x, v)\n s += tmp[1]\n ...
[ 0 ]
############################################################################## # Nombre : import.py # Descripción : It takes the information from Transfom.sh Initial Node # Final Node and HAVERSINE Formule # # Parámetros: # Realizado Por : # # HISTORIAL DE CAMB...
normal
{ "blob_id": "0018cbb1d945ad1b6469804e7993afee44406fd1", "index": 2895, "step-1": "<mask token>\n\n\ndef transform_to_my_format(data):\n d = defaultdict(dict)\n for i1, i2, i3 in re.findall('([\\\\d\\\\.]+)\\\\s+([\\\\d\\\\.]+)\\\\s+([\\\\d\\\\.]+)',\n data):\n d[i1].update({i2: float(i3)})\n ...
[ 2, 3, 4, 5, 6 ]
from django.contrib import admin from django.urls import path from . import view urlpatterns = [ path('', view.enterMarks), path('MarkSheet', view.getMarks, name='MarkSheet'), ]
normal
{ "blob_id": "511c555c88fb646b7b87678044b43a5a623a5ac7", "index": 4670, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', view.enterMarks), path('MarkSheet', view.getMarks,\n name='MarkSheet')]\n", "step-3": "from django.contrib import admin\nfrom django.urls import path\nfrom . ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def calculaMinkowski(obj1, obj2, p): soma = 0 for I in range(len(obj1)): soma += abs(obj1[I] - obj2[I]) ** p return soma ** (1 / p) <|reserved_special_token_0|> def calculaMinkowskiNormalizada(obj1, obj2, p): soma = 0 somaDelta = 0 for I in range(len(ob...
flexible
{ "blob_id": "6c349b7b4d82b37ec1b1ff8e0d35a3557ed1af67", "index": 4613, "step-1": "<mask token>\n\n\ndef calculaMinkowski(obj1, obj2, p):\n soma = 0\n for I in range(len(obj1)):\n soma += abs(obj1[I] - obj2[I]) ** p\n return soma ** (1 / p)\n\n\n<mask token>\n\n\ndef calculaMinkowskiNormalizada(ob...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> class SomeModelAdmin(SummernoteModelAdmin): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class SomeModelAdmin(SummernoteModelAdmin): summernote_fields = '__all__' <|reserved_special_token_0|> <|reser...
flexible
{ "blob_id": "a86b64ccd0dab4ab70ca9c2b7625fb34afec3794", "index": 63, "step-1": "<mask token>\n\n\nclass SomeModelAdmin(SummernoteModelAdmin):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass SomeModelAdmin(SummernoteModelAdmin):\n summernote_fields = '__all__'\n\n\n<mask token>\n",...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(abs(input_one - input_two)) <|reserved_special_token_1|> time_one = abs(int(input())) time_two = abs(int(input())) time_three = abs(int(input())) time_four = abs(int(input())) time_five = abs(int(input())) time_six = abs(...
flexible
{ "blob_id": "7a4044acaa191509c96e09dcd48e5b951ef7a711", "index": 3582, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(abs(input_one - input_two))\n", "step-3": "time_one = abs(int(input()))\ntime_two = abs(int(input()))\ntime_three = abs(int(input()))\ntime_four = abs(int(input()))\ntime_five = a...
[ 0, 1, 2, 3 ]
from django.db import models # Create your models here. class AlertMailModel(models.Model): receipient_mail = models.EmailField() host_mail = models.EmailField() host_smtpaddress = models.CharField(max_length=25) mail_host_password = models.CharField(max_length=200) use_tls=models.BooleanField(defa...
normal
{ "blob_id": "2872c86294037b4585158e7ff6db414ba7ab90cc", "index": 1814, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AlertMailModel(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclas...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if rok_int % 4 == 0: if rok_int % 100 != 0: if rok_int % 400: print(f'Rok {rok_int} je priestupny') else: print('rok je neprestupny') else: print('rok je prestupny') else: ...
flexible
{ "blob_id": "c9b1956d66f0b8ae8a7ce7e509259747c8b7709e", "index": 6088, "step-1": "<mask token>\n", "step-2": "<mask token>\nif rok_int % 4 == 0:\n if rok_int % 100 != 0:\n if rok_int % 400:\n print(f'Rok {rok_int} je priestupny')\n else:\n print('rok je neprestupny')\n ...
[ 0, 1, 2, 3 ]
L = [ [ "0", "0", "00" ],[ "..0", "000" ],[ "00", ".0", ".0" ], [ "000", "0" ] ] J = [ [ ".0", ".0", "00" ],[ "0..", "000" ],[ "00", "0", "0"...
normal
{ "blob_id": "5718eab8c5fac4cb7bfa1b049b63ca1e30610247", "index": 9554, "step-1": "<mask token>\n", "step-2": "L = [['0', '0', '00'], ['..0', '000'], ['00', '.0', '.0'], ['000', '0']]\nJ = [['.0', '.0', '00'], ['0..', '000'], ['00', '0', '0'], ['000', '..0']]\nO = [['00', '00']]\nT = [['000', '.0'], ['0', '00',...
[ 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": "04c1765e6c2302098be2a7f3242dfd536683f742", "index": 6138, "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 = [('users', '00...
[ 0, 1, 2, 3, 4 ]
import torch def DiceLoss(pred,target,smooth=2): # print("pred shape: ",pred.shape) # print("target shape: ",target.shape) index = (2*torch.sum(pred*target)+smooth)/(torch.sum(pred)+torch.sum(target)+smooth) #if torch.sum(target).item() == 0: #print("instersection: ",torch.sum(pred*target).item()) ...
normal
{ "blob_id": "0aa0fcbb0ec1272bea93574a9287de9f526539c8", "index": 3119, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef DiceLoss(pred, target, smooth=2):\n index = (2 * torch.sum(pred * target) + smooth) / (torch.sum(pred) +\n torch.sum(target) + smooth)\n return 1 - index\n", "step-...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def aug_fn(image): data = {'image': image} aug_data = transforms(**data) aug_img = aug_data['image'] aug_img = tf.cast(aug_img, tf.float32) / 255.0 aug_img = tf.image.per_image_standardization(aug_img) return aug_img def process_data(image, label): aug_img = ...
flexible
{ "blob_id": "943e8be7a9ee4e494c0a42e1368555f3df3de897", "index": 1518, "step-1": "<mask token>\n\n\ndef aug_fn(image):\n data = {'image': image}\n aug_data = transforms(**data)\n aug_img = aug_data['image']\n aug_img = tf.cast(aug_img, tf.float32) / 255.0\n aug_img = tf.image.per_image_standardiza...
[ 7, 10, 11, 12, 16 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(randbelow(100)) <|reserved_special_token_1|> from secrets import randbelow print(randbelow(100))
flexible
{ "blob_id": "18ae982c7fac7a31e0d257f500da0be0851388c2", "index": 8985, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(randbelow(100))\n", "step-3": "from secrets import randbelow\nprint(randbelow(100))\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
<|reserved_special_token_0|> class CrawlSerializer(serializers.Serializer): <|reserved_special_token_0|> <|reserved_special_token_0|> def create(self, validated_data): """Start a network crawl""" crawl = validated_data['crawl'] if crawl == CRAWL_COMMAND_START: cache.se...
flexible
{ "blob_id": "cb32aa6a1c42e7bb417999f3f6f74ec22209c5a0", "index": 1230, "step-1": "<mask token>\n\n\nclass CrawlSerializer(serializers.Serializer):\n <mask token>\n <mask token>\n\n def create(self, validated_data):\n \"\"\"Start a network crawl\"\"\"\n crawl = validated_data['crawl']\n ...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> def main(): global args torch.manual_seed(args.seed) if not args.use_avai_gpus: os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu_devices use_gpu = torch.cuda.is_available() if args.use_cpu: use_gpu = False log_name = 'log_test.txt' sys.stdout = Log...
flexible
{ "blob_id": "0ad529298f321d2f3a63cde8179a50cf2881ee00", "index": 2162, "step-1": "<mask token>\n\n\ndef main():\n global args\n torch.manual_seed(args.seed)\n if not args.use_avai_gpus:\n os.environ['CUDA_VISIBLE_DEVICES'] = args.gpu_devices\n use_gpu = torch.cuda.is_available()\n if args.u...
[ 1, 2, 3, 4, 5 ]
## adapted from https://matplotlib.org/examples/api/radar_chart.html import numpy as np import matplotlib.pyplot as plt from matplotlib.path import Path from matplotlib.spines import Spine from matplotlib.projections.polar import PolarAxes from matplotlib.projections import register_projection def radar_factory(num...
normal
{ "blob_id": "ddf64ea5ecbd3aa737cd788924035cccb5544fec", "index": 5544, "step-1": "<mask token>\n\n\ndef radar_factory(num_vars, frame='circle'):\n theta = np.linspace(0, 2 * np.pi, num_vars, endpoint=False)\n theta += np.pi / 2\n\n def draw_poly_patch(self):\n verts = unit_poly_verts(theta)\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_imagemagick_path(): config = configparser.ConfigParser() config.read('settings/settings.ini') return config['commands'].get('convert', shutil.which('convert')) <|reserved_special_token_1|> import configpar...
flexible
{ "blob_id": "5fa9c9908d4aea507cf0ca8287a6b8e5b391470a", "index": 9297, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_imagemagick_path():\n config = configparser.ConfigParser()\n config.read('settings/settings.ini')\n return config['commands'].get('convert', shutil.which('convert'))\...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def createMD5(str): hl = hashlib.md5() hl.update(str.encode(encoding='utf-8')) return hl.hexdigest() <|reserved_special_token_1|> import hashlib def createMD5(str): hl = hashlib.md5() hl.update(str.encod...
flexible
{ "blob_id": "ea78f754ffff26bac1e53ed1e842fd79112b8ee7", "index": 6811, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef createMD5(str):\n hl = hashlib.md5()\n hl.update(str.encode(encoding='utf-8'))\n return hl.hexdigest()\n", "step-3": "import hashlib\n\n\ndef createMD5(str):\n hl = ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def convert_arg_to_list(arg): try: return [float(elem) for elem in arg] except: sys.exit('Invalid content inside {}'.format(arg)) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_...
flexible
{ "blob_id": "347bfb2d8809b55046f698620a690099cc83fb56", "index": 6433, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef convert_arg_to_list(arg):\n try:\n return [float(elem) for elem in arg]\n except:\n sys.exit('Invalid content inside {}'.format(arg))\n\n\n<mask token>\n", "...
[ 0, 1, 2, 3, 4 ]
# The error measures used in this project # # Rooth Mean Squared Error # Mean Absolute Error # # ! Both calculated after descaling the output of the system first import numpy as np def RMSE(min_y, max_y, yhat, y): # first scale output and target back to # original scale, to prevent scale bias yhat = descale(yhat,...
normal
{ "blob_id": "4fd4c9cf3bdb73a003ce860bf2ee0ccab01f0009", "index": 4646, "step-1": "<mask token>\n\n\ndef RMSE(min_y, max_y, yhat, y):\n yhat = descale(yhat, min_y, max_y)\n y = descale(y, min_y, max_y)\n return np.mean(np.power(np.subtract(yhat, y), 2))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(hex(n1)) print(hex(n2)) print(abs(-119999)) <|reserved_special_token_1|> n1 = 255 n2 = 1000 print(hex(n1)) print(hex(n2)) print(abs(-119999)) <|reserved_special_token_1|> # -*- coding: utf-8 -*- # author : rovo98 # d...
flexible
{ "blob_id": "31064145ae2702f93a475d0957395c62a6b320ee", "index": 1741, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(hex(n1))\nprint(hex(n2))\nprint(abs(-119999))\n", "step-3": "n1 = 255\nn2 = 1000\nprint(hex(n1))\nprint(hex(n2))\nprint(abs(-119999))\n", "step-4": "# -*- coding: utf-8 -*-\r\n#...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def findKthNode(root, k): if not root: return None if root.number < k or k <= 0: return None if k == 1: return root if root.left and root.left.number >= k - 1: return findKthNode(root.left, k - 1) else: res = 1 if not root.left e...
flexible
{ "blob_id": "b9675bc65e06624c7f039188379b76da8e58fb19", "index": 1623, "step-1": "<mask token>\n\n\ndef findKthNode(root, k):\n if not root:\n return None\n if root.number < k or k <= 0:\n return None\n if k == 1:\n return root\n if root.left and root.left.number >= k - 1:\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class TestTranslators(unittest.TestCase): <|reserved_special_token_0|> def init_lisp(self, program): return LispTranslator(Parser(Lexer(program))) <|reserved_special_token_0|> <|reserved_special_token_0|> def test_examples_chapter_seven(self): self.as...
flexible
{ "blob_id": "d0e957abfe5646fb84aed69902f2382d554dc825", "index": 4401, "step-1": "<mask token>\n\n\nclass TestTranslators(unittest.TestCase):\n <mask token>\n\n def init_lisp(self, program):\n return LispTranslator(Parser(Lexer(program)))\n <mask token>\n <mask token>\n\n def test_examples_...
[ 3, 5, 6, 8 ]
from functools import reduce with open("input.txt") as f: numbers = f.read().split("\n") n = sorted(list(map(lambda x: int(x), numbers))) n.insert(0, 0) n.append(n[-1] + 3) target = n[-1] memoize = {} def part2(number): if number == target: return 1 if number in memoize.keys(): return ...
normal
{ "blob_id": "3179c13968f7bcdccbd00ea35b9f098dc49b42d8", "index": 4450, "step-1": "<mask token>\n\n\ndef part2(number):\n if number == target:\n return 1\n if number in memoize.keys():\n return memoize[number]\n paths = 0\n if number + 1 in n:\n paths += part2(number + 1)\n if ...
[ 1, 2, 3, 4, 5 ]
from terminaltables import AsciiTable import copy table_data = [ ['WAR', 'WAW'], ['S1 -> S2: R1', 'row1 column2'], ['row2 column1', 'row2 column2'], ['row3 column1', 'row3 column2'] ] table = AsciiTable(table_data) def getDependenceStr(ins1, ins2, reg): return f"{ins1} -> {ins2}: {reg}" def get...
normal
{ "blob_id": "e045dc348fb2e9de51dbeada1d1826211cf89eae", "index": 3114, "step-1": "<mask token>\n\n\ndef getDependenceStr(ins1, ins2, reg):\n return f'{ins1} -> {ins2}: {reg}'\n\n\ndef getInstructionStr(ins, reg1, reg2, reg3):\n return f'{ins} {reg1} {reg2} {reg3}'\n\n\n<mask token>\n\n\ndef validateInput(s...
[ 7, 10, 11, 13, 16 ]
<|reserved_special_token_0|> class Solution: def primePalindrome(self, N: int) ->int: """return lowest prime palindrome >= N""" for p in palindromes(N): if isPrime(p): return p <|reserved_special_token_1|> <|reserved_special_token_0|> def palindromes(n: int) ->int...
flexible
{ "blob_id": "b07073a7f65dbc10806b68729f21a8bc8773a1ab", "index": 3836, "step-1": "<mask token>\n\n\nclass Solution:\n\n def primePalindrome(self, N: int) ->int:\n \"\"\"return lowest prime palindrome >= N\"\"\"\n for p in palindromes(N):\n if isPrime(p):\n return p\n", ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @register.simple_tag def getlatestarticle(): latearticle = Article.objects.all().order_by('-atime') return latearticle <|reserved_special_token_1|> <|reserved_special_token_0|> register = template.Library() @registe...
flexible
{ "blob_id": "804c75b3ab0b115e5187d44e4d139cfb553269a9", "index": 6791, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@register.simple_tag\ndef getlatestarticle():\n latearticle = Article.objects.all().order_by('-atime')\n return latearticle\n", "step-3": "<mask token>\nregister = template.Li...
[ 0, 1, 2, 3, 4 ]
from django.db import models ch=[ ('Garment','Garment'), ('Hardgoods','Hardgoods'), ('Home Furnishing','Home Furnishing'), ] class Factory(models.Model): name = models.CharField(max_length=30,choices=ch) def __str__(self): return self.name class Fabric(models.Model): n...
normal
{ "blob_id": "a0dcfb738451c11ed4ff1428629c3f7bbf5c52c9", "index": 5649, "step-1": "<mask token>\n\n\nclass Category(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.category\n\n\nclass Subcategory(models.Model):\n name = models.ForeignKey(Categ...
[ 17, 20, 22, 24, 30 ]
import os import urllib.request as ulib import json from bs4 import BeautifulSoup as Bsoup def find_links(name): name = name.replace(" ", "+") url_str = 'https://www.google.com/search?ei=1m7NWePfFYaGmQG51q7IBg&hl=en&q={}' + \ '\&tbm=isch&ved=0ahUKEwjjovnD7sjWAhUGQyYKHTmrC2kQuT0I7gEoAQ&start={}'...
normal
{ "blob_id": "02ffdd1c03cc20883eddc691fc841022b4ff40fd", "index": 1601, "step-1": "<mask token>\n\n\ndef download_images(links, name):\n dir_name = name.replace(' ', '_')\n if not os.path.isdir(dir_name):\n os.mkdir(dir_name)\n for i, img_link in enumerate(links):\n img_path = os.path.join(...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class CrypTenConfig: <|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": "501ca508df5d72b0190b933f07c4bd505d7090c0", "index": 6464, "step-1": "<mask token>\n\n\nclass CrypTenConfig:\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\n @contextmanager\n de...
[ 2, 7, 10, 12, 13 ]
from room import Room class Office(Room): def __init__(self): pass
normal
{ "blob_id": "d3af5ac87474a99f1ade222995884bc8e035ce35", "index": 6142, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Office(Room):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Office(Room):\n\n def __init__(self):\n pass\n", "step-4": "from room import Room\n\n\nclass...
[ 0, 1, 2, 3 ]
from django.shortcuts import render_to_response, get_object_or_404 from django.http import HttpResponseNotFound from django.template import RequestContext from bgame.models import Game, Period, Player, ROLES from bgame.forms import GameForm import logging log = logging.getLogger(__name__) def index(request): games...
normal
{ "blob_id": "6c825cb60475a1570e048cab101567bd5847d2c2", "index": 5113, "step-1": "from django.shortcuts import render_to_response, get_object_or_404\nfrom django.http import HttpResponseNotFound\nfrom django.template import RequestContext\nfrom bgame.models import Game, Period, Player, ROLES\nfrom bgame.forms im...
[ 0 ]
# Generated by Django 3.1.7 on 2021-03-19 14:38 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('news', '0002_auto_202103...
normal
{ "blob_id": "8b4bc312bf4b64f98c4f84f4bf89984291be0428", "index": 6033, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
# 拆包 t1 = (4,7,3) # a,b=t1 # ValueError:too many values to unpack(拆包) (expected 3, got 2) a,b,c = t1 print(a,b,c) a = t1 print(a) # x,y,z = (6,) # ValueError: not enough values to unpack (expected 3, got 1) # s1 = 'hello' # s2 = s1 # 变量个数与元祖个数不一致 t1 = (12,23,42,12,43) a,*_,c = t1 print(a,c,_) a,c,*_ = t1 p...
normal
{ "blob_id": "c65755d7a58c1cda7d6eea83876e0522a7ca9c74", "index": 2679, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a, b, c)\n<mask token>\nprint(a)\n<mask token>\nprint(a, c, _)\n<mask token>\nprint(a, c, _)\n<mask token>\nprint(a, c, b)\n<mask token>\nprint(a, b)\nprint(*b)\n<mask token>\nprint...
[ 0, 1, 2, 3 ]
cassandra = {'nodes': ['localhost'], 'keyspace': 'coffee'}
normal
{ "blob_id": "0738fc48bc367f1df75567ab97ce20d3e747dc18", "index": 8897, "step-1": "<mask token>\n", "step-2": "cassandra = {'nodes': ['localhost'], 'keyspace': 'coffee'}\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
<|reserved_special_token_0|> class RegisterSchema(Schema): <|reserved_special_token_0|> <|reserved_special_token_0|> class LoginSchema(Schema): """ 登录 """ _schema = UserSchemas.LOGIN_SCHEMA.value <|reserved_special_token_1|> <|reserved_special_token_0|> class RegisterSchema(Schema): ...
flexible
{ "blob_id": "e0d7fb8a9799c91dca0ca0827a5149804c9efabb", "index": 7082, "step-1": "<mask token>\n\n\nclass RegisterSchema(Schema):\n <mask token>\n <mask token>\n\n\nclass LoginSchema(Schema):\n \"\"\"\n 登录\n \"\"\"\n _schema = UserSchemas.LOGIN_SCHEMA.value\n", "step-2": "<mask token>\n\n\ncl...
[ 4, 5, 6, 7 ]
import unittest from LempelZivWelchDecoder import LempelZivWelchDecoder class TestLempelZivWelchDecoder(unittest.TestCase): def test_decode(self): test_value = ['t', 256, 257, 'e', 's', 260, 't', '1'] run_length_decoder = LempelZivWelchDecoder() self.assertRaises(ValueError, ...
normal
{ "blob_id": "8126af930ec75e2818455d959f00285bdc08c044", "index": 1899, "step-1": "<mask token>\n\n\nclass TestLempelZivWelchDecoder(unittest.TestCase):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass TestLempelZivWelchDecoder(unittest.TestCase):\n\n def test_decode(self):\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class TestCopy(AsyncRESTTestCase): <|reserved_special_token_0|> @gen_test def test_get(self): response = yield self.http_client.get(self.api_url.format('/')) assert response.body == Handler.S <|reserved_special_token_1|> <|reserved_special_token_0|> class...
flexible
{ "blob_id": "4bbd97942023370e053ccf4b5c1496c7247c7bf2", "index": 9026, "step-1": "<mask token>\n\n\nclass TestCopy(AsyncRESTTestCase):\n <mask token>\n\n @gen_test\n def test_get(self):\n response = yield self.http_client.get(self.api_url.format('/'))\n assert response.body == Handler.S\n"...
[ 2, 3, 4, 6, 7 ]
<|reserved_special_token_0|> class Activation: <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Activation: <|reserved_special_token_0|> def __init__(self, game): """ Constru...
flexible
{ "blob_id": "0774bad4082e0eb04ae3f7aa898c0376147e9779", "index": 2645, "step-1": "<mask token>\n\n\nclass Activation:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Activation:\n <mask token>\n\n def __init__(self, game):\n \"\"\"\n Constructor\...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def elutee(s): n = 0 for i in s: if i != '.': n += int(i) if n < 10: return n else: return elutee(str(n)) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reser...
flexible
{ "blob_id": "971187dc0e0f02282c8945940d07c011e247667a", "index": 9401, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef elutee(s):\n n = 0\n for i in s:\n if i != '.':\n n += int(i)\n if n < 10:\n return n\n else:\n return elutee(str(n))\n\n\n<mask token>...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def map_file(file_map, d, f): for find, repl in file_map: if '/' in find: source = os.path.join(d, f) includes_path = True else: source = f includes_path = False match = re.match(find, source) if match: ...
flexible
{ "blob_id": "03d07f5f4647e904c288e828b8f8e7de35740054", "index": 3737, "step-1": "<mask token>\n\n\ndef map_file(file_map, d, f):\n for find, repl in file_map:\n if '/' in find:\n source = os.path.join(d, f)\n includes_path = True\n else:\n source = f\n ...
[ 8, 10, 11, 12, 14 ]
import pandas as pd import copy as cp import numpy as np from autoencoder import * from encoding import smtEncoding import matplotlib import matplotlib.pyplot as plt from data_generator import * from marabou_encoding import marabouEncoding def main(): ''' Trains an autoencoder on (generated) data and checks advers...
normal
{ "blob_id": "44e1208a2165fe68f71d0aa49baa29b26c961e02", "index": 5681, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n \"\"\"\n\tTrains an autoencoder on (generated) data and checks adversarial robustness\n\t\"\"\"\n architecture = [10, 5, 10]\n print('----------Training autoenc...
[ 0, 1, 2, 3, 4 ]
import requests from bs4 import BeautifulSoup ''' OCWから学院一覧を取得するスクリプト(6個くらいだから必要ない気もする) gakuinListの各要素は次のような辞書に鳴っている { 'name' : 学院名, 'url' : その学院の授業の一覧のurl, } ''' def getGakuinList(): url = "http://www.ocw.titech.ac.jp/" response = requests.get(url) soup = BeautifulSoup(response.content,"lxml") topMainNav = sou...
normal
{ "blob_id": "24274dddbeb1be743cfcac331ee688d48c9a46dd", "index": 8647, "step-1": "<mask token>\n\n\ndef getLectures(name, url):\n urlprefix = 'http://www.ocw.titech.ac.jp'\n response = requests.get(url)\n soup = BeautifulSoup(response.content, 'lxml')\n table = soup.find('table', class_='ranking-list...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print('输入:') while True: s = input() if s == '0 0 0 0 0 0': break S.append(s) print('\n输出:') <|reserved_special_token_0|> for k in range(len(S)): p = [int(i) for i in S[k].split()] _sum = sum(i * j for ...
flexible
{ "blob_id": "0d20b75bcc87db8f3e4bdd9d6448cc44c979de1d", "index": 137, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('输入:')\nwhile True:\n s = input()\n if s == '0 0 0 0 0 0':\n break\n S.append(s)\nprint('\\n输出:')\n<mask token>\nfor k in range(len(S)):\n p = [int(i) for i in S[k...
[ 0, 1, 2, 3 ]
#!/usr/local/bin/python3 def printGrid(grid): for row in grid: print(row) print("") def validFormatting(grid): if (type(grid) is not list): return False elif (len(grid) != 9): return False else: for row in grid: if (type(row) is not list): ...
normal
{ "blob_id": "67452f31a49f50cdb2555406287b31e53a994224", "index": 7906, "step-1": "<mask token>\n\n\ndef validRows(grid):\n found_zero = False\n for row in range(9):\n bit_dict = {}\n for col in range(9):\n current_item = grid[row][col]\n if current_item != 0 and current_...
[ 5, 7, 9, 12, 13 ]
""" Like Places but possibly script based and temporary. Like a whisper command where is keeps tracks of participants. """
normal
{ "blob_id": "378c07c512425cb6ac6c998eaaa86892b02a37b8", "index": 6905, "step-1": "<mask token>\n", "step-2": "\"\"\"\nLike Places but possibly script based and temporary.\nLike a whisper command where is keeps tracks of participants.\n\"\"\"", "step-3": null, "step-4": null, "step-5": null, "step-ids":...
[ 0, 1 ]
# -*- coding: utf-8 -*- from django.contrib.auth.models import User from django.contrib.auth.admin import UserAdmin from django.contrib import admin from accounts.models import (UserProfile) admin.site.register(UserProfile) admin.site.unregister(User) class CustomUserAdmin(UserAdmin): list_display = ('username', ...
normal
{ "blob_id": "c95eaa09241428f725d4162e0e9f6ed3ce6f8fdd", "index": 6709, "step-1": "<mask token>\n\n\nclass CustomUserAdmin(UserAdmin):\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass CustomUserAdmin(UserAdmin):\n list_display = 'username', 'email', 'is_staff', 'is...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> def maior(a, b): if a > b: return a else: return b <|reserved_special_token_0|> <|reserved_special_token_1|> def maior(a, b): if a > b: return a else: return b <|reserved_special_token_0|> print(maior(a, ...
flexible
{ "blob_id": "f4ca7f31000a1f649876b19ef937ece9958dd60f", "index": 5352, "step-1": "<mask token>\n", "step-2": "def maior(a, b):\n if a > b:\n return a\n else:\n return b\n\n\n<mask token>\n", "step-3": "def maior(a, b):\n if a > b:\n return a\n else:\n return b\n\n\n<ma...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 def twoNumberSum(array, targetSum): # Write your code here. # O(n^2) time | O(1) space ''' Double for loop, quadratic run time No variables increase as the input size increases, therefore constant space complexity. ''' for i in range(len(array) - 1): firstNu...
normal
{ "blob_id": "a406efcab62b2af67484da776f01fc4e6d20b697", "index": 984, "step-1": "#!/usr/bin/env python3\n\ndef twoNumberSum(array, targetSum):\n # Write your code here.\n\n # O(n^2) time | O(1) space\n ''' Double for loop, quadratic run time\n No variables increase as the input size increases,\n ...
[ 0 ]
<|reserved_special_token_0|> class SendMessagePermission(BasePermission): <|reserved_special_token_0|> <|reserved_special_token_0|> class MessageOwnerPermission(BasePermission): message = 'You cant modify your messages only!' def has_object_permission(self, request, view, obj): return obj.u...
flexible
{ "blob_id": "56b5faf925d9a1bfaef348caeb35a7d3c323d57f", "index": 8450, "step-1": "<mask token>\n\n\nclass SendMessagePermission(BasePermission):\n <mask token>\n <mask token>\n\n\nclass MessageOwnerPermission(BasePermission):\n message = 'You cant modify your messages only!'\n\n def has_object_permis...
[ 4, 6, 8, 10, 11 ]
# 1장 말뭉치와 워드넷 - 외부 말뭉치 다운로드, 로드하고 액세스하기 from nltk.corpus import CategorizedPlaintextCorpusReader from random import randint # 말뭉치 읽기 reader = CategorizedPlaintextCorpusReader(r'/workspace/NLP_python/tokens', r'.*\.txt', cat_pattern=r'(\w+)/*') print(reader.categories()) print(reader.fileids()) # 샘플 문서 출력 # pos, neg 카...
normal
{ "blob_id": "81cec5c1f28e92bf8e4adc2e2c632e072ed1f901", "index": 5765, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(reader.categories())\nprint(reader.fileids())\n<mask token>\nprint(fileP)\nprint(fileN)\nfor w in reader.words(fileP):\n print(w + ' ', end='')\n if w is '.':\n print()...
[ 0, 1, 2, 3, 4 ]
from soppa.contrib import * class ModD(Soppa): needs = ['test_project.modf'] something = 1
normal
{ "blob_id": "13da16ba89e4743b12d9b8e24929864747f8bbf2", "index": 1308, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ModD(Soppa):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ModD(Soppa):\n needs = ['test_project.modf']\n something = 1\n", "step-4": "fro...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> app.config.from_object('config') <|reserved_special_token_0|> lm.init_app(app) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> app = Flask(__name__) app.config.from_object('config') db = S...
flexible
{ "blob_id": "8c1bd4df5f33c433880d6a4becadf88fb922762b", "index": 6379, "step-1": "<mask token>\n", "step-2": "<mask token>\napp.config.from_object('config')\n<mask token>\nlm.init_app(app)\n<mask token>\n", "step-3": "<mask token>\napp = Flask(__name__)\napp.config.from_object('config')\ndb = SQLAlchemy(app)...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_notes(piece): part = piece.parts[0] measures = filter(lambda x: isinstance(x, music21.stream.Measure), part .elements) notes = reduce(operator.add, map(lambda x: x.notes.elements, measures)) retur...
flexible
{ "blob_id": "92ee66565eb1d0e3cd8fa1ec16747f15e0d92be8", "index": 2885, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_notes(piece):\n part = piece.parts[0]\n measures = filter(lambda x: isinstance(x, music21.stream.Measure), part\n .elements)\n notes = reduce(operator.add, map...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def meetBlock(x, y, maps): if maps[x][y] == 1: return True else: return False def onlyUpdate(n_blocks, xs, ys, maps): for i in range(n_blocks): maps[xs[i]][ys[i]] = 1 def oneLineFull(maps, CLR): for i in range(4, 10): for j in range(4): ...
flexible
{ "blob_id": "937d01eaa82cbfe07b20fae9320c554a0960d7b1", "index": 571, "step-1": "<mask token>\n\n\ndef meetBlock(x, y, maps):\n if maps[x][y] == 1:\n return True\n else:\n return False\n\n\ndef onlyUpdate(n_blocks, xs, ys, maps):\n for i in range(n_blocks):\n maps[xs[i]][ys[i]] = 1\...
[ 9, 10, 11, 12, 14 ]
<|reserved_special_token_0|> class MainWindow(tk.Tk): def __init__(self): super().__init__() self.title('Main Window') self.geometry('600x400+30+30') tk.Button(self, text='Count Tags', command=self.new_tags).pack() tk.Button(self, text='Count keywords', command=self.new_ke...
flexible
{ "blob_id": "1482c8276f9cfc912293356d04e08307edf6d367", "index": 5133, "step-1": "<mask token>\n\n\nclass MainWindow(tk.Tk):\n\n def __init__(self):\n super().__init__()\n self.title('Main Window')\n self.geometry('600x400+30+30')\n tk.Button(self, text='Count Tags', command=self.n...
[ 4, 5, 7, 8, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> nan = '' section_words = {'start': -1, '1.1': 17, '1.2': 38, '1.3': 55, '1.4': 76, '1.5': 95, '1.6': 114, '1.7': 133, '1.8': 151, '1.9': 170, '1.10': 190, '1.11': 209, '1.12': 233, '1.13': 257, '1.14': 277, '1.15': 299, '1...
flexible
{ "blob_id": "8a0c0f5ca6a965e07f59a6c88d4dd335310cbdfc", "index": 9530, "step-1": "<mask token>\n", "step-2": "<mask token>\nnan = ''\nsection_words = {'start': -1, '1.1': 17, '1.2': 38, '1.3': 55, '1.4': 76,\n '1.5': 95, '1.6': 114, '1.7': 133, '1.8': 151, '1.9': 170, '1.10': 190,\n '1.11': 209, '1.12': ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class AttendanceDetailView(DetailView): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> class AttendanceCreateView(CreateView): model = Attendance template_name = 'attendance_new.html' fields = ['group', 'disciple'] def g...
flexible
{ "blob_id": "38c78a51a50ee9844aec8b8cdcdd42b858748518", "index": 2552, "step-1": "<mask token>\n\n\nclass AttendanceDetailView(DetailView):\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass AttendanceCreateView(CreateView):\n model = Attendance\n template_name = 'attendance_new.html'\n fi...
[ 5, 8, 9, 10, 11 ]
from sharpie import Sharpie class SharpieSet(): def __init__(self): self.sharpies = [] self.usable_sharpies = [] self.usable_sharpies_count = 0 def add_sharpie(self, sharpie: Sharpie): self.sharpies.append(sharpie) def count_usable(self): for i in self.sharpies: ...
normal
{ "blob_id": "4524dd5f5cddd475ca39fea7ec94fa3c1df6bd2e", "index": 3268, "step-1": "<mask token>\n\n\nclass SharpieSet:\n <mask token>\n\n def add_sharpie(self, sharpie: Sharpie):\n self.sharpies.append(sharpie)\n <mask token>\n\n def remove_unusable(self):\n for i in self.sharpies:\n ...
[ 3, 4, 5, 6, 7 ]
import pymarc from pymarc import JSONReader, Field, JSONWriter, XMLWriter import psycopg2 import psycopg2.extras import time import logging import json #WRITTEN W/PYTHON 3.7.3 print("...starting export"); # constructing file and log name timestr = time.strftime("%Y%m%d-%H%M%S") logging.basicConfig(filename=timestr ...
normal
{ "blob_id": "d81e8478d60c9ee778e1aeb0dd7b05f675e4ecad", "index": 2306, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('...starting export')\n<mask token>\nlogging.basicConfig(filename=timestr + '-export.log')\n<mask token>\nmatCursor.execute(select_all_mat)\n<mask token>\nfor m in materialTypes:\n ...
[ 0, 1, 2, 3, 4 ]
# Copyright (c) 2008 Johns Hopkins University. # All rights reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose, without fee, and without written # agreement is hereby granted, provided that the above copyright # notice, the (updated) modification history ...
normal
{ "blob_id": "4af53bf9cbe136dec7dcc609e28cdd013911c385", "index": 7421, "step-1": "# Copyright (c) 2008 Johns Hopkins University.\n# All rights reserved.\n#\n# Permission to use, copy, modify, and distribute this software and its\n# documentation for any purpose, without fee, and without written\n# agreement is h...
[ 0 ]
<|reserved_special_token_0|> class SandboxedEnvironment(Environment): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> def intercept_unop(self, operator): ... <|reserved_special_token_0...
flexible
{ "blob_id": "697f4dd640ddba0411eb6eb68e7ce079a6330670", "index": 9837, "step-1": "<mask token>\n\n\nclass SandboxedEnvironment(Environment):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def intercept_unop(self, operator):\n ...\n <mask token>\n <ma...
[ 10, 11, 13, 17, 21 ]
""" Version 3 of IRC (Infinite Recursive classifier). Based on the idea that each output is placed in a certain location. Let me try to solve a simpler problem first. Let me forget about the gate and do non stop recursive classification step by step, one bye one. Update. 19 May 2015. Let me stept this up. Instead of h...
normal
{ "blob_id": "eb043c4c981b48763164e3d060fd52f5032be0ea", "index": 8996, "step-1": "\"\"\" Version 3 of IRC (Infinite Recursive classifier). Based on the idea that each output is placed in a certain\nlocation.\nLet me try to solve a simpler problem first. Let me forget about the gate and do non stop recursive clas...
[ 0 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.route('/') def home(): return render_template('home.html') <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.route('/') def home(): return render_template('home.html'...
flexible
{ "blob_id": "5a0a8205977e59ff59a5d334a487cf96eee514d2", "index": 7211, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef home():\n return render_template('home.html')\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\n@app.route('/')\ndef home():\n return render_template('ho...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Sat Aug 11 13:13:53 2018 @author: zhang """ ''' Warp Commands use during diffusion-weighted images preprocessing ================================================================ dwidenoise & mrdegibbs from MRTrix3.0; eddy-openmp from FSL ------------------------------------------...
normal
{ "blob_id": "419aee3045a0d532afa0fc314df9cdef7aab5219", "index": 4181, "step-1": "<mask token>\n\n\nclass MRdegibbsInputSpec(CommandLineInputSpec):\n in_file = File(desc='input DWI image', exists=True, mandatory=True,\n position=0, argstr='%s')\n force = traits.Bool(desc='force overwrite of output f...
[ 20, 22, 24, 26, 29 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> print('gggg') print('gggg') print('gggg') <|reserved_special_token_1|> print("gggg") print("gggg") print("gggg")
flexible
{ "blob_id": "b53294330a908f8a50d8fbb50b9c88e2bc6135a1", "index": 4124, "step-1": "<mask token>\n", "step-2": "print('gggg')\nprint('gggg')\nprint('gggg')\n", "step-3": "print(\"gggg\")\nprint(\"gggg\")\nprint(\"gggg\")\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 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": "7817a42e5aee1786cfb3e8018bd7ca0a5e74749d", "index": 8447, "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 = [('nomenclatur...
[ 0, 1, 2, 3, 4 ]
distance = float(input("Введите начальную дистанцию: ")) target = int(input("Введите целевую дистанцию: ")) day = 1 print("{:>3}-й день: {:.3}".format(day, distance)) # некрасивенько while target > distance: day += 1 distance += distance / 10 print("{:>3}-й день: {:.3}".format(day, distance)) print("Ответ: ...
normal
{ "blob_id": "9033ba0a19d765a83737d59289735a9ffd02abb1", "index": 7519, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('{:>3}-й день: {:.3}'.format(day, distance))\nwhile target > distance:\n day += 1\n distance += distance / 10\n print('{:>3}-й день: {:.3}'.format(day, distance))\nprint('О...
[ 0, 1, 2, 3 ]
from PIL import Image, ImageDraw, ImageFont from PIL.ExifTags import TAGS from datetime import datetime #Extracts the timestamp from the filename and inserts it into the image def insert_timestamp_from_filename_into_image(path_to_image:str, ignorable_string:str, output_filename:str = "", distance_to_border:int = 5, ...
normal
{ "blob_id": "e6ab18d87ace00436a480f4f01da224eead84fc0", "index": 5145, "step-1": "<mask token>\n\n\ndef insert_timestamp_from_filename_into_image(path_to_image: str,\n ignorable_string: str, output_filename: str='', distance_to_border: int\n =5, color_of_timestamp: tuple=(0, 0, 0), size_of_timestamp: int=2...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> def get_random_id(): return uuid.uuid4().hex <|reserved_special_token_0|> def get_last_loaded_ids(source_id): try: with open('vk_loader/loaded_ids/' + str(source_id), 'r') as file: return list(map(lambda s: int(s.replace('\n', '')), file. re...
flexible
{ "blob_id": "cb742701094a8060e524ba22a0af2f969bdbf3d9", "index": 2365, "step-1": "<mask token>\n\n\ndef get_random_id():\n return uuid.uuid4().hex\n\n\n<mask token>\n\n\ndef get_last_loaded_ids(source_id):\n try:\n with open('vk_loader/loaded_ids/' + str(source_id), 'r') as file:\n return...
[ 5, 7, 10, 11, 12 ]
import pymel.all as pm from collections import Counter # example # v.Create( sel[0], pm.datatypes.Color.red, sel[1], 'leftEye', 0.2 ) # select mesh 1st then the control def Create( obj, targetColor, control, attr, offset ) : shape = obj.getShape() name = obj.name() if( type(shape) == pm.Mesh ) : outVerts = [] ...
normal
{ "blob_id": "9061db3bb3aa3178262af58e56126302b9effdff", "index": 6509, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Create(obj, targetColor, control, attr, offset):\n shape = obj.getShape()\n name = obj.name()\n if type(shape) == pm.Mesh:\n outVerts = []\n verts = shape.v...
[ 0, 1, 2, 3, 4 ]
''' "MAIN" module All operations are added to the defaultgraph. Network functions are found in module network_functions_2 Display graph in tensorboard by opening a new terminal and write "tensorboard --logdir=tensorbaord/debug/01/" where the last number depends on which directory the current graph is saved in (see l...
normal
{ "blob_id": "8a2cf1d550a593beae579104413b424e007d511f", "index": 9048, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith tf.name_scope('input_data'):\n (iterate_data, sub_images, sub_depths, sub_images_placeholder,\n sub_depths_placeholder) = rd.read_debug_data()\n sub_images_coarse = tf.c...
[ 0, 1, 2, 3, 4 ]
# Your code here d = dict() count = 0 fave_fast_food = input("Fave fast food restaurant: ") 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('Fast Food R...
normal
{ "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 ]
from gymnasium.spaces import Box, Discrete import numpy as np from typing import Optional, TYPE_CHECKING, Union from ray.rllib.env.base_env import BaseEnv from ray.rllib.models.action_dist import ActionDistribution from ray.rllib.models.modelv2 import ModelV2 from ray.rllib.models.tf.tf_action_dist import Categorical,...
normal
{ "blob_id": "b2b47b394eadebda5c51e89abd27832f9dbd4c8c", "index": 4193, "step-1": "<mask token>\n\n\n@PublicAPI\nclass ParameterNoise(Exploration):\n <mask token>\n\n def __init__(self, action_space, *, framework: str, policy_config: dict,\n model: ModelV2, initial_stddev: float=1.0, random_timesteps...
[ 16, 17, 20, 21, 22 ]
#! /usr/bin/python3 class Animal: def eat(self): print("吃") def bark(self): print("喝") def run(seft): print("跑") def sleep(self): print("睡") class Dog(Animal): # 子类拥有父类的所有属性和方法 def bark(self): print("汪汪叫") class XiaoTianQuan(Dog): # 3. 增加其...
normal
{ "blob_id": "d7aa85c2458ee12a8de0f75419945fbe2acdf95d", "index": 3946, "step-1": "class Animal:\n\n def eat(self):\n print('吃')\n\n def bark(self):\n print('喝')\n <mask token>\n <mask token>\n\n\nclass Dog(Animal):\n\n def bark(self):\n print('汪汪叫')\n\n\nclass XiaoTianQuan(Dog...
[ 8, 9, 11, 12, 13 ]
<|reserved_special_token_0|> def get_close(x): if len(x) == 0: return '' return x[0] <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_close(x): if len(x) == 0: return '' return x[0] <|reserved_special_token_0|> result.to_csv(output...
flexible
{ "blob_id": "7a9515b1f8cc196eb7551137a1418d5a387e7fd3", "index": 959, "step-1": "<mask token>\n\n\ndef get_close(x):\n if len(x) == 0:\n return ''\n return x[0]\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef get_close(x):\n if len(x) == 0:\n return ''\n return x[0]\n\n\n<mask ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class MainPage(Base): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class MainPage(Base): def goto_contact(self): self.find(By.CSS_SELECTOR, '#menu_contacts').click(...
flexible
{ "blob_id": "7775d260f0db06fad374d9f900b03d8dbcc00762", "index": 6504, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MainPage(Base):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass MainPage(Base):\n\n def goto_contact(self):\n self.find(By.CSS_SELECTOR, '#menu_contacts').c...
[ 0, 1, 2, 3, 4 ]