code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
"""Test the init file of Mailgun.""" import hashlib import hmac import pytest from homeassistant import config_entries, data_entry_flow from homeassistant.components import mailgun, webhook from homeassistant.config import async_process_ha_core_config from homeassistant.const import CONF_API_KEY, CONF_DOMAIN from hom...
normal
{ "blob_id": "a55024f0e5edec22125ce53ef54ee364be185cb8", "index": 1099, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.fixture\nasync def http_client(hass, hass_client_no_auth):\n \"\"\"Initialize a Home Assistant Server for testing this module.\"\"\"\n await async_setup_component(hass, ...
[ 0, 1, 2, 3, 4 ]
import re list = ["Protein XVZ [Human]","Protein ABC [Mouse]","go UDP[3] glucosamine N-acyltransferase [virus1]","Protein CDY [Chicken [type1]]","Protein BBC [type 2] [Bacteria] [cat] [mat]","gi p19-gag protein [2] [Human T-lymphotropic virus 2]"] pattern = re.compile("\[(.*?)\]$") for string in list: match = re.se...
normal
{ "blob_id": "21c12aabfb21e84f3ea546842fb55c41d2129ff9", "index": 6526, "step-1": "import re\nlist = [\"Protein XVZ [Human]\",\"Protein ABC [Mouse]\",\"go UDP[3] glucosamine N-acyltransferase [virus1]\",\"Protein CDY [Chicken [type1]]\",\"Protein BBC [type 2] [Bacteria] [cat] [mat]\",\"gi p19-gag protein [2] [Hum...
[ 0 ]
clear ; clc; %-----------------------读入图像-------------------------------------% markbefore=imread('p203.bmp'); markbefore2=rgb2gray(markbefore); mark=im2bw(markbefore2); figure(1); subplot(2,3,1); imshow(mark),title('水印图像'); [rm,cm]=size(mark); cover=imread('pic.bmp'); cover1=imresize(cover,[512...
normal
{ "blob_id": "56d3e59e3e077b1febb834668aba44ce8dba13ae", "index": 635, "step-1": "clear ;\nclc;\n \n%-----------------------读入图像-------------------------------------%\nmarkbefore=imread('p203.bmp');\nmarkbefore2=rgb2gray(markbefore);\nmark=im2bw(markbefore2); \nfigure(1); \nsubplot(2,3,1); \nimshow...
[ 0 ]
#!/usr/bin/env python3 # given a set A and n other sets. # find whether set A is a strict superset of each of the n sets # print True if yes, otherwise False A = set(map(int, input().split())) b = [] for _ in range(int(input())): b.append(A > set(map(int, input().split()))) print(all(b))
normal
{ "blob_id": "a9eb2b3f26396918c792de3f126e51bde334b709", "index": 7777, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(int(input())):\n b.append(A > set(map(int, input().split())))\nprint(all(b))\n", "step-3": "A = set(map(int, input().split()))\nb = []\nfor _ in range(int(input())):\n...
[ 0, 1, 2, 3 ]
""" module : watcher.py description : Script to automatically watch a directory (via watchdog) for tests and run them via py.test """ import sys import os.path import subprocess import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler class SpecificationsEventHandler(Fil...
normal
{ "blob_id": "95ea8a21d3ac44c7760179bc4ebf67f0c16e6a19", "index": 2421, "step-1": "<mask token>\n\n\nclass SpecificationsEventHandler(FileSystemEventHandler):\n <mask token>\n\n def __init__(self):\n self.paused = False\n self.banner = (\n '==========================================...
[ 3, 4, 5, 6, 7 ]
import random from typing import List from faker import Faker from call_center.src.actors.agent import InsuranceAgent from call_center.src.actors.consumer import Consumer from call_center.src.common.person import ( AGE, AVAILABLE, INSURANCE_OPERATION, PHONE_NUMBER, INCOME, CARS_COUNT, KID...
normal
{ "blob_id": "db31a69c57f773a79e5eaa8b3443b0366fd74861", "index": 8565, "step-1": "<mask token>\n\n\nclass ActorsCreator(metaclass=SingletonMeta):\n <mask token>\n\n def __init__(self):\n self.consumers = ActorsCreator.create_consumers()\n self.agents = ActorsCreator.create_agents()\n\n def...
[ 6, 7, 8, 9, 10 ]
from django.shortcuts import render, HttpResponseRedirect, HttpResponse from django.views.generic import View from django.contrib.auth import login from django.contrib.auth.models import User class RegisterView(View): def get(self, request): return render(request, 'users/register.html', locals()) def...
normal
{ "blob_id": "c9191df0fc04818b4df9c93a9479f75a60688aa9", "index": 6372, "step-1": "<mask token>\n\n\nclass RegisterView(View):\n <mask token>\n <mask token>\n\n\nclass HomeView(View):\n\n def get(self, request):\n return HttpResponse(f'Home Page | Logged in as - {request.user}')\n", "step-2": "<...
[ 3, 4, 5, 6, 7 ]
from django.urls import path from photo.api.views import api_photo_detail_view, api_photos_view urlpatterns = [path('<int:id>', api_photo_detail_view, name='user_detail'), path('', api_photos_view, name='users')]
normal
{ "blob_id": "ab4145ccc0b360dcca9b9aa6ebe919bdddac65a2", "index": 3962, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('<int:id>', api_photo_detail_view, name='user_detail'),\n path('', api_photos_view, name='users')]\n", "step-3": "from django.urls import path\nfrom photo.api.vie...
[ 0, 1, 2 ]
from collections import defaultdict, Counter import numpy as np import sys import re def parseFile(file, frequency_tree): readnumber = re.compile('[r]+\d+') line_spliter = re.compile('\t+') colon_spliter = re.compile(':') forward_reads = 0 reverse_reads = 0 unmatched_reads = 0 read_position...
normal
{ "blob_id": "227b71cb6d4cde8f498ad19c1c5f95f7fc572752", "index": 6995, "step-1": "<mask token>\n\n\ndef getChromosome(str):\n if str == '*' or str[3:] == 'X':\n return -1\n try:\n return int(str[3:])\n except:\n return -1\n", "step-2": "<mask token>\n\n\ndef parseFile(file, freque...
[ 1, 2, 3, 4, 5 ]
#! /usr/bin/env python import smtpsend S = smtpsend.Smtpsent(SUBJECT='Test') S.sendemail(''' this is a test! ''')
normal
{ "blob_id": "7754974e79202b2df4ab9a7f69948483042a67cc", "index": 855, "step-1": "<mask token>\n", "step-2": "<mask token>\nS.sendemail(\"\"\"\nthis is a test!\n\"\"\")\n", "step-3": "<mask token>\nS = smtpsend.Smtpsent(SUBJECT='Test')\nS.sendemail(\"\"\"\nthis is a test!\n\"\"\")\n", "step-4": "import smtp...
[ 0, 1, 2, 3, 4 ]
import json import glob import argparse from model.NewModel import runModel from collections import namedtuple import csv OutputFile = "./HealthSimOutputSheet.csv" parser = argparse.ArgumentParser(description='Select policy file') parser.add_argument('-p', type=str, default='default', help='name of a a policy file') ...
normal
{ "blob_id": "894ce07c6443208483be2d3ef1409f12f24d99f3", "index": 2852, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('-p', type=str, default='default', help=\n 'name of a a policy file')\nparser.add_argument('-n', type=int, default=100000, help='number of patients')\n<mask token>\...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.1.2 on 2018-10-25 09:36 import django.contrib.auth.models import django.contrib.auth.validators from django.db import migrations, models import django.utils.timezone import uuid class Migration(migrations.Migration): dependencies = [ ('grafit', '0002_article'), ] operati...
normal
{ "blob_id": "8b0eed6d1f24b5dd30726ce08c97354a5d5ab69b", "index": 7597, "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 = [('grafit', '0...
[ 0, 1, 2, 3, 4 ]
INPUT_MINBIAS = '/build/RAWReference/MinBias_RAW_320_STARTUP.root' INPUT_TTBAR = '/build/RAWReference/TTbar_RAW_320_STARTUP.root' puSTARTUP_TTBAR = '/build/RAWReference/TTbar_Tauola_PileUp_RAW_320_STARTUP.root' relval = { 'step1': { 'step': 'GEN-HLT', 'timesize': (100, ['MinBias','TTbar']), 'igprof': (50...
normal
{ "blob_id": "78c9f92349ba834bc64dc84f884638c4316a9ea4", "index": 352, "step-1": "<mask token>\n", "step-2": "INPUT_MINBIAS = '/build/RAWReference/MinBias_RAW_320_STARTUP.root'\nINPUT_TTBAR = '/build/RAWReference/TTbar_RAW_320_STARTUP.root'\npuSTARTUP_TTBAR = (\n '/build/RAWReference/TTbar_Tauola_PileUp_RAW_...
[ 0, 1, 2 ]
import requests from bs4 import BeautifulSoup import time print("Put some unfamiliar skills") unfamilar_skills = input(">") print(f"Filtering result for {unfamilar_skills}...\n") def find_jobs(): html_text = requests.get('https://www.timesjobs.com/candidate/job-search.html?searchType=personalizedSearch&from=submit...
normal
{ "blob_id": "92b71c67130cd37b2143fbd9ad71fe9a18b3f7e8", "index": 2622, "step-1": "<mask token>\n\n\ndef find_jobs():\n html_text = requests.get(\n 'https://www.timesjobs.com/candidate/job-search.html?searchType=personalizedSearch&from=submit&txtKeywords=python&txtLocation='\n ).text\n soup = ...
[ 1, 2, 3, 4, 5 ]
from django import forms from acl.models import Alert class CreateAlertForm(forms.ModelForm): class Meta: model = Alert exclude = ['role', 'age_analysis', 'Date_Uploaded', 'alias_name', 'CAMT_Reveiewer', 'Date_Regularised', 'alert_message', 'Count2']
normal
{ "blob_id": "bfcf6e241881c4f668f926e087ab0f7dcad61dee", "index": 5260, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CreateAlertForm(forms.ModelForm):\n\n\n class Meta:\n model = Alert\n exclude = ['role', 'age_analysis', 'Date_Uploaded', 'alias_name',\n 'CAMT_Revei...
[ 0, 1, 2 ]
# These are instance types to make available to all AWS EC2 systems, except the . # PostgreSQL server, until the auto tuning playbook can tune for systems that # small. AWSGlobalInstanceChoices = [ 't2.nano', 't2.micro', 't3.nano', 't3.micro', 't3a.nano', 't3a.micro', ] class SpecValidator: ...
normal
{ "blob_id": "4db93bdab2d73e7226dcad61827f5faea8513767", "index": 9888, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SpecValidator:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass SpecValidator:\n\n def __init__(self, type=None, default=None, choices=[], min=Non...
[ 0, 1, 2, 3, 4 ]
""" 챕터: day4 주제: 반복문(for문) 문제: 1에서 100까지 합을 구하여 출력하시오. 작성자: 한현수 작성일: 2018.9.20. """ result = 0 for i in range(101): result += i print(result)
normal
{ "blob_id": "d2754099adebdb4bd2b028fdf9015571ad773754", "index": 9313, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(101):\n result += i\nprint(result)\n", "step-3": "<mask token>\nresult = 0\nfor i in range(101):\n result += i\nprint(result)\n", "step-4": "\"\"\"\n챕터: day4\n주제:...
[ 0, 1, 2, 3 ]
from rest_framework import serializers from django.contrib.auth import password_validation from rest_framework.validators import UniqueValidator from .models import CustomUser, Role, Permission, ActionEntity from .utils import create_permission class ActionEntitySerializer(serializers.ModelSerializer): id = ser...
normal
{ "blob_id": "b10a50ce649650542d176a2f6fb8c35c500fbc38", "index": 3644, "step-1": "<mask token>\n\n\nclass UserCreateSerializer(serializers.ModelSerializer):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n model = CustomUser\n fields =...
[ 7, 17, 18, 23, 26 ]
from django.urls import path from .views.home import Home from .views.signup import Signup from .views.login import Login urlpatterns = [ path('', Home.as_view(), name='home'), path('signup', Signup.as_view(), name='signup'), path('login', Login.as_view(), name='login'), ]
normal
{ "blob_id": "979a387e29867818ffad7291511ff0be40dee118", "index": 1938, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', Home.as_view(), name='home'), path('signup', Signup\n .as_view(), name='signup'), path('login', Login.as_view(), name='login')]\n", "step-3": "from django.url...
[ 0, 1, 2, 3 ]
import time import json import pygame from pygame.locals import * import urllib.request from pygame.color import THECOLORS pygame.init() Brack=[0,0,0] White=[255,255,255] Green=[0,255,0] Red=[255,0,0] Gray=[169,169,169] button_text=["开 始","开 始","开 始","开 始","开 始"] line=['http://localhost:5050/mixer/000','http://localhos...
normal
{ "blob_id": "609071fc3af1b526fbd4555ced2376f56ae0f3c3", "index": 2174, "step-1": "<mask token>\n\n\ndef Process(num, x, y, button_text, color):\n text_fmt1 = text_1.render(text[num], 1, Brack)\n screen.blit(text_fmt1, (x - 127, y))\n pygame.draw.rect(screen, Brack, [x, y, 60, 25], 2)\n pygame.draw.re...
[ 2, 3, 4, 5, 6 ]
import numpy as np import matplotlib.pyplot as plt def cos_Taylor2(x, n): s = 0 a = 1 for i in range(0, n+1): s = s+a a = -a*x**2 / ((2*i+1)*(2*i+2)) return s, abs(a) vcos = np.vectorize(cos_Taylor2) def cos_two_terms(x): s = 0 a = 1 s = s+a a = -a*x**2 / ((2*0+1)*(2*...
normal
{ "blob_id": "fb0dcb641dfb379751264dc0b18007f5d058d379", "index": 3520, "step-1": "<mask token>\n\n\ndef cos_two_terms(x):\n s = 0\n a = 1\n s = s + a\n a = -a * x ** 2 / ((2 * 0 + 1) * (2 * 0 + 2))\n s = s + a\n a = -a * x ** 2 / ((2 * 1 + 1) * (2 * 1 + 2))\n s = s + a\n a = -a * x ** 2 /...
[ 2, 4, 5, 6, 7 ]
class Node: def __init__(self, data): self.data = data self.prev = None self.next = None class LinkedList: def __init__(self): self.head = None def insertAtHead(self, newNode, curNode): newNode.next = curNode if curNode is not None: curNode.prev = newNode ...
normal
{ "blob_id": "a3cbdecbbfc49e8ac045f4aabbea6b9f54ed3d5f", "index": 4904, "step-1": "<mask token>\n\n\nclass LinkedList:\n\n def __init__(self):\n self.head = None\n\n def insertAtHead(self, newNode, curNode):\n newNode.next = curNode\n if curNode is not None:\n curNode.prev = ...
[ 5, 7, 8, 9, 11 ]
/Users/andreilyskov/anaconda/lib/python3.5/sre_compile.py
normal
{ "blob_id": "faf4f4d26236ac555594ef6913a0d43c3516f1f2", "index": 2063, "step-1": "/Users/andreilyskov/anaconda/lib/python3.5/sre_compile.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
import sys, os sys.path.append(os.pardir) import numpy as np from dataset.mnist import load_mnist from two_layer_net import TwoLayerNet (x_train, t_train), (x_test, t_test) = load_mnist(normalize=True, one_hot_label = True) train_loss_list = [] #hiper param iters_num = 1000 train_size = x_train.shape[0] batch_size =...
normal
{ "blob_id": "dbe3aa107de8e62822803d1740773a4b22f41edf", "index": 971, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.append(os.pardir)\n<mask token>\nfor i in range(iters_num):\n print(i)\n batch_mask = np.random.choice(train_size, batch_size)\n x_batch = x_train[batch_mask]\n t_batc...
[ 0, 1, 2, 3, 4 ]
import sys sys.stdin = open('magnet.txt', 'r') from collections import deque def check(t, d, c): if t == 1: if m1[2] != m2[-2] and not c: check(t + 1, d * (-1), 1) if d == 1: m1.appendleft(m1.pop()) else: m1.append(m1.popleft()) elif t == 4: ...
normal
{ "blob_id": "7e3a5e1f19683b1716f3c988dcc1e65fee1cae13", "index": 8956, "step-1": "<mask token>\n\n\ndef check(t, d, c):\n if t == 1:\n if m1[2] != m2[-2] and not c:\n check(t + 1, d * -1, 1)\n if d == 1:\n m1.appendleft(m1.pop())\n else:\n m1.append(m1.pop...
[ 1, 2, 3, 4, 5 ]
import boto3 import pprint import yaml #initialize empty dictionary to store values new_dict = {} count = 0 new_dict2 = {} # dev = boto3.session.Session(profile_name='shipt') mybatch = boto3.client('batch') #load config properties with open('config.yml') as f: content = yaml.load(f) # pprint.pprint(content) #to...
normal
{ "blob_id": "3ba9ff00b0d6a2006c714a9818c8b561d884e252", "index": 2302, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('config.yml') as f:\n content = yaml.load(f)\n<mask token>\nfor k, v in response.items():\n if k == 'jobDefinitions':\n new_dict = v[0]['containerProperties']\nprin...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('levantamiento', '0001_initial'), ] operations = [ migrations.CreateModel( name='FichaTecnica', field...
normal
{ "blob_id": "1049a7d2cdc54c489af6246ec014deb63a98f96d", "index": 3951, "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 = [('levantamien...
[ 0, 1, 2, 3, 4 ]
# Developed by Lorenzo Mambretti, Justin Wang # # 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 # # https://github.com/jtwwang/hanabi/blob/master/LICENSE # # Unless required by applic...
normal
{ "blob_id": "bbd5eb1f80843efdd2709aa19a65bf325a88f473", "index": 8856, "step-1": "<mask token>\n\n\ndef model_crossover(weights1, weights2):\n new_weights = []\n assert len(weights1) == len(weights2)\n if random.uniform(0, 1) > 0.3:\n print('crossover')\n for layer in range(len(weights1)):...
[ 3, 4, 5, 6, 7 ]
import sqlite3 import pandas as pd #%matplotlib inline import matplotlib.pyplot as plt db_filename = 'readonly/dinofunworld.db' conn = sqlite3.connect(db_filename) c = conn.cursor() c.execute("SELECT a.Name, count(c.visitorID) \ FROM attraction as a, checkin c \ WHERE \ a.AttractionID = c.attraction \ AND a.Category l...
normal
{ "blob_id": "c19c3f580d7555379bd7e077b0264a3784179e93", "index": 696, "step-1": "<mask token>\n", "step-2": "<mask token>\nc.execute(\n \"SELECT a.Name, count(c.visitorID) FROM attraction as a, checkin c WHERE a.AttractionID = c.attraction AND a.Category like 'Thrill Rides%' GROUP BY a.AttractionID \"\n ...
[ 0, 1, 2, 3, 4 ]
import random consonants = [ 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z' ] vowels = [ 'a', 'e',' i', 'o', 'u' ] def make_word(user_input): word = "" for letter in user_input: letter = letter.lower() if letter...
normal
{ "blob_id": "a4f4137b9310ebc68515b9cae841051eda1f0360", "index": 3522, "step-1": "<mask token>\n\n\ndef make_word(user_input):\n word = ''\n for letter in user_input:\n letter = letter.lower()\n if letter == 'c':\n word += random.choice(consonants)\n elif letter == 'v':\n ...
[ 1, 2, 4, 5, 6 ]
class Solution: # @param num, a list of integer # @return an integer def longestConsecutive(self, num): sted = {} n = len(num) for item in num: if item in sted: continue sted[item] = item if item-1 in sted: sted[item...
normal
{ "blob_id": "d7c4bee7245dab1cbb90ee68b8e99994ce7dd219", "index": 3295, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def longestConsecutive(self, num):\n sted = {}\n n = len(num)\n for item in num:\n if item in s...
[ 0, 1, 2, 3 ]
from classNinapro import Ninapro import numpy as np import tensorflow as tf print(tf.__version__) Debug = True # for tensor dimensionality checking ninapro = Ninapro() ninapro.splitImagesLabels() # Train print('ninapro.TrainImages shape: ', ninapro.TrainImages.shape) # m x 16 x 30 print('ninapro.TrainLabels shape...
normal
{ "blob_id": "30aa8405ccf64ce8a05204f3f9fa2ffab436ad3b", "index": 1578, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(tf.__version__)\n<mask token>\nninapro.splitImagesLabels()\nprint('ninapro.TrainImages shape: ', ninapro.TrainImages.shape)\nprint('ninapro.TrainLabels shape: ', ninapro.TrainLabels...
[ 0, 1, 2, 3, 4 ]
#connect4_JayNa.py #Jay Na #CS111 Spring 2018 #This file creates a version of the game Connect4, where the user plays against an AI from graphics import * import random class ConnectWindow: def __init__(self): self.window = GraphWin("Connect Four", 690, 590) self.window.setMouseHandler(self.handleClick) self....
normal
{ "blob_id": "abbad57e945d2195021948a0e0838c6bfd9c6a1e", "index": 769, "step-1": "<mask token>\n\n\nclass ConnectWindow:\n <mask token>\n\n def startScreen(self):\n \"\"\"This function creates the board and intializes the board count for each column\"\"\"\n self.background = Rectangle(Point(0,...
[ 2, 8, 10, 11, 16 ]
import json import requests import config class RequestAnnotation: def schedule(self, command: str, **kwargs): response = requests.post(url=f"http://localhost:{config.annotation_port}/{command}", json=kwargs) # not 'text' for annotating, but...
normal
{ "blob_id": "6782761bcbf53ea5076b6dfb7de66d0e68a9f45d", "index": 3123, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass RequestAnnotation:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass RequestAnnotation:\n\n def schedule(self, command: str, **kwargs):\n response = requests....
[ 0, 1, 2, 3, 4 ]
# # Wrappers for model evaluation # import torch import torch.nn.functional as F from torch.utils.data import Dataset, DataLoader from modules import Classifier from typing import Generator, NamedTuple, Optional, Union from utils import expand_generator class Evaluator(object): class Result(NamedTuple): ...
normal
{ "blob_id": "493dbf85069f2115896a5f5f5d593c8d95b85cff", "index": 4594, "step-1": "<mask token>\n\n\nclass ModelEvaluator(Evaluator):\n\n def __init__(self, dataset: Dataset, batch_size: int, num_workers: int,\n mixed_precision: bool=True):\n self.dataset = dataset\n self.mixed_precision =...
[ 5, 6, 7, 8, 9 ]
import csv import os with open("sample.csv") as rf: csv_reader=csv.DictReader(rf) with open("sample1.csv","w") as wf: csv_headers=['fname','lname','email'] if os.path.isfile('sample1.csv'): q=input("File already exists. Do you want to overwrite?") if q.lower()=='yes':...
normal
{ "blob_id": "43196258b61801799b8d6b7d23f5816d84cb5dff", "index": 7294, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('sample.csv') as rf:\n csv_reader = csv.DictReader(rf)\n with open('sample1.csv', 'w') as wf:\n csv_headers = ['fname', 'lname', 'email']\n if os.path.isfile...
[ 0, 1, 2, 3 ]
from datetime import datetime from random import seed from pandas import date_range, DataFrame import matplotlib.pyplot as plt from matplotlib import style from numpy import asarray import strategy_learner as sl from util import get_data style.use('ggplot') seed(0) def run_algo(sym, investment, start_date, end_date...
normal
{ "blob_id": "c0f9a1c39ff5d7cc99a16cf00cddcc14705937ba", "index": 3917, "step-1": "<mask token>\n\n\ndef run_algo(sym, investment, start_date, end_date, bench_sym):\n learner = sl.StrategyLearner(bench_sym=bench_sym, verbose=verbose)\n learner.add_evidence(symbol=sym, start_date=start_date, end_date=\n ...
[ 1, 2, 3, 4, 5 ]
class Solution: def evalRPN(self, tokens: List[str]) -> int: def operation(op1,op2,op): if op == "+": return op1 + op2 if op == "-": return op1 - op2 if op == "*": return op1 * op2 if op == "/": ...
normal
{ "blob_id": "6b597f1570c022d17e4476e2ab8817e724a166a7", "index": 1096, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def evalRPN(self, tokens: List[str]) ->int:\n\n def operation(op1, op2, op):\n if op == '+':\n ...
[ 0, 1, 2, 3 ]
from django.db import models class crontab(models.Model): name = models.CharField(max_length=20) class converter(models.Model): name = models.CharField(max_length=20) class MainTable(models.Model): rank = models.IntegerField(null=True) coinid = models.CharField(max_length=30,null=True) symbol = ...
normal
{ "blob_id": "0054921928838d9aee63cf58f50a0a01ee12635d", "index": 6049, "step-1": "<mask token>\n\n\nclass Table(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Price(models.Model):\n price = models.FloatField(null=True)\n\n\nclass Marketdata(...
[ 5, 6, 10, 12, 14 ]
#TODO: allow workers to pull this from cache RABBITMQ_IP = '172.23.105.82' OBJECT_CACHE_IP = "172.23.105.69" OBJECT_CACHE_PORT = "11911" SERIESLY_IP = '' COUCHBASE_IP = '172.23.105.54' COUCHBASE_PORT = '8091' COUCHBASE_USER = "Administrator" COUCHBASE_PWD = "password" SSH_USER = "root" SSH_PASSWORD = "password" WORKER...
normal
{ "blob_id": "e70ebd9bb9cd7027772ec117cb91349afba7ab10", "index": 6390, "step-1": "<mask token>\n", "step-2": "RABBITMQ_IP = '172.23.105.82'\nOBJECT_CACHE_IP = '172.23.105.69'\nOBJECT_CACHE_PORT = '11911'\nSERIESLY_IP = ''\nCOUCHBASE_IP = '172.23.105.54'\nCOUCHBASE_PORT = '8091'\nCOUCHBASE_USER = 'Administrator...
[ 0, 1, 2 ]
#This is a file from CS50 Finance from functools import wraps from flask import redirect, render_template, session from threading import Thread from flask_mail import Message from application import app, mail ALLOWED_EXTENSIONS = {"png", "PNG", "jpg", "jpeg", "JPG", "JPEG"} def login_required(f): """ Decorat...
normal
{ "blob_id": "1a4da621add157fa6d1f578370d64594b102eeb5", "index": 4245, "step-1": "<mask token>\n\n\ndef login_required(f):\n \"\"\"\n Decorate routes to require login.\n\n http://flask.pocoo.org/docs/1.0/patterns/viewdecorators/\n \"\"\"\n\n @wraps(f)\n def decorated_function(*args, **kwargs):\...
[ 3, 4, 5, 6, 7 ]
""" Created on Feb 10, 2013 @author: jens Deprecated module for crystallogrphy related geometry operations. And a lot of other stuff that I put here. """ import numpy as np atomtable = {'H': 1, 'He': 2, 'Li': 3, 'Be': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'Ne': 10, 'Na': 11, 'Mg': 12, 'Al': 13, '...
normal
{ "blob_id": "27e685750e5caa2f80c5a6399b07435ee9aa9fb9", "index": 7936, "step-1": "<mask token>\n\n\ndef xd_element(name):\n \"\"\"\n Return the element of an atom as defined in it's label.\n \"\"\"\n try:\n name = name[:2]\n except:\n pass\n try:\n covalence_radius[name]\n ...
[ 23, 33, 40, 50, 51 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ('auth', '0001_initial'), ('c4c_app', '0006_c4cjob_complete'), ] operations = [ migrations.AlterModelOptions( ...
normal
{ "blob_id": "30986eb0a6cd82f837dd14fb383529a6a41def9a", "index": 8338, "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 = [('auth', '000...
[ 0, 1, 2, 3, 4 ]
from nltk.tokenize import sent_tokenize, word_tokenize from nltk.corpus import stopwords from nltk.stem import PorterStemmer from nltk.classify import NaiveBayesClassifier from nltk.probability import FreqDist import csv f = open('trolls.csv', 'r') file = csv.reader(f) sentences=[] remarks=[] psObject = PorterStemmer(...
normal
{ "blob_id": "0dbdd7f7adffed850f126a2054c764b421c6ab84", "index": 6799, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor kk in file:\n paragraph += kk[0]\nf.close()\n<mask token>\nprint('most commons below...')\nprint(most_common_words)\n<mask token>\nfor i, j in most_common_words:\n most_cm_1.app...
[ 0, 1, 2, 3, 4 ]
from flask import Flask, request, render_template, redirect import os import smtplib from email.message import EmailMessage app = Flask(__name__) EMAIL_ADDRESS = os.environ.get('EMAIL_USER') EMAIL_PASSWORD = os.environ.get('EMAIL_PASS') @app.route('/') def index(): return render_template('index.html') @app.rout...
normal
{ "blob_id": "27d9e6a868cfc18780ec9615e8dbc3b5ea2fd0c3", "index": 1399, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('index.html')\n\n\n@app.route('/submit', methods=['POST'])\ndef submit():\n if request.method == 'POST':\n name = request.form['name']\n e...
[ 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from machina.apps.forum_conversation.abstract_models import AbstractPost from machina.apps.forum_conversation.abstract_models import AbstractTopic from machina.core.db.models import model_factory from django.dispatch import receiver from django.db.models...
normal
{ "blob_id": "1e81e0f3cb2fb25fdef08a913aa1ff77d0c2a562", "index": 9204, "step-1": "<mask token>\n\n\nclass UserNotification(models.Model):\n user = models.ForeignKey(User, on_delete=models.CASCADE)\n notification_content = models.CharField(max_length=100)\n notification_link = models.CharField(max_length...
[ 10, 11, 12, 13, 14 ]
import numpy as np import time import uuid from datetime import datetime log_host = "agent1" class State: def __init__(self, path, iterations): self.path = path self.iterations = iterations def run(self): assert 0, "run not implemented" class BruteForceAttackState(State): def ...
normal
{ "blob_id": "cf3b4e2c76091f95d24e8a987a63ece46503d6e8", "index": 3459, "step-1": "<mask token>\n\n\nclass BruteForceAttackState(State):\n\n def run(self):\n os_val = np.random.choice(['Windows7', 'Windows10', 'Ubuntu16',\n 'MacOS10'])\n addr_val = np.random.choice(['127.0.0.6', '127.0...
[ 4, 7, 8, 9, 10 ]
def formula(a,b): if(b == 0): print "You can not divide by zero" else: return (a+b)/b print formula(4,4) print formula(2,0)
normal
{ "blob_id": "dffd575b9d5b763abdbce6f88586c183b71086c4", "index": 7701, "step-1": "def formula(a,b):\n if(b == 0):\n print \"You can not divide by zero\"\n else:\n return (a+b)/b \n\n\nprint formula(4,4)\nprint formula(2,0)\n", "step-2": null, "step-3": null, "step-4": null, "step-5": ...
[ 0 ]
import numpy as np from sklearn.decomposition import PCA import pandas as pd from numpy.testing import assert_array_almost_equal import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from sklearn import decomposition from sklearn import datasets def transform(x): if x == 'Kama': return 0 elif x =...
normal
{ "blob_id": "ef04e808a2a0e6570b28ef06784322e0b2ca1f8f", "index": 4774, "step-1": "<mask token>\n\n\ndef transform(x):\n if x == 'Kama':\n return 0\n elif x == 'Rosa':\n return 1\n else:\n return 2\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef transform(x):\n if x == 'K...
[ 1, 2, 3, 4, 5 ]
from django.test import TestCase, Client from pdf_crawler.models import Document from rest_framework.reverse import reverse class TestCase(TestCase): client = Client() def setUp(self): Document.objects.create(name='First').save() def test_endpoints(self): """ test for endpoints ...
normal
{ "blob_id": "0d28ab54f08301d9788ca9a5e46d522e043e9507", "index": 4474, "step-1": "<mask token>\n\n\nclass TestCase(TestCase):\n <mask token>\n\n def setUp(self):\n Document.objects.create(name='First').save()\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TestCase(TestCase):\n <mask t...
[ 2, 3, 4, 5 ]
# Ejercicio 28 - Hoja VI (5) - Indicar la nota ponderada según el criterio dado # (parte teórica 60%, práctica 40%) de cada uno de un número determinado de alumnos numalumnos=int(input("Introduce el número total de alumnos:\n")) print("Usa el punto '.' para los decimales") for contador in range(1,numalumnos+1): ...
normal
{ "blob_id": "f2056ff46ce6e38c3b6ca553bbdec7f59d60b198", "index": 1417, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\"Usa el punto '.' para los decimales\")\nfor contador in range(1, numalumnos + 1):\n print(f'\\nDatos del alumno número {contador} de {numalumnos}:')\n teorica = float(input(...
[ 0, 1, 2, 3 ]
version https://git-lfs.github.com/spec/v1 oid sha256:7f0b7267333e6a4a73d3df0ee7f384f7b3cb6ffb14ed2dc8a5894b853bac8957 size 1323
normal
{ "blob_id": "f1972baee8b399c9a52561c8f015f71cb9922bb0", "index": 4875, "step-1": "version https://git-lfs.github.com/spec/v1\noid sha256:7f0b7267333e6a4a73d3df0ee7f384f7b3cb6ffb14ed2dc8a5894b853bac8957\nsize 1323\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ...
[ 0 ]
# Copyright 2021 Google LLC. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
normal
{ "blob_id": "30df17d636c33d2824aad7d7ef6aae7db83615ec", "index": 8058, "step-1": "<mask token>\n\n\nclass LatestBlessedModelStrategy(resolver.ResolverStrategy):\n <mask token>\n\n def _resolve(self, input_dict: Dict[str, List[types.Artifact]],\n model_channel_key: str, model_blessing_channel_key: st...
[ 3, 4, 5, 6, 7 ]
import sys import os import numpy as np import pandas as pd import matplotlib.pyplot as plt import seaborn as sea import sklearn import glob import pydub from pydub import AudioSegment import time import librosa import noisereduce as nr from scipy.io import wavfile import IPython import sounddevice as sd from pysndfx ...
normal
{ "blob_id": "14bf4befdce4270b4514b4e643964182f9c49ff4", "index": 8434, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(IPython.display.Audio(data=my, rate=sr))\nsd.play(my, sr)\n<mask token>\n", "step-3": "<mask token>\nmy, sr = librosa.load(\n 'C:\\\\Users\\\\pranj\\\\Downloads\\\\IEMOCAP_full...
[ 0, 1, 2, 3, 4 ]
import logging def log_func(handler): if handler.get_status() < 400: log_method = logging.info elif handler.get_status() < 500: log_method = logging.warning else: log_method = logging.error request_time = 1000.0 * handler.request.request_time() log_method("%d %s %s (%s) %s ...
normal
{ "blob_id": "e403be68894ba283d71a0b71bb0bfd0adfab8c41", "index": 8684, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef log_func(handler):\n if handler.get_status() < 400:\n log_method = logging.info\n elif handler.get_status() < 500:\n log_method = logging.warning\n else:\n ...
[ 0, 1, 2, 3, 4 ]
year = int(input('西暦>')) if year % 4 == 0 and year % 100 != 0: print('閏年') pass elif year % 400 == 0: print('閏年') pass else: print('平年') pass
normal
{ "blob_id": "b381d1110e6a7570cd872d689a43aba2d2580a23", "index": 8449, "step-1": "<mask token>\n", "step-2": "<mask token>\nif year % 4 == 0 and year % 100 != 0:\n print('閏年')\n pass\nelif year % 400 == 0:\n print('閏年')\n pass\nelse:\n print('平年')\n pass\n", "step-3": "year = int(input('西暦>...
[ 0, 1, 2 ]
import logging from django.contrib.auth import get_user_model from django.db import models from rest_framework import serializers from rest_framework.test import APITestCase from ..autodocs.docs import ApiDocumentation from .utils import Deferred log = logging.getLogger(__name__) def get_serializer(endpoint, met...
normal
{ "blob_id": "04822e735c9c27f0e0fcc9727bcc38d2da84dee6", "index": 7831, "step-1": "<mask token>\n\n\nclass AutoTestCase(APITestCase):\n <mask token>\n\n @classmethod\n def setUpClass(cls):\n \"\"\"\n Создание пользователя для всех тестов, который цепляется через `settings.AUTH_USER_PK`\n\n ...
[ 6, 11, 12, 14, 16 ]
# -*- coding: utf-8 -*- import unittest import torch from pythainlp.transliterate import romanize, transliterate, pronunciate, puan from pythainlp.transliterate.ipa import trans_list, xsampa_list from pythainlp.transliterate.thai2rom import ThaiTransliterator from pythainlp.corpus import remove _BASIC_TESTS = { ...
normal
{ "blob_id": "486cfc4bb4b46d78715b11cba44656e8ba077c9b", "index": 2551, "step-1": "<mask token>\n\n\nclass TestTransliteratePackage(unittest.TestCase):\n <mask token>\n\n def test_romanize_royin_basic(self):\n for word in _BASIC_TESTS:\n expect = _BASIC_TESTS[word]\n self.assert...
[ 6, 8, 10, 11, 12 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/6/20 下午4:00 # @Author : Huang HUi # @Site : # @File : query_parse.py # @Software: PyCharm from mysqlConnection import mysqlConnection import yaml import copy import time import csv import json from collections import OrderedDict import ast # # GIV...
normal
{ "blob_id": "b52807a15cef8f07f685f8761a470d4a24d9c3dc", "index": 6603, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef query_parse(GIVEN_QUERY):\n try:\n countryIds_query = list(map(lambda x: x['country_id'], GIVEN_QUERY[\n 'countries']))\n except:\n countryIds_query...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import urllib class LicenseChecker( object ): def __init__( self ): self.url = 'http://logon.guidoaccardo.com.ar/' self.count_offline = 15 def __countTimes( self ): ff = open( 'times.ehead', 'r' ) bb = ff.read() ff.close() return int( bb ) ...
normal
{ "blob_id": "c70aa1a373530ac73553753e62d3989f5bc79287", "index": 687, "step-1": "<mask token>\n\n\nclass LicenseChecker(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass LicenseChecker(object):\n <mask token>\n <mask token>\n\n def ...
[ 1, 3, 5, 6, 7 ]
from dbmanager import DbManager from message import Message def list_returner(f): def wrapper(*args, **kwargs): result = f(*args, **kwargs) if result: return result else: return [dict()] return wrapper class Messenger: def __init__(self, messages_count=2...
normal
{ "blob_id": "4d1ea6522a01603f0159a1f27da70b65c4f387cb", "index": 7093, "step-1": "<mask token>\n\n\nclass Messenger:\n <mask token>\n\n def add_message(self, message):\n self.message_manager.add(message)\n\n @list_returner\n def get_room_messages(self):\n messages = []\n i = 6\n ...
[ 5, 7, 8, 9 ]
import unittest from game_of_life.board import Board from game_of_life.cell import Cell, ALIVE, DEAD def create_test_board(size): board = Board(size) board[0, 0].state = ALIVE board[0, 1].state = ALIVE board[2, 1].state = ALIVE return board class BoardTests(unittest.TestCase): def test_get_n...
normal
{ "blob_id": "f644ff322d1268092dbdcbfc1a3c76006424184b", "index": 1482, "step-1": "<mask token>\n\n\nclass BoardTests(unittest.TestCase):\n\n def test_get_neighbours(self):\n board = create_test_board(3)\n self.assertListEqual(board.get_neighbour_states(1, 0), [None, None,\n ALIVE, ALI...
[ 10, 11, 14, 15, 16 ]
#Kivy + Box2d test #Not working... from Box2D import * from random import random from kivy.app import App from kivy.uix.widget import Widget from kivy.properties import NumericProperty, ObjectProperty from kivy.lang import Builder from kivy.clock import Clock Builder.load_string(''' <PongBall>: canvas: C...
normal
{ "blob_id": "fa8431ae96cd6c1133d56285d0168f43d9068bc5", "index": 2099, "step-1": "<mask token>\n\n\nclass PongBall(Widget):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, **kwargs):\n super(PongBall, self).__init__(**kwargs)\n sel...
[ 8, 12, 13, 15, 16 ]
import sys lines = sys.stdin.readlines() t = int(lines[0]) for i in range(t): c = i*10+1 n = int(lines[c]) - 1 first = [x.strip() for x in [ lines[c+1], lines[c+2], lines[c+3], lines[c+4]]] first = [s.split() for s in first] m = int(lines[c+5]) - 1 second = [x....
normal
{ "blob_id": "d6bc8afcdb7636085b01add860f808024fbe566d", "index": 2428, "step-1": "import sys\n\nlines = sys.stdin.readlines()\n\nt = int(lines[0])\n\nfor i in range(t):\n c = i*10+1\n n = int(lines[c]) - 1\n first = [x.strip() for x in [\n lines[c+1],\n lines[c+2],\n lines[c+3],\n ...
[ 0 ]
from rest_framework import serializers from . import models class RaumSerializer(serializers.ModelSerializer): class Meta: model = models.Raum fields = [ "Raumnummer", "Anzahl_Sitzplaetze", "Beamer", "Whiteboard", ] class ZeitraumSerialize...
normal
{ "blob_id": "451c353a949458f5f71783c4aba1888c40018bfa", "index": 9400, "step-1": "<mask token>\n\n\nclass RaumbelegungSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = models.Raumbelegung\n fields = ['Belegt', 'Belegungsgrund']\n", "step-2": "<mask token>\n\n\nclass Zeitraum...
[ 1, 2, 3, 4, 5 ]
import xl2dict myxlobject= XlToDict() myxlobject.convert_sheet_to_dict(file_path="Soul Breaks.xlsx", sheet="First Sheet", filter_variables_dict={"User Type" : "Admin", "Environment" : "Dev"})
normal
{ "blob_id": "8ec981bf8746e09d3865bc20dcfbf2fbd797c145", "index": 7511, "step-1": "<mask token>\n", "step-2": "<mask token>\nmyxlobject.convert_sheet_to_dict(file_path='Soul Breaks.xlsx', sheet=\n 'First Sheet', filter_variables_dict={'User Type': 'Admin',\n 'Environment': 'Dev'})\n", "step-3": "<mask t...
[ 0, 1, 2, 3, 4 ]
# # -*- coding: utf-8 -*- # # """ # Py40 PyQt5 tutorial # # This example shows three labels on a window # using absolute positioning. # # author: Jan Bodnar # website: py40.com # last edited: January 2015 # """ # # import sys # from PyQt5.QtWidgets import QWidget, QLabel, QApplication # # # class Example(QWidget): # # ...
normal
{ "blob_id": "e05dac901228e6972c1cb48ce2def3d248b4c167", "index": 3053, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef absent(lectureid, sectionid):\n connection = psycopg2.connect(database='profmate', user='python',\n password='python', host='34.74.217.167', port='5432')\n cursor = c...
[ 0, 1, 2, 3, 4 ]
import glob import csv import math import pandas # this is used to train the model, try different model, generate the csv file of the result import pandas import pandas as pd import pickle from sklearn.linear_model import LogisticRegression from sklearn import metrics from sklearn import datasets from sklearn.prepro...
normal
{ "blob_id": "a92384a6abee9e231092ee0e4dbdb60bafcc9979", "index": 8782, "step-1": "<mask token>\n\n\ndef naiveBayes(X_train, y_train):\n model = GaussianNB()\n model = model.fit(X_train, y_train)\n return model\n\n\ndef knn(X_train, y_train):\n model = KNeighborsClassifier()\n model = model.fit(X_t...
[ 13, 14, 16, 17, 21 ]
# coding: utf-8 import datetime import json import requests import os import re import sys from todoist.api import TodoistAPI #SLACK_CHANNEL = os.environ['SLACK_CHANNEL'] #SLACK_POSTURL = os.environ['SLACK_POSTURL'] TDIAPI = TodoistAPI(os.environ['TODOISTAPITOKEN'], cache=False) TDIAPI.sync() name = os.environ['TODOI...
normal
{ "blob_id": "3c3d45f0844496b8d623286b36a4935a154f410a", "index": 4133, "step-1": "<mask token>\n\n\ndef lambda_handler(event, context):\n if event['function'] == 'tasklist':\n msg = tasklist(name)\n if event['function'] == 'activity':\n msg = activity(name)\n return\n\n\n<mask token>\n\n\n...
[ 3, 5, 6, 7, 8 ]
import matplotlib.pyplot as plt import numpy as np import random plt.ion() def draw_board(grid_size, hole_pos,wall_pos): board = np.ones((grid_size,grid_size)) board[wall_pos] = 10 board[hole_pos] = 0 return board class Game(): """ A class which implements the Gobble game. Initializes with a ...
normal
{ "blob_id": "a74f2050a057f579a8a8b77ac04ef09073cdb6cf", "index": 6057, "step-1": "<mask token>\n\n\nclass Game:\n <mask token>\n\n def __init__(self, grid_size):\n self.grid_size = grid_size\n self.start_game(grid_size)\n plt.title(\"Nate's Lame Game\")\n\n def start_game(self, grid...
[ 8, 9, 10, 12, 13 ]
"""Primer3 input form. For details on input params see: https://primer3.org/manual.html#globalTags """ from django import forms from django.core.exceptions import ValidationError from .fasta import Fasta class PrimerForm(forms.Form): """Collect user input to run primer prediction.""" fasta = forms.CharFie...
normal
{ "blob_id": "6291375738db7914d551f9a1c6d2897b7d236b87", "index": 1742, "step-1": "<mask token>\n\n\nclass PrimerForm(forms.Form):\n <mask token>\n fasta = forms.CharField(initial='')\n primer_min = forms.IntegerField(initial=18, max_value=35)\n primer_max = forms.IntegerField(initial=27, max_value=35...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python """\ Simple g-code streaming script for grbl """ import serial import time import csv import json import RPi.GPIO as GPIO from multiprocessing import Process, Queue class motion(): def __init__(self): # Open grbl serial port #self.s = serial.Serial("/dev/ttyUSB0",baudrate=115...
normal
{ "blob_id": "ac2d4372f8913ea9ae1066833cca09985e521f99", "index": 383, "step-1": "#!/usr/bin/env python\n\"\"\"\\\nSimple g-code streaming script for grbl\n\"\"\"\n \nimport serial\nimport time\nimport csv\nimport json\nimport RPi.GPIO as GPIO\nfrom multiprocessing import Process, Queue\nclass motion():\n def ...
[ 0 ]
import math from Config import defaults as df from Utils.controls import sigmoid_decay def f1(phi, phi_o, d): """sinusoidally growing function between (phi_o-d) to phi_o""" return 1 - sigmoid_decay(phi, phi_o, d) def f2(phi, sigma): """normal distribution""" return math.exp(-phi ** 2 / sigma ** 2) ...
normal
{ "blob_id": "19bb3cd0c7862f39a78479d9a9703ebef198fc73", "index": 3677, "step-1": "<mask token>\n\n\ndef f1(phi, phi_o, d):\n \"\"\"sinusoidally growing function between (phi_o-d) to phi_o\"\"\"\n return 1 - sigmoid_decay(phi, phi_o, d)\n\n\ndef f2(phi, sigma):\n \"\"\"normal distribution\"\"\"\n retu...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- """ Created on Wed Dec 20 09:54:08 2017 @author: chuang """ import os import pickle #from collections import Counter #import user_replace import jieba import re from multiprocessing import Pool #%% # parameters for processing the dataset DATA_PATH = '../data/weibo_single...
normal
{ "blob_id": "5fd54de3b2f9c2e18a283d016fc16e0e622dc6a0", "index": 8415, "step-1": "<mask token>\n\n\ndef replace_tokens(text, replace_dict=None):\n pattern = re.compile('|'.join(DELETE))\n text = re.sub(pattern, '', text)\n return text\n\n\ndef read_txt(file_path, encoding):\n with open(os.path.join(D...
[ 6, 7, 10, 11, 12 ]
#=============================================================================== # @author: Daniel V. Stankevich # @organization: RMIT, School of Computer Science, 2012 # # # This package contains representations of the following models: # 'Particle' - an atomic element # 'Swarm' - a set of p...
normal
{ "blob_id": "5c06229f8e80a7225620f25941cc5276a9021e53", "index": 5353, "step-1": "<mask token>\n\n\nclass SwarmModel:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass NeighbourhoodModel:\n _particles = []\n _bestPosition = None\n _bestPositionFitness =...
[ 10, 11, 12, 15, 16 ]
from utilities import SumOneToN, RSS, MSE, R2Score import numpy as np import scipy.stats as st class RidgeLinearModel: covariance_matrix = None # covariance matrix of the model coefficients covariance_matrix_updated = False beta = None # coefficients of the modelfunction var_vector = None var_vecto...
normal
{ "blob_id": "a5dcc66ece4e58995fe86c3a399c45975a596b1a", "index": 5836, "step-1": "<mask token>\n\n\nclass RidgeLinearModel:\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 <mas...
[ 6, 10, 11, 12, 13 ]
import qrcode def generate_qr(query): img = qrcode.make(query)
normal
{ "blob_id": "e97bcf31657317f33f4a138ede80bb9171337f52", "index": 4730, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_qr(query):\n img = qrcode.make(query)\n", "step-3": "import qrcode\n\n\ndef generate_qr(query):\n img = qrcode.make(query)\n", "step-4": null, "step-5": null,...
[ 0, 1, 2 ]
import platform, sys, os, ensurepip ensurepip.bootstrap() try: import pip except ImportError: print("Error: Failed to install pip, make sure you are running this script as admin.") sys.exit() arch = platform.architecture()[0] wheelUrl = "https://raw.githubusercontent.com/Starfox64/pygame-installer/master/wheels...
normal
{ "blob_id": "b44f75db652b3a40cd9475bfe44027724e845252", "index": 1146, "step-1": "<mask token>\n", "step-2": "<mask token>\nensurepip.bootstrap()\ntry:\n import pip\nexcept ImportError:\n print(\n 'Error: Failed to install pip, make sure you are running this script as admin.'\n )\n sys.e...
[ 0, 1, 2, 3, 4 ]
import torch import torch_scatter import torchgraphs as tg import textwrap from . import autograd_tricks as lrp def patch(): torch.add = lrp.add torch.cat = lrp.cat torch.index_select = lrp.index_select tg.utils.repeat_tensor = lrp.repeat_tensor torch_scatter.scatter_add = lrp.scatter_add torc...
normal
{ "blob_id": "faafc7cfd900d3f6fd6df30af5580f71eecfb279", "index": 8298, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef computational_graph(op):\n if op is None:\n return 'None'\n res = f'{op.__class__.__name__} at {hex(id(op))}:'\n if op.__class__.__name__ == 'AccumulateGrad':\n ...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.2 on 2016-02-07 23:42 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('events', '0005_auto_20160207_1529'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "ab3609c27fa002d79735c5d5c09ec7a52fedd040", "index": 3484, "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 = [('events', '0...
[ 0, 1, 2, 3, 4 ]
import pandas as pd import numpy as np class LabeledArray: @staticmethod def get_label_for_indexes_upto(input_data, input_label, input_index): df_input_data = pd.DataFrame(input_data) df_labels = pd.DataFrame(input_label) df_data_labels = pd.concat([df_input_data, df_labels], axis=1) ...
normal
{ "blob_id": "0dea8675d8050a91c284a13bcbce6fd0943b604e", "index": 5135, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LabeledArray:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LabeledArray:\n\n @staticmethod\n def get_label_for_indexes_upto(input_data, input_label, input_in...
[ 0, 1, 2, 3 ]
from abc import abstractmethod from anoncreds.protocol.repo.public_repo import PublicRepo from anoncreds.protocol.types import ClaimDefinition, PublicKey, SecretKey, ID, \ RevocationPublicKey, AccumulatorPublicKey, Accumulator, TailsType, \ RevocationSecretKey, AccumulatorSecretKey, \ TimestampType from an...
normal
{ "blob_id": "890841c8892e89375bb022f0d469fefc27414a2b", "index": 5823, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass IssuerWalletInMemory(IssuerWallet, WalletInMemory):\n\n def __init__(self, claimDefId, repo: PublicRepo):\n WalletInMemory.__init__(self, claimDefId, repo)\n se...
[ 0, 2, 4, 5, 6 ]
""" AlbumInfo-related frames for the Album view. """ from __future__ import annotations import logging from typing import TYPE_CHECKING, Iterator, Collection, Any from ds_tools.caching.decorators import cached_property from tk_gui.elements import Element, HorizontalSeparator, Multiline, Text, Input, Image, Spacer fr...
normal
{ "blob_id": "384588e1a767081191228db2afa4a489f967a220", "index": 3952, "step-1": "\"\"\"\nAlbumInfo-related frames for the Album view.\n\"\"\"\n\nfrom __future__ import annotations\n\nimport logging\nfrom typing import TYPE_CHECKING, Iterator, Collection, Any\n\nfrom ds_tools.caching.decorators import cached_pro...
[ 0 ]
import urllib.request username = '' link = r'https://www.instagram.com/' + username html = urllib.request.urlopen(link) print(html.read())
normal
{ "blob_id": "db93de33f537eeaf64ca8e2b2b79aba1f592305b", "index": 5434, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(html.read())\n", "step-3": "<mask token>\nusername = ''\nlink = 'https://www.instagram.com/' + username\nhtml = urllib.request.urlopen(link)\nprint(html.read())\n", "step-4": "i...
[ 0, 1, 2, 3, 4 ]
print('Welcome aboard, Oleksij!')
normal
{ "blob_id": "2b1ec29d665aa93cd53644b62efcd1305b34e13e", "index": 2636, "step-1": "<mask token>\n", "step-2": "print('Welcome aboard, Oleksij!')\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
from app import app from flask import request @app.route('/') @app.route('/index') def index(): return 'Hello world' @app.route('/api_post', methods=['POST']) def postJsonHandler(): print(request.is_json) content = request.get_json() print(content) return 'JSON posted'
normal
{ "blob_id": "9d8c4bf9f9279d5e30d0e9742cdd31713e5f4b9e", "index": 2104, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\n@app.route('/index')\ndef index():\n return 'Hello world'\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\n@app.route('/')\n@app.route('/index')\ndef index():\...
[ 0, 1, 2, 3 ]
# este script comprar diferente metodos de base2number from sklearn.model_selection import KFold from sklearn.model_selection import train_test_split #from matplotlib import pyplot as plt #from matplotlib import cm import matplotlib.pyplot as plt from matplotlib import pyplot import math import os import sys import ...
normal
{ "blob_id": "9696e5799d46adb5b92c0900e2064b927addfd93", "index": 2506, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor sequence_file in sequences:\n f_in = open(current_dir + '/sample_genomes/' + sequence_file, 'r')\n f_out.write(f_in.read())\n f_in.close()\n data = []\n fa_file = curre...
[ 0, 1, 2, 3, 4 ]
""" Physical units and dimensions """ from sympy import * from sympy.core.basic import Atom from sympy.core.methods import ArithMeths, RelMeths class Unit(Atom, RelMeths, ArithMeths): is_positive = True # make (m**2)**Rational(1,2) --> m is_commutative = True def __init__(self, name, a...
normal
{ "blob_id": "c0e1c0c4545777a669fac19900239ab9baade242", "index": 5993, "step-1": "<mask token>\n\n\nclass Unit(Atom, RelMeths, ArithMeths):\n is_positive = True\n is_commutative = True\n\n def __init__(self, name, abbrev):\n self.name = name\n self.abbrev = abbrev\n\n def tostr(self, le...
[ 5, 6, 7, 9, 10 ]
from random import randrange import random """ both user and computer funcs: """ def check_ok(boat, taken_positions): # input: boat, taken_positions # this func checks if the boat outside the playground or the position of the boat is already in taken_position # return: boat. boat will returned as [-1] or its...
normal
{ "blob_id": "95584dfdb232be7f507dc9d29ed2f1d95fa2b653", "index": 9642, "step-1": "<mask token>\n\n\ndef check_ok(boat, taken_positions):\n boat.sort()\n for i in range(len(boat)):\n if boat[i] in taken_positions:\n boat = [-1]\n break\n elif boat[i] > 99 or boat[i] < 0:\...
[ 7, 10, 11, 12, 16 ]
import os import string filenames = os.listdir('data/SENTIMENT_test') filenames.sort() outfile = open('sentiment_test.txt', 'w') remove_punctuation_map = dict((ord(char), None) for char in string.punctuation) for filename in filenames: infile = open('data/SENTIMENT_test/' + filename, errors='ignore') infiletext...
normal
{ "blob_id": "6434e427c9015544985a38104cffeaa10866b9ea", "index": 4585, "step-1": "<mask token>\n", "step-2": "<mask token>\nfilenames.sort()\n<mask token>\nfor filename in filenames:\n infile = open('data/SENTIMENT_test/' + filename, errors='ignore')\n infiletext = infile.read()\n infiletext = infilet...
[ 0, 1, 2, 3 ]
from bs4 import BeautifulSoup import re class Rules: def __init__(self): self.ruleCollection = { "1" : self.rule1, "2" : self.rule2, "3" : self.rule3, "4" : self.rule4, "5" : self.rule5, "6" : self.rule6, "7" : self.rule7, "8" : self.r...
normal
{ "blob_id": "7747cbb1a1ed191b616b0d1bcfd51cdea05067f5", "index": 5954, "step-1": "<mask token>\n\n\nclass Rules:\n\n def __init__(self):\n self.ruleCollection = {'1': self.rule1, '2': self.rule2, '3': self.\n rule3, '4': self.rule4, '5': self.rule5, '6': self.rule6, '7':\n self.ru...
[ 8, 11, 13, 14, 17 ]
print('-' * 60) print( 'Welcome to CLUB425, the most lit club in downtown ACTvF. Before you can enter, I need you yo answer some question...' ) print() age = input('What is your age today? ') age = int(age) if age >= 21: print('Cool, come on in.') else: print( 'Your gonna need to back up. This c...
normal
{ "blob_id": "19ffac718008c7c9279fb8cbc7608597d2d3e708", "index": 3937, "step-1": "<mask token>\n", "step-2": "print('-' * 60)\nprint(\n 'Welcome to CLUB425, the most lit club in downtown ACTvF. Before you can enter, I need you yo answer some question...'\n )\nprint()\n<mask token>\nif age >= 21:\n pri...
[ 0, 1, 2 ]
import random def Fun_hiraganas(): hiraganas = ['a', 'i', 'u', 'e', 'o', 'ka', 'ki', 'ku', 'ke', 'ko', 'sa', 'shi', 'su', 'se', 'so', 'ta', 'chi', 'tsu', 'te', 'to', 'na', 'ni', 'nu', 'ne', 'no', 'ha', 'hi', 'fu', 'he', 'ho'] print("escriba el hiragana", hiraganas[random.randint(0, len(hiraganas)-1)]) print("Hell...
normal
{ "blob_id": "1fe7d5db1b47ba082301d07d010c6796fbd7edb7", "index": 6859, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Fun_hiraganas():\n hiraganas = ['a', 'i', 'u', 'e', 'o', 'ka', 'ki', 'ku', 'ke', 'ko',\n 'sa', 'shi', 'su', 'se', 'so', 'ta', 'chi', 'tsu', 'te', 'to', 'na',\n 'n...
[ 0, 2, 3, 4, 5 ]
from django.contrib.auth.decorators import login_required from django.shortcuts import render from orders.models import Setting def search(request): return render(request, 'ui/search.html') def search_printed(request): print_url = '' setting = Setting.objects.filter(name='printer').first() if settin...
normal
{ "blob_id": "f16d43d9dfb3e9b9589fa92eb82aaa4c73fe48cd", "index": 1264, "step-1": "<mask token>\n\n\ndef search(request):\n return render(request, 'ui/search.html')\n\n\ndef search_printed(request):\n print_url = ''\n setting = Setting.objects.filter(name='printer').first()\n if setting != None:\n ...
[ 2, 3, 4, 5 ]
#Eyal Reis - 203249354 from view import View def main(): """ primary game method """ view = View() view.root.mainloop() if __name__ == "__main__": main()
normal
{ "blob_id": "640eae824e43e394bf0624dd4cf7dcec78f43604", "index": 4947, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n \"\"\"\n primary game method\n \"\"\"\n view = View()\n view.root.mainloop()\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef main():\n \"\"\"\...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Sun Oct 4 12:14:16 2020 @author: mdevasish """ import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression,Lasso,Ridge from sklearn.metrics import mean_squared_error,mean_absolute_error from sklearn.model_selection import train_test_split import job...
normal
{ "blob_id": "f07b95a3b18aecf6cadaa8398c9158a7cd10aeeb", "index": 7101, "step-1": "<mask token>\n\n\nclass model_construction:\n <mask token>\n\n def implement_model(self, filename):\n \"\"\"\n Method inside the model_construction class, used for implementing the model\n and return feat...
[ 2, 3, 4, 5, 7 ]
# Generated by Django 3.2.2 on 2021-05-11 09:49 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('meeting', '0004_auto_20210511_0947'), ] operations = [ migrations.AlterField( model_name='event', name='end', ...
normal
{ "blob_id": "1c1cd0eeea4dbf446aa4582f42ef1f3b5a4e8875", "index": 7452, "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 = [('meeting', '...
[ 0, 1, 2, 3, 4 ]
# Pass Function def hello_func(): pass hello_func() print(hello_func()) def hello_func(): hello_func() print(hello_func) # Function allows to reuse ,without repeat def hello_func(): print('hello function!') hello_func()
normal
{ "blob_id": "94a0b341aac3683712578b31e98a0a5a6a643b57", "index": 7646, "step-1": "def hello_func():\n pass\n\n\n<mask token>\n", "step-2": "def hello_func():\n pass\n\n\n<mask token>\n\n\ndef hello_func():\n print('hello function!')\n hello_func()\n", "step-3": "def hello_func():\n pass\n\n\n<...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ @Author: xiezizhe @Date: 5/7/2020 下午8:52 """ from typing import List class KMP: def partial(self, pattern): """ Calculate partial match table: String -> [Int]""" ret = [0] for i in range(1, len(pattern)): j = ret[i - 1] while j > 0 and...
normal
{ "blob_id": "57de9a46dfbf33b117c2dfbb534a5020e019d520", "index": 8513, "step-1": "<mask token>\n\n\nclass Trie:\n\n def __init__(self):\n self.dicts = dict()\n\n def add(self, word):\n node = self.dicts\n for w in word:\n if w not in node:\n node[w] = dict()\n...
[ 5, 7, 8, 10, 12 ]
from django.conf.urls import url from .views.show import show_article, show_articles, export_db urlpatterns = [ url(r'^$', show_articles, name='index'), url(r'^article/$', show_article, name='article'), url(r'^export/$', export_db, name='article'), ]
normal
{ "blob_id": "9fdc7c1eb68a92451d41313861164a915b85fcee", "index": 8988, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^$', show_articles, name='index'), url('^article/$',\n show_article, name='article'), url('^export/$', export_db, name='article')]\n", "step-3": "from django.conf...
[ 0, 1, 2, 3 ]