code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
from sklearn.tree import DecisionTreeClassifier from sklearn.model_selection import train_test_split import pandas as pd import numpy as np from sklearn.datasets import load_iris from sklearn.model_selection import cross_val_score iris_dataset=load_iris() X=iris_dataset['data'] y=iris_dataset['target'] X_tra...
normal
{ "blob_id": "cc46485a3b5c68e4f77a2f9a033fd2ee2859b52b", "index": 978, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor c in range(1, 11):\n tree = DecisionTreeClassifier(max_depth=4, random_state=c)\n model.append(tree.fit(X_train, y_train))\n<mask token>\nfor a in model:\n in_sample_accuracy....
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- from __future__ import absolute_import from tests import unittest from kepler.descriptors import * class DescriptorsTestCase(unittest.TestCase): def testEnumDefaultsToNoopMapper(self): class Record(object): cat = Enum(name='cat', enums=['Lucy Cat', 'Hot Pocket']) ...
normal
{ "blob_id": "3eb40dfe68573b93c544a2279ac5c8728ae9601f", "index": 7485, "step-1": "<mask token>\n\n\nclass DescriptorsTestCase(unittest.TestCase):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass DescriptorsTestCase(unittest.TestCase):\n\n def testEnumDefaultsToNoopMapper(self):\n\n...
[ 1, 2, 3, 4, 5 ]
import requests import json import logging import time from alto.server.components.datasource import DBInfo, DataSourceAgent class CRICAgent(DataSourceAgent): def __init__(self, dbinfo: DBInfo, name: str, namespace='default', **cfg): super().__init__(dbinfo, name, namespace) self.uri = self.ensu...
normal
{ "blob_id": "55c00ce4c1657dc5ce78e5eeccd8e9625c0590dc", "index": 5345, "step-1": "<mask token>\n\n\nclass CRICAgent(DataSourceAgent):\n <mask token>\n <mask token>\n\n def run(self):\n if self.refresh_interval is None:\n self.refresh_interval = 60\n while True:\n self...
[ 2, 3, 4, 5, 6 ]
import discord from discord.ext import commands from discord.ext.commands import Bot import asyncio import random import requests import os #Discord Tech Stuff BOT_PREFIX = ("!") client = discord.Client() client = Bot(command_prefix=BOT_PREFIX) #Functions of the Funny Coin @client.command() async def wasitfunny():...
normal
{ "blob_id": "f047afeb6462ab01a8fea1f3c8693608335eb960", "index": 3488, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@client.command()\nasync def wasitfunny():\n possible_responses = [\n 'Per the judgement from the committee of comedy, we have decided that the joke was indeed funny'\n ...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.0.2 on 2020-02-18 05:52 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('myapp', '0003_admin'), ] operations = [ migrations.DeleteModel( name='admin', ), migrations.RemoveField( mod...
normal
{ "blob_id": "c0bf146ebfdb54cce80ef85c4c7f4a61632e67d4", "index": 3371, "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 = [('myapp', '00...
[ 0, 1, 2, 3, 4 ]
import typing from rest_framework.exceptions import ValidationError from rest_framework.request import Request def extract_organization_id_from_request_query(request): return request.query_params.get('organization') or request.query_params.get('organization_id') def extract_organization_id_from_request_data(re...
normal
{ "blob_id": "0b7523035fdad74454e51dc9da9fc4e9bea2f6bf", "index": 6904, "step-1": "<mask token>\n\n\ndef extract_field_from_request(request: Request, field_name: str\n ) ->typing.Optional[int]:\n \"\"\"\n Extracts attribte from request\n if attribute is present in data it has precedence over query par...
[ 1, 2, 3, 4, 5 ]
# -*- encoding: utf-8 -*- # # BigBrotherBot(B3) (www.bigbrotherbot.net) # Copyright (C) 2011 Thomas "Courgette" LÉVEIL <courgette@bigbrotherbot.net> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundat...
normal
{ "blob_id": "903d5913025d7d61ed50285785ec7f683047b49a", "index": 8960, "step-1": "# -*- encoding: utf-8 -*-\n#\n# BigBrotherBot(B3) (www.bigbrotherbot.net)\n# Copyright (C) 2011 Thomas \"Courgette\" LÉVEIL <courgette@bigbrotherbot.net>\n#\n# This program is free software; you can redistribute it and/or modify\n#...
[ 0 ]
import numpy as np from math import sqrt import warnings from collections import Counter import pandas as pd import random def k_NN(data, predict, k=3): if len(data) >= k: warnings.warn("K is set to a value less than total voting groups !") distances = [] [[ distances.append([np.linalg.norm(np.array(features) - ...
normal
{ "blob_id": "c6ce6ffe46be993bfe74ccb240e1ebf586c9f556", "index": 7656, "step-1": "<mask token>\n\n\ndef k_NN(data, predict, k=3):\n if len(data) >= k:\n warnings.warn('K is set to a value less than total voting groups !')\n distances = []\n [[distances.append([np.linalg.norm(np.array(features) - ...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf8 -*- ''' dump data from mysql/hive to load into mysql ''' from datetime import datetime,timedelta from optparse import OptionParser import argparse import ConfigParser import sys import os import time import commonutil def getConf(cfgfile): config = ConfigParser.ConfigParser() ...
normal
{ "blob_id": "df984939c109662bebbd1556c12223fce8f643e6", "index": 1773, "step-1": "<mask token>\n\n\ndef truncateFile(fileName):\n fileTemp = open(fileName, 'w')\n fileTemp.truncate()\n fileTemp.close()\n\n\ndef getConnBySecName(dbConf, secName):\n descSec = ''\n secs = dbConf.sections()\n for s...
[ 3, 4, 6, 7, 8 ]
from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Upload class DocumentForm(forms.ModelForm): class Meta: model = Upload fields = ('document',)
normal
{ "blob_id": "e7b1ccbcbb81ff02561d858a4db54d49a2aa0f8a", "index": 6094, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass DocumentForm(forms.ModelForm):\n\n\n class Meta:\n model = Upload\n fields = 'document',\n", "step-3": "from django import forms\nfrom django.contrib.auth.mod...
[ 0, 1, 2, 3 ]
print(10-10) print(1000-80) print(10/5) print(10/6) print(10//6) # remoção das casas decimais print(10*800) print(55*5)
normal
{ "blob_id": "e488761c15ee8cddbb7577d5340ee9001193c1a4", "index": 4767, "step-1": "<mask token>\n", "step-2": "print(10 - 10)\nprint(1000 - 80)\nprint(10 / 5)\nprint(10 / 6)\nprint(10 // 6)\nprint(10 * 800)\nprint(55 * 5)\n", "step-3": "print(10-10)\r\nprint(1000-80)\r\nprint(10/5)\r\nprint(10/6)\r\nprint(10/...
[ 0, 1, 2 ]
from flask import Flask, render_template, request, redirect #from gevent.pywsgi import WSGIServer import model as db import sys import time, calendar import jsonify def get_date(date): date = date.split("/") time = str(date[0]) day_str = calendar.day_name[calendar.weekday(int(date[3]), int(date[2]), int(da...
normal
{ "blob_id": "79390f3ae5dc4cc9105a672d4838a8b1ba53a248", "index": 3959, "step-1": "<mask token>\n\n\ndef get_date(date):\n date = date.split('/')\n time = str(date[0])\n day_str = calendar.day_name[calendar.weekday(int(date[3]), int(date[2]),\n int(date[1]))]\n day_num = str(int(date[1]))\n ...
[ 6, 8, 9, 10, 11 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 4 15:21:29 2021 @author: diego """ import subprocess import os import numpy as np if __name__ == "__main__": path_clusters = snakemake.input[0] path_clusters = "/".join(path_clusters.split("/")[:-1]) + "/" merge_vc...
normal
{ "blob_id": "f6d81387f61ac4150cd6279121780b7113517b1e", "index": 2860, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n path_clusters = snakemake.input[0]\n path_clusters = '/'.join(path_clusters.split('/')[:-1]) + '/'\n merge_vcf = snakemake.output[0]\n ref_genome ...
[ 0, 1, 2, 3 ]
# Author: Omkar Sunkersett # Purpose: To fetch SPP data and update the database # Summer Internship at Argonne National Laboratory import csv, datetime, ftplib, MySQLdb, os, time class SPP(): def __init__(self, server, path, start_dt, end_dt, prog_dir): self.files_cached = [] try: self.ftp_handle = ...
normal
{ "blob_id": "755eeaf86ebf2560e73869084030a3bfc89594f6", "index": 2390, "step-1": "# Author: Omkar Sunkersett\r\n# Purpose: To fetch SPP data and update the database\r\n# Summer Internship at Argonne National Laboratory\r\n\r\nimport csv, datetime, ftplib, MySQLdb, os, time\r\n\r\nclass SPP():\r\n\tdef __init__(s...
[ 0 ]
from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() from django.conf import settings from django.conf.urls.static import static from django.contrib.staticfiles.urls import staticfiles_urlpatterns from dajaxice.co...
normal
{ "blob_id": "68a503b2a94304530e20d79baf9fb094024ba67e", "index": 539, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.autodiscover()\n<mask token>\ndajaxice_autodiscover()\n<mask token>\nurlpatterns += staticfiles_urlpatterns()\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_...
[ 0, 1, 2, 3, 4 ]
# -*-coding:utf-8-*- # Author: Scott Larter import pygame import pygame.draw import numpy as np from agent import * from tools import * SCREENSIZE = [1200, 400] # walls.csv #SCREENSIZE = [1200, 650] # walls2.csv RESOLUTION = 180 AGENTSNUM = 12 GROUPSNUM = 2 MAXGROUPSIZE = 6 MAXSUBGROUPSIZE = 3 BACKGROUNDCOLOR = [255...
normal
{ "blob_id": "00051a4087bfcf2e6826e9afa898830dc59aa5ab", "index": 5451, "step-1": "<mask token>\n", "step-2": "<mask token>\npygame.init()\n<mask token>\npygame.display.set_caption('Social Force Model - Crosswalk')\n<mask token>\nfor line in open(WALLSFILE, newline='', encoding='utf-8-sig'):\n coords = line....
[ 0, 1, 2, 3, 4 ]
from selenium.webdriver import Chrome path=("/Users/karimovrustam/PycharmProjects/01.23.2020_SeleniumAutomation/drivers/chromedriver") driver=Chrome(executable_path=path) driver.maximize_window() driver.get("http://www.toolsqa.com/iframe-practice-page/") # driver.switch_to.frame("iframe2") # When working with few wi...
normal
{ "blob_id": "53eb1dcd54ce43d9844c48eb1d79f122a87dca39", "index": 3831, "step-1": "<mask token>\n", "step-2": "<mask token>\ndriver.maximize_window()\ndriver.get('http://www.toolsqa.com/iframe-practice-page/')\ndriver.switch_to.default_content()\ndriver.find_element_by_xpath(\"//span[text()='VIDEOS']\").click()...
[ 0, 1, 2, 3, 4 ]
import os import matplotlib.pyplot as plt import cv2 import numpy as np def divide_img(img_path, img_name, save_path): imgg = img_path +'\\' +img_name print(imgg) img = cv2.imread(imgg) print(img) # img = cv2.cvtColor(img,cv2.COLOR_BGR2RGB) h = img.shape[0] w = img.shape[1] n = 8 ...
normal
{ "blob_id": "03f3fcb38877570dea830a56460061bd3ccb8927", "index": 8830, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef divide_img(img_path, img_name, save_path):\n imgg = img_path + '\\\\' + img_name\n print(imgg)\n img = cv2.imread(imgg)\n print(img)\n h = img.shape[0]\n w = img...
[ 0, 1, 2, 3, 4 ]
import sys from .csvtable import * from .utils import * from .reporter import Reporter class ColumnKeyVerifier: def __init__(self): self.keys = {} def prologue(self, table_name, header): if 0 == len(header): return False # 키는 첫번째 컬럼에만 설정 가능하다. return header[0].is_...
normal
{ "blob_id": "eca4abf706fd094a40fdfc8ea483d71b0a018ce9", "index": 4378, "step-1": "<mask token>\n\n\nclass ColumnKeyVerifier:\n <mask token>\n <mask token>\n\n def epilogue(self):\n pass\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ColumnKeyVerifier:\n\n def __init__(self):\n ...
[ 2, 4, 5, 6, 7 ]
# Generated by Django 3.1.7 on 2021-02-24 05:37 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('autotasks', '0017_auto_20210210_1512'), ] operations = [ migrations.AddField( model_name='automatedtask', name='run_...
normal
{ "blob_id": "3ab1de77147f6abfabeea10f2a4e85686edffd6f", "index": 2573, "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 = [('autotasks',...
[ 0, 1, 2, 3, 4 ]
# Jarvis interface class definition import kernel.service class interface(kernel.service.service): def __init__(self, name): self.name = name
normal
{ "blob_id": "237f1f72ac3ef381f115a88025518f387825ff79", "index": 9696, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass interface(kernel.service.service):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass interface(kernel.service.service):\n\n def __init__(self, name):\n self.n...
[ 0, 1, 2, 3, 4 ]
from rest_framework.permissions import BasePermission, SAFE_METHODS class IsOwnerOrStaffOrReadOnly(BasePermission): def has_object_permission(self, request, view, obj): """ Переопределяем права доступа. Даем все права на запись, только владельцу или администратору, на чтение даем...
normal
{ "blob_id": "4488612164435ab062ca66000f0d7dc3ccd89da2", "index": 8150, "step-1": "<mask token>\n\n\nclass IsOwnerOrStaffOrReadOnly(BasePermission):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass IsOwnerOrStaffOrReadOnly(BasePermission):\n\n def has_object_permission(self, request...
[ 1, 2, 3, 4 ]
# Copyright 2015 Google Inc. 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": "b4ce95d754dd0d7c1b91fa0348de0194a4397aca", "index": 6830, "step-1": "<mask token>\n\n\nclass NodeLookup(object):\n \"\"\"Converts integer node ID's to human readable labels.\"\"\"\n\n def __init__(self, label_lookup_path=None, uid_lookup_path=None):\n if not label_lookup_path:\n ...
[ 6, 7, 11, 13, 14 ]
"""IDQ Importer Exporter This script defines Import and Export functions through which it can communicate with a Informatica Model Repository. It also provides some related functions, such as: - Create IDQ folder - Check in IDQ components Parts by Laurens Verhoeven Parts by Jac. Beekers @Version: 20190...
normal
{ "blob_id": "09b14705a6905470058b5eecc6dd0bb214975c66", "index": 6408, "step-1": "<mask token>\n\n\ndef import_infadeveloper(**KeyWordArguments):\n \"\"\"Import IDQ Components\"\"\"\n KeyWordArguments['Tool'] = 'Import'\n ImportCommand = buildCommand.build(**KeyWordArguments)\n result = executeInfacm...
[ 10, 11, 12, 13, 14 ]
# Generated by Django 2.2.1 on 2019-06-01 09:56 from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ] operations = [ migrations.CreateModel( name='Participant', fields=[ ('username', models....
normal
{ "blob_id": "58b12418a2a6b1ef9b63800b89e7f0b9fffd908c", "index": 9223, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
import logging import os.path from day03.code.main import traverse_map, get_map_cell, traverse_map_multiple_slopes logger = logging.getLogger(__name__) local_path = os.path.abspath(os.path.dirname(__file__)) def test_get_map_cell(): map_template = """..##....... #...#...#.. .#....#..#. ..#.#...#.# .#...##..#. ....
normal
{ "blob_id": "7599f13d1cabe73d876ff97722962f2fcf9a9940", "index": 2269, "step-1": "<mask token>\n\n\ndef test_sample_input():\n map_template = \"\"\"..##.......\n#...#...#..\n.#....#..#.\n..#.#...#.#\n.#...##..#.\n..#.##.....\n.#.#.#....#\n.#........#\n#.##...#...\n#...##....#\n.#..#...#.#\"\"\"\n logger.in...
[ 5, 6, 7, 8, 9 ]
mapName =input('\nEnter map name(s) (omitting the mp_ prefix)\nSeparate map names with comma\n:').lower() mapNameList =mapName.split(',') def convertWPFile(mapName): #Converts mapname_waypoints.gsc file (old style PEzBot format) to newer mapname.gsc file (new style Bot Warfare format) fullMapName ='mp_'+m...
normal
{ "blob_id": "1aacd04234d60e495888fc44abe3fbacf404e0ce", "index": 5799, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef convertWPFile(mapName):\n fullMapName = 'mp_' + mapName + '_waypoints.gsc'\n waypoints = open(fullMapName, 'r')\n wpLines = waypoints.readlines()\n waypoints.close()\n...
[ 0, 1, 2, 3, 4 ]
t = int(input()) m = 0 while(m < t): n = int(input()) arr = list(map(int, input().strip().split(" "))) s = int(input()) hash_map = {} curr_sum = 0 count = 0 for i in range(len(arr)): curr_sum += arr[i] if curr_sum == s: count += 1 if curr_sum - s in hash_m...
normal
{ "blob_id": "3ac69068db94f45bc44a8295a10603126d004b34", "index": 6219, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile m < t:\n n = int(input())\n arr = list(map(int, input().strip().split(' ')))\n s = int(input())\n hash_map = {}\n curr_sum = 0\n count = 0\n for i in range(len(...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ Created on Thu Sep 3 18:45:08 2020 @author: Neeraj """ import cv2 import numpy as np num_down=2 num_bilateral=50 img_rgb=cv2.imread("stunning-latest-pics-of-Kajal-Agarwal.jpg") #image path img_rgb=cv2.resize(img_rgb,(800,800)) img_color=img_rgb for _ in range(num_...
normal
{ "blob_id": "16db443642746af4ae45862627baaa9eca54a165", "index": 3138, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(num_down):\n img_color = cv2.pyrDown(img_color)\nfor _ in range(num_bilateral):\n img_color = cv2.bilateralFilter(img_color, d=9, sigmaColor=9, sigmaSpace=7)\nfor _ i...
[ 0, 1, 2, 3, 4 ]
''' Useful constants. Inspired by pyatspi: http://live.gnome.org/GAP/PythonATSPI @author: Eitan Isaacson @copyright: Copyright (c) 2008, Eitan Isaacson @license: LGPL This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the ...
normal
{ "blob_id": "5ec2ac3e0d66026da1b0c957d10c95e95c201f8f", "index": 9032, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _sym, _val in locals().items():\n if _sym.startswith('EVENT_') or _sym.startswith('IA2_EVENT_'):\n winEventIDsToEventNames[_val] = _sym\n", "step-3": "<mask token>\nCHILDI...
[ 0, 1, 2, 3 ]
''' Functional tests for the Write Stream ''' from behave import given, when, then from OSC import OSCClient, OSCMessage, OSCServer @given('I want to send an integer') def step_impl (context): pass @given('I want to send a float') def step_impl (context): pass @given('I want to send two integers with one ...
normal
{ "blob_id": "3770e59c5bd6837a0fb812f80c6549024e06a9e4", "index": 5957, "step-1": "<mask token>\n\n\n@given('I want to send an integer')\ndef step_impl(context):\n pass\n\n\n<mask token>\n\n\n@given('I want to send two integers with one channel')\ndef step_impl(context):\n pass\n\n\n@given('I want to send t...
[ 8, 10, 12, 13, 15 ]
from django.urls import path, include from .views import StatusAPIView, StateAPIView, LogAPIView urlpatterns = [ path('status/', StatusAPIView.as_view(), name='status'), path('log/', LogAPIView.as_view(), name='log'), path('state/', StateAPIView.as_view(), name='state'), ]
normal
{ "blob_id": "1ae8d78c6581d35cd82194e2565e7a11edda1487", "index": 7265, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('status/', StatusAPIView.as_view(), name='status'),\n path('log/', LogAPIView.as_view(), name='log'), path('state/',\n StateAPIView.as_view(), name='state')]\n",...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ Created on Mon Sep 11 07:41:34 2017 @author: Gabriel """ months = 12 balance = 4773 annualInterestRate = 0.2 monthlyPaymentRate = 434.9 monthlyInterestRate = annualInterestRate / 12 while months > 0: minimumMonPayment = monthlyPaymentRate * balance monthlyUnpaidBa...
normal
{ "blob_id": "299b437c007d78c3d9a53205de96f04d2c6118e0", "index": 7662, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile months > 0:\n minimumMonPayment = monthlyPaymentRate * balance\n monthlyUnpaidBalan = balance - monthlyPaymentRate\n balance = monthlyUnpaidBalan + monthlyInterestRate * mo...
[ 0, 1, 2, 3 ]
from datetime import datetime start = datetime.now() # Poker Hand Analyser Library for Project Euler: Problem 54 from collections import namedtuple # import pe_lib def character_frequency(s): freq = {} for i in s: if i in freq: freq[i] += 1 else: freq[i] = 1 return freq suits = "HDCS".split() faces = "2...
normal
{ "blob_id": "561763d4d7b613446f2890ef629b631542f2f472", "index": 2776, "step-1": "<mask token>\n\n\nclass Card(namedtuple('Card', 'face, suit')):\n\n def __repr__(self):\n return ''.join(self)\n\n\ndef royal_flush(hand):\n royalface = 'TJQKA'\n ordered = sorted(hand, key=lambda card: (faces.index...
[ 7, 8, 10, 17, 19 ]
# # 8/19/2020 # Of course, binary classification is just a single special case. Target encoding could be applied to any target variable type: # For binary classification usually mean target encoding is used # For regression mean could be changed to median, quartiles, etc. # For multi-class classification with N classe...
normal
{ "blob_id": "5433e75bdc46d5a975969e7ece799174dc9b8713", "index": 2918, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(test[['RoofStyle', 'RoofStyle_enc']].drop_duplicates())\n", "step-3": "train['RoofStyle_enc'], test['RoofStyle_enc'] = mean_target_encoding(train=\n train, test=test, target='S...
[ 0, 1, 2, 3 ]
# Generated by Django 3.0.3 on 2020-05-30 05:32 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('people', '0110_auto_20200530_0631'), ] operations = [ migrations.AlterField( model_name='site', name='password_reset...
normal
{ "blob_id": "795f936423965063c44b347705c53fd1c306692f", "index": 4927, "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 = [('people', '0...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import socket import threading import signal import sys class Proxy: #initialise server socket def __init__(self): self.serverSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.serverSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1...
normal
{ "blob_id": "2dcf0466c84c952c60dcfce86498f063f43726f3", "index": 2298, "step-1": "#!/usr/bin/python\n\nimport socket\nimport threading\nimport signal\nimport sys\n \nclass Proxy:\n #initialise server socket\n def __init__(self): \n self.serverSocket = socket.socket(socket.AF_INET, socket.SOCK...
[ 0 ]
from .queue_worker import QueueWorker import threading class WorkersOrchestrator: @classmethod def worker_func(cls, worker): worker.start_consumption() def run_orchestrator(self, num_of_workers): worker_list = [] for i in range(num_of_workers): worker_list.append(Queu...
normal
{ "blob_id": "6a4a5eac1b736ee4f8587adba298571f90df1cf9", "index": 8864, "step-1": "<mask token>\n\n\nclass WorkersOrchestrator:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass WorkersOrchestrator:\n\n @classmethod\n def worker_func(cls, worker):\n worker.start_consumption...
[ 1, 2, 3, 4 ]
import copy import os from datetime import datetime import numpy as np from sklearn.neighbors import NearestNeighbors from sklearn.preprocessing import normalize ROOT_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), '../') DATA_FILE = os.path.join(ROOT_DIR, 'data/data_train.csv') TRAINING_FILE_NAME = os....
normal
{ "blob_id": "af1eab58fd641b14ac054fa26e28d52c9741fb16", "index": 7675, "step-1": "<mask token>\n\n\ndef ratings_to_matrix(ratings):\n matrix_rows = USER_COUNT\n matrix_cols = ITEM_COUNT\n matrix = np.zeros([matrix_rows, matrix_cols])\n for row, col, rating in ratings:\n matrix[row, col] = rati...
[ 16, 19, 21, 22, 24 ]
import numpy as np class Element(object): def __init__(self): self.ndof = 0 self.nn = 0 self.ng = 0 self.element_type = 0 self.coord_position = np.array([]) self.setup() def setup(self): pass def shape_function_value(self): pass def s...
normal
{ "blob_id": "ed2ae166c4881289b27b7e74e212ba2d6164998b", "index": 2981, "step-1": "<mask token>\n\n\nclass Element(object):\n\n def __init__(self):\n self.ndof = 0\n self.nn = 0\n self.ng = 0\n self.element_type = 0\n self.coord_position = np.array([])\n self.setup()\n...
[ 3, 4, 5, 6 ]
from discord import Message, ChannelType from discord.ext.commands import Bot, Cog, command, Context from ccbot import repo from shared import fetch_tools import os class Submissions(Cog): def __init__(self, bot: Bot) -> None: self.bot = bot @command() async def current(self, ctx: Context) -> None...
normal
{ "blob_id": "82bfdb46e1da96e5db91d66c3a060d8bf7747d07", "index": 2214, "step-1": "<mask token>\n\n\nclass Submissions(Cog):\n <mask token>\n\n @command()\n async def current(self, ctx: Context) ->None:\n await ctx.trigger_typing()\n repo.init()\n drafts = repo.drafts()\n if n...
[ 1, 2, 3, 4, 5 ]
from .slinklist import SingleLinkedList
normal
{ "blob_id": "2a5d498a386190bdd2c05bc2b14db0fecd707162", "index": 1128, "step-1": "<mask token>\n", "step-2": "from .slinklist import SingleLinkedList\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
#давайте напишем программу русской рулетки import random amount_of_bullets = int(input("Сколько вы хотите вставить патронов?")) baraban = [0, 0, 0, 0, 0, 0] # 0 -аналогия пустого гнезда # 1 - аналогия гнезда с патроном for i in range(amount_of_bullets): print(i) baraban[i] = 1 print("Посмотрите на барабан"...
normal
{ "blob_id": "6c0080aa62579b4cbdaf3a55102924bfe31ffb40", "index": 8107, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(amount_of_bullets):\n print(i)\n baraban[i] = 1\nprint('Посмотрите на барабан', baraban)\n<mask token>\nfor i in range(how_much):\n random.shuffle(baraban)\n if...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # @Time : 2021/5/12 2:48 下午 # @Author : shaoguowen # @Email : shaoguowen@tencent.com # @FileName: train.py # @Software: PyCharm import argparse from mmcv import Config import trainers # 解析传入的参数 parser = argparse.ArgumentParser(description='Train IVQA model') parser.add_argument('config',...
normal
{ "blob_id": "46e2955756cf1aea902f31685b258ffd14b2e62b", "index": 5291, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('config', help='train config file path')\n<mask token>\nif __name__ == '__main__':\n trainer = getattr(trainers, config.trainer.trainer_name)(config, args.\n ...
[ 0, 1, 2, 3, 4 ]
# 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 agreed to ...
normal
{ "blob_id": "5e2fcc6379a8ecee0378d26108e4deab9d17dba6", "index": 7483, "step-1": "<mask token>\n\n\nclass NSDescriptorsViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n\n def get_success_headers(self, data):\n return {'Location': data['_links']['self']}\n\n def ...
[ 6, 7, 8, 9, 10 ]
class car: def info(self): print(self.speed, self.color, self.model) def increment(self): print('increment') def decrement(self): print('decrement') BMW = car() BMW.speed = 320 BMW.color = 'red' BMW.model = 1982 BMW.info() Camry = car() Camry.speed = 220 Camry.color = 'blue'
normal
{ "blob_id": "022f588455d8624d0b0107180417f65816254cb1", "index": 8687, "step-1": "class car:\n\n def info(self):\n print(self.speed, self.color, self.model)\n\n def increment(self):\n print('increment')\n <mask token>\n\n\n<mask token>\n", "step-2": "class car:\n\n def info(self):\n ...
[ 3, 4, 5, 6 ]
from django.db import models from albums.models import Albums class Song(models.Model): name = models.CharField(max_length=255) filename = models.FileField(upload_to='canciones/') album = models.ForeignKey(Albums) def __unicode__(self,): return self.name
normal
{ "blob_id": "8ec18e259af1123fad7563aee3a363e095e30e8e", "index": 1064, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Song(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n def __unicode__(self):\n return self.name\n", "step-3": "<mask token>\n\n\nclass Song(m...
[ 0, 2, 3, 4, 5 ]
from __future__ import annotations from collections import Counter from distribution import Distribution, Normal class GoodKind: """ The definition of a kind of good. "Vegtable" is a kind of good, as is "Iron Ore", "Rocket Fuel", and "Electic Motor" """ def __init__(self, name: str): as...
normal
{ "blob_id": "286801b69546046853d123c5708f24eaaa2e8cec", "index": 6044, "step-1": "<mask token>\n\n\nclass Recipe:\n <mask token>\n\n def __init__(self, labor_amount: float, required_goods: BagOfGoods,\n planet_variation: Distribution, person_variation: Distribution,\n labor_variation: Distrib...
[ 6, 9, 17, 23, 26 ]
import sys import os import cv2 def write_video(fps, input_folder="output",video_name="video.mp4"): fourcc = cv2.VideoWriter_fourcc("m","p","4","v") video = cv2.VideoWriter(video_name, fourcc, fps, (1280,720)) path = os.getcwd() files = os.listdir(path+"/"+input_folder) count = len(files) ...
normal
{ "blob_id": "ca0c38cf2a55b2311a254b09cb693516c3d0ab10", "index": 1763, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef write_video(fps, input_folder='output', video_name='video.mp4'):\n fourcc = cv2.VideoWriter_fourcc('m', 'p', '4', 'v')\n video = cv2.VideoWriter(video_name, fourcc, fps, (12...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python from google.appengine.ext.webapp import template from google.appengine.ext import ndb import logging import os.path import webapp2 import json from webapp2_extras import auth from webapp2_extras import sessions from webapp2_extras.auth import InvalidAuthIdError from webapp2_extras.auth import ...
normal
{ "blob_id": "fe7fb9a4a5ca2bb8dab0acf440eb2fac127264ce", "index": 2631, "step-1": "<mask token>\n\n\nclass BaseHandler(webapp2.RequestHandler):\n\n @webapp2.cached_property\n def auth(self):\n \"\"\"Shortcut to access the auth instance as a property.\"\"\"\n return auth.get_auth()\n <mask t...
[ 40, 42, 48, 49, 51 ]
from __future__ import division rates = { "GBP-EUR":1.10, "EUR-USD":1.11, "GBP-USD":1.22, "GBP-YEN": 129.36 } def find(rates, fx): try: return rates[fx] except: return -1 def getInputs(): amount = raw_input("Enter amount: ") firstCurrency = raw_input("Enter Currency To Convert From: ") secCurrency = raw_in...
normal
{ "blob_id": "c664257d64b269002964ce95c05f132e563a65d4", "index": 8736, "step-1": "from __future__ import division\n\nrates = { \"GBP-EUR\":1.10, \"EUR-USD\":1.11, \"GBP-USD\":1.22, \"GBP-YEN\": 129.36 }\n\ndef find(rates, fx):\n\ttry:\n\t\treturn rates[fx]\n\texcept:\n\t\treturn -1\n\n\ndef getInputs():\n\tamoun...
[ 0 ]
import Individual import Grupal import matplotlib.pyplot as plt import pandas as pd plt.show()
normal
{ "blob_id": "bb1caf4d04c8a42279afa0ac586ced991e0dff84", "index": 4574, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.show()\n", "step-3": "import Individual\nimport Grupal\nimport matplotlib.pyplot as plt\nimport pandas as pd\nplt.show()\n", "step-4": null, "step-5": null, "step-ids": [ ...
[ 0, 1, 2 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import random """ 检查图数据和结构或者链表数据结构中是否存在环 https://www.youtube.com/watch?v=YKE4Vd1ysPI """ def get_all_edge(graph): result = [] for k, v in graph.items(): for i in v: if sorted((k, i)) not in result: result.append(sorted((k, ...
normal
{ "blob_id": "371762a6e3f8b8ed14742a70a709da224ae6712b", "index": 305, "step-1": "<mask token>\n\n\ndef bfs(graph, start):\n result = []\n queue = []\n seen = set()\n queue.append(start)\n seen.add(start)\n while len(queue):\n vertex = queue.pop(0)\n nodes = graph[vertex]\n ...
[ 1, 2, 3, 4, 5 ]
class HashTable: def __init__(self): self.dados = [] def hash(self, chave): return int(chave) def __put(self, int, chave, valor): self.dados.append({chave: valor}) """ backup = dados dados = novo_array(t * 2) for elemento in backup: hash = hash(elemento.chave) __put(...
normal
{ "blob_id": "f14d46bedd5f6e0081a982251ad45e95860ef310", "index": 209, "step-1": "class HashTable:\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "class HashTable:\n <mask token>\n\n def hash(self, chave):\n return int(chave)\n <mask token>\n\n\n<mask token...
[ 1, 2, 3, 4, 5 ]
# bot.py import os import sqlite3 import json import datetime from dotenv import load_dotenv import discord from discord.ext import commands from discord.ext.commands import Bot from cogs.utils import helper as h intents = discord.Intents.default() intents.members = True load_dotenv() TOKEN = os.getenv('DISCORD_T...
normal
{ "blob_id": "849343561dd9bdcfc1da66c604e1bfa4aa10ddf3", "index": 5359, "step-1": "<mask token>\n\n\nclass LLKEventsBot(Bot):\n <mask token>\n\n async def on_ready(self):\n if not os.path.exists('db'):\n os.makedirs('db')\n if not os.path.exists('logs'):\n os.makedirs('lo...
[ 1, 2, 4, 5, 6 ]
class Solution: def jump(self, nums: List[int]) -> int: if len(nums) < 2: return 0 jump = 1 curr_max = max_reach = nums[0] for i ...
normal
{ "blob_id": "7f2ffa653486d000c9eee0087fc1e6ca0c84003c", "index": 5671, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def jump(self, nums: List[int]) ->int:\n if len(nums) < 2:\n return 0\n jump = 1\n curr_max = m...
[ 0, 1, 2, 3 ]
''' selection review very similar to quicksort in terms of set up. no need to sort to find kth element in a list but instead can be done in o(n) quick sort can be o(nlogn) if we choose median instead of pivot tips: raise value error for bad index not in between 0 <= k < n basecase of n <=1 --> return arr[0] use L, E, ...
normal
{ "blob_id": "69d3a39dc024929eaf6fb77e38a7a818d2886cf7", "index": 8512, "step-1": "<mask token>\n\n\ndef select(arr, k):\n n = len(arr)\n if not 0 <= k < n:\n raise ValueError('not valid index in array')\n if n <= 1:\n return arr[0]\n pivot = random.choice(arr)\n L, E, G = [], [], []\...
[ 1, 2, 3, 4, 5 ]
# 30 - Faça um programa que receba três números e mostre - os em ordem crescentes. n1 = int(input("Digite o primeiro número: ")) n2 = int(input("Digite o segundo número: ")) n3 = int(input("Digite o terceiro número: ")) if n1 <= n2 and n2 <= n3: print(f'A ordem crescente é {n1}, {n2}, {n3}') elif n1 <= n3 and n3 ...
normal
{ "blob_id": "09712a397ad7915d9865b4aebf16606f85988f67", "index": 2737, "step-1": "<mask token>\n", "step-2": "<mask token>\nif n1 <= n2 and n2 <= n3:\n print(f'A ordem crescente é {n1}, {n2}, {n3}')\nelif n1 <= n3 and n3 <= n2:\n print(f'A ordem crescente é {n1}, {n3}, {n2}')\nelif n2 <= n1 and n1 <= n3:...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # crits_ldap.py # This connects to an LDAP server and pulls data about all users. # Then, it either updates existing targets in CRITS or creates a new entry. import json import sys import datetime import logging import logging.config from configparser import ConfigParser from ldap3 import Serve...
normal
{ "blob_id": "5d568c5ac9040ad93749c27bd6fe1a956e7456f7", "index": 9016, "step-1": "#!/usr/bin/env python3\n# crits_ldap.py\n# This connects to an LDAP server and pulls data about all users.\n# Then, it either updates existing targets in CRITS or creates a new entry.\n\nimport json\nimport sys\nimport datetime\nim...
[ 0 ]
""" Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. The order of elements can be changed. It doesn't matter ...
normal
{ "blob_id": "8be4bf5c1a5a7b841edc915793571686ee0bffe6", "index": 113, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def remove_element(self, nums: list[int], val: int) ->int:\n last_p...
[ 0, 1, 2, 3 ]
import time #melakukan import library time import zmq #melakukan import library ZeroMQ context = zmq.Context() #melakukan inisialisasi context ZeroMQ pada variable context socket = context.socket(zmq.REP) #menginisialisasikan socket(Reply) pada variable context(ZeroMQ) socket.bind("tcp://10.20.32.221:5555") #melakuka...
normal
{ "blob_id": "ccba923fa4b07ca9c87c57797e1e6c7da3a71183", "index": 4315, "step-1": "<mask token>\n", "step-2": "<mask token>\nsocket.bind('tcp://10.20.32.221:5555')\nwhile True:\n message = socket.recv()\n print('Received request: %s' % message)\n time.sleep(1)\n socket.send(b'World')\n", "step-3":...
[ 0, 1, 2, 3, 4 ]
from django.db import models class Subscribe(models.Model): mail_subscribe = models.EmailField('Пошта', max_length=40) def __str__(self): return self.mail_subscribe class Meta: verbose_name = 'підписку' verbose_name_plural = 'Підписки'
normal
{ "blob_id": "3c22b187f8538e16c0105706e6aac2875ea3a25c", "index": 6162, "step-1": "<mask token>\n\n\nclass Subscribe(models.Model):\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_name = 'підписку'\n verbose_name_plural = 'Підписки'\n", "step-2": "<mask token>\n\n\nclass Subscri...
[ 1, 2, 3, 4 ]
from opengever.propertysheets.assignment import get_document_assignment_slots from opengever.propertysheets.assignment import get_dossier_assignment_slots from opengever.propertysheets.storage import PropertySheetSchemaStorage from plone.restapi.services import Service LISTING_TO_SLOTS = { u'dossiers': get_dossie...
normal
{ "blob_id": "ab352c9431fda19bc21a9f7ffa075303641cca45", "index": 155, "step-1": "<mask token>\n\n\nclass ListingCustomFieldsGet(Service):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ListingCustomFieldsGet(Service):\n <mask token>\n\n def reply(self):\n solr_fields = ...
[ 1, 2, 3, 5, 6 ]
#!/usr/bin/env python import vtk from vtk.util.misc import vtkGetDataRoot VTK_DATA_ROOT = vtkGetDataRoot() # Create the RenderWindow, Renderer and both Actors # ren1 = vtk.vtkRenderer() ren2 = vtk.vtkRenderer() renWin = vtk.vtkRenderWindow() renWin.SetMultiSamples(0) renWin.AddRenderer(ren1) renWin.AddRenderer(ren2) i...
normal
{ "blob_id": "7399612f64eb8e500bc676e6d507be5fe375f40f", "index": 3746, "step-1": "<mask token>\n", "step-2": "<mask token>\nrenWin.SetMultiSamples(0)\nrenWin.AddRenderer(ren1)\nrenWin.AddRenderer(ren2)\n<mask token>\niren.SetRenderWindow(renWin)\n<mask token>\npl3d.SetXYZFileName('' + str(VTK_DATA_ROOT) + '/Da...
[ 0, 1, 2, 3, 4 ]
import IDS # In[7]: # testfile = 'data/good_fromE2.txt' # testfile = 'data/goodqueries.txt' good_testfile = "data/good_fromE2.txt" bad_testfile = "data/badqueries.txt" # a = IDS.LG() a = IDS.SVM() # preicdtlist = ['www.foo.com/id=1<script>alert(1)</script>','www.foo.com/name=admin\' or 1=1','abc.com/admin.php','"><s...
normal
{ "blob_id": "e627bcc6c9a49d46190cc793a77103aa0a760989", "index": 1709, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(good_testfile, 'r') as f:\n print('预测数据集: ' + good_testfile)\n preicdtlist = [i.strip('\\n') for i in f.readlines()[:]]\n result = a.predict(preicdtlist)\n print('恶意...
[ 0, 1, 2, 3, 4 ]
import logging from queue import Queue import concurrent.futures """ Post processing decorater logic for FtpDownloader """ class FtpDownloaderPostProcess: def __init__(self, ftp_downloader, post_processor, num_workers=None, config_dict=None): self.post_processor = post_processor self.ftp_downlo...
normal
{ "blob_id": "56a41f432d332aaebbde15c52e133eee51b22ce1", "index": 2833, "step-1": "<mask token>\n\n\nclass FtpDownloaderPostProcess:\n <mask token>\n <mask token>\n\n @property\n def logger(self):\n return logging.getLogger(__name__)\n\n def iterate(self, *args, **kwargs):\n \"\"\"\nU...
[ 4, 6, 7, 8, 9 ]
import numpy as np def SO3_to_R3(x_skew): x = np.zeros((3, 1)) x[0, 0] = -1 * x_skew[1, 2] x[1, 0] = x_skew[0, 2] x[2, 0] = -1 * x_skew[0, 1] return x
normal
{ "blob_id": "97bff6eb0cd16c915180cb634e6bf30e17adfdef", "index": 2080, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef SO3_to_R3(x_skew):\n x = np.zeros((3, 1))\n x[0, 0] = -1 * x_skew[1, 2]\n x[1, 0] = x_skew[0, 2]\n x[2, 0] = -1 * x_skew[0, 1]\n return x\n", "step-3": "import nu...
[ 0, 1, 2 ]
#!/usr/bin/python3 ''' FileStorage module ''' import json from models.base_model import BaseModel import models from models.user import User from models.place import Place from models.state import State from models.city import City from models.amenity import Amenity from models.review import Review class FileStorage:...
normal
{ "blob_id": "5461d50d3c06bc4276044cc77bd804f6e7c16b3b", "index": 1278, "step-1": "<mask token>\n\n\nclass FileStorage:\n <mask token>\n <mask token>\n <mask token>\n\n def all(self):\n \"\"\"\n Return:\n the dictionary __objects\n \"\"\"\n return self.__objects\n ...
[ 3, 5, 7, 8, 9 ]
import csv import tweepy import pandas as pd ####input your credentials here from tweepy.auth import OAuthHandler auth = OAuthHandler('WNUpykrIjiGF0NKoV7qk7uiNj', 'Nhe0GjOkbaQKbPMLTqcAYQnqMnz3Edpdup28h2R2KqRLa6iBDN') auth.set_access_token('956917059287375875-EThit80MxgQPTJlh7ZObqyHsoV8Q2D7', 'eLv893meGppqfX3xOr8SJ93kps...
normal
{ "blob_id": "b68cc09347584dfc613b2e38d036b124c9af7952", "index": 1904, "step-1": "<mask token>\n", "step-2": "<mask token>\nauth.set_access_token('956917059287375875-EThit80MxgQPTJlh7ZObqyHsoV8Q2D7',\n 'eLv893meGppqfX3xOr8SJ93kpsbZpoOiRsVM3XTgJryZM')\n<mask token>\nauth.set_access_token('956917059287375875-...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python """ A package that determines the current day of the week. """ from datetime import date import calendar # Set the first day of the week as Sunday. calendar.firstday(calendar.SUNDAY) def day_of_the_week(arg): """ Returns the current day of the week. """ if arg == "day": ...
normal
{ "blob_id": "7e23f5598ccfe9aff74d43eb662f860b0404b7ec", "index": 8333, "step-1": "#!/usr/bin/env python\n\n\"\"\"\nA package that determines the current day of the week.\n\"\"\"\n\nfrom datetime import date \nimport calendar\n\n# Set the first day of the week as Sunday.\n\ncalendar.firstday(calendar.SUNDAY)\n\nd...
[ 0 ]
"Base document saver context classes." import copy import os.path import sys import flask from . import constants from . import utils class BaseSaver: "Base document saver context." DOCTYPE = None EXCLUDE_PATHS = [["_id"], ["_rev"], ["doctype"], ["modified"]] HIDDEN_VALUE_PATHS = [] def __ini...
normal
{ "blob_id": "83fe635e35711c2c41d043a59d00a50cc87e69fa", "index": 7696, "step-1": "<mask token>\n\n\nclass BaseSaver:\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 <mask token...
[ 8, 15, 21, 22, 24 ]
""" Design and implement a TwoSum class. It should support the following operations: add and find. add - Add the number to an internal data structure. find - Find if there exists any pair of numbers which sum is equal to the value. Example 1: add(1); add(3); add(5); find(4) -> true find(7) -> false Example 2: add(3);...
normal
{ "blob_id": "025c740813f7eea37abadaa14ffe0d8c1bedc79d", "index": 6275, "step-1": "<mask token>\n\n\nclass TwoSum:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TwoSum:\n\n def __init__(self):\n \"\"\"\n Initialize your data structure here.\n ...
[ 1, 2, 3, 4, 5 ]
"""Identifying Antecedent Pronoun""" from question import Question,Packet qdict={ "correct pronoun-antecedent agreement":[ "<u>He</u> came home to <u>his</u> own car.", "<u>He</u> found <u>his</u> sneakers in the garage.", "<u>Harry</u> gave <u>himself</u> a baseball for Christmas.", "<u>Jill</u> found <u>her</u> miss...
normal
{ "blob_id": "94b1e0280eff165f63e117969d5e1bf9d1e35193", "index": 1598, "step-1": "\"\"\"Identifying Antecedent Pronoun\"\"\"\nfrom question import Question,Packet\n\nqdict={\n\"correct pronoun-antecedent agreement\":[\n\"<u>He</u> came home to <u>his</u> own car.\",\n\"<u>He</u> found <u>his</u> sneakers in the ...
[ 0 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-01-03 19:28 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('mybus', '0007_auto_20160104_0053'), ] operations = [ migrations.RemoveField(...
normal
{ "blob_id": "1dec7a997b0bef3226fb17e4039b053c7a2e457e", "index": 9045, "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 = [('mybus', '00...
[ 0, 1, 2, 3, 4 ]
import webapp2 class RedirectToSiteRootHandler(webapp2.RequestHandler): def get(self): self.response.set_status(301) self.response.headers['Location'] = '/' class AppendTrailingSlashHandler(webapp2.RequestHandler): def get(self, uri): self.response.set_status(301) redirect_uri = uri + ...
normal
{ "blob_id": "064792a6aba96a679bec606a85b19d4925861f7d", "index": 2493, "step-1": "<mask token>\n\n\nclass AppendTrailingSlashHandler(webapp2.RequestHandler):\n\n def get(self, uri):\n self.response.set_status(301)\n redirect_uri = uri + '/'\n self.response.headers['Location'] = redirect_u...
[ 2, 3, 4, 6, 7 ]
#Exercise 2 - Write a Python class which has two methods get_String and print_String. get_String accept a string #from the user and print_String print the string in upper case #string will be an input to a get_string method and whatever you put in will print when you make the print screen method class IOString(): ...
normal
{ "blob_id": "cf2973b94f1113013fe9baa946202ec75488f7d2", "index": 9697, "step-1": "class IOString:\n <mask token>\n\n def get_String(self):\n self.str1 = input()\n <mask token>\n\n\n<mask token>\n", "step-2": "class IOString:\n <mask token>\n\n def get_String(self):\n self.str1 = in...
[ 2, 3, 4, 5, 7 ]
from django.apps import AppConfig class BooksaleConfig(AppConfig): name = 'booksale'
normal
{ "blob_id": "e642054dad8a2de5b01f2994348e10e9c7574ee0", "index": 4581, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BooksaleConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass BooksaleConfig(AppConfig):\n name = 'booksale'\n", "step-4": "from django.apps import ...
[ 0, 1, 2, 3 ]
''' Create a dictionary of fasttext embedding, stored locally fasttext import. This will hopefully make it easier to load and train data. This will also be used to store the Steps to clean scripts (codify): 1) copy direct from website (space-delimited text) 2) remove actions in ...
normal
{ "blob_id": "9a6ceeb286bb6c3d5923fe3b53be90a097e16ef5", "index": 1078, "step-1": "<mask token>\n\n\ndef convert_lines_to_arrays(content):\n \"\"\"\n convert each line in scene to an array of text\n formating when not relevant\n \"\"\"\n lines = []\n for x in content:\n line = x.s...
[ 12, 13, 15, 16, 17 ]
#!/usr/bin/env python3 """Transfer learning with xception""" import tensorflow.keras as K from GPyOpt.methods import BayesianOptimization import pickle import os import numpy as np class my_model(): """A model bassed on xception""" def make_model(self, param): """makes the model""" self.lr = ...
normal
{ "blob_id": "d015a1b27a3a9e7f5e6614da752137064000b905", "index": 239, "step-1": "<mask token>\n\n\nclass my_model:\n <mask token>\n\n def make_model(self, param):\n \"\"\"makes the model\"\"\"\n self.lr = param[0][0]\n dr = param[0][1]\n layer_units0 = param[0][2]\n layer...
[ 3, 4, 5, 6, 7 ]
# ======= # Imports # ======= import os import sympy import numpy from distutils.spawn import find_executable import matplotlib import matplotlib.pyplot as plt from .Declarations import n,t # ============= # Plot Settings # ============= def PlotSettings(): """ General settings for the plot. """ # C...
normal
{ "blob_id": "81da2aab9ca11e63dafdd4eefc340d37b326fc6f", "index": 1846, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef PlotFunctions(phi_orthonormalized_list, StartFunctionIndex, Interval):\n PlotSettings()\n t_array = numpy.logspace(-7, numpy.log10(Interval[1]), 1000)\n NumFunctions = le...
[ 0, 1, 2, 3, 4 ]
from .line_detection_research import score_pixel_v3p2
normal
{ "blob_id": "305554fc86ddc116677b6d95db7d94d9f2213c41", "index": 5088, "step-1": "<mask token>\n", "step-2": "from .line_detection_research import score_pixel_v3p2\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
import datetime interval_length_minutes = 10 # 10 minutes per interval tek_rolling_period = 144 # 24*60//10 - 24 hours per day, 60 minutes per hour, 10 minutes per interval def get_timestamp_from_interval(interval_number): return interval_number * interval_length_minutes * 60 # 60 seconds per minute def get...
normal
{ "blob_id": "f3bfa30f51c4a91844457c72fbf2b2b8368d8476", "index": 1874, "step-1": "<mask token>\n\n\ndef get_timestamp_from_interval(interval_number):\n return interval_number * interval_length_minutes * 60\n\n\ndef get_datetime_from_utc_timestamp(utc_timestamp):\n return datetime.datetime.utcfromtimestamp(...
[ 2, 3, 4, 5, 7 ]
import os import numpy as np from argparse import ArgumentParser from tqdm import tqdm from models.networks import Perceptron from data.perceptron_dataset import Dataset, batchify from utils.utils import L1Loss, plot_line from modules.perceptron_trainer import Trainer if __name__ == '__main__': parser = Argumen...
normal
{ "blob_id": "726aaa0ef129f950e6da6701bb20e893d2f7373b", "index": 3823, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n parser = ArgumentParser()\n parser.add_argument('--name', type=str, default='test')\n parser.add_argument('--input_dim', type=int, default=2)\n pa...
[ 0, 1, 2, 3 ]
''' Bayesian models for TWAS. Author: Kunal Bhutani <kunalbhutani@gmail.com> ''' from scipy.stats import norm import pymc3 as pm import numpy as np from theano import shared from scipy.stats.distributions import pareto from scipy import optimize import theano.tensor as t def tinvlogit(x): return t.exp(x) / (1 +...
normal
{ "blob_id": "057140ef1b8db340656b75b3a06cea481e3f20af", "index": 1689, "step-1": "<mask token>\n\n\nclass TwoStage(BayesianModel):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass TwoStageBF(BayesianModel):\n \"\"\"\n Two Stage Inference.\n\n First stage: Bootstrapped ElasticNet\n Sec...
[ 28, 29, 46, 49, 55 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jan 10 11:08:59 2020 @author: rishi """ # --------- Global Variables ----------- # Will hold our game board data board = ["-" for i in range(1,26)] # Lets us know if the game is over yet game_still_going = True # Tells us who the winner is winner = ...
normal
{ "blob_id": "605e088beed05c91b184e26c4a5d2a97cb793759", "index": 2909, "step-1": "<mask token>\n\n\ndef display_board():\n print('\\n')\n print(board[0] + ' | ' + board[1] + ' | ' + board[2] + ' | ' + board[3] +\n ' | ' + board[4] + ' 1 | 2 | 3 | 4 | 5')\n print(board[5] + ' | ' + board[6] + ...
[ 7, 9, 11, 12, 13 ]
from random import choice, random from tabulate import tabulate from Constants import * from time import sleep import numpy as np import os class QLearn(): def __init__(self, alfa, gama, epsilon, epsilonDecay, epsilonMin, rewards, environment): self.alfa = alfa self.gama = gama self.epsilon...
normal
{ "blob_id": "221b6ad6035276fb59addc4065c4ccee3f5a2d84", "index": 6351, "step-1": "<mask token>\n\n\nclass QLearn:\n <mask token>\n <mask token>\n\n def checkBoundaries(self, state, action):\n row, column = int(state[0]), int(state[1])\n if action == Directions.UP:\n return f'{ma...
[ 5, 7, 9, 10, 12 ]
def four_Ow_four(error): ''' method to render the 404 error page ''' return render_template('fourOwfour.html'),404
normal
{ "blob_id": "851cfd4e71ffd2d5fed33616abca4444474669a3", "index": 4508, "step-1": "<mask token>\n", "step-2": "def four_Ow_four(error):\n \"\"\"\n method to render the 404 error page\n \"\"\"\n return render_template('fourOwfour.html'), 404\n", "step-3": "def four_Ow_four(error):\n '''\n met...
[ 0, 1, 2 ]
from os import environ as env import json import utils import utils.aws as aws import utils.handlers as handlers def put_record_to_logstream(event: utils.LambdaEvent) -> str: """Put a record of source Lambda execution in LogWatch Logs.""" log_group_name = env["REPORT_LOG_GROUP_NAME"] utils.Log.info("Fet...
normal
{ "blob_id": "01d545e77c211201332a637a493d27608721aad5", "index": 7004, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef put_record_to_logstream(event: utils.LambdaEvent) ->str:\n \"\"\"Put a record of source Lambda execution in LogWatch Logs.\"\"\"\n log_group_name = env['REPORT_LOG_GROUP_NAM...
[ 0, 1, 2, 3, 4 ]
import spacy nlp = spacy.load("en_core_web_lg") def find_entities(corpus): doc = nlp(corpus) entities = {} for ent in doc.ents: entity_type = ent.label_ entity_name = ent.text values = entities.get(entity_type, set()) values.add(entity_name) entities[entity_type]...
normal
{ "blob_id": "3a0bf031b76d2df03cdb5b37861cb8942307709c", "index": 7601, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_entities(corpus):\n doc = nlp(corpus)\n entities = {}\n for ent in doc.ents:\n entity_type = ent.label_\n entity_name = ent.text\n values = enti...
[ 0, 1, 2, 3, 4 ]
#embaralhar sorteio import random a1 = input('Primeiro aluno: ') a2 = input('Primeiro segundo: ') a3 = input('Primeiro terceiro: ') a4 = input('Primeiro quarto: ') lista = [a1, a2, a3, a4] random.shuffle(lista) print('A ordem de apresentacao será') print(lista)
normal
{ "blob_id": "9a0e24fbe9f51dc914d891e90196c2ff4e65f04a", "index": 9652, "step-1": "<mask token>\n", "step-2": "<mask token>\nrandom.shuffle(lista)\nprint('A ordem de apresentacao será')\nprint(lista)\n", "step-3": "<mask token>\na1 = input('Primeiro aluno: ')\na2 = input('Primeiro segundo: ')\na3 = input('Pri...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python from ks_auth import sess from ks_auth import trust_auth from ks_auth import ks from ks_auth import utils from novaclient import client import novaclient.exceptions from time import sleep from uuid import uuid4 import sys # RDTIBCC-1042 VERSION = '2' nova = client.Client(VERSION, session=sess) u...
normal
{ "blob_id": "9f40162348d33d70639692dac87777a2799999e9", "index": 6688, "step-1": "#!/usr/bin/env python\nfrom ks_auth import sess\nfrom ks_auth import trust_auth\nfrom ks_auth import ks\nfrom ks_auth import utils\nfrom novaclient import client\nimport novaclient.exceptions\nfrom time import sleep\nfrom uuid impo...
[ 0 ]
from gym_mag.envs.mag_control_env import MagControlEnv
normal
{ "blob_id": "dd7896e3beb5e33282b38efe0a4fc650e629b185", "index": 5081, "step-1": "<mask token>\n", "step-2": "from gym_mag.envs.mag_control_env import MagControlEnv\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
''' Created on Nov 20, 2012 @author: shriram ''' import xml.etree.ElementTree as ET from xml.sax.saxutils import escape ''' Annotating only Sparse and Non Sparse Lines ''' class Trainer: def html_escape(self,text): html_escape_table = { '"': "&quot;", "'": "&apos;" } re...
normal
{ "blob_id": "22e24e8dd49367ae57d1980c4addf48d65c5e897", "index": 7851, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Trainer:\n\n def html_escape(self, text):\n html_escape_table = {'\"': '&quot;', \"'\": '&apos;'}\n return escape(text, html_escape_table)\n\n def train(self...
[ 0, 3, 4, 6, 7 ]
from django.conf.urls import url from django.contrib.auth.views import login,logout from appPortas.views import * urlpatterns = [ url(r'^porta/list$', porta_list, name='porta_list'), url(r'^porta/detail/(?P<pk>\d+)$',porta_detail, name='porta_detail'), url(r'^porta/new/$', porta_new, name='porta_new'), ...
normal
{ "blob_id": "5e355732f07029aa644617ac9b5e9ad50ee9397f", "index": 1161, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [url('^porta/list$', porta_list, name='porta_list'), url(\n '^porta/detail/(?P<pk>\\\\d+)$', porta_detail, name='porta_detail'), url(\n '^porta/new/$', porta_new, name...
[ 0, 1, 2, 3 ]
# # PySNMP MIB module CISCO-L2NAT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-L2NAT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:47:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
normal
{ "blob_id": "2fb95fa2b7062085f31c6b1dbb8c1336c3871e93", "index": 3271, "step-1": "<mask token>\n", "step-2": "<mask token>\nciscoL2natMIB.setRevisions(('2013-04-16 00:00',))\nif mibBuilder.loadTexts:\n ciscoL2natMIB.setLastUpdated('201304160000Z')\nif mibBuilder.loadTexts:\n ciscoL2natMIB.setOrganization...
[ 0, 1, 2, 3 ]
""" Project: tomsim simulator Module: FunctionalUnit Course: CS2410 Author: Cyrus Ramavarapu Date: 19 November 2016 """ # DEFINES BUSY = 1 FREE = 0 class FunctionalUnit: """FunctionalUnit Class to encompass methods needed for Integer, Divide, Multipler, Load, Store Functional Units in tomsim ...
normal
{ "blob_id": "a2a94e87bb9af1ccaf516581d6662d776caf0b0d", "index": 6284, "step-1": "<mask token>\n\n\nclass FunctionalUnit:\n <mask token>\n <mask token>\n\n def __str__(self):\n return (\n \"\"\"\n Id: {}\n Instruction Count: {}\n Latency:...
[ 7, 8, 11, 12, 13 ]
from collections import defaultdict class Graph: def __init__(self): self._graph = defaultdict(list) self._odd_vertices = [] def add_vertex(self, v): if not v in self._graph: self._graph[v] = list() def add_edge(self, v1, v2): self._graph[v1].append(v2) ...
normal
{ "blob_id": "b4d412e8b45722a855a16dd64b7bce9b303d0ffe", "index": 964, "step-1": "<mask token>\n\n\nclass Graph:\n\n def __init__(self):\n self._graph = defaultdict(list)\n self._odd_vertices = []\n\n def add_vertex(self, v):\n if not v in self._graph:\n self._graph[v] = list...
[ 5, 6, 7, 8, 9 ]
import pandas import os from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException import json CONFIG_FILE_NAME = os.path.join(os.path.dirname(__file__), 'input_info.json') def create_ne...
normal
{ "blob_id": "14cb702054b8caaa8899a2a3d8b65aae9b063cb6", "index": 5600, "step-1": "<mask token>\n\n\ndef create_new_report(chrome_driver_inner, report_info_inner):\n add_new_report = chrome_driver_inner.find_element_by_id(\n 'MainContent_MainActionCreate')\n add_new_report.click()\n next_button = ...
[ 2, 3, 4, 5, 6 ]
import FWCore.ParameterSet.Config as cms maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) ) readFiles = cms.untracked.vstring() source = cms.Source ("PoolSource",fileNames = readFiles, lumisToProcess = cms.untracked.VLuminosityBlockRange(*('1:11169', '1:11699', '1:16592', '1:23934', '1:17699', '1:22722',...
normal
{ "blob_id": "15821bb33c2949f5a3e72e23cf7b5d8766dfce70", "index": 4568, "step-1": "<mask token>\n", "step-2": "<mask token>\nreadFiles.extend([\n '/store/mc/RunIIFall17MiniAODv2/TTbarDMJets_Dilepton_pseudoscalar_LO_TuneCP5_13TeV-madgraph-mcatnlo-pythia8/MINIAODSIM/PU2017_12Apr2018_rp_94X_mc2017_realistic_v14...
[ 0, 1, 2, 3, 4 ]
# -*- coding:utf-8 -*- from odoo import api, fields, _, models Type_employee = [('j', 'Journalier'), ('m', 'Mensuel')] class HrCnpsSettings(models.Model): _name = "hr.cnps.setting" _description = "settings of CNPS" name = fields.Char("Libellé", required=True) active = fields.Boolean("Ac...
normal
{ "blob_id": "4f7b689c06383673b510092932b051c644306b84", "index": 3500, "step-1": "<mask token>\n\n\nclass HrCnpsSettings(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\n\nclass HrCnpsCotisationLineTe...
[ 3, 4, 5, 6, 7 ]