code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
__author__ = 'GazouillisTeam' import numpy as np import os import sys import time from keras.callbacks import Callback def save_architecture(model, path_out): """ Based on the keras utils 'model.summary()' """ # Redirect the print output the a textfile orig_stdout = sys.stdout # and store the...
normal
{ "blob_id": "f8635c815b375dc77e971d4ea0f86547215ab2f9", "index": 7987, "step-1": "<mask token>\n\n\nclass ModelSaver(Callback):\n \"\"\"\n Keras callback subclass which defines a saving procedure of the model being trained : after each epoch,\n the last model is saved under the name 'after_random.cnn'. ...
[ 6, 7, 8, 10, 13 ]
__all__ = ["loading"] from . import loading
normal
{ "blob_id": "f633496f1a7cd562fd41d697a2e26831ceaef479", "index": 8047, "step-1": "<mask token>\n", "step-2": "__all__ = ['loading']\n<mask token>\n", "step-3": "__all__ = ['loading']\nfrom . import loading\n", "step-4": "__all__ = [\"loading\"]\n\nfrom . import loading\n", "step-5": null, "step-ids": [...
[ 0, 1, 2, 3 ]
import os from pathlib import Path import shutil from ament_index_python.packages import get_package_share_directory, get_package_prefix import launch import launch_ros.actions def generate_launch_description(): cart_sdf = os.path.join(get_package_share_directory('crs_support'), 'sdf', 'cart.sdf') car...
normal
{ "blob_id": "cc74163d5dbcc2b2ca0fe5222692f6f5e45f73fe", "index": 2377, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef generate_launch_description():\n cart_sdf = os.path.join(get_package_share_directory('crs_support'),\n 'sdf', 'cart.sdf')\n cart_spawner = launch_ros.actions.Node(nod...
[ 0, 1, 2 ]
import datetime class Schedule: def __init__(self, start, end, name, other): # Constructor self.start = self.str_convert(start) # Schedule start time (ex. 9:00) self.end = self.str_convert(end) # Schedule end time (ex. 22:00) ...
normal
{ "blob_id": "f56978d5738c2f8cb4ed5ce4f11d3aae6a9689b1", "index": 4604, "step-1": "<mask token>\n\n\nclass Schedule:\n\n def __init__(self, start, end, name, other):\n self.start = self.str_convert(start)\n self.end = self.str_convert(end)\n self.name = name\n self.other = other\n ...
[ 9, 10, 12, 13, 14 ]
#-*- coding: utf-8 -*- def print99(): """ 打印99乘法口诀表 :return: """ for i in range(1,10): for j in range(1, i+1): print('%dX%d=%2s ' %(j,i,i*j)) print('\n') print99()
normal
{ "blob_id": "90f1fd45d58c7e6f275a33cd9c693ff584b2df47", "index": 1396, "step-1": "<mask token>\n", "step-2": "def print99():\n \"\"\"\n 打印99乘法口诀表\n :return:\n \"\"\"\n for i in range(1, 10):\n for j in range(1, i + 1):\n print('%dX%d=%2s ' % (j, i, i * j))\n print('\\n'...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python """ maskAOI.py Dan Fitch 20150618 """ from __future__ import print_function import sys, os, glob, shutil, fnmatch, math, re, numpy, csv from PIL import Image, ImageFile, ImageDraw, ImageColor, ImageOps, ImageStat ImageFile.MAXBLOCK = 1048576 DEBUG = False AOI_DIR='/study/reference/public/IAP...
normal
{ "blob_id": "833053a5a75636267feaad5ddaa21dce1de34038", "index": 5319, "step-1": "<mask token>\n\n\ndef RepresentsInt(s):\n try:\n int(s)\n return True\n except ValueError:\n return False\n\n\n<mask token>\n\n\ndef drawOneEllipse(aoi, img, draw):\n if DEBUG:\n print('Ellipse ...
[ 6, 8, 12, 13, 17 ]
import sys import os sys.path.append(os.pardir) from ch03.softmax import softmax from ch04.cross_entropy_error_batch import cross_entropy_error import numpy as np class SoftmaxWithLossLayer: """ x -> [Softmax] -> y -> [CrossEntropyError with t] -> out In the textbook, this class has `loss` field. """...
normal
{ "blob_id": "8ae64c65d6d5dc9f2a99aeceff31657deff06c15", "index": 5236, "step-1": "<mask token>\n\n\nclass SoftmaxWithLossLayer:\n <mask token>\n\n def __init__(self):\n self.y = None\n self.t = None\n\n def forward(self, x, t):\n \"\"\"\n x: input to softmax\n t: teach...
[ 4, 5, 6, 7, 8 ]
# Counts number of dumbbell curls in the video import cv2 import mediapipe as mp import base import math import numpy as np class PoseEstimator(base.PoseDetector): def __init__(self, mode=False, upperBody = False, smooth=True, detectConf=.5, trackConf=.5, outFile="output.mp4", outWidth=720, outHe...
normal
{ "blob_id": "4a886437727ed6b48206e12b686a59a1d2a1c489", "index": 4948, "step-1": "<mask token>\n\n\nclass PoseEstimator(base.PoseDetector):\n <mask token>\n\n def findAngle(self, img, p1, p2, p3, draw=True):\n x1, y1 = self.lms[p1][1:]\n x2, y2 = self.lms[p2][1:]\n x3, y3 = self.lms[p3...
[ 3, 5, 6, 7, 8 ]
from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression, Lasso, Ridge from sklearn import tree import pickle as pk X = pk.load(file=open('../data/temp/train.pkl', 'rb')) y = pk.load(file=open('../data/temp/label.pkl', 'rb')) X_train, X_test, y_train, y_test = train_test_...
normal
{ "blob_id": "539726df0e631c7a8edabf50fd739ee0497e3e97", "index": 5557, "step-1": "<mask token>\n\n\ndef train_model(model_name):\n if model_name == 'LinearRegression':\n model = LinearRegression()\n model.fit(X_train, y_train)\n score = model.score(X_test, y_test)\n print(score)\n ...
[ 1, 2, 3, 4, 5 ]
s=input("enter a string") u=0 l=0 for i in s: if i.isupper(): u+=1 elif i.islower(): l+=1 print(u,l,end="")
normal
{ "blob_id": "bbb23d606b081d2591699cb6b9336c8766eea5b2", "index": 2436, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in s:\n if i.isupper():\n u += 1\n elif i.islower():\n l += 1\nprint(u, l, end='')\n", "step-3": "s = input('enter a string')\nu = 0\nl = 0\nfor i in s:\n i...
[ 0, 1, 2, 3 ]
import sys import psyco sys.stdin = open("/home/shiva/Learning/1.txt", "r") sys.stdout = open("/home/shiva/Learning/2.txt", "w") def compute(plus,minus,total,inp): if plus == 1 and minus == 0: print(total); return elif (plus == 1 and minus == 1): print("Impossible"); return elif (abs(plus-minus) > total): pl...
normal
{ "blob_id": "d29c8ec737b8e962d381c8fdd0999e7e01847836", "index": 5274, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef compute(plus, minus, total, inp):\n if plus == 1 and minus == 0:\n print(total)\n return\n elif plus == 1 and minus == 1:\n print('Impossible')\n ...
[ 0, 2, 3, 4, 5 ]
import sqlite3 class announcement: def __init__(eps_df, revenue_df): conn = sqlite3.connect("earnings.db", timeout=120) cur = conn.cursor() symbol_href = self.driver.find_element_by_class_name("lfkTWp") symbol = symbol_href.text eps_history_df = pd.read_sql( '...
normal
{ "blob_id": "b7738c27e11e9566d90157717633312031cdffd6", "index": 818, "step-1": "<mask token>\n\n\nclass announcement:\n\n def __init__(eps_df, revenue_df):\n conn = sqlite3.connect('earnings.db', timeout=120)\n cur = conn.cursor()\n symbol_href = self.driver.find_element_by_class_name('l...
[ 6, 7, 8, 9, 11 ]
#!/usr/bin/python3 def divisible_by_2(my_list=[]): if my_list is None or len(my_list) == 0: return None new = [] for num in my_list: if num % 2 == 0: new.append(True) else: new.append(False) return new
normal
{ "blob_id": "17f91b612fad14200d2911e2cb14e740b239f9ff", "index": 4894, "step-1": "<mask token>\n", "step-2": "def divisible_by_2(my_list=[]):\n if my_list is None or len(my_list) == 0:\n return None\n new = []\n for num in my_list:\n if num % 2 == 0:\n new.append(True)\n ...
[ 0, 1, 2 ]
from ethereum.common import mk_transaction_sha, mk_receipt_sha from ethereum.exceptions import InsufficientBalance, BlockGasLimitReached, \ InsufficientStartGas, InvalidNonce, UnsignedTransaction from ethereum.messages import apply_transaction from ethereum.slogging import get_logger from ethereum.utils import enco...
normal
{ "blob_id": "e364ba45513167966fe50e31a01f552ccedec452", "index": 6552, "step-1": "<mask token>\n\n\ndef add_transactions(shard_state, collation, txqueue, shard_id,\n min_gasprice=0, mainchain_state=None):\n \"\"\"Add transactions to a collation\n (refer to ethereum.common.add_transactions)\n \"\"\"\n...
[ 4, 5, 6, 7, 10 ]
import re import sys import zipfile import pathlib from typing import IO, Any from collections.abc import Mapping import numpy.typing as npt import numpy as np from numpy.lib._npyio_impl import BagObj if sys.version_info >= (3, 11): from typing import assert_type else: from typing_extensions import assert_typ...
normal
{ "blob_id": "e2f134f5ff00405396b8bbf4edc263b70ef5d972", "index": 2435, "step-1": "<mask token>\n\n\nclass BytesWriter:\n <mask token>\n\n\nclass BytesReader:\n\n def read(self, n: int=...) ->bytes:\n ...\n\n def seek(self, offset: int, whence: int=...) ->int:\n ...\n\n\n<mask token>\n", ...
[ 4, 5, 6, 7, 8 ]
from django.utils.text import slugify from pyexpat import model from django.db import models # Create your models here. from rest_framework_simplejwt.state import User FREQUENCY = ( ('daily', 'Diario'), ('weekly', 'Semanal'), ('monthly', 'Mensual') ) class Tags(models.Model): name = models.CharField(m...
normal
{ "blob_id": "71503282e58f60e0936a5236edc094f1da937422", "index": 6565, "step-1": "<mask token>\n\n\nclass Tags(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n ordering = '-created_at',\n\n\nclass Newsletter(m...
[ 5, 7, 8, 10, 11 ]
from pyspark import SparkContext, SparkConf conf = SparkConf().setAppName("same_host").setMaster("local") sc = SparkContext(conf=conf) julyFirstLogs = sc.textFile("/Users/iamsuman/src/iamsuman/myspark/mypyspark/data/nasa_19950701.tsv") augFirstLogs = sc.textFile("/Users/iamsuman/src/iamsuman/myspark/mypyspark/data/na...
normal
{ "blob_id": "36fce3837e0341d94ff6099a06be8cf757a1cfa9", "index": 3596, "step-1": "<mask token>\n", "step-2": "<mask token>\ncleanedHostIntersection.saveAsTextFile('out/nasa_logs_same_hosts.csv')\n", "step-3": "<mask token>\nconf = SparkConf().setAppName('same_host').setMaster('local')\nsc = SparkContext(conf...
[ 0, 1, 2, 3, 4 ]
# Copyright (c) 2021 Koichi Sakata from pylib_sakata import init as init # uncomment the follows when the file is executed in a Python console. # init.close_all() # init.clear_all() import os import shutil import numpy as np from control import matlab from pylib_sakata import ctrl from pylib_sakata import plot prin...
normal
{ "blob_id": "ad1aa69f92f104ac8b82aca3c0a64ce3de48b36d", "index": 3847, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Start simulation!')\n<mask token>\nif os.path.exists(figurefolderName):\n shutil.rmtree(figurefolderName)\nos.makedirs(figurefolderName)\n<mask token>\nprint('Common parameters ...
[ 0, 1, 2, 3, 4 ]
import numpy as np import tensorflow as tf def mfcc(data): pass def cut_frames(data): pass
normal
{ "blob_id": "8411acf6b27425357d212f5e220314daa019e023", "index": 9669, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef cut_frames(data):\n pass\n", "step-3": "<mask token>\n\n\ndef mfcc(data):\n pass\n\n\ndef cut_frames(data):\n pass\n", "step-4": "import numpy as np\nimport tensorflo...
[ 0, 1, 2, 3 ]
import sys import os import traceback from src.properties import * from src.utils import * from subprocess import call from src.entity.cursor import Cursor from curses import * def main(screen, file_path): setUpEnv() text = readFileIfExist(file_path) while 1: try: text = startEditing(s...
normal
{ "blob_id": "7a6d45ef87d93af9a15bd352b893164d3a36c399", "index": 7545, "step-1": "<mask token>\n\n\ndef main(screen, file_path):\n setUpEnv()\n text = readFileIfExist(file_path)\n while 1:\n try:\n text = startEditing(screen, text)\n printQuitOptions(screen)\n cha...
[ 4, 5, 6, 7, 8 ]
import os import struct import sys import wave sys.path.insert(0, os.path.dirname(__file__)) C5 = 523 B4b = 466 G4 = 392 E5 = 659 F5 = 698 VOLUME = 12000 notes = [ [VOLUME, C5], [VOLUME, C5], [VOLUME, B4b], [VOLUME, C5], [0, C5], [VOLUME, G4], [0, C5], [VOLUME, G4], [VOLUME, C5], ...
normal
{ "blob_id": "4fb563985bd99599e88676e167ee84a95b018aba", "index": 5414, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.insert(0, os.path.dirname(__file__))\n<mask token>\nfor volume, frequency in notes:\n samples = square_wave(int(44100 / frequency // 2))\n samples = gain(samples, volume)\n...
[ 0, 1, 2, 3, 4 ]
import random import numpy as np class Board: def __init__(self, nrows, ncols, random_seed=42): self.nrows = nrows self.ncols = ncols self.random = random.Random() self.random.seed(random_seed) self.board = np.zeros((nrows, ncols)) self.score = 0 self.__add_new_numbers() # Initialize with 1/8 of the ...
normal
{ "blob_id": "cab45a823e319bd504b3db68cf70bff315f44fc6", "index": 7462, "step-1": "<mask token>\n\n\nclass Board:\n\n def __init__(self, nrows, ncols, random_seed=42):\n self.nrows = nrows\n self.ncols = ncols\n self.random = random.Random()\n self.random.seed(random_seed)\n ...
[ 10, 12, 13, 14, 16 ]
# -*- coding: utf-8 -*- """ Created on Tue Dec 31 05:48:57 2019 @author: emama """ import datetime as dt t = dt.datetime.today() print(t)
normal
{ "blob_id": "b1fbc8f3616b70e5d35898fd895c37e838c87dc9", "index": 9293, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(t)\n", "step-3": "<mask token>\nt = dt.datetime.today()\nprint(t)\n", "step-4": "<mask token>\nimport datetime as dt\nt = dt.datetime.today()\nprint(t)\n", "step-5": "# -*- co...
[ 0, 1, 2, 3, 4 ]
from rest_framework import serializers, viewsets, routers from lamp_control.models import Lamp class LampSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = Lamp fields = '__all__' class LampViewSet(viewsets.ModelViewSet): serializer_class = LampSerializer queryset ...
normal
{ "blob_id": "aff1d702e591efcfc0fc93150a3fbec532408137", "index": 55, "step-1": "<mask token>\n\n\nclass LampViewSet(viewsets.ModelViewSet):\n serializer_class = LampSerializer\n queryset = Lamp.objects.all()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass LampSerializer(serializers.HyperlinkedMo...
[ 2, 3, 5, 6, 7 ]
from GRAFICA_BRESENHAMS import Bresenhams def main(): x = int(input('INGRESA VALOR PARA X: \n')) y = int(input('INGRESA VALOR PARA Y: \n')) x1 = int(input('INGRESA VALOR PARA X1: \n')) y1 = int(input('INGRESA VALOR PARA Y1: \n')) Bresenhams(x, y, x1, y1) if __name__ == '__main__': main()
normal
{ "blob_id": "e75bee4e014aa369131c3e200ce874a8840b5690", "index": 3573, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n x = int(input('INGRESA VALOR PARA X: \\n'))\n y = int(input('INGRESA VALOR PARA Y: \\n'))\n x1 = int(input('INGRESA VALOR PARA X1: \\n'))\n y1 = int(input('I...
[ 0, 1, 2, 3 ]
from jox_api import label_image,Mysql,Utils from jox_config import api_base_url import json class Menu(): def __init__(self): self.mysqlClass = Mysql.MySQL() self.timeClass = Utils.Time() def get_menu(self,type,openid): try: if type == 'mine': self.sql = "SEL...
normal
{ "blob_id": "4fa9d16f979acf3edce05a209e1c6636e50fc315", "index": 222, "step-1": "<mask token>\n\n\nclass Menu:\n <mask token>\n\n def get_menu(self, type, openid):\n try:\n if type == 'mine':\n self.sql = (\n \"SELECT * FROM get_menu WHERE openid='%s' ord...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/env python # coding: utf-8 # In[1]: import pandas as pd gp = pd.read_csv('graph6.csv') N=gp['Starting-node'].max() M=gp['Ending-node'].max() N=max(N,M) gp=gp.sort_values(by='Cost') gp=gp.reset_index() gp=gp.reset_index() gp['tree label']=gp['level_0'] index=gp['index'].max() gp.drop('index',axis...
normal
{ "blob_id": "719f7b7b2d8df037583263588e93d884ab3820fe", "index": 5963, "step-1": "<mask token>\n", "step-2": "<mask token>\ngp.drop('index', axis=1, inplace=True)\ngp.drop('level_0', axis=1, inplace=True)\nfor n in range(index + 1):\n Count = []\n Visit = []\n Visit2 = []\n for i in range(11):\n ...
[ 0, 1, 2, 3, 4 ]
# models.py- Team from django.db import models class Team(models.Model): teamName = models.TextField() #Seasons associated #Registrants unique return
normal
{ "blob_id": "331b5f0a34db4d12d713439db3d2818e8c922310", "index": 4236, "step-1": "<mask token>\n\n\nclass Team(models.Model):\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass Team(models.Model):\n teamName = models.TextField()\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ncl...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- from django.conf.urls import patterns, include, url from apps.virt.views import node, domain,device,cluster,home urlpatterns = patterns('', # Home url(r'^$', home.HomeView.as_view(), name='home'), # Cluster url(r'^cluster/status/$', cluster.ClusterStatusView.as_view(), name...
normal
{ "blob_id": "484d104a8481a707a187d0bcb30898c3459a88be", "index": 389, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = patterns('', url('^$', home.HomeView.as_view(), name='home'),\n url('^cluster/status/$', cluster.ClusterStatusView.as_view(), name=\n 'cluster_status'), url('^node/list...
[ 0, 1, 2, 3 ]
import numpy as np import pandas as pd import matplotlib.pyplot as plt import csv file_open = open("C:/Users/DI_Lab/Desktop/20년도 Kisti 과제/HMM/HMM(Up,Down).csv", 'r', encoding='UTF8') save_file = open("C:/Users/DI_Lab/Desktop/20년도 Kisti 과제/HMM/HMM사후확률.csv", 'w', encoding='UTF8',newline='') write = csv.writer(save_file)...
normal
{ "blob_id": "55977a673bb36900e1d797cb9ec330ce6d9aa717", "index": 8232, "step-1": "<mask token>\n\n\ndef count(a, b):\n a = int(a)\n b = int(b)\n if a == 0 and b == 0:\n return 0\n elif a == 0 and b == 1:\n return 1\n elif a == 1 and b == 0:\n return 2\n elif a == 1 and b ==...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: WuTian # @Date : 2018/5/3 # @Contact : jsj0804wt@126.com # @Desc :使用广度优先搜索查找芒果商 from collections import deque graph = {} graph["you"] = ["alice", "bob", "claire"] graph["bob"] = ["anuj", "peggy"] graph["alice"] = ["peggy"] graph["claire"] = ["thom", "jonny"] g...
normal
{ "blob_id": "e881fcfce933d8f3bafcbaab039ddcf98827bf5e", "index": 4244, "step-1": "<mask token>\n\n\ndef is_mango_seller(name):\n return name[-1] == 'm'\n\n\ndef search_mango_seller(name):\n search_queue = deque()\n searched = []\n global graph\n search_queue += graph[name]\n while search_queue:...
[ 2, 3, 4, 5, 6 ]
import mlcd,pygame,time,random PLAYER_CHAR=">" OBSTACLE_CHAR="|" screenbuff=[[" "," "," "," "," "," "," "," "," "," "," "," "], [" "," "," "," "," "," "," "," "," "," "," "," "]] player={"position":0,"line":0,"score":000} game={"speed":4.05,"level":2.5,"obstacle":0} keys={"space":False,"quit":False,"nex...
normal
{ "blob_id": "aeaab602cbb9fa73992eb5259e8603ecb11ba333", "index": 4863, "step-1": "<mask token>\n\n\ndef keypress():\n global keys\n keys['space'] = keys['quit'] = keys['next'] = False\n for event in pygame.event.get():\n if event.type == pygame.KEYDOWN and event.key == pygame.K_SPACE:\n ...
[ 1, 2, 3, 4, 5 ]
from sklearn.metrics import accuracy_score, recall_score, precision_score, f1_score print(accuracy_score(true_labels, guesses)) print(recall_score(true_labels, guesses)) print(precision_score(true_labels, guesses)) print(f1_score(true_labels, guesses)) from sklearn.metrics import confusion_matrix print(confusion_matrix...
normal
{ "blob_id": "faa53db9dd581b6508fb9e4042ec86ebaf850e60", "index": 5320, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(accuracy_score(true_labels, guesses))\nprint(recall_score(true_labels, guesses))\nprint(precision_score(true_labels, guesses))\nprint(f1_score(true_labels, guesses))\n<mask token>\n...
[ 0, 1, 2 ]
# SymBeam examples suit # ========================================================================================== # António Carneiro <amcc@fe.up.pt> 2020 # Features: 1. Numeric length # 2. Pin # 3. Two rollers # 4. Numeric distributed...
normal
{ "blob_id": "bdbeebab70a6d69e7553807d48e3539b78b48add", "index": 2946, "step-1": "<mask token>\n", "step-2": "<mask token>\ntest_beam.add_support(0, 'roller')\ntest_beam.add_support(2, 'roller')\ntest_beam.add_support(6, 'pin')\ntest_beam.add_support(4, 'hinge')\ntest_beam.add_distributed_load(0, 4, -5)\ntest_...
[ 0, 1, 2, 3, 4 ]
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not u...
normal
{ "blob_id": "47cee0c659976a2b74e2bb07f6c4d622ceab7362", "index": 3866, "step-1": "<mask token>\n\n\nclass AirflowSecurityManager(SecurityManagerOverride, SecurityManager,\n LoggingMixin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask tok...
[ 33, 36, 40, 47, 49 ]
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'FormHello.ui' # # Created by: PyQt5 UI code generator 5.15.4 # # WARNING: Any manual changes made to this file will be lost when pyuic5 is # run again. Do not edit this file unless you know what you are doing. from PyQt5 import QtCore, Qt...
normal
{ "blob_id": "fc20a2bf09d510892a4d144fbbd2cb2012c3ad98", "index": 8579, "step-1": "<mask token>\n\n\nclass Ui_FormHello(object):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Ui_FormHello(object):\n\n def setupUi(self, FormHello):\n FormHello.setObjectName('FormHello')\n ...
[ 1, 2, 3, 4, 5 ]
#%% ### 날짜 데이터 분리 # 연-월-일 날짜 데이터에서 일부 분리 추출 import pandas as pd df = pd.read_csv('../../datasets/part5/stock-data.csv') # 문자열인 날짜 데이터를 판다스 Timestamp로 변환 df['new_Date'] = pd.to_datetime(df['Date']) # df에 새로운 열로 추가 print(df.head()) print() # dt 속성을 이용하여 new_Data 열의 연-월-일 정보를 년, 월, 일로 구분 df['Year'] = df['new_...
normal
{ "blob_id": "d89e1d653c6db322feb6edba93cbfc622bf47aa2", "index": 2781, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(df.head())\nprint()\n<mask token>\nprint(df.head())\nprint('------------------')\n<mask token>\nprint(df.head())\nprint('------------------')\ndf.set_index('Date_m', inplace=True)\n...
[ 0, 1, 2, 3, 4 ]
import discord, requests from random import choice TOKEN = 'TOKEN' CONTACT_EMAIL = None #'Contact email for getting 10000 words/day instead of 1000' translate_command = '$t' id_start = '<@!' client = discord.Client() def unescape(text): return text.replace('&#39;', '\'').replace('&lt;','<').replace(...
normal
{ "blob_id": "1ab69874a89311b22220dda541dfe03462a98a55", "index": 2243, "step-1": "<mask token>\n\n\ndef unescape(text):\n return text.replace('&#39;', \"'\").replace('&lt;', '<').replace('&gt;', '>')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef unescape(text):\n return text.replace('&#39;', \"'...
[ 1, 2, 3, 4, 5 ]
from pylab import * def f(x,y): return (1-x/2+x**5+y**3)*np.exp(-x**2-y**2) n = 256 x = np.linspace(-3,3,n) y = np.linspace(-3,3,n) X,Y = np.meshgrid(x,y) axes([0.025,0.025,0.95,0.95]) contourf(X, Y, f(X,Y), 8, alpha=.75, cmap=cm.hot) C = contour(X, Y, f(X,Y), 8, colors='black', linewidth=.5) clabel(C, inline=1, fo...
normal
{ "blob_id": "e9c439eafac8fd689980ffcb562f3b5ee903dd56", "index": 2604, "step-1": "<mask token>\n\n\ndef f(x, y):\n return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y ** 2)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef f(x, y):\n return (1 - x / 2 + x ** 5 + y ** 3) * np.exp(-x ** 2 - y **...
[ 1, 2, 3, 4, 5 ]
class Solution: # @param arrive : list of integers # @param depart : list of integers # @param K : integer # @return a boolean def hotel(self, arrive, depart, K): self.count = 0 self.temp = 0 for i in range(len(arrive)): for j in range(i, len(depart)): ...
normal
{ "blob_id": "de6a6c2dc7bea255e5674663616c962c1d1625e0", "index": 4138, "step-1": "class Solution:\n # @param arrive : list of integers\n # @param depart : list of integers\n # @param K : integer\n # @return a boolean\n def hotel(self, arrive, depart, K):\n self.count = 0\n self.temp ...
[ 0 ]
import math getal1 = 5 getal2 = 7 getal3 = 8 getal4 = -4 getal5 = 2 print(getal1 * getal2 + getal3) print(getal1 * (getal2 + getal3)) print(getal2 + getal3 / getal1) print((getal2 + getal3) / getal1) print(getal2 + getal3 % getal1) print(abs(getal4 * getal1)) print(pow(getal3, getal5)) print(round(getal5 / getal2, 2)) ...
normal
{ "blob_id": "30d75aafd9612ac02557b947fc4e3c2f7322a7fd", "index": 3555, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(getal1 * getal2 + getal3)\nprint(getal1 * (getal2 + getal3))\nprint(getal2 + getal3 / getal1)\nprint((getal2 + getal3) / getal1)\nprint(getal2 + getal3 % getal1)\nprint(abs(getal4 *...
[ 0, 1, 2, 3 ]
# SaveIsawQvector import sys import os if os.path.exists("/opt/Mantid/bin"): sys.path.append("/opt/mantidnightly/bin") #sys.path.append("/opt/Mantid/bin") # Linux cluster #sys.path.append('/opt/mantidunstable/bin') else: sys.path.append("C:/MantidInstall/bin") # Windows PC # import ma...
normal
{ "blob_id": "b72bf00d156862c7bddecb396da3752be964ee66", "index": 5463, "step-1": "# SaveIsawQvector\r\n\r\nimport sys\nimport os\n\r\nif os.path.exists(\"/opt/Mantid/bin\"):\n sys.path.append(\"/opt/mantidnightly/bin\")\n #sys.path.append(\"/opt/Mantid/bin\") # Linux cluster\n #sys.path.append('...
[ 0 ]
""" definition of a sensor """ import datetime import pytz class tlimit: def __init__(self, name, text): self.name = name self.text = text time_limit = [ tlimit("All", "All Data"), tlimit("day", "Current day"), tlimit("24hours", "Last 24 hours"), tlimit("3days", "Three last days"...
normal
{ "blob_id": "cb9ea8791009a29a24a76bc2b161e7f8599fec1b", "index": 5780, "step-1": "<mask token>\n\n\nclass tlimit:\n\n def __init__(self, name, text):\n self.name = name\n self.text = text\n\n\n<mask token>\n\n\nclass SensorData:\n date = datetime.datetime(1970, 1, 1, 0, 0, 0)\n server_room...
[ 12, 13, 14, 18, 20 ]
from collections import defaultdict squares = dict() for i in range(2000): squares[i * i] = i perims = defaultdict(int) for a in range(1, 1001): for b in range(a + 1, 1001): if a * a + b * b not in squares: continue c = squares[a * a + b * b] perims[a + b + c] += 1 for perim,...
normal
{ "blob_id": "a3299a2945a638c74c2d16bc28079ed692718fbd", "index": 2703, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(2000):\n squares[i * i] = i\n<mask token>\nfor a in range(1, 1001):\n for b in range(a + 1, 1001):\n if a * a + b * b not in squares:\n continue\n ...
[ 0, 1, 2, 3 ]
from PyQt5.QtWidgets import QPushButton,QWidget,QApplication,QGridLayout,QListWidget,QLineEdit,QVBoxLayout,QLabel import pyqtgraph as pg import sys import numpy as np from tools import DataModel,HoldPositions from load_sina import LoadNet import time from get_day_histroy import history import pandas as pd from volume ...
normal
{ "blob_id": "8ddb7abb480ea8ee674c59719c0946f133ef0a4b", "index": 1303, "step-1": "<mask token>\n\n\nclass addItemThread(QThread):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Example(QWidget):\n\n def...
[ 11, 12, 13, 14, 17 ]
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: Nirvana # # Created: 07/06/2014 # Copyright: (c) Nirvana 2014 # Licence: <your licence> #------------------------------------------------------------------------------- import r...
normal
{ "blob_id": "eb246beb05249f5dfde019b773698ba3bb1b1118", "index": 544, "step-1": "<mask token>\n\n\nclass Coin(object):\n\n def __init__(self):\n self.sideup = 'Heads'\n\n def toss(self):\n if random.randint(0, 1) == 0:\n self.sideup = 'Heads'\n else:\n self.sideup...
[ 4, 5, 6, 7, 8 ]
from os.path import basename from .FileInfo import FileInfo class mrk_file(FileInfo): """ .mrk specific file container. """ def __init__(self, id_=None, file=None, parent=None): super(mrk_file, self).__init__(id_, file, parent) self._type = '.mrk' #region class methods def __get...
normal
{ "blob_id": "8e9aec7d3653137a05f94e4041d28f3423122751", "index": 3990, "step-1": "<mask token>\n\n\nclass mrk_file(FileInfo):\n <mask token>\n\n def __init__(self, id_=None, file=None, parent=None):\n super(mrk_file, self).__init__(id_, file, parent)\n self._type = '.mrk'\n <mask token>\n\...
[ 4, 5, 6, 7, 8 ]
from django.urls import path from django.conf.urls.i18n import urlpatterns from . import views urlpatterns = [ path('signup/', views.signup, name='signup'), path('home', views.home, name='home'), path('collab/', views.collab, name='collab'), ]
normal
{ "blob_id": "351963bee76ecaa9fa5c8d659f6d7c6ca9b22531", "index": 2182, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('signup/', views.signup, name='signup'), path('home',\n views.home, name='home'), path('collab/', views.collab, name='collab')]\n", "step-3": "from django.urls im...
[ 0, 1, 2, 3 ]
import numpy as np ''' 1. Create 0-D array, 1-D array, 2-D array, 3-D array with following value 0-D: [2] 1-D: [3, 4, 5, 6, 7] 2-D: [[8, 1, 3], [2, 3, 4], [6, 2, 5]] 3-D: [[[1, 2, 4], [3, 3, 2], [1, 9, 1]], [[6, 8, 7], [9, 1, 0], [8, 2, 3]], [[5, 4, 1], [5, 7, 2], [3, 5, 9]]] print them ''' D0 = np....
normal
{ "blob_id": "a868ecb6ea6a5c7a186ddd8fa4fb76d96efeb21d", "index": 4140, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('D0')\nprint(D0)\nprint('D1')\nprint(D1)\nprint('D2')\nprint(D2)\nprint('D3')\nprint(D3)\n<mask token>\nprint('D2')\nprint(D2)\n<mask token>\nprint('D3')\nprint(D3)\n<mask token>\np...
[ 0, 1, 2, 3, 4 ]
from django.contrib import admin from .models import Account # Register your models here. class AuthenticationCustom(admin.ModelAdmin): list_display = ("email", "id") search_fields = ["email", "mobile"] admin.site.register(Account, AuthenticationCustom)
normal
{ "blob_id": "4957e62deec6192aabdf7144f02b28c7ce60ed4b", "index": 4250, "step-1": "<mask token>\n\n\nclass AuthenticationCustom(admin.ModelAdmin):\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass AuthenticationCustom(admin.ModelAdmin):\n list_display = 'email', 'id...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # coding: utf-8 from unittest import TestCase from optimoida.logging import ( SUCCESS, FAILURE, logger) class LoggerTestCase(TestCase): def test_flag_value(self): self.assertEqual(SUCCESS, "\x1b[34mSUCCESS\x1b[0m") self.assertEqual(FAILURE, "\x1b[31mFAILURE\x1b[0m") ...
normal
{ "blob_id": "ac8c8dc4bcccef7942dd48d54902e13e811f950c", "index": 5059, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LoggerTestCase(TestCase):\n\n def test_flag_value(self):\n self.assertEqual(SUCCESS, '\\x1b[34mSUCCESS\\x1b[0m')\n self.assertEqual(FAILURE, '\\x1b[31mFAILURE\\...
[ 0, 2, 3, 4, 5 ]
# coding=gbk from numpy import * import fp_growth ''' #创建树的一个单节点 rootNode=fp_growth.treeNode('pyramid',9,None) #为其增加一个子节点 rootNode.children['eye']=fp_growth.treeNode('eye',13,None) rootNode.disp() #导入事务数据库实例 simpData=fp_growth.loadSimpData() #print("simpData:") #print(simpData) #对数据进行格式化处理 initSet=fp_growth.cre...
normal
{ "blob_id": "e8b0e6e5e68933703e2ac8c9b2b62d68c0c2f53d", "index": 8295, "step-1": "<mask token>\n", "step-2": "<mask token>\nfp_growth.minTree(myFPtree, myHeaderTab, 100000, set([]), myFreqList)\nprint(len(myFreqList))\n", "step-3": "<mask token>\nparsedDat = [line.split() for line in open('kosarak.dat').read...
[ 0, 1, 2, 3, 4 ]
import os import time import re import json from os.path import join, getsize from aiohttp import web from utils import helper TBL_HEAD = ''' <table class="table table-striped table-hover table-sm"> <thead> <tr> <th scope="col">Directory</th> <th scope="col">Size</th> </tr> </thead> <tbody>...
normal
{ "blob_id": "7c9b51ae7cde9c3a00888dac6df710b93af6dd7f", "index": 4836, "step-1": "<mask token>\n\n\ndef stats_count_info(request):\n root_path = request.app['PATH-DB']\n cpt = 0\n d = dict()\n dirs_data = dict()\n for root, dirs, files in os.walk(root_path, topdown=False):\n cpt += len(file...
[ 2, 3, 4, 5, 6 ]
# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # ...
normal
{ "blob_id": "2ab303a2f36cdd64e2119856312dd5e38ee728d6", "index": 9632, "step-1": "<mask token>\n\n\nclass LoadBalancerTest(common.HeatTestCase):\n\n def setUp(self):\n super(LoadBalancerTest, self).setUp()\n self.lb_template = {'AWSTemplateFormatVersion': '2010-09-09',\n 'Description'...
[ 62, 89, 97, 102, 126 ]
# --------------------------------------------------------------------- # Iskratel.ESCOM.get_version # --------------------------------------------------------------------- # Copyright (C) 2007-2018 The NOC Project # See LICENSE for details # --------------------------------------------------------------------- # Pyth...
normal
{ "blob_id": "40b3c403f99044eb61740d62eda15ddd08b0f739", "index": 1980, "step-1": "<mask token>\n\n\nclass Script(BaseScript):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <m...
[ 1, 2, 3, 4, 5 ]
forbidden = ['Key.esc', 'Key.cmd', 'Key.cmd_r', 'Key.menu', 'Key.pause', 'Key.scroll_lock', 'Key.print_screen', 'Key.enter', 'Key.space', 'Key.backspace', 'Key.ctrl_l', 'Key.ctrl_r', 'Key.alt_l', 'Key.alt_gr', 'Key.caps_lock', 'Key.num_lock', 'Key.tab', 'Key.shift', 'Key.shift_r', 'Key.insert', 'Key.del...
normal
{ "blob_id": "995dc34ea32de4566e2804b6797d9b551b733ff3", "index": 3406, "step-1": "<mask token>\n", "step-2": "forbidden = ['Key.esc', 'Key.cmd', 'Key.cmd_r', 'Key.menu', 'Key.pause',\n 'Key.scroll_lock', 'Key.print_screen', 'Key.enter', 'Key.space',\n 'Key.backspace', 'Key.ctrl_l', 'Key.ctrl_r', 'Key.alt...
[ 0, 1 ]
msg = "eduardo foi a feira" if 'feira' in msg: print('Sim, foi a feira') else: print('não ele não foi a feira')
normal
{ "blob_id": "2a83bc9157e2210da46e58c56fc0b7199856f4c0", "index": 6287, "step-1": "<mask token>\n", "step-2": "<mask token>\nif 'feira' in msg:\n print('Sim, foi a feira')\nelse:\n print('não ele não foi a feira')\n", "step-3": "msg = 'eduardo foi a feira'\nif 'feira' in msg:\n print('Sim, foi a feir...
[ 0, 1, 2, 3 ]
import gzip import pickle as pkl import time from datetime import datetime import grpc import numpy as np from sklearn.utils import shuffle import neural_nets_pb2 as nn_pb import neural_nets_pb2_grpc as nn_pb_grpc from mnist_loader import load_data from activations import * # pylint: disable=too-many-arguments cl...
normal
{ "blob_id": "fa6f251f27b645fc6827285b5578fd9634c8bb30", "index": 6361, "step-1": "<mask token>\n\n\nclass Layer(nn_pb_grpc.LayerDataExchangeServicer):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def init_weights(self, load_weights=None):\n ...
[ 24, 27, 28, 32, 35 ]
# -*- coding:utf-8 -*- # Copyright 2015 NEC Corporation. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License...
normal
{ "blob_id": "b220189d506737bf8cff9e600d1cfd4d7bc8435d", "index": 1434, "step-1": "# -*- coding:utf-8 -*-\n\n# Copyright 2015 NEC Corporation. #\n# #\n# Licensed under the Apache License, Version 2.0 ...
[ 0 ]
# -*- coding:utf-8 -*- #实现同义词词林的规格化 with open('C:\\Users\\lenovo\\Desktop\\哈工大社会计算与信息检索研究中心同义词词林扩展版.txt') as f: with open('convert.txt','a') as w: for line in f: data = line[8:-1].split() for item in data: tmp = data.copy() ...
normal
{ "blob_id": "9109e649a90730df022df898a7760140275ad724", "index": 4854, "step-1": "<mask token>\n", "step-2": "with open('C:\\\\Users\\\\lenovo\\\\Desktop\\\\哈工大社会计算与信息检索研究中心同义词词林扩展版.txt') as f:\n with open('convert.txt', 'a') as w:\n for line in f:\n data = line[8:-1].split()\n ...
[ 0, 1, 2 ]
#!/usr/bin/env python # -*- coding:utf-8 -*- #allisnone 20200403 #https://github.com/urllib3/urllib3/issues/1434 #https://github.com/dopstar/requests-ntlm2 #https://github.com/requests/requests-ntlm #base on python3 #if you request https website, you need to add ASWG CA to following file: #/root/.pyenv/versio...
normal
{ "blob_id": "a7fae2da8abba6e05b4fc90dec8826194d189853", "index": 2758, "step-1": "<mask token>\n\n\ndef get_random_ip_or_user(start, end, prefix='172.16.90.', type='ip'):\n if type == 'ip' and max(start, end) > 255:\n end = 255\n i = random.randint(start, end)\n return prefix + str(i)\n\n\ndef ge...
[ 6, 7, 8, 9, 11 ]
# the main program of this project import log import logging import os from ast_modifier import AstModifier from analyzer import Analyzer class Demo(): def __init__(self): self.log = logging.getLogger(self.__class__.__name__) def start(self, filename: str): self.log.debug('analyse file: ' + fil...
normal
{ "blob_id": "e989f73011559080f96802dba4db30361d5626f9", "index": 4002, "step-1": "<mask token>\n\n\nclass Demo:\n\n def __init__(self):\n self.log = logging.getLogger(self.__class__.__name__)\n\n def start(self, filename: str):\n self.log.debug('analyse file: ' + filename)\n astmodif =...
[ 3, 4, 5, 6, 7 ]
from LinkedList import LinkedList class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ h1 = l1 ...
normal
{ "blob_id": "0f3ecd0a7189f57fdbda2360f6e39bd6101e2fdb", "index": 7435, "step-1": "<mask token>\n\n\nclass ListNode(object):\n\n def __init__(self, x):\n self.val = x\n self.next = None\n\n\nclass Solution(object):\n\n def addTwoNumbers(self, l1, l2):\n \"\"\"\n :type l1: ListNod...
[ 4, 5, 6, 7 ]
# 2019/10/08 2019년10월8일 ss = input('날짜: 년/월/일 입력-> ') sslist = ss.split('/') print(sslist) print('입력하신 날짜의 10년 후 -> ', end='') year = int(sslist[0]) + 10 print(str(year) + "년", end='') print(sslist[1] + "월", end='') print(sslist[2] + "일")
normal
{ "blob_id": "fb2ef5a90b6e2582450726905868dd1b78e36166", "index": 5008, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(sslist)\nprint('입력하신 날짜의 10년 후 -> ', end='')\n<mask token>\nprint(str(year) + '년', end='')\nprint(sslist[1] + '월', end='')\nprint(sslist[2] + '일')\n", "step-3": "ss = input('날짜: 년...
[ 0, 1, 2, 3 ]
#!/C:\Program Files (x86)\Python35-32 #importar librarias necesarias from urllib.request import urlopen from bs4 import BeautifulSoup
normal
{ "blob_id": "7a59c8c883a9aaa723175783e01aa62e23503fde", "index": 376, "step-1": "<mask token>\n", "step-2": "from urllib.request import urlopen\nfrom bs4 import BeautifulSoup\n", "step-3": "#!/C:\\Program Files (x86)\\Python35-32\n\n#importar librarias necesarias\nfrom urllib.request import urlopen\nfrom bs4...
[ 0, 1, 2 ]
import ttk import Tkinter as tk from rwb.runner.log import RobotLogTree, RobotLogMessages from rwb.lib import AbstractRwbGui from rwb.widgets import Statusbar from rwb.runner.listener import RemoteRobotListener NAME = "monitor" HELP_URL="https://github.com/boakley/robotframework-workbench/wiki/rwb.monitor-User-Guide"...
normal
{ "blob_id": "572d58eec652207e6ec5a5e1d4c2f4310f2a70f3", "index": 1665, "step-1": "import ttk\nimport Tkinter as tk\nfrom rwb.runner.log import RobotLogTree, RobotLogMessages\nfrom rwb.lib import AbstractRwbGui\nfrom rwb.widgets import Statusbar\n\nfrom rwb.runner.listener import RemoteRobotListener\n\nNAME = \"m...
[ 0 ]
__author__ = 'Vicio' from Conexion.conexion import Conexion class ConexionList(): def __init__(self): self.conexion = Conexion() def selectClientes(self): pass def selectProveedores(self): pass
normal
{ "blob_id": "6b4af452778bdf13ac18e8d260cf1c9176ca95e0", "index": 8414, "step-1": "<mask token>\n\n\nclass ConexionList:\n <mask token>\n\n def selectClientes(self):\n pass\n\n def selectProveedores(self):\n pass\n", "step-2": "<mask token>\n\n\nclass ConexionList:\n\n def __init__(sel...
[ 3, 4, 5, 6, 7 ]
import matplotlib.pyplot as plt from partisan_symmetry_noplot import partisan_symmetry for k in range(1,100): a=[] for i in range(1,100): a.append([]) for j in range(1,100): a[i-1].append(partisan_symmetry([5*i/100,.20,5*j/100],1000,False)) plt.imshow(a) plt.colorbar() p...
normal
{ "blob_id": "cfa0937f1c49b52283c562d9ab1cb0542e71b990", "index": 5970, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor k in range(1, 100):\n a = []\n for i in range(1, 100):\n a.append([])\n for j in range(1, 100):\n a[i - 1].append(partisan_symmetry([5 * i / 100, 0.2, 5...
[ 0, 1, 2, 3 ]
from collections import defaultdict as dd def grouping(w): d = dd(list) for k, v in ((len([y for y in x if y.isupper()]), x) for x in sorted(w, key=str.casefold)): d[k].append(v) return dict(sorted(d.items()))
normal
{ "blob_id": "545794cf4f0b2ab63b6a90951a78f8bdaca3c9e6", "index": 390, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef grouping(w):\n d = dd(list)\n for k, v in ((len([y for y in x if y.isupper()]), x) for x in sorted(w,\n key=str.casefold)):\n d[k].append(v)\n return dict(so...
[ 0, 1, 2 ]
#!/usr/bin/env python3 import sys, os import random import numpy as np import matplotlib as mpl if os.environ.get('DISPLAY','') == '': print('no display found. Using non-interactive Agg backend') mpl.use('Agg') import matplotlib.pyplot as plt from mpl_toolkits.axes_grid1 import make_axes_locatable import sha...
normal
{ "blob_id": "b4454d92ab8380e0eded2f7aed737378e1710c72", "index": 9413, "step-1": "<mask token>\n", "step-2": "<mask token>\nif os.environ.get('DISPLAY', '') == '':\n print('no display found. Using non-interactive Agg backend')\n mpl.use('Agg')\n<mask token>\nsys.path.append(path_to_utils)\n<mask token>\n...
[ 0, 1, 2, 3, 4 ]
# terminal based game in Python from random import randint print('Terminal based number guessing game') while True: try: numberOfGames = int(input('Please choose how many games you want to play ---> ')) except: print('Only numbes accepted') continue if (numberOfGames > 0 and numberO...
normal
{ "blob_id": "20c081dc47f541a988bccef89b8e51f446c80f58", "index": 5471, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Terminal based number guessing game')\nwhile True:\n try:\n numberOfGames = int(input(\n 'Please choose how many games you want to play ---> '))\n except:\n...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Wed Apr 12 16:38:22 2017 @author: secoder """ import io import random import nltk from nltk.tokenize import RegexpTokenizer from sklearn.feature_extraction.text import CountVectorizer from sklearn.feature_extraction.text import TfidfTransformer from collections import Ordered...
normal
{ "blob_id": "4a8a733a965e25ad7ef53600fad6dd47343655b0", "index": 8677, "step-1": "<mask token>\n\n\nclass recommendationsys:\n\n def __init__(self, nyear):\n self.activityyear = 10\n self.debug = 0\n self.nremd = 3\n PROJECT_DIRECTORY = 'output/project/' + project_name\n sel...
[ 21, 25, 35, 43, 47 ]
# Cookies Keys class Cookies: USER_TOKEN = "utoken" # Session Keys class Session: USER_ROOT_ID = "x-root-id" class APIStatisticsCollection: API_ACTION = "x-stats-api-action" DICT_PARAMS = "x-stats-param-dict" DICT_RESPONSE = "x-stats-resp-dict" SUCCESS = "x-stats-success" ...
normal
{ "blob_id": "d0e5a3a6db0e27ecf157294850a48a19750a5ac2", "index": 1667, "step-1": "<mask token>\n\n\nclass Session:\n <mask token>\n\n\n class APIStatisticsCollection:\n API_ACTION = 'x-stats-api-action'\n DICT_PARAMS = 'x-stats-param-dict'\n DICT_RESPONSE = 'x-stats-resp-dict'\n ...
[ 3, 4, 5, 6, 7 ]
#!/usr/bin/python #encoding=utf8 import sys import tushare as ts def local_main(): if len(sys.argv) != 2: print sys.argv[0], " [stock id]" return stock_id = sys.argv[1] df = ts.get_hist_data(stock_id) df.to_excel(stock_id + '_his.xlsx', sheet_name = stock_id) if __name__ == '__main__...
normal
{ "blob_id": "81a53d08ab36e85dd49cf1f3d9c22c1f18605149", "index": 6233, "step-1": "#!/usr/bin/python\n#encoding=utf8\n\nimport sys\nimport tushare as ts\n\ndef local_main():\n if len(sys.argv) != 2:\n print sys.argv[0], \" [stock id]\"\n return\n\n stock_id = sys.argv[1]\n df = ts.get_hist_...
[ 0 ]
# from magicbot import AutonomousStateMachine, timed_state, state # from components.drivetrain import Drivetrain, DrivetrainState # from components.intake import Intake # from fieldMeasurements import FieldMeasurements # class PushBotAuto(AutonomousStateMachine): # # this auto is intended to push other robots of...
normal
{ "blob_id": "fdef3e94bbeb29c25bf14e17cd1d013cf848bedc", "index": 9456, "step-1": "# from magicbot import AutonomousStateMachine, timed_state, state\n\n# from components.drivetrain import Drivetrain, DrivetrainState\n# from components.intake import Intake\n\n# from fieldMeasurements import FieldMeasurements\n\n# ...
[ 1 ]
import re from collections import OrderedDict OPENING_TAG = '<{}>' CLOSING_TAG= '</{}>' U_LIST = '<ul>{}</ul>' LIST_ITEM = '<li>{}</li>' STRONG = '<strong>{}</strong>' ITALIC = '<em>{}</em>' PARAGRAPH = '<p>{}</p>' HEADERS = OrderedDict({'######': 'h6', '#####': 'h5', '###...
normal
{ "blob_id": "6b0b60ec571cf026d0f0cff3d9517362c16b459b", "index": 6092, "step-1": "<mask token>\n\n\ndef replace_bold_tags(l=''):\n line_with_bold = re.match('(.*)__(.*)__(.*)', l)\n if line_with_bold:\n return line_with_bold.group(1) + STRONG.format(line_with_bold.group(2)\n ) + line_with...
[ 5, 6, 8, 9, 10 ]
from django.urls import path,include from .import views urlpatterns = [ path('',views.home,name='home'), path('category/',include('api.category.urls')), path('product/',include('api.product.urls')), path('user/',include('api.user.urls')), path('order/',include('api.order.urls')), path('payment...
normal
{ "blob_id": "fe12f6d3408ab115c5c440c5b45a9014cfee6539", "index": 564, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.home, name='home'), path('category/', include\n ('api.category.urls')), path('product/', include('api.product.urls')),\n path('user/', include('api.user...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # Created by: Khang Le # Created on: Dec 2019 # This program uses lists and rotation def rotation(list_of_number, ratating_time): numbers = list_of_number[0] numbers = [list_of_number[(i + ratating_time) % len(list_of_number)] for i, x in enumerate(list_of_number)] ...
normal
{ "blob_id": "74de0da708c7eb792dea15afb23713d9d71af520", "index": 5491, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n lst = []\n user_input = int(input('Enter number of elements : '))\n rotating_time = int(input('Enter how many times you want to rotate: '))\n print('The numb...
[ 0, 1, 2, 3, 4 ]
import sys def main(stream=sys.stdin): """ Input, output, and parsing, etc. Yeah. """ num_cases = int(stream.readline().strip()) for i in xrange(num_cases): rows, cols = map(int, stream.readline().strip().split()) board = [] for r in xrange(rows): board = board +...
normal
{ "blob_id": "5bcfb0d4fd371a0882dd47814935700eed7885ec", "index": 6925, "step-1": "import sys\n\ndef main(stream=sys.stdin):\n \"\"\"\n Input, output, and parsing, etc. Yeah.\n \"\"\"\n num_cases = int(stream.readline().strip())\n for i in xrange(num_cases):\n rows, cols = map(int, stream.re...
[ 0 ]
from telegram.ext import Dispatcher,CommandHandler,CallbackQueryHandler import random from telegram import InlineKeyboardMarkup, InlineKeyboardButton gifGOODBOAT = 'https://media3.giphy.com/media/3oz8xRQiRlaS1XwnPW/giphy.gif' gifBADBOAT = 'https://media1.giphy.com/media/l2Je3n9VXC8z3baTe/giphy.gif' gifGOODMAN = 'https...
normal
{ "blob_id": "bc3e94c3fb8e563f62fcf0ca628d4aa73c668612", "index": 7097, "step-1": "<mask token>\n\n\ndef treasure(update, context):\n msg1 = \"\"\"\n 欢迎来到寻宝游戏!这是一场惊悚又危险追逐战,智慧,运气和勇气都是成功的关键!记得要避开海盗!读一读规则吧!\n 1. 系统会自动给你分配即将要发生的事,做好心理准备!\n 2. 好的外表不一定有好的结果...\n 3. 点击按钮开始寻宝!\n -----------------------\...
[ 2, 3, 4, 5, 6 ]
import unittest import math from python.src.sort.insertion import Insertion from python.src.sort.selection import Selection from python.src.sort.shell import Shell from python.test.util.utilities import Utilities class ElementarySortTest(unittest.TestCase): def setUp(self): self.n = 1000 def test_in...
normal
{ "blob_id": "779ef8942bfb55bf017a8da9dfe34c03ac574a9a", "index": 2591, "step-1": "<mask token>\n\n\nclass ElementarySortTest(unittest.TestCase):\n <mask token>\n\n def test_insertion_sort(self):\n insertion = Insertion()\n actual = Utilities.generate_random_array(self.n)\n expected = l...
[ 5, 6, 7, 8 ]
import unittest from datetime import datetime from models import * class Test_PlaceModel(unittest.TestCase): """ Test the place model class """ def setUp(self): self.model = Place() self.model.save() def test_var_initialization(self): self.assertTrue(hasattr(self.model, "...
normal
{ "blob_id": "c7881c0d06600a43bdc01f5e464127c596db6713", "index": 7993, "step-1": "<mask token>\n\n\nclass Test_PlaceModel(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_var_initialization(self):\n self.assertTrue(hasattr(self.model, 'city_id'))\n self.assertTrue(hasattr(sel...
[ 2, 4, 5, 6, 7 ]
import requests import json r = requests.get('http://pythonspot.com/') jsondata = str(r.headers).replace("'", '"') print(jsondata) #headerObj = json.loads(jsondata) #ERROR >> json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 556 (char 555) #print(headerObj)["server"] #print(headerObj)['content-leng...
normal
{ "blob_id": "7404dd324d54bb072e56985716bbae746b4dd219", "index": 1395, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(jsondata)\n", "step-3": "<mask token>\nr = requests.get('http://pythonspot.com/')\njsondata = str(r.headers).replace(\"'\", '\"')\nprint(jsondata)\n", "step-4": "import requests...
[ 0, 1, 2, 3, 4 ]
import numpy import matplotlib.pyplot as plt numpy.random.seed(2) # create datasets x = numpy.random.normal(3, 1, 100) y = numpy.random.normal(150, 40, 100) / x # displaying original dataset plt.scatter(x, y) plt.title("Original dataset") plt.xlabel("Minutes") plt.ylabel("Spent money") plt.show() # train dataset wi...
normal
{ "blob_id": "9fd985e9675514f6c8f3ac5b91962eb744e0e82c", "index": 6514, "step-1": "<mask token>\n", "step-2": "<mask token>\nnumpy.random.seed(2)\n<mask token>\nplt.scatter(x, y)\nplt.title('Original dataset')\nplt.xlabel('Minutes')\nplt.ylabel('Spent money')\nplt.show()\n<mask token>\nplt.scatter(train_x, trai...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python # view_rows.py - Fetch and display the rows from a MySQL database query # import the MySQLdb and sys modules # katja seltmann April 16, 2013 to run on arthropod data in scan symbiota database import MySQLdb import sys #connection information from mysql #test database connect = MySQLdb.connect("", u...
normal
{ "blob_id": "4d066a189bf5151534e0227e67cdc2eed5cd387c", "index": 6745, "step-1": "#!/usr/bin/python\n# view_rows.py - Fetch and display the rows from a MySQL database query\n# import the MySQLdb and sys modules\n# katja seltmann April 16, 2013 to run on arthropod data in scan symbiota database\n\nimport MySQLdb\...
[ 0 ]
# Generated by Django 3.2.7 on 2021-09-23 07:33 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('sms_consumer', '0006_auto_20210923_0733'), ] operations = [ migrations.RemoveField( model_name='smslogmodel', name='hello', ...
normal
{ "blob_id": "fc9742ceb3c38a5f8c1ad1f030d76103ba0a7a81", "index": 3857, "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 = [('sms_consume...
[ 0, 1, 2, 3, 4 ]
import os from multiprocessing import Pool import glob import click import logging import pandas as pd from src.resampling.resampling import Resampler # Default paths path_in = 'data/hecktor_nii/' path_out = 'data/resampled/' path_bb = 'data/bbox.csv' @click.command() @click.argument('input_folder', type=click.Pat...
normal
{ "blob_id": "3479276d4769518aa60dcd4e1bb41a8a1a7d6517", "index": 315, "step-1": "<mask token>\n\n\n@click.command()\n@click.argument('input_folder', type=click.Path(exists=True), default=path_in)\n@click.argument('output_folder', type=click.Path(), default=path_out)\n@click.argument('bounding_boxes_file', type=c...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python """This script draws a boxplot of each atom contribution to the cavity.""" import sys if sys.version < "2.7": print >> sys.stderr, "ERROR: This script requires Python 2.7.x. "\ "Please install it and try again." exit(1) try: import matplotlib.pyplot as pyp...
normal
{ "blob_id": "9fdcaf65f070b7081afd327442dd20e3284c71eb", "index": 7905, "step-1": "<mask token>\n\n\ndef parse_args():\n import argparse\n import os.path\n\n def isfile(path):\n Error = argparse.ArgumentTypeError\n if not os.path.exists(path):\n raise Error(\"No such file: '{0}'\...
[ 6, 7, 8, 11, 12 ]
# coding=utf-8 class Movie: def __init__(self,movieid,moviename,score,poster): self.movieid=movieid self.moviename=moviename self.score=score self.poster=poster for i in range(1,32): print("<option value =\""+str(i)+"\">"+str(i)+"</option>")
normal
{ "blob_id": "856e62cf4cd443c7b3397e926f8fc4fece145f5b", "index": 3447, "step-1": "<mask token>\n", "step-2": "class Movie:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Movie:\n\n def __init__(self, movieid, moviename, score, poster):\n self.movieid = movieid\n self.moviename = mo...
[ 0, 1, 2, 3, 4 ]
import numpy as np def layer_forward(x, w): """ input: - inputs (x): (N, d_1, ..., d_k), - weights (w): (D, M) """ # intermediate value (z) z = None output = [] cache = (x, w, z, output) return output, cache def layer_backward(d_output, cache): """ Re...
normal
{ "blob_id": "c1fd6e940b3b15ae01a102b3c0aba9bd327c77b2", "index": 8403, "step-1": "<mask token>\n\n\ndef layer_forward(x, w):\n \"\"\"\n input:\n - inputs (x): (N, d_1, ..., d_k),\n - weights (w): (D, M)\n \"\"\"\n z = None\n output = []\n cache = x, w, z, output\n r...
[ 4, 5, 6, 7, 8 ]
name = 'Ледяная скорбь' description = 'Тот кто держит этот клинок, должен обладать бесконечной силой. Подобно тому, как он разрывает плоть, он разрывает души.' price = 3000 fightable = True def fight_use(user, reply, room): return 200
normal
{ "blob_id": "7254e74ff3f562613cc610e4816a2d92b6b1cd4c", "index": 6074, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fight_use(user, reply, room):\n return 200\n", "step-3": "name = 'Ледяная скорбь'\ndescription = (\n 'Тот кто держит этот клинок, должен обладать бесконечной силой. Подобн...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python #coding:utf-8 ''' Created on 2016年8月29日 @author: lichen ''' def custom_proc(request): """ 自定义context_processors """ return { "context_test":"test" }
normal
{ "blob_id": "43ecb173e3d306284f2122410b5b74945572f683", "index": 8104, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef custom_proc(request):\n \"\"\"\n 自定义context_processors\n \"\"\"\n return {'context_test': 'test'}\n", "step-3": "#!/usr/bin/env python\n#coding:utf-8\n\n'''\nCreated...
[ 0, 1, 2 ]
""" 复习 面向对象:考虑问题从对象的角度出发. 抽象:从多个事物中,舍弃个别的/非本质的特征(不重要), 抽出共性的本质(重要的)过程。 三大特征: 封装:将每个变化点单独分解到不同的类中。 例如:老张开车去东北 做法:定义人类,定义车类。 继承:重用现有类的功能和概念,并在此基础上进行扩展。 统一概念 例如:图形管理器,统计圆形/矩形.....面积。 ...
normal
{ "blob_id": "2749a262bf8da99aa340e878c15a6dba01acc38c", "index": 7025, "step-1": "<mask token>\n", "step-2": "\"\"\"\n 复习\n 面向对象:考虑问题从对象的角度出发.\n 抽象:从多个事物中,舍弃个别的/非本质的特征(不重要),\n 抽出共性的本质(重要的)过程。\n 三大特征:\n 封装:将每个变化点单独分解到不同的类中。\n 例如:老张开车去东北\n ...
[ 0, 1 ]
import whoosh.index as index from whoosh.fields import * from whoosh.qparser import MultifieldParser from whoosh import scoring w = scoring.BM25F(B=0.75, content_B=1.0, K1=1.5) fieldnames = ["bill_text", "bill_title", "year", "sponsor_name", "subject"] boosts = {"bill_text": 1, "bill_title": 2.5, "year": 0, "sponsor_n...
normal
{ "blob_id": "6a400419c26c62471dfc6893cc2d1ff6d88e49f4", "index": 7518, "step-1": "import whoosh.index as index\nfrom whoosh.fields import *\nfrom whoosh.qparser import MultifieldParser\nfrom whoosh import scoring\n\nw = scoring.BM25F(B=0.75, content_B=1.0, K1=1.5)\nfieldnames = [\"bill_text\", \"bill_title\", \"...
[ 0 ]
from tkinter import * root = Tk() root.title("Calculator") e = Entry(root, width = 50, borderwidth = 5) e.grid(row = 0, column = 0, columnspan = 4, padx = 10, pady = 20) def button_click(number): digit = e.get() e.delete(0, END) e.insert(0, str(digit) + str(number)) def button_add(): global first_...
normal
{ "blob_id": "59a75f78c7a146dcf55d43be90f71abce2bcf753", "index": 4934, "step-1": "<mask token>\n\n\ndef button_add():\n global first_num\n global math\n math = 'addition'\n first_num = e.get()\n e.delete(0, END)\n\n\n<mask token>\n\n\ndef button_sub():\n global first_num\n global math\n m...
[ 4, 5, 6, 7, 11 ]
import pandas as pd import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimation import math from tkinter import * from tkinter.ttk import * from facedetectandtrack import * x_vals = [] root = Tk() counter=0 #def graph(): plt.style.use('seaborn') def animate(i): data = pd.read_csv('data.csv...
normal
{ "blob_id": "239f055fd76a3ecb5f384c256ad850ea42739b8f", "index": 9710, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.style.use('seaborn')\n\n\ndef animate(i):\n data = pd.read_csv('data.csv')\n global x_vals\n global counter\n x_vals.append(counter)\n try:\n x = data.iloc[x_val...
[ 0, 2, 3, 4, 5 ]
g=int(input()) num=0 while(g>0): num=num+g g=g-1 print(num)
normal
{ "blob_id": "8b18f098080c3f5773aa04dffaff0639fe7fa74f", "index": 8886, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile g > 0:\n num = num + g\n g = g - 1\nprint(num)\n", "step-3": "g = int(input())\nnum = 0\nwhile g > 0:\n num = num + g\n g = g - 1\nprint(num)\n", "step-4": "g=int(in...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import sys def add_them(a, b): return a + b def main(): print add_them(10, 21) if __name__ == '__main__': sys.exit(main())
normal
{ "blob_id": "aebf1d64923c5f325c9d429be092deaa06f20963", "index": 6232, "step-1": "#!/usr/bin/env python\n\nimport sys\n\ndef add_them(a, b):\n return a + b\n\ndef main():\n print add_them(10, 21)\n\nif __name__ == '__main__':\n sys.exit(main())\n", "step-2": null, "step-3": null, "step-4": null, ...
[ 0 ]
from rest_framework import viewsets from recruitment.serializers.LocationSerializer import LocationSerializer from recruitment.models.Location import Location import django_filters class LocationViewSet(viewsets.ModelViewSet): queryset = Location.objects.all().filter(deleted=0) serializer_class = LocationSer...
normal
{ "blob_id": "aef45cb8ea9fcaeffcca147da7637536bcc4b226", "index": 6217, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass LocationViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass LocationViewSet(viewsets.ModelViewSet):\n ...
[ 0, 1, 2, 3, 4 ]
import numpy as np import pandas as pd from scipy import sparse, io import cPickle as pickle import sys sys.path.append('code') import models import split from itertools import chain def test_simple_instance(items, item_numbers, negative_items, user): model = models.Word2VecRecommender(size=200, window=max(item_nu...
normal
{ "blob_id": "04dc4d46a645a23913e33606c500037d37418cd7", "index": 8114, "step-1": "import numpy as np\nimport pandas as pd\nfrom scipy import sparse, io\nimport cPickle as pickle\nimport sys\nsys.path.append('code')\nimport models\nimport split\nfrom itertools import chain\n\ndef test_simple_instance(items, item_...
[ 0 ]