code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
""" Forms and validation code for user registration. Note that all of these forms assume your user model is similar in structure to Django's default User class. If your user model is significantly different, you may need to write your own form class; see the documentation for notes on custom user models with django-re...
normal
{ "blob_id": "3b959481f7c818ec35b8af174b1982954b4c72eb", "index": 1208, "step-1": "<mask token>\n\n\nclass RegistrationFormCaseInsensitive(RegistrationForm):\n <mask token>\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self.fields[User.USERNAME_FIELD].validator...
[ 8, 12, 14, 15, 16 ]
import os import math def get_datas(): filename = None while True: filename = input('Please enter filename:') if not filename.strip(): print('Filename is empty!') continue if not os.path.exists(filename): print('File is not exists!') conti...
normal
{ "blob_id": "6829f7bcbc1b12500795eec19829ff077502e270", "index": 3260, "step-1": "<mask token>\n\n\ndef get_datas():\n filename = None\n while True:\n filename = input('Please enter filename:')\n if not filename.strip():\n print('Filename is empty!')\n continue\n ...
[ 6, 7, 8, 10, 12 ]
from matplotlib import pyplot as plt dev_x = [25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35] dev_y = [4000, 45000, 50000, 55000, 60000, 56000, 62316, 64928, 67317, 68748, 73752] plt.plot(dev_x, dev_y, label='All Devs') #dev_x and dev_y are respectively x-axis and y-axis # Median Python Developer Salari...
normal
{ "blob_id": "796a13de72c2879956c5f9c9c9bdef7253760c9d", "index": 9895, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.plot(dev_x, dev_y, label='All Devs')\n<mask token>\nplt.plot(dev_x, py_dev_y, label='Python')\nplt.xlabel('Ages')\nplt.ylabel('Median Salary')\nplt.title('Median Salary (USD) by Age')...
[ 0, 1, 2, 3, 4 ]
import asyncio def callback(): print('callback invoked') def stopper(loop): print('stopper invoked') loop.stop() event_loop = asyncio.get_event_loop() try: print('registering callbacks') # the callbacks are invoked in the order they are scheduled event_loop.call_soon(callback) event_loop....
normal
{ "blob_id": "3b96cc4ef538a06251958495e36fe5dbdf80c13d", "index": 4952, "step-1": "<mask token>\n\n\ndef callback():\n print('callback invoked')\n\n\ndef stopper(loop):\n print('stopper invoked')\n loop.stop()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef callback():\n print('callback invok...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/python3 """City Module""" from models.base_model import BaseModel class City(BaseModel): """City Class Public class attributes: state_d: type string name: type string """ state_id = "" name = ""
normal
{ "blob_id": "3f2c1a83ae0dfdba202038a209b90162ccddee36", "index": 6115, "step-1": "<mask token>\n\n\nclass City(BaseModel):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass City(BaseModel):\n <mask token>\n state_id = ''\n name = ''\n", "step-3": "<mask tok...
[ 1, 2, 3, 4, 5 ]
from django.contrib import admin # Register your models here. from blog.models import Post,Category,Profile admin.site.register(Profile) admin.site.register(Category) admin.site.register(Post)
normal
{ "blob_id": "20f0de097fdd8f2a435c06a73c6a90cc7ebc69ad", "index": 4014, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Profile)\nadmin.site.register(Category)\nadmin.site.register(Post)\n", "step-3": "from django.contrib import admin\nfrom blog.models import Post, Category, Profile\n...
[ 0, 1, 2, 3 ]
# Constructor without arguments class Demo: def __init__(self): print("\nThis is constructor") obj = Demo() # Constructor with arguments class Demo2: def __init__(self, number1, number2): sumOfNumbers = number1 + number2 print(sumOfNumbers) obj2 = Demo2(50,75...
normal
{ "blob_id": "b005f4657a1036044c2e6051207641fe621eb17e", "index": 8861, "step-1": "<mask token>\n\n\nclass Demo2:\n\n def __init__(self, number1, number2):\n sumOfNumbers = number1 + number2\n print(sumOfNumbers)\n\n\n<mask token>\n", "step-2": "class Demo:\n <mask token>\n\n\n<mask token>\n...
[ 2, 3, 4, 5, 6 ]
from flask import abort from flask_restx import Resource, Namespace, Model, fields, reqparse from infraestructura.lineas_repo import LineasRepo from infraestructura.equipos_repo import EquiposRepo from infraestructura.clientes_lep_repo import ClientesLepRepo from infraestructura.lineaequipoplan_repo import LineaEquipoP...
normal
{ "blob_id": "821e89730fde2e12b24b52b04701c1f3501e0d57", "index": 8771, "step-1": "<mask token>\n\n\n@nsLinea.route('/<int:id>')\nclass LineasResource(Resource):\n <mask token>\n <mask token>\n\n\n@nsLinea.route('/baja/<int:id>')\nclass LineasResource(Resource):\n\n def put(self, id):\n if repo.ba...
[ 3, 7, 8, 9, 12 ]
## SOLVED ## the possible way of solving this is to make a scoring of the hand ## of each player, by encoding the category of winning and the cards import csv value = ['2','3','4','5','6','7','8','9','T','J','Q','K','A'] val_order = {k:v for v,k in enumerate(value)} def compute(): poker_hand = load_data() ans...
normal
{ "blob_id": "480e595c54da7426951d750187712fecdcb6d8c7", "index": 9081, "step-1": "<mask token>\n\n\ndef compute():\n poker_hand = load_data()\n ans = sum(1 for x in poker_hand if p1_wins(x))\n return ans\n\n\ndef p1_wins(hands):\n p1 = [(a[0], a[1]) for a in hands[:5]]\n p2 = [(a[0], a[1]) for a i...
[ 6, 7, 8, 9, 11 ]
import pygame import sys # класс для хранения настроек class Settings(): """docstring for Setting""" def __init__(self): # параметры экрана self.colour = (230, 230, 230) self.screen_width = 1200 self.screen_height = 800 # параметры коробля self.ship_speed = 1.5 # параметры пули self.bullet_speed = ...
normal
{ "blob_id": "2402188380bc0189b88e3cfcbaabf64a9919b3d5", "index": 8810, "step-1": "<mask token>\n\n\nclass Settings:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Settings:\n <mask token>\n\n def __init__(self):\n self.colour = 230, 230, 230\n self.screen_width =...
[ 1, 2, 3, 4, 5 ]
from django.urls import path from .views import PostListView, PostDetailView urlpatterns = [ path('blog/', PostListView.as_view()), path('blog/<pk>/', PostDetailView.as_view()), ]
normal
{ "blob_id": "be7fb94c3c423b67aa917a34328acda5926cf78a", "index": 3133, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('blog/', PostListView.as_view()), path('blog/<pk>/',\n PostDetailView.as_view())]\n", "step-3": "from django.urls import path\nfrom .views import PostListView, Po...
[ 0, 1, 2, 3 ]
from collections import deque for case in xrange(input()): cards = input() indexes = map(int, raw_input().split()) deck = [0 for i in xrange(cards)] index = -1 for i in xrange(1, cards + 1): while True: index = (index + 1)%cards if deck[index] == 0: break for j in xrange(i - 1): ...
normal
{ "blob_id": "c7ecf8ada74b3e401c2144457d4fa1050f598727", "index": 8787, "step-1": "from collections import deque\n\nfor case in xrange(input()):\n cards = input()\n indexes = map(int, raw_input().split())\n\n deck = [0 for i in xrange(cards)]\n index = -1\n for i in xrange(1, cards + 1):\n while True:\n ...
[ 0 ]
# -*- coding: utf-8 -*- ################################################## # GNU Radio Python Flow Graph # Title: channel # Author: Maria Camila Herrera Ramos # Generated: Thu Aug 2 18:09:17 2018 ################################################## from gnuradio import analog from gnuradio import blocks from gnuradio ...
normal
{ "blob_id": "8adf25fbffc14d6927d665931e54a7d699a3b439", "index": 6202, "step-1": "<mask token>\n\n\nclass channel(gr.hier_block2):\n <mask token>\n <mask token>\n\n def set_k(self, k):\n self.k = k\n self.channels_fading_model_0.set_K(self.k)\n\n def get_tchannel(self):\n return ...
[ 5, 6, 7, 8, 10 ]
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 django.test import TestCase from django.urls import reverse from django.utils import timezone from recensioni_site import settings from django.contrib.auth.models import User from forum.models import Sezione,Post,UserDataReccomandation class testRegistrazione(TestCase): def setUp(self): self.credent...
normal
{ "blob_id": "cf9339659f49b4093c07e3723a2ede1543be41b8", "index": 4900, "step-1": "<mask token>\n\n\nclass testRegistrazione(TestCase):\n <mask token>\n\n def tearDown(self):\n self.proprietario1.delete()\n self.proprietario2.delete()\n self.user1.delete()\n self.user2.delete()\n...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Apr 2 13:34:19 2020 @author: ShihaoYang """ from pyltp import SentenceSplitter from pyltp import Segmentor from pyltp import Postagger from pyltp import Parser from pyltp import NamedEntityRecognizer import os import jieba import re os.getcwd() os.ch...
normal
{ "blob_id": "dc41c64d09e5fdd0e234f516eeec0cbd2433876c", "index": 8507, "step-1": "<mask token>\n\n\nclass Sentence(object):\n\n def __init__(self, text):\n self.text = text\n self.data = dict()\n\n def SentS(self):\n sents = SentenceSplitter.split(self.text)\n return sents\n\n ...
[ 9, 11, 12, 14, 16 ]
from Receiver import Receiver import time import Image class Sender: ACK = [] size = None windowSize = None tableOfFrames = [] ChosenSumAlgorithm = None def __init__(self, receiver): self.receiver = receiver pass def send_frame(self, frame): self.receiver.receiver_...
normal
{ "blob_id": "ecbcd023b8fec5763c6ff7f4cd0999426fae4a50", "index": 9093, "step-1": "<mask token>\n\n\nclass Sender:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def send_frame(self, frame):\n self.receiver.receiver_frame(frame)\n p...
[ 5, 7, 8, 10, 11 ]
#!/use/bin/python import os, sys from io import BytesIO from pathlib import Path from flask_config import app from flask import send_file from PyPDF2 import PdfFileReader, PdfFileWriter def rotate_pdf(working_dir, filename, rotation): os.chdir(working_dir) output_name = 'pages' rotate_pdf_pages(filename, rotati...
normal
{ "blob_id": "624027373f53f62ededc40bfc859f28b5a83ca04", "index": 3266, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef rotate_pdf_pages(filename, rotation, output_name):\n pdf_reader = PdfFileReader('{}.pdf'.format(filename))\n pdf_writer = PdfFileWriter()\n for page in range(pdf_reader.g...
[ 0, 1, 2, 3, 4 ]
def assert_shapes(shape, other): assert len(shape) == len(other), "Dimensions are different" for s, o in zip(shape, other): if s is not None and o is not None: assert s == o, "Shapes {} and {} are not equal".format(shape, other)
normal
{ "blob_id": "337311c3fbb6a8baab7a237d08152f0db9822527", "index": 2931, "step-1": "<mask token>\n", "step-2": "def assert_shapes(shape, other):\n assert len(shape) == len(other), 'Dimensions are different'\n for s, o in zip(shape, other):\n if s is not None and o is not None:\n assert s ...
[ 0, 1, 2 ]
import netCDF4 as nc import numpy as np import os def RangeExtender(filename,directory): fileNC=nc.Dataset(directory+filename,'r') nu=fileNC['nu'][:] filename,ext=os.path.splitext(filename) fileOut=nc.Dataset(directory+filename+"_50000cm-1.nc",'w') nu_orig_length=len(nu) step=abs(nu[1]...
normal
{ "blob_id": "f3527185117fd7205f55f47f2f08448a7d7b0100", "index": 8143, "step-1": "<mask token>\n\n\ndef RangeExtender(filename, directory):\n fileNC = nc.Dataset(directory + filename, 'r')\n nu = fileNC['nu'][:]\n filename, ext = os.path.splitext(filename)\n fileOut = nc.Dataset(directory + filename ...
[ 1, 2, 3, 4, 5 ]
import cv2 import numpy as np if __name__ == "__main__": cap = cv2.VideoCapture() while True: ret, frame = cap.read() cv2.imshow(frame)
normal
{ "blob_id": "14f309d478de6de5a0b493503176941fdfa8b702", "index": 110, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n cap = cv2.VideoCapture()\n while True:\n ret, frame = cap.read()\n cv2.imshow(frame)\n", "step-3": "import cv2\nimport numpy as np\nif __...
[ 0, 1, 2, 3 ]
# animation2.py # multiple-shot cannonball animation from math import sqrt, sin, cos, radians, degrees from graphics import * from projectile import Projectile from button import Button class Launcher: def __init__(self, win): """Create inital launcher with angle 45 degrees and velocity 40 win i...
normal
{ "blob_id": "09aedd6cab0b8c6a05bbee5b336fcd38aea1f7b9", "index": 3202, "step-1": "<mask token>\n\n\nclass Launcher:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass ShotTracker:\n \"\"\" Graphical depiction of a projectile flight using a Circle \"\"\"\n\n ...
[ 12, 14, 15, 17, 20 ]
#This is a module which implements Naive Set Theory in Python. #It will be useful for Unions, Intersections, Mutual Exclusion, and more. #ideas: print(sum([[[1],[2]], [[3],[4]], [[5],[6]]], [])) Monoid - abstraction on + trial = [1, 2, 3] trial2 = [3, 4, 5] def recursiveUnioniser(set): if isinstance(set[0], int)...
normal
{ "blob_id": "c632c50028fee2f19fb65458f0b55ec228b8006f", "index": 2137, "step-1": "<mask token>\n\n\ndef intersection(set_a, set_b):\n res = [i for i in set_a if i in set_b]\n return res\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef recursiveUnioniser(set):\n if isinstance(set[0], int):\n ...
[ 1, 4, 5, 6, 7 ]
from ._sinAction import * from ._sinActionFeedback import * from ._sinActionGoal import * from ._sinActionResult import * from ._sinFeedback import * from ._sinGoal import * from ._sinResult import *
normal
{ "blob_id": "c6b261a09b2982e17704f847586bbf38d27cb786", "index": 353, "step-1": "<mask token>\n", "step-2": "from ._sinAction import *\nfrom ._sinActionFeedback import *\nfrom ._sinActionGoal import *\nfrom ._sinActionResult import *\nfrom ._sinFeedback import *\nfrom ._sinGoal import *\nfrom ._sinResult impor...
[ 0, 1 ]
import math def sieve(n): sieve = [1] * (n+1) sieve[1] = 0 sieve[0] = 0 for i in range(2, int(math.sqrt(n) + 1)): if sieve[i] == 1: for j in range(i*i, n + 1, i): sieve[j] = 0 return sieve def odd_prime(a): while a != 0: y = a % 10 if y == 3 ...
normal
{ "blob_id": "60617ff6eda880e5467b3b79d3df13a7147f5990", "index": 3329, "step-1": "<mask token>\n\n\ndef sieve(n):\n sieve = [1] * (n + 1)\n sieve[1] = 0\n sieve[0] = 0\n for i in range(2, int(math.sqrt(n) + 1)):\n if sieve[i] == 1:\n for j in range(i * i, n + 1, i):\n ...
[ 2, 3, 4, 5, 6 ]
''' Copyright (c) 2021, Štěpán Beneš The purpose of this script it to take the 5 BSE and 5 SE hand-picked prototype images and turn them into the same shape and format as the rest of the data. Prototype images are resized to 768x768, the info bar is cropped off. Afterwards the images are normalized to float32 in ran...
normal
{ "blob_id": "af7af5d1048d2b0968e831aad89d5baf30cab608", "index": 3210, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(proto_images_se_list.shape)\nprint(proto_images_bse_list.shape)\nnp.save('Data/SE_prototypes.npy', proto_images_se_list)\nnp.save('Data/BSE_prototypes.npy', proto_images_bse_list)\n...
[ 0, 1, 2, 3, 4 ]
from django.apps import AppConfig class AttendaceConfig(AppConfig): name = 'attendace'
normal
{ "blob_id": "d5d61b23dc14ffdfe7fe6f983164916863928eaf", "index": 3685, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AttendaceConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AttendaceConfig(AppConfig):\n name = 'attendace'\n", "step-4": "from django.apps impo...
[ 0, 1, 2, 3 ]
# import the necessary packages from .pigear import PiGear from .camgear import CamGear from .videogear import VideoGear __all__ = ["PiGear", "CamGear", "VideoGear"]
normal
{ "blob_id": "3431e342c940b0d91f817c3e583728e55e305210", "index": 8940, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['PiGear', 'CamGear', 'VideoGear']\n", "step-3": "from .pigear import PiGear\nfrom .camgear import CamGear\nfrom .videogear import VideoGear\n__all__ = ['PiGear', 'CamGear', '...
[ 0, 1, 2, 3 ]
import numpy import yfinance as yf import pandas as pd import path import math pd.options.mode.chained_assignment = None # default='warn' all_tickers = ['2020.OL', 'ABG.OL', 'ADE.OL', 'AFG.OL', 'AKAST.OL', 'AKER.OL', 'AKBM.OL', ...
normal
{ "blob_id": "22ffda3b2d84218af22bad7835689ec3d4959ab2", "index": 3660, "step-1": "<mask token>\n\n\ndef calculate_returns(ticker_data):\n returns_list = list()\n previous_ticker_day = None\n for ticker_day in ticker_data.itertuples():\n if previous_ticker_day == None:\n returns_list.ap...
[ 6, 8, 9, 10, 11 ]
num_str = "1" num_str1 = "\u00b2" num_str2 = "一千零一" # 判断字符串是否只包含数字 # 1.三种方法都不能判断小数 # 2.isdigit 和 isnumeric 比 isdecimal 强大一些,后者只能判断正常数字,前两者可以判断带有数字的符号,如平方 # isnumeric 还可以判断中文数字 print(num_str) print(num_str1) print(num_str.isdecimal()) print(num_str1.isdecimal()) print(num_str.isdigit()) print(num_str1.isdigit()) print(n...
normal
{ "blob_id": "a7be2f43c6ec8d1576ed194a75762a36089cb052", "index": 4195, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(num_str)\nprint(num_str1)\nprint(num_str.isdecimal())\nprint(num_str1.isdecimal())\nprint(num_str.isdigit())\nprint(num_str1.isdigit())\nprint(num_str.isnumeric())\nprint(num_str1.i...
[ 0, 1, 2, 3 ]
"""to get the all the module and its location""" import sys print(sys.modules)
normal
{ "blob_id": "20637e41df8a33e3837905a4729ae0b4a9f94dbb", "index": 3128, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(sys.modules)\n", "step-3": "<mask token>\nimport sys\nprint(sys.modules)\n", "step-4": "\"\"\"to get the all the module and its location\"\"\"\r\nimport sys\r\nprint(sys.modules...
[ 0, 1, 2, 3 ]
from datetime import datetime from app.commands import backfill_performance_platform_totals, backfill_processing_time # This test assumes the local timezone is EST def test_backfill_processing_time_works_for_correct_dates(mocker, notify_api): send_mock = mocker.patch("app.commands.send_processing_time_for_start_...
normal
{ "blob_id": "fcb1285648f6728e3dad31ad4b602fa4e5c5b422", "index": 9230, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_backfill_totals_works_for_correct_dates(mocker, notify_api):\n send_mock = mocker.patch(\n 'app.commands.send_total_sent_notifications_to_performance_platform')\n ...
[ 0, 1, 2, 3, 4 ]
# coding: utf-8 """Supporting model logic for predicting emotional content of user input. """ import pandas as pd import gensim from sklearn.model_selection import train_test_split from sklearn.multiclass import OneVsRestClassifier from sklearn.svm import LinearSVC #load data for emo2vec loc = 'https://s3-us-west-1.a...
normal
{ "blob_id": "f5f26819be4b98fab3d46e57e1a5431e54342aed", "index": 414, "step-1": "<mask token>\n\n\ndef dropper():\n for ex in affected['word']:\n if ex not in model.vocab:\n idx_to_drop.append(affected.loc[affected.word == ex].index[0])\n\n\n<mask token>\n", "step-2": "<mask token>\nprint(...
[ 1, 2, 3, 4, 5 ]
def get_all_lefts(word,substring): if len(substring) == 0: yield ((len(word),word),) else: if substring[0] not in word: yield (-1,) else: for i in range(len(word)): if word[i] == substring[0]: for sub_sequance in get_all_lefts(w...
normal
{ "blob_id": "8c0377b70b902e6e61351869a4378b4c2c50a3a7", "index": 2478, "step-1": "<mask token>\n", "step-2": "def get_all_lefts(word, substring):\n if len(substring) == 0:\n yield (len(word), word),\n elif substring[0] not in word:\n yield -1,\n else:\n for i in range(len(word)):\...
[ 0, 1, 2, 3 ]
from django.db import models # Create your models here. class Orders(models.Model): customer_name = models.CharField(max_length=80) customer_email = models.CharField(max_length=120) customer_mobile = models.CharField(max_length=40) status = models.CharField(max_length=20) process_url = models.Cha...
normal
{ "blob_id": "bc7a7b9ba4b3277c862aadb57b56661c24efc6e5", "index": 5577, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Orders(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", "step...
[ 0, 1, 2, 3, 4 ]
import numpy as np import math import datetime def multi_strassen(A,B, check_ig = True, check_quad = True, check_pot = True, check_time = True): def Strassen(matriz_1,matriz_2): # Função do algoritmo de Strassen para multiplicação de matrizes do tipo 2x2 if (matriz_1.shape[0] != 2) or (matriz_1.shape[...
normal
{ "blob_id": "6707723b3d0b42271e49c08c639afc9103066dc7", "index": 4679, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef multi_strassen(A, B, check_ig=True, check_quad=True, check_pot=True,\n check_time=True):\n\n def Strassen(matriz_1, matriz_2):\n if matriz_1.shape[0] != 2 or matriz_1...
[ 0, 1, 2, 3 ]
class person(object): population = 50 def __init__(self, name, age): self.name = name self.age = age @classmethod def getpopulation(cls): return cls.population @staticmethod def isadult(age=17): return age >= 18 def display(self): print(self.name, ...
normal
{ "blob_id": "a21942a835f7b2ea70e9dd7b26285ea2dd411750", "index": 1205, "step-1": "class person(object):\n <mask token>\n\n def __init__(self, name, age):\n self.name = name\n self.age = age\n\n @classmethod\n def getpopulation(cls):\n return cls.population\n\n @staticmethod\n ...
[ 5, 6, 7, 8 ]
import pytest import os import pandas as pd import numpy as np import math import scipy from scipy import stats from sklearn import metrics, linear_model from gpmodel import gpkernel from gpmodel import gpmodel from gpmodel import gpmean from gpmodel import chimera_tools n = 200 d = 10 X = np.random.random(size=(n, ...
normal
{ "blob_id": "62c28b5eb31b90191dfbab4456fc5373ba51bf64", "index": 8869, "step-1": "<mask token>\n\n\ndef test_normalize():\n model = gpmodel.GPRegressor(kernel)\n m, s, normed = model._normalize(Y)\n assert np.isclose(m, Y.mean())\n assert np.isclose(s, Y.std())\n assert np.allclose(normed, (Y - m)...
[ 6, 7, 8, 9, 11 ]
import os import time import torch from torch.utils.data import DataLoader from torchvision.datasets import SVHN from torchvision.transforms import ToTensor from lib.utils import Logger, normal_logpdf, sumflat, print_model_info, tanh_to_uint8, get_optimizer from lib.vae import VAE def train(hp): os.makedirs(hp.o...
normal
{ "blob_id": "43db8ed10face1c668aeadd3cbc5b13f87fb0126", "index": 4997, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef train(hp):\n os.makedirs(hp.out_dir, exist_ok=True)\n device = torch.device('cuda' if hp.use_cuda else 'cpu')\n dataset = SVHN(root='svhn', split='train', download=True, ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from celery import Celery app = Celery('task', include=['task.tasks']) app.config_from_object('task.config') if __name__ == '__main__': app.start()
normal
{ "blob_id": "68d9f77f91a13c73373c323ef0edbe18af9990a3", "index": 4321, "step-1": "<mask token>\n", "step-2": "<mask token>\napp.config_from_object('task.config')\nif __name__ == '__main__':\n app.start()\n", "step-3": "<mask token>\napp = Celery('task', include=['task.tasks'])\napp.config_from_object('tas...
[ 0, 1, 2, 3, 4 ]
from abc import ABC, abstractmethod from datetime import datetime, timedelta, date import os import housekeeper import yfinance as yf import pandas as pd class DataManager(ABC): def __init__(self): self.__myHousekeeper = housekeeper.instance_class() self.__config_filename = "tickers...
normal
{ "blob_id": "e77e0791ddf211807566528e9532eebb54db43b5", "index": 5550, "step-1": "<mask token>\n\n\nclass DataManager(ABC):\n\n def __init__(self):\n self.__myHousekeeper = housekeeper.instance_class()\n self.__config_filename = 'tickers_config.json'\n self.__dir_list = ['Data', 'Tickers'...
[ 30, 34, 35, 40, 41 ]
from pathlib import Path import eyed3 import csv import sys import filetype import os pathFile = Path( 'C:\\Users\\JORGE\\Music\\Vicente Garcia - Te Soñé (Lyric Video)(MP3_160K).mp3' ) audiofile = eyed3.load(pathFile) with open('loveMusic.csv', 'w', newline='') as csvFile: fieldsName = ['nameFile', 'tittle...
normal
{ "blob_id": "629649abe9d855122a5db6d61a20735ceb89c5cf", "index": 6426, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('loveMusic.csv', 'w', newline='') as csvFile:\n fieldsName = ['nameFile', 'tittle', 'artist', 'gender', 'path']\n writer = csv.DictWriter(csvFile, fieldnames=fieldsName)\n...
[ 0, 1, 2, 3 ]
from RestClient4py.client import RestClient from API_Wrap import util import os import json kakao_native_app_key, kakao_rest_api_key, kakao_javascript_key, kakao_admin_key = util.kakao_auth() client = RestClient() client.set_header("Authorization", "KakaoAK {}".format(kakao_rest_api_key)) client.set_header("Accept", ...
normal
{ "blob_id": "7f58179efecd5a0d691a5c6d83b808f2cd2fcba3", "index": 5332, "step-1": "<mask token>\n\n\ndef translation(query, src_lang, target_lang):\n if type(query) != str:\n raise AttributeError('[ERROR] query parameter should be string type')\n elif len(query) > 5000:\n raise AttributeError(...
[ 1, 2, 3, 4, 5 ]
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def getIntersectionNode(self, headA, headB): """ :type head1, head1: ListNode :rtype: ListNode """ if not hea...
normal
{ "blob_id": "66f60eb86137203a74656be13b631384eba30c84", "index": 1681, "step-1": "class Solution(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Solution(object):\n\n def getIntersectionNode(self, headA, headB):\n \"\"\"\n :type head1, head1: ListNode\n ...
[ 1, 2, 3, 4, 5 ]
# This source code is part of the Biotite package and is distributed # under the 3-Clause BSD License. Please see 'LICENSE.rst' for further # information. import warnings from tempfile import TemporaryFile import glob from os.path import join import pytest import numpy as np import biotite.structure as struc import bi...
normal
{ "blob_id": "cc637d14ce2106fcc3b8bbb54e497691e72a3f65", "index": 2858, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.mark.parametrize('path', glob.glob(join(data_dir('structure'),\n '*.cif')))\ndef test_array_conversion(path):\n pdbx_file = pdbx.PDBxFile.read(path)\n ref_structure =...
[ 0, 1, 2, 3 ]
from django.contrib.auth.models import BaseUserManager class MyUserManager(BaseUserManager): def create_user(self, email, password, full_name, national_code, mobile, address): if not email : raise ValueError('ایمیل الزامی است') if not full_name : raise ValueError('نام و نام...
normal
{ "blob_id": "f5f14e4d114855b7eef555db182ee991bdf26c39", "index": 8832, "step-1": "<mask token>\n\n\nclass MyUserManager(BaseUserManager):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass MyUserManager(BaseUserManager):\n <mask token>\n\n def create_superuser(self, email, passwor...
[ 1, 2, 3, 4, 5 ]
from microbit import * import music while True: if button_a.is_pressed(): music.pitch(400, 500)
normal
{ "blob_id": "356c817e254d8885beb447aa10759fff6a45ca25", "index": 9454, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n if button_a.is_pressed():\n music.pitch(400, 500)\n", "step-3": "from microbit import *\nimport music\nwhile True:\n if button_a.is_pressed():\n music....
[ 0, 1, 2 ]
from .base import * RAVEN_CONFIG = {} ALLOWED_HOSTS = ['*']
normal
{ "blob_id": "eee60a6f46549ededfbc7b0b294ab723e2e73f7e", "index": 4490, "step-1": "<mask token>\n", "step-2": "<mask token>\nRAVEN_CONFIG = {}\nALLOWED_HOSTS = ['*']\n", "step-3": "from .base import *\nRAVEN_CONFIG = {}\nALLOWED_HOSTS = ['*']\n", "step-4": null, "step-5": null, "step-ids": [ 0, ...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.11 on 2018-03-31 17:58 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('words', '0004_auto_20180330_0647'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "e6884afaae15e903c62eecb3baec868548998080", "index": 2106, "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 = [('words', '00...
[ 0, 1, 2, 3, 4 ]
import unittest, warnings from pony.orm import * from pony.orm import core from pony.orm.tests.testutils import raises_exception db = Database('sqlite', ':memory:') class Person(db.Entity): id = PrimaryKey(int) name = Required(str) tel = Optional(str) db.generate_mapping(check_tables=False)...
normal
{ "blob_id": "33c39b098cb9d3368b8f74a7433e0943fe252da5", "index": 5672, "step-1": "<mask token>\n\n\nclass TestValidate(unittest.TestCase):\n\n @db_session\n def setUp(self):\n db.execute('delete from Person')\n registry = getattr(core, '__warningregistry__', {})\n for key in list(regis...
[ 6, 8, 9, 10, 12 ]
#MenuTitle: Find and Replace Corner Components at Certain Angles # -*- coding: utf-8 -*- from __future__ import division, print_function, unicode_literals __doc__=""" Replace Corner Components at blunt or acute angles. """ import vanilla, math from Foundation import NSPoint class ReplaceCornersAtCertainAngles( object...
normal
{ "blob_id": "540ae4be6a41d52d9c803f829fc8b13b523b31bc", "index": 116, "step-1": "<mask token>\n\n\nclass ReplaceCornersAtCertainAngles(object):\n\n def __init__(self):\n windowWidth = 250\n windowHeight = 140\n windowWidthResize = 100\n windowHeightResize = 0\n self.w = vani...
[ 8, 9, 10, 11, 12 ]
import numpy as np import random import sys import canton as ct from canton import * import tensorflow as tf time_steps = 16 def get_text_data(filename): import codecs with open(filename,'rb') as f: text = f.read() length = len(text) print('got corpus length:', length) return text def mod...
normal
{ "blob_id": "0016e38d39ed2a4c7a75bed103bc47a5b6fd0e8c", "index": 2538, "step-1": "<mask token>\n\n\ndef r(ep=100):\n length = len(corpus)\n batch_size = 256\n mbl = time_steps * batch_size\n sr = length - mbl - time_steps - 2\n for i in range(ep):\n print('---------------------iter', i, '/'...
[ 6, 9, 12, 13, 14 ]
#!/usr/bin/env python """ Use version of DriverSlave that has pixmap and pixheights """ import threading # import base classes and driver from bibliopixel import LEDStrip, LEDMatrix # from bibliopixel.drivers.LPD8806 import DriverLPD8806, ChannelOrder from bibliopixel.drivers.visualizer import DriverVisualizer, Channel...
normal
{ "blob_id": "307e7a059f9b0b1131f8a57d0f55cf0ee05173e8", "index": 9822, "step-1": "#!/usr/bin/env python\n\"\"\"\nUse version of DriverSlave that has pixmap and pixheights\n\"\"\"\nimport threading\n# import base classes and driver\nfrom bibliopixel import LEDStrip, LEDMatrix\n# from bibliopixel.drivers.LPD8806 i...
[ 0 ]
questions = ('Какой язык мы учим?', 'Какой тип данных имеет целая переменная?', 'Какой тип данных имеет вещественная переменная?', 'Какой тип данных имеет логическая переменная?', 'Какой тип данных имеет символьная переменная?') answers = ('Python', 'Integer', 'Float', 'Bool', 'String') i = 0 count_answers = 0 while i ...
normal
{ "blob_id": "dd936839d71b97b3a21115498092d8984de0e3f1", "index": 7445, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile i < len(questions):\n user_answers = input('{}...'.format(questions[i]))\n if user_answers.capitalize() == answers[i]:\n count_answers = count_answers + 1\n i += 1\n...
[ 0, 1, 2, 3 ]
import time import pytest from pytest_bdd import scenarios, given, when, then from conf import Constants from page_components.page import PageComponent from page_components.overall import OverallPage # Scenarios scenarios('overall_rating.feature', features_base_dir=Constants.FEATURE_FILES_BASE_DIR) # Fixtures ...
normal
{ "blob_id": "2809ed3a5ea1e527609e169bca1440e0db2761b9", "index": 8408, "step-1": "<mask token>\n\n\n@pytest.fixture\ndef home_page(getBrowser):\n aHome = HomePage(getBrowser)\n return aHome\n\n\n@pytest.fixture\ndef overall_page(getBrowser):\n aOverall = OverallPage(getBrowser)\n return aOverall\n\n\...
[ 14, 15, 17, 18, 19 ]
import time import os from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from app.wechat_subscription.object_page.home_page import HomePage from conf.decorator import teststep, teststeps from conf.base_page import BasePage from selenium.webdriver...
normal
{ "blob_id": "600b49c7884f8b6e3960549702a52deb20089f5a", "index": 3503, "step-1": "<mask token>\n\n\nclass LoginPage(BasePage):\n <mask token>\n\n @teststeps\n def __init__(self):\n self.home = HomePage()\n self.toast = Toast()\n <mask token>\n\n @teststeps\n def wait_check_test1(s...
[ 17, 18, 20, 21, 22 ]
sentence = input() check_list = ["U", "C", "P", "C"] check = True for i in range(len(check_list)): if check_list[i] in sentence: check = True idx = sentence.find(check_list[i]) sentence = sentence[idx+1:] else: check = False break if check == True: print("I love UCP...
normal
{ "blob_id": "4545d9756d1f396ead0b0c75d319fb6a718375cd", "index": 2108, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(check_list)):\n if check_list[i] in sentence:\n check = True\n idx = sentence.find(check_list[i])\n sentence = sentence[idx + 1:]\n else:\n ...
[ 0, 1, 2, 3 ]
from cobra.model.fabric import HIfPol from createMo import * DEFAULT_AUTO_NEGOTIATION = 'on' DEFAULT_SPEED = '10G' DEFAULT_LINK_DEBOUNCE_INTERVAL = 100 AUTO_NEGOTIATION_CHOICES = ['on', 'off'] SPEED_CHOICES = ['100M', '1G', '10G', '40G'] def input_key_args(msg='\nPlease Specify Link Level Policy:'): print msg ...
normal
{ "blob_id": "36ab827b889adcd4d54296e7da432d3b39d5a2e6", "index": 2246, "step-1": "from cobra.model.fabric import HIfPol\n\nfrom createMo import *\n\nDEFAULT_AUTO_NEGOTIATION = 'on'\nDEFAULT_SPEED = '10G'\nDEFAULT_LINK_DEBOUNCE_INTERVAL = 100\n\nAUTO_NEGOTIATION_CHOICES = ['on', 'off']\nSPEED_CHOICES = ['100M', '...
[ 0 ]
from django.db import models class TestModel(models.Model): name = models.CharField(max_length=15) surname = models.CharField(max_length=10) age = models.IntegerField() class Example(models.Model): integer_field = models.IntegerField() positive_field = models.PositiveIntegerField() positive_...
normal
{ "blob_id": "8afce5b47c7c9c67a8be493f7f4de1510352b1c7", "index": 4559, "step-1": "<mask token>\n\n\nclass Place(models.Model):\n name = models.CharField(max_length=50)\n address = models.CharField(max_length=80)\n\n def __str__(self):\n return self.name\n\n\nclass Restaurant(models.Model):\n p...
[ 10, 12, 16, 17, 21 ]
from django.apps import AppConfig class DojoBookAppConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'dojo_book_app'
normal
{ "blob_id": "314f6cc97f53fa5bd8bf0ec0e1e305ca6384f1a2", "index": 1559, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass DojoBookAppConfig(AppConfig):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass DojoBookAppConfig(AppConfig):\n default_auto_field = 'django.db.mod...
[ 0, 1, 2, 3 ]
def multiplica(): one = int(input('1º: ')) two = int(input('2º: ')) print('a multiplicação é: ', one*two) def soma(): one = int(input('1º: ')) two = int(input('2º: ')) print('a soma é: ', one+two) def subtra(): one = int(input('1º: ')) two = int(input('2º: ')) ...
normal
{ "blob_id": "414fa4021b21cea0dc49380aebfe67f0204f0574", "index": 5994, "step-1": "def multiplica():\n one = int(input('1º: '))\n two = int(input('2º: '))\n print('a multiplicação é: ', one * two)\n\n\ndef soma():\n one = int(input('1º: '))\n two = int(input('2º: '))\n print('a soma é: ', one + ...
[ 2, 3, 4, 5, 6 ]
import math import torch from torch import nn from d2l import torch as d2l def masked_softmax(X, valid_lens): """通过在最后一个轴上掩蔽元素来执行softmax操作""" # X:3D张量,valid_lens:1D或2D张量 if valid_lens is None: return nn.functional.softmax(X, dim=-1) else: shape = X.shape if valid_lens.dim() == ...
normal
{ "blob_id": "cda01bc7b0ebcfaf010bb87e7d9be34fd310d7a7", "index": 9626, "step-1": "<mask token>\n\n\nclass AdditiveAttention(nn.Module):\n <mask token>\n\n def __init__(self, key_size, query_size, num_hiddens, dropout, **kwargs):\n super(AdditiveAttention, self).__init__(**kwargs)\n self.W_k =...
[ 7, 9, 10, 11, 13 ]
from django.db import models from django.contrib.gis.db import models from django.contrib.auth.models import User from django.urls import reverse class Project(models.Model): actual_developer = models.ForeignKey(User,null = True,blank=True, on_delete=models.CASCADE) # actual_developer = models.CharField(User,null ...
normal
{ "blob_id": "ac1d38f550e548dff6ba226dbfc3dd1e5ff876a8", "index": 5563, "step-1": "<mask token>\n\n\nclass Project(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ...
[ 3, 4, 5, 6, 7 ]
import unittest import sys import os #Add project root to path sys.path.append('../..') from speckle.SpeckleClient import SpeckleApiClient class TestSpeckleStream(unittest.TestCase): def setUp(self): self.s = SpeckleApiClient() self.user = {'email':'testuser@arup.com','password':'testpassword',...
normal
{ "blob_id": "b39403171ed264c8fae5ea4ae9d17f77cfcab497", "index": 9122, "step-1": "<mask token>\n\n\nclass TestSpeckleStream(unittest.TestCase):\n\n def setUp(self):\n self.s = SpeckleApiClient()\n self.user = {'email': 'testuser@arup.com', 'password':\n 'testpassword', 'username': 'te...
[ 7, 11, 12, 13, 14 ]
def equals(left, right, tol=0.001): """ Tests equality of left and right Rosalind allows for a default [absolute] error of 0.001 in decimal answers unless otherwise stated. """ try: left = left.strip() right = right.strip() except AttributeError: pass try: ...
normal
{ "blob_id": "b137fc40a5b2dec63c7abb6953664a969f5c126f", "index": 8022, "step-1": "<mask token>\n", "step-2": "def equals(left, right, tol=0.001):\n \"\"\"\n Tests equality of left and right\n\n Rosalind allows for a default [absolute] error of 0.001 in decimal\n answers unless otherwise stated.\n ...
[ 0, 1, 2 ]
import os templateFile = 'crab_template.py' samples=[\ #"/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola/Spring14miniaod-PU20bx25_POSTLS170_V5-v1/MINIAODSIM", #"/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola/Spring14miniaod-PU20bx25_POSTLS170_V5-v2/MINIAODSIM", #Identical? Same event count #miniAO...
normal
{ "blob_id": "184b850e85b523f22a44cfde698efd96b94d819d", "index": 2095, "step-1": "import os\ntemplateFile = 'crab_template.py'\nsamples=[\\\n#\"/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-tauola/Spring14miniaod-PU20bx25_POSTLS170_V5-v1/MINIAODSIM\", \n#\"/TTJets_MSDecaysCKM_central_Tune4C_13TeV-madgraph-t...
[ 0 ]
import matplotlib.pyplot as plt import sys sys.path.append('coin_flipping_src') from monte_carlo import monte_carlo from probability import probability plt.style.use('bmh') x_coords = range(10) probablility_results = [probability(x,10) for x in x_coords] plt.plot(x_coords,probablility_results,linewidth = 2.5) # plt.plo...
normal
{ "blob_id": "124d7da330aa7c869320e10f4f89cc1c872f85f2", "index": 430, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append('coin_flipping_src')\n<mask token>\nplt.style.use('bmh')\n<mask token>\nplt.plot(x_coords, probablility_results, linewidth=2.5)\nfor _ in range(5):\n plt.plot(x_coords, ...
[ 0, 1, 2, 3, 4 ]
""" @file @brief Various function to clean files. """ from __future__ import print_function import os import re def clean_exts(folder=".", fLOG=print, exts=None, fclean=None): """ Cleans files in a folder and subfolders with a given extensions. @param folder folder to clean @param fLOG...
normal
{ "blob_id": "57972e6368aa5749edeab94e45d84f7897ca14ab", "index": 8751, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef clean_files(folder='.', posreg='.*[.]((py)|(rst))$', negreg=\n '.*[.]git/.*', op='CR', fLOG=print):\n \"\"\"\n Cleans ``\\\\r`` in files a folder and subfolders with a gi...
[ 0, 1, 2, 3, 4 ]
#Nianzu Wang #Email: wangn89@gmail.com #for_while.py: demonstrates some fun things with for and while loops def starsFor(x): array = range(x, 0, -1) array2 = range(1, x) for num in array2: print "*" * num for num in array: print "*" * num def starsWhile(n): a = 1 while a < n: ...
normal
{ "blob_id": "7e287eca041cf27d99292a331604fef9e9f90fc2", "index": 7268, "step-1": "#Nianzu Wang\n#Email: wangn89@gmail.com\n\n#for_while.py: demonstrates some fun things with for and while loops\n\ndef starsFor(x):\n array = range(x, 0, -1)\n array2 = range(1, x)\n for num in array2:\n print \"*\"...
[ 0 ]
# # @lc app=leetcode id=14 lang=python3 # # [14] Longest Common Prefix # # @lc code=start class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: pass # At the moment I just wanna test my workspace so it's working tomorrow it's time for the problems # @lc code=end
normal
{ "blob_id": "401c6b09edf593e00aecf5bbb1b2201effc9e78c", "index": 7384, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def longestCommonPrefix(self, strs: List[str]) ->str:\n pass\n", "step-4": "#\n# @lc app=leetcode id=14 lang=python3\n...
[ 0, 1, 2, 3 ]
def TriSelection(S): """ Tri par sélection Le tableau est constitué de deux parties : la 1ère constituée des éléments triés (initialisée avec seulement le 1er élément) et la seconde constituée des éléments non triés (initialisée du 2ème au dernier élément) """ for i in range(0, len(S)-1): ...
normal
{ "blob_id": "4c752c96b7e503ae5c9bc87a038fcf6dc176b776", "index": 5830, "step-1": "def TriSelection(S):\r\n \"\"\" Tri par sélection\r\n\r\n Le tableau est constitué de deux parties : la 1ère constituée des éléments triés\r\n (initialisée avec seulement le 1er élément) et la seconde constituée des éléme...
[ 0 ]
""".. Ignore pydocstyle D400.""" from rolca.payment.api.views import ( PaymentViewSet, ) routeList = ((r'payment', PaymentViewSet),)
normal
{ "blob_id": "2bfdc259bcd5ff058ee8661a14afd8a915b8372b", "index": 7020, "step-1": "<mask token>\n", "step-2": "<mask token>\nrouteList = ('payment', PaymentViewSet),\n", "step-3": "<mask token>\nfrom rolca.payment.api.views import PaymentViewSet\nrouteList = ('payment', PaymentViewSet),\n", "step-4": "\"\"\...
[ 0, 1, 2, 3 ]
# Copyright (c) Facebook, Inc. and its affiliates. from .build import build_backbone, BACKBONE_REGISTRY # noqa F401 isort:skip from .backbone import Backbone from .fpn import FPN from .resnet import ResNet, ResNetBlockBase, build_resnet_backbone, make_stage __all__ = [k for k in globals().keys() if not k.star...
normal
{ "blob_id": "502f405f48df92583757ebc9edb4b15910c1f76a", "index": 2305, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = [k for k in globals().keys() if not k.startswith('_')]\n", "step-3": "from .build import build_backbone, BACKBONE_REGISTRY\nfrom .backbone import Backbone\nfrom .fpn import FP...
[ 0, 1, 2, 3 ]
# Background: The Fibonacci numbers are defined by F(n) = F(n-1) + F(n-2). # There are different conventions on whether 0 is a Fibonacci number, # and whether counting starts at n=0 or at n=1. Here, we will assume that # 0 is not a Fibonacci number, and that counting starts at n=0, # so F(0)=F(1)=1, and F(2)=2. Wit...
normal
{ "blob_id": "40744a8530df28f0bd8648900beb8a66e2d44cd0", "index": 7730, "step-1": "<mask token>\n", "step-2": "def fun_nthfibonaccinumber(n):\n n1 = 1\n n2 = 1\n if n == 0:\n return n2\n else:\n for i in range(0, n - 1):\n sum = n1 + n2\n n1 = n2\n n2 =...
[ 0, 1, 2 ]
""" A set of constants to describe the package. Don't put any code in here, because it must be safe to execute in setup.py. """ __title__ = 'space_tracer' # => name in setup.py __version__ = '4.10.2' __author__ = "Don Kirkby" __author_email__ = "donkirkby@gmail.com" __description__ = "Trade time for space when debug...
normal
{ "blob_id": "6cb29ebd9c0f2660d0eb868bec87ffd97cf4d198", "index": 6262, "step-1": "<mask token>\n", "step-2": "<mask token>\n__title__ = 'space_tracer'\n__version__ = '4.10.2'\n__author__ = 'Don Kirkby'\n__author_email__ = 'donkirkby@gmail.com'\n__description__ = 'Trade time for space when debugging your code.'...
[ 0, 1, 2 ]
import apache_beam as beam from apache_beam.options.pipeline_options import PipelineOptions,SetupOptions from apache_beam.options.pipeline_options import GoogleCloudOptions from apache_beam.options.pipeline_options import StandardOptions dataflow_options = ['--project=lofty-shine-248403', '--job_name=newjob', '--temp_...
normal
{ "blob_id": "93a2385d9ebdbc1a7a88185c0a0d5d1f227e46a3", "index": 8159, "step-1": "<mask token>\n\n\ndef MLmodel(data):\n import pickle\n import numpy as np\n from google.cloud import storage\n storage_client = storage.Client()\n bucket = storage_client.get_bucket('testing-gcp-mandar')\n blob = ...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 """Test telegram_menu package."""
normal
{ "blob_id": "8d4ffed90e103e61a85a54d6163770966fb2e5c9", "index": 5049, "step-1": "<mask token>\n", "step-2": "#!/usr/bin/env python3\n\n\"\"\"Test telegram_menu package.\"\"\"\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
letters = ['a', 'b', 'c'] def delete_head(letters): del letters[0] print letters print delete_head(letters)
normal
{ "blob_id": "e0c10dfa4074b0de4d78fc78a6f373074ef4dadd", "index": 3971, "step-1": "letters = ['a', 'b', 'c']\ndef delete_head(letters):\n\tdel letters[0]\n\tprint letters\nprint delete_head(letters)\n\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
# Generated by Django 3.1.2 on 2020-10-21 21:00 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('monitoring', '0002_auto_20201021_0027'), ] operations = [ migrations.AlterField( model_name='endpoint', name='freque...
normal
{ "blob_id": "20f56ff484321a7d623cead4315e5a6b3b0653a7", "index": 2720, "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 = [('monitoring'...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.1.2 on 2020-10-17 15:46 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('story1', '0006_visitor'), ] operations = [ migrations.RenameField( model_name='visitor', old_name='identitiy_n...
normal
{ "blob_id": "1aaace83af0235341d10b8ac3b47d00a944dac37", "index": 1422, "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 = [('story1', '0...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python # Script to time convolution using different number of processors. # Jason Neal # December 2016 from __future__ import division, print_function import datetime from eniric.nIRanalysis import convolve_spectra spectrum_name = "lte03900-4.50-0.0.PHOENIX-ACES-AGSS-COND-2011-HiRes_wave.dat" data_rep = ...
normal
{ "blob_id": "2105619102de0d4d976c7bdfc839ee08058b7ab5", "index": 2713, "step-1": "<mask token>\n\n\ndef time_diff_procs(numprocs):\n \"\"\"Time the convolution with different number of processors\"\"\"\n conv_times = dict()\n for proc in numprocs:\n start_time = datetime.datetime.now()\n c...
[ 1, 2, 3, 4, 5 ]
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse class CampaignNegativeKeywords(Client): @sp_endpoint('/v2/sp/campaignNegativeKeywords/{}', method='GET') def get_campaign_negative_keyword(self, keywordId, **kwargs) -> ApiResponse: r""" get_campaign_negative_keyword(...
normal
{ "blob_id": "f6e0215f9992ceab51887aab6a19f58a5d013eb4", "index": 7829, "step-1": "<mask token>\n\n\nclass CampaignNegativeKeywords(Client):\n <mask token>\n\n @sp_endpoint('/v2/sp/campaignNegativeKeywords/{}', method='DELETE')\n def delete_campaign_negative_keyword(self, keywordId, **kwargs\n ) -...
[ 5, 6, 8, 9, 10 ]
import argparse from ags_save_parser import saved_game def report_mismatch(compare_result_list): report = [] for i in range(len(compare_result_list)): value = compare_result_list[i] if value != '_': report.append((i, value)) return report def report_mismatch_for_module( ...
normal
{ "blob_id": "329451a3d3fa95f5572dc1701d1adbf4aaa72628", "index": 8521, "step-1": "<mask token>\n\n\ndef report_mismatch_for_module(modules_1, modules_2, index):\n module_1 = modules_1[index]\n module_2 = modules_2[index]\n if len(module_1) != 2 or len(module_2) != 2:\n raise AssertionError('Modul...
[ 3, 5, 6, 7, 8 ]
## #Author: Stephen ## import socket import select import sys, os from contextlib import contextmanager hostip = 'localhost' hostport = 8089 def connect(hostip=hostip,hostport=hostport): server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) IP_address = hostip Port = hostport server.connect((IP_a...
normal
{ "blob_id": "5cdf8cd4bfebb9aab2e8f421047fc1ba3190d566", "index": 3451, "step-1": "<mask token>\n\n\ndef connect(hostip=hostip, hostport=hostport):\n server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n IP_address = hostip\n Port = hostport\n server.connect((IP_address, Port))\n return serv...
[ 5, 6, 7, 8, 9 ]
# Write a class to hold player information, e.g. what room they are in # currently. class Player(): def __init__(self, name, location, items=[]): self.name = name self.location = location self.items = items # def try_direction(self, user_action): # attribute = user_action + '_...
normal
{ "blob_id": "b355bd5a519d65ea35d4e8d5e6a384424d79130a", "index": 3620, "step-1": "<mask token>\n", "step-2": "class Player:\n <mask token>\n\n def pick_up_item(self, item):\n if len(self.items) <= 3:\n self.items.append(item)\n print(\n f\"\"\"\n\nNOW YOU HAVE ...
[ 0, 2, 3, 4, 5 ]
import rospy #: the parameter namespace for the arni_countermeasure node ARNI_CTM_NS = "arni/countermeasure/" #: the parameter namespace for configuration files #: of the arni_countermeasure node ARNI_CTM_CFG_NS = ARNI_CTM_NS + "config/" def get_param_num(param): #dummy val value = 1 try: value...
normal
{ "blob_id": "70c9d75dabfa9eac23e34f94f34d39c08e21b3c0", "index": 6070, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_param_num(param):\n value = 1\n try:\n value = rospy.get_param(param)\n if not isinstance(value, (int, float, long)):\n err_msg = 'Param %s is n...
[ 0, 2, 3, 4, 5 ]
# encoding: utf-8 from GlyphsApp.plugins import * from outlineTestPenGlyphs import OutlineTestPenGlyphs from string import strip plugin_id = "de.kutilek.RedArrow" class RedArrow(ReporterPlugin): def settings(self): self.menuName = "Red Arrows" self.keyboardShortcut = 'a' self.keyboardShortcutModifier = N...
normal
{ "blob_id": "229d7378695f7e00176eb7c3962519af3db1b7e1", "index": 4461, "step-1": "<mask token>\n\n\nclass RedArrow(ReporterPlugin):\n <mask token>\n\n def start(self):\n self.addMenuItem()\n self.options = {'extremum_calculate_badness': False,\n 'extremum_ignore_badness_below': 0,\...
[ 7, 10, 12, 13, 14 ]
print("calificacion de los alumnos") lista2_calificaciones=[] for i in range (0,5): lista2_calificaciones.append(int(input(f"ingrese la calificacion corresponfiente al alumno"))) print(lista2_calificaciones) for n in range(0,len(lista2_calificaciones)): if lista2_calificaciones[i] >=0 and lista2_calific...
normal
{ "blob_id": "1cc9c89182f69a5f1eb9a0e7f3433dc30c8d7035", "index": 2938, "step-1": "<mask token>\n", "step-2": "print('calificacion de los alumnos')\n<mask token>\nfor i in range(0, 5):\n lista2_calificaciones.append(int(input(\n f'ingrese la calificacion corresponfiente al alumno')))\n print(lista2...
[ 0, 1, 2, 3 ]
def lucas(): yield 2 a = 2 b = 1 while True: yield b a, b = b, a + b l = lucas() for i in range(10): print('{}: {}'.format(i, next(l)))
normal
{ "blob_id": "4745c00ca0f3ca4316117228a9d44bdb5df02877", "index": 7799, "step-1": "<mask token>\n", "step-2": "def lucas():\n yield 2\n a = 2\n b = 1\n while True:\n yield b\n a, b = b, a + b\n\n\n<mask token>\n", "step-3": "def lucas():\n yield 2\n a = 2\n b = 1\n while ...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # # This will take a snapshot and convert it into a volume. To create a volume # without any links to the old snapshot you need to convert it to a temporary # volume first, convert that into an image and convert the image back into # your final volume. Once this is all done, the temporary volume a...
normal
{ "blob_id": "aebe749a20482636d7ed508f9cbd9cde56656b73", "index": 6236, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main(args):\n openstack.enable_logging(debug=False)\n api = openstack.connect(cloud=args.cloud)\n snapshot_id = args.snapshot\n server = args.volume\n try:\n ...
[ 0, 1, 2, 3, 4 ]
from .__main__ import datajson_write, datajson_read
normal
{ "blob_id": "2269e74c006833976c3a28cd52c238e2dde20051", "index": 5871, "step-1": "<mask token>\n", "step-2": "from .__main__ import datajson_write, datajson_read\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
# 出现频率特别高的和频率特别低的词对于文本分析帮助不大,一般在预处理阶段会过滤掉。 # 在英文里,经典的停用词为 “The”, "an".... # 方法1: 自己建立一个停用词词典 stop_words = ["the", "an", "is", "there"] # 在使用时: 假设 word_list包含了文本里的单词 word_list = ["we", "are", "the", "students"] filtered_words = [word for word in word_list if word not in stop_words] print (filtered_words) # ...
normal
{ "blob_id": "d14937aaa7a80d6b95825afa2a2d6ff8202e5f5c", "index": 2498, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(filtered_words)\n<mask token>\nprint(' '.join(singles))\n", "step-3": "stop_words = ['the', 'an', 'is', 'there']\nword_list = ['we', 'are', 'the', 'students']\nfiltered_words = [w...
[ 0, 1, 2, 3, 4 ]
""" Массив размером 2m + 1, где m — натуральное число, заполнен случайным образом. Найдите в массиве медиану. Медианой называется элемент ряда, делящий его на две равные части: в одной находятся элементы, которые не меньше медианы, в другой — не больше медианы. Примечание: задачу можно решить без сортировки исходного м...
normal
{ "blob_id": "fbcbad9f64c0f9b68e29afde01f3a4fdba012e10", "index": 4868, "step-1": "<mask token>\n\n\ndef heapify(array, size, ind):\n largest = ind\n left = 2 * ind + 1\n right = 2 * ind + 2\n if left < size and array[left] > array[largest]:\n largest = left\n if right < size and array[right...
[ 2, 3, 4, 5, 6 ]
import math import torch import torch.nn as nn import torch.nn.functional as F class Model(nn.Module): def __init__(self, hidden_size, encoder_layer=2, step=4, is_bidir=False, **kw): super(Model, self).__init__() fc_embedding = [] # First, we should convert the 1 dim data to ...
normal
{ "blob_id": "188f82b0fb04d6814d77617fa9148113d0e6ef01", "index": 2170, "step-1": "<mask token>\n\n\nclass Model(nn.Module):\n <mask token>\n\n def forward(self, input_seq, target_seq=None):\n input_seq = self.fc_embedding(input_seq.unsqueeze(-1))\n _, encoding_result = self.encoder(input_seq)...
[ 4, 5, 6, 7, 8 ]
from data import constants from data.action import Action from data.point import Point class MoveActorsAction(Action): """A code template for moving actors. The responsibility of this class of objects is move any actor that has a velocity more than zero. Stereotype: Controller Attributes:...
normal
{ "blob_id": "3be7183b5c1d86ee0ebfdea89c6459efe89510f8", "index": 6103, "step-1": "<mask token>\n\n\nclass MoveActorsAction(Action):\n <mask token>\n\n def execute(self, cast):\n \"\"\"Executes the action using the given actors.\n\n Args:\n cast (dict): The game actors {key: tag, va...
[ 2, 3, 4, 5, 6 ]
n_m_q=input().split(" ") n=int(n_m_q[0]) m=int(n_m_q[1]) q=int(n_m_q[2]) dcc=[] for i in range(n): a=[] dcc.append(a) available=[] for i in range(m): x=input().split(" ") a=int(x[0]) b=int(x[1]) available.append([a,b]) dcc[a-1].append(b) dcc[b-1].append(a) for i in range(q): x=input(...
normal
{ "blob_id": "062b6133ba4de24f7eaf041e4b6c039501b47b9a", "index": 8873, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n a = []\n dcc.append(a)\n<mask token>\nfor i in range(m):\n x = input().split(' ')\n a = int(x[0])\n b = int(x[1])\n available.append([a, b])\n dc...
[ 0, 1, 2, 3 ]
from config import Config def test_stf_3_2_1_pos(fixture): seed = fixture.common.get_seed() fixture.stf.open_stf_exercise('3-2-1', seed) fixture.stf.open_solution_url(seed) assert fixture.stf.get_solution() == Config.test_pass_text fixture.common.back_to_main_page() def test_stf_3_2_1_neg(fixtur...
normal
{ "blob_id": "028b38a07c71232eb42bedecd734cf7188550239", "index": 9602, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_stf_3_2_1_neg(fixture):\n seed = fixture.common.get_seed()\n fixture.stf.open_stf_exercise('3-2-1', seed)\n fixture.stf.open_solution_url('test')\n assert fixture...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python3 """Prints the first State object from the database specified """ from sys import argv import sqlalchemy from sqlalchemy import create_engine, orm from model_state import Base, State if __name__ == "__main__": engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}' ...
normal
{ "blob_id": "1f3e20e7fe597a88cddacf6813250f1ede6c6ee0", "index": 6595, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n engine = create_engine('mysql+mysqldb://{}:{}@localhost/{}'.format(*\n argv[1:4]), pool_pre_ping=True)\n Base.metadata.create_all(engine)\n se...
[ 0, 1, 2, 3 ]
import time from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.select import Select from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions class TestTa...
normal
{ "blob_id": "777dc2056443f0404ccb75d570f2ddc3a3aa747b", "index": 6669, "step-1": "<mask token>\n\n\nclass TestTaniHub:\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass TestTaniHub:\n <mask token>\n <mask token>\n\n def test_tanihub_number_2...
[ 1, 2, 4, 6, 8 ]
#!/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 ]