code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
#coding=utf-8 import requests,sys result_url=[] def main(): counts=open(sys.argv[1]).readlines() for line in open(sys.argv[1]): line=line.strip("\n") url=line try: #url="http://s6000.sgcc.com.cn/WebContent/s6000/main/index.jsp#no-back" r=requests.get(u...
normal
{ "blob_id": "96a4659f03879e051af95b5aa9c1e1364015fb86", "index": 8723, "step-1": "<mask token>\n\n\ndef main():\n counts = open(sys.argv[1]).readlines()\n for line in open(sys.argv[1]):\n line = line.strip('\\n')\n url = line\n try:\n r = requests.get(url, verify=True, timeo...
[ 1, 2, 3, 4, 5 ]
# Copyright (C) 2020 Francis Sun, all rights reserved. """A copyright utility""" import datetime import argparse import os import os.path class Copyright: _file_type = { 'c/c++': ['h', 'c', 'cpp', 'cc'], 'python': ['py'], 'cmake': ['cmake'], 'vim': ['vim'], ...
normal
{ "blob_id": "dc05a441c21a67fbb3a1975b3fccb865a32731c8", "index": 4642, "step-1": "<mask token>\n\n\nclass Copyright:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def _c_cpp_formater(self):\n return '/* ' + self.declaration + ' */'\n for ft in _file_type['c/c++']:\n ...
[ 5, 7, 11, 12, 13 ]
#!/usr/bin/env python # @HEADER # ************************************************************************ # # TriBITS: Tribal Build, Integrate, and Test System # Copyright 2013 Sandia Corporation # # Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, # the U.S. Govern...
normal
{ "blob_id": "550f5ad4fef77d5795db0393ae0701f679143e72", "index": 221, "step-1": "<mask token>\n", "step-2": "<mask token>\nif os.environ.get('MOCKPROGRAM_INOUT_FILE_OVERRIDE'):\n mockProgramInOutFilePath = os.environ.get('MOCKPROGRAM_INOUT_FILE_OVERRIDE'\n )\nelse:\n mockProgramInOutFilePath = '.m...
[ 0, 1, 2, 3, 4 ]
""" USERS MODEL """ from www import app import mongoengine import datetime class User(mongoengine.Document): username = mongoengine.StringField(required=True) password = mongoengine.StringField(required=True) email = mongoengine.StringField(required=True) active_hash = mongoengine.StringField(re...
normal
{ "blob_id": "51cdb41836415c08609ee6a6bcc3adbaf2533da4", "index": 3697, "step-1": "<mask token>\n\n\nclass User(mongoengine.Document):\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>...
[ 2, 3, 4, 5, 6 ]
from dateutil import parser from datetime import datetime from backend.crawler import calender_crawler from backend.logic.schedule_by_time.schedule_utils import get_weeks_of_subject from backend.logic.schedule_by_time.schedule_utils import get_time_str # e.g. hôm nay, hôm qua, ngày mai, thứ 2, thứ tư, chủ nhật, thứ ...
normal
{ "blob_id": "6339f5c980ab0c0fb778870196493ddd83963ae7", "index": 9203, "step-1": "<mask token>\n\n\ndef filter_by_session(schedule_table, time_entity):\n subjects_of_day = filter_by_weekday(schedule_table, time_entity)\n start_session_hour = parser.parse(time_entity['value']['from']).hour\n schedule = [...
[ 5, 6, 7, 10, 11 ]
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'KPS_RevisitBusinessEvents.ui' # # Created: Sun May 18 14:50:49 2014 # by: PyQt4 UI code generator 4.10.4 # # WARNING! All changes made in this file will be lost! from PyQt4 import QtCore, QtGui, QtSql import sqlite3 try: _fromUtf...
normal
{ "blob_id": "8339113fd6b0c286cc48ec04e6e24978e2a4b44e", "index": 9991, "step-1": "<mask token>\n\n\nclass Ui_Form(object):\n\n def setupUi(self, Form):\n Form.setObjectName(_fromUtf8('Form'))\n Form.resize(666, 538)\n palette = QtGui.QPalette()\n self.eventSkip = 0\n self.db...
[ 8, 10, 11, 12, 13 ]
from helper import * tree_type = TREE_TYPE_SPLIT file_name = '' file_path = '' split_scalars = {} visited = {} adjacency = {} pairs = {} index_map = {} postorder_map = {} preorder_map = {} birth = {} death = {} string = '' class Tree(object): def __init__(self): self.index = None self.children = [] self.p...
normal
{ "blob_id": "4daab8b8db1e394e3132ab5550fe0236b67074d8", "index": 5527, "step-1": "from helper import *\n\ntree_type = TREE_TYPE_SPLIT\n\nfile_name = ''\nfile_path = ''\n\nsplit_scalars = {}\nvisited = {}\nadjacency = {}\npairs = {}\n\nindex_map = {}\npostorder_map = {}\npreorder_map = {}\n\nbirth = {}\ndeath = {...
[ 0 ]
#!/usr/bin/python ''' ** dmcalc ** Estimates the Dispersion Measure (DM) from the data in psrfits file format. Returns the DM value with its uncertainty and reduced chi-square from tempo2 DM fit. Dependencies ------------- PSRCHIVE with python interface: http://psrchive.sourceforge.ne...
normal
{ "blob_id": "e464b465c4bc90c250c0ea02c17b7398d975964b", "index": 1163, "step-1": "<mask token>\n\n\ndef main():\n args = parser.parse_args()\n quiet = False\n if args.quiet:\n quiet = True\n tempo2 = True\n ptoa = False\n if args.print_toas:\n ptoa = True\n if not quiet:\n ...
[ 4, 5, 6, 7, 8 ]
from django import forms class LoginForm(forms.Form): usuario=forms.CharField(label="Usuario",max_length=20, required=True, widget=forms.TextInput( attrs={'class':'form-control'} )) contraseña=forms.CharField(label="Contraseña",max_length=20, widget=forms.PasswordInput( attrs={'class':'for...
normal
{ "blob_id": "7da5a7476c807619bed805cb892774c23c04c6f7", "index": 4917, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LoginForm(forms.Form):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LoginForm(forms.Form):\n usuario = forms.CharField(label='Usuario', max_le...
[ 0, 1, 2, 3, 4 ]
class NlpUtility(): """ Utility methods to get particular parts of speech from a token set """ def get_nouns(self, tokens): nouns = [] for word, pos in tokens: if pos == "NN": nouns.push(word) def get_verbs(self, tokens): verbs = [] for word, pos in tokens: if pos == "VB": nouns.push(word) ...
normal
{ "blob_id": "c6502ea2b32ad90c76b6dfaf3ee3218d029eba15", "index": 56, "step-1": "class NlpUtility:\n <mask token>\n\n def get_nouns(self, tokens):\n nouns = []\n for word, pos in tokens:\n if pos == 'NN':\n nouns.push(word)\n <mask token>\n <mask token>\n\n d...
[ 4, 5, 6, 7, 8 ]
from catalyst_rl.contrib.registry import ( Criterion, CRITERIONS, GRAD_CLIPPERS, Model, MODELS, Module, MODULES, Optimizer, OPTIMIZERS, Sampler, SAMPLERS, Scheduler, SCHEDULERS, Transform, TRANSFORMS ) from catalyst_rl.core.registry import Callback, CALLBACKS from catalyst_rl.utils.tools.registry import Reg...
normal
{ "blob_id": "09d13fe6b090850782feb601412cf135d497136f", "index": 6206, "step-1": "<mask token>\n\n\ndef _callbacks_loader(r: Registry):\n from catalyst_rl.dl import callbacks as m\n r.add_from_module(m)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef _callbacks_loader(r: Registry):\n from catal...
[ 1, 2, 3, 4, 5 ]
# -*- utf-8 -*- from django.db import models class FieldsTest(models.Model): pub_date = models.DateTimeField() mod_date = models.DateTimeField() class BigS(models.Model): s = models.SlugField(max_length=255) class Foo(models.Model): a = models.CharField(max_length=10) d = models.DecimalField(...
normal
{ "blob_id": "d6cfe7132855d832d8fd1ea9ca9760bd22109a92", "index": 1893, "step-1": "<mask token>\n\n\nclass Bar(models.Model):\n b = models.CharField(max_length=10)\n a = models.ForeignKey(Foo, related_name='bars', on_delete=models.CASCADE)\n\n\nclass DTModel(models.Model):\n name = models.CharField(max_l...
[ 5, 6, 8, 10, 13 ]
# import visual_servoing_utils_main as utils from autolab_core import rigid_transformations as rt from yumipy import YuMiState class YumiConstants: T_gripper_gripperV = rt.RigidTransform(rotation=[[-1, 0, 0], [0, 1, 0], [0, 0, -1]], from_frame='gripper', to_frame='obj') ...
normal
{ "blob_id": "34c81b9318d978305748d413c869a86ee6709e2c", "index": 996, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass YumiConstants:\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...
[ 0, 1, 2, 3, 4 ]
from math import sqrt, ceil def encode_s(s): encoded_s = '' s_with_no_spaces = s.replace(' ', '') step = ceil(sqrt(len(s_with_no_spaces))) for j in range(0, step): i = j while i < len(s_with_no_spaces): encoded_s = encoded_s + s_with_no_spaces[i] i += step ...
normal
{ "blob_id": "a3ed47c285b26dca452fa192eb354a21a78b8424", "index": 4632, "step-1": "<mask token>\n\n\ndef TheRabbitsFoot(s, encode):\n if encode:\n return encode_s(s)\n return decode_s(s)\n", "step-2": "<mask token>\n\n\ndef decode_s(s):\n arr = s.split(' ')\n decoded_s = ''\n for j in rang...
[ 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ A customised logger for this project for logging to the file and console Created on 29/07/2022 @author: PNimbhore """ # imports import os import logging class Logger: """ A custom logger which will take care of logging to console and file. """ def __init__(self, filepat...
normal
{ "blob_id": "45d57f8392b89776f9349c32b4bb2fa71a4aaa83", "index": 8610, "step-1": "<mask token>\n\n\nclass Logger:\n <mask token>\n\n def __init__(self, filepath):\n \"\"\"\n Constructor\n :param filepath:\n \"\"\"\n self.filepath = filepath\n self.logger = logging....
[ 2, 3, 4, 5, 6 ]
#-*- coding: utf-8 -*- s = "123" try: print(int(s) + 1) print(int(s) / 1) except ValueError as ve: print("ValueError occurs!!!", ve) except ZeroDivisionError as e: print("ValueError occurs!!!", e) except : print("Error occurs!!!") else: print("elseeeeeeeeeeeeeee") finally: print("ABCDE...
normal
{ "blob_id": "1bf79319613ca1454f3a9ed21068bd899616395c", "index": 624, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n print(int(s) + 1)\n print(int(s) / 1)\nexcept ValueError as ve:\n print('ValueError occurs!!!', ve)\nexcept ZeroDivisionError as e:\n print('ValueError occurs!!!', e)\ne...
[ 0, 1, 2, 3 ]
""" [BBC] Web Scraper """ import os from .abstract_crawler import AbstractWebCrawler class BBCCrawler(AbstractWebCrawler): """ [BBC] Web Scraper """ # Spider Properties name = "web_bbc" # Crawler Properties resource_link = 'http://www.bbc.com/news/topics/cz4pr2gd85qt/cyber-security' resourc...
normal
{ "blob_id": "3c22fbfd7d83ff3ecacabc3c88af2169fa5906b9", "index": 5190, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BBCCrawler(AbstractWebCrawler):\n <mask token>\n name = 'web_bbc'\n resource_link = (\n 'http://www.bbc.com/news/topics/cz4pr2gd85qt/cyber-security')\n resour...
[ 0, 2, 3, 4, 5 ]
from django import forms from django.core.validators import RegexValidator from dashboard.validators import validate_domainonly_email class addUserForm(forms.Form): username = forms.CharField(label='User Name', required="required", disabled="", min_length=6, max_length=128, help_tex...
normal
{ "blob_id": "39b6ca21b8d4856e2b2edfcbd00b75fbce6dfff7", "index": 1407, "step-1": "<mask token>\n\n\nclass addUserForm(forms.Form):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass addUserForm(for...
[ 1, 2, 3, 4, 5 ]
from discord.ext import commands def is_owner(): async def predicate(ctx): return ctx.author.id == 98208218022428672 return commands.check(predicate) class Staff(commands.Cog): def __init__(self, bot): self.bot = bot @commands.command( name='stop', aliases=['shutdow...
normal
{ "blob_id": "23b2cc5b561a11ae7757a281a141491d5b7e23ca", "index": 2683, "step-1": "<mask token>\n\n\nclass Staff(commands.Cog):\n <mask token>\n\n @commands.command(name='stop', aliases=['shutdown'], description=\n 'This is a command for staff only to stop the bot')\n @is_owner()\n async def st...
[ 1, 2, 3, 4, 5 ]
# Author: BeiYu # Github: https://github.com/beiyuouo # Date : 2021/2/21 21:57 # Description: __author__ = "BeiYu" from utils.init_env import set_seed from utils.options import * import os import logging import torch from torch import nn from torch import optim from torch.optim.lr_scheduler import MultiStepLR from ...
normal
{ "blob_id": "75e6554ea3c327c87a2a65710a7f1d55e9933bb0", "index": 276, "step-1": "<mask token>\n\n\ndef train():\n args = get_args()\n os.makedirs(args.model_path, exist_ok=True)\n set_seed(args.seed)\n \"\"\"\n To follow this training routine you need a DataLoader that yields the tuples of the...
[ 1, 3, 4, 5, 6 ]
import discord from discord.ext import commands class TestCommands(commands.Cog, description="Unstable test commands", command_attrs=dict(hidden=True, description="Can only be used by an Owner")): def __init__(self, bot): self.bot = bot self.hidden = True print("Loaded", __name__) as...
normal
{ "blob_id": "d5a5c6f9d483b2998cd0d9e47b37ab4499fa1c2a", "index": 6279, "step-1": "<mask token>\n\n\nclass TestCommands(commands.Cog, description='Unstable test commands',\n command_attrs=dict(hidden=True, description='Can only be used by an Owner')\n ):\n <mask token>\n\n async def cog_check(self, ct...
[ 1, 2, 3, 4, 5 ]
from django.urls import path,include from Income import views urlpatterns = [ path('IncomeHome/',views.IncomeHome,name='IncomeHome'), path('IncomeCreate/',views.IncomeCreate.as_view(),name='IncomeCreate'), path('IncomeUpdate/<int:pk>',views.IncomeUpdate.as_view(),name='IncomeUpdate'), path('IncomeDel...
normal
{ "blob_id": "ad3a7221883a847fc9d26097c3801973cbbda38e", "index": 355, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('IncomeHome/', views.IncomeHome, name='IncomeHome'),\n path('IncomeCreate/', views.IncomeCreate.as_view(), name='IncomeCreate'\n ), path('IncomeUpdate/<int:pk>', ...
[ 0, 1, 2, 3 ]
__author__ = 'jjpr' import pyrr import barleycorn as bc def test_xyz123(): cone_x = bc.primitives.Cone(1.0, 1.0)
normal
{ "blob_id": "e6af221f1d6397d0fc52671cdd27d43549d0aecb", "index": 513, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_xyz123():\n cone_x = bc.primitives.Cone(1.0, 1.0)\n", "step-3": "__author__ = 'jjpr'\n<mask token>\n\n\ndef test_xyz123():\n cone_x = bc.primitives.Cone(1.0, 1.0)\n", ...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # jan 2014 bbb garden shield attempt # AKA ''' Sensors: analog level sensor, pin AIN0 TMP102 i2c temperature sensor, address 0x48 (if add0 is grounded) or 0x49 (if pulled up) Outputs: Analog RGB LED strip I2C display(?) Pump Activate/Deactivate (GPIO pin) Some measurem...
normal
{ "blob_id": "06992263599fe3290c87ec00c6cb8af3748920c8", "index": 5497, "step-1": "\n#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n# jan 2014 bbb garden shield attempt\n# AKA\n\n'''\nSensors:\nanalog level sensor, pin AIN0\nTMP102 i2c temperature sensor, address 0x48\n(if add0 is grounded) or 0x49 (if pulled up...
[ 0 ]
# apport hook for oem-config; adds log file import os.path def add_info(report): if os.path.exists('/var/log/oem-config.log'): report['OemConfigLog'] = ('/var/log/oem-config.log',)
normal
{ "blob_id": "74b1cdcb1aaf6cde7e8ce3eeb73cd82689719b00", "index": 6404, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef add_info(report):\n if os.path.exists('/var/log/oem-config.log'):\n report['OemConfigLog'] = '/var/log/oem-config.log',\n", "step-3": "import os.path\n\n\ndef add_info...
[ 0, 1, 2, 3 ]
''' "MAIN" module All operations are added to the defaultgraph. Network functions are found in module network_functions_2 Display graph in tensorboard by opening a new terminal and write "tensorboard --logdir=tensorbaord/debug/01/" where the last number depends on which directory the current graph is saved in (see l...
normal
{ "blob_id": "8a2cf1d550a593beae579104413b424e007d511f", "index": 9048, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith tf.name_scope('input_data'):\n (iterate_data, sub_images, sub_depths, sub_images_placeholder,\n sub_depths_placeholder) = rd.read_debug_data()\n sub_images_coarse = tf.c...
[ 0, 1, 2, 3, 4 ]
import sys from collections import defaultdict sys.setrecursionlimit(1200) def dfs(G, v, prev): t = [] s = 0 for x in G[v]: if x == prev: continue tmp = dfs(G, x, v) s += tmp[1] t.append(tmp[0] - tmp[1]) t.sort() t = t[:2] if len(t) < 2: return (s...
normal
{ "blob_id": "efa06d929e76a255afd9923b5340252c291a325c", "index": 3615, "step-1": "import sys\nfrom collections import defaultdict\nsys.setrecursionlimit(1200)\n\ndef dfs(G, v, prev):\n t = []\n s = 0\n for x in G[v]:\n if x == prev: continue\n tmp = dfs(G, x, v)\n s += tmp[1]\n ...
[ 0 ]
from typing import Type from sqlalchemy.exc import IntegrityError from src.main.interface import RouteInterface as Route from src.presenters.helpers import HttpRequest, HttpResponse from src.presenters.errors import HttpErrors def flask_adapter(request: any, api_route: Type[Route]) -> any: """Adapter pattern for ...
normal
{ "blob_id": "3212bb7df990ad7d075b8ca49a99e1072eab2a90", "index": 595, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef flask_adapter(request: any, api_route: Type[Route]) ->any:\n \"\"\"Adapter pattern for Flask\n :param - Flask Request\n :api_route: Composite Routes\n \"\"\"\n try:\...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """Part of speech mapping constants and functions for NLPIR/ICTCLAS. This module is used by :mod:`pynlpir` to format segmented words for output. """ import logging logger = logging.getLogger("pynlpir.pos_map") #: A dictionary that maps part of speech codes returned by NLPIR to #: human-read...
normal
{ "blob_id": "093b2afef7cdfb7070eb5e94e84624afe495db66", "index": 1948, "step-1": "<mask token>\n\n\ndef get_pos_name(code, name='parent', english=True, pos_tags=POS_MAP):\n \"\"\"Gets the part of speech name for *code*.\n\n :param str code: The part of speech code to lookup, e.g. ``'nsf'``.\n :param str...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- from django.shortcuts import get_object_or_404 from rest_framework import serializers from tandlr.core.api.serializers import ModelSerializer from tandlr.users.models import DeviceUser, User, UserSettings from tandlr.utils.refresh_token import create_token class LoginSerializer(serializers.S...
normal
{ "blob_id": "01900c1d14a04ee43553c8602a07e0c6ecfabded", "index": 1803, "step-1": "<mask token>\n\n\nclass LogoutSerializer(ModelSerializer):\n <mask token>\n <mask token>\n\n\n class Meta:\n model = DeviceUser\n fields = ['device_user_token', 'device_os', 'is_active']\n <mask token>\n ...
[ 9, 11, 15, 17, 19 ]
"""Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent elements in the subsequence equals difference.""" class Solution(object): def longestSubsequence(self, arr, difference): ...
normal
{ "blob_id": "fa4ab3ed5c653633879b5ba2c078c896aa3eb0c6", "index": 2838, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution(object):\n\n def longestSubsequence(self, arr, difference):\n dp = dict()\n ...
[ 0, 1, 2, 3 ]
#alds13c from collections import deque d_stack=deque() res_stack=deque() s = input() for i in range(len(s)): #print(d_stack,res_stack) if s[i]=="\\": d_stack.append(i) elif s[i]=="/": if len(d_stack)==0: continue left = d_stack.pop() area = i-left #res_s...
normal
{ "blob_id": "48e3259698788904e000eb15b5443067b0c3e791", "index": 5968, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(s)):\n if s[i] == '\\\\':\n d_stack.append(i)\n elif s[i] == '/':\n if len(d_stack) == 0:\n continue\n left = d_stack.pop()\n ...
[ 0, 1, 2, 3, 4 ]
import smtplib import requests import datetime import json import time from datetime import date from urllib.request import Request,urlopen today = date.today().strftime("%d-%m-%y") count = 0 pincodes = ["784164","781017","784161","787001"] date = 0 temp = str(14) + "-05-21" while True: for...
normal
{ "blob_id": "7c60ae58b26ae63ba7c78a28b72192373cc05a86", "index": 1211, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n for i in range(0, 8):\n temp = str(23 + i) + '-05-21'\n for pincode in pincodes:\n req = Request(\n 'https://cdn-api.co-vin.in/api...
[ 0, 1, 2, 3, 4 ]
import datetime def year_choices(): return [(r, r) for r in range(1984, datetime.date.today().year + 1)] def current_year(): return datetime.date.today().year
normal
{ "blob_id": "90bb70b0a97c7872c8581a176ebacc50df8e1f72", "index": 464, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef year_choices():\n return [(r, r) for r in range(1984, datetime.date.today().year + 1)]\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef year_choices():\n return [(r, ...
[ 0, 1, 2, 3 ]
import warnings from re import * from pattern import collection warnings.filterwarnings("ignore") def test(): raw_text = "通化辉南县经济适用房_通化辉南县经适房_通化辉南县经济适用房转让_通化去114网通化切换城市var googlequerykey ='二手经适房 二手房买卖 二手房地产公司' ; var AdKeyWords = 'j...
normal
{ "blob_id": "488d20a86c5bddbca2db09b26fb8df4b6f87a1dc", "index": 2354, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test():\n raw_text = (\n \"通化辉南县经济适用房_通化辉南县经适房_通化辉南县经济适用房转让_通化去114网通化切换城市var googlequerykey ='二手经适房 二手房买卖 二手房地产公司' ; ...
[ 0, 1, 2, 3, 4 ]
import os, sys, datetime, csv, platform ####FUNCTIONS#### #Get Creation Time def get_lastupdate_date(path): return os.path.getmtime(path) #Get Date From String def convertIntToTimestamp(timeint): return str(datetime.datetime.fromtimestamp(timeint)) #Get Filename def getFilename(name): return os.path...
normal
{ "blob_id": "e83b6b1f4cb12fe3b932903eddddfb0dc0e7d98d", "index": 2765, "step-1": "<mask token>\n\n\ndef get_lastupdate_date(path):\n return os.path.getmtime(path)\n\n\ndef convertIntToTimestamp(timeint):\n return str(datetime.datetime.fromtimestamp(timeint))\n\n\ndef getFilename(name):\n return os.path....
[ 5, 8, 9, 11, 12 ]
#!/usr/bin/python # -*- coding:utf-8 -*- import epd2in7 import time from PIL import Image,ImageDraw,ImageFont import traceback try: epd = epd2in7.EPD() epd.init() epd.Clear(0xFF) time.sleep(2) epd.sleep() except: print 'traceback.format_exc():\n%s' % traceback.format_exc...
normal
{ "blob_id": "14cac4f11830511923ee1ce0d49ec579aec016fd", "index": 4720, "step-1": "#!/usr/bin/python\n# -*- coding:utf-8 -*-\n\nimport epd2in7\nimport time\nfrom PIL import Image,ImageDraw,ImageFont\nimport traceback\n\ntry:\n epd = epd2in7.EPD()\n epd.init()\n epd.Clear(0xFF)\n \n time.sleep(2)\n ...
[ 0 ]
# print all cards with even numbers. cards = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"] for card in cards: try: number = int(card) if number % 2 == 0: # modulo operator print(card, "is an even card.") except ValueError: print (card, "can not be divi...
normal
{ "blob_id": "b5180a2dbe1f12e1bbc92874c67ea99c9a84a9ed", "index": 19, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor card in cards:\n try:\n number = int(card)\n if number % 2 == 0:\n print(card, 'is an even card.')\n except ValueError:\n print(card, 'can not be d...
[ 0, 1, 2, 3 ]
### Global parameters ### seconds_per_unit_time = 0.01 ######################### pars_spont = { "tau_p": 2.5, "tau_d": 5.0, "amp_p": 0.08, "amp_d": -0.0533, "rho": 0.0015, "N": 50, "w_max": 0.05, "mu": 0.07, "seed": None, "tend": 50_000_000, "r_in": 0.04, "w_in": 0.05,...
normal
{ "blob_id": "8f17c1ed0cb273a88b986cd7fe7a45439211d536", "index": 8641, "step-1": "<mask token>\n", "step-2": "seconds_per_unit_time = 0.01\npars_spont = {'tau_p': 2.5, 'tau_d': 5.0, 'amp_p': 0.08, 'amp_d': -0.0533,\n 'rho': 0.0015, 'N': 50, 'w_max': 0.05, 'mu': 0.07, 'seed': None, 'tend':\n 50000000, 'r_...
[ 0, 1, 2 ]
from functions.service_funcs.get_data import get_data_character def clean_room(update): char, db_sess = get_data_character(update, return_sess=True) # удаляем старую комнату и всю инфу о ней if char and char.room: if char.room.mobs: for mob in char.room.mobs: db_sess.de...
normal
{ "blob_id": "4d57fa22282d7b3f8adabedd7a04e32767181890", "index": 5693, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef clean_room(update):\n char, db_sess = get_data_character(update, return_sess=True)\n if char and char.room:\n if char.room.mobs:\n for mob in char.room.mob...
[ 0, 1, 2, 3 ]
from .Buzzer import BuzzerController from .Card import CardScanner from .RFID import RFIDController from .Servo import ServoController __all__ = ["BuzzerController", "CardScanner", "RFIDController", "ServoController"]
normal
{ "blob_id": "8fa78824a38a3b0c1f51aceacab671f987ea2705", "index": 9635, "step-1": "<mask token>\n", "step-2": "<mask token>\n__all__ = ['BuzzerController', 'CardScanner', 'RFIDController',\n 'ServoController']\n", "step-3": "from .Buzzer import BuzzerController\nfrom .Card import CardScanner\nfrom .RFID im...
[ 0, 1, 2, 3 ]
from __future__ import division import random as rnd import math from collections import Counter from matplotlib import pyplot as plt import ds_library import ds_algebra import ds_probability import ds_gradient_descent def normal_pdfs_visualization(): xs = [x/10.0 for x in range(-50, 50)] plt.plot(xs...
normal
{ "blob_id": "c0adc0032a2647a19d3540c057fa9762906e5f62", "index": 4439, "step-1": "<mask token>\n\n\ndef normal_pdfs_visualization():\n xs = [(x / 10.0) for x in range(-50, 50)]\n plt.plot(xs, [ds_probability.normal_pdf(x, sigma=1) for x in xs], '-',\n label='mu=0-sigma=1')\n plt.plot(xs, [ds_prob...
[ 3, 4, 6, 7, 8 ]
from django.shortcuts import resolve_url as r from django.test import TestCase class coreGetHome(TestCase): def setUp(self): self.resp = self.client.get(r('core:core_home')) def test_template_home(self): self.assertTemplateUsed(self.resp, 'index.html') def test_200_template_home(self): ...
normal
{ "blob_id": "d20e41dd7054ff133be264bebf13e4e218710ae5", "index": 933, "step-1": "<mask token>\n\n\nclass coreGetHome(TestCase):\n <mask token>\n <mask token>\n\n def test_200_template_home(self):\n self.assertEqual(200, self.resp.status_code)\n", "step-2": "<mask token>\n\n\nclass coreGetHome(T...
[ 2, 3, 4, 5 ]
import praw import pickle import copy class histogram: def __init__(self, dictionary=None): self.frequencies = {} if dictionary is not None: self.frequencies = copy.deepcopy(dictionary) def get_sum(self): the_sum = 0 for e in self.frequencies: the_sum +=...
normal
{ "blob_id": "f135d52e4d5e49f96869c4209b84f30ff72f6780", "index": 876, "step-1": "import praw\nimport pickle\nimport copy\n\nclass histogram:\n def __init__(self, dictionary=None):\n self.frequencies = {}\n if dictionary is not None:\n self.frequencies = copy.deepcopy(dictionary)\n\n ...
[ 0 ]
# Error using ncdump - NetCDF4 Python ncdump -h filename
normal
{ "blob_id": "12f0eeeb81fe611d88e33fd2e8df407e289fb582", "index": 1255, "step-1": "# Error using ncdump - NetCDF4 Python\nncdump -h filename\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
#!/usr/bin/python # -*- coding: utf-8 -*- from __future__ import unicode_literals import os try: import Image except ImportError: from PIL import Image import sys sys.path.append(os.path.abspath(os.path.join(__file__, os.pardir, os.pardir, 'DropPy.Common'))) from file_tools import get_file_paths_from_director...
normal
{ "blob_id": "df3208a00f7a5dd1ddd76542ac0de85762cc45ab", "index": 7236, "step-1": "<mask token>\n\n\nclass Task(object):\n <mask token>\n <mask token>\n\n @staticmethod\n def rotate_file(input_file, output_dir, degrees, expand):\n output_file_name = os.path.basename(input_file)\n output_...
[ 2, 3, 4, 6, 7 ]
import os import pandas as pd import time import sys from tqdm import tqdm sys.path.append(os.path.join(os.environ['HOME'],'Working/interaction/')) from src.make import exec_gjf from src.vdw import vdw_R, get_c_vec_vdw from src.utils import get_E import argparse import numpy as np from scipy import signal i...
normal
{ "blob_id": "961bda96e433bb66d592ad1e99c92db0a9ab9fe9", "index": 8545, "step-1": "<mask token>\n\n\ndef init_process(args):\n auto_dir = args.auto_dir\n monomer_name = args.monomer_name\n os.makedirs(os.path.join(auto_dir, 'gaussian'), exist_ok=True)\n os.makedirs(os.path.join(auto_dir, 'gaussview'),...
[ 3, 7, 9, 10, 12 ]
from starter2 import * from collections import defaultdict import scipy import colors import hair_dryer reload(hair_dryer) import three_loopers_u500 as TL import movie_frames def GE_pearson(this_looper,core_list=None): if core_list is None: core_list = np.unique(this_looper.tr.core_ids) name = th...
normal
{ "blob_id": "0762c5bec2d796bb7888e3de45e29fb20f88f491", "index": 392, "step-1": "<mask token>\n\n\ndef GE_pearson(this_looper, core_list=None):\n if core_list is None:\n core_list = np.unique(this_looper.tr.core_ids)\n name = this_looper.sim_name\n thtr = this_looper.tr\n mask = movie_frames.q...
[ 1, 2, 3, 4, 5 ]
class StartStateImpl: start_message = "Для продолжения мне необходим ваш корпоративный E-mail"\ "Адрес вида: <адрес>@edu.hse.ru (без кавычек)" thank_you = "Спасибо за ваш адрес. Продолжаем." def __init__(self): pass def enter_state(self, message, user): user.send_message(StartS...
normal
{ "blob_id": "3741e44178375f351278cb17c2bf8f11c69e1262", "index": 4009, "step-1": "class StartStateImpl:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def exit_state(self, message, user):\n user.send_message(StartStateImpl.thank_you)\n <mask token>\n\n\nclass StartState(...
[ 5, 6, 7, 8, 10 ]
"""This module will serve the api request.""" import json from bson.json_util import dumps from flask import abort, request, Response, jsonify from api import app, collection @app.route("/api/v1/users", methods=['POST']) def create_user(): """ Function to create new users. """ try: # Creat...
normal
{ "blob_id": "0f4bb65b93df997ca1a9b7945ebcec53a2f43822", "index": 3636, "step-1": "<mask token>\n\n\n@app.route('/api/v1/users', methods=['POST'])\ndef create_user():\n \"\"\"\n Function to create new users.\n \"\"\"\n try:\n try:\n body = request.get_json()\n except:\n ...
[ 3, 4, 5, 6, 7 ]
import tensorflow as tf import blood_model import os import numpy as np FLAGS = tf.app.flags.FLAGS RUN = 'new_test_hm' tf.app.flags.DEFINE_string('checkpoint_dir', RUN+'/checkpoints', """Directory where to write event logs and checkpoint.""") tf.app.flags.DEFINE_string('summaries_dir', RUN+...
normal
{ "blob_id": "f653e906d3026de4bb1e705162f4321bb75e8705", "index": 4166, "step-1": "<mask token>\n\n\ndef check_filesystem():\n \"\"\"\n either start a new checkpoint or continue from existing checkpoint folder\n \"\"\"\n if FLAGS.continue_run:\n if not tf.gfile.Exists(FLAGS.summaries_dir):\n ...
[ 3, 5, 6, 7, 8 ]
import json from django.core.management import call_command from django.http import JsonResponse from django.test import TestCase from django.urls import reverse URLS = ['api_v1:categories', 'api_v1:main_categories', 'api_v1:articles'] class GetJsonData(TestCase): def test_post_not_login_no_pk(self): f...
normal
{ "blob_id": "676caabb103f67c631bc191b11ab0d2d8ab25d1e", "index": 5803, "step-1": "<mask token>\n\n\nclass UnLoginGetArticleJsonTestCase(TestCase):\n\n @classmethod\n def setUpClass(cls):\n super().setUpClass()\n call_command('loaddata', 'fixtures/auth.json', verbosity=0)\n call_command...
[ 5, 7, 8, 9, 11 ]
from slistener import SListener from slistener import track import datetime import time, tweepy, sys import json import re #def tweet_collector(): consumer_key='qpUR91PwjvChszV0VFgrc4Hje' consumer_secret='q9mPUZE2OsFbaqKUF32ZsY1ry4anZ1k8pNSne56wc3HInmERFu' access_token='2845943577-R0g6YRlrdEqSFb2mKy5HXuByQPdpq4TLGrPkm...
normal
{ "blob_id": "606e40dd073c3efc95ef01a08466fd536a28f140", "index": 324, "step-1": "from slistener import SListener\nfrom slistener import track\nimport datetime\nimport time, tweepy, sys\nimport json\nimport re\n\n#def tweet_collector():\nconsumer_key='qpUR91PwjvChszV0VFgrc4Hje'\nconsumer_secret='q9mPUZE2OsFbaqKUF...
[ 0 ]
from setuptools import setup from os import path this_directory = path.abspath(path.dirname(__file__)) with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f: long_description = f.read() setup( name='SumoSound', packages=['SumoSound'], version='1.0.2', license='MIT', description='A pyt...
normal
{ "blob_id": "81c9cabaa611f8e884708d535f0b99ff83ec1c0d", "index": 8319, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:\n long_description = f.read()\nsetup(name='SumoSound', packages=['SumoSound'], version='1.0.2', license=\n ...
[ 0, 1, 2, 3, 4 ]
#read file my_file=open("file.txt","r") #print(my_file.read()) #print(my_file.readline()) #print(my_file.read(3))#read 3 caracteres """ for line in my_file: print(line) my_file.close() """ print(my_file.readlines())#list #close file my_file.close() #create new file and writing new_file=open("newfile.txt",mode="w",...
normal
{ "blob_id": "d44f8a2dee35d76c152695d49d73f74e9c25bfa9", "index": 3015, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(my_file.readlines())\nmy_file.close()\n<mask token>\nfor i in range(5):\n new_file.write('new line ' + str(i + 1) + '\\n')\nnew_file.close()\n<mask token>\nnew_file.writelines(a)...
[ 0, 1, 2, 3 ]
from robotcar import RobotCar import pdb class RobotCar_Stub(RobotCar): def forward(self): print("Forward") def backward(self): print("Backward") def left(self): print("Left") def right(self): print("Right") def stop(self): print("Stop") if __name__ == '__main__': ...
normal
{ "blob_id": "09b2c1e69203f440754e82506b42e7856c94639a", "index": 8623, "step-1": "<mask token>\n\n\nclass RobotCar_Stub(RobotCar):\n <mask token>\n\n def backward(self):\n print('Backward')\n\n def left(self):\n print('Left')\n\n def right(self):\n print('Right')\n\n def stop(...
[ 5, 6, 7, 8, 9 ]
def longest_word(s, d): lengths = [(entry, len(entry)) for entry in d] sorted_d = sorted(lengths, key = lambda x: (-x[1], x[0])) for word, length in sorted_d: j = 0 for i in range(0, len(s)): if j < len(word) and word[j] == s[i]: j += 1 if j == len(wo...
normal
{ "blob_id": "86de5b4a72978e2c49e060eefc513e3ed61272ae", "index": 4004, "step-1": "<mask token>\n", "step-2": "def longest_word(s, d):\n lengths = [(entry, len(entry)) for entry in d]\n sorted_d = sorted(lengths, key=lambda x: (-x[1], x[0]))\n for word, length in sorted_d:\n j = 0\n for i...
[ 0, 1, 2, 3 ]
import requests import json data = json.load(open("dummy_data/data.json")) for one in data: print(one) r = requests.post("http://localhost:8080/sumari", json=one) print(r.text)
normal
{ "blob_id": "8bc40ed4fe1091ecdb40cd55ff9cf53010078823", "index": 361, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor one in data:\n print(one)\n r = requests.post('http://localhost:8080/sumari', json=one)\n print(r.text)\n", "step-3": "<mask token>\ndata = json.load(open('dummy_data/data.j...
[ 0, 1, 2, 3, 4 ]
""" Exercise 3 from the Python tutorial Part 1 on: https://codeandwork.github.io/courses/prep/pythonTutorial1.html """ import math print("Give the length of each side in order to compute the area of a triangle.") lenA = float(input("Give the length of side A:")) lenB = float(input("Give the length of side B:")) len...
normal
{ "blob_id": "398cb05218a9772a0b62fdfbacc465b26427827d", "index": 2854, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(\n 'Give the length of each side in order to compute the area of a triangle.')\n<mask token>\nprint('The triangle area is:', triangleArea)\n", "step-3": "<mask token>\nprint(\n...
[ 0, 1, 2, 3, 4 ]
import sys n=int(input().strip()) a=list(input().strip().split(' ')) H=list(input().strip().split(' ')) a = [int(i) for i in a] m=int(H[0]) hmin=int(H[1]) hmax=int(H[2]) pos=0 found = 0 d=a[-1]-a[0] if(d==m): print(a[0]) elif(0<d<m): for i in range(hmin, hmax+1): fin1 = a[0]-i+m if(hmin<=fin1-...
normal
{ "blob_id": "3da82bcff0a4f91c1245892bc01e9f743ea354a8", "index": 4484, "step-1": "<mask token>\n", "step-2": "<mask token>\nif d == m:\n print(a[0])\nelif 0 < d < m:\n for i in range(hmin, hmax + 1):\n fin1 = a[0] - i + m\n if hmin <= fin1 - a[-1] <= hmax or fin1 == a[-1]:\n prin...
[ 0, 1, 2, 3, 4 ]
from .base import * import os SECRET_KEY = os.environ['SECRET_KEY'] ALLOWED_HOSTS = ['demo.pythonic.nl'] DEBUG = False
normal
{ "blob_id": "e5607d9893b775b216d1790897124a673b190c26", "index": 2085, "step-1": "<mask token>\n", "step-2": "<mask token>\nSECRET_KEY = os.environ['SECRET_KEY']\nALLOWED_HOSTS = ['demo.pythonic.nl']\nDEBUG = False\n", "step-3": "from .base import *\nimport os\nSECRET_KEY = os.environ['SECRET_KEY']\nALLOWED_...
[ 0, 1, 2 ]
#library import pandas as pd import numpy as np import sys from tqdm import tqdm # appear the precess of running situation. import time from scipy.spatial.distance import pdist, squareform #0. Data Load data = pd.read_csv(sys.argv[1], delimiter='\t') # Load train (input text file) #1. Data Preprocessing all_element...
normal
{ "blob_id": "267695555e876dc2fe5820dc194490aad9e5e344", "index": 1361, "step-1": "<mask token>\n\n\ndef avg_dissim_within_group_element(node, element_list):\n max_diameter = -np.inf\n sum_dissm = 0\n for i in element_list:\n sum_dissm += dissimilarity_matrix[node][i]\n if dissimilarity_mat...
[ 4, 5, 6, 8, 9 ]
def primo(num): if num < 1: print(f"El numero {num} no es primo") return None else: if num == 2: print(f"El numero {num} es primo") return None else: for i in range(2, num): if num % i == 0: print(f"El numer...
normal
{ "blob_id": "29eb1a1642d38160c138733e269bb3ba0c5d4bba", "index": 9834, "step-1": "<mask token>\n\n\ndef leerNumero():\n numer = int(input('Escribe un numero ==> '))\n primo(numer)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef leerNumero():\n numer = int(input('Escribe un numero ==> '))\n p...
[ 1, 2, 3, 4, 5 ]
import json import os from six import iteritems from ..exceptions import ColinConfigException from ..constant import CONFIG_DIRECTORY, JSON from ..loader import load_check_implementation from ..target import is_compatible class Config(object): def __init__(self, name=None): """ Load config for ...
normal
{ "blob_id": "7bb9455e6f0c15ab0be6963cff06ff41df73e6e0", "index": 2583, "step-1": "<mask token>\n\n\nclass Config(object):\n\n def __init__(self, name=None):\n \"\"\"\n Load config for colin.\n\n :param name: str (name of the config file (without .json), default is \"default\"\n \"\...
[ 6, 7, 8, 9, 11 ]
from flask import Flask, render_template, request, url_for, redirect,jsonify,json,request from pymongo import MongoClient #conexão bd app = Flask(__name__) conexao = MongoClient('localhost',27017) db = conexao['teste_db'] #inserindo contatos iniciais contato1 = {'nome': 'Lucas', 'email': 'lucas@gmail.com', 'telefone...
normal
{ "blob_id": "05ca16303d0eb962249793164ac91795c45cc3c2", "index": 9974, "step-1": "<mask token>\n\n\n@app.route('/')\ndef showMachineList():\n return render_template('list.html')\n\n\n@app.route('/insert_records', methods=['POST'])\ndef insert_records():\n json_data = request.json['info']\n nome = json_d...
[ 3, 4, 5, 6, 7 ]
from scipy.io import wavfile import numpy from matplotlib import pyplot as plt import librosa import noisereduce def loadWavFile(fileName, filePath, savePlot, maxAudioLength, reduceNoise = True): # Read file # rate, data = wavfile.read(filePath) # print(filePath, rate, data.shape, "audio length", data.shap...
normal
{ "blob_id": "07ac061d7d1eaf23b6c95fbcbf6753f25e568188", "index": 157, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef loadWavFile(fileName, filePath, savePlot, maxAudioLength, reduceNoise=True\n ):\n data, rate = librosa.load(filePath, sr=None)\n if reduceNoise:\n noiseRemovedData ...
[ 0, 1, 2, 3 ]
from sklearn.preprocessing import RobustScaler from statsmodels.tsa.arima.model import ARIMA from sklearn.metrics import mean_squared_error, r2_score, mean_absolute_error from math import sqrt import tensorflow as tf import pandas as pd import numpy as np import os import random # set random seed random.seed(1) np.ra...
normal
{ "blob_id": "d78ac5188cad104ee1b3e214898c41f843b6d8c0", "index": 5185, "step-1": "<mask token>\n", "step-2": "<mask token>\nrandom.seed(1)\nnp.random.seed(1)\ntf.random.set_random_seed(1)\n<mask token>\nfor i in range(1, 6):\n df = pd.read_csv(random_sample_save_folder_path + \n 'power_demand_sample%...
[ 0, 1, 2, 3, 4 ]
from flask_restful import Api, Resource, reqparse class HelloApiHandler(Resource): def get(self): return { 'resultStatus': 'SUCCESS', 'message': "Hello Api Handler" } def post(self): print(self) parser = reqparse.RequestParser() parser.add_argument('type', type=str) parser.ad...
normal
{ "blob_id": "80c3d9165c1b592122fabf6382e265465604989c", "index": 1450, "step-1": "<mask token>\n\n\nclass HelloApiHandler(Resource):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass HelloApiHandler(Resource):\n\n def get(self):\n return {'resultStatus': 'SUCCESS', 'message':...
[ 1, 2, 3, 4, 5 ]
from game import BaseGame class First(BaseGame): key = 'F' code = 'FIRST' short_description = 'Vinci se esce 1 o 2. x2.8' long_description = ( 'Si lancia un unico dado, se esce 1 o 2 vinci 2.8 volte quello che hai' ' puntato.') min_bet = 20 multiplier = 2.8 def has_won(sel...
normal
{ "blob_id": "81fa3129d971fe8296a89a7b772d61ff50a8b9f7", "index": 9284, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass First(BaseGame):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def has_won(self, draws):\n return dra...
[ 0, 2, 3, 4, 5 ]
import speech_recognition as sr import pyttsx3 import pywhatkit import datetime listner = sr.Recognizer() engine = pyttsx3.init() #change voices voices = engine.getProperty('voices') engine.setProperty('voice',voices[10].id) rate = engine.getProperty('rate') engine.setProperty('rate', 150) #for machine to say def t...
normal
{ "blob_id": "c4f437e6f5aaeccb6dd0948c3ed1f1d465bb29ce", "index": 1200, "step-1": "<mask token>\n\n\ndef talk(text):\n engine.say(text)\n engine.runAndWait()\n\n\ndef takeCommand():\n try:\n with sr.Microphone() as sc:\n print('Listening......')\n vc = listner.listen(sc)\n ...
[ 3, 4, 5, 6, 7 ]
from collections import Counter import pandas as pd import string from collections import namedtuple, defaultdict import csv import sys import torch import numpy as np from sklearn.preprocessing import LabelEncoder from scipy.sparse import coo_matrix from tqdm import tqdm device = torch.device('cuda' if torch.cuda.is_...
normal
{ "blob_id": "613b060ee50b49417342cfa70b36f77d112dcc58", "index": 2951, "step-1": "<mask token>\n\n\ndef get_data():\n df = pd.read_csv('./data/filteredCorpus.csv')\n df_filt = df[df['outcome'] == True]\n df_filt = df_filt[df_filt['role'] == 'speaker']\n df_filt = df_filt[df_filt['source'] == 'human']...
[ 4, 5, 6, 7, 8 ]
from unittest.case import TestCase from datetime import datetime from src.main.domain.Cohort import Cohort from src.main.domain.Group import Group from src.main.util.TimeFormatter import TimeFormatter __author__ = 'continueing' class CohortTest(TestCase): def testAnalyzeNewGroups(self): cohort = Cohort(...
normal
{ "blob_id": "f12bdfc054e62dc244a95daad9682790c880f20d", "index": 5367, "step-1": "<mask token>\n\n\nclass CohortTest(TestCase):\n\n def testAnalyzeNewGroups(self):\n cohort = Cohort(aStartDate=TimeFormatter.toDatetime(\n '2014-05-05 00:00:00'), aEndDate=TimeFormatter.toDatetime(\n ...
[ 2, 3, 4, 5, 6 ]
import re pattern1 = r"[:]{2}[A-Z][a-z]{2,}[:]{2}|[\*]{2}[a-zA-Z]{3,}[\*]{2}" pattern2 = r"([0-9]+)" data = input() valid_emojis = re.findall(pattern1, data) numbers_ascii = re.findall(pattern2, data) numbers_total = "" for num in numbers_ascii: numbers_total += num cool_threshold = 1 for i in numbers_total: ...
normal
{ "blob_id": "c2201a281ccd0833b0d7d2219d97ce3175fb012b", "index": 2042, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor num in numbers_ascii:\n numbers_total += num\n<mask token>\nfor i in numbers_total:\n i = int(i)\n cool_threshold *= i\nprint(f'Cool threshold: {cool_threshold}')\n<mask toke...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.test import TestCase from collections import Counter import generator.resume_parser as resume_parser import os import json class TestResumeParser(TestCase): def load_resume(self, resume_name): path_to_directory = "generator/fixtures/{...
normal
{ "blob_id": "4bbfb35e4b03e2bfd46dd0fe5bfd54fb01ba11df", "index": 1996, "step-1": "<mask token>\n\n\nclass TestResumeParser(TestCase):\n <mask token>\n <mask token>\n\n def generate_counter(self, resume_name):\n json_file = self.load_resume(resume_name)\n return self.convert_to_counter(json...
[ 10, 22, 24, 25, 26 ]
import os from google.cloud import bigquery def csv_loader(data, context): client = bigquery.Client() dataset_id = os.environ['DATASET'] dataset_ref = client.dataset(dataset_id) job_config = bigquery.LoadJobConfig() job_config.schema = [ bigquery.SchemaField('id'...
normal
{ "blob_id": "01467a4dad3255a99025c347469881a71ffbae7c", "index": 8179, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef csv_loader(data, context):\n client = bigquery.Client()\n dataset_id = os.environ['DATASET']\n dataset_ref = client.dataset(dataset_id)\n job_config = bigquery.LoadJob...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- { 'name': 'EDC Analytic Entry', 'depends': [ 'stock_account', 'purchase_stock', 'account_accountant', ], "description": """ """, 'author': "Ejaftech", 'data': [ 'views/account_move_view.xml', ], }
normal
{ "blob_id": "797e7c1b3e8b41a167bfbedfb6a9449e6426ba22", "index": 8570, "step-1": "<mask token>\n", "step-2": "{'name': 'EDC Analytic Entry', 'depends': ['stock_account',\n 'purchase_stock', 'account_accountant'], 'description': '\\n ',\n 'author': 'Ejaftech', 'data': ['views/account_move_view.xml']}\n"...
[ 0, 1, 2 ]
#!/usr/bin/env python import sys total = 0 for line in sys.stdin: edges = [int(x) for x in line.split("x")] edges.sort() ribbon = sum(x * 2 for x in edges[:2]) l, w, h = edges bow = l * w * h total += bow + ribbon print(total)
normal
{ "blob_id": "ed85cb61f4bc8bf758dafb10ffbabf87fb4521d0", "index": 9281, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in sys.stdin:\n edges = [int(x) for x in line.split('x')]\n edges.sort()\n ribbon = sum(x * 2 for x in edges[:2])\n l, w, h = edges\n bow = l * w * h\n total +=...
[ 0, 1, 2, 3, 4 ]
import datetime with open('D:\Documents\PythonDocs\ehmatthes-pcc-f555082\chapter_10\programming.txt') as f_obj: lines = f_obj.readlines() m_lines = [] for line in lines: m_line = line.replace('python', 'C#') m_lines.append(m_line) with open('D:\Documents\PythonDocs\ehmatthes-pcc-f555082\chapter_10\prog...
normal
{ "blob_id": "03da813650d56e7ab92885b698d4af3a51176903", "index": 3878, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(\n 'D:\\\\Documents\\\\PythonDocs\\\\ehmatthes-pcc-f555082\\\\chapter_10\\\\programming.txt'\n ) as f_obj:\n lines = f_obj.readlines()\n<mask token>\nfor line in lines:...
[ 0, 1, 2, 3, 4 ]
''' Created on 13 Dec 2016 @author: hpcosta ''' # https://www.hackerrank.com/challenges/backreferences-to-failed-groups regex = r"^\d{2}(-?)\d{2}\1\d{2}\1\d{2}$" # Do not delete 'r'. import re print(str(bool(re.search(regex, raw_input()))).lower()) # Task # # You have a test string S. # Your task is to write...
normal
{ "blob_id": "e884ce5878de75afe93085e2310b4b8d5953963a", "index": 337, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(str(bool(re.search(regex, raw_input()))).lower())\n", "step-3": "<mask token>\nregex = '^\\\\d{2}(-?)\\\\d{2}\\\\1\\\\d{2}\\\\1\\\\d{2}$'\n<mask token>\nprint(str(bool(re.search(re...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.0.1 on 2020-01-11 19:59 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('users', '0004_auto_20191230_2037'), ] operations = [ migrations.AddField( model_name='user', name='cir...
normal
{ "blob_id": "6aa762165dba891a3638d13862019dd342a7e05a", "index": 7644, "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 = [('users', '00...
[ 0, 1, 2, 3, 4 ]
from django import forms class photoForm(forms.Form): iso = forms.ChoiceField(label='ISO', choices=[("100", 100), ("200", 200), ("300", 300), ("400", 400), ...
normal
{ "blob_id": "19b55b2de3d2ed16275cef572e3518fbb2457f84", "index": 8293, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass photoForm(forms.Form):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass photoForm(forms.Form):\n iso = forms.ChoiceField(label='ISO', choices=[('1...
[ 0, 1, 2, 3, 4 ]
#------------------------------------------------------------------------------- # rtlconverter.py # # PyCoRAM RTL Converter # # Copyright (C) 2013, Shinya Takamaeda-Yamazaki # License: Apache 2.0 #------------------------------------------------------------------------------- import sys import os import subprocess im...
normal
{ "blob_id": "55ffcf5e6120cc07da461e30979dd8a36a599bee", "index": 8353, "step-1": "<mask token>\n\n\nclass RtlConverter(object):\n\n def __init__(self, filelist, topmodule='userlogic', include=None,\n define=None, single_clock=False):\n self.filelist = filelist\n self.topmodule = topmodule...
[ 7, 8, 9, 10, 11 ]
#!/usr/bin/python2 # -*- coding: UTF-8 -*- # coding: utf-8 #!/usr/bin/env python ''' 发布轨迹信息 path.x; path.y; c_speed; ''' import numpy as np import matplotlib.pyplot as plt import copy import math from cubic_spline import Spline2D from polynomials import QuarticPolynomial, QuinticPolynomial import time import...
normal
{ "blob_id": "4647a7d0996ceeef4f39cf3182ac3944d25cb349", "index": 8197, "step-1": "<mask token>\n\n\nclass FrenetPath:\n\n def __init__(self):\n self.t = []\n self.d = []\n self.d_d = []\n self.d_dd = []\n self.d_ddd = []\n self.s = []\n self.s_d = []\n s...
[ 20, 21, 24, 25, 27 ]
#-------------------------------------------------------- # File------------project2.py # Developer-------Paige Weber # Course----------CS1213-03 # Project---------Project #1 # Due-------------September 26, 2017 # # This program uses Gregory-Leibniz series to compute # an approximate value of pi. #---------------------...
normal
{ "blob_id": "466148395a4141793b5f92c84513fd093876db76", "index": 9964, "step-1": "<mask token>\n", "step-2": "<mask token>\nif number_of_terms >= 1:\n add_approximation = 0\n for count in range(1, number_of_terms):\n approximation = (-1) ** (count + 1) / (2 * count - 1)\n add_approximation ...
[ 0, 1, 2, 3 ]
from django.contrib.auth.models import User from django.core import validators from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from django.contrib.auth.models import Group from django.conf import settings @receiver(post_save, sender=settings.AUTH_USER_...
normal
{ "blob_id": "a139042d0c6fa4941b7149a33b0a48018e9f511b", "index": 9003, "step-1": "<mask token>\n\n\nclass Category(models.Model):\n \"\"\"Категории\"\"\"\n name = models.CharField('Категория', max_length=150)\n url = models.SlugField(max_length=160, unique=True)\n\n def __str__(self):\n return...
[ 8, 9, 10, 14, 15 ]
from golem import actions from projects.golem_gui.pages import common from projects.golem_gui.pages import api from projects.golem_gui.pages import test_builder_code description = 'Verify the user can edit test code and save it' tags = ['smoke'] def setup(data): common.access_golem(data.env.url, data.env.admin) ...
normal
{ "blob_id": "d4cdc4f1995eab7f01c970b43cb0a3c5ed4a2711", "index": 3673, "step-1": "<mask token>\n\n\ndef setup(data):\n common.access_golem(data.env.url, data.env.admin)\n api.project.using_project('test_builder_code')\n data.test = api.test.create_access_test_code(data.project)\n\n\n<mask token>\n", "...
[ 1, 2, 3, 4 ]
from sklearn import svm, metrics, tree from sklearn.ensemble import AdaBoostClassifier from sklearn.neighbors import KNeighborsClassifier import numpy as np my_data = np.loadtxt('edited_data/dataset_regression_edited.csv',delimiter=',', dtype='str') training_data = my_data[:, 0:6] validation_data = my_data[:, 6] ...
normal
{ "blob_id": "3024359710148bfbb15677973555f214b1f878b7", "index": 1521, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor classifier in classifiers:\n classifier.fit(training_data[:1500], validation_data[:1500])\n expected = validation_data[681:]\n predicted = classifier.predict(training_data[68...
[ 0, 1, 2, 3, 4 ]
#GUIcal.py from tkinter import * from tkinter import ttk import math GUI=Tk() GUI.title('My Cal Program') GUI.geometry('500x500') def calc(): height=v_height.get() base=v_base.get()#ดึงค่ามาจากv_base print(f'height is {height}') print(f'Basal length is {base}') length= math.isqrt((height*height)+(b...
normal
{ "blob_id": "77d7fb49ed4c3e78b148cd446e9a5c6a0e6fac8b", "index": 835, "step-1": "<mask token>\n\n\ndef calc():\n height = v_height.get()\n base = v_base.get()\n print(f'height is {height}')\n print(f'Basal length is {base}')\n length = math.isqrt(height * height + base * base)\n print('Lenght i...
[ 1, 2, 3, 4, 5 ]
# -*- coding:utf-8 -*- import requests from lxml import etree import codecs from transfrom import del_extra import re MODIFIED_TEXT = [r'一秒记住.*?。', r'(看书.*?)', r'纯文字.*?问', r'热门.*?>', r'最新章节.*?新', r'は防§.*?e', r'&.*?>', r'r.*?>', r'c.*?>', r'复制.*?>', r'字-符.*?>', r'最新最快,无.*?。', ...
normal
{ "blob_id": "7539042b92a5188a11f625cdfc0f341941f751f0", "index": 6937, "step-1": "<mask token>\n\n\ndef crawl_urls(u):\n response = requests.get(u, headers=HEADER)\n body = etree.HTML(response.content)\n content_urls = body.xpath('//div[@class=\"box_con\"]/div/dl//dd/a/@href')\n for pk_id, u in enume...
[ 4, 5, 6, 7, 8 ]
from yoloPydarknet import pydarknetYOLO import cv2 import imutils import time yolo = pydarknetYOLO(obdata="../darknet/cfg/coco.data", weights="yolov3.weights", cfg="../darknet/cfg/yolov3.cfg") video_out = "yolo_output.avi" start_time = time.time() if __name__ == "__main__": VIDEO_IN = cv2.VideoCapture(0) ...
normal
{ "blob_id": "669eb2e898c3a127ae01e0ee3020a3674e5e340d", "index": 1091, "step-1": "from yoloPydarknet import pydarknetYOLO\nimport cv2\nimport imutils\nimport time\n\nyolo = pydarknetYOLO(obdata=\"../darknet/cfg/coco.data\", weights=\"yolov3.weights\", \n cfg=\"../darknet/cfg/yolov3.cfg\")\nvideo_out = \"yolo_...
[ 0 ]
# Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. import datetime import json import logging import mock from parameterized import parameterized from buildbucket_proto import common_pb2 from buildbucket_pr...
normal
{ "blob_id": "325efe65030ad3488a7fc45c0d4a289eb0b17196", "index": 1311, "step-1": "<mask token>\n\n\nclass StepUtilTest(wf_testcase.WaterfallTestCase):\n\n def testGetLowerBoundBuildNumber(self):\n self.assertEqual(5, step_util._GetLowerBoundBuildNumber(5, 100))\n self.assertEqual(50, step_util._...
[ 26, 32, 43, 49, 55 ]
import datetime import matplotlib.pyplot as plt import numpy as np import statsmodels.api as sm import xlrd from pandas import * from xlrd import xldate #since I messed up when first scraping the data, I have the dates and viewcounts in separate files #need to create a dictionary of 'author-title':[viewcount, date] ...
normal
{ "blob_id": "6ece524c82521b175cc7791e22c8249dd24dc714", "index": 2281, "step-1": "import datetime\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport statsmodels.api as sm\nimport xlrd\nfrom pandas import *\nfrom xlrd import xldate\n\n\n#since I messed up when first scraping the data, I have the dates a...
[ 0 ]
# Generated by Django 3.0.1 on 2020-02-01 16:38 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('shopUser', '0024_order_contact'), ] operations = [ migrations.AddField( model_name='order', name='location', ...
normal
{ "blob_id": "0a5570ef17efa26ef6317930df616c8326f83314", "index": 2936, "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 = [('shopUser', ...
[ 0, 1, 2, 3, 4 ]
import requests,cv2,numpy,time,imutils class imageAnalyzer(): def __init__(self, roverName="Rover03", url="http://192.168.1.10:5000/api/", temp_img_path = "./temp", ): self.url = url + roverName self.temp_img_path = ...
normal
{ "blob_id": "7d3264e9a90ebd72439f77983cbf4f9755048a85", "index": 4300, "step-1": "<mask token>\n\n\nclass imageAnalyzer:\n <mask token>\n\n def getImage(self, img_number):\n temp = open(self.temp_img_path + str(img_number) + '.jpeg', 'wb')\n img = requests.get(self.url + '/image')\n te...
[ 6, 8, 9, 10, 11 ]
#!/usr/bin/python import socket import sys host = '10.211.55.5' port = 69 try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) except: print "socket() failed" sys.exit(1) filename = "Aa0Aa1Aa2Aa3Aa4Aa5Aa6Aa7Aa8Aa9Ab0Ab1Ab2Ab3Ab4Ab5Ab6Ab7Ab8Ab9Ac0Ac1Ac2Ac3Ac4Ac5Ac6Ac7Ac8Ac9Ad0Ad1Ad2Ad3Ad4Ad5Ad6Ad7...
normal
{ "blob_id": "b318f5d443dbf8e4442707839649149e75653295", "index": 5917, "step-1": "#!/usr/bin/python \nimport socket \nimport sys\n\nhost = '10.211.55.5' \nport = 69\ntry:\n s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) \nexcept:\n print \"socket() failed\" \n sys.exit(1)\nfilename = \"Aa0Aa1Aa2Aa...
[ 0 ]
class Solution(object): def findDisappearedNumbers(self, nums): """ :type nums: List[int] :rtype: List[int] """ ns = [0]*len(nums) for i in range(0, len(nums), 1): ns[nums[i]-1] = 1 ret = [] for j in range(0, len(ns), 1): ...
normal
{ "blob_id": "87504fb88cbbf810ad8bab08bc59284d2cf37cce", "index": 850, "step-1": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Solution(object):\n\n def findDisappearedNumbers(self, nums):\n \"\"\"\n :type nums: List[int]\n :rtype: Li...
[ 1, 2, 3, 4, 5 ]
import cv2 import numpy as np import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt from keras.preprocessing.image import ImageDataGenerator from keras.models import Sequential from keras.layers import SeparableConv2D, Conv2D, MaxPooling2D from keras.layers import BatchNormalization, Activation, Dropo...
normal
{ "blob_id": "e47d6b5d46f2dd84569a2341178b2ea5e074603a", "index": 7361, "step-1": "<mask token>\n\n\ndef layer_to_visualize(layer):\n inputs = [K.learning_phase()] + model.inputs\n _convout1_f = K.function(inputs, [layer.output])\n\n def convout1_f(X):\n return _convout1_f([0] + [X])\n convolut...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/python import os from subprocess import Popen, PIPE, STDOUT import time import re import telnetlib from get_sys_info import get_node_list, get_spec_node_list, get_active_tcu, get_ru_list, is_active_ru g_rg_list = [ '/SGWNetMgr', '/SS7SGU', '/MGW_CMRG', '/MGW_OMURG', '/Directory', ] status_dic...
normal
{ "blob_id": "603d904404ace88205a524d8bfbe3e621b65f425", "index": 8750, "step-1": "#!/usr/bin/python\nimport os\nfrom subprocess import Popen, PIPE, STDOUT\nimport time\nimport re\nimport telnetlib\nfrom get_sys_info import get_node_list, get_spec_node_list, get_active_tcu, get_ru_list, is_active_ru\ng_rg_list = ...
[ 0 ]
# Kai Joseph # Loop Practice # Since I worked on my own, I did not have to complete all 25 challenges (with Ms. Healey's permission). I completed a total of 14 challenges. import sys import random ''' 1. Write a for loop that will print out all the integers from 0-4 in ascending order. ''' if sys.argv[1] == '...
normal
{ "blob_id": "eda8bde048f3d4c4af4bd1c296e4cc02b92eaa17", "index": 4727, "step-1": "<mask token>\n", "step-2": "<mask token>\nif sys.argv[1] == '1':\n for x in range(5):\n print(str(x))\n<mask token>\nif sys.argv[1] == '2':\n for x in range(5):\n print(str(4 - x))\n<mask token>\nif sys.argv[1...
[ 0, 1, 2, 3 ]
# # Author:: Noah Kantrowitz <noah@coderanger.net> # # Copyright 2014, Noah Kantrowitz # # 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 # # Unles...
normal
{ "blob_id": "a1e563f94044ff7cd7e0e55542bc4ca2db81df28", "index": 9749, "step-1": "<mask token>\n\n\nclass TestUnwrap(object):\n\n @pytest.fixture\n def fn(self):\n\n def fn():\n pass\n return fn\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask toke...
[ 14, 15, 20, 25, 26 ]