code
stringlengths
13
6.09M
order_type
stringclasses
2 values
original_example
dict
step_ids
listlengths
1
5
from mysql import connector def get_db_connection(): try: return connector.connect(host="server_database_1", user="root", password="password1234", database="SMARTHOUSE") except connector.errors.DatabaseError: connection = connector.connect(host="server_database_1", user="root", password="pass...
normal
{ "blob_id": "6cb97e6f3c7ba312ec1458fd51635508a16f70dd", "index": 2957, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_db_connection():\n try:\n return connector.connect(host='server_database_1', user='root',\n password='password1234', database='SMARTHOUSE')\n except co...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # Ben Suay, RAIL # May 2013 # Worcester Polytechnic Institute # # http://openrave.org/docs/latest_stable/command_line_tools/ # openrave-robot.py /your/path/to/your.robot.xml --info=joints # On that page you can find more examples on how to use openrave-robot.py. from openravepy import * import s...
normal
{ "blob_id": "6ad939ab541562efdaacb8b56865e76d1745176a", "index": 2494, "step-1": "#!/usr/bin/env python\n# Ben Suay, RAIL\n# May 2013\n# Worcester Polytechnic Institute\n#\n\n# http://openrave.org/docs/latest_stable/command_line_tools/\n# openrave-robot.py /your/path/to/your.robot.xml --info=joints\n# On that pa...
[ 0 ]
import datetime a = datetime.datetime.now() while True: print("""\ Welcome to HMS 1. Are you want enter data 2. Are you want see record 3. exit """) option = int(input("enter your option")) print(option) if option == 1: print("""\ Select client na...
normal
{ "blob_id": "5c5a0fd67a6d6e805b77ddfddfe959335daa3bad", "index": 6383, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n print(\n \"\"\" Welcome to HMS\n 1. Are you want enter data\n 2. Are you want see record\n 3. exit\n \"\"\"\n )\n opti...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def prepareTransformAttributes(attributes): dtype = attributes.get('type') dtype = '{}'.format(dtype) min = attributes.get('min') max = attributes.get('max') ftype = attributes.get('ftype') maxV = np.power(2.0, np.iinfo(np.dtype(dtype)).bits) - 1.0 minO = np.ii...
flexible
{ "blob_id": "57490e56833154d3ed3a18b5bf7bc4db32a50d69", "index": 2979, "step-1": "<mask token>\n\n\ndef prepareTransformAttributes(attributes):\n dtype = attributes.get('type')\n dtype = '{}'.format(dtype)\n min = attributes.get('min')\n max = attributes.get('max')\n ftype = attributes.get('ftype'...
[ 6, 7, 11, 12, 13 ]
import numpy as np class RandomPlayer: def __init__(self, game): self.game = game def play(self, board): a = np.random.randint(self.game.getActionSize()) valids = self.game.getValidMoves(board, 1) while valids[a] != 1: a = np.random.randint(self.game.getActionSize(...
normal
{ "blob_id": "efe099bc5cd0319ffefd779f1e854f1a60edc5fa", "index": 9240, "step-1": "<mask token>\n\n\nclass MinimaxPlayer:\n\n def __init__(self, game):\n self.game = game\n\n def play(self, Board):\n key = -1\n bem = -99999999\n board = self.to_board(Board)\n print(Board)\...
[ 7, 9, 14, 16, 17 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- "Widget for exporting the data" import asyncio from pathlib import Path from typing import List from bokeh.models import Div, CustomAction, CustomJS from view.dialog import FileDialog from utils.gui import startfile class ...
normal
{ "blob_id": "d120172e65f329b1137df38b693e5fe7145bc80d", "index": 2840, "step-1": "<mask token>\n\n\nclass CSVExporter:\n <mask token>\n <mask token>\n\n def reset(self, *_):\n \"\"\"reset all\"\"\"\n\n @staticmethod\n async def _run(dlg: SaveFileDialog, mainview, ctrl, doc):\n paths ...
[ 2, 7, 8, 9, 10 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('location', '0005_auto_20170303_1625'), ] operations = [ migrations.RemoveField( ...
normal
{ "blob_id": "ca7b3b5df860d3c3fb0953857ad950affdcc671d", "index": 9311, "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 = [('location', ...
[ 0, 1, 2, 3, 4 ]
from functools import partial def power_func(x, y, a=1, b=0): return a * x ** y + b new_func = partial(power_func, 2, a=4) print(new_func(4, b=1)) print(new_func(1))
normal
{ "blob_id": "c9f1768e2f2dd47d637c2e577067eb6cd163e972", "index": 8331, "step-1": "<mask token>\n\n\ndef power_func(x, y, a=1, b=0):\n return a * x ** y + b\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef power_func(x, y, a=1, b=0):\n return a * x ** y + b\n\n\n<mask token>\nprint(new_func(4, b=1))...
[ 1, 2, 3, 4 ]
from django.db import models from django.conf import settings from django.utils.text import slugify from six import python_2_unicode_compatible from ckeditor_uploader.fields import RichTextUploadingField from ckeditor.fields import RichTextField # Create your models here. class topic(models.Model): name = models.Ch...
normal
{ "blob_id": "31801f62942337b0cdf0e022dc75a9e125be54e3", "index": 4191, "step-1": "<mask token>\n\n\nclass article(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\n def __str__(sel...
[ 5, 7, 9, 10, 11 ]
<|reserved_special_token_0|> class mrk_file(FileInfo): <|reserved_special_token_0|> def __init__(self, id_=None, file=None, parent=None): super(mrk_file, self).__init__(id_, file, parent) self._type = '.mrk' <|reserved_special_token_0|> def __setstate__(self, state): super(mr...
flexible
{ "blob_id": "8e9aec7d3653137a05f94e4041d28f3423122751", "index": 3990, "step-1": "<mask token>\n\n\nclass mrk_file(FileInfo):\n <mask token>\n\n def __init__(self, id_=None, file=None, parent=None):\n super(mrk_file, self).__init__(id_, file, parent)\n self._type = '.mrk'\n <mask token>\n\...
[ 4, 5, 6, 7, 8 ]
# load the dependencies from airflow import DAG from datetime import date, timedelta, datetime # default_args are the default arguments applied to the DAG and all inherited tasks DAG_DEFAULT_ARGS = { 'owner': 'airflow', 'depends_on_past': False, 'retries': 1, 'retry_delay': timedelta(minutes=1) } with DAG('twitte...
normal
{ "blob_id": "436cc06778bf9ac9e04a897f4a4db90c595d943c", "index": 5969, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith DAG('twitter_dag_v1', start_date=datetime(2018, 10, 1),\n schedule_interval='@daily', default_args=DAG_DEFAULT_ARGS, catchup=False\n ) as dag:\n None\n", "step-3": "<mask ...
[ 0, 1, 2, 3, 4 ]
""" @File : jump.py @copyright : GG @Coder: Leslie_s @Date: 2020/1/26 """ import requests from lxml import html import pandas as pd import time import pandas as pd import datetime import re import json headers = { 'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,appl...
normal
{ "blob_id": "5aecd021297fee4407d6b529c24afb3c6398f7ba", "index": 7205, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in r:\n print(i.group(1))\n provinceName = i.group(1)\n provinceShortName = i.group(2)\n confirmedCount = i.group(3)\n iter_dict.setdefault(provinceShortName, confirm...
[ 0, 1, 2, 3, 4 ]
import cv2 as cv '''色彩空间介绍''' ''' RGB:对于RGB的色彩空间是立方体的色彩空间 三通道 红 黄 蓝 每个灰度级为255 HSV:对于HSV的色彩空间是255度的圆柱体 三通道 高度 圆心角 半径分别是255 HIS YCrCb YUV ''' '''常用的色彩空间转换函数***cvtColor''' def colorSpaceConvert(image): '''转换到灰度空间''' res = cv.cvtColor(image, cv.COLOR_BGR2GRAY) cv.imshow("gray", res) '''转换到HSV色彩空间''' r...
normal
{ "blob_id": "6d359d987c50fd0d5e963d467a379eb245e3eb40", "index": 3756, "step-1": "<mask token>\n\n\ndef colorSpaceConvert(image):\n \"\"\"转换到灰度空间\"\"\"\n res = cv.cvtColor(image, cv.COLOR_BGR2GRAY)\n cv.imshow('gray', res)\n \"\"\"转换到HSV色彩空间\"\"\"\n res = cv.cvtColor(image, cv.COLOR_BGR2HSV)\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class ViagemSerializer(serializers.ModelSerializer): detalhes = DetalheSerializer(many=True, read_only=True) caixa = CaixaSerializer(read_only=True) localPartida = HospitalSerializer(read_only=True) localChegada = HospitalSerializer(read_only=True) class Meta: ...
flexible
{ "blob_id": "b5c68211cfa255e47ee316dc5b0627719eacae78", "index": 8504, "step-1": "<mask token>\n\n\nclass ViagemSerializer(serializers.ModelSerializer):\n detalhes = DetalheSerializer(many=True, read_only=True)\n caixa = CaixaSerializer(read_only=True)\n localPartida = HospitalSerializer(read_only=True)...
[ 2, 6, 7, 8, 9 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def state_preparation(m, name, p): circ = QuantumCircuit(m, name='State prep') if name == 'GHZ': circ.h(0) for k in range(1, m): circ.cx(0, k) elif name == 'noisy_GHZ_bitflip': pro...
flexible
{ "blob_id": "6962bf99e3ecae473af54ded33fde09527cb82c0", "index": 8284, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef state_preparation(m, name, p):\n circ = QuantumCircuit(m, name='State prep')\n if name == 'GHZ':\n circ.h(0)\n for k in range(1, m):\n circ.cx(0, k)...
[ 0, 1, 2, 3 ]
// Time Complexity : O(n) // Space Complexity : O(n) // Did this code successfully run on Leetcode : Yes // // Any problem you faced while coding this : No // Your code here along with comments explaining your approach class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: res=[] ...
normal
{ "blob_id": "23bcef07326db084d4e0e6337beb00faba329193", "index": 1834, "step-1": "// Time Complexity : O(n)\n// Space Complexity : O(n)\n// Did this code successfully run on Leetcode : Yes\n// // Any problem you faced while coding this : No\n\n// Your code here along with comments explaining your approach\nclass...
[ 0 ]
from django import forms from .models import Picture class PictureUploadForm(forms.ModelForm): class Meta: model = Picture exclude = () def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) for field_name, field in self.fields.items(): field.widge...
normal
{ "blob_id": "3d45fd7dcb3b382efaefe2797ebeb33216a840fa", "index": 680, "step-1": "<mask token>\n\n\nclass PictureUploadForm(forms.ModelForm):\n\n\n class Meta:\n model = Picture\n exclude = ()\n <mask token>\n <mask token>\n\n\nclass PictureUpdateForm(forms.Form):\n width = forms.Integer...
[ 5, 6, 7, 8, 9 ]
<|reserved_special_token_0|> def get_accuracy(model, kb): results = [] for clause in kb.clauses: o1, o2 = model.forward(clause) if o2.data.numpy()[0][0] > 0.9: results.append(1.0) else: results.append(0.0) return sum(results) / len(kb.clauses) def test_mod...
flexible
{ "blob_id": "3022cade3bfa36925bcbda8023e5cd98ed33d093", "index": 9901, "step-1": "<mask token>\n\n\ndef get_accuracy(model, kb):\n results = []\n for clause in kb.clauses:\n o1, o2 = model.forward(clause)\n if o2.data.numpy()[0][0] > 0.9:\n results.append(1.0)\n else:\n ...
[ 2, 3, 4, 5, 6 ]
from flask_opencv_streamer.streamer import Streamer import cv2 import numpy as np MASK = np.array([ [0, 1, 0], [1, -4, 1], [0, 1, 0] ]) port = 3030 require_login = False streamer = Streamer(port, require_login) video_capture = cv2.VideoCapture('http://149.43.156.105/mjpg/video.mjpg') whi...
normal
{ "blob_id": "a19b4928c9423dae6c60f39dbc5af0673b433c8e", "index": 3551, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n _, frame = video_capture.read()\n frame = cv2.medianBlur(frame, 3)\n frame = cv2.filter2D(frame, -1, MASK)\n _, frame = cv2.threshold(frame, 10, 255, cv2.THRESH_...
[ 0, 1, 2, 3, 4 ]
from torch import nn from abc import ABCMeta, abstractmethod class BaseEncoder(nn.Module): __metaclass__ = ABCMeta def __init__(self, **kwargs): if len(kwargs) > 0: raise RuntimeError( "Unrecognized options: {}".format(', '.join(kwargs.keys()))) super(BaseEncoder, s...
normal
{ "blob_id": "86ee2300b5270df3dadb22f2cfea626e6556e5db", "index": 9951, "step-1": "<mask token>\n\n\nclass BaseEncoder(nn.Module):\n <mask token>\n\n def __init__(self, **kwargs):\n if len(kwargs) > 0:\n raise RuntimeError('Unrecognized options: {}'.format(', '.join(\n kwarg...
[ 3, 4, 5, 6, 7 ]
# -*-coding:utf-8 -* # Copyright (c) 2011-2015, Intel Corporation # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, # are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, thi...
normal
{ "blob_id": "3c2873add66172a5ed038949c31d514dcd5f26b3", "index": 7152, "step-1": "# -*-coding:utf-8 -*\n\n# Copyright (c) 2011-2015, Intel Corporation\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without modification,\n# are permitted provided that the following condit...
[ 0 ]
import itertools def possibleNumber(digitSet, n): res = [[]] pools = [digitSet] * n # print(pools) for pool in pools: # print(res) res = [ x + [y] for x in res for y in pool] for prod in res: yield prod # def possibleNumber(digitSet, n): # res = [] # temp = itertoo...
normal
{ "blob_id": "fcc6dd61b94d5fa7f088fc75b748d976d1b30fa5", "index": 1781, "step-1": "<mask token>\n\n\ndef possibleNumber(digitSet, n):\n res = [[]]\n pools = [digitSet] * n\n for pool in pools:\n res = [(x + [y]) for x in res for y in pool]\n for prod in res:\n yield prod\n\n\n<mask token...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class Atendent(models.Model): user = models.ForeignKey(User) event = models.ForeignKey(Event, null=True, blank=True) state = models.IntegerField(null=True, blank=True) <|reserved_special_token_1|> <|reserved_special_token_0|> class Event(models.Model): <|reserved_spec...
flexible
{ "blob_id": "137f9310256f66ccd9fbe6626659c3c4daea0efc", "index": 8949, "step-1": "<mask token>\n\n\nclass Atendent(models.Model):\n user = models.ForeignKey(User)\n event = models.ForeignKey(Event, null=True, blank=True)\n state = models.IntegerField(null=True, blank=True)\n", "step-2": "<mask token>\...
[ 2, 4, 5, 6, 7 ]
import numpy as np import os # ---------------------------------------------------------------------------- # Common variables # shifting channels based on rules: # CH_SHIFT[rule_name] = {src_1_based_ch:new_1_based_ch} CH_SHIFT = {} CH_SHIFT[None] = None # for 1-to-1 cards CH_SHIFT['1to1'] = {} for ch1 in xrange(1,...
normal
{ "blob_id": "c2ee716b72652035502a1f07dfe8aa68a104b2bb", "index": 8255, "step-1": "import numpy as np\nimport os\n\n# ----------------------------------------------------------------------------\n# Common variables\n\n# shifting channels based on rules:\n# CH_SHIFT[rule_name] = {src_1_based_ch:new_1_based_ch}\n...
[ 0 ]
class BinaryTree: def __init__(self, data=None): self.data = data self.left = None self.right = None def insert(self, data): if self.data != None: arr = [self] while len(arr) > 0: node = arr[0] if node.left: ...
flexible
{ "blob_id": "3eaced9609c7adfa5457d7dcad8b2dfaeb697b16", "index": 3220, "step-1": "class BinaryTree:\n\n def __init__(self, data=None):\n self.data = data\n self.left = None\n self.right = None\n\n def insert(self, data):\n if self.data != None:\n arr = [self]\n ...
[ 12, 15, 18, 19, 22 ]
#!/bin/env python # coding: utf-8 """ Dakara Online protocol generator, by Alejandro Santos """ from genpackets import * from gendefs_js import * BUILDERS = [] HANDLERS = [] DECODE_DISPATCH = [] ARGS_HANDLER = [] def write_packets_from(f, fph, base_name, namespace, P): # Enum with IDs if base_name != "Serv...
normal
{ "blob_id": "22dccf6bb76dab735f373089d0772f475b2d5a5d", "index": 6849, "step-1": "<mask token>\n\n\ndef write_packets_from(f, fph, base_name, namespace, P):\n if base_name != 'ServerPacket':\n f.write('var {base_name}ID = {{ \\n'.format(base_name=base_name))\n for i, x in enumerate(P):\n ...
[ 4, 5, 6, 7, 8 ]
from datetime import datetime import warnings import numpy as np import xarray as xr from .common import HDF4, expects_file_info pyhdf_is_installed = False try: from pyhdf import HDF, VS, V from pyhdf.SD import SD, SDC pyhdf_is_installed = True except ImportError: pass __all__ = [ 'CloudSat', ] ...
normal
{ "blob_id": "4328d526da14db756fad8d05457724a23e3e3ef6", "index": 3939, "step-1": "<mask token>\n\n\nclass CloudSat(HDF4):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, **kwargs):\n super().__init__(**kwargs)\n\n @expects_file_info()\n def get_info(self, file_info, *...
[ 4, 7, 8, 9, 11 ]
import time class SequenceHeuristic(object): def __init__(self, minChanges, minDuration, noMotionDelay): self._minChanges = minChanges self._minDuration = minDuration self._noMotionDelay = noMotionDelay self._duration = 0 def isValid(self, image, data): numOfChanges...
normal
{ "blob_id": "e07bd4cd13209bff8bc1119a619a2954abd52592", "index": 1515, "step-1": "<mask token>\n\n\nclass SequenceHeuristic(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass SequenceHeuristic(object):\n\n def __init__(self, minChanges, minDuration, noMotionDelay):\n ...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> with open('got_info.json', 'w') as f: f.write(x) <|reserved_special_token_1|> <|reserved_special_token_0|> headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0...
flexible
{ "blob_id": "d625e6724a3fe077a6f80b6de6b1f5bb0b95d47d", "index": 4612, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('got_info.json', 'w') as f:\n f.write(x)\n", "step-3": "<mask token>\nheaders = {'User-Agent':\n 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gec...
[ 0, 1, 2, 3, 4 ]
# model class for a sale record from app.models.product import Product class Sale(Product): def __init__(self,product_name,quantity,unit_price,attendant,date): super(Sale, self).__init__(product_name, quantity, unit_price) self.attendant = attendant self.date = date
normal
{ "blob_id": "8ed14bb9af23055f4689e06df872a1d36185cd09", "index": 6865, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Sale(Product):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Sale(Product):\n\n def __init__(self, product_name, quantity, unit_price, attendant, date):\n ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 data = None with open('./01-data.txt') as f: data = f.read().splitlines() ss = {} s = 0 ss[s] = True def check(data): global ss global s for line in data: s += int(line) if ss.get(s, False): return s ss[s] = True return None v = chec...
normal
{ "blob_id": "7e1dd242c60ee12dfc4130e379fa35ae626a4d63", "index": 5217, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef check(data):\n global ss\n global s\n for line in data:\n s += int(line)\n if ss.get(s, False):\n return s\n ss[s] = True\n return None...
[ 0, 1, 2, 3, 4 ]
import os import json from google.appengine.ext import webapp from generic import JsonRpcService class ViewService(JsonRpcService): def json_create(self): return "Hello, World!"
normal
{ "blob_id": "1b091d139635e90fb53b3fecc09bb879514c7b38", "index": 7352, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ViewService(JsonRpcService):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ViewService(JsonRpcService):\n\n def json_create(self):\n return 'Hello, World!...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def talk(text): engine.say(text) engine.runAndWait() def takeCommand(): try: with sr.Microphone() as sc: print('Listening......') vc = listner.listen(sc) cmd = listner.recognize_google(vc) cmd = cmd.lower() ...
flexible
{ "blob_id": "c4f437e6f5aaeccb6dd0948c3ed1f1d465bb29ce", "index": 1200, "step-1": "<mask token>\n\n\ndef talk(text):\n engine.say(text)\n engine.runAndWait()\n\n\ndef takeCommand():\n try:\n with sr.Microphone() as sc:\n print('Listening......')\n vc = listner.listen(sc)\n ...
[ 3, 4, 5, 6, 7 ]
<|reserved_special_token_0|> def GetPrediction(X, regr): return regr.predict(X) def GetRMSE(Y, YP): return sqrt(mean_squared_error(Y, YP)) def SplitFitGKRR(X, Y): Xt, XT, Yt, YT = cross_validation.train_test_split(X, Y, test_size=0.2) regr = setBestParameters(len(Xt)) regr.fit(Xt, Yt) retu...
flexible
{ "blob_id": "7d3a33968a375141c1c451ecd531ce8d97906c7f", "index": 3065, "step-1": "<mask token>\n\n\ndef GetPrediction(X, regr):\n return regr.predict(X)\n\n\ndef GetRMSE(Y, YP):\n return sqrt(mean_squared_error(Y, YP))\n\n\ndef SplitFitGKRR(X, Y):\n Xt, XT, Yt, YT = cross_validation.train_test_split(X, ...
[ 5, 7, 8, 10, 11 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @view_defaults(context=IndividualResource) class IndividualView(CRUDCommonView): <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @view_defaults(context=IndividualResource) class In...
flexible
{ "blob_id": "a3cfd507e30cf232f351fbc66d347aaca99a0447", "index": 4059, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@view_defaults(context=IndividualResource)\nclass IndividualView(CRUDCommonView):\n <mask token>\n", "step-3": "<mask token>\n\n\n@view_defaults(context=IndividualResource)\nclas...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def solution2(n): return sum([i for i in range(1, n + 1) if n % i == 0]) <|reserved_special_token_0|> <|reserved_special_token_1|> def solution(n): answer = [] for i in range(1, n + 1): if n % i == 0: ...
flexible
{ "blob_id": "7cfbc36cc6cd6ff7c30f02d979667448f2003546", "index": 9267, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solution2(n):\n return sum([i for i in range(1, n + 1) if n % i == 0])\n\n\n<mask token>\n", "step-3": "def solution(n):\n answer = []\n for i in range(1, n + 1):\n ...
[ 0, 1, 2, 3, 4 ]
from ShazamAPI import Shazam import json import sys print("oi")
normal
{ "blob_id": "c248d653556ecdf27e56b57930832eb293dfd579", "index": 5413, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('oi')\n", "step-3": "from ShazamAPI import Shazam\nimport json\nimport sys\nprint('oi')\n", "step-4": "from ShazamAPI import Shazam\nimport json\nimport sys\n\nprint(\"oi\")\n",...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> @mod.route('/shutdown') def shutdown(): flash( 'Shutting down.<br>When the LEDs on the board stop flashing, it should be safe to unplug your Raspberry Pi.' ) subprocess.call(['sudo', 'halt']) return redirect(url_for('system.index')) <|reserved_special_tok...
flexible
{ "blob_id": "e056a1600b620519e729c597dcec57793284019a", "index": 1470, "step-1": "<mask token>\n\n\n@mod.route('/shutdown')\ndef shutdown():\n flash(\n 'Shutting down.<br>When the LEDs on the board stop flashing, it should be safe to unplug your Raspberry Pi.'\n )\n subprocess.call(['sudo...
[ 1, 4, 5, 6, 7 ]
from .models import Video, VideoClass from rest_framework import serializers # Video 정보 class VideoSerializer(serializers.ModelSerializer): class Meta: model = Video fields = ['videoURL','subTitle', 'numOfLike', 'numOfPlay'] # Video 분류 class VideoClassSerializer(serializers.ModelSerializer): ...
normal
{ "blob_id": "b20a8160ba455a39e990b8b37c5017645530ced3", "index": 1545, "step-1": "<mask token>\n\n\nclass VideoClassSerializer(serializers.ModelSerializer):\n <mask token>\n\n\n class Meta:\n model = VideoClass\n fields = 'title', 'video_set'\n\n def get_video_set(self, instance):\n ...
[ 2, 3, 4, 5, 6 ]
from typing import Any from electionguard.ballot import CiphertextAcceptedBallot from electionguard.decryption import compute_decryption_share_for_ballot from electionguard.election import CiphertextElectionContext from electionguard.scheduler import Scheduler from electionguard.serializable import write_json_object fr...
normal
{ "blob_id": "0544c67cb14549e32b6ff8ea3215c6c65c8416ec", "index": 5542, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@router.post('/decrypt-shares', tags=[TALLY])\ndef decrypt_ballot_shares(request: DecryptBallotSharesRequest=Body(...),\n scheduler: Scheduler=Depends(get_scheduler)) ->Any:\n \...
[ 0, 1, 2, 3, 4 ]
start=0 last=100 middle=50 counter=1 print(" Guess a number between 0 and 100") condition = int(input("Is your guess " + str(middle) + "? (0 means it's too low, 1 means it's your guess and 2 means it's too high) ")) while condition != 1: counter += 1 if condition == 0: last = middle elif conditio...
normal
{ "blob_id": "42d03aabef7d75c813f30bb6d8a835d76fd1fc83", "index": 603, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(' Guess a number between 0 and 100')\n<mask token>\nwhile condition != 1:\n counter += 1\n if condition == 0:\n last = middle\n elif condition == 2:\n start = ...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # --------------------( LICENSE )-------------------- # Copyright (c) 2014-2023 Beartype authors. # See "LICENSE" for further details. ''' Project-wide **standard Python module globals** (i.e., global constants describing modules and packages bundled with CPython's sta...
normal
{ "blob_id": "a42f36fca2f65d0c5c9b65055af1814d8b4b3d42", "index": 89, "step-1": "<mask token>\n", "step-2": "<mask token>\nBUILTINS_MODULE_NAME = 'builtins'\n<mask token>\n", "step-3": "#!/usr/bin/env python3\n# --------------------( LICENSE )--------------------\n# Copyright (c) 20...
[ 0, 1, 2 ]
"""component URL Configuration The `urlpatterns` list routes URLs to views. For more information please see: https://docs.djangoproject.com/en/1.11/topics/http/urls/ Examples: Function views 1. Add an import: from my_app import views 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')...
normal
{ "blob_id": "0de735647cf87f64ab64af081da6e11b0ed8a7a7", "index": 1173, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^login/$', login_page, name='login'), url('^logout/$',\n logout_page, name='logout'), url('^register/$', register_page, name=\n 'register'), url('^product/$', pr...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> class MessageUnpacker: <|reserved_special_token_0|> <|reserved_special_token_0|> def unpack_json_to_dict(self, incoming_json): record_as_dict = json.loads(incoming_json) return record_as_dict <|reserved_special_token_0|> <|reserved_special_token_1|> <|r...
flexible
{ "blob_id": "2afc1027c6866e8ab9584a5f7feef4470661f763", "index": 4246, "step-1": "<mask token>\n\n\nclass MessageUnpacker:\n <mask token>\n <mask token>\n\n def unpack_json_to_dict(self, incoming_json):\n record_as_dict = json.loads(incoming_json)\n return record_as_dict\n <mask token>\...
[ 2, 4, 5, 6, 7 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @bp_admin.route('/profile', methods=['GET', 'POST']) @login_required def profile_edit(): """Show user profile edition form.""" form = ProfileForm(obj=current_user) if form.validate_on_submit(): form.populate_...
flexible
{ "blob_id": "cde62c5032109bb22aa81d813e30097dad80a9c3", "index": 4924, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@bp_admin.route('/profile', methods=['GET', 'POST'])\n@login_required\ndef profile_edit():\n \"\"\"Show user profile edition form.\"\"\"\n form = ProfileForm(obj=current_user)\n...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> input_object.close() <|reserved_special_token_0|> for line in input_data: cleaned_data.append(int(line.strip())) <|reserved_special_token_0|> for i in range(0, input_size): for j in range(i, input_size): for k in r...
flexible
{ "blob_id": "72f3ae476581ff5acd6c7101764f4764285a47bd", "index": 4426, "step-1": "<mask token>\n", "step-2": "<mask token>\ninput_object.close()\n<mask token>\nfor line in input_data:\n cleaned_data.append(int(line.strip()))\n<mask token>\nfor i in range(0, input_size):\n for j in range(i, input_size):\n...
[ 0, 1, 2, 3 ]
from django.http import response from django.shortcuts import render from rest_framework.views import APIView from rest_framework.response import Response from .models import User from .serializers import UserSerializer,UserCreationSerialier,UserEditionSerializer from rest_framework import status from rest_framework.pe...
normal
{ "blob_id": "dff454cbde985a08b34377b80dd8e3b22f1cc13a", "index": 3948, "step-1": "<mask token>\n\n\nclass CreateUser(APIView):\n <mask token>\n\n\nclass EditUser(APIView):\n\n def put(self, request, pk):\n user = User.objects.filter(pk=pk, is_removed=False).first()\n if user is None:\n ...
[ 8, 10, 11, 13, 15 ]
ii = [('CookGHP3.py', 1), ('AubePRP2.py', 1), ('WilkJMC3.py', 1), ( 'LeakWTI3.py', 1), ('AubePRP.py', 2), ('GellWPT.py', 2), ('AdamWEP.py', 1), ('KiddJAE.py', 1), ('CoolWHM.py', 1), ('WadeJEB.py', 1), ( 'SoutRD.py', 2), ('WheeJPT.py', 1), ('HowiWRL2.py', 1), ('WilkJMC.py', 1), ('WestJIT.py', 1), ('Dequ...
normal
{ "blob_id": "dce496c9ae6605e95ffbbb2885ec15b19fb756ef", "index": 2799, "step-1": "<mask token>\n", "step-2": "ii = [('CookGHP3.py', 1), ('AubePRP2.py', 1), ('WilkJMC3.py', 1), (\n 'LeakWTI3.py', 1), ('AubePRP.py', 2), ('GellWPT.py', 2), ('AdamWEP.py',\n 1), ('KiddJAE.py', 1), ('CoolWHM.py', 1), ('WadeJEB...
[ 0, 1 ]
from django.db import models from datetime import datetime class Folder(models.Model): folder = models.CharField(max_length=200, default = "misc") num_of_entries = models.IntegerField(default=0) def __str__(self): return self.folder class Meta: verbose_name_plural = "Folders/Categories" class Bookmark(model...
normal
{ "blob_id": "ca3cdbd5d5d30be4f40925366994c3ea9d9b9614", "index": 3195, "step-1": "<mask token>\n\n\nclass Folder(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name_plural = 'Folders/Categories'\n\n\nclass Bookmark(models.Model):\n name = models.Char...
[ 4, 5, 6, 7, 8 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for i in range(N): a = A[i] if a < 400: C[0] += 1 elif a < 800: C[1] += 1 elif a < 1200: C[2] += 1 elif a < 1600: C[3] += 1 elif a < 2000: C[4] += 1 elif a < 2400...
flexible
{ "blob_id": "a1ca6c258298feda99b568f236611c1c496e3262", "index": 8993, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(N):\n a = A[i]\n if a < 400:\n C[0] += 1\n elif a < 800:\n C[1] += 1\n elif a < 1200:\n C[2] += 1\n elif a < 1600:\n C[3] += 1\n ...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ This script reads in video information frame-by-frame, and then calculates visual edge information for each frame, storing the information in a vector. This can be averaged within TRs in an fMRI analysis to 'regress out' high-frequency visual information in the video. ...
normal
{ "blob_id": "d70d3d8eef711441ac89c2d98c72a5f95e0ab20d", "index": 5261, "step-1": "<mask token>\n\n\ndef AnalyzeFrames(vidpath):\n print('\\nGetting video info & writing out image files for each frame...\\n')\n vidObj = cv2.VideoCapture(vidpath)\n fps = vidObj.get(cv2.CAP_PROP_FPS)\n print('Frames per...
[ 1, 2, 3, 4, 5 ]
""" 默认查询所有 > db.test1000.find() { "_id" : ObjectId("5c3559ab648171cce9135dd6"), "name" : "zhangdapeng" } { "_id" : ObjectId("5c3559af648171cce9135dd7"), "name" : "zhangdapeng1" } { "_id" : ObjectId("5c3559b2648171cce9135dd8"), "name" : "zhangdapeng2" } { "_id" : ObjectId("5c3559b4648171cce9135dd9"),...
normal
{ "blob_id": "d8e0198244c3df77fa0258cc97a55042e36d056f", "index": 7756, "step-1": "<mask token>\n", "step-2": "\"\"\"\n默认查询所有\n > db.test1000.find()\n { \"_id\" : ObjectId(\"5c3559ab648171cce9135dd6\"), \"name\" : \"zhangdapeng\" }\n { \"_id\" : ObjectId(\"5c3559af648171cce9135dd7\"), \"name\" : \"zhan...
[ 0, 1 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> Base.metadata.create_all(bind=engine) <|reserved_special_token_1|> <|reserved_special_token_0|> SQLALCHEMY_DATABASE_URL = ( f'sqlite:///{Path(__name__).parent.absolute()}/sql_app.db') engine = create_engine(SQLALCHEMY_DATAB...
flexible
{ "blob_id": "0656c3e1d8f84cfb33c4531e41efb4a349d08aac", "index": 6747, "step-1": "<mask token>\n", "step-2": "<mask token>\nBase.metadata.create_all(bind=engine)\n", "step-3": "<mask token>\nSQLALCHEMY_DATABASE_URL = (\n f'sqlite:///{Path(__name__).parent.absolute()}/sql_app.db')\nengine = create_engine(S...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> np.random.seed(50) <|reserved_special_token_0|> rl.load_weight(load_file_name) <|reserved_special_token_0|> print(rl.w) <|reserved_special_token_0|> plt.scatter(x, track.y[0][:, 0], c='b', label='random') plt.scatter(x, track.y[1]...
flexible
{ "blob_id": "5e6bbb10ec82e566c749dd4d794eabd2e8f7a648", "index": 4488, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.random.seed(50)\n<mask token>\nrl.load_weight(load_file_name)\n<mask token>\nprint(rl.w)\n<mask token>\nplt.scatter(x, track.y[0][:, 0], c='b', label='random')\nplt.scatter(x, track.y[...
[ 0, 1, 2, 3, 4 ]
import numpy as np catogory = np.array([50, 30, 40, 20]) data = np.array([[20, 50, 10, 15, 20], [30, 40, 20, 65, 35], [75, 30, 42, 70, 45], [40, 25, 35, 22, 55]]) print(catogory) print(data) print(catogory.dot(data)) print(data.T.dot(catogory))
normal
{ "blob_id": "e4b49faaad648c6e85274abb18f994083a74013d", "index": 7160, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(catogory)\nprint(data)\nprint(catogory.dot(data))\nprint(data.T.dot(catogory))\n", "step-3": "<mask token>\ncatogory = np.array([50, 30, 40, 20])\ndata = np.array([[20, 50, 10, 15...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def range_func(measures): scores = [] for entry in measures: try: curr = int(entry[1]) except: curr = None if curr is not None: scores.append(curr) if len(scores) < 1: return 0 return max(scores) - min(sco...
flexible
{ "blob_id": "4c60fd123f591bf2a88ca0affe14a3c3ec0d3cf6", "index": 60, "step-1": "<mask token>\n\n\ndef range_func(measures):\n scores = []\n for entry in measures:\n try:\n curr = int(entry[1])\n except:\n curr = None\n if curr is not None:\n scores.appe...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> def get(i): with open('晚安.txt', 'r', encoding='utf-8') as f: line = f.readlines()[i] return line <|reserved_special_token_0|> def main(): for i in range(3650): send(i) time.sleep(5) <|reserved_special_token_0|> <|reserved_special_token_1|> <|re...
flexible
{ "blob_id": "a7d11f130e0d5d6c9b4ac7c5d3a804fb9f79b943", "index": 2284, "step-1": "<mask token>\n\n\ndef get(i):\n with open('晚安.txt', 'r', encoding='utf-8') as f:\n line = f.readlines()[i]\n return line\n\n\n<mask token>\n\n\ndef main():\n for i in range(3650):\n send(i)\n time.slee...
[ 2, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for _ in range(t): n, m = map(int, input().split()) rows = [0] * n a_column = list() for r in range(n): tmp = list(input().split()) rows[r] = tmp a_column.append(tmp[0]) sorted_a_column ...
flexible
{ "blob_id": "9004314951f77b14bab1aba9ae93eb49c8197a8d", "index": 4409, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(t):\n n, m = map(int, input().split())\n rows = [0] * n\n a_column = list()\n for r in range(n):\n tmp = list(input().split())\n rows[r] = tmp\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> def merge_sort(lists): if len(lists) <= 1: return lists middle = len(lists) // 2 left = merge_sort(lists[:middle]) right = merge_sort(lists[middle:]) return merge(left, right) <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_tok...
flexible
{ "blob_id": "cf3b66a635c6549553af738f263b035217e75a7a", "index": 903, "step-1": "<mask token>\n\n\ndef merge_sort(lists):\n if len(lists) <= 1:\n return lists\n middle = len(lists) // 2\n left = merge_sort(lists[:middle])\n right = merge_sort(lists[middle:])\n return merge(left, right)\n\n\...
[ 1, 2, 3, 4, 5 ]
<|reserved_special_token_0|> class DjangoHandler(tornado.web.RequestHandler): async def reroute(self): http = tornado.httpclient.AsyncHTTPClient() new_request = copy.deepcopy(self.request) url_obj = copy.urlparse(new_request.url) new_request.url = f'{url_obj.scheme}://localhost:90...
flexible
{ "blob_id": "6960fc6d949512ffc783b085041f86cb791160a3", "index": 1500, "step-1": "<mask token>\n\n\nclass DjangoHandler(tornado.web.RequestHandler):\n\n async def reroute(self):\n http = tornado.httpclient.AsyncHTTPClient()\n new_request = copy.deepcopy(self.request)\n url_obj = copy.urlp...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> __all__ = ['ISearcher'] <|reserved_special_token_1|> from .isearch import ISearcher __all__ = ['ISearcher']
flexible
{ "blob_id": "13e2f474294edb7c78bd81456097d1389e6a0f1b", "index": 5003, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['ISearcher']\n", "step-3": "from .isearch import ISearcher\n__all__ = ['ISearcher']\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
#-*- coding = utf-8-*- #@Time : 2020/6/26 11:02 #@Author :Ella #@File :app.py #@Software : PyCharm import time import datetime from flask import Flask,render_template,request #render_template渲染模板 app = Flask(__name__) #初始化的对象 #路由解析,通过用户访问的路径,匹配想要的函数 @app.route('/') def hello_world(): return '你好' #通过访问路径,获取用户的...
normal
{ "blob_id": "d68bd9c90a106a9eac767607ad77bdd84d0f18d2", "index": 1006, "step-1": "<mask token>\n\n\n@app.route('/')\ndef hello_world():\n return '你好'\n\n\n@app.route('/test1/<name>')\ndef test1(name):\n return '你好,%s' % name\n\n\n@app.route('/test2/<int:id>')\ndef test2(id):\n return '你好,%d' % id\n\n\n<...
[ 5, 6, 7, 9, 10 ]
# Copyright 2017 Klarna AB # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, s...
normal
{ "blob_id": "d5d12e2269b343dde78534eddf2cce06759eb264", "index": 9128, "step-1": "<mask token>\n\n\n@override_settings(RETHINK_DB_DB=os.environ.get('RETHINK_DB_DB',\n 'django_rethinkci'))\nclass APITests(TestCase):\n\n @classmethod\n def setUpClass(cls):\n super(APITests, cls).setUpClass()\n ...
[ 8, 12, 14, 18, 19 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- from .variational_legacy import *
normal
{ "blob_id": "ea07cb640e76ced8be92b55ee14e1d3058e073c9", "index": 845, "step-1": "<mask token>\n", "step-2": "from .variational_legacy import *\n", "step-3": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom .variational_legacy import *\n", "step-4": null, "step-5": null, "step-ids": [ 0, ...
[ 0, 1, 2 ]
from test.framework import TestCase from test.mock import Mock from package.util.svnutil import ReleaseXmlParser, Release import time class SvnUtilTests(TestCase): def setUp(self): r1 = Release() r1.name = 'BETA1.1.0' r1.type = 'BETA' r1.version = '1.1.0' r1.date = time.strp...
normal
{ "blob_id": "9c320db85ca1a9df6b91f6bb062e4d5c3d94ee91", "index": 9516, "step-1": "<mask token>\n\n\nclass SvnUtilTests(TestCase):\n\n def setUp(self):\n r1 = Release()\n r1.name = 'BETA1.1.0'\n r1.type = 'BETA'\n r1.version = '1.1.0'\n r1.date = time.strptime('2009-04-21 23:...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals import markdown from django.db import models from django.contrib.auth.models import User from datetime import datetime class MovieRankings(models.Model): """ 各种电影排行榜. """ name = models.CharField(max_length=100) def __unicode__(self)...
normal
{ "blob_id": "449ae193f8817d4ee2fe67eadf72d9c19b2c5e53", "index": 1319, "step-1": "<mask token>\n\n\nclass MovieRankings(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Movie(models.Model):\n \"\"\"\n 电影的数据库表格\n \"\"\"\n movie_name = models.CharField(max_length=64, blan...
[ 8, 10, 11, 12, 13 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> __author__ = 'ghou' <|reserved_special_token_0|> bGameValid = True dAskUserInfo = {} gAccMode = 0 gWhiteTestResourceVersion = None gInvalidClientVersion = None <|reserved_special_token_1|> __author__ = 'ghou' from datetime import datetime bGameValid = True...
flexible
{ "blob_id": "2e075c3ee6b245b1ffd0bb8c4e205199f794da76", "index": 5725, "step-1": "<mask token>\n", "step-2": "__author__ = 'ghou'\n<mask token>\nbGameValid = True\ndAskUserInfo = {}\ngAccMode = 0\ngWhiteTestResourceVersion = None\ngInvalidClientVersion = None\n", "step-3": "__author__ = 'ghou'\nfrom datetime...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations.Migration): dependencies = [(...
flexible
{ "blob_id": "9af71eaf8f6f4daacdc1def7b8c5b29e6bac6b46", "index": 4897, "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 = [('backend', '...
[ 0, 1, 2, 3, 4 ]
from .kahfm_batch import KaHFMBatch
normal
{ "blob_id": "8e317d4d8ae8dc3d692d237e7e0abfaf37aecbb6", "index": 7017, "step-1": "<mask token>\n", "step-2": "from .kahfm_batch import KaHFMBatch\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
# coding:utf-8 class Solution: def searchInsert(self, nums, target: int): n = len(nums) left = 0 right = n - 1 # 返回大于等于target的第一个索引则用left,否则用right while left <= right: mid = (left + right) // 2 if nums[mid] == target: return mid ...
normal
{ "blob_id": "9ec1cca08fac2fd976c1f596f7d340befc4eb339", "index": 2020, "step-1": "class Solution:\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "class Solution:\n\n def searchInsert(self, nums, target: int):\n n = len(nums)\n left = 0\n right = n ...
[ 1, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def get_station_coords(station): if station == 'steaks': coords = [0.4625, 0.375, 0.14] elif station == 'griddle': coords = [0.73, 0.375, 0.05] elif station == 'steak_flip_initial': coords = [...
flexible
{ "blob_id": "86c03fa85ac405a148be13325efeaaf691d9ec26", "index": 5223, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_station_coords(station):\n if station == 'steaks':\n coords = [0.4625, 0.375, 0.14]\n elif station == 'griddle':\n coords = [0.73, 0.375, 0.05]\n elif s...
[ 0, 1, 2, 3 ]
import MySQLdb import settings import redis import socket import fcntl import struct import datetime db = MySQLdb.connect(settings.host, settings.user, settings.pwd, settings.db) cursor = db.cursor() def connect_mysql(): try: db.ping() except: db = MySQLdb.connect...
normal
{ "blob_id": "b46b9b086fc089e24cb39a0c2c4ac252591b2190", "index": 1540, "step-1": "import MySQLdb\nimport settings\nimport redis\nimport socket\nimport fcntl\nimport struct\nimport datetime\n\n\ndb = MySQLdb.connect(settings.host, settings.user, settings.pwd, settings.db)\ncursor = db.cursor()\ndef connect_mysql(...
[ 0 ]
<|reserved_special_token_0|> class IGENMessage(object): def __init__(self): self.serial = None self.temperature = None self.pv1 = 0 self.pv2 = 0 self.pv3 = 0 self.pa1 = 0 self.pa2 = 0 self.pa3 = 0 self.ov1 = 0 self.ov2 = 0 se...
flexible
{ "blob_id": "5df42a024e1edbe5cc977a814efe580db04b8b76", "index": 2386, "step-1": "<mask token>\n\n\nclass IGENMessage(object):\n\n def __init__(self):\n self.serial = None\n self.temperature = None\n self.pv1 = 0\n self.pv2 = 0\n self.pv3 = 0\n self.pa1 = 0\n s...
[ 6, 7, 8, 9, 10 ]
<|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_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Migration(migrations....
flexible
{ "blob_id": "ab343f88c84d45cf90bddd52623362f047c72d3c", "index": 5754, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python #MTU Server from config import * from pymodbus.client.sync import ModbusTcpClient import time import numpy as np import logging from sklearn.decomposition import PCA import matplotlib.pyplot as plt import matplotlib.animation as anim logging.basicConfig() log = logging.getLogger() log.setLevel(loggin...
normal
{ "blob_id": "572a9da5edcff3ff5ca0a37f982432f9712dc58c", "index": 9279, "step-1": "#!/usr/bin/python\n#MTU Server\nfrom config import *\nfrom pymodbus.client.sync import ModbusTcpClient\nimport time\nimport numpy as np\nimport logging\nfrom sklearn.decomposition import PCA\nimport matplotlib.pyplot as plt\nimport...
[ 0 ]
print(sum([int(d) for d in str(pow(2, 1000))]))
normal
{ "blob_id": "fc0c8deb3a5a57934c9e707911c352af55100c3c", "index": 3533, "step-1": "<mask token>\n", "step-2": "print(sum([int(d) for d in str(pow(2, 1000))]))\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#! /usr/bin/env python3 from PIL import Image from imtools import * import os cwd = os.getcwd() filelist = get_imlist(os.getcwd()) print(filelist) for infile in filelist: outfile = os.path.splitext(infile)[0] + ".jpg" if infile != outfile: try: Image.open(infile).save(outfile) except IOError: print("ca...
normal
{ "blob_id": "31416f1ba9f3c44a7aa740365e05b5db49e70444", "index": 9106, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(filelist)\nfor infile in filelist:\n outfile = os.path.splitext(infile)[0] + '.jpg'\n if infile != outfile:\n try:\n Image.open(infile).save(outfile)\n ...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> class RetModel(object): <|reserved_special_token_0|> <|reserved_special_token_1|> class RetModel(object): def __init__(self, code=0, message='success', data=None): self.code = code self.msg = message self.data = data <|re...
flexible
{ "blob_id": "ec395b93cecf8431fd0df1aa0151ebd32244c367", "index": 4941, "step-1": "<mask token>\n", "step-2": "class RetModel(object):\n <mask token>\n", "step-3": "class RetModel(object):\n\n def __init__(self, code=0, message='success', data=None):\n self.code = code\n self.msg = message...
[ 0, 1, 2, 3 ]
# -*- coding:utf-8 -*- # from django.core.paginator import Paginator def pagination(request, queryset, display_amount=15, after_range_num=5, bevor_range_num=4): # 按参数分页 paginator = Paginator(queryset, display_amount) try: # 得到request中的page参数 page = int(request.GET['page']) except: ...
normal
{ "blob_id": "7a2b33d1763e66335c6a72a35082e20725cab03d", "index": 3318, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef pagination(request, queryset, display_amount=15, after_range_num=5,\n bevor_range_num=4):\n paginator = Paginator(queryset, display_amount)\n try:\n page = int(req...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> if __name__ == '__main__': app.run_server() <|reserved_special_token_1|> <|reserved_special_token_0|> app = dash.Dash() app.layout = html.Div(children=[html.Label('Dropdowm'), dcc.Dropdown(id= 'my-dropdown', options=[{'...
flexible
{ "blob_id": "443bf59bc3c5ed2114f0c276aa7134ff5bf7fb64", "index": 7264, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n app.run_server()\n", "step-3": "<mask token>\napp = dash.Dash()\napp.layout = html.Div(children=[html.Label('Dropdowm'), dcc.Dropdown(id=\n 'my-dropdo...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Aceptar_letras_wizard(models.TransientModel): <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> <|reserved_special_token_0|> @api.multi def aceptar_letras(self): active_ids = self.env.context.get('active_ids', [])...
flexible
{ "blob_id": "4ad3390f8f2c92f35acde507be7a7b713af997f2", "index": 5092, "step-1": "<mask token>\n\n\nclass Aceptar_letras_wizard(models.TransientModel):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @api.multi\n def aceptar_letras(self):\n active_ids = self.env.context.g...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class MainWindow(Ui_MainWindow, QtCore.QObject): def __init__(self, qmain_window): super().__init__() self.setupUi(qmain_window) self._proxy_model = CustomSortFilterProxyModel(self) self._mod...
flexible
{ "blob_id": "7a918518d8c9ff1184a634d1a5c799e735dfbc8a", "index": 1707, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MainWindow(Ui_MainWindow, QtCore.QObject):\n\n def __init__(self, qmain_window):\n super().__init__()\n self.setupUi(qmain_window)\n self._proxy_model = ...
[ 0, 2, 3, 4, 5 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> print(message) <|reserved_special_token_1|> message = 'Hello Python World ' print(message) <|reserved_special_token_1|> # message 为定义的变量 message = 'Hello Python World ' print(message)
flexible
{ "blob_id": "ee5e970f32b1d601f9dc3ab37a5028ce7ff8a32e", "index": 1368, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(message)\n", "step-3": "message = 'Hello Python World '\nprint(message)\n", "step-4": "# message 为定义的变量\r\nmessage = 'Hello Python World '\r\nprint(message)", "step-5": null...
[ 0, 1, 2, 3 ]
from flask import Flask from flask_ask import Ask, statement, question, session # import json, requests import random app = Flask(__name__) ask = Ask(app, "/") def get_cat_fact(): myFacts = [ "Cats should not be fed tuna exclusively, as it lacks taurine, an essential nutrient required for good feline hea...
normal
{ "blob_id": "77971b088a7e076e3bf6d7aa320981a50e7756ce", "index": 429, "step-1": "<mask token>\n\n\ndef get_cat_fact():\n myFacts = [\n 'Cats should not be fed tuna exclusively, as it lacks taurine, an essential nutrient required for good feline health. Make sure you have the proper Pet supplies to kee...
[ 3, 4, 5, 7, 8 ]
import numpy as np from input_parameters.program_constants import ITERATIONS_NUM, TIMESTEPS_NUMB def init_zero_arrays(): radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB)) dot_radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB)) dotdot_radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB)) d...
normal
{ "blob_id": "e652196f9c74be6f05c6148de152996e449670ea", "index": 3059, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef init_zero_arrays():\n radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB))\n dot_radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB))\n dotdot_radius_arr = np.zeros...
[ 0, 1, 2, 3 ]
''' held-karp.py Implementation of the Bellman-Held-Karp Algorithm to exactly solve TSPs, requiring no external dependencies. Includes a purely recursive implementation, as well as both top-down and bottom-up dynamic programming approaches. ''' import sys def held_karp_recursive(distance_matrix): ''' Soluti...
normal
{ "blob_id": "3e8fa71c4e23348c6f00fe97729b5717bb6245a1", "index": 8070, "step-1": "<mask token>\n\n\ndef held_karp_bottomup(distance_matrix):\n \"\"\"\n In the bottom up implementation, we compute all possible solutions for the\n values `i` and `visited` as in the implementations above, and then\n sim...
[ 5, 8, 9, 10, 12 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> for coluna in range(0, n_colunas): if tabela[0][coluna] < menor_valor: menor_valor = tabela[0][coluna] menor_posicao = coluna <|reserved_special_token_0|> while menor_posicao != -1: solucao_dividida.clear()...
flexible
{ "blob_id": "785dcaf7de68174d84af3459cde02927bc2e10cc", "index": 8951, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor coluna in range(0, n_colunas):\n if tabela[0][coluna] < menor_valor:\n menor_valor = tabela[0][coluna]\n menor_posicao = coluna\n<mask token>\nwhile menor_posicao != ...
[ 0, 1, 2, 3 ]
<|reserved_special_token_0|> def loadConfiguration(fileloc): """Loads configuration from file location""" global config with open(fileloc, 'r') as file_: conf = load(file_) if config is None: config = conf else: config.update(conf) def get(key): """Gets the configurat...
flexible
{ "blob_id": "5261ae90a67e2df8dd1c679a8046ee3e0cbc6221", "index": 3264, "step-1": "<mask token>\n\n\ndef loadConfiguration(fileloc):\n \"\"\"Loads configuration from file location\"\"\"\n global config\n with open(fileloc, 'r') as file_:\n conf = load(file_)\n if config is None:\n config...
[ 2, 3, 4, 5, 6 ]
from turtle import * from shapes import * #1- #1.triangle def eTriangle(): forward(100) right(120) forward(100) right(120) forward(100) right(120) mainloop() #2.square def square(): forward(100) right(90) forward(100) right(90) forward(100) right(90) forwa...
normal
{ "blob_id": "92d689e5caa2d8c65f86af0f8b49b009d162a783", "index": 7379, "step-1": "<mask token>\n\n\ndef square():\n forward(100)\n right(90)\n forward(100)\n right(90)\n forward(100)\n right(90)\n forward(100)\n mainloop()\n\n\ndef pentagon():\n forward(100)\n right(72)\n forward...
[ 8, 10, 12, 14, 20 ]
#!/usr/bin/env python import vtk from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() # Create the RenderWindow, Renderer and both Actors # ren1 = vtk.vtkRenderer() ren2 = vtk.vtkRenderer() renWin = vtk.vtkRenderWindow() renWin.SetMultiSamples(0) renWin.AddRenderer(ren1) renWin.AddRenderer(ren2) i...
normal
{ "blob_id": "7399612f64eb8e500bc676e6d507be5fe375f40f", "index": 3746, "step-1": "<mask token>\n", "step-2": "<mask token>\nrenWin.SetMultiSamples(0)\nrenWin.AddRenderer(ren1)\nrenWin.AddRenderer(ren2)\n<mask token>\niren.SetRenderWindow(renWin)\n<mask token>\npl3d.SetXYZFileName('' + str(VTK_DATA_ROOT) + '/Da...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> class Ui_Login(QtWidgets.QDialog): def __init__(self): super(Ui_Login, self).__init__() uic.loadUi('login.ui', self) self.icon = self.findChild(QtWidgets.QLabel, 'ilogin') self.icon.setStyleSheet('image: url(sorce/roundicon.png)') self.inputUse...
flexible
{ "blob_id": "0ff6e22f8704a0c6c0ffff3c53761b9d3a531b6d", "index": 683, "step-1": "<mask token>\n\n\nclass Ui_Login(QtWidgets.QDialog):\n\n def __init__(self):\n super(Ui_Login, self).__init__()\n uic.loadUi('login.ui', self)\n self.icon = self.findChild(QtWidgets.QLabel, 'ilogin')\n ...
[ 5, 7, 8, 9, 10 ]
# Copyright 2016-2021 Swiss National Supercomputing Centre (CSCS/ETH Zurich) # ReFrame Project Developers. See the top-level LICENSE file for details. # # SPDX-License-Identifier: BSD-3-Clause # # Meta-class for creating regression tests. # import reframe.core.namespaces as namespaces import reframe.core.parameters ...
normal
{ "blob_id": "e754a24fc9c965c50f7fa12036c884a1a54cc29d", "index": 6853, "step-1": "<mask token>\n\n\nclass RegressionTestMeta(type):\n\n\n class MetaNamespace(namespaces.LocalNamespace):\n \"\"\"Custom namespace to control the cls attribute assignment.\n\n Regular Python class attributes can be o...
[ 2, 4, 6, 8, 10 ]
from marshmallow import ValidationError from werkzeug.exceptions import HTTPException from flask_jwt_extended.exceptions import JWTExtendedException from memedata.util import mk_errors from memedata import config def jwt_error_handler(error): code = 401 messages = list(getattr(error, 'args', [])) return m...
normal
{ "blob_id": "e1da3255668999c3b77aa8c9332b197a9203478e", "index": 8992, "step-1": "<mask token>\n\n\ndef jwt_error_handler(error):\n code = 401\n messages = list(getattr(error, 'args', []))\n return mk_errors(code, messages)\n\n\n<mask token>\n\n\ndef validation_error_handler(error):\n code = getattr(...
[ 4, 5, 6, 7 ]
from math import sqrt, ceil def encode_s(s): encoded_s = '' s_with_no_spaces = s.replace(' ', '') step = ceil(sqrt(len(s_with_no_spaces))) for j in range(0, step): i = j while i < len(s_with_no_spaces): encoded_s = encoded_s + s_with_no_spaces[i] i += step ...
normal
{ "blob_id": "a3ed47c285b26dca452fa192eb354a21a78b8424", "index": 4632, "step-1": "<mask token>\n\n\ndef TheRabbitsFoot(s, encode):\n if encode:\n return encode_s(s)\n return decode_s(s)\n", "step-2": "<mask token>\n\n\ndef decode_s(s):\n arr = s.split(' ')\n decoded_s = ''\n for j in rang...
[ 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> def test_classify_source_files() ->None: scalatest_files = {'foo/bar/BazSpec.scala'} junit_files = {'foo/bar/BazTest.scala'} lib_files = {'foo/bar/Baz.scala'} assert {ScalatestTestsGeneratorTarget: scalatest_file...
flexible
{ "blob_id": "42d2d8717ec2c25a99302e8de3090d600f8e80ff", "index": 674, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_classify_source_files() ->None:\n scalatest_files = {'foo/bar/BazSpec.scala'}\n junit_files = {'foo/bar/BazTest.scala'}\n lib_files = {'foo/bar/Baz.scala'}\n asser...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python """ Load API client for a Tool Registry Service (TRS) endpoint based either on the GA4GH specification or an existing client library. """ import logging from bravado.requests_client import RequestsClient from ga4ghtest.core.config import trs_config from .client import TRSClient logger = logging...
normal
{ "blob_id": "d122267e1da2d9cf68d245148bb496dfba3e7d19", "index": 4467, "step-1": "<mask token>\n\n\nclass TRSInterface:\n\n def toolsGet(self):\n raise NotImplementedError\n\n def metadataGet(self):\n raise NotImplementedError\n <mask token>\n <mask token>\n <mask token>\n <mask t...
[ 18, 21, 24, 27, 30 ]
# (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative works of this code must retain this...
normal
{ "blob_id": "2e2de50a7d366ca1a98d29b33ed157a1e8445ada", "index": 3523, "step-1": "<mask token>\n\n\ndef git_short_hash():\n try:\n git_str = '+' + os.popen('git log -1 --format=\"%h\"').read().strip()\n except:\n git_str = ''\n else:\n if git_str == '+':\n git_str = ''\n ...
[ 2, 3, 4, 5, 6 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> @app.task def add(x, y): return x + y <|reserved_special_token_1|> <|reserved_special_token_0|> app = Celery('tasks', broker='redis://localhost') @app.task def add(x, y): return x + y <|reserved_special_token_1|> ...
flexible
{ "blob_id": "3ef114dd35ef3995ae73bf85bbe38db4fb7045d8", "index": 7315, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.task\ndef add(x, y):\n return x + y\n", "step-3": "<mask token>\napp = Celery('tasks', broker='redis://localhost')\n\n\n@app.task\ndef add(x, y):\n return x + y\n", "st...
[ 0, 1, 2, 3, 4 ]
#%% # -*- coding: utf-8 -*- import numpy as np import plotly from plotly.subplots import make_subplots import plotly.graph_objects as go import pandas as pd import os output_directory = r'C:/Users/jgamm/Desktop/rssi_measurement/2020-06-10/figures' antennas = ['original_whip'] folder = r'C:/Users/jgamm/Desktop/rssi_me...
normal
{ "blob_id": "3d3b9956a98f11a170d66280abe7f193cef9ccfb", "index": 808, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i_angle in np.arange(0, 360, 45):\n ri_filenames.append('r%di%d.csv' % (i_angle, i_angle))\n ri_filenames.append('r%di%d.csv' % (i_angle + 45, i_angle))\nri_filenames.append('r36...
[ 0, 1, 2, 3, 4 ]
<|reserved_special_token_0|> <|reserved_special_token_1|> <|reserved_special_token_0|> class Acoount(models.Model): <|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": "18c2fe40b51ad1489d55aa2be068a1c4f381a2a5", "index": 553, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Acoount(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name = 'А...
[ 0, 1, 2, 4, 5 ]