code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
from datetime import datetime import xarray import matplotlib.pyplot as plt import pandas as pd from matplotlib.dates import date2num import numpy as np from matplotlib.gridspec import GridSpec def test_plot_area_avg(target_nc_folder="", source_nc_path=""): # target_nc_folder = "/HOME/huziy/skynet3_rech1/Netbea...
normal
{ "blob_id": "2d5e147b081283047cd044746d73d91ee2e59052", "index": 4139, "step-1": "<mask token>\n\n\ndef __print_field_stats(tfield, field, label):\n good_mask = ~field.mask\n if not np.any(good_mask):\n print(f'{label}: no meaningful data')\n return\n good_data = field[good_mask]\n prin...
[ 3, 4, 5, 6, 7 ]
# coding: utf-8 import sys from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand from flask_assets import ManageAssets from app import app from assets import assets from db import db from .changepassword import ChangePassword from .create_superuser import SuperUserCommand from ....
normal
{ "blob_id": "c331802cf5a09bc8db8ddbfa37636a01cf73684e", "index": 2626, "step-1": "<mask token>\n\n\nclass MyMan(Manager):\n\n def run(self, commands=None, default_command=None):\n \"\"\"\n Prepares manager to receive command line input. Usually run\n inside \"if __name__ == \"__main__\" b...
[ 2, 3, 4, 5, 6 ]
import os, sys, datetime, pytz, tzlocal, urllib.request, requests, csv, hashlib, json, boto3 uri = 'ftp://ftpcimis.water.ca.gov/pub2/daily/daily107.csv' #Station 107 is Santa Barbara base_et = 0.15 def main(): try: tempfile = tempfile_name() get_datafile(tempfile) except: print("Could not retrieve da...
normal
{ "blob_id": "4d82e68faa3102fc2949fd805588504b7d874589", "index": 5457, "step-1": "<mask token>\n\n\ndef main():\n try:\n tempfile = tempfile_name()\n get_datafile(tempfile)\n except:\n print('Could not retrieve datafile ' + tempfile)\n exit(-1)\n et = get_yesterdays_et(tempfi...
[ 8, 9, 10, 11, 12 ]
# 数组的每个索引作为一个阶梯,第 i个阶梯对应着一个非负数的体力花费值 cost[i](索引从0开始)。 # # 每当你爬上一个阶梯你都要花费对应的体力花费值,然后你可以选择继续爬一个阶梯或者爬两个阶梯。 # # 您需要找到达到楼层顶部的最低花费。在开始时,你可以选择从索引为 0 或 1 的元素作为初始阶梯。 # # 示例 1: # # 输入: cost = [10, 15, 20] # 输出: 15 # 解释: 最低花费是从cost[1]开始,然后走两步即可到阶梯顶,一共花费15。 # # # 示例 2: # # 输入: cost = [1, 100, 1, 1, 1, 100, 1, 1, 100, 1] # 输出...
normal
{ "blob_id": "38363316cc9a8419a528bb78b9ad03682e24172d", "index": 9823, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution(object):\n\n def minCostClimbingStairs(self, cost):\n \"\"\"\n :type cost: List[int]\n ...
[ 0, 1, 2, 3, 4 ]
#https://codeforces.com/problemset/problem/1321/A n=int(input()) r=list(map(int,input().split())) b=list(map(int,input().split())) l=[0]*n x=0 y=0 for i in range(n): if r[i]-b[i]==1: x+=1 elif r[i]-b[i]==-1: y+=1 if x==0: print(-1) else: print(y//x+min(y%x+1,1))
normal
{ "blob_id": "7aa6bba8483082354a94ed5c465e59a0fc97fe23", "index": 1248, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n if r[i] - b[i] == 1:\n x += 1\n elif r[i] - b[i] == -1:\n y += 1\nif x == 0:\n print(-1)\nelse:\n print(y // x + min(y % x + 1, 1))\n", "s...
[ 0, 1, 2, 3 ]
from django import forms from django.forms import ModelForm from .models import Noticia class NoticiaForm(ModelForm): class Meta: model = Noticia fields = ['idNoticia', 'resumen', 'titulo', 'categoria']
normal
{ "blob_id": "e7a283e0e0e16e9adb415b26d724b2ee84c4f4f8", "index": 1547, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass NoticiaForm(ModelForm):\n\n\n class Meta:\n model = Noticia\n fields = ['idNoticia', 'resumen', 'titulo', 'categoria']\n", "step-3": "from django import forms...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- from __future__ import print_function, absolute_import, unicode_literals, division __all__ = ['getLevelName', 'getLevel'] #, 'getLevelOrName', '_checkLevel'] import logging # private re-implementations till Python Core fixes Lib/logging # XXX bug numbers here def getLevelName(level, format='...
normal
{ "blob_id": "ba8b46f830abaaaedf1730cba2f04fd677f11da4", "index": 182, "step-1": "<mask token>\n\n\ndef getLevel(levelName, no_match=logging.NOTSET):\n \"\"\"Return the numeric representation of levelName.\n\n see getLevelName() for background\n \"\"\"\n try:\n result = logging._nameToLevel.get...
[ 2, 3, 5, 6, 7 ]
# -*- encoding: utf-8 -*- ############################################################################## # # ServerPLM, Open Source Product Lifcycle Management System # Copyright (C) 2020-2020 Didotech srl (<http://www.didotech.com>). All Rights Reserved # # Created on : 2018-03-01 # Author : Fabio ...
normal
{ "blob_id": "06643bf4b1bded757078b0974c21ddec814f5889", "index": 1762, "step-1": "<mask token>\n\n\nclass plm_component(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def _insertlog(self, ids, changes={}, note={}):\n ret = False\n op_...
[ 20, 34, 38, 44, 49 ]
import socket from Server.MachineClient.Identification import Identification from Server.SQL import DataBase import threading import time from Server.Connection.AcceptClients import Accept from Server.Connection.ConnectionCheck import ConnectionCheck from Server.Clients_Data import Clients class MachineClient: de...
normal
{ "blob_id": "ff1bb2634ffec6181a42c80a4b2a19c2c27a8f9f", "index": 3136, "step-1": "<mask token>\n\n\nclass MachineClient:\n\n def __init__(self, host, port):\n self.host = host\n self.port = port\n self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\n self.db = DataBase(\n ...
[ 5, 6, 7, 8, 9 ]
import sys def tackle_mandragora(health): health.sort() # for all tipping points, where we change over from eating to defeating defeating = defeating_cost_precompute(health) opt = 0 for i in range(0, len(health) + 1): opt = max(opt, defeating_cost(i, defeating)) return opt def defe...
normal
{ "blob_id": "24ad62342fb9e7759be8561eaf0292736c7dcb6d", "index": 6756, "step-1": "<mask token>\n\n\ndef defeating_cost(i, defeating):\n return (i + 1) * defeating[i]\n\n\ndef defeating_cost_precompute(health):\n n = len(health) + 1\n defeating = [(0) for x in range(n)]\n defeating[len(health)] = 0\n ...
[ 2, 4, 5, 6, 7 ]
"""This module contains an algorithm to find the different components in a graph represented as an adjacency matrix. """ def find_components(adjacency_matrix): visited = set() components = [] for node in range(len(adjacency_matrix)): if node not in visited: component = [] b...
normal
{ "blob_id": "e71a23ef7a065bc4210e55552e19c83c428bc194", "index": 3187, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef find_components(adjacency_matrix):\n visited = set()\n components = []\n for node in range(len(adjacency_matrix)):\n if node not in visited:\n component...
[ 0, 1, 2, 3 ]
import server_pb2 import atexit from grpc.beta import implementations from random import randint from grpc._adapter._types import ConnectivityState global _pool _pool = dict() class ChannelPool(object): def __init__(self, host, port, pool_size): self.host = host self.port = port self.p...
normal
{ "blob_id": "aec45936bb07277360ea1a66b062edc4c282b45a", "index": 4097, "step-1": "import server_pb2\n\nimport atexit\n\nfrom grpc.beta import implementations\nfrom random import randint\nfrom grpc._adapter._types import ConnectivityState\n\nglobal _pool\n_pool = dict()\n\n\nclass ChannelPool(object):\n\n def ...
[ 0 ]
import itertools import unittest from pylev3 import Levenshtein TEST_DATA = [ ('classic', "kitten", "sitting", 3), ('same', "kitten", "kitten", 0), ('empty', "", "", 0), ('a', "meilenstein", "levenshtein", 4), ('b', "levenshtein", "frankenstein", 6), ('c', "confide", "deceit", 6), ('d', "...
normal
{ "blob_id": "892d6662e4276f96797c9654d15c96a608d0835a", "index": 8927, "step-1": "<mask token>\n\n\nclass Tests(unittest.TestCase):\n\n def test_singleton(self):\n lev1, lev2 = Levenshtein(), Levenshtein()\n self.assertIs(lev1, lev2)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Tes...
[ 2, 3, 4, 5, 7 ]
#! /usr/bin/env python import ldac from numpy import * import shearprofile as sp import sys import os, subprocess import pylab if len(sys.argv) != 6: sys.stderr.write("wrong number of arguments!\n") sys.exit(1) catfile= sys.argv[1] clusterz=float(sys.argv[2]) center= map(float,sys.argv[3].split(',')) pixsc...
normal
{ "blob_id": "f19d8aa2104240cc93a0146f1b14c635e7cd3a41", "index": 268, "step-1": "#! /usr/bin/env python\n\nimport ldac\nfrom numpy import *\nimport shearprofile as sp\nimport sys\nimport os, subprocess\n\nimport pylab\n\n\nif len(sys.argv) != 6:\n sys.stderr.write(\"wrong number of arguments!\\n\")\n sys.e...
[ 0 ]
#!/usr/bin/env python import crawl import logging from elasticsearch import Elasticsearch if __name__ == '__main__': logging.basicConfig(level=logging.INFO) logging.getLogger("crawl").setLevel(logging.INFO) logging.getLogger("elasticsearch").setLevel(logging.ERROR) es = Elasticsearch() crawl...
normal
{ "blob_id": "21d07c2b80aa00d0c75da342d37195b6829593b6", "index": 1110, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n logging.basicConfig(level=logging.INFO)\n logging.getLogger('crawl').setLevel(logging.INFO)\n logging.getLogger('elasticsearch').setLevel(logging.ERR...
[ 0, 1, 2, 3 ]
# # @lc app=leetcode id=67 lang=python3 # # [67] Add Binary # # https://leetcode.com/problems/add-binary/description/ # # algorithms # Easy (46.70%) # Likes: 2566 # Dislikes: 331 # Total Accepted: 572.1K # Total Submissions: 1.2M # Testcase Example: '"11"\n"1"' # # Given two binary strings a and b, return their ...
normal
{ "blob_id": "227a56c970a74d515ab694d2c0924885e2209cfe", "index": 7089, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def addBinary(self, a: str, b: str) ->str:\n if len(a) < len(b):\n a = '0' * (len(b) - len(a)) + a\n e...
[ 0, 1, 2, 3 ]
class Patient(object): def __init__(self, id_number, name, bed_number, *allergies): self.id_number = id_number self.name = name self.allergies = allergies self.bed_number = bed_number class Hospital(object): def __init__(self, name, capacity): self.patients = [] ...
normal
{ "blob_id": "259a4bb39496bdfc71d60edb4994d26351c6961d", "index": 3621, "step-1": "class Patient(object):\r\n def __init__(self, id_number, name, bed_number, *allergies):\r\n self.id_number = id_number\r\n self.name = name\r\n self.allergies = allergies\r\n self.bed_number = bed_num...
[ 0 ]
from pathlib import Path from build_midi.appenders import * from build_midi.converters import Converter from build_midi.melody_builder import MelodyBuilder from build_midi.sequences import * from build_midi.tracks import * from music_rules.instruments import Instruments from music_rules.music_scale import MusicScale f...
normal
{ "blob_id": "c846c33ef13795d51c6d23ffa5a6b564b66e6a3c", "index": 3438, "step-1": "<mask token>\n\n\nclass WeatherToMusicConverter:\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 WeatherToMusicConverter:\n <ma...
[ 1, 4, 5, 6, 7 ]
# Copyright (c) 2015 OpenStack Foundation. # # 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 # # Unle...
normal
{ "blob_id": "89a3c34b3145b93a4cfa78eeb055c8136ab2bfe6", "index": 2084, "step-1": "<mask token>\n\n\nclass OvsApi(object):\n <mask token>\n\n def __init__(self, ip, protocol='tcp', port='6640', timeout=10):\n super(OvsApi, self).__init__()\n self.ip = ip\n self.protocol = protocol\n ...
[ 18, 23, 25, 27, 35 ]
from flask import Flask, request, jsonify import sqlite3 from database import Database app = Flask(__name__) db = Database() @app.route('/') def homepage(): argslist = request.args faciltype = argslist.get('facil') facils = [] try: facils = db.getFacilitiesFromFacilityType(facilty...
normal
{ "blob_id": "2424d667e1bb4ee75b5053eb6f9b002787a5317f", "index": 6391, "step-1": "<mask token>\n\n\n@app.route('/')\ndef homepage():\n argslist = request.args\n faciltype = argslist.get('facil')\n facils = []\n try:\n facils = db.getFacilitiesFromFacilityType(faciltype)\n facils = map(l...
[ 2, 6, 7, 8, 9 ]
from flask import Flask, render_template, request app = Flask(__name__) def convert(decimal_num): roman = {1000:'M', 900:'CM', 500:'D', 400:'CD', 100:'C', 90:'XC', 50:'L', 40:'XL', 10:'X', 9:'IX', 5:'V', 4:'IV', 1:'I'} num_to_roman = '' for i in roman.keys(): num_to_roman += roman[i]*(decimal_num/...
normal
{ "blob_id": "7025cc896035c59e0bbb7943493b6ca24fd9e6ca", "index": 9429, "step-1": "<mask token>\n\n\ndef convert(decimal_num):\n roman = {(1000): 'M', (900): 'CM', (500): 'D', (400): 'CD', (100): 'C',\n (90): 'XC', (50): 'L', (40): 'XL', (10): 'X', (9): 'IX', (5): 'V',\n (4): 'IV', (1): 'I'}\n ...
[ 2, 3, 4, 5, 6 ]
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # SPDX-License-Identifier: MIT-0 # # This code is sample only. Not for use in production. # # Author: Babu Srinivasan # Contact: babusri@amazon.com, babu.b.srinivasan@gmail.com # # Spark Streaming ETL script # Input: # 1/ Kinesis Data Strea...
normal
{ "blob_id": "fcccbc8d582b709aa27500ef28d86103e98eee4c", "index": 7980, "step-1": "<mask token>\n\n\ndef populateTimeInterval(rec):\n out_ts = (rec['event_time'] - TEMP_TS) // DELTA_MINS * DELTA_MINS + TEMP_TS\n rec['intvl_date'] = datetime.datetime.strftime(out_ts, '%Y-%m-%d')\n rec['intvl_hhmm'] = date...
[ 2, 3, 4, 5, 6 ]
#import cvxopt from cvxopt import matrix, spmatrix, solvers #import scipy from scipy.special import expit import numpy as np import sys import pandas as pd import time class KernelNC(): """ distance based classifier for spectrum kernels """ def __init__(self, classes): self.classes = class...
normal
{ "blob_id": "6f35c29f6f2dcc6c1dae3e9c1ddf595225748041", "index": 3018, "step-1": "<mask token>\n\n\nclass KernelNC:\n <mask token>\n\n def __init__(self, classes):\n self.classes = classes\n\n def compute_dist(self, X, Y):\n K_x = np.dot(X, X.T).toarray()\n K_y = np.dot(Y, Y.T).toar...
[ 16, 17, 19, 20, 21 ]
# Copyright (c) "Neo4j" # Neo4j Sweden AB [https://neo4j.com] # # This file is part of Neo4j. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2...
normal
{ "blob_id": "5b33615e1890631bac68801310e4b606ac41cb13", "index": 1340, "step-1": "<mask token>\n\n\nclass TestTimeDehydration(_TestTemporalDehydrationV1):\n\n @pytest.fixture\n def hydration_handler(self):\n return HydrationHandler()\n <mask token>\n <mask token>\n\n def test_pandas_date_ti...
[ 6, 7, 8, 11, 13 ]
def check_bit4(input): mas=0b1000 desired=input & mas if desired>0: return "om" else : return "off"
normal
{ "blob_id": "29dc940292a6805aabfa5bed22bb75d31140c83f", "index": 3257, "step-1": "<mask token>\n", "step-2": "def check_bit4(input):\n mas = 8\n desired = input & mas\n if desired > 0:\n return 'om'\n else:\n return 'off'\n", "step-3": "def check_bit4(input):\n\tmas=0b1000\n\tdesire...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- """ 项目:爬取思否网站首页推荐文章 作者:cho 时间:2019.9.23 """ import json import parsel import scrapy from scrapy import Request from SF.items import SfItem class SfCrawlSpider(scrapy.Spider): name = 'sf_crawl' allowed_domains = ['segmentfault.com'] header = { 'user-agent': 'Mozilla/5.0 (W...
normal
{ "blob_id": "7ed6d475bfe36fdd0b6cd2f0902a0bccb22f7f60", "index": 6082, "step-1": "<mask token>\n\n\nclass SfCrawlSpider(scrapy.Spider):\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 SfCrawlSpider(scrapy.Spider)...
[ 1, 4, 5, 6, 7 ]
import re from typing import Any, Dict, List import aiosqlite from migri.elements import Query from migri.interfaces import ConnectionBackend, TransactionBackend class SQLiteConnection(ConnectionBackend): _dialect = "sqlite" @staticmethod def _compile(query: Query) -> dict: q = query.statement ...
normal
{ "blob_id": "191a57d3f13fcbe217ff6d0bd92dea163d5fb3cf", "index": 4822, "step-1": "<mask token>\n\n\nclass SQLiteConnection(ConnectionBackend):\n <mask token>\n <mask token>\n\n async def connect(self):\n self.db = await aiosqlite.connect(self.db_name)\n self.db.row_factory = aiosqlite.Row\...
[ 3, 4, 5, 6, 7 ]
import pygame import random from lb_juego import* #Dimensiones de la pantalla ALTO=400 ANCHO=600 #lista de colores basicos ROJO=(255,0,0) SALMON=(240,99,99) BLANCO=(255,255,255) NEGRO=(0,0,0) AZUL=(59,131,189) VERDE=(0,255,0) if __name__=='__main__': #Inicializacion de la aplicacion en pygame pygame.init() ...
normal
{ "blob_id": "85fc2fc0a404c20b1f0806412424192ea4a50a9b", "index": 7085, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n pygame.init()\n fuente = pygame.font.Font(None, 36)\n pantalla = pygame.display.set_mode([ANCHO, ALTO])\n pantalla.fill(BLANCO)\n General = pyg...
[ 0, 1, 2, 3, 4 ]
def readint(): return int(raw_input()) T = readint() for t in xrange(T): N = int(raw_input()) res = 0 sum = 0 min = 1000000 for i in raw_input().split(): r = int(i) res ^= r sum += r if min > r: min = r if res == 0: sum -= min print "Case #%d: %s" % (t + 1, sum) else: print "Case ...
normal
{ "blob_id": "81a1fbd13b06e4470bfbaa0d1716d5301e1a4b36", "index": 1035, "step-1": "def readint(): return int(raw_input())\r\n\r\nT = readint()\r\nfor t in xrange(T):\r\n\tN = int(raw_input())\r\n\tres = 0\r\n\tsum = 0\r\n\tmin = 1000000\r\n\tfor i in raw_input().split():\r\n\t\tr = int(i)\r\n\t\tres ^= r\r\n\t\ts...
[ 0 ]
#manual forward propagation #based on a course I got from Datacamp.com 'Deep Learning in Python' #python3 ~/Documents/pyfiles/dl/forward.py #imports import numpy as np #we are going to simulate a neural network forward propagation algorithm #see the picture forwardPropagation.png for more info #the basics are it mov...
normal
{ "blob_id": "6a09311b5b3b876fd94ed0a9cce30e070528f22c", "index": 2993, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(weights)\n<mask token>\nprint(hidden_layer_vals)\n<mask token>\nprint(output_val)\n<mask token>\n", "step-3": "<mask token>\ninput_data = np.array([2, 3])\nweights = {'node_0': np...
[ 0, 1, 2, 3, 4 ]
# -*- coding:utf-8 -*- # Author: 李泽军 # Date: 2020/1/27 3:31 PM # Project: flask-demo from flask import abort from flask_login import current_user from functools import wraps from simpledu.modes import User def role_required(role): ''' 带参数的装饰器,可以用它来保护一个路由处理函数智能被特定的用户访问 :param role: :return: '''...
normal
{ "blob_id": "b3f6d255830bdb2b0afc99aab6e3715616ac4dec", "index": 4298, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef role_required(role):\n \"\"\"\n 带参数的装饰器,可以用它来保护一个路由处理函数智能被特定的用户访问\n :param role:\n :return:\n \"\"\"\n\n def decorator(func):\n\n @wraps(func)\n de...
[ 0, 1, 2, 3, 4 ]
# 1.Create a list of 10 elements of four different data types like int, string, complex and float. i=[1,2,3,4,5,6,7,8,9,10] f=[10.5,12.2,13.7,14.9,14.9,18.8,19.7,23.6,90.9,25.7] s=['Arpi','world','Hello','Python','Consultadd','job','c++','Concepts','interesting'] c=[1+2j,2+3j,4+5j,5+6j,56+7j,8+9j,7+8j,3+6j,7+9j] print...
normal
{ "blob_id": "87d1c28819d187944a3cf99b35b1d41eab11b139", "index": 6652, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(c)\n", "step-3": "i = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nf = [10.5, 12.2, 13.7, 14.9, 14.9, 18.8, 19.7, 23.6, 90.9, 25.7]\ns = ['Arpi', 'world', 'Hello', 'Python', 'Consultadd', 'jo...
[ 0, 1, 2, 3 ]
''' Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. Your task is to write a function that takes a string and return a new string with all vowels removed. For example, the string "This website is for...
normal
{ "blob_id": "4dea0967a0ee3e9eb3b46145739dfeb233f3a120", "index": 5307, "step-1": "<mask token>\n\n\ndef disemvowel(s):\n return s.translate(None, 'aeiouAEIOU')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef disemvowel(string):\n returnString = ''\n vowels = ['a', 'e', 'i', 'o', 'u']\n upper...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/python import os import sys import csv import json from time import sleep from datetime import datetime ShowProgress = False ConvertTime = False def print_welcome(): print(""" [*******************************************************************************************************] ...
normal
{ "blob_id": "dace25428f48da633ee571b51565d15650782649", "index": 1237, "step-1": "#!/usr/bin/python\nimport os\nimport sys\nimport csv\nimport json\nfrom time import sleep\nfrom datetime import datetime\n\nShowProgress = False\nConvertTime = False\n\n\ndef print_welcome():\n print(\"\"\"\n[*******************...
[ 0 ]
""" Python wrapper that connects CPython interpreter to the numba dictobject. """ from collections import MutableMapping from numba.types import DictType, TypeRef from numba import njit, dictobject, types, cgutils from numba.extending import ( overload_method, box, unbox, NativeValue ) @njit def _mak...
normal
{ "blob_id": "ad44e9411ba6a07c54bb55b0d8af9d0c16c6b71b", "index": 5173, "step-1": "<mask token>\n\n\ndef _from_meminfo_ptr(ptr, dicttype):\n d = TypedDict(meminfo=ptr, dcttype=dicttype)\n return d\n\n\nclass TypedDict(MutableMapping):\n \"\"\"A typed-dictionary usable in Numba compiled functions.\n\n ...
[ 19, 24, 28, 29, 33 ]
#!/bin/env python3 """ A tool for painting and saving Game Boy tiles. Usage: `python3 gb-tile-painter.py` Please see: README.md. """ from sys import argv, exit # If we got an argument and it is --help or -h if len(argv) == 2 and (argv[1] == "--help" or argv[1] == "-h"): print(__doc__) # Print the docstring ...
normal
{ "blob_id": "c153c7a3a11a09ed645540632daec42e8905432a", "index": 4165, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(argv) == 2 and (argv[1] == '--help' or argv[1] == '-h'):\n print(__doc__)\n exit(0)\n<mask token>\nif __name__ == '__main__':\n window = MainWindow()\n window.mainloop(...
[ 0, 1, 2, 3 ]
import numpy as np import faiss from util import vecs_io, vecs_util from time import time import os ''' 提取vecs, 输出numpy文件 ''' def vecs2numpy(fname, new_file_name, file_type, file_len=None): if file_type == 'bvecs': vectors, dim = vecs_io.bvecs_read_mmap(fname) elif file_type == 'ivecs':...
normal
{ "blob_id": "5f84c8654c976bca2fa33e8f9ba5e28e3249253d", "index": 7312, "step-1": "<mask token>\n\n\ndef vecs2numpy(fname, new_file_name, file_type, file_len=None):\n if file_type == 'bvecs':\n vectors, dim = vecs_io.bvecs_read_mmap(fname)\n elif file_type == 'ivecs':\n vectors, dim = vecs_io....
[ 1, 2, 3, 4, 5 ]
import sqlite3 if __name__ == '__main__': conn = sqlite3.connect('donations.sqlite') c = conn.cursor() query = """DROP TABLE IF EXISTS factions;""" c.execute(query) query = """DROP TABLE IF EXISTS members;""" c.execute(query) query = """DROP TABLE IF EXISTS bank;""" c.execute(query) ...
normal
{ "blob_id": "b6b8dfaa9644fa4f4c250358b89f4a30c26c317f", "index": 4788, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n conn = sqlite3.connect('donations.sqlite')\n c = conn.cursor()\n query = 'DROP TABLE IF EXISTS factions;'\n c.execute(query)\n query = 'DROP TA...
[ 0, 1, 2, 3 ]
import numpy as np import pandas as pd import time from sklearn.metrics import log_loss from keras.models import Sequential, Model from keras.layers import Dense, Input from keras.layers import Dropout from keras.layers import Flatten from keras.layers import LSTM from keras.layers.convolutional import Convolution3D f...
normal
{ "blob_id": "e3d886dedaf5b120392d0dc81c4c71398f08f8d6", "index": 8234, "step-1": "<mask token>\n\n\ndef base_model():\n input_shape = 1, HM_SLICES, IMG_PX_SIZE, IMG_PX_SIZE\n inputs = Input(shape=input_shape)\n conv1 = Convolution3D(32, 5, 5, 5, activation='relu')(inputs)\n drop1 = Dropout(0.2)(conv1...
[ 1, 2, 3, 4, 5 ]
import time import os, os.path import random import cv2 import glob import keras import matplotlib import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.cluster import KMeans from sklearn.mixture import GaussianMixture from sklearn.decomposition import PCA import pandas as ...
normal
{ "blob_id": "9c8a213fc8a7397662eebb74d6ee1ad34cb884d9", "index": 1420, "step-1": "<mask token>\n\n\ndef create_train_kmeans(data, number_of_clusters):\n k = KMeans(n_clusters=number_of_clusters, n_jobs=-1, random_state=728)\n start = time.time()\n k.fit(data)\n end = time.time()\n print('Training ...
[ 1, 3, 4, 6, 7 ]
import cv2 import numpy as np from pycocotools.coco import maskUtils # from dataset.augmentors import FlipTransform, joints_to_point8, point8_to_joints, AugImgMetadata # from dataset.base_dataflow import Meta from dataset.augmentors import FlipTransform, joints_to_point8, point8_to_joints, AugImgMetadata from data...
normal
{ "blob_id": "e47223622a2718830d830dbb779800659d659ae3", "index": 8472, "step-1": "<mask token>\n\n\ndef augment(components, augmentors, use_o=False):\n \"\"\"\n Augmenting of images.\n\n :param components: components\n :return: updated components.\n \"\"\"\n img_path = components[0]\n height...
[ 2, 4, 5, 6, 7 ]
import sys from pprint import pprint sys.stdin = open("sample_input.txt", "r") test_case = int(input()) """ for test in range(test_case): nxn_array, palin_len = map(int, input().split()) ## 2차 배열 만들기 => 행스트링 리스트 order_2nd_array = [] for i in range(nxn_array): order_2nd_array.append(input()) ...
normal
{ "blob_id": "15fea8a84accdfc2dac87c111cbe8bfca61fe801", "index": 3482, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.stdin = open('sample_input.txt', 'r')\ntest_case = int(input())\n<mask token>\n", "step-3": "import sys\nfrom pprint import pprint\nsys.stdin = open('sample_input.txt', 'r')\ntest_c...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import math #COMECE SEU CÓDIGO AQUI f = float(input('Digite o valor de f: ')) L = float(input('Digite o valor de L: ')) Q = float(input('Digite o valor de Q: ')) DeltaH = float(input('Digite o valor de DeltaH: ')) v = float(input('Digite o valor de v: ')) g = 9.81 e = 0.000002 #PROCESSAMENTO D =...
normal
{ "blob_id": "b6183daa943cc63fd2959e3e54fc1e6af5d761de", "index": 202, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('valor de D: %.4f' % D)\nprint('valor de Rey: %.4f' % Rey)\nprint('valor de k: %.4f' % k)\n", "step-3": "<mask token>\nf = float(input('Digite o valor de f: '))\nL = float(input('D...
[ 0, 1, 2, 3, 4 ]
#coding=utf-8 from selenium import webdriver from selenium.webdriver import ActionChains # 常用鼠标操作 driver = webdriver.Chrome() driver.get('https://www.baidu.com') driver.maximize_window() element = driver.find_element_by_link_text(u"新闻") #˫ 双击 ‘新闻’ 这个超链接 ActionChains(driver).double_click(element).perform() import time ...
normal
{ "blob_id": "e3f180d4309ade39ac42a895f7f73469fd20724f", "index": 4538, "step-1": "<mask token>\n", "step-2": "<mask token>\ndriver.get('https://www.baidu.com')\ndriver.maximize_window()\n<mask token>\nActionChains(driver).double_click(element).perform()\n<mask token>\ntime.sleep(2)\ndriver.quit()\n<mask token>...
[ 0, 1, 2, 3, 4 ]
import os, time def counter(count): # run in new process for i in range(count): time.sleep(1) # simulate real work print('[%s] => %s' % (os.getpid(), i)) import pdb;pdb.set_trace() for i in range(5): pid= os.fork() if pid !...
normal
{ "blob_id": "fd564d09d7320fd444ed6eec7e51afa4d065ec4d", "index": 6945, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef counter(count):\n for i in range(count):\n time.sleep(1)\n print('[%s] => %s' % (os.getpid(), i))\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef counter...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (c) 2010-2014 Elico Corp. All Rights Reserved. # Alex Duan <alex.duan@elico-corp.com> # # This program is free software: you can redistribute it and...
normal
{ "blob_id": "19d86c64876575ed9b3f5e33dd44e7633c96e696", "index": 2401, "step-1": "<mask token>\n\n\nclass product_product(orm.Model):\n <mask token>\n <mask token>\n <mask token>\n\n def _get_sale_quotation_qty(self, cr, uid, product_id, context=None):\n \"\"\"get all qty of the product in all...
[ 2, 6, 8, 9, 10 ]
'Attempts to use <http://countergram.com/software/pytidylib>.' try: import tidylib def tidy(html): html, errors = tidylib.tidy_document(html, options={'force-output': True, 'output-xhtml': True, 'tidy-mark': False}) return html except ImportError: def tidy(html): return html
normal
{ "blob_id": "33ec822f6149a57244edf6d8d99a5b3726600c2e", "index": 3236, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n import tidylib\n\n def tidy(html):\n html, errors = tidylib.tidy_document(html, options={'force-output':\n True, 'output-xhtml': True, 'tidy-mark': False})\...
[ 0, 1, 2 ]
from tkinter import * import tkinter.messagebox import apikey import tinify class Setting_GUI(Toplevel): def __init__(self,parent): super().__init__() self.parent = parent key = "Input your key here" self.keystringvar = StringVar() self.wm_title("Settings - TingImage") ...
normal
{ "blob_id": "9340c9055a7e0d74d232d878b43d91a3e6cd32e5", "index": 5785, "step-1": "<mask token>\n\n\nclass Setting_GUI(Toplevel):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Setting_GUI(Toplevel):\n\n def __init__(self, parent):\n super().__init__()\n self.parent ...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # # ConVirt - Copyright (c) 2008 Convirture Corp. # ====== # # ConVirt is a Virtualization management tool with a graphical user # interface that allows for performing the standard set of VM operations # (start, stop, pause, kill, shutdown, reboot, snapshot, etc...). It # also attempts to s...
normal
{ "blob_id": "3078a0c7e2c711da88846ca3401c7924b1790dbc", "index": 1251, "step-1": "#!/usr/bin/env python\n#\n# ConVirt - Copyright (c) 2008 Convirture Corp.\n# ======\n#\n# ConVirt is a Virtualization management tool with a graphical user\n# interface that allows for performing the standard set of VM opera...
[ 0 ]
""" Python 3.3 introduces the new "yield from" statement to provide straightforward way for a generator to call out to other generators """ def gen1(): yield 'foo' yield 'bar' def gen2(): yield 'spam' yield 'eggs' """ For python versions < 3.3 """ def full_gen(): for word in gen1(): yiel...
normal
{ "blob_id": "c1e649b73c207ea08235d295c28daad8c91398a7", "index": 1440, "step-1": "\"\"\"\nPython 3.3 introduces the new \"yield from\" statement to provide straightforward way for\na generator to call out to other generators\n\"\"\"\n\ndef gen1():\n yield 'foo'\n yield 'bar'\n\ndef gen2():\n yield 'spam...
[ 0 ]
import numpy as np # UM TRABALHO FEITO PELA GRANDE DUPLA PEQUENA Mag e Rud def main(): a = int(input("Informe a sua opção (Aleatório = 0, Você escolhe = outro numero): ")) if(a != 0): linhas = int(input("Informe o número de linhas da matriz: ")) colunas = int(input("Informe o número de colunas...
normal
{ "blob_id": "c80ecb97c8863b724169715b766024ce824b9225", "index": 5572, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n a = int(input(\n 'Informe a sua opção (Aleatório = 0, Você escolhe = outro numero): '))\n if a != 0:\n linhas = int(input('Informe o número de linhas...
[ 0, 1, 2, 3, 4 ]
import sys from PyQt4 import QtGui,QtCore class Button(QtGui.QPushButton): def __init__(self,*__args): super().__init__(*__args) self.setAcceptDrops(True) # 设置可以接受拖入事件 def dragEnterEvent(self, e): "设置接受的类型" #判断拖动的数据类型是否是:text/plain # 这两个一组表示一个类型 #查询方法是:e.mimeData().form...
normal
{ "blob_id": "e4b0dc2e3d9310bbe462e746e21080d309dfed84", "index": 9640, "step-1": "<mask token>\n\n\nclass Button(QtGui.QPushButton):\n\n def __init__(self, *__args):\n super().__init__(*__args)\n self.setAcceptDrops(True)\n\n def dragEnterEvent(self, e):\n \"\"\"设置接受的类型\"\"\"\n ...
[ 5, 6, 7, 8, 9 ]
from scrapy import Spider, Request from urllib.parse import quote from Product.items import ProductItem class TaobaoSpider(Spider): name = 'taobao' allowed_domains = ['www.taobao.com'] start_urls = ['http://www.taobao.com/'] def parse(self, response, **kwargs): pass
normal
{ "blob_id": "8f709af924820c77290f97731d9f96258c3db095", "index": 2533, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TaobaoSpider(Spider):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TaobaoSpider(Spider):\n <mask token>\n ...
[ 0, 1, 2, 3, 4 ]
# -*- encoding: utf-8 -*- import requests import time import random STATS = True INFINITE = True VOTING_ENDPOINT = 'http://www.adressa.no/poll/vote.do' # These are the required fields from the voting form payload = { "vote": "svar4", "mentometerId": "10790638", "publicationId": "167", "redirectTo": "...
normal
{ "blob_id": "1e344330b88b336598295e2a7be6a6dc57cb3d59", "index": 8207, "step-1": "# -*- encoding: utf-8 -*-\n\nimport requests\nimport time\nimport random\n\nSTATS = True\nINFINITE = True\nVOTING_ENDPOINT = 'http://www.adressa.no/poll/vote.do'\n\n# These are the required fields from the voting form\npayload = {\...
[ 0 ]
N=int(input("N=")) K=int() K=0 while N>=2: N=N/2 K=K+1 print("K=",K)
normal
{ "blob_id": "7f4c6e4a5627b44b9a700d2de4f9caca0ae8b17c", "index": 2808, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile N >= 2:\n N = N / 2\n K = K + 1\nprint('K=', K)\n", "step-3": "N = int(input('N='))\nK = int()\nK = 0\nwhile N >= 2:\n N = N / 2\n K = K + 1\nprint('K=', K)\n", "ste...
[ 0, 1, 2, 3 ]
n = int(input()) b = 0 p = [0,0] flg = True for i in range(n): t,x,y = map(int,input().split()) diff = abs(x - p[0]) + abs(y - p[1]) time = t - b if(diff > time or time%2 != diff %2): flg = False break else: b = t p[0] = x p[1] = y if flg: print("Yes") else: print("No")
normal
{ "blob_id": "8bc465a1b546907d8a9e5eee2cae672befb1ea13", "index": 7808, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(n):\n t, x, y = map(int, input().split())\n diff = abs(x - p[0]) + abs(y - p[1])\n time = t - b\n if diff > time or time % 2 != diff % 2:\n flg = False\n...
[ 0, 1, 2, 3 ]
# https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/ # BruteForce class BruteForceSolution: def smallerNumbersThanCurrent(self, nums): answer = [] for num in nums: counter = 0 for i in range(len(nums)): if n...
normal
{ "blob_id": "58e023c3c453d1e190fdb5bc457358f42d1bd93f", "index": 397, "step-1": "class BruteForceSolution:\n <mask token>\n\n\nclass Solution:\n\n def smallerNumbersThanCurrent(self, nums):\n answer = []\n sortedNums = sorted(nums)\n for num in nums:\n answer.append(sortedNu...
[ 3, 4, 5, 6, 7 ]
import os import numpy as np import nibabel as nib def loop_access(n,m,data,tpl): if n >m: return loop_access(n,m+1,data[tpl[m]],tpl) else: return data[tpl[m]] def loop_rec(n,m,mapCoords,dims,data,tple): if n >= m: for x in range(dims[m]): loop_rec(n,m+1,mapCoords,dims,...
normal
{ "blob_id": "55b4448caa73bcb50a15eb46d07328934fce72c8", "index": 7029, "step-1": "<mask token>\n\n\ndef loop_rec(n, m, mapCoords, dims, data, tple):\n if n >= m:\n for x in range(dims[m]):\n loop_rec(n, m + 1, mapCoords, dims, data, tple + (x,))\n else:\n temp = loop_access(len(dim...
[ 1, 2, 3, 4, 5 ]
import sqlparse f = open("parse.sql") go = open("struct.go", "w+") dictiony = { "uuid": "string", "varchar": "string", "timestamp": "time.Time", "int": "int", "text": "string", "dbname": "IndividualContrAgent", "interface": "IndividualContrAgentI", "ica":"ica" } #package go.write("packa...
normal
{ "blob_id": "e99e558ebf5938a90f00df6593c9f75a18affcb8", "index": 9127, "step-1": "<mask token>\n", "step-2": "<mask token>\ngo.write('package main\\n\\n')\ngo.write('import (\\n ')\ngo.write(\"\"\"\"github.com/jmoiron/sqlx\"\n)\n\n\"\"\")\ngo.write('type {0} struct {1}\\n'.format(dictiony['dbname'], '{'))\n...
[ 0, 1, 2, 3, 4 ]
import httplib import sys http_server = "localhost:8000" connection = httplib.HTTPConnection(http_server) # Open test input. test_file_path = "test_input" test_f = open(test_file_path) inputs = test_f.readlines() inputs = [x.strip() for x in inputs] test_f.close() # Open expected input. expected_file_path = "expect...
normal
{ "blob_id": "cd9b04a93d85ba0ee2a38b534386f9aec0ef6895", "index": 5165, "step-1": "<mask token>\n", "step-2": "<mask token>\ntest_f.close()\n<mask token>\nexpected_f.close()\nassert len(inputs) == len(expecteds)\nfor i in range(len(inputs)):\n connection.request('GET', '<start>%s<end>' % inputs[i])\n resp...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.2.4 on 2021-07-18 02:05 from django.db import migrations, models import django.db.models.deletion import uuid class Migration(migrations.Migration): initial = True dependencies = [ ('tracker', '0003_auto_20210626_0735'), ] operations = [ migrations.CreateMod...
normal
{ "blob_id": "ead843f1edcfe798613effb049e3ca79dcd03b71", "index": 7919, "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 ]
"""Unit test for int install """ import math import pytest ROUND_OFF_ERROR = 0.001 def int_installs(x): try: return int(x.replace(',', '').replace('+', '')) except: raise ValueError("Cannot transform to int.") def test_int_install_1(): """Unit test to showcase functionality of int...
normal
{ "blob_id": "b874bfe9590a3eaff4298d6f9cc72be92000dc30", "index": 1108, "step-1": "<mask token>\n\n\ndef int_installs(x):\n try:\n return int(x.replace(',', '').replace('+', ''))\n except:\n raise ValueError('Cannot transform to int.')\n\n\ndef test_int_install_1():\n \"\"\"Unit test to sho...
[ 2, 4, 5, 6, 7 ]
from django.contrib import admin from employees.models import Leave,EmployeeProfile admin.site.register(Leave) admin.site.register(EmployeeProfile) # Register your models here.
normal
{ "blob_id": "77ea670b537e9ff7082aeb9ed54b011fa8e3a035", "index": 6328, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.site.register(Leave)\nadmin.site.register(EmployeeProfile)\n", "step-3": "from django.contrib import admin\nfrom employees.models import Leave, EmployeeProfile\nadmin.site.registe...
[ 0, 1, 2, 3 ]
import torch import torch.nn as nn import torch.nn.functional as F import torch.nn.init as init import numpy as np import time import os import csv import matplotlib.pyplot as plt from GELu import GELu from My_Dataset import MyDataset from pytorchtools import EarlyStopping from LSTM import LSTM ''' Wr...
normal
{ "blob_id": "80531ac3cc247d48ee36bff581925b8f29f9e235", "index": 8590, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef train_model(model, DEVICE, patience, n_epochs, csv_record=False):\n train_losses = []\n valid_losses = []\n avg_train_losses = []\n avg_valid_losses = []\n early_st...
[ 0, 1, 2, 3, 4 ]
import basevcstest class TestVCSBoxfill(basevcstest.VCSBaseTest): def testRobinsonBoxfill(self): # This tests if extending the longitude to more than 360 decrees is handled correctly by # proj4. See https://github.com/UV-CDAT/uvcdat/issues/1728 for more # information. clt3 = self.c...
normal
{ "blob_id": "c1475209d9c9a98d72d7f703e0516aceaeb13163", "index": 6820, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestVCSBoxfill(basevcstest.VCSBaseTest):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TestVCSBoxfill(basevcstest.VCSBaseTest):\n\n def testRobinsonBoxfill(self)...
[ 0, 1, 2, 3, 4 ]
import os import random import cv2 import tensorflow as tf import tensorflow.contrib.slim as slim import tensorflow.contrib.slim.nets as nets from skimage.transform import resize import PIL import numpy as np import json # os.environ["CUDA_VISIBLE_DEVICES"] = "1" import matplotlib.pyplot as plt # plt.switch_backend('...
normal
{ "blob_id": "31d87b11f6a1f6304a2fef6dd1cd1c0ca292dfe8", "index": 3491, "step-1": "<mask token>\n\n\ndef inception(image, reuse):\n preprocessed = tf.multiply(tf.subtract(tf.expand_dims(image, 0), 0.5), 2.0)\n arg_scope = nets.inception.inception_v3_arg_scope(weight_decay=0.0)\n with slim.arg_scope(arg_s...
[ 5, 6, 7, 9, 10 ]
import sys sys.stdin = open("sample_input_17.txt","r") T = int(input()) def code(N): # 암호코드가 있는 열의 위치를 찾음 code = [] for i in range(N-4): for j in range(49,53): if S[i][j] == "1" : code = S[i] return code def code_s(code): # 암호코드의 행 위치를 찾아 슬라이싱 for x in ...
normal
{ "blob_id": "b739c1de6c008158ee3806bed9fa2865eb484b4f", "index": 5596, "step-1": "<mask token>\n\n\ndef code(N):\n code = []\n for i in range(N - 4):\n for j in range(49, 53):\n if S[i][j] == '1':\n code = S[i]\n return code\n\n\ndef code_s(code):\n for x ...
[ 3, 4, 5, 6, 7 ]
from flask import Flask,render_template, redirect, url_for,request, jsonify, abort,request from flask_sqlalchemy import SQLAlchemy from src.flaskbasic import * from src.flaskbasic.form import StudentForm from src.flaskbasic.models import Student import sys import logging # logging.basicConfig(filename='app.log...
normal
{ "blob_id": "18f9e55b62b30ce8c9d4a57cd9c159543a738770", "index": 4709, "step-1": "<mask token>\n\n\n@application.route('/results', methods=['GET', 'POST'])\ndef get_results():\n _logger_getting.warning('retrieving all student results')\n data = Student.query.all()\n _logger_getting.warning('the students...
[ 4, 6, 7, 8, 9 ]
def spam(divide_by): return 42 / divide_by try: print(spam(2)) print(spam(12)) print(spam(0)) print(spam(1)) print(spam("dog")) except Exception: print("Error: Invalid argument.")
normal
{ "blob_id": "357ee02060cbfa391920b3d45dfbe16e679a6c8d", "index": 7346, "step-1": "<mask token>\n", "step-2": "def spam(divide_by):\n return 42 / divide_by\n\n\n<mask token>\n", "step-3": "def spam(divide_by):\n return 42 / divide_by\n\n\ntry:\n print(spam(2))\n print(spam(12))\n print(spam(0))...
[ 0, 1, 2, 3 ]
from common.get_keyword import GetKeyword from common.operation_Excel import OperationExcel from common.op_database import OpDatabase from interface.login import Login from interface.address import Address import unittest import ddt # 测试数据 op_excel = OperationExcel() add_file = r'D:\pyCharm\Demo\pycode\Requests\201911...
normal
{ "blob_id": "0f0b3eea9dc397d32e81749304041abaf6651e94", "index": 1873, "step-1": "<mask token>\n\n\n@ddt.ddt\nclass TestAddress(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def test_02_check_address(self):\n url = 'http://ecshop.itsoso.cn/ECMobile/?url...
[ 2, 8, 9, 10, 12 ]
from django.apps import AppConfig class FitnerappConfig(AppConfig): name = 'fitnerapp'
normal
{ "blob_id": "6546d04d3755d62d1a8756bdec1a10f6f018dcea", "index": 5638, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass FitnerappConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass FitnerappConfig(AppConfig):\n name = 'fitnerapp'\n", "step-4": "from django.apps impo...
[ 0, 1, 2, 3 ]
from share_settings import Settings import urllib.request,json import pprint as p s = Settings() prefix = "http://finance.google.com/finance?client=ig&output=json&q=" def get(symbol,exchange): url = prefix+"%s:%s"%(exchange,symbol) u = urllib.request.urlopen(url) #translates url to string c = u.re...
normal
{ "blob_id": "7247ef463998f6738c21ad8efa988a32f7fb99c0", "index": 4760, "step-1": "<mask token>\n\n\ndef get_lp(s):\n \"\"\"gets latest prices from google\"\"\"\n sl = []\n for stock in s.symbols:\n quote = get(stock, 'LON')\n x = quote.replace(',', '')\n x = float(x)\n sl.app...
[ 1, 2, 3, 4, 5 ]
# data={ # "name":"Alby", # "age":23 # } # print (data['age']) # def foo(): # print("Hellow world") # return 1 # print (foo()) a="aa" def add(): print(a) add()
normal
{ "blob_id": "97857c1c5468a96187d44abc23ffaaf2a7ead1a6", "index": 1869, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef add():\n print(a)\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef add():\n print(a)\n\n\nadd()\n", "step-4": "a = 'aa'\n\n\ndef add():\n print(a)\n\n\nadd()\n"...
[ 0, 1, 2, 3, 4 ]
import io import os from setuptools import setup setup(name='testcov-plugin', version='1.0', packages=['testcov'], namespace_packages=['testcov'], entry_points={ 'plugins': ['testp = testcov.plugin:testp'], }, description="Test for coverage bug")
normal
{ "blob_id": "88f5aa56eca6b61ba2b428bff0efdf4ec7f5f5d9", "index": 1913, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='testcov-plugin', version='1.0', packages=['testcov'],\n namespace_packages=['testcov'], entry_points={'plugins': [\n 'testp = testcov.plugin:testp']}, description='Test ...
[ 0, 1, 2, 3 ]
#for declaring the variables used in program img_rows=200 img_cols=200 img_channels=1 nb_classes=3 nb_test_images=1
normal
{ "blob_id": "c41388043295280f9354e661a8d38ae46cae2d65", "index": 9590, "step-1": "<mask token>\n", "step-2": "img_rows = 200\nimg_cols = 200\nimg_channels = 1\nnb_classes = 3\nnb_test_images = 1\n", "step-3": "#for declaring the variables used in program\nimg_rows=200\nimg_cols=200\nimg_channels=1\nnb_classe...
[ 0, 1, 2 ]
# Generated by Django 4.1.9 on 2023-06-29 16:11 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("search", "0003_auto_20230209_1441"), ] operations = [ migrations.CreateModel( name="SearchSettings", fields=[ ...
normal
{ "blob_id": "45969b346d6d5cbdef2f5d2f74270cf12024072d", "index": 3, "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 = [('search', '0003...
[ 0, 1, 2, 3, 4 ]
# -*- coding:utf-8 -*- __author__ = 'leandro' from datetime import * from PyQt4 import QtGui, QtCore from baseDatos.ventas.venta import NotaCredito from gui import CRUDWidget,MdiWidget from ventanas import Ui_vtnDevolucionDeCliente, Ui_vtnReintegroCliente, Ui_vtnVentaContado from baseDatos.obraSocial import ObraSoc...
normal
{ "blob_id": "59233cd45000cd6d6ad0876eb3812599392d7c05", "index": 9357, "step-1": "# -*- coding:utf-8 -*-\n__author__ = 'leandro'\n\n\nfrom datetime import *\n\nfrom PyQt4 import QtGui, QtCore\n\nfrom baseDatos.ventas.venta import NotaCredito\nfrom gui import CRUDWidget,MdiWidget\nfrom ventanas import Ui_vtnDevol...
[ 0 ]
import pickle import time start = time.time() f = open('my_classifier.pickle', 'rb') cl = pickle.load(f) f.close() print(cl.classify("Where to travel in bangalore ?")) print(cl.classify("Name a golf course in Myrtle beach .")) print(cl.classify("What body of water does the Danube River flow into ?")) #print("Accuracy...
normal
{ "blob_id": "82a3fca0261b4bde43f7bf258bb22e5b2ea8c28d", "index": 5370, "step-1": "<mask token>\n", "step-2": "<mask token>\nf.close()\nprint(cl.classify('Where to travel in bangalore ?'))\nprint(cl.classify('Name a golf course in Myrtle beach .'))\nprint(cl.classify('What body of water does the Danube River fl...
[ 0, 1, 2, 3, 4 ]
import os import re import sys import traceback import readline from typing import NamedTuple, List from PyInquirer import prompt from pygments import highlight from pygments.formatters.terminal import TerminalFormatter from pygments.lexers.python import PythonLexer import argparse parser = argparse.ArgumentParser(d...
normal
{ "blob_id": "bec3d8546cd7d27f7da48f5658480cf17c36a255", "index": 9462, "step-1": "<mask token>\n\n\nclass Grade(NamedTuple):\n score: int\n message: str\n comments: List[Comment]\n\n\ndef clear():\n os.system('cls' if os.name == 'nt' else 'clear')\n\n\n<mask token>\n\n\ndef complete(comment):\n if...
[ 9, 12, 13, 14, 17 ]
import hashlib md5 = hashlib.md5(b'Najmul') print(md5.hexdigest()) sha1 = hashlib.sha1(b'Najmul') print(sha1.hexdigest()) sha224 = hashlib.sha224(b'Najmul') print(sha224.hexdigest()) sha256 = hashlib.sha256(b'Najmul') print(sha256.hexdigest()) sha384 = hashlib.sha384(b'Najmul') print(sha384.hexdigest()) sha512 = hashli...
normal
{ "blob_id": "ab4c668c8a167f8c387199b7aa49aa742d563250", "index": 1698, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(md5.hexdigest())\n<mask token>\nprint(sha1.hexdigest())\n<mask token>\nprint(sha224.hexdigest())\n<mask token>\nprint(sha256.hexdigest())\n<mask token>\nprint(sha384.hexdigest())\n<...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @author: Allen(Zifeng) An @course: @contact: anz8@mcmaster.ca @file: 17. Letter Combinations of a Phone Number.py @time: 2020/2/2 21:18 ''' from typing import List class Solution: def letterCombinations(self, digits: str) -> List[str]: d={2:'abc', ...
normal
{ "blob_id": "de925b8f6bd31bfdfd1f04628659847b0761899d", "index": 340, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n\n def letterCombinations(self, digits: str) ->List[str]:\n d = {(2): 'abc', (3): 'def', (4): 'ghi',...
[ 1, 2, 3, 4, 5 ]
import graphene from django.core.exceptions import ValidationError from ....app import models from ....app.error_codes import AppErrorCode from ....permission.enums import AppPermission, get_permissions from ....webhook.event_types import WebhookEventAsyncType from ...account.utils import can_manage_app from ...core.m...
normal
{ "blob_id": "972a063bab35926472be592e6a17d450034fbf37", "index": 4745, "step-1": "<mask token>\n\n\nclass AppUpdate(ModelMutation):\n\n\n class Arguments:\n id = graphene.ID(description='ID of an app to update.', required=True)\n input = AppInput(required=True, description=\n 'Fields ...
[ 1, 2, 3, 4, 5 ]
"""empty message Revision ID: 0bb5933fe69f Revises: 09c6fdb3cf81 Create Date: 2021-03-11 16:48:06.771046 """ from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision = '0bb5933fe69f' down_revision = '09c6fdb3cf81' branch_labels = None depends_on = None def upgrade(): # ...
normal
{ "blob_id": "f727c0551f20fb0dc72b4d81b7b3ed8ce9b1b6f4", "index": 2072, "step-1": "<mask token>\n\n\ndef downgrade():\n op.drop_constraint(None, 'user', type_='unique')\n op.drop_constraint(None, 'user', type_='unique')\n op.drop_column('user', 'money')\n", "step-2": "<mask token>\n\n\ndef upgrade():\n...
[ 1, 2, 3, 4, 5 ]
import os from flask import Flask,render_template,request,redirect,url_for from sqlalchemy import create_engine from sqlalchemy.orm import scoped_session,sessionmaker app = Flask(__name__) engine = create_engine("postgres://lkghylsqhggivp:d827f6dc5637928e95e060761de590b7d9514e9463c5241ed3d652d777a4a3a9@ec2-5...
normal
{ "blob_id": "af9430caff843242381d7c99d76ff3c964915700", "index": 6753, "step-1": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('a.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef index():\n return render_template('a.html')\n\n\n@app.route('/insert...
[ 1, 2, 3, 4, 5 ]
from __future__ import absolute_import import unittest import yaml import os from bok_choy.web_app_test import WebAppTest from .pages.job_config_history_subpage import JobConfigHistorySubPage class TestJobConfigHistory(WebAppTest): def setUp(self): super(TestJobConfigHistory, self).setUp() config_...
normal
{ "blob_id": "51bdbec732bebd73a84b52c6d1d39eead047d29e", "index": 5349, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestJobConfigHistory(WebAppTest):\n\n def setUp(self):\n super(TestJobConfigHistory, self).setUp()\n config_path = os.getenv('CONFIG_PATH')\n try:\n ...
[ 0, 2, 3, 4, 5 ]
# pyOCD debugger # Copyright (c) 2006-2013,2018 Arm Limited # SPDX-License-Identifier: Apache-2.0 # # 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/LICENS...
normal
{ "blob_id": "58aa72588357b18ab42391dfffbf2a1b66589edd", "index": 552, "step-1": "<mask token>\n\n\nclass KV11Z7(Kinetis):\n <mask token>\n\n def __init__(self, session):\n super(KV11Z7, self).__init__(session, self.MEMORY_MAP)\n self._svd_location = SVDFile.from_builtin('MKV11Z7.svd')\n", "...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/python # -*- coding: UTF-8 -*- def parse(node, array): string = '' string += "\t%s = ScrollView:create();\n" % node if (array.get('IsBounceEnabled') != None and array['IsBounceEnabled']): string += "\t%s:setBounceEnabled(true);\n" % node if (array.get('InnerNodeSize') != None): ...
normal
{ "blob_id": "97b94f3388a6e2473d43e3c4c4e281a86a031dbb", "index": 9288, "step-1": "<mask token>\n", "step-2": "def parse(node, array):\n string = ''\n string += '\\t%s = ScrollView:create();\\n' % node\n if array.get('IsBounceEnabled') != None and array['IsBounceEnabled']:\n string += '\\t%s:set...
[ 0, 1, 2 ]
from flask import Blueprint, render_template, flash, redirect, url_for, request, current_app, g, session from flask_login import current_user from app import decorators from app.models import User, Post, Comment, Tag from slugify import slugify from app.main.forms import CommentForm, TagForm, ProfileForm, ContactForm f...
normal
{ "blob_id": "4e66fe0485d987da590d11c848009b2e1665b3dc", "index": 5445, "step-1": "<mask token>\n\n\ndef manage_prev_page():\n global session, request\n if ('profile' not in request.referrer and 'change_password' not in\n request.referrer and 'forgot_password' not in request.referrer and \n 'r...
[ 5, 6, 7, 8, 9 ]
from collections import deque def solution(people, limit): people.sort() cnt = 0 left_idx = 0 right_idx = len(people) - 1 while left_idx <= right_idx: if people[left_idx] + people[right_idx] <= limit: cnt += 1 left_idx += 1 right_idx -= 1 else: ...
normal
{ "blob_id": "b0dbc4e8a2ce41dc9d2040890e3df4d078680fa1", "index": 5444, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef solution(people, limit):\n people.sort()\n cnt = 0\n left_idx = 0\n right_idx = len(people) - 1\n while left_idx <= right_idx:\n if people[left_idx] + people...
[ 0, 1, 2 ]
#!/bin/env python3 import os ##print(os.environ) ##print("**********************************************************************") ##print("**********************************************************************") ##print("**********************************************************************") ##print(str(os.environ.ge...
normal
{ "blob_id": "b49696d6cac5fbf97172aa7cf16903d002262b5c", "index": 1940, "step-1": "<mask token>\n\n\ndef AddOverflow(h):\n nxbins = h.GetXaxis().GetNbins()\n nybins = h.GetYaxis().GetNbins()\n idxx = 0.0\n idxy = nybins + 1\n for ix in range(nxbins):\n idxx = ix + 1\n ovf_bincont = h....
[ 1, 2, 3, 4, 5 ]
# MINISTを読み込んでレイヤーAPIでCNNを構築するファイル import tensorflow as tf import numpy as np import os import tensorflow as tf import glob import numpy as np import config as cf from data_loader import DataLoader from PIL import Image from matplotlib import pylab as plt dl = DataLoader(phase='Train', shuffle=True) X...
normal
{ "blob_id": "a5559ff22776dee133f5398bae573f515efb8484", "index": 3820, "step-1": "<mask token>\n", "step-2": "<mask token>\ndl = DataLoader(phase='Train', shuffle=True)\nX_data, y_data = dl.shuffle_and_get()\nX_data = np.reshape(X_data, [-1, cf.Height, cf.Width])\nconfig = tf.ConfigProto()\nconfig.gpu_options....
[ 0, 1, 2, 3 ]
num=int(input("enter no")) def factorial(no): fact=1 if no <0: print("-ve no factorial not exist") else: for i in range(1,no+1): fact=fact*i return fact print(factorial(num))
normal
{ "blob_id": "2d3ab575b18144f714f06167f54cd069af4e5895", "index": 7506, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef factorial(no):\n fact = 1\n if no < 0:\n print('-ve no factorial not exist')\n else:\n for i in range(1, no + 1):\n fact = fact * i\n retu...
[ 0, 1, 2, 3, 4 ]
#! /usr/bin/env python # # Copyright (c) 2015 Jason Ish # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # 1. Redistributions of source code must retain the above copyright # notice, this li...
normal
{ "blob_id": "41889456fbb56d263e0039716519e8959316b67e", "index": 3473, "step-1": "<mask token>\n\n\ndef render_timestamp(sec, usec):\n tt = time.localtime(sec)\n return '%04d-%02d-%02dT%02d:%02d:%02d.%06d%s' % (tt.tm_year, tt.tm_mon,\n tt.tm_mday, tt.tm_hour, tt.tm_min, tt.tm_sec, usec, get_tzoffset...
[ 12, 15, 16, 17, 19 ]
# -*- coding: utf-8 -*- """ Created on Fri Apr 10 01:03:35 2020 @author: Jordan """ import pandas as pd import numpy as np import matplotlib.pyplot as plt from datetime import date ## from COVID19_Simple import * from COVID19_Diff import calc_diff_country ### Dash Stuff ### import dash import dash_core...
normal
{ "blob_id": "1e02d584cde0cdf251aa36abd27b683219ef87ed", "index": 7539, "step-1": "<mask token>\n\n\n@app.callback(Output(component_id='global-box-1', component_property=\n 'figure'), [Input(component_id='global-dropdown', component_property=\n 'value')])\ndef global_update(select_global):\n if select_gl...
[ 3, 4, 5, 6, 7 ]
from django.db import models # Create your models here. class Covid(models.Model): states= models.CharField(max_length=100, null=True, blank=True) affected = models.IntegerField(null=True) cured = models.IntegerField(null=True) death = models.IntegerField(null=True)
normal
{ "blob_id": "284955a555ce1a727ba5041008cd0bac3c3bed49", "index": 1283, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Covid(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Covid(models.Model):\n states = models.C...
[ 0, 1, 2, 3, 4 ]
import unittest.mock import assist import pytest def test_simple_query(): q = assist.build_query(select='time, value', from_='system_load', where='L2=\'cpuload\' and time > \'2021-06-16 00:00:00\' and time < \'2021-06-17 00:00:00\' and "name" != \'Idle\'', gr...
normal
{ "blob_id": "8aa9ba145b6c7347a7a926d50dca35383ddd52a3", "index": 9217, "step-1": "<mask token>\n\n\ndef test_nested_query_with_datetime():\n inner_q = assist.build_query(select='time, value', from_='system_load',\n where='L2=\\'cpuload\\' and \"name\" != \\'Idle\\'', groupby=('host', 'L3'))\n outer_...
[ 6, 8, 9, 11, 12 ]
import matplotlib.pyplot as plt import numpy as np import pandas as pd from sklearn import linear_model from features import calculateTargets currency = 'EURUSD' interval = '1440' df = pd.read_csv( r'../data/' + currency.upper() + interval + '.csv', names=['date', 'time', 'open', 'high', 'low', 'close', 'volu...
normal
{ "blob_id": "8c0bae9e49c5ea9fbdee7c5c864afff16cc9f8b8", "index": 3757, "step-1": "import matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nfrom sklearn import linear_model\nfrom features import calculateTargets\n\ncurrency = 'EURUSD'\ninterval = '1440'\n\ndf = pd.read_csv(\n r'../data/' + cur...
[ 0 ]
# Default imports from sklearn.feature_selection import SelectFromModel from sklearn.ensemble import RandomForestClassifier import pandas as pd import numpy as np data = pd.read_csv('data/house_prices_multivariate.csv') # Your solution code here def select_from_model(dataframe): X = dataframe.iloc[:, :-1] y...
normal
{ "blob_id": "d6791c8122129a46631582e7d9339ea08bd2e92b", "index": 3183, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef select_from_model(dataframe):\n X = dataframe.iloc[:, :-1]\n y = dataframe.iloc[:, -1]\n np.random.seed(9)\n model = RandomForestClassifier()\n sfm = SelectFromMode...
[ 0, 1, 2, 3, 4 ]
class Solution: def commonFactors(self, a: int, b: int) ->int: gcd = math.gcd(a, b) return sum(a % i == 0 and b % i == 0 for i in range(1, gcd + 1))
normal
{ "blob_id": "ea696329a0cfd558fb592ffaf6339a35e8950a3c", "index": 6721, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n", "step-3": "class Solution:\n\n def commonFactors(self, a: int, b: int) ->int:\n gcd = math.gcd(a, b)\n return sum(a % i == 0 and b % i == 0 for ...
[ 0, 1, 2 ]
from django.contrib.auth.decorators import permission_required from django.db import models from students.models import Student # Create your models here. class Fine(models.Model): amount = models.DecimalField(max_digits=8, decimal_places=2, null=True, default=0) student = models.OneToOneField(Student, on_de...
normal
{ "blob_id": "22b697790516e1160ac501a58ad93ef5b579414a", "index": 7109, "step-1": "<mask token>\n\n\nclass Fine(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n db_table = 'fines'\n verbose_name_plural = 'Fines'\n verbose_name = 'Fi...
[ 1, 2, 3, 4, 5 ]