code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
from django.db import models # Create your models here. STATUS_CHOICES=( ('Pending','Pending'), ('Completed','Completed')) class Appointment(models.Model): first_name=models.CharField(max_length=100) last_name=models.CharField(max_length=100) phone_number=models.CharField(max_length=12,null=False...
normal
{ "blob_id": "3343844bf49cb3f4d655613475e44a140ac3106d", "index": 4505, "step-1": "<mask token>\n\n\nclass Appointment(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.first_n...
[ 2, 3, 4, 5, 6 ]
c_horas=int(input("Ingrese la cantidad de horas trabajadas:")) v_horas=int(input("Ingrese el valor de cada hora trabajada:")) sueldo=c_horas*v_horas print("Su sueldo mensual sera") print(sueldo)
normal
{ "blob_id": "2e4b47b8c3ac4f187b32f1013a34c3bea354b519", "index": 6817, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Su sueldo mensual sera')\nprint(sueldo)\n", "step-3": "c_horas = int(input('Ingrese la cantidad de horas trabajadas:'))\nv_horas = int(input('Ingrese el valor de cada hora trabaj...
[ 0, 1, 2, 3 ]
class Solution: def containsDuplicate(self, nums) -> bool: d = {} # store the elements which already exist for elem in nums: if elem in d: return True else: d[elem] = 1 return False print(Solution().containsDuplicate([0]))
normal
{ "blob_id": "89256a38208be92f87115b110edc986cebc95306", "index": 8440, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "class Solution:\n\n def containsDuplicate(self, nums) ->bool:\n d = {}\n for elem in nums:\n if elem in ...
[ 0, 1, 2, 3, 4 ]
file_id = '0BwwA4oUTeiV1UVNwOHItT0xfa2M' request = drive_service.files().get_media(fileId=file_id) fh = io.BytesIO() downloader = MediaIoBaseDownload(fh, request) done = False while done is False: status, done = downloader.next_chunk() print "Download %d%%." % int(status.progress() * 100)
normal
{ "blob_id": "6b3f634f3f0108e678d44ef9c89150f9fd116f76", "index": 9471, "step-1": "file_id = '0BwwA4oUTeiV1UVNwOHItT0xfa2M'\nrequest = drive_service.files().get_media(fileId=file_id)\nfh = io.BytesIO()\ndownloader = MediaIoBaseDownload(fh, request)\ndone = False\nwhile done is False:\n status, done = downloade...
[ 0 ]
import os bind = '0.0.0.0:8000' workers = os.environ['GET_KEYS_ACCOUNTS_WORKERS']
normal
{ "blob_id": "d84a7e16471c604283c81412653e037ecdb19102", "index": 3530, "step-1": "<mask token>\n", "step-2": "<mask token>\nbind = '0.0.0.0:8000'\nworkers = os.environ['GET_KEYS_ACCOUNTS_WORKERS']\n", "step-3": "import os\nbind = '0.0.0.0:8000'\nworkers = os.environ['GET_KEYS_ACCOUNTS_WORKERS']\n", "step-4...
[ 0, 1, 2 ]
#!/usr/bin/env python3 from aws_cdk import core import os from ec2_ialb_aga_custom_r53.network_stack import NetworkingStack from ec2_ialb_aga_custom_r53.aga_stack import AgaStack from ec2_ialb_aga_custom_r53.alb_stack import ALBStack from ec2_ialb_aga_custom_r53.certs_stack import CertsStack from ec2_ialb_aga_custom_...
normal
{ "blob_id": "2f96e58a825744ae6baafd1bfb936210500f0fd0", "index": 6334, "step-1": "<mask token>\n", "step-2": "<mask token>\nec2.add_dependency(net)\n<mask token>\nalb.add_dependency(net)\nalb.add_dependency(ec2)\nalb.add_dependency(cert)\n<mask token>\naga.add_dependency(net)\naga.add_dependency(cert)\naga.add...
[ 0, 1, 2, 3, 4 ]
from const import BORN_KEY, PRESIDENT_KEY, CAPITAL_KEY, PRIME_KEY, MINISTER_KEY, POPULATION_KEY, \ GOVERNMENT_KEY,AREA_KEY, WHO_KEY, IS_KEY, THE_KEY, OF_KEY, WHAT_KEY, WHEN_KEY, WAS_KEY from geq_queries import capital_of_country_query, area_of_country_query, government_of_country_query, \ population_of_country...
normal
{ "blob_id": "18dce1ce683b15201dbb5436cbd4288a0df99c28", "index": 938, "step-1": "<mask token>\n\n\ndef get_last_argument(words):\n return ' '.join(words)[:-1]\n\n\n<mask token>\n\n\ndef parse_what_is_the(words):\n question_number = None\n arg = None\n if words[3] == POPULATION_KEY:\n question_...
[ 5, 6, 7, 8, 9 ]
def favorite_book(name): print(f"One of my favorite books is {name}...") favorite_book("Alice in Wonderland")
normal
{ "blob_id": "08848e51d5564bad927607be3fa3c86f2c1212c5", "index": 9668, "step-1": "<mask token>\n", "step-2": "def favorite_book(name):\n print(f'One of my favorite books is {name}...')\n\n\n<mask token>\n", "step-3": "def favorite_book(name):\n print(f'One of my favorite books is {name}...')\n\n\nfavor...
[ 0, 1, 2, 3 ]
x = '我是一个字符串' y = "我也是一个字符串" z = """我还是一个字符串""" #字符串str用单引号(' ')或双引号(" ")括起来 #使用反斜杠(\)转义特殊字符。 s = 'Yes,he doesn\'t' #如果你不想让反斜杠发生转义, #可以在字符串前面添加一个r,表示原始字符串 print('C:\some\name') print('C:\\some\\name') print(r'C:\some\name') #反斜杠可以作为续行符,表示下一行是上一行的延续。 s = "abcd\ efg" print(s) #还可以使用"""...""...
normal
{ "blob_id": "8fe9d21bb65b795a6633ab390f7f5d24a90146d5", "index": 6774, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('C:\\\\some\\name')\nprint('C:\\\\some\\\\name')\nprint('C:\\\\some\\\\name')\n<mask token>\nprint(s)\n<mask token>\nprint(s)\n", "step-3": "x = '我是一个字符串'\ny = '我也是一个字符串'\nz = '我还...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python """ Script to download and plot RaspberryShake station data Also computes and plots theoretical phase arrival times and raypaths. See https://docs.obspy.org/packages/obspy.taup.html for more info on Earth models and phase-nmaing nomenclature. Stephen Hicks Imperial College London Feb 2020 """ ...
normal
{ "blob_id": "8d8ea6ad7a3ed1a1e6e96ab75260ecf6e8211d32", "index": 1305, "step-1": "<mask token>\n", "step-2": "<mask token>\nst.merge()\nst.detrend(type='demean')\nst.remove_response()\nst.filter('bandpass', freqmin=F1, freqmax=F2, corners=4)\nst.trim(t1, t2)\n<mask token>\nplt.suptitle(LABEL)\n<mask token>\nax...
[ 0, 1, 2, 3, 4 ]
''' Created on 18/10/2012 @author: matthias ''' import os import errno import uuid import glob import shutil import sys import subprocess import time import pickle import common.pbs def prepare_directories(options, extension, subversiondir=None): # extract datadir from options datadir = options['datadir'] ...
normal
{ "blob_id": "6aeaa2ed01e0c0dac54cd8220c5da005fccc53e9", "index": 2609, "step-1": "<mask token>\n\n\ndef prepare_directories(options, extension, subversiondir=None):\n datadir = options['datadir']\n print('Creating directory {0:s}.'.format(datadir + extension))\n try:\n os.makedirs(datadir + exten...
[ 1, 2, 3, 4, 5 ]
import pytesseract from PIL import Image img = Image.open("flag.png") text = pytesseract.image_to_string(img) def rot(*symbols): def _rot(n): encoded = ''.join(sy[n:] + sy[:n] for sy in symbols) lookup = str.maketrans(''.join(symbols), encoded) return lambda s: s.translate(lookup) re...
normal
{ "blob_id": "b7a60322b4a0fcb6de16cd12be33db265a2b8746", "index": 2735, "step-1": "<mask token>\n\n\ndef rot(*symbols):\n\n def _rot(n):\n encoded = ''.join(sy[n:] + sy[:n] for sy in symbols)\n lookup = str.maketrans(''.join(symbols), encoded)\n return lambda s: s.translate(lookup)\n re...
[ 1, 4, 5, 6, 7 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jan 25 18:40:07 2021 @author: tomachache """ import numpy as np from qiskit import * # Various state preparation def state_preparation(m, name, p): # m : nb of qubits # name : name of the state we want # p : proba associated with nois...
normal
{ "blob_id": "6962bf99e3ecae473af54ded33fde09527cb82c0", "index": 8284, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef state_preparation(m, name, p):\n circ = QuantumCircuit(m, name='State prep')\n if name == 'GHZ':\n circ.h(0)\n for k in range(1, m):\n circ.cx(0, k)...
[ 0, 1, 2, 3 ]
import numpy as np import math a = [ [0.54, -0.04, 0.10], [-0.04, 0.50, 0.12], [0.10, 0.12, 0.71] ] b = [0.33, -0.05, 0.28] # Метод Гаусса def gauss(left, right, prec=3): # Создаем расширенную матрицу arr = np.concatenate((np.array(left), np.array([right]).T), axis=1) print('\nИсходная матриц...
normal
{ "blob_id": "bd0530b6f3f7b1a5d72a5b11803d5bb82f85105d", "index": 6587, "step-1": "<mask token>\n\n\ndef gauss(left, right, prec=3):\n arr = np.concatenate((np.array(left), np.array([right]).T), axis=1)\n print('\\nИсходная матрица:')\n print(arr)\n if np.linalg.matrix_rank(left) != np.linalg.matrix_r...
[ 4, 6, 7, 9, 10 ]
import arcade import os SPRITE_SCALING = 0.5 SCREEN_WIDTH = 800 SCREEN_HEIGHT = 600 SCREEN_TITLE = "Raymond Game" MOVEMENT_SPEED = 50 class Ball: def __init__(self, position_x, position_y, change_x, change_y, radius): # Take the parameters of the init function above, and create instance variables ou...
normal
{ "blob_id": "37d079ca6a22036e2660507f37442617d4842c4e", "index": 4060, "step-1": "<mask token>\n\n\nclass MyGame(arcade.Window):\n\n def __init__(self, width, height, title):\n super().__init__(width, height, title)\n self.drawer = 0\n self.wardrobe = 0\n self.bookshelves = 0\n ...
[ 6, 8, 12, 13, 15 ]
from enum import Enum class CellState(Enum): EMPTY = 1 DEAD = 2 ALIVE = 3 WAS_ALIVE = 4 def __str__(self): default_str = super(CellState, self).__str__() if default_str == "CellState.EMPTY": return "E" elif default_str == "CellState.DEAD": return "D" elif default_str...
normal
{ "blob_id": "29bee4ef11281380aa05d22ef54cb76502ecd685", "index": 466, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CellState(Enum):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n default_str = super(CellState, self).__str__()\n ...
[ 0, 2, 3, 4, 5 ]
from unittest import TestCase from tests import AuthHelperTestCase class TestTestHelper(TestCase): """ Test our helper functions """ def test_assertAnyIn_fails(self): """ Make sure assertInAny fails correctly :return: """ test_case = AuthHelperTestCase('asser...
normal
{ "blob_id": "ae1aab7563443db3a31fe98b5b26b32944d57c9d", "index": 1473, "step-1": "<mask token>\n\n\nclass TestTestHelper(TestCase):\n <mask token>\n <mask token>\n\n def test_assertAnyIn_suceeds(self):\n \"\"\"\n Make sure assertInAny succeeds\n \n :return: \n \"\"\"\n...
[ 2, 3, 4, 5 ]
''' held-karp.py Implementation of the Bellman-Held-Karp Algorithm to exactly solve TSPs, requiring no external dependencies. Includes a purely recursive implementation, as well as both top-down and bottom-up dynamic programming approaches. ''' import sys def held_karp_recursive(distance_matrix): ''' Soluti...
normal
{ "blob_id": "3e8fa71c4e23348c6f00fe97729b5717bb6245a1", "index": 8070, "step-1": "<mask token>\n\n\ndef held_karp_bottomup(distance_matrix):\n \"\"\"\n In the bottom up implementation, we compute all possible solutions for the\n values `i` and `visited` as in the implementations above, and then\n sim...
[ 5, 8, 9, 10, 12 ]
import pandas as pd import numpy as np #I'm adding these too avoid any type of na value. missing_values = ["n/a", "na", "--", " ?","?"] # Name Data Type Meas. Description # ---- --------- ----- ----------- # Sex nominal M, F, and I (infant) # Length continuous mm Longest shell measurement # Diameter con...
normal
{ "blob_id": "1b773f2ca01f07d78d2d7edc74cd2df6630aa97a", "index": 4968, "step-1": "<mask token>\n\n\ndef tt(X, y, sample):\n X_train, X_valid, y_train, y_valid = train_test_split(X, y, train_size=\n sample, random_state=1)\n return {'X_train': X_train, 'X_valid': X_valid, 'y_train': y_train,\n ...
[ 1, 2, 3, 4, 5 ]
# from dataclasses import InitVar, dataclass # standard library imports from math import floor # third-party imports import gym import torch from torch.nn import Conv2d, Linear, MaxPool2d, Module, ModuleList, ReLU, Sequential from torch.nn import functional as F # local imports from tmrl.nn import TanhNormalLayer fro...
normal
{ "blob_id": "6f6d3fbb9a6a118e0f4026a7f9054b90b8cf2fca", "index": 5677, "step-1": "<mask token>\n\n\nclass BigCNN(Module):\n\n def __init__(self, h_in, w_in, channels_in):\n super(BigCNN, self).__init__()\n self.h_out, self.w_out = h_in, w_in\n self.conv1 = Conv2d(channels_in, 64, 8, strid...
[ 14, 16, 19, 22, 24 ]
#!/usr/bin/python2.7 # -*- coding: utf-8 -*- """ # @Time : 20-6-9 上午11:47 # @Author : zhufa # @Software: PyCharm """ """ tensorflow version must below 1.15 """ import numpy as np import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", ...
normal
{ "blob_id": "779e7cd05edfd74c8e60eaf5ce8443aea5fdaaef", "index": 8028, "step-1": "#!/usr/bin/python2.7\n# -*- coding: utf-8 -*-\n\n\"\"\"\n# @Time : 20-6-9 上午11:47\n\n# @Author : zhufa\n\n# @Software: PyCharm\n\"\"\"\n\"\"\"\ntensorflow version must below 1.15\n\"\"\"\n\nimport numpy as np\nimport tensorflow...
[ 0 ]
cars=100 drivers=30 passengers=70 print "There are",cars,"cars available." print "There are only",drivers,"drivers available." print "Each driver needs to drive",passengers/drivers-1,"passengers."
normal
{ "blob_id": "b1a1287c2c3b624eb02f2955760f6e9eca8cdcf9", "index": 1241, "step-1": "cars=100\ndrivers=30\npassengers=70\nprint \"There are\",cars,\"cars available.\"\nprint \"There are only\",drivers,\"drivers available.\"\nprint \"Each driver needs to drive\",passengers/drivers-1,\"passengers.\"\n", "step-2": n...
[ 0 ]
import sys V, E = map(int, sys.stdin.readline().split()) node = [] graphs = [] for i in range(V+1): node.append(i) for _ in range(E): graphs.append((list(map(int, sys.stdin.readline().split())))) graph = sorted(graphs, key=lambda x: x[2]) def get_parent(parent, x): if parent[x] == x: return x ...
normal
{ "blob_id": "2e794e281c6f34858cd32725cdc454eb18c28892", "index": 3415, "step-1": "<mask token>\n\n\ndef get_parent(parent, x):\n if parent[x] == x:\n return x\n parent[x] = get_parent(parent, parent[x])\n return parent[x]\n\n\ndef union_parent(parent, a, b):\n a = get_parent(parent, a)\n b ...
[ 2, 3, 4, 5, 6 ]
#https://www.acmicpc.net/problem/2581 def isPrime(x): if x==1: return False for d in range(1,int(x**0.5)): if x==d+1: continue if x%(d+1)==0: return False else: return True N=int(input()) M=int(input()) sum=0 min=10001 for x in range(N,M+1): if i...
normal
{ "blob_id": "37d465043eddd34c4453fd7e31b08d0ba58b725f", "index": 4351, "step-1": "<mask token>\n", "step-2": "def isPrime(x):\n if x == 1:\n return False\n for d in range(1, int(x ** 0.5)):\n if x == d + 1:\n continue\n if x % (d + 1) == 0:\n return False\n e...
[ 0, 1, 2, 3, 4 ]
import uuid from aliyunsdkcore.client import AcsClient from aliyunsdkcore.profile import region_provider # 注意:不要更改 from celery_tasks.sms.dysms_python.build.lib.aliyunsdkdysmsapi.request.v20170525 import SendSmsRequest class SendMes(object): REGION = "cn-hangzhou" PRODUCT_NAME = "Dysmsapi" DOMAIN = "dysmsapi.aliy...
normal
{ "blob_id": "daecbf5280c199b31f3b9d9818df245d9cd165a7", "index": 4295, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SendMes(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n region_provider.add_endpoint(PRODUCT_NAME, REGI...
[ 0, 1, 3, 4, 5 ]
#case1 print("My name is Jia-Chi. \nI have an older sister. \nI prefer Coke.\nMy favorite song is \"Amazing Grace\"") #case2 print('''Liang, Jia-Chi 1 Coke Amazing Grace''')
normal
{ "blob_id": "55986f6c2dafe650704660142cf85640e763b26d", "index": 3291, "step-1": "<mask token>\n", "step-2": "print(\n \"\"\"My name is Jia-Chi. \nI have an older sister. \nI prefer Coke.\nMy favorite song is \"Amazing Grace\\\"\"\"\"\n )\nprint(\"\"\"Liang, Jia-Chi\n1\nCoke\nAmazing Grace\"\"\")\n", "...
[ 0, 1, 2 ]
# https://github.com/openai/gym/blob/master/gym/envs/__init__.py#L449 import gym import numpy as np from rl_main.conf.names import EnvironmentName, DeepLearningModelName from rl_main.environments.environment import Environment from rl_main.main_constants import DEEP_LEARNING_MODEL class BreakoutDeterministic_v4(Envi...
normal
{ "blob_id": "05e57ed95427f0de74ea5b0589c5cd56e4a96f73", "index": 8776, "step-1": "<mask token>\n\n\nclass BreakoutDeterministic_v4(Environment):\n\n def __init__(self):\n self.env = gym.make(EnvironmentName.BREAKOUT_DETERMINISTIC_V4.value)\n super(BreakoutDeterministic_v4, self).__init__()\n ...
[ 9, 11, 16, 17, 18 ]
from LAMARCK_ML.data_util import ProtoSerializable class NEADone(Exception): pass class NoSelectionMethod(Exception): pass class NoMetric(Exception): pass class NoReproductionMethod(Exception): pass class NoReplaceMethod(Exception): pass class ModelInterface(ProtoSerializable): def reset(self): ...
normal
{ "blob_id": "501b8a9307a1fd65a5f36029f4df59bbe11d881a", "index": 6591, "step-1": "<mask token>\n\n\nclass ModelInterface(ProtoSerializable):\n\n def reset(self):\n raise NotImplementedError()\n pass\n\n def run(self):\n raise NotImplementedError()\n\n def stop(self):\n raise ...
[ 9, 10, 13, 14, 16 ]
from manimlib.imports import * import math class A_Swerve(Scene): def construct(self): chassis = Square(side_length=2, stroke_width=0, fill_color=GRAY, fill_opacity=1).shift(2*RIGHT) fr = Dot().shift(UP+3*RIGHT) fl = Dot().shift(UP+RIGHT) rl = Dot().shift(DOWN+RIGHT) rr = Dot().shift(DOWN+3*RIGH...
normal
{ "blob_id": "bdde3a3725510d4a83b09421e4b8538a38e29584", "index": 8196, "step-1": "<mask token>\n\n\nclass A_Swerve(Scene):\n\n def construct(self):\n chassis = Square(side_length=2, stroke_width=0, fill_color=GRAY,\n fill_opacity=1).shift(2 * RIGHT)\n fr = Dot().shift(UP + 3 * RIGHT)\...
[ 2, 3, 4, 5, 6 ]
import os import time from datetime import datetime, timedelta from git import Repo class CommitAnalyzer(): """ Takes path of the repo """ def __init__(self, repo_path): self.repo_path = repo_path self.repo = Repo(self.repo_path) assert not self.repo.bare def get_conflict_commits(self): conflict_commits...
normal
{ "blob_id": "8479c70fed36dc6f1e6094c832fb22d8c2e53e3a", "index": 920, "step-1": "<mask token>\n\n\nclass CommitAnalyzer:\n <mask token>\n\n def __init__(self, repo_path):\n self.repo_path = repo_path\n self.repo = Repo(self.repo_path)\n assert not self.repo.bare\n <mask token>\n\n\n...
[ 2, 5, 6, 7, 8 ]
alien_0 = {} # 声明一个空字典 alien_0['color'] = 'green' # 向空字典中添加值 alien_0['points'] = 5 print(alien_0) x = alien_0['color'] print(f"\nThe alien is {alien_0['color']}") # 引号的用法 alien_0['color'] = 'yellow' # 对字典中的元素重新赋值 print(f"The alien is now {alien_0['color']}")
normal
{ "blob_id": "f4dd9500835cb22a859da8bd57487052522bb593", "index": 7697, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(alien_0)\n<mask token>\nprint(f\"\"\"\nThe alien is {alien_0['color']}\"\"\")\n<mask token>\nprint(f\"The alien is now {alien_0['color']}\")\n", "step-3": "alien_0 = {}\nalien_0['...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- ''' :Title Insert Date :Planguage Python :Requires VoodooPad 3.5+ :Description Inserts Date EOD ''' VPScriptSuperMenuTitle = "GTD" VPScriptMenuTitle = "Insert Date" VPShortcutMask = "control" VPShortcutKey = "J" import AppKit import time def main(windowController, *args, **kwargs): te...
normal
{ "blob_id": "e51ca78ca6751f8238a39d3eae55d6cc6ab65128", "index": 5797, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main(windowController, *args, **kwargs):\n textView = windowController.textView()\n document = windowController.document()\n if textView != None:\n dateFormat = ti...
[ 0, 1, 2, 3, 4 ]
import numpy as np from nn.feedforward_nn import Feed_Forward class RMSprop(object): def __init__(self,n_in,n_hid,n_out,regularization_coe): self.nn = Feed_Forward(n_in,n_hid,n_out,regularization_coe) def set_param(self,param): if 'learning_rate' in param.keys(): self.learning_rat...
normal
{ "blob_id": "f971302f39149bcdcbe4237cc71219572db600d4", "index": 8720, "step-1": "<mask token>\n\n\nclass RMSprop(object):\n\n def __init__(self, n_in, n_hid, n_out, regularization_coe):\n self.nn = Feed_Forward(n_in, n_hid, n_out, regularization_coe)\n <mask token>\n <mask token>\n <mask toke...
[ 2, 4, 5, 6, 7 ]
import math import datetime import numpy as np import matplotlib.pyplot as plt def draw_chat( id, smooth_id, main_mode, my_name, chat_day_data, main_plot, pie_plot, list_chats_plot): min_in_day = 1440 possible_smooth = [1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, 16, 18, 20, 24, 30, 32, 36, 40, 45, 48, ...
normal
{ "blob_id": "b297a09ee19bb8069eb65eb085903b3219c6fe5a", "index": 7971, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef draw_chat(id, smooth_id, main_mode, my_name, chat_day_data, main_plot,\n pie_plot, list_chats_plot):\n min_in_day = 1440\n possible_smooth = [1, 2, 3, 4, 5, 6, 8, 9, 10, ...
[ 0, 1, 2, 3 ]
#公路工程工程量清单编码默认格式母节点为数字型式,子节点为-b字母形式,为使编码唯一便于数据处理,编制此脚本 import re import pandas as pd import os def get_csv_path():#原编码保存为csv文件的一列,便于读取 path=input('enter csv path:') if os.path.isfile(path): return path else: print('csv file not exsit,try again:') return get_csv_path() def unique_code...
normal
{ "blob_id": "857e3e04b99cb346fd89b34c0d14957d65b7ac38", "index": 9566, "step-1": "<mask token>\n\n\ndef get_csv_path():\n path = input('enter csv path:')\n if os.path.isfile(path):\n return path\n else:\n print('csv file not exsit,try again:')\n return get_csv_path()\n\n\n<mask toke...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Created on Sat Sep 29 19:10:06 2018 @author: labuser """ # 2018-09-29 import os import numpy as np from scipy.stats import cauchy from scipy.optimize import curve_fit import matplotlib.pyplot as plt import pandas as pd def limit_scan(fname, ax): data = pd.read_csv(fname, sep='\t', ...
normal
{ "blob_id": "aee8fa7bc1426945d61421fc72732e43ddadafa1", "index": 3191, "step-1": "<mask token>\n\n\ndef cauchy_model(x, a, loc, scale, y0):\n return a * cauchy.pdf(x, loc, scale) + y0\n\n\ndef cauchy_fit(x, y, d):\n if d is -1:\n a0 = -(max(y) - min(y)) * (max(x) - min(x)) / 10\n loc0 = x[np....
[ 4, 7, 8, 9, 10 ]
""" Exercício 1 - Facebook Você receberá uma lista de palavras e uma string . Escreva uma função que decida quais palavras podem ser formadas com os caracteres da string (cada caractere só pode ser utilizado uma vez). Retorne a soma do comprimento das palavras escolhidas. Exemplo 1: """ # words = ["cat", "bt", "hat", ...
normal
{ "blob_id": "bf7e3ddaf66f4c325d3f36c6b912b47f4ae22cba", "index": 4779, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef count_words(words, chars):\n ans = 0\n alphabet = {}\n for char in chars:\n if char not in alphabet:\n alphabet[char] = 1\n else:\n al...
[ 0, 1, 2, 3, 4 ]
from django.shortcuts import render, redirect from datetime import datetime from fichefrais.models import FicheFrais, Etat, LigneFraisForfait, LigneFraisHorsForfait, Forfait def home_admin(request): """ :view home_admin: Menu principale des Administrateurs :template home_admin.html: """ if not re...
normal
{ "blob_id": "b453c8e9cc50066d1b5811493a89de384a000f37", "index": 4929, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef home_admin(request):\n \"\"\"\n :view home_admin: Menu principale des Administrateurs\n :template home_admin.html:\n \"\"\"\n if not request.user.is_authenticated()...
[ 0, 1, 2, 3 ]
from trytond.pool import Pool from .reporte import MyInvoiceReport def register(): Pool.register(MyInvoiceReport, module='cooperar-reporte-factura', type_ ='report')
normal
{ "blob_id": "a52e0dde47d7df1b7b30887a690b201733ac7592", "index": 4473, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef register():\n Pool.register(MyInvoiceReport, module='cooperar-reporte-factura', type_\n ='report')\n", "step-3": "from trytond.pool import Pool\nfrom .reporte import M...
[ 0, 1, 2 ]
# -*- coding:utf-8 -*- import requests import json def fun1(): s_cut = [('72af8ecf3609a546bac3150c20f70455', ['老凤祥', '六福珠宝', '周生生', '亚一珠宝', '亚一金店']), ('3e78397f7dbb88ffbd78ba52d0e925fa', ['老庙', '谢瑞麟', '中国黄金', '明牌珠宝']), # yh ('6bee32b2f0719ea45cc194847efd8917', ['周大福', '潮宏基', '东华美钻', '周...
normal
{ "blob_id": "66f8fa5fc12dc80b8f46684c39781c2e4634de4a", "index": 3479, "step-1": "<mask token>\n\n\ndef fun1():\n s_cut = [('72af8ecf3609a546bac3150c20f70455', ['老凤祥', '六福珠宝', '周生生',\n '亚一珠宝', '亚一金店']), ('3e78397f7dbb88ffbd78ba52d0e925fa', ['老庙', '谢瑞麟',\n '中国黄金', '明牌珠宝']), ('6bee32b2f0719ea45cc1...
[ 1, 2, 3, 4, 5 ]
#create a list a = [2,3,4,5,6,7,8,9,10] print(a) #indexing b = int(input('Enter indexing value:')) print('The result is:',a[b]) print(a[8]) print(a[-1]) #slicing print(a[0:3]) print(a[0:]) #conconteation b=[20,30] print(a+b) #Repetition print(b*3) #updating print(a[2]) a[2]=100 print(a) #membership print(5 in a) ...
normal
{ "blob_id": "f7d29dd1d990b3e07a7c07a559cf5658b6390e41", "index": 4601, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a)\n<mask token>\nprint('The result is:', a[b])\nprint(a[8])\nprint(a[-1])\nprint(a[0:3])\nprint(a[0:])\n<mask token>\nprint(a + b)\nprint(b * 3)\nprint(a[2])\n<mask token>\nprint(a...
[ 0, 1, 2, 3 ]
from urllib.request import urlopen from bs4 import BeautifulSoup import re url = input('Enter - ') html = urlopen(url).read() soup = BeautifulSoup(html, "html.parser") tags = soup.find_all('tr', {'id': re.compile(r'nonplayingnow.*')}) for i in tags: casa = i.find("td", {'class': re.compile(r'team-home')}).find(...
normal
{ "blob_id": "d07a26a69ccbbccf61402632dd6011315e0d61ed", "index": 2710, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in tags:\n casa = i.find('td', {'class': re.compile('team-home')}).find('a')\n visitante = i.find('td', {'class': re.compile('team-away')}).find('a')\n print('Partido-> ' +...
[ 0, 1, 2, 3, 4 ]
import re # regex module from ftplib import FTP, error_perm from itertools import groupby from typing import List, Tuple, Dict import requests # HTTP requests module from util import retry_multi, GLOBAL_TIMEOUT # from util.py class ReleaseFile: """! Class representing a Released file on Nebula `name`: str...
normal
{ "blob_id": "612b1851ba5a07a277982ed5be334392182c66ef", "index": 4064, "step-1": "<mask token>\n\n\nclass ReleaseFile:\n <mask token>\n <mask token>\n\n def __repr__(self):\n return repr(self.name)\n\n\nclass SourceFile:\n \"\"\"! Class represeting a source file\n\n `name`: str\n Fil...
[ 8, 10, 11, 12, 14 ]
import itertools def sevens_in_a_row(arr,n): in_a_row={} for iteration in arr: if arr[iteration]==arr[iteration+1]: print blaaa def main(): n=3 arr=['1','1','1','2','3','-4'] print (sevens_in_a_row(arr,n)) if __name__== '__main__': main()
normal
{ "blob_id": "a2626b384d0b7320ee9bf7cd75b11925ccc00666", "index": 9399, "step-1": "import itertools\ndef sevens_in_a_row(arr,n):\n\tin_a_row={}\n\tfor iteration in arr:\n\t\tif arr[iteration]==arr[iteration+1]:\n\t\t\tprint blaaa\n\t\t\t\n\ndef main():\n\tn=3\n\tarr=['1','1','1','2','3','-4']\n\tprint (sevens_in_...
[ 0 ]
class Graph(): def __init__(self, nvertices): self.N = nvertices self.graph = [[0 for column in range(nvertices)] for row in range(nvertices)] self.V = ['0' for column in range(nvertices)] def nameVertex(self): for i in range(self.N): pr...
normal
{ "blob_id": "51a8b963047215bf864eb4a3e62beb5741dfbafe", "index": 8572, "step-1": "class Graph:\n\n def __init__(self, nvertices):\n self.N = nvertices\n self.graph = [[(0) for column in range(nvertices)] for row in range\n (nvertices)]\n self.V = ['0' for column in range(nverti...
[ 3, 5, 6, 7, 8 ]
print("Enter string:") s=input() a = s.lower() vowels = "aeiou" consonants = "bcdfghjklmnpqrstvwxyz" digits = "1234567890" whitespace = " " c = 0 v = 0 d = 0 ws= 0 for i in a: if i in vowels: v+=1 elif i in consonants: c+=1 elif i in digits: d+=1 elif i in whitespace: ...
normal
{ "blob_id": "088c77e090d444e7057a91cac606995fb523c8ef", "index": 3079, "step-1": "<mask token>\n", "step-2": "print('Enter string:')\n<mask token>\nfor i in a:\n if i in vowels:\n v += 1\n elif i in consonants:\n c += 1\n elif i in digits:\n d += 1\n elif i in whitespace:\n ...
[ 0, 1, 2, 3 ]
class Solution(object): def moveZeroes(self, nums): """ 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 --- 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] --- 思路; :type nums: List[int] :rtype: void Do not return anything, modify nums in-place instead. """ num = nums.count(0) while 0 i...
normal
{ "blob_id": "ece80a7765674f9d2991029bb86486b616a90f58", "index": 3944, "step-1": "<mask token>\n", "step-2": "class Solution(object):\n <mask token>\n", "step-3": "class Solution(object):\n\n def moveZeroes(self, nums):\n \"\"\"\n\t\t给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。\n\t\t---\n\t\t...
[ 0, 1, 2 ]
#Developer: Chritian D. Goyes ''' this script show your name and your age. ''' myName = 'Christian D. Goyes' myDate = 1998 year = 2020 age = year - myDate print ("yourname is: ", age, "and your are", "years old")
normal
{ "blob_id": "f5331b56abea41873bd3936028471d0da1c58236", "index": 4986, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('yourname is: ', age, 'and your are', 'years old')\n", "step-3": "<mask token>\nmyName = 'Christian D. Goyes'\nmyDate = 1998\nyear = 2020\nage = year - myDate\nprint('yourname is:...
[ 0, 1, 2, 3 ]
import logging, numpy as np, time, pandas as pd from abc import abstractmethod from kombu import binding from tqdm import tqdm from functools import lru_cache from threading import Thread from math import ceil from copy import copy from .pos import Position from .base import BaseConsumer from .event import SignalEven...
normal
{ "blob_id": "76d166bc227986863db77aa784be3de8110437ff", "index": 530, "step-1": "<mask token>\n\n\nclass BaseStrategy(BaseConsumer):\n <mask token>\n <mask token>\n\n @abstractmethod\n def calculate_signals(self):\n \"\"\"Provide the mechanism to calculate a list of signals\"\"\"\n rais...
[ 18, 19, 28, 30, 32 ]
"""Get pandas dataframes for a given data and month. *get_dataframes(csvfile, spec=SPEC)* is a function to get dataframes from *csvfile* connection under *spec* parsing instruction. *Vintage* class addresses dataset by year and month: Vintage(year, month).save() Vintage(year, month).validate() *Collecti...
normal
{ "blob_id": "e78c4f65d84d5b33debb415005e22f926e14d7d4", "index": 1203, "step-1": "<mask token>\n\n\nclass Vintage:\n <mask token>\n\n def __init__(self, year, month):\n self.year, self.month = year, month\n self.csv = LocalCSV(year, month)\n <mask token>\n <mask token>\n <mask token>...
[ 9, 13, 14, 15, 19 ]
import pygame, states, events from settings import all as settings import gui def handleInput(world, event): if event == events.btnSelectOn or event == events.btnEscapeOn: bwd(world) if event%10 == 0: world.sounds['uiaction'].play(0) # world.shouldRedraw = True def bwd(world): if wor...
normal
{ "blob_id": "8650e0f1e7f2ac42c3c78191f79810f5befc9f41", "index": 3298, "step-1": "<mask token>\n\n\ndef bwd(world):\n if world.state >= states.Config:\n return left(world)\n world.shouldRedraw = True\n world.state = states.Intro\n\n\ndef draw(world):\n if not world.shouldRedraw:\n retur...
[ 2, 3, 4, 5, 6 ]
# Generated by Django 3.1.7 on 2021-03-20 14:31 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('restapp', '0021_auto_20210320_1421'), ] operations = [ migrations.AddField( model_name='order', name='phone', ...
normal
{ "blob_id": "bf160bd2fc924a11d340bd466b4a879d1cdcd86e", "index": 7639, "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 = [('restapp', '...
[ 0, 1, 2, 3, 4 ]
#This file was created by Tate Hagan from RootGUI import RootGUI root = RootGUI() root.mainloop()
normal
{ "blob_id": "d17081ef94df1e14308128341d040559edb81805", "index": 7100, "step-1": "<mask token>\n", "step-2": "<mask token>\nroot.mainloop()\n", "step-3": "<mask token>\nroot = RootGUI()\nroot.mainloop()\n", "step-4": "from RootGUI import RootGUI\nroot = RootGUI()\nroot.mainloop()\n", "step-5": "#This fil...
[ 0, 1, 2, 3, 4 ]
import requests import json from concurrent import futures from tqdm import trange def main(): ex=futures.ThreadPoolExecutor(max_workers=50) for i in trange(1,152): url="https://api.bilibili.com/pgc/season/index/result?season_version=-1&" \ "area=-1&is_finish=-1&copyright=-1&season...
normal
{ "blob_id": "ff8b6bc607dac889da05b9f7e9b3595151153614", "index": 7358, "step-1": "<mask token>\n\n\ndef index_page(url):\n res = requests.get(url)\n res.encoding = res.apparent_encoding\n next_page(res.text)\n\n\ndef next_page(html):\n data = json.loads(html)\n for i in data['data']['list']:\n ...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt from matplotlib.font_manager import FontProperties from sklearn import svm data=np.loadtxt('yucedata1.txt') X=data[:,0] y=data[:,1] plt.figure(1,figsize=(8,6)) myfont = FontProperties(fname=r"c:\windo...
normal
{ "blob_id": "73d7b1895282df5b744d8c03ec7e6f8530366b76", "index": 865, "step-1": "# -*- coding: utf-8 -*-\r\nimport numpy as np\r\nimport matplotlib as mpl\r\nimport matplotlib.pyplot as plt \r\nfrom matplotlib.font_manager import FontProperties \r\nfrom sklearn import svm\r\n\r\n\r\ndata=np.loadtxt('yucedata1.tx...
[ 0 ]
# website = urlopen("https://webservices.ulm.edu/forms/forms-list") # data = bs(website, "lxml") # forms = data.findAll("span", {"class": "file"}) # forms_list = [] # names = [] # for f in forms: # forms_list.append(f.find("a")["href"]) # names.append(f.get_text()) # # print(forms_list) # for f in forms_list:...
normal
{ "blob_id": "a61f351391ca1b18359323fd9e49f1efa4c7513c", "index": 4007, "step-1": "<mask token>\n\n\ndef main():\n website = input('Enter the website you want to download file from: ')\n div = input('Enter the div/span (be as specific as you can): ')\n classTag = input('Enter the class/id tag you want to...
[ 1, 2, 3, 4, 5 ]
""" @author Lucas @date 2019/3/29 21:46 """ # 二分查找 def search(nums, target): left = 0 right = len(nums) - 1 while left <= right: mid = int((left + right)/2) if target > nums[mid]: left = mid + 1 elif target < nums[mid]: right = mid - 1 else: ...
normal
{ "blob_id": "3eeed39bf775e2ac1900142b348f20d15907c6e6", "index": 4972, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef search(nums, target):\n left = 0\n right = len(nums) - 1\n while left <= right:\n mid = int((left + right) / 2)\n if target > nums[mid]:\n left =...
[ 0, 1, 2, 3 ]
# -*- Python -*- # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # California Institute of Technology # (C) 2008 All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ...
normal
{ "blob_id": "721e014bc5bf53a39556e31f281b77b90508cf12", "index": 7138, "step-1": "<mask token>\n\n\nclass Retriever(base):\n\n def _retrieveResultsFor(self, computation):\n director = self.director\n db = director.clerk.db\n orm = director.clerk.orm\n analysisObj = orm.record2objec...
[ 2, 3, 4, 5, 6 ]
from pull_links import pull_links from scrape_lyrics import scrape_lyrics from vader_sentiment import getSentimentScores import sys import os import shutil # Get user input for artist -> capitalize it artist = sys.argv[1].title() pull_links(artist) # Dictionary w/ song name as key and lyrics as value lyrics = scrape_...
normal
{ "blob_id": "5055743c9ed8c92bcfab5379162f28315409ff91", "index": 2200, "step-1": "<mask token>\n", "step-2": "<mask token>\npull_links(artist)\n<mask token>\nos.remove('./links.json')\nshutil.rmtree('./songs')\n<mask token>\nfor song in sentimentScores:\n print(song + ': ')\n print(sentimentScores[song])...
[ 0, 1, 2, 3, 4 ]
# -*- coding:utf-8 -*- __author__ = 'yangxin_ryan' """ Solutions: 题目要求非递归的中序遍历, 中序遍历的意思其实就是先遍历左孩子、然后是根结点、最后是右孩子。我们按照这个逻辑,应该先循环到root的最左孩子, 然后依次出栈,然后将结果放入结果集合result,然后是根的val,然后右孩子。 """ class BinaryTreeInorderTraversal(object): def inorderTraversal(self, root: TreeNode) -> List[int]: result = list() ...
normal
{ "blob_id": "8e629ee53f11e29aa026763508d13b06f6ced5ba", "index": 940, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass BinaryTreeInorderTraversal(object):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass BinaryTreeInorderTraversal(object):\n\n def inorderTraversal(self, root: TreeNod...
[ 0, 1, 2, 3, 4 ]
""" Author: C.M. Gosmeyer Date: Mar 2018 References: "Introduction to Statistical Problem Solving in Geography", J.C. McGrew, Jr., A.J. Lembo, Jr., C.B. Monroe To Do: Should tables interpolate? y = y1 + ((x - x1) / (x2 - x1)) * (y2 - y1) """ import numpy as np import pandas as p...
normal
{ "blob_id": "adb6e33dc665f88c82fcc399688a8dbd67b1e3e3", "index": 9894, "step-1": "<mask token>\n\n\nclass LoadStudentsTTable(LoadTable):\n <mask token>\n\n def __init__(self, tails):\n \"\"\"\n\n Parameters\n ----------\n tails : int\n 1 or 2.\n \"\"\"\n ...
[ 8, 18, 19, 21, 23 ]
from flask import Flask, render_template, redirect, request, session, flash from data import db_session from data import users, products import os from flask_wtf import FlaskForm from wtforms import StringField, PasswordField, SubmitField, BooleanField, SelectField, IntegerField from wtforms.fields.html5 import E...
normal
{ "blob_id": "d373d283a622262e2da974549907bdd8f61e89ec", "index": 2114, "step-1": "<mask token>\n\n\ndef allowed_file(filename):\n return '.' in filename and filename.rsplit('.', 1)[1].lower() == 'jpg'\n\n\ndef get_profile_img():\n os.chdir('static\\\\img\\\\profile_img')\n if os.access(f'{current_user.i...
[ 30, 35, 37, 40, 41 ]
sair = True while sair: num = int(input("informe um numero inteiro:")) if num <16: fatorial = 1 x = num while x>=1: print(x,".") fatorial = fatorial*x x -= 1 print("Valor total do Fatorial do %d = %d "%(num,fatorial)) else: ...
normal
{ "blob_id": "421e7ed0cc5a8c8acc9b98fae4ee6cc784d9b068", "index": 9683, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile sair:\n num = int(input('informe um numero inteiro:'))\n if num < 16:\n fatorial = 1\n x = num\n while x >= 1:\n print(x, '.')\n fat...
[ 0, 1, 2, 3 ]
from sand_game.Environment import Environment from sand_game.behaviours.Behaviour import Behaviour class EphemeralBehaviour(Behaviour): """Removes the particle after one frame """ def behave(env: Environment, loc: tuple[int, int]) ->tuple[int, int]: env.set(loc[0], loc[1], None)
normal
{ "blob_id": "2728c3ab26fbdbaac9c47054eafe1c114341f6f2", "index": 7736, "step-1": "<mask token>\n\n\nclass EphemeralBehaviour(Behaviour):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass EphemeralBehaviour(Behaviour):\n <mask token>\n\n def behave(env: Environment, loc: tuple[int...
[ 1, 2, 3, 4 ]
print("""Hello world""") print("Hello again") print('Hello again')
normal
{ "blob_id": "fe82a46a7965b27729ff5bd61c1059416c96cae7", "index": 8015, "step-1": "<mask token>\n", "step-2": "print('Hello world')\nprint('Hello again')\nprint('Hello again')\n", "step-3": "print(\"\"\"Hello world\"\"\")\nprint(\"Hello again\")\nprint('Hello again')", "step-4": null, "step-5": null, "s...
[ 0, 1, 2 ]
import numpy as np def find_saddle_points(A): B = [] for i in range(A.shape[0]): min_r = np.min(A[i]) ind_r = 0 max_c = 0 ind_c = 0 for j in range(A.shape[1]): if (A[i][j] == min_r): min_r = A[i][j] ind_r = j for k in range(A.shape[0]): if (A[k][ind_r] >= max_c): max_c = A[k][ind_...
normal
{ "blob_id": "808fe8f106eaff00cf0080edb1d8189455c4054b", "index": 6706, "step-1": "<mask token>\n\n\ndef find_saddle_points(A):\n B = []\n for i in range(A.shape[0]):\n min_r = np.min(A[i])\n ind_r = 0\n max_c = 0\n ind_c = 0\n for j in range(A.shape[1]):\n if A...
[ 5, 8, 9, 11, 12 ]
#!/usr/bin/env python3 import sys from argparse import ArgumentParser from arg_checks import IsFile, MinInt from visualisation import Visualisation parser = ArgumentParser(description="Visualises DS simulations") # The order of arguments in descending order of file frequency is: config, failures, log. # This should...
normal
{ "blob_id": "1f953b20ff0eb868c2fbff367fafa8b651617e64", "index": 6131, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('config', action=IsFile, help=\n 'configuration file used in simulation')\nparser.add_argument('log', action=IsFile, help=\n 'simulation log file to visualise')\...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python #!-*-coding:utf-8 -*- """ @version: python3.7 @author: ‘v-enshi‘ @license: Apache Licence @contact: 123@qq.com @site: @software: PyCharm @file: Images_fade.py @time: 2019/1/16 17:17 """ from PIL import Image import numpy as np filename = "hw0_data/westbrook.jpg" im=Image.open(filename) #open th...
normal
{ "blob_id": "6e78d1fb2364d334f47fea89b065d859c025ca2f", "index": 5648, "step-1": "<mask token>\n", "step-2": "<mask token>\nfinalImg.save('Q2.jpg')\n", "step-3": "<mask token>\nfilename = 'hw0_data/westbrook.jpg'\nim = Image.open(filename)\nimgs = np.array(im)\nimgsDiv2 = np.trunc(imgs / 2)\nimgInt = imgsDiv...
[ 0, 1, 2, 3, 4 ]
from analizer_pl.abstract.instruction import Instruction from analizer_pl import grammar from analizer_pl.statement.expressions import code from analizer_pl.reports.Nodo import Nodo class If_Statement(Instruction): def __init__(self, row, column,expBool, elseif_list,else_,stmts ) -> None: super().__i...
normal
{ "blob_id": "bbbdb30ceef920e600c9f46fb968732b077be2d8", "index": 4231, "step-1": "<mask token>\n\n\nclass If_Statement(Instruction):\n\n def __init__(self, row, column, expBool, elseif_list, else_, stmts) ->None:\n super().__init__(row, column)\n self.expBool = expBool\n self.elseif_list ...
[ 7, 9, 10, 11, 12 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Implements the webservice calls of the command like rest apis or other network related methods """
normal
{ "blob_id": "48369e1ed826a9a50c0fd9f63b7cc10b8225ce2b", "index": 8760, "step-1": "<mask token>\n", "step-2": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n\"\"\"\nImplements the webservice calls of the command\nlike rest apis or other network related methods\n\"\"\"", "step-3": null, "step-4": null, ...
[ 0, 1 ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-15 15:20 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('challenges', '0019_auto_20170310_1114'), ] operations = [ migrations.AddFie...
normal
{ "blob_id": "6b7ff00eb9a5d0837def5b245ba2d4a0acec972e", "index": 3466, "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 = [('challenges'...
[ 0, 1, 2, 3, 4 ]
#! py -3 # -*- coding: utf-8 -*- import requests from urllib.parse import quote import logging from urllib.parse import urlparse logger = logging.getLogger(__name__) logger = logging.getLogger() # 配置日志级别,如果不显示配置,默认为Warning,表示所有warning级别已下的其他level直接被省略, # 内部绑定的handler对象也只能接收到warning级别以上的level,你可以理解为总开关 logger.setLeve...
normal
{ "blob_id": "c5d92ec592250d5bc896d32941364b92ff1d21e9", "index": 3793, "step-1": "<mask token>\n\n\ndef request_dyn():\n logger.info('dyn: 开始测试请求')\n postUrl = '%s/raframework/browse/dyn' % serverUrl\n postData = {'page': '/conf/CDSConfig.jsp', 'amp': '', 'action':\n 'returnXML', 'LOCALE_LANGUAGE...
[ 3, 5, 6, 8, 9 ]
from pylab import * import pandas as pd from matplotlib import pyplot import pylab from mpl_toolkits.mplot3d import Axes3D from threading import Thread from threading import Semaphore from threading import Lock from Queue import Queue sam = Semaphore(1) lck = Lock() q=Queue(10) def myFunc(z): #if z%2==0 and z>1: ...
normal
{ "blob_id": "33c0efb47e3253442b6a808c7ebffac275c19321", "index": 7763, "step-1": "from pylab import *\nimport pandas as pd\nfrom matplotlib import pyplot\nimport pylab\nfrom mpl_toolkits.mplot3d import Axes3D\nfrom threading import Thread\nfrom threading import Semaphore\nfrom threading import Lock\nfrom Queue i...
[ 0 ]
import subprocess import logging import time import argparse import threading import os import matplotlib.pyplot as plt import numpy as np import argparse def runWeka(wekapath, modelpath, datapath): os.chdir(wekapath) proc = subprocess.Popen(['/usr/bin/java', '-classpath', 'weka.jar', 'weka.classifiers.functio...
normal
{ "blob_id": "a1f0eced5d122fe8557ebc4d707c87b4194513e3", "index": 4976, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef runWeka(wekapath, modelpath, datapath):\n os.chdir(wekapath)\n proc = subprocess.Popen(['/usr/bin/java', '-classpath', 'weka.jar',\n 'weka.classifiers.functions.Multi...
[ 0, 1, 2, 3, 4 ]
# wfp, 6/6 # simple list stuff my_list = [1,'a',3.14] print("my_list consists of: ",my_list) print() print("Operations similar to strings") print("Concatenation") print("my_list + ['bill'] equals: ", my_list + ["bill"]) print() print("Repeat") print("my_list * 3 equals: ", my_list * 3) print() print("In...
normal
{ "blob_id": "1c134cba779459b57f1f3c195aed37d105b94aef", "index": 9935, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('my_list consists of: ', my_list)\nprint()\nprint('Operations similar to strings')\nprint('Concatenation')\nprint(\"my_list + ['bill'] equals: \", my_list + ['bill'])\nprint()\nprin...
[ 0, 1, 2, 3 ]
class Node: def __init__ (self, val): self.childleft = None self.childright = None self.nodedata = val root = Node("Kaif") root.childleft = Node("name") root.childright = Node("!") root.childleft.childleft = Node("My") root.childleft.childright = Node("is") message = input(...
normal
{ "blob_id": "73e4346007acae769b94a55ef53a48a9d3325002", "index": 7262, "step-1": "class Node:\n <mask token>\n\n\n<mask token>\n", "step-2": "class Node:\n\n def __init__(self, val):\n self.childleft = None\n self.childright = None\n self.nodedata = val\n\n\n<mask token>\n\n\ndef try...
[ 1, 3, 4, 5, 6 ]
#!/usr/bin/env python3 from datetime import datetime import re import sys MONTHS_REGEXP = ('Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec|' 'January|February|March|April|June|July|August|September|October|November|December') re_entry_begin = re.compile(r'(?P<version>[\d.]+)[ :]*\(?(?P<date>\d\d\d\d...
normal
{ "blob_id": "03677f02473019fcc6a40d91569a85be78ca0a87", "index": 7179, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in sys.stdin:\n m = re_entry_begin.match(line)\n if m:\n if first_line_met:\n sys.stdout.write(signature_format.format(date=current_date))\n versio...
[ 0, 1, 2, 3, 4 ]
''' Created on 3 Jul 2009 @author: charanpal An abstract base class which represents a graph generator. The graph generator takes an existing empty graph and produces edges over it. ''' from apgl.util.Util import Util class AbstractGraphGenerator(object): def generate(self, graph): Util.abst...
normal
{ "blob_id": "e37e468d8a41b8711fb0eb4ddec7db67691f9156", "index": 488, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass AbstractGraphGenerator(object):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass AbstractGraphGenerator(object):\n\n def generate(self, graph):\n Util.abstrac...
[ 0, 1, 2, 3, 4 ]
""" Copyright (C) Adrian Herrera, 2017 You will need to install r2pipe and pydot: ``` pip install r2pipe pydot ``` """ from __future__ import print_function import glob import json import os import pydot import r2pipe import s2e_web.S2E_settings as S2E_settings def function_addrs(r2): """ Yield a list of...
normal
{ "blob_id": "2aee4af2e5a5c3f59dde4d9dd46f8d124a32fb27", "index": 2590, "step-1": "<mask token>\n\n\ndef function_addrs(r2):\n \"\"\"\n Yield a list of all the function's start addresses.\n \"\"\"\n for addr in r2.cmdj('aflqj'):\n yield int(addr, 16)\n\n\n<mask token>\n\n\ndef basic_block_cover...
[ 3, 4, 5, 6, 7 ]
class A(object): _a ='d' @staticmethod def func_1(): A._a = 'b' print A._a @classmethod def func_3(cls): print cls._a def func_2(self): # self._a = 'c' print self._a # print A._a # # class B(object): # @staticmethod # def func_1(): # ...
normal
{ "blob_id": "2ab3adb4d0ed7e6e48afb2a8dab8f9250d335723", "index": 2253, "step-1": "class A(object):\n _a ='d'\n\n\n @staticmethod\n def func_1():\n A._a = 'b'\n print A._a\n\n @classmethod\n def func_3(cls):\n print cls._a\n\n def func_2(self):\n # self._a = 'c'\n ...
[ 0 ]
import operator def group_by_owners(files): print(files, type(files)) for k, v in files.items(): # for v in k: print(k, v) # if k[v] == k[v]: # print("same", v) for f in files: print(f[0]) for g in v: print(g) _files = sorted(files.items(...
normal
{ "blob_id": "4843239a41fe1ecff6c8c3a97aceef76a3785647", "index": 7334, "step-1": "<mask token>\n\n\ndef group_by_owners(files):\n print(files, type(files))\n for k, v in files.items():\n print(k, v)\n for f in files:\n print(f[0])\n for g in v:\n print(g)\n _files = so...
[ 1, 2, 3, 4, 5 ]
# Generated by Django 3.1.7 on 2021-03-29 18:50 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ("core", "0052_add_more_tags"), ] operations = [ migrations.RenameField( model_name="reporter", old_name="auth0_role_name", ...
normal
{ "blob_id": "c0cabf2b6f7190aefbaefa197a9008de3a344147", "index": 2082, "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 = [('core', '005...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import csv import sys import os.path #Versao 2 do gerador das RawZones #global DIR_PYGEN = "/bid/_temporario_/pythonGeneration/" DIR_INTGR_PAR = "/bid/integration_layer/par/" DIR_INTGR_JOB = "/bid/integration_layer/job/" def Sqoop(filename,source_database,source_table, split_field, sourcesystem, ta...
normal
{ "blob_id": "aa817b86e26cf8cd9771aeb276914a1f5869c737", "index": 1849, "step-1": "#!/usr/bin/python\nimport csv\nimport sys\nimport os.path\n\n#Versao 2 do gerador das RawZones\n\n#global\nDIR_PYGEN = \"/bid/_temporario_/pythonGeneration/\"\nDIR_INTGR_PAR = \"/bid/integration_layer/par/\"\nDIR_INTGR_JOB = \"/bid...
[ 0 ]
# -*- coding: utf-8 -*- """ Created on Wed Aug 19 05:29:19 2020 @author: Gaurav """ from tensorflow.keras.models import load_model import cv2 import os from tensorflow.keras.preprocessing.image import img_to_array import numpy as np model=load_model('E:/AI Application Implementation/trained_model/Classifi...
normal
{ "blob_id": "c3e2bd635a7ff558ed56e7fb35e8b10e1c660c88", "index": 6804, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in arr:\n img = cv2.imread(i)\n img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)\n img = cv2.resize(img, (32, 32))\n img = img_to_array(img)\n img = np.expand_dims(img, axi...
[ 0, 1, 2, 3, 4 ]
from __future__ import division import numpy as np import scipy.stats from tms import read_and_transform __author__ = 'Diego' def estimate_vrpn_clock_drift(points): # clocks = [map(np.datetime64,(p.date,p.ref_date,p.point_date)) for p in points] clocks = [(p.date, p.ref_date, p.point_date) for p in points...
normal
{ "blob_id": "7d0b0cb19e22ff338104e0c2061da94ba04d4f16", "index": 2249, "step-1": "from __future__ import division\n\nimport numpy as np\nimport scipy.stats\n\nfrom tms import read_and_transform\n\n\n__author__ = 'Diego'\n\n\ndef estimate_vrpn_clock_drift(points):\n # clocks = [map(np.datetime64,(p.date,p.ref_...
[ 0 ]
from pyspark import SparkContext, SparkConf import time # Create a basic configuration conf = SparkConf().setAppName("myTestCopyApp") # Create a SparkContext using the configuration sc = SparkContext(conf=conf) print("START") time.sleep(30) print("END")
normal
{ "blob_id": "4b773fbf45d15dff27dc7bd51d6636c5f783477b", "index": 9183, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('START')\ntime.sleep(30)\nprint('END')\n", "step-3": "<mask token>\nconf = SparkConf().setAppName('myTestCopyApp')\nsc = SparkContext(conf=conf)\nprint('START')\ntime.sleep(30)\np...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # coding: utf-8 # In[2]: from __future__ import absolute_import, division, print_function, unicode_literals import tensorflow as tf print("Num GPUs Available: ", len(tf.config.experimental.list_physical_devices('GPU'))) # In[1]: import numpy as np import pandas as pd import matplotlib.pypl...
normal
{ "blob_id": "aea92827753e12d2dc95d63ddd0fe4eb8ced5d14", "index": 3815, "step-1": "<mask token>\n\n\ndef convolve(image, fltr):\n r_p = 0\n c_p = 0\n conv_list = []\n while r_p + 1 <= image.shape[0] - 1:\n while c_p + 1 <= image.shape[1] - 1:\n x = np.sum(np.multiply(image[r_p:r_p + ...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # Copyright (c) 2018, HSCH and contributors # For license information, please see license.txt from __future__ import unicode_literals import frappe from frappe import _ from frappe.utils.nestedset import NestedSet class GoalCategory(NestedSet): nsm_parent_field = 'parent_goal_category'; de...
normal
{ "blob_id": "c6055c6b67ac28d304ed34ddc2f81e59da8e7f1b", "index": 1103, "step-1": "<mask token>\n\n\nclass GoalCategory(NestedSet):\n nsm_parent_field = 'parent_goal_category'\n\n def on_update(self):\n self.validate_name_with_goal()\n super(GoalCategory, self).on_update()\n self.valida...
[ 4, 5, 6, 7, 8 ]
# Generated by Django 2.1.7 on 2019-03-18 02:25 from django.conf import settings from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('training_area', '0006_remove_event_day'), ] operations = [ migrations.Crea...
normal
{ "blob_id": "9905559909f10831373e659cde0f275dc5d71e0d", "index": 7041, "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 = [('training_ar...
[ 0, 1, 2, 3, 4 ]
from bs4 import BeautifulSoup import urllib2 def get_begin_data(url): headers = { 'ser-Agent': '', 'Cookie': '' } request = urllib2.Request(url, headers=headers) web_data = urllib2.urlopen(request) soup = BeautifulSoup(web_data, 'html.parser') results = soup.select('tab...
normal
{ "blob_id": "790110a8cba960eb19593e816b579080dfc46a4e", "index": 4572, "step-1": "<mask token>\n\n\ndef get_begin_data(url):\n headers = {'ser-Agent': '', 'Cookie': ''}\n request = urllib2.Request(url, headers=headers)\n web_data = urllib2.urlopen(request)\n soup = BeautifulSoup(web_data, 'html.parse...
[ 2, 3, 4, 5, 6 ]
from os import getenv LISTEN_IP = getenv('LISTEN_IP', '0.0.0.0') LISTEN_PORT = int(getenv('LISTEN_PORT', 51273)) LISTEN_ADDRESS = LISTEN_IP, LISTEN_PORT CONFIRMATION = getenv('CONFIRMATION') if CONFIRMATION: CONFIRMATION = CONFIRMATION.encode() class UDPProtocol: def __init__(self, consumer): self...
normal
{ "blob_id": "cca543f461724c3aac8fef23ef648883962bd706", "index": 4607, "step-1": "<mask token>\n\n\nclass UDPProtocol:\n <mask token>\n\n def connection_made(self, transport):\n self.transport = transport\n <mask token>\n <mask token>\n <mask token>\n\n def stop(self):\n self.tran...
[ 3, 5, 8, 9, 11 ]
class Leg(): __smelly = True def bend_knee(self): print("knee bent") @property def smelly(self): return self.__smelly @smelly.setter def smelly(self,smell): self.__smelly = smell def is_smelly(self): return self.__smelly
normal
{ "blob_id": "a4ecc578a163ee4657a2c9302f79f15c2e4e39de", "index": 672, "step-1": "class Leg:\n <mask token>\n <mask token>\n\n @property\n def smelly(self):\n return self.__smelly\n <mask token>\n\n def is_smelly(self):\n return self.__smelly\n", "step-2": "class Leg:\n <mask ...
[ 3, 4, 5, 6, 7 ]
from inotifier import Notifier from IPython.display import display, Audio, HTML import pkg_resources import time class AudioPopupNotifier(Notifier): """Play Sound and show Popup upon cell completion""" def __init__(self, message="Cell Completed", audio_file="pad_confirm.wav"): super(AudioPopupNotifi...
normal
{ "blob_id": "94a3a74260fac58b4cad7422608f91ae3a1a0272", "index": 6247, "step-1": "<mask token>\n\n\nclass AudioPopupNotifier(Notifier):\n <mask token>\n <mask token>\n\n def notify(self):\n display(Audio(self.audio, autoplay=True))\n time.sleep(3)\n display(HTML(self.template.format...
[ 2, 3, 4, 5, 6 ]
# Problem Statement – An automobile company manufactures both a two wheeler (TW) and a four wheeler (FW). A company manager wants to make the production of both types of vehicle according to the given data below: # 1st data, Total number of vehicle (two-wheeler + four-wheeler)=v # 2nd data, Total number of wheels = W ...
normal
{ "blob_id": "74939f81e999b8e239eb64fa10b56f48c47f7d94", "index": 1622, "step-1": "<mask token>\n", "step-2": "<mask token>\nif w < 2 or w % 2 != 0 or w <= v:\n print('INVALID INPUT')\nelse:\n x = (4 * v - w) // 2\n print('TW={0} FW={1}'.format(x, v - x))\n", "step-3": "v = int(input())\nw = int(inpu...
[ 0, 1, 2, 3 ]
from django.apps import AppConfig class FilebasedUniqueConfig(AppConfig): name = 'papermerge.filebased_unique' label = 'filebased_unique'
normal
{ "blob_id": "2d17229afe154937132c1e4f8c138896da34ab61", "index": 1430, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass FilebasedUniqueConfig(AppConfig):\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass FilebasedUniqueConfig(AppConfig):\n name = 'papermerge.filebase...
[ 0, 1, 2, 3 ]
import luigi import numpy as np import tqdm import os from scipy import spatial from kq import wordmat_distance class QuestionVectorTask(luigi.Task): resources = {'cpu': 1} dataset = luigi.Parameter() def requires(self): #yield wordmat_distance.WeightedSentenceVecs() yield wordmat_distan...
normal
{ "blob_id": "ae6a6f7622bf98c094879efb1b9362a915a051b8", "index": 1175, "step-1": "<mask token>\n\n\nclass QuestionVectorTask(luigi.Task):\n <mask token>\n <mask token>\n <mask token>\n\n def output(self):\n return luigi.LocalTarget('./cache/question_distance/%s.npy' % self.\n datase...
[ 7, 8, 11, 12, 13 ]
# -*- coding: utf-8 -*- """ Created on Sat Aug 3 17:16:12 2019 @author: Meagatron """ import numpy as np import pandas as pd import matplotlib.pyplot as plt from collections import defaultdict import math import itertools from dtw import dtw import timeit from helper_functions import normalize,alphabetize_ts,hammin...
normal
{ "blob_id": "16215ee42c4ea284dca0ebb7372fef04c0cc54b9", "index": 2149, "step-1": "<mask token>\n\n\ndef segment_ts():\n ts_len = len(x1)\n mod = ts_len % window_size\n rnge = 0\n if skip_offset == 0:\n ts_len = int((ts_len - mod - window_size) / 1)\n rnge = int(ts_len / window_size)\n ...
[ 4, 5, 6, 7, 8 ]
number = int(input()) bonus = 0 if number <= 100: bonus = 5 total_point = number + bonus elif number > 1000: bonus = 0.1 * number total_point = number + bonus else: bonus = 0.2 * number total_point = number + bonus if number % 2 == 0: bonus = bonus + 1 total_point = number + bonus pr...
normal
{ "blob_id": "7ee3301b55d323d156bd394f8525e37502d19430", "index": 7669, "step-1": "<mask token>\n", "step-2": "<mask token>\nif number <= 100:\n bonus = 5\n total_point = number + bonus\nelif number > 1000:\n bonus = 0.1 * number\n total_point = number + bonus\nelse:\n bonus = 0.2 * number\n t...
[ 0, 1, 2 ]
import os import requests import sqlite3 from models import analytics, jcanalytics def populate(): url = 'https://api.clicky.com/api/stats/4?site_id=100716069&sitekey=93c104e29de28bd9&type=visitors-list' date = '&date=last-30-days' limit = '&limit=all' output = '&output=json' total = url+date+limi...
normal
{ "blob_id": "e8226ab6be5c21335d843cba720e66646a2dee4e", "index": 241, "step-1": "import os\nimport requests\nimport sqlite3\nfrom models import analytics, jcanalytics\n\n\ndef populate():\n url = 'https://api.clicky.com/api/stats/4?site_id=100716069&sitekey=93c104e29de28bd9&type=visitors-list'\n date = '&d...
[ 0 ]
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER # Copyright (c) 2018 Juniper Networks, Inc. # All rights reserved. # Use is subject to license terms. # # Author: cklewar import os import threading import time from jnpr.junos import Device from jnpr.junos import exception from jnpr.junos.utils.config im...
normal
{ "blob_id": "45cdf33f509e7913f31d2c1d6bfada3a84478736", "index": 2904, "step-1": "<mask token>\n\n\nclass SoftwareTask(Task):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, sample_device=None, shared=None):\n super(SoftwareTask, self).__...
[ 9, 10, 11, 12, 13 ]