code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
import os import json import pathlib from gql import gql, Client from gql.transport.aiohttp import AIOHTTPTransport # Select your transport with a defined url endpoint transport = AIOHTTPTransport(url="https://public-api.nbatopshot.com/graphql") # Create a GraphQL client using the defined transport client = Client(tr...
normal
{ "blob_id": "df518fd719b7eafffd8fee92c926d4d24b65ce18", "index": 7877, "step-1": "<mask token>\n", "step-2": "<mask token>\npathlib.Path(DIR).mkdir(parents=True, exist_ok=True)\nprint('--------Query Topshot GraphQL Endpoint--------')\nfor setsId in setsIdList:\n for setId in setsId:\n count += 1\n ...
[ 0, 1, 2, 3, 4 ]
""" Class implementing ReportGenerator """ from urllib.parse import urlparse import requests from src.classes.reporter.flag import Flag from src.classes.reporter.line_finder import LineFinder class ReportGenerator(object): """ Class designed to generate reports after CSP audition The ReportGenerator cla...
normal
{ "blob_id": "2003060f7793de678b4a259ad9424cd5927a57f7", "index": 3167, "step-1": "<mask token>\n\n\nclass ReportGenerator(object):\n <mask token>\n <mask token>\n\n def run(self, html, url):\n print('[#] Running the report generator')\n self.html = html\n self.getting_flags_location...
[ 8, 13, 14, 15, 17 ]
print ("Welcome to the Guessing Game 2.0\n") print ("1 = Easy\t(1 - 10)") print ("2 = Medium\t(1 - 50)") print ("3 = Hard\t(1 - 100)") # Player: Input user's choice # while: Check if user enters 1 or 2 or 3 # CPU: Generate a random number # Player: Input user's number # Variable: Add a variable 'attempt...
normal
{ "blob_id": "7f2489aa440441568af153b231420aa2736716ca", "index": 4052, "step-1": "<mask token>\n", "step-2": "print('Welcome to the Guessing Game 2.0\\n')\nprint('1 = Easy\\t(1 - 10)')\nprint('2 = Medium\\t(1 - 50)')\nprint('3 = Hard\\t(1 - 100)')\n", "step-3": "print (\"Welcome to the Guessing Game 2.0\\n\"...
[ 0, 1, 2 ]
# Generated by Django 3.0.5 on 2020-04-23 11:23 from django.conf import settings from django.db import migrations class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ('review', '0002_auto_20200419_1409'), ] operations = [ ...
normal
{ "blob_id": "8471e6a3b6623236740ad5219e5038a64e0c0056", "index": 2083, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
import fs gInfo = { 'obj': g2.go(capUrl), 'Headers-C-T': g2.response.headers['Content-Type'], 'url': g2.response.url, 'urlDetails': g2.response.url_details() } capHtml = capHtml = gInfo['obj'].unicode_body(ignore_errors=True, fix_special_entities=True) b64cap = re.findall(r'base64,(.*?)\\" id=', capHtml, re.DO...
normal
{ "blob_id": "2a5f69fbb26bd1f94c10ff0da687391bf5bd3c23", "index": 6054, "step-1": "<mask token>\n", "step-2": "<mask token>\nsavecaptcha.write(b64cap[0])\nsavecaptcha.close()\n<mask token>\nf.close()\n<mask token>\nfincapfile.close()\n", "step-3": "<mask token>\ngInfo = {'obj': g2.go(capUrl), 'Headers-C-T': g...
[ 0, 1, 2, 3, 4 ]
from numpy import array, sum def comp_point_ref(self, is_set=False): """Compute the point ref of the Surface Parameters ---------- self : SurfLine A SurfLine object is_set: bool True to update the point_ref property Returns ------- point_ref : complex the refe...
normal
{ "blob_id": "b7721e95cfb509a7c0c6ccdffa3a8ca2c6bd6033", "index": 6713, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef comp_point_ref(self, is_set=False):\n \"\"\"Compute the point ref of the Surface\n\n Parameters\n ----------\n self : SurfLine\n A SurfLine object\n is_set: ...
[ 0, 1, 2 ]
''' Converts luptitudes to maggies and stores in folder output Written by P. Gallardo ''' import numpy as np import pandas as pd import sys assert len(sys.argv) == 2 # usage: lups2maggies.py /path/to/cat.csv fname = sys.argv[1] print("Converting maggies from catalog \n%s" % fname) df = pd.read_csv(fname) z = d...
normal
{ "blob_id": "e8971b3d183ded99a5fc03f031ef807280b8cc7f", "index": 1744, "step-1": "<mask token>\n", "step-2": "<mask token>\nassert len(sys.argv) == 2\n<mask token>\nprint(\"\"\"Converting maggies from catalog \n%s\"\"\" % fname)\n<mask token>\nnp.savetxt('./output/maggies.txt', to_exp)\n", "step-3": "<mask t...
[ 0, 1, 2, 3, 4 ]
g#https://www.acmicpc.net/problem/9461 ''' 1. Divide 2 case △ and ▽ d[0] is △ sequence d[1] is ▽ sequence 2. find a role between d[0] and d[1] ''' import math t = int(input()) n = [] for _ in range(t): n.append(int(input())) index = math.ceil(max(n)/2) d = [[0 for _ in range(52)] for _ in range(2)] d[0][1],d[0][2],...
normal
{ "blob_id": "524b6ebd0be4c2285fac540627bb48baca71452e", "index": 2989, "step-1": "<mask token>\n", "step-2": "g\n<mask token>\nfor _ in range(t):\n n.append(int(input()))\n<mask token>\nfor i in range(3, index + 1):\n d[0][i] = d[1][i - 1] + d[1][i - 3]\n d[1][i] = d[0][i] + d[0][i - 2]\nfor k in n:\n...
[ 0, 1, 2, 3, 4 ]
from django.db import models from django.contrib.auth.models import AbstractUser from django.db.models import Max from django.core.validators import RegexValidator from django.utils import timezone class User(AbstractUser): is_developer = models.BooleanField('developer status', default=False) is_marketing = mo...
normal
{ "blob_id": "94e9e7c4c09c8c4de4c8f2649707a949d5f5f856", "index": 7836, "step-1": "<mask token>\n\n\nclass Location(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\n...
[ 38, 40, 46, 50, 55 ]
from . import resources from jsonschema import validate from jsonschema.exceptions import ValidationError import aiohttp_client import importlib.resources as pkg_resources import json import logging log = logging.getLogger("amplitude-client") API_URL = "https://api.amplitude.com/2/httpapi" class AmplitudeLogger: ...
normal
{ "blob_id": "d32f009f373249b7b602ac36f29982273a2ed192", "index": 2289, "step-1": "<mask token>\n\n\nclass AmplitudeLogger:\n <mask token>\n\n async def log_event(self, event):\n event = {'api_key': self.api_key, 'events': [event]}\n try:\n validate(instance=event, schema=self.api_s...
[ 1, 2, 3, 4, 5 ]
#! /usr/bin/env python # -*- coding: utf-8 -*- from __future__ import division import os from solid import * from solid.utils import * from shapes import * import sys # Assumes SolidPython is in site-packages or elsewhwere in sys.path from solid import * from solid.utils import * def voxels(): # shape = cube([1,...
normal
{ "blob_id": "27ca60435c614e4d748917da45fc2fc75ee59f1c", "index": 1682, "step-1": "<mask token>\n\n\ndef voxels():\n shape = []\n for x in range(-5, 4, 1):\n for y in range(-5, 4, 1):\n for z in range(0, 10, 1):\n translate([x, y, z])\n new_cube = color([0, 0,...
[ 2, 3, 4, 5, 6 ]
from django.apps import AppConfig class AdminrequestsConfig(AppConfig): name = 'adminRequests'
normal
{ "blob_id": "e08b7a96c957895068e584a0564f02c52acd48ec", "index": 3753, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AdminrequestsConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AdminrequestsConfig(AppConfig):\n name = 'adminRequests'\n", "step-4": "from djan...
[ 0, 1, 2, 3 ]
from django.db import models from django.contrib.contenttypes.models import ContentType from widgy.generic import ProxyGenericForeignKey, ProxyGenericRelation from django.contrib.contenttypes.generic import GenericForeignKey, GenericRelation class Base(models.Model): content_type = models.ForeignKey(ContentType)...
normal
{ "blob_id": "c70df1fab0db6f71d22a23836b11d66879879656", "index": 6336, "step-1": "<mask token>\n\n\nclass Related(models.Model):\n <mask token>\n <mask token>\n\n\nclass AbstractModel(models.Model):\n bases = ProxyGenericRelation(Base, content_type_field='content_type',\n object_id_field='content...
[ 6, 7, 8, 9, 11 ]
#!/usr/bin/python """ Created on Aug 1 2014 """ import rospy def my_callback(event): print 'Timer called at ' + str(event.current_real) if __name__ == '__main__': rospy.init_node('timer') rospy.Timer(rospy.Duration(2), my_callback) rospy.spin()
normal
{ "blob_id": "4e61f9fefe8e6b5203ba05ac9bd626db1102df36", "index": 122, "step-1": "#!/usr/bin/python\n\"\"\"\nCreated on Aug 1 2014\n\n\"\"\"\n\nimport rospy\ndef my_callback(event):\n print 'Timer called at ' + str(event.current_real)\n\nif __name__ == '__main__':\n rospy.init_node('timer')\n\n rospy.Ti...
[ 0 ]
""""Module for miscellaneous behavior stuff For example, stuff like extracting lick times or choice times. TrialSpeak shouldn't depend on stuff like that. # Also get the pldf and use that to get lick times ldf = ArduFSM.TrialSpeak.read_logfile_into_df(bdf.loc[idx, 'filename']) # Get the lick times ...
normal
{ "blob_id": "78761eda403ad8f54187e5858a23c23d3dd79b09", "index": 8821, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_choice_times(behavior_filename, verbose=False):\n \"\"\"Calculates the choice time for each trial in the logfile\"\"\"\n state_num2names = MCwatch.behavior.db.get_state_...
[ 0, 1, 2, 3, 4 ]
from lib import gen, core Shellcode = gen.Varname_Creator() Hide_Window = gen.Varname_Creator() def Start(): Start_Code = "#include <windows.h>\n" Start_Code += "#include <tlhelp32.h>\n" Start_Code += "#include <stdio.h>\n" Start_Code += "#include <stdlib.h>\n" Start_Code += "#include <string....
normal
{ "blob_id": "e9b9f87a18a5788ac86b1e85c0f3d7858946e03a", "index": 2999, "step-1": "<mask token>\n\n\ndef Start():\n Start_Code = '#include <windows.h>\\n'\n Start_Code += '#include <tlhelp32.h>\\n'\n Start_Code += '#include <stdio.h>\\n'\n Start_Code += '#include <stdlib.h>\\n'\n Start_Code += '#in...
[ 4, 5, 6, 7, 8 ]
from z3 import * import re dna = re.compile("dna_(\d+)") opt = Optimize() opt.from_file("../benchmarks/bench.smt2") set_option("sat.random_seed",23) def get_soft(soft): return [f.arg(0) for f in soft.children()] def free_vars(fs): seen = set([]) vars = set([]) def fv(seen, vars, f): if f in...
normal
{ "blob_id": "c0d8f2542f9cf9a5097011c61c90073c031d2708", "index": 9831, "step-1": "<mask token>\n\n\ndef get_soft(soft):\n return [f.arg(0) for f in soft.children()]\n\n\ndef free_vars(fs):\n seen = set([])\n vars = set([])\n\n def fv(seen, vars, f):\n if f in seen:\n return\n ...
[ 7, 8, 9, 10, 11 ]
from numpy.testing import assert_almost_equal from fastats.maths.norm_cdf import norm_cdf def test_norm_cdf_basic_sanity(): assert_almost_equal(0.5, norm_cdf(0.0, 0, 1)) def test_norm_cdf_dartmouth(): """ Examples taken from: https://math.dartmouth.edu/archive/m20f12/public_html/matlabnormal sto...
normal
{ "blob_id": "0229783467b8bcd0361baf6be07e3261f34220c7", "index": 6581, "step-1": "<mask token>\n\n\ndef test_norm_cdf_dartmouth():\n \"\"\"\n Examples taken from:\n https://math.dartmouth.edu/archive/m20f12/public_html/matlabnormal\n stored in literature directory as dartmouth_normcdf_norminv.pdf\n ...
[ 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import scrapy import MySQLdb import openpyxl from scrapy.crawler import CrawlerProcess import sys class AllabolaSpider(scrapy.Spider): name = 'allabola' allowed_domains = ['https://www.allabolag.se'] start_urls = [] #'https://www.allabolag.se/7696250484/befattningar' host =...
normal
{ "blob_id": "d60a2100127db859162890204655d313cdc2a4a5", "index": 4614, "step-1": "<mask token>\n\n\nclass AllabolaSpider(scrapy.Spider):\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 f.write('fn,ln,zip,ct,st,co...
[ 2, 4, 5, 6, 8 ]
from zExceptions import Unauthorized if REQUEST is not None: raise Unauthorized portal = context.getPortalObject() compute_node = context reference = "TIOCONS-%s-%s" % (compute_node.getReference(), source_reference) version = "%s" % context.getPortalObject().portal_ids.generateNewId( id_group=('slap_tioxml_consum...
normal
{ "blob_id": "6c27f70e820202f6cc4348de3c9198e7b20ec7d9", "index": 4470, "step-1": "<mask token>\n", "step-2": "<mask token>\nif REQUEST is not None:\n raise Unauthorized\n<mask token>\ndocument.submit()\nreturn document.getRelativeUrl()\n", "step-3": "<mask token>\nif REQUEST is not None:\n raise Unauth...
[ 0, 1, 2, 3, 4 ]
from django.conf.urls.defaults import * #from wiki.feeds import * from django.conf import settings from django.conf.urls.defaults import * # feeds for wikiPages and wikiNews """ feeds = { 'latestpages': LatestPages, } sitemaps = { 'wiki': Wiki, } """ urlpatterns = patterns('', # Example: # (r'^goimcommu...
normal
{ "blob_id": "f44ff7488ae8fc64bc1785fb6cbe80c4cc011fbe", "index": 6808, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', ('^admin/', include('django.contrib.admin.urls')\n ), ('^polls/', include('goimcommunity.polls.urls')), ('^league/',\n include('goimcommunity.leaguesystem...
[ 0, 1, 2, 3 ]
import operator import theano.tensor as T from collections import OrderedDict from lasagne.layers import get_output from stanza.research import config from neural import SimpleLasagneModel, NeuralLearner from vectorizers import SequenceVectorizer, BucketsVectorizer from neural import OPTIMIZERS, get_named_layers from ...
normal
{ "blob_id": "3496216de9f6b7d9d3db69eb4d8f8c0fdcd5123c", "index": 1358, "step-1": "<mask token>\n\n\nclass RSAGraphModel(SimpleLasagneModel):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass...
[ 15, 21, 23, 36, 38 ]
from flask_sqlalchemy import SQLAlchemy from flask_security import UserMixin, RoleMixin db = SQLAlchemy() roles_users = db.Table('roles_users', db.Column('user_id', db.Integer(), db.ForeignKey('user.id')), db.Column('role_id', db.Integer(), db.ForeignKey('role.id'))) class Role(db.Model, RoleMixin): ...
normal
{ "blob_id": "f561846c943013629e417d16f4dae77df43b25c4", "index": 3806, "step-1": "<mask token>\n\n\nclass Role(db.Model, RoleMixin):\n <mask token>\n <mask token>\n <mask token>\n\n def __repr__(self):\n return f'<Role {self.name}'\n\n\nclass User(db.Model, UserMixin):\n id = db.Column(db.I...
[ 10, 11, 12, 13, 14 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 1 11:52:48 2022 @author: ccamargo """ import xarray as xr import numpy as np import matplotlib.pyplot as plt import os # 1. get filelist path = "/Volumes/LaCie_NIOZ/data/steric/data/" path_to_original_files = path + "original/" flist = [file for ...
normal
{ "blob_id": "4fc4bb81d47a33e4669df46033033fddeca6544e", "index": 8858, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor file in flist:\n print(file)\n name = file.split('.nc')[0]\n ds = xr.open_dataset(path_to_regrided_files + file, decode_times=False)\n timespan = [ds.timespan]\n print(...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # @Time : 2020/6/12 20:19 # @Author : damon # @Site : # @File : work0612 # @Software: PyCharm import math """ 1、给定n=10,计算1! + 2! + 3! + ... + n!的值 """ # 解法1: n = 10 factorial = 1 sum = 0 for i in range(1, n+1): factorial = i * factorial sum += factorial print(f"阶乘之和{sum}")...
normal
{ "blob_id": "af9adc0faad4fc1426a2bd75c1c77e23e37b60bf", "index": 2431, "step-1": "<mask token>\n\n\ndef fa(x):\n dict2 = {(1): 'one', (2): 'two', (3): 'three', (4): 'four', (5): 'five',\n (6): 'six', (7): 'seven', (8): 'eight', (9): 'nine', (0): 'zero'}\n return dict2[int(x)]\n\n\n<mask token>\n", ...
[ 1, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.shortcuts import render from django.db.models import Q from django.contrib.auth import get_user_model from rest_framework.response import Response from rest_framework.status import HTTP_200_OK, HTTP_400_BAD_REQUEST from rest_framework.views imp...
normal
{ "blob_id": "18f355041a9982de56ad2eb51b665dd39a156f0a", "index": 9638, "step-1": "<mask token>\n\n\nclass UserUpdateAPIView(UpdateAPIView):\n <mask token>\n <mask token>\n\n def post(self, request, format=None):\n data = request\n queryset = User.objects.get()\n\n\nclass UserTokenVerifyAPI...
[ 11, 12, 14, 16, 18 ]
import pygame from evolution import Darwin from Sensor import Robot, obstacleArray # Game Settings pygame.init() background_colour = (0, 0, 0) (width, height) = (1000, 600) target_location = (800, 300) screen = pygame.display.set_mode((width, height)) pygame.display.set_caption("Omar's Simulation") screen.fill(backgr...
normal
{ "blob_id": "cbcbc0d01c32693ebbdbcf285efdc8e521c447ee", "index": 3998, "step-1": "<mask token>\n", "step-2": "<mask token>\npygame.init()\n<mask token>\npygame.display.set_caption(\"Omar's Simulation\")\nscreen.fill(background_colour)\n<mask token>\nfor i in range(population_size):\n robots.append(Robot(175...
[ 0, 1, 2, 3, 4 ]
""" ConstantsCommands.py """ TEST_HEAD = "\n >>>>>> " \ "\n >>>>>> Test in progress: {0}" \ "\n >>>>>>" TEST_TAIL = ">>>>>> Test execution done, tearDown\n\r"
normal
{ "blob_id": "45f0a7a78184195a593061d863ff2114abe01a46", "index": 6321, "step-1": "<mask token>\n", "step-2": "<mask token>\nTEST_HEAD = \"\"\"\n >>>>>> \n >>>>>> Test in progress: {0}\n >>>>>>\"\"\"\nTEST_TAIL = '>>>>>> Test execution done, tearDown\\n\\r'\n", "step-3": "\"\"\"\nConstantsCommands.py\n\"\"\"\...
[ 0, 1, 2 ]
import torch from torch import nn from torch.nn import functional as F import torchvision import math from torchvision.models.resnet import Bottleneck from dataset import load_image, load_text, ALPHABET, MAX_LEN class ResNetFeatures(nn.Module): def __init__(self, pretrained=True): super().__init__() ...
normal
{ "blob_id": "79522db1316e4a25ab5a598ee035cf9b9a9a9411", "index": 3511, "step-1": "<mask token>\n\n\nclass PositionalEncoding(nn.Module):\n\n def __init__(self, d_model, max_len, dropout=0.1):\n super(PositionalEncoding, self).__init__()\n self.dropout = nn.Dropout(p=dropout)\n pe = torch....
[ 12, 18, 21, 23, 24 ]
n, x = map(int, input().split()) m = [int(input()) for _ in range(n)] m.sort() x -= sum(m) print(n + x // m[0])
normal
{ "blob_id": "0ff398775fd13fb5fbd23bf2359bb31dff6bd38c", "index": 9821, "step-1": "<mask token>\n", "step-2": "<mask token>\nm.sort()\nx -= sum(m)\nprint(n + x // m[0])\n", "step-3": "n, x = map(int, input().split())\nm = [int(input()) for _ in range(n)]\nm.sort()\nx -= sum(m)\nprint(n + x // m[0])\n", "ste...
[ 0, 1, 2 ]
"""Support for binary sensor using I2C abelectronicsiopi chip.""" from custom_components.abelectronicsiopi.IOPi import IOPi import voluptuous as vol from homeassistant.components.binary_sensor import PLATFORM_SCHEMA, BinarySensorEntity from homeassistant.const import DEVICE_DEFAULT_NAME import homeassistant.help...
normal
{ "blob_id": "73d056d4ab0d268841156b21dfc2c54b5fb2f5f1", "index": 5218, "step-1": "<mask token>\n\n\nclass abelectronicsiopiBinarySensor(BinarySensorEntity):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, pinname, pin, pull_mode, invert_logic, bus):\n \"\"...
[ 5, 7, 8, 10, 11 ]
# -*- coding: utf-8 -*- # @Time : 2019/9/17 17:48 # @Author : ZhangYang # @Email : ian.zhang.88@outlook.com from functools import wraps def create_new_sequence_node(zk_client, base_path, prefix, is_ephemeral=False): if not zk_client.exists(base_path): zk_client.ensure_path(base_path) new_node =...
normal
{ "blob_id": "f9a0c3b643c2ee6bb6778477bf8fc21564812081", "index": 3373, "step-1": "<mask token>\n\n\nclass SetGetMixin:\n\n def get(path_variable):\n\n def decorator(func):\n\n @wraps(func)\n def wrapper(self, *args, **kwargs):\n if not self.zk_client.exists(getattr(...
[ 2, 3, 4, 5, 6 ]
import numpy as np import matplotlib.pyplot as plt from sklearn.model_selection import KFold import keras from keras.datasets import mnist from keras.models import Sequential from keras.layers.core import Dense,Activation,Dropout from keras.optimizers import SGD,Adam,RMSprop from keras.utils import np_utils x_train=n...
normal
{ "blob_id": "5b919bde9f4fe1da867695ece58f151abb9b70fb", "index": 1492, "step-1": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom sklearn.model_selection import KFold\nimport keras\nfrom keras.datasets import mnist\nfrom keras.models import Sequential\nfrom keras.layers.core import Dense,Activation,Dro...
[ 0 ]
import utilities import sys if __name__ == "__main__": print('I am main!') else: print(__name__) for i in range(0,6): print(i) mylist = [12, 13, 14, 13, 12] print(mylist) #Enter iterations to run [0-5] #value = -1 value = 3 while (value not in range(0,6)): try: value =...
normal
{ "blob_id": "f218f47acfb078877645de26c64e57f92dbcd953", "index": 8003, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n print('I am main!')\nelse:\n print(__name__)\nfor i in range(0, 6):\n print(i)\n<mask token>\nprint(mylist)\n<mask token>\nwhile value not in range(0...
[ 0, 1, 2, 3, 4 ]
import pandas as pd #1. 读入数据 #从本地读入“wheat.csv”文件,指定index_col参数为00,即将第一列作为每行的索引。用head()函数查看前几行数据。 data = pd.read_csv("wheat.csv",index_col=0) print(data.head(6)) #2. 缺失值处理 #该数据集中包含部分缺失值,在模型训练时会遇到特征值为空的问题,故对缺失值进行处理, ## 用DataFrame的fillna方法进行缺失值填充,填充值为用mean方法得到的该列平均值。 data = data.fillna(data.mean()) print(data) #3. 划分数据...
normal
{ "blob_id": "7da2be1b530faa8ce9a8570247887e8e0d74c310", "index": 711, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(data.head(6))\n<mask token>\nprint(data)\n<mask token>\nprint(X_train.shape)\nprint(y_train.shape)\nprint(X_test.shape)\nprint(y_test.shape)\n<mask token>\nmodel.fit(X_train, y_train...
[ 0, 1, 2, 3, 4 ]
from Distributions import UniformDistribution from EventGenerator import Generator from Processor import Processor class Modeller: def __init__(self, generator, operators, computers): self._generator = generator self._operators = operators self._computers = computers def event_mode...
normal
{ "blob_id": "11ed7550c25ca9944ce7073d9655cb9af7bdeae9", "index": 1324, "step-1": "<mask token>\n\n\nclass Modeller:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Modeller:\n <mask token>\n\n def event_mode(self):\n refusals = 0\n processed = 0\n generated...
[ 1, 2, 3, 4, 5 ]
# -*- encoding: utf-8 -*- class BaseException(object): """ Common base class for all exceptions """ def with_traceback(self, tb): # real signature unknown; restored from __doc__ """ Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self. """ p...
normal
{ "blob_id": "3d01910ae1c163067f4a23b3cca109a7d9e193d5", "index": 5251, "step-1": "class BaseException(object):\n <mask token>\n\n def with_traceback(self, tb):\n \"\"\"\n Exception.with_traceback(tb) --\n set self.__traceback__ to tb and return self.\n \"\"\"\n pass\n...
[ 9, 10, 11, 12, 15 ]
from django.db import transaction from django.contrib.auth.models import Group from drf_yasg import openapi from drf_yasg.utils import swagger_auto_schema from rest_framework import status, mixins from rest_framework.decorators import action from rest_framework.response import Response from rest_framework.viewsets imp...
normal
{ "blob_id": "43b5936ca9368dcae8d41b44fd9dc927fe18c9bc", "index": 8794, "step-1": "<mask token>\n\n\nclass CustomUsuarioViewSet(AccessViewSetMixin, mixins.CreateModelMixin,\n mixins.RetrieveModelMixin, mixins.ListModelMixin, GenericViewSet):\n <mask token>\n <mask token>\n <mask token>\n <mask toke...
[ 13, 14, 19, 21, 23 ]
def squirrel_play(temp, is_summer): if is_summer == True: if 60 <= temp <= 100: return True else: return False if is_summer == False: if 60 <= temp <= 90: return True else: return False
normal
{ "blob_id": "48755cf48c6696259d0c319d382021f33751ac01", "index": 9497, "step-1": "<mask token>\n", "step-2": "def squirrel_play(temp, is_summer):\n if is_summer == True:\n if 60 <= temp <= 100:\n return True\n else:\n return False\n if is_summer == False:\n if 6...
[ 0, 1 ]
from __future__ import annotations import math from abc import abstractmethod from pytown_core.patterns.behavioral import Command from pytown_core.serializers import IJSONSerializable from .buildings import BuildingProcess, BuildingTransaction from .buildings.factory import BuildingFactory from .check import ( A...
normal
{ "blob_id": "22b9868063d6c5fc3f8b08a6e725fff40f4a1a03", "index": 3886, "step-1": "<mask token>\n\n\nclass BuildCommand(ServerCommand):\n\n def __init__(self, tile: tuple, building_name: str):\n ServerCommand.__init__(self)\n self._tile = tile\n self._building_name = building_name\n <ma...
[ 72, 74, 84, 86, 98 ]
from setuptools import setup import sys if not sys.version_info >= (3, 6, 0): msg = 'Unsupported version %s' % sys.version raise Exception(msg) def get_version(filename): import ast version = None with open(filename) as f: for line in f: if line.startswith('__version__'): ...
normal
{ "blob_id": "d3b55863c6e3a1b6cbdcec37db81ee42b769938d", "index": 9039, "step-1": "<mask token>\n\n\ndef get_version(filename):\n import ast\n version = None\n with open(filename) as f:\n for line in f:\n if line.startswith('__version__'):\n version = ast.parse(line).body...
[ 1, 2, 3, 4, 5 ]
# system import os import numpy as np import random import copy import time # ROS import rospy import std_msgs.msg import sensor_msgs.msg import geometry_msgs.msg import visualization_msgs.msg import tf2_ros import rosbag import actionlib from actionlib_msgs.msg import GoalStatus import ros_numpy # spartan ROS import...
normal
{ "blob_id": "33867677611ceb757f6973eb70368c9f75f3ce92", "index": 1341, "step-1": "# system\nimport os\nimport numpy as np\nimport random\nimport copy\nimport time\n\n# ROS\nimport rospy\nimport std_msgs.msg\nimport sensor_msgs.msg\nimport geometry_msgs.msg\nimport visualization_msgs.msg\nimport tf2_ros\nimport r...
[ 0 ]
def convertEnEntier(nombre): result = ""; if (nombre == 4): result = "IV" if (nombre == 3): result = "III" if (nombre == 2): result = "II" if (nombre == 1): result = "I" return result print (convertEnEntier(1)) print (convertEnEntier(2)) pri...
normal
{ "blob_id": "ef7fad5019e79950e8fad56404e9ba5d302cfe1c", "index": 7596, "step-1": "<mask token>\n", "step-2": "def convertEnEntier(nombre):\n result = ''\n if nombre == 4:\n result = 'IV'\n if nombre == 3:\n result = 'III'\n if nombre == 2:\n result = 'II'\n if nombre == 1:\n...
[ 0, 1, 2, 3 ]
import hashlib import hmac import time def hmac_sha1_token(): timestamp = str(time.time()) hmac_pass = hmac.new(b'some very secret string', timestamp.encode( 'utf-8'), hashlib.sha1).hexdigest() token = '%s:%s' % (timestamp, hmac_pass) return token
normal
{ "blob_id": "65ef3b2ed5eef3d9d9e682ca18cf84457e929df2", "index": 2222, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef hmac_sha1_token():\n timestamp = str(time.time())\n hmac_pass = hmac.new(b'some very secret string', timestamp.encode(\n 'utf-8'), hashlib.sha1).hexdigest()\n toke...
[ 0, 1, 2 ]
# coding: utf-8 ''' Precision, Recall, F1で評価する Leave-one-outの結果 K-foldの結果 ''' import sys import os.path import snlocest.util as util import numpy as np import pandas as pd from sklearn.model_selection import KFold from sklearn.metrics import precision_recall_fscore_support, classification_report def precision_re...
normal
{ "blob_id": "79c7a2f2e5f0301c15efe1b26a7839a12098f793", "index": 6618, "step-1": "<mask token>\n\n\ndef precision_recall_fscore(nodes, y_true, y_pred):\n df = pd.DataFrame({'true': y_true, 'pred': y_pred}, index=nodes)\n n_predicted_nodes = len(df[df['pred'] != 0])\n n_corrects = len(df[df['pred'] == df...
[ 2, 3, 4, 5, 6 ]
from unv.app.base import Application def multiply(): print('multiply', 2 * 2) def setup(app: Application): app.register_run_task(multiply)
normal
{ "blob_id": "760a62a94347171eb9e40015c0c43d72df8f4fc8", "index": 1463, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef setup(app: Application):\n app.register_run_task(multiply)\n", "step-3": "<mask token>\n\n\ndef multiply():\n print('multiply', 2 * 2)\n\n\ndef setup(app: Application):\n ...
[ 0, 1, 2, 3 ]
""" This module is used to extract features from the lines extracted from documents using BERT encodings. This package leverages the bert-as-a-server package to create the embeddings. Example: feature_extractor = FeatureExtractor(document) # document is of class Document encoded_doc = feature_extracto...
normal
{ "blob_id": "882d265f14c04b2f2f626504d18e2cd07dcc8637", "index": 3042, "step-1": "<mask token>\n\n\nclass FeatureExtractor:\n <mask token>\n <mask token>\n\n def encode(self):\n \"\"\" encodes the text in the Document object, and then adds it to the encoding attribute \"\"\"\n text_lines =...
[ 3, 4, 5, 6, 7 ]
# Generated by Django 3.0.1 on 2020-01-11 09:50 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('blog', '0005_auto_20200111_1513'), ] operations = [ migrations.AlterField( model_name='post', name='photo', ...
normal
{ "blob_id": "8e8c72362dfb1587150aadaa6b8a0aeb77c3641a", "index": 1516, "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 = [('blog', '000...
[ 0, 1, 2, 3, 4 ]
# -*- encoding: utf-8 -*- from django.contrib import admin from finish.wall.models import (Autor, Category, Announcement, Banner, Caricatura, Video, TypePost, Post, Phrase, TypeGalery, ImageGalery, Sponsor) class AutorAdmin(admin.ModelAdmin): pass ...
normal
{ "blob_id": "3c9302b5cb92e5103ed16ec56e1b349f0662950c", "index": 154, "step-1": "<mask token>\n\n\nclass CaricaturaAdmin(admin.ModelAdmin):\n pass\n\n\nclass VideoAdmin(admin.ModelAdmin):\n pass\n\n\nclass TypePostAdmin(admin.ModelAdmin):\n pass\n\n\nclass PostAdmin(admin.ModelAdmin):\n\n\n class Med...
[ 8, 9, 10, 11, 15 ]
#Homework 09 #Raymond Guevara #018504731 #Algorithm Workbench #Question 1 print("Question 1") height = int(input("Please enter your height: ")) print() #Question 2 print("Question 2") color = input("please enter your favorite color: ") print() #Question 3 print("Question 3") a = -8/3 #Solved for variable "a" usin...
normal
{ "blob_id": "82c426836fee0560e917848084af4ca124e74dff", "index": 7043, "step-1": "<mask token>\n", "step-2": "print('Question 1')\n<mask token>\nprint()\nprint('Question 2')\n<mask token>\nprint()\nprint('Question 3')\n<mask token>\nprint('%.2f' % b)\n<mask token>\nprint('%.2f' % a)\n<mask token>\nprint('%.2f'...
[ 0, 1, 2, 3 ]
import string import random import os from threading import Thread class Process(Thread): def __init__(self): Thread.__init__(self) def run(self): while True: prenom = id_generator(random.randint(4, 8)) nom = id_generator(random.randint(4, 8)) password = id_...
normal
{ "blob_id": "b9c058bdb04df93beb379d05939b00f4db423cd3", "index": 452, "step-1": "import string\nimport random\nimport os\nfrom threading import Thread\n\nclass Process(Thread):\n def __init__(self):\n Thread.__init__(self)\n\n def run(self):\n while True:\n prenom = id_generator(ra...
[ 0 ]
FILE = "Luke" NAME = "Luke Walker" NATIONALITY = "American" CLASS = "Manipulator" WEAPON = "" BIRTH = "" BIRTH_LOCATION = "" LETTER = "W" RECRUITMENT_ORDER = 10 SUMMARY = "" ABILITIES = "" BACKSTORY = "" HIGHLIGHTS = "" SUMMONS = ("Tonberry", "Grimnir", "Griever", "Starlet")
normal
{ "blob_id": "fa3ab879541c04e278317b11dd79e6e1b4319536", "index": 7586, "step-1": "<mask token>\n", "step-2": "FILE = 'Luke'\nNAME = 'Luke Walker'\nNATIONALITY = 'American'\nCLASS = 'Manipulator'\nWEAPON = ''\nBIRTH = ''\nBIRTH_LOCATION = ''\nLETTER = 'W'\nRECRUITMENT_ORDER = 10\nSUMMARY = ''\nABILITIES = ''\nB...
[ 0, 1, 2 ]
from django.db import models from django.contrib.auth.models import User from django.db.models.signals import post_save from django.dispatch import receiver from django.core.mail import EmailMultiAlternatives from django.template import loader from django.conf import settings from django.contrib.sites.shortcuts import ...
normal
{ "blob_id": "de77edaccdaada785f41828135ad2da4ae2b403e", "index": 725, "step-1": "<mask token>\n\n\nclass Post(models.Model):\n blog = models.ForeignKey(Blog, on_delete=models.DO_NOTHING)\n user = models.ForeignKey(User, on_delete=models.CASCADE)\n header = models.CharField(max_length=50)\n text = mod...
[ 6, 8, 9, 10, 11 ]
#!/usr/bin/env python3 '''Testing File''' import tensorflow.keras as K def test_model( network, data, labels, verbose=True ): '''A Function that tests a neural network''' return network.evaluate( x=data, y=labels, verbose=verbose )
normal
{ "blob_id": "39643454cbef9e6fa7979d0f660f54e07d155bc7", "index": 7690, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_model(network, data, labels, verbose=True):\n \"\"\"A Function that tests\n a neural network\"\"\"\n return network.evaluate(x=data, y=labels, verbose=verbose)\n", ...
[ 0, 1, 2, 3 ]
import time from numpy import empty from src.utils import normalize_input_sentence, evaluate, add_begin_and_trailing_tag, check_for_terminal_argument from classes.BaseTagger import BaseTagger from src.CONSTANT import POS_TAG_KEYNAME, WORD_KEYNAME, TRUETAG_KEYNAME, DEFAULT_TRAINING_FILENAME import sys import os # TOD...
normal
{ "blob_id": "8cc0314d48f81ceead863245443548297e8188f8", "index": 9610, "step-1": "<mask token>\n\n\nclass ForwardBackward(BaseTagger):\n <mask token>\n <mask token>\n\n def probabilities(self):\n \"\"\"\n Return the probabilities of a hidden state sequence given observed output sequence\n ...
[ 3, 4, 5, 7, 8 ]
import json data = '{"var1": "harry", "var2":56}' parsed = json.loads(data) print(parsed['var1']) # data2 = {"channel_name": "Chill_Out", # "Cars": ["BMW", "Audi a8", "ferrari"], # "fridge": ("loki", "Aalu", "pasta"), # "isbad": False # } # jscomp = json.dumps(data2) # print(jscomp)
normal
{ "blob_id": "f0f9541eba29b4488c429c889f3b346d53d0239d", "index": 7193, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(parsed['var1'])\n", "step-3": "<mask token>\ndata = '{\"var1\": \"harry\", \"var2\":56}'\nparsed = json.loads(data)\nprint(parsed['var1'])\n", "step-4": "import json\ndata = '{\...
[ 0, 1, 2, 3, 4 ]
import numpy as np import cPickle from features import create_features, PROJECT from parse import load_data from dict_vectorizer import DictVectorizer videos, users, reviews = load_data() orig_X = np.array([(x['date'], x['text'], x['user']) for x in reviews]) feats = create_features(orig_X, None) v = DictVectorizer(s...
normal
{ "blob_id": "e26fa69ea1f0bee82b4108ac5a541a6175645728", "index": 5955, "step-1": "<mask token>\n", "step-2": "<mask token>\ncPickle.dump(v, open(PROJECT + 'db/dictvectorizer.pickle', 'wb'))\n", "step-3": "<mask token>\nvideos, users, reviews = load_data()\norig_X = np.array([(x['date'], x['text'], x['user'])...
[ 0, 1, 2, 3, 4 ]
import os, shutil, cv2 from PIL import Image INP_DIR = '/dataset/test_set_A_full' # Lọc thư mục data test ra thành 3 thư mục: None, Square (1:1), và phần còn lại (đã được crop ngay chính giữa) # Trả về path dẫn đến 3 thư mục nói trên def pre_proc(INP_DIR): INP_DIR = INP_DIR + '/' NONE_DIR = os.path.dirname(I...
normal
{ "blob_id": "4ad4cf46be735c6ac26b5b0953d4c2458f37496a", "index": 9372, "step-1": "<mask token>\n\n\ndef pre_proc(INP_DIR):\n INP_DIR = INP_DIR + '/'\n NONE_DIR = os.path.dirname(INP_DIR) + '_none'\n SQUARE_DIR = os.path.dirname(INP_DIR) + '_square'\n CROP_DIR = os.path.dirname(INP_DIR) + '_cropped'\n...
[ 1, 2, 3, 4, 5 ]
from __future__ import division, print_function import numpy as np from copy import deepcopy class IntegratedRegressor(): regs = [] def __init__(self, reg, predict_log=True): self.reg = reg self.predict_log = predict_log def fit(self, X, y): self.regs = [] for target in ...
normal
{ "blob_id": "72d41f939a586fbd8459927983d9d62a96b650e2", "index": 1844, "step-1": "<mask token>\n\n\nclass IntegratedRegressor:\n <mask token>\n <mask token>\n\n def fit(self, X, y):\n self.regs = []\n for target in y.columns:\n tmp = deepcopy(self.reg)\n if self.predi...
[ 6, 7, 8, 10, 11 ]
import cv2 as cv import numpy as np from servo import * from func import * #import threading #import dlib # import socket # import struct # import pickle def constrain(val, minv, maxv): return min(maxv, max(minv, val)) KP = 0.22 KI = 0 KD = 0.17 last = 0 integral = 0 # constants SIZE = (400, 300) RECT = np.flo...
normal
{ "blob_id": "3ccbafbdc84447438c194288b1409e332bb2b479", "index": 3630, "step-1": "<mask token>\n\n\ndef constrain(val, minv, maxv):\n return min(maxv, max(minv, val))\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef constrain(val, minv, maxv):\n return min(maxv, max(minv, val))\n\n\n<mask token>\nc...
[ 1, 2, 3, 4, 5 ]
user_input = input() #abv>1>1>2>2asdasd exploded_str = user_input for n in range(len(user_input)): explosion_strength = 0 if user_input[n] == ">": explosion_strength += int(user_input[n+1]) if user_input[n+explosion_strength] != ">": exploded_str = user_input[:n] + user_input[n+ex...
normal
{ "blob_id": "7930bb813bd546747c7c65b661900939f5ba93f1", "index": 273, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor n in range(len(user_input)):\n explosion_strength = 0\n if user_input[n] == '>':\n explosion_strength += int(user_input[n + 1])\n if user_input[n + explosion_streng...
[ 0, 1, 2, 3 ]
import sys sys.path.append("./") from torchtext.datasets import Multi30k from torchtext.data import Field from torchtext import data import pickle import models.transformer as h import torch from datasets import load_dataset from torch.utils.data import DataLoader from metrics.metrics import bleu import numpy as np fro...
normal
{ "blob_id": "57bc34c6a23c98fd031ea6634441d4d135c06590", "index": 8694, "step-1": "<mask token>\n\n\nclass Batch:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass MyIterator(data.Iterator):\n\n def create_batches(self):\n if self.train:\n\n def pool(d, random_shuffler):\n ...
[ 7, 14, 17, 18, 21 ]
#!/usr/bin/env python3 import re import datetime import math import pathlib import os import io import argparse import subprocess import xml.sax.saxutils from typing import (Optional, List, Iterable) import sys _DEFAULT_TRACK_TYPE = 'Dashcam track' class Arguments(object): def __init__(self): parser = ...
normal
{ "blob_id": "fbb1254c7166fa2aa9cd8a0b9c6525dbe5b652a0", "index": 2625, "step-1": "<mask token>\n\n\nclass GpsDataBlockIndex(object):\n\n def __init__(self, position: int, size: int):\n if position <= 0:\n raise ValueError(f\"An invalid position: `{position}'.\")\n if size <= 0:\n ...
[ 47, 55, 64, 81, 82 ]
#!/usr/bin/python import os from nao.tactics import Tactic from nao.inspector import Inspector def test_file(): print("\n[*] === file ===") name_libmagic_so = 'libmagic.so.1' inspector = Inspector("./sample/file", debug=True) # find_addr = 0x1742D # ret block of is_tar find_addr = 0x173F8 # return ...
normal
{ "blob_id": "a25fb9b59d86de5a3180e4257c4e398f22cdbb05", "index": 6947, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_file():\n print('\\n[*] === file ===')\n name_libmagic_so = 'libmagic.so.1'\n inspector = Inspector('./sample/file', debug=True)\n find_addr = 95224\n cond = i...
[ 0, 1, 2, 3, 4 ]
from django import forms from myapp.models import Student from myapp.models import Employee class EmpForm(forms.ModelForm): class Meta: model = Student fields = "__all__" class StudentForm(forms.Form): firstname = forms.CharField(label="Enter first name:", max_length=50) lastname = forms...
normal
{ "blob_id": "0b141ecca501c21df50e76d0841dd5651274f0da", "index": 8509, "step-1": "<mask token>\n\n\nclass StudentForm(forms.Form):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass EmployeeForm(forms.ModelForm):\n\n\n class Meta:\n model = Employee\n fields = '__...
[ 2, 3, 4, 5, 6 ]
from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: # from django.contrib import admin # admin.autodiscover() urlpatterns = patterns('accounts.views', url(r'^$', 'home', name='home'), url(r'^login/$', 'login', name='login'), url(r'^logout/$', 'logout', n...
normal
{ "blob_id": "798ddd4a6e4febb4664bf1c973877628d1a45c71", "index": 368, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('accounts.views', url('^$', 'home', name='home'),\n url('^login/$', 'login', name='login'), url('^logout/$', 'logout', name\n ='logout'), url('^register/$', 'r...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright (c) 2017 Maarten Los # See LICENSE.rst for details. class Defaults(object): INBUS_VERSION = 2 LOCALHOST = "127.0.0.1" PORT = 7222 INBUS_ADDRESS = (LOCALHOST, PORT) BUFFER_SIZE = 65536
normal
{ "blob_id": "bc087482e901ce1831cef56aa9c7aef0c8f2d15a", "index": 1793, "step-1": "<mask token>\n", "step-2": "class Defaults(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "class Defaults(object):\n INBUS_VERSION = 2\n LOCALHOST = '127.0...
[ 0, 1, 2, 3 ]
import numpy as np from datetime import date, timedelta, datetime from pytz import timezone import store import psycopg2 import requests import os import filters FIRST = 4 def prepareDate(): pc_tz = timezone('US/Pacific') n = datetime.now(pc_tz) nd = n.date() store.updateStore(today=nd) def getData(): toda...
normal
{ "blob_id": "5b4651f37cdcbb13f8ddd03327ef65af0f9cf61d", "index": 1944, "step-1": "<mask token>\n\n\ndef getDates():\n dates = store.mapStore('dates')\n data = store.mapStore('data')\n exceptions = store.mapStore('exceptions')\n if len(exceptions) > 0:\n return False\n try:\n d0 = dat...
[ 3, 4, 6, 7, 8 ]
lc_headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15", "authority": "leetcode.com", } lc_all = "https://leetcode.com/api/problems/all/" lc_submissions = "https://leetcode.com/api/submissions/?off...
normal
{ "blob_id": "f715628da2f1b950b8fbf8aa5b033e5299d3e224", "index": 7857, "step-1": "<mask token>\n", "step-2": "lc_headers = {'User-Agent':\n 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Safari/605.1.15'\n , 'authority': 'leetcode.com'}\nlc_all = 'http...
[ 0, 1, 2 ]
# content of conftest.py # adapted from http://pytest.org/latest/example/special.html import pytest import requests def tear_down(): ''' conftest.py tear_down - the last to go.... ''' print("\nTEARDOWN after all tests") @pytest.fixture(scope="session", autouse=True) def set_up(request): ''' conftest...
normal
{ "blob_id": "816b1a932208a4525230dd886adf8c67dec3af3e", "index": 349, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.fixture(scope='session', autouse=True)\ndef set_up(request):\n \"\"\" conftest.py set_up - the first to start.... \"\"\"\n print('\\nSETUP before all tests')\n request...
[ 0, 1, 2, 3, 4 ]
class Solution(object): def countSmaller(self, nums): """ :type nums: List[int] :rtype: List[int] naive -- o(n^2) """ ## StefanPochmann solution #2 def countSmaller(self, nums): def sort(enum): half = len(enum) / 2 if half: left = sort(enum...
normal
{ "blob_id": "42021b762737a2eb21866ba029ece4ac120152cd", "index": 5902, "step-1": "class Solution(object):\n\n def countSmaller(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: List[int]\n naive -- o(n^2)\n \"\"\"\n\n\n<mask token>\n\n\ndef mergesort(x):\n if len(x)...
[ 6, 7, 8, 9, 10 ]
from django.conf.urls import url, include from django.contrib import admin from rest_framework_swagger.views import get_swagger_view schema_view = get_swagger_view(title='Pastebin API') urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^doc_u/', schema_view), url(r'^', include('o.urls', )), url(...
normal
{ "blob_id": "891588327046e26acb9a691fa8bb9a99420712d6", "index": 913, "step-1": "<mask token>\n", "step-2": "<mask token>\nschema_view = get_swagger_view(title='Pastebin API')\nurlpatterns = [url('^admin/', admin.site.urls), url('^doc_u/', schema_view),\n url('^', include('o.urls')), url('^api/', include('r...
[ 0, 1, 2, 3 ]
# O(logn) T O(1) S def binarySearch(array, target): if len(array) == 0: return -1 else: return binarySearchR(array, target, 0, len(array) - 1) def binarySearchR(array, target, leftPointer, rightPointer): if leftPointer > rightPointer: return -1 else: midPointer = (leftP...
normal
{ "blob_id": "57d6b9e7f48d32e5d10bfd6a340ea56281f5d82d", "index": 1890, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef binarySearchR(array, target, leftPointer, rightPointer):\n if leftPointer > rightPointer:\n return -1\n else:\n midPointer = (leftPointer + rightPointer) // 2\...
[ 0, 1, 2, 3 ]
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4 # (c) Simen Sommerfeldt, @sisomm, simen.sommerfeldt@gmail.com Licensed as CC-BY-SA import os import argparse,time import pygame import paho.mqtt.client as paho parser = argparse.ArgumentParser() parser.add_argument("-s","--server", default="127.0.0.1", help="The I...
normal
{ "blob_id": "9852d2a15047b110c7f374fd75e531c60c954724", "index": 3920, "step-1": "<mask token>\n\n\ndef task_goodbye():\n pygame.mixer.music.load('../sounds/despicable.wav')\n pygame.mixer.music.play()\n\n\ndef task_hello():\n pygame.mixer.music.load('../sounds/mday.wav')\n pygame.mixer.music.play()\...
[ 4, 5, 6, 8, 9 ]
from __future__ import annotations import typing import requests import heapq from sklearn.metrics.pairwise import cosine_similarity from sklearn.feature_extraction.text import TfidfVectorizer from bs4 import BeautifulSoup from wikiAPI import get_JSON, get_intro, compare_titles from typing import List, Type, Callable ...
normal
{ "blob_id": "1fad591fde707c73bd52aa8518828c8b8be9cd32", "index": 2283, "step-1": "<mask token>\n\n\nclass Article:\n <mask token>\n title: str\n target: str\n g: float\n f: float\n parent: typing.Union[Article, Type(None)]\n heuristic: Callable[[str, str], float]\n\n def __init__(self, ti...
[ 12, 15, 17, 18, 23 ]
import discord class Leveling: __slots__ = ('sid', 'channelID', 'message', 'noxpchannelIDs', 'noxproleID', 'remove', 'bot', 'roles') sid: int channelID: int message: str noxpchannelIDs: list[int] noxproleID: int remove: bool roles: list[list] def __init__(self, bot, sid, r...
normal
{ "blob_id": "346df9706dc222f43a77928964cd54e7d999a585", "index": 8052, "step-1": "<mask token>\n\n\nclass Leveling:\n <mask token>\n sid: int\n channelID: int\n message: str\n noxpchannelIDs: list[int]\n noxproleID: int\n remove: bool\n roles: list[list]\n <mask token>\n\n @property...
[ 2, 3, 4, 5 ]
#coding=utf8 """ Created on Thu Feb 20 00:53:28 2020 @author: Neal LONG """ import json import requests fake_header = { "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36", "Accept":"text/html,application/xhtml+xml,...
normal
{ "blob_id": "166a1dfbd3baf766230080361d98648ec0a64455", "index": 1038, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(parsed_json2)\n", "step-3": "<mask token>\nfake_header = {'user-agent':\n 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113...
[ 0, 1, 2, 3, 4 ]
n = int(input()) s = "" for i in range(n): l = list(map(lambda x:x*x,map(int, input().split()))) l.sort() if l[0] + l[1] == l[2]: s += "YES\n" else: s += "NO\n" print(s,end="")
normal
{ "blob_id": "f8b473451a15e42319b60f44a527d715c0032614", "index": 3411, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n l = list(map(lambda x: x * x, map(int, input().split())))\n l.sort()\n if l[0] + l[1] == l[2]:\n s += 'YES\\n'\n else:\n s += 'NO\\n'\nprint...
[ 0, 1, 2, 3 ]
#n-repeated element class Solution: def repeatedNTimes(self, A): freq = {} for i in A: if i in freq.keys(): freq[i] += 1 else: freq[i] = 1 key = list(freq.keys()) val = list(freq.values()) m = max(val) return key...
normal
{ "blob_id": "d50618f7784e69b46cb665ec1a9c56f7a2867785", "index": 5033, "step-1": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Solution:\n\n def repeatedNTimes(self, A):\n freq = {}\n for i in A:\n if i in freq.keys():\n freq[i] += 1\n ...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ @author: longshuicui @date : 2021/2/4 @function: 32. Longest Valid Parentheses (Hard) https://leetcode.com/problems/longest-valid-parentheses/ 题目描述 在给的字符串里面找到 最大长度的 有效 括号字符串 输入输出示例 Input: s = ")()())" Output: 4 Explanation: The longest valid parentheses substring is "()()"...
normal
{ "blob_id": "0f03ff63662b82f813a18cc8ece3d377716ce678", "index": 2318, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef longestValidParentheses(s):\n stack = []\n maxLength = 0\n stack.append(-1)\n for i in range(len(s)):\n if s[i] == '(':\n stack.append(i)\n el...
[ 0, 1, 2, 3, 4 ]
from django.test import TestCase from core.factories import CompanyFactory, EmployeeFactory from core.pair_matcher import MaximumWeightGraphMatcher class PairMatcherTestCase(TestCase): def setUp(self): self.company = CompanyFactory.create() def test_simple(self): employees = EmployeeFactory....
normal
{ "blob_id": "0c68bd65cac3c8b9fd080900a00991b2d19260ee", "index": 534, "step-1": "<mask token>\n\n\nclass PairMatcherTestCase(TestCase):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass PairMatcherTestCase(TestCase):\n <mask token>\n\n def test_simple(self):\n employees = ...
[ 1, 2, 3, 4 ]
from collections import defaultdict, deque import numpy as np import gym from chula_rl.policy.base_policy import BasePolicy from chula_rl.exception import * from .base_explorer import BaseExplorer class OneStepExplorerWithTrace(BaseExplorer): """one-step explorer but with n-step trace""" def __init__(self...
normal
{ "blob_id": "958d7ec966179d63c6ba0a651e99fff70f0db31a", "index": 5410, "step-1": "<mask token>\n\n\nclass OneStepExplorerWithTrace(BaseExplorer):\n <mask token>\n <mask token>\n\n def step(self, policy: BasePolicy):\n if self.n_interaction > self.n_max_interaction:\n raise InteractionE...
[ 2, 3, 4, 5, 6 ]
name = 'valentina ' print(name * 1000)
normal
{ "blob_id": "aff1a9263e183610f403a4d6a7f27b45eacb7ff2", "index": 0, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(name * 1000)\n", "step-3": "name = 'valentina '\nprint(name * 1000)\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
# this is for the 12/30/2015 experiments # varied over 1, 10, 25, 50, 100 repeat particles per particle # 10000 particles total per filter # bias is at 0.8 in both the "real" world (realWorld.cpp) files = ['data0Tue_Dec_30_20_37_34_2014.txt', 'data0Tue_Dec_30_20_37_49_2014.txt', 'data0Tue_Dec_30_20_38_04_2014.txt', 'd...
normal
{ "blob_id": "b63221af86748241fdce34052819569a06d37afe", "index": 6965, "step-1": "<mask token>\n", "step-2": "files = ['data0Tue_Dec_30_20_37_34_2014.txt',\n 'data0Tue_Dec_30_20_37_49_2014.txt',\n 'data0Tue_Dec_30_20_38_04_2014.txt',\n 'data0Tue_Dec_30_20_38_19_2014.txt',\n 'data0Tue_Dec_30_20_38_3...
[ 0, 1, 2 ]
club_info = {'club_url': 'https://www.futbin.com///18/leagues/Major%20League%20Soccer?page=1&club=101112' , 'club_logo': 'https://cdn.futbin.com/content/fifa18/img/clubs/101112.png', 'club_name': 'Vancouver Whitecaps FC'} players = {} players['Waston'] = {'player_url': 'https://www.futbin.com//18/pl...
normal
{ "blob_id": "35c4e26acbe99ca7f37b63b67f38d5c40fbf0ea4", "index": 2503, "step-1": "<mask token>\n", "step-2": "club_info = {'club_url':\n 'https://www.futbin.com///18/leagues/Major%20League%20Soccer?page=1&club=101112'\n , 'club_logo':\n 'https://cdn.futbin.com/content/fifa18/img/clubs/101112.png',\n ...
[ 0, 1 ]
from utils import * name = 'topological' def topological(above): "Topologically sort a DAG by removing a layer of sources until empty." result = [] while above: sources = set(above) - set(flatten(above.values())) result.extend(sources) for node in sources: del above[nod...
normal
{ "blob_id": "a8ea91797942616779ae0acc884db1e521c7ad28", "index": 3927, "step-1": "<mask token>\n\n\ndef topological(above):\n \"\"\"Topologically sort a DAG by removing a layer of sources until empty.\"\"\"\n result = []\n while above:\n sources = set(above) - set(flatten(above.values()))\n ...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- import enhancedyaml import vector def roots_of_n_poly_eq(n, x, var_upper_bounds=tuple()): '''find the all possible non-negative interger roots of a `n`-term polynomial equals `x`.''' countdown = lambda: xrange(x if not var_upper_bounds else var_upper_bounds[0], -...
normal
{ "blob_id": "c6b80a7dfce501bfe91f818ac7ab45238a0a126b", "index": 3367, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nimport enhancedyaml\nimport vector\n\ndef roots_of_n_poly_eq(n, x, var_upper_bounds=tuple()):\n '''find the all possible non-negative interger roots of a `n`-term polynomial equa...
[ 0 ]
from graphics import * from random import random def printIntro(): print("This program evaluates pi via Monte Carlo techniques") def simDarts(n): win = GraphWin("", 400, 400) win.setCoords(-1.2, -1.2, 1.2, 1.2) hits = 0 for i in range(n): pt = getDarts() if hitTarget(pt): ...
normal
{ "blob_id": "0bf970a84911d29a8343575ef15f2765875b8b89", "index": 9552, "step-1": "<mask token>\n\n\ndef printIntro():\n print('This program evaluates pi via Monte Carlo techniques')\n\n\n<mask token>\n\n\ndef getDarts():\n x = 2 * random() - 1\n y = 2 * random() - 1\n pt = Point(x, y)\n return pt\...
[ 5, 6, 7, 8, 9 ]
# MODULES import sys sys.path.append('~/Documents/Project_3/REPO') from scipy import * from scipy import linalg import cPickle as pickle import ConfigParser import TobySpectralMethods as tsm config = ConfigParser.RawConfigParser() fp = open('config.cfg') config.readfp(fp) N = config.getint('General', 'N') M = config....
normal
{ "blob_id": "1221394dfb97cbbfb00b412f60d4df521acc1262", "index": 8029, "step-1": "\n# MODULES\nimport sys\nsys.path.append('~/Documents/Project_3/REPO')\nfrom scipy import *\nfrom scipy import linalg\nimport cPickle as pickle\nimport ConfigParser\nimport TobySpectralMethods as tsm\n\nconfig = ConfigParser.RawCon...
[ 0 ]
import psycopg2 from .connection import get_connection def get_clientes(): query = 'SELECT nombre, t_documento ,documento, telefono, direccion, correo, ciudad_circulacion, fecha_nacimiento, comercial, primas FROM clientes' cursor = get_connection(query) return cursor def get_clientes_by_id(_id...
normal
{ "blob_id": "035a87ccf21d45b2c147da4315c2143bea1ff21d", "index": 8173, "step-1": "<mask token>\n\n\ndef add_cliente(parametros):\n query = (\n 'INSERT INTO clientes VALUES(%s,%s,%s,%s,%s,%s,%s,%s,NULL,NULL,%s,NULL,%s)'\n )\n get_connection(query, parametros)\n print('Datos almacenados')\n ...
[ 1, 5, 7, 9, 10 ]
import requests, os def lambda_handler(event, context): print(requests) apiKey = os.environ['newrelic_api_key'] headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'X-api-key': apiKey} r = requests.get('https://api.newrelic.com/v2/applications.json', headers=heade...
normal
{ "blob_id": "e89600f109335ffdb00c13f617d61496c547ba61", "index": 5612, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef lambda_handler(event, context):\n print(requests)\n apiKey = os.environ['newrelic_api_key']\n headers = {'content-type': 'application/json', 'Accept-Charset':\n 'U...
[ 0, 1, 2 ]
array = [1, 7, 3, 8, 9, 2, 4] index = 0 while (index < len(array)): count = 0 while(count <= len(array)-2): if(count == len(array)-1): break if (array[count] > array[count+1]): sift = array[count] array[count] = array[count+1] array[count+1] = sift...
normal
{ "blob_id": "fc8976141a19afd099f92cbbdb578e9c620cb745", "index": 5075, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile index < len(array):\n count = 0\n while count <= len(array) - 2:\n if count == len(array) - 1:\n break\n if array[count] > array[count + 1]:\n ...
[ 0, 1, 2, 3 ]
from django.contrib import admin from calc.models import CalcResult class MyAdmin(admin.ModelAdmin): def has_add_permission(self, request, obj=None): return False def has_delete_permission(self, request, obj=None): return False class CalcResultAdmin(MyAdmin): list_display = ('result', ...
normal
{ "blob_id": "e2573a5dc507e9aeb811fbc254129aeb6e54cc0b", "index": 2483, "step-1": "<mask token>\n\n\nclass MyAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n\n\nclass CalcResultAdmin(MyAdmin):\n list_display = 'result', 'message', 'time'\n search_fields = 'result', 'message', 'time'\n\n\n<mask...
[ 3, 4, 5, 6, 8 ]
import pandas as pd import numpy as np #from ctaFunction import std_normalized def barStdNormal(bars, timeperiod=5): '''Std Normal ''' close = bars['close'] result = close.rolling(timeperiod).apply(std_normalized) return result
normal
{ "blob_id": "6fa0e1dabd178507c32c62146b404bb42f8445d4", "index": 9860, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef barStdNormal(bars, timeperiod=5):\n \"\"\"Std Normal \"\"\"\n close = bars['close']\n result = close.rolling(timeperiod).apply(std_normalized)\n return result\n", "s...
[ 0, 1, 2, 3 ]
import tensorflow as tf import tensorflow_probability as tfp import pytest import numpy as np from estimators import NormalizingFlowNetwork tfd = tfp.distributions tf.random.set_seed(22) np.random.seed(22) @pytest.mark.slow def test_x_noise_reg(): x_train = np.linspace(-3, 3, 300, dtype=np.float32).reshape((300,...
normal
{ "blob_id": "303a8609cb21c60a416160264c3d3da805674920", "index": 777, "step-1": "<mask token>\n\n\n@pytest.mark.slow\ndef test_x_noise_reg():\n x_train = np.linspace(-3, 3, 300, dtype=np.float32).reshape((300, 1))\n noise = tfd.MultivariateNormalDiag(loc=5 * tf.math.sin(2 * x_train),\n scale_diag=ab...
[ 2, 3, 4, 5, 6 ]
from collections import namedtuple from math import tau, sin, cos, atan2 grid = 21 c = grid / 2 points = grid**3 Velocity = namedtuple('Velocity', ('x', 'y', 'z')) velocity = [] for k in range(grid): for j in range(grid): for i in range(grid): x = (i / grid + 0.25) * tau y = (j /...
normal
{ "blob_id": "d70986b016e58877c39bfbb76c5bd622c44cbca9", "index": 9273, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor k in range(grid):\n for j in range(grid):\n for i in range(grid):\n x = (i / grid + 0.25) * tau\n y = (j / grid + 0.25) * tau\n z = (k / gri...
[ 0, 1, 2, 3, 4 ]
movies = ["Abraham Lincoln", "Blue Steel", "Behind Office Doors", "Bowery at Midnight", "Captain Kidd", "Debbie Does Dallas", "The Emperor Jones", "Rain"] movies_tuple = [("Abraham Lincoln", 1993), ("Blue Steel", 1938), ("Behind Office Doors", 1999), ("Bowery at Midnight", 2000), ("Captain Kidd",2010), ("Debbie Does D...
normal
{ "blob_id": "8435a69ee9793435c7483df9bb15f01ef8051479", "index": 3340, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(selected_movies)\n<mask token>\nprint(selected_movies2)\n", "step-3": "movies = ['Abraham Lincoln', 'Blue Steel', 'Behind Office Doors',\n 'Bowery at Midnight', 'Captain Kidd',...
[ 0, 1, 2, 3 ]
# 1-[2-3-4-5]-1 # 순열로 돌리고, 백트래킹으로 걷어내기 def DFS(idx, cost, cur_loc): global min_cost if min_cost < cost: return if idx == N and arr[cur_loc][0]: if min_cost > cost + arr[cur_loc][0]: min_cost = cost + arr[cur_loc][0] return for i in range(1, N): if way[i] or not arr[c...
normal
{ "blob_id": "4ff7e83c6e85a041578a8b3471cbbb7e0c2543e6", "index": 2663, "step-1": "<mask token>\n", "step-2": "def DFS(idx, cost, cur_loc):\n global min_cost\n if min_cost < cost:\n return\n if idx == N and arr[cur_loc][0]:\n if min_cost > cost + arr[cur_loc][0]:\n min_cost = c...
[ 0, 1, 2, 3, 4 ]
from django.contrib import admin # Register your models here. from django.contrib import admin from practice_app.models import Person class PersonAdmin(admin.ModelAdmin): pass admin.site.register(Person)
normal
{ "blob_id": "d90aeaaa682b371afb4771ecfbf1077fc12520b4", "index": 3873, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PersonAdmin(admin.ModelAdmin):\n pass\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass PersonAdmin(admin.ModelAdmin):\n pass\n\n\nadmin.site.register(Person)\n",...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- ########################### # CSCI 573 Data Mining - Eclat and Linear Kernel SVM # Author: Chu-An Tsai # 12/14/2019 ########################### import fim import numpy as np from sklearn.model_selection import train_test_split, GridSearchCV from sklearn.svm import SVC from sklearn.m...
normal
{ "blob_id": "07b05093b630fc0167532884ec69a00420ed70b4", "index": 4021, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in lines:\n strpline = line.rstrip()\n arr = strpline.split(',')\n newline = []\n for i in range(len(arr)):\n if arr[i] == 'y':\n newline.append(i)\...
[ 0, 1, 2, 3, 4 ]