code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
a = [3, 4, 2, 3, 5, 8, 23, 32, 35, 34, 4, 6, 9] print("") print("Lesson #2") print("Program start:") for i in a: if i < 9: print(i) print("End")
normal
{ "blob_id": "58f7810e2731721562e3459f92684589dc66862c", "index": 881, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('')\nprint('Lesson #2')\nprint('Program start:')\nfor i in a:\n if i < 9:\n print(i)\nprint('End')\n", "step-3": "a = [3, 4, 2, 3, 5, 8, 23, 32, 35, 34, 4, 6, 9]\nprint('...
[ 0, 1, 2, 3 ]
import sys if __name__ == '__main__': cases = sys.stdin.readline() for i in range(int(cases)): sys.stdin.readline() lineas, columnas = sys.stdin.readline().strip().split(" ") lineas = int(lineas) columnas = int(columnas) list_lines = [] for linea in range(linea...
normal
{ "blob_id": "22909e41e4f9ad0280c22ec11ecfbccff87efae1", "index": 1402, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n cases = sys.stdin.readline()\n for i in range(int(cases)):\n sys.stdin.readline()\n lineas, columnas = sys.stdin.readline().strip().split(...
[ 0, 1, 2, 3 ]
"""MPI-supported kernels for computing diffusion flux in 2D.""" from sopht.numeric.eulerian_grid_ops.stencil_ops_2d import ( gen_diffusion_flux_pyst_kernel_2d, gen_set_fixed_val_pyst_kernel_2d, ) from sopht_mpi.utils.mpi_utils import check_valid_ghost_size_and_kernel_support from mpi4py import MPI def gen_dif...
normal
{ "blob_id": "ba8cb18544e4ded8b229bfb9cc4b28599119414f", "index": 854, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef gen_diffusion_flux_pyst_mpi_kernel_2d(real_t, mpi_construct,\n ghost_exchange_communicator):\n diffusion_flux_pyst_kernel = gen_diffusion_flux_pyst_kernel_2d(real_t=\n ...
[ 0, 1, 2, 3 ]
from django.urls import reverse_lazy from django.views.generic import ( ListView, DetailView, CreateView, UpdateView, DeleteView, ) from .models import Entry class EntryListView(ListView): model = Entry queryset = Entry.objects.all().order_by("-date_created") class EntryDetailView(Detai...
normal
{ "blob_id": "37c03732ae52171fc24aec85c940848b02d76dc1", "index": 1176, "step-1": "<mask token>\n\n\nclass EntryCreateView(CreateView):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass EntryUpdateView(UpdateView):\n model = Entry\n fields = ['title', 'content']\n\n def get_success_url(sel...
[ 6, 7, 10, 11, 13 ]
#!/usr/local/autopkg/python """ JamfScriptUploader processor for uploading items to Jamf Pro using AutoPkg by G Pugh """ import os.path import sys from time import sleep from autopkglib import ProcessorError # pylint: disable=import-error # to use a base module in AutoPkg we need to add this path to the sys.pa...
normal
{ "blob_id": "35d99713df754052a006f76bb6f3cfe9cf875c0b", "index": 3993, "step-1": "<mask token>\n\n\nclass JamfScriptUploader(JamfUploaderBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass JamfScriptUploader(J...
[ 1, 4, 5, 7, 8 ]
# Generated by Django 3.1.6 on 2021-05-06 10:29 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('core', '0028_auto_20210506_1020'), ] operations = [ migrations.AlterField( model_name='user', ...
normal
{ "blob_id": "39ac4e0d543048ea02123baa39b6c8ce7618d16b", "index": 6802, "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', '002...
[ 0, 1, 2, 3, 4 ]
import time import datetime import math import os import random import logzero import logging from logzero import logger from sense_hat import SenseHat import ephem anyException = False # program Time is here for easy acces (in minutes) programTime = 175 # 2:55 min of runtime # _________________________...
normal
{ "blob_id": "05e468c2f64e33d6b390f681314ed7961bd4def7", "index": 2684, "step-1": "<mask token>\n\n\ndef setLoggingFile():\n \"\"\"\n This function will setup a logger and logfile\n \"\"\"\n try:\n dirPath = os.path.dirname(os.path.realpath(__file__))\n dirFiles = os.listdir(dirPath)\n ...
[ 10, 12, 14, 15, 16 ]
# -*- coding: utf-8 -*- # # Copyright (C) 2015 Brandon Bennett <bennetb@gmail.com> # # Send a notification via notifyserver (https://github.com/nemith/notifyserver) # on highlight/private message or new DCC. # # History: # # 2015-02-07, Brandon Bennett <bennetb@gmail.com>: # version 0.1: initial release # SCRIPT...
normal
{ "blob_id": "0ae9ad7af26e3d19f2d3967c02611503c32aea70", "index": 2593, "step-1": "<mask token>\n\n\nclass Config(object):\n _DEFAULT = {'url': 'http://localhost:9999/notify', 'title':\n 'IRC Notification', 'activate_label': '', 'sound': ''}\n\n def __init__(self):\n self._opts = {}\n f...
[ 5, 7, 9, 10, 12 ]
# Напишите программу, которая вводит с клавиатуры последовательность чисел и выводит её # отсортированной в порядке возрастания. def is_numb_val(val): try: x = float(val) except ValueError: return False else: return True def main(): num_seq = input("Введите последовательность ...
normal
{ "blob_id": "4c8a873c816678532b029af409be13258757eae1", "index": 7577, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n num_seq = input('Введите последовательность чисел через пробел: ').split()\n num_lst = [float(s) for s in num_seq if is_numb_val(s)]\n print(sorted(num_lst))\n\...
[ 0, 1, 2, 3, 4 ]
#!/bin/python import sys arr = map(int, raw_input().strip().split(' ')) smallest = 1000000001 largest = 0 smi = -1 lri = -1 for i, num in enumerate(arr): if num < smallest: smallest = num smi = i if num > largest: largest = num lri = i smsum = 0 lrsum = 0 for i in range(len(a...
normal
{ "blob_id": "164665c7d037f1e4128d8227d5fc148940d5c2b8", "index": 6235, "step-1": "#!/bin/python\n\nimport sys\n\narr = map(int, raw_input().strip().split(' '))\n\nsmallest = 1000000001\nlargest = 0\nsmi = -1\nlri = -1\nfor i, num in enumerate(arr):\n if num < smallest:\n smallest = num\n smi = i...
[ 0 ]
""" This is the hourly animation program. It displays a series of images across the board. It is hard coded to work with the Sonic images. Adjustments would need to be made to the y values which are distance traveled. Change sonicFrame < 8 value to the total number of frames the new animation has. """ from runImages im...
normal
{ "blob_id": "ede675c971ed233e93c14aa4d2ffb66fe7ba775a", "index": 5613, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef animationDisplay():\n matrix.Clear()\n sonicRun = 0\n sonicFrame = 0\n y = 0\n while y < 70:\n sonicFrame = 0\n if sonicRun >= 100:\n sonic...
[ 0, 1, 2, 3 ]
import numpy as np x = np.zeros(10) idx = [1, 4, 5, 9] np.put(x, ind=idx, v=1) print(x)
normal
{ "blob_id": "9e2485554a5a8de07dd3df39cc255f2a1ea2f164", "index": 4769, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.put(x, ind=idx, v=1)\nprint(x)\n", "step-3": "<mask token>\nx = np.zeros(10)\nidx = [1, 4, 5, 9]\nnp.put(x, ind=idx, v=1)\nprint(x)\n", "step-4": "import numpy as np\nx = np.zeros(...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import graphviz import fa_util class Graph: def draw(self, directory, filename, rules, start_state, accept_states): g = graphviz.Digraph(format="svg", graph_attr={'rankdir': 'LR'}) self.add_start_edge(g, start_state) edges = {} for rule in rules: ...
normal
{ "blob_id": "c0e94a0d20397ebbbdddf726307b19b6c5c85ae6", "index": 9082, "step-1": "<mask token>\n\n\nclass Graph:\n\n def draw(self, directory, filename, rules, start_state, accept_states):\n g = graphviz.Digraph(format='svg', graph_attr={'rankdir': 'LR'})\n self.add_start_edge(g, start_state)\n ...
[ 6, 7, 9, 10, 12 ]
import random import numpy as np import torch from utils import print_result, set_random_seed, get_dataset, get_extra_args from cogdl.tasks import build_task from cogdl.datasets import build_dataset from cogdl.utils import build_args_from_dict DATASET_REGISTRY = {} def build_default_args_for_node_classification(da...
normal
{ "blob_id": "2396f7acab95260253c367c62002392760157705", "index": 1236, "step-1": "<mask token>\n\n\ndef build_default_args_for_node_classification(dataset):\n cpu = not torch.cuda.is_available()\n args = {'lr': 0.01, 'weight_decay': 0.0005, 'max_epoch': 1000,\n 'max_epochs': 1000, 'patience': 100, '...
[ 5, 6, 7, 8, 10 ]
import pygame import numpy as np import glob from entities.base import AnimatedSprite images_path = sorted(glob.glob('./resources/trophy_sparkle_*.png')) trophy_im_dict = {'sparkle':[pygame.transform.scale(pygame.image.load(img_path),(400,400)) for img_path in images_path]} class Trophy(AnimatedSprite): def __in...
normal
{ "blob_id": "883cb1e3ea227bb5ac5aa3b4348336ab1a7fba70", "index": 3476, "step-1": "<mask token>\n\n\nclass Trophy(AnimatedSprite):\n\n def __init__(self, position, image_dict, hold_for_n_frames=3):\n super().__init__(position, image_dict, hold_for_n_frames)\n self.initial_position = position\n ...
[ 2, 3, 4, 5, 6 ]
from __future__ import absolute_import, print_function, unicode_literals import six from six.moves import zip, filter, map, reduce, input, range import pathlib import unittest import networkx as nx import multiworm TEST_ROOT = pathlib.Path(__file__).parent.resolve() DATA_DIR = TEST_ROOT / 'data' SYNTH1 = DATA_DIR ...
normal
{ "blob_id": "dfee0407eaed7b1ab96467874bbfe6463865bcb4", "index": 6238, "step-1": "<mask token>\n\n\nclass TestExperimentOpen(unittest.TestCase):\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 TestMalformed...
[ 18, 19, 24, 27, 29 ]
from PrStatusWorker import PrStatusWorker import threading def initialize_worker(): worker = PrStatusWorker() worker.start_pr_status_polling() print("Starting the PR status monitor worker thread...") worker_thread = threading.Thread(target=initialize_worker, name="pr_status_worker") worker_thread.start()
normal
{ "blob_id": "4b5f58d471b05428caef3ca7a3bdc0d30a7e3881", "index": 5265, "step-1": "<mask token>\n\n\ndef initialize_worker():\n worker = PrStatusWorker()\n worker.start_pr_status_polling()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef initialize_worker():\n worker = PrStatusWorker()\n worke...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python import pyaudio import wave import winshell """ This script accesses the Laptop's microphone using the library pyaudio and opens a stream to record the voice and writes it to an mp3 file """ def start(): try: CHUNK = 1024 FORMAT = pyaudio.paInt16 CHANNELS = 2 RA...
normal
{ "blob_id": "bbbbf0e1bbd7ead034d8cd88ee6a09a61cde7803", "index": 3463, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef start():\n try:\n CHUNK = 1024\n FORMAT = pyaudio.paInt16\n CHANNELS = 2\n RATE = 44100\n dest_path = winshell.desktop() + '\\\\Spyware\\\\Ou...
[ 0, 1, 2, 3 ]
# user_events.py import dataclasses from typing import Optional @dataclasses.dataclass class UserUpdateMessage: id: str name: Optional[str] = None age: Optional[int] = None async def receive_user_update(message: UserUpdateMessage) -> None: print(f"Received update for user id={message.id}")
normal
{ "blob_id": "b2fb5564d44f7481c6de2a5d4af09df4903026b8", "index": 8222, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@dataclasses.dataclass\nclass UserUpdateMessage:\n id: str\n name: Optional[str] = None\n age: Optional[int] = None\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\n@data...
[ 0, 1, 2, 3, 4 ]
#Pràctica 9 Condicionals, Exercici 2: print("Introduce un valor par:") numpar=int(input()) print("Introduce un valor impar:") numimp=int(input()) if numpar==numimp*2: print(numpar," es el doble que ",numimp,".") else: print(numpar," no es el doble que ",numimp,".")
normal
{ "blob_id": "8ad5f3e5f73eae191a3fe9bc20f73b4bfcfedc8c", "index": 4884, "step-1": "<mask token>\n", "step-2": "print('Introduce un valor par:')\n<mask token>\nprint('Introduce un valor impar:')\n<mask token>\nif numpar == numimp * 2:\n print(numpar, ' es el doble que ', numimp, '.')\nelse:\n print(numpar,...
[ 0, 1, 2, 3 ]
animals = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'platypus'] The animal at 1. The third (3rd) animal. The first (1st) animal. The animal at 3. The fifth (5th) animal. The animal at 2. The sixth (6th) animal. The animal at 4.
normal
{ "blob_id": "a319ebb05e9034f19aef39bd46830c8a607ed121", "index": 1013, "step-1": "animals = ['bear', 'python', 'peacock', 'kangaroo', 'whale', 'platypus']\nThe animal at 1.\nThe third (3rd) animal.\nThe first (1st) animal.\nThe animal at 3.\nThe fifth (5th) animal.\nThe animal at 2.\nThe sixth (6th) animal.\nThe...
[ 0 ]
# Mac File import platform import os def Mac(SystemArray = [], ProcessorArray = []): # System Info OSName = str() OSVersionMajor = str() OSArchitecture = str() # Processor Info command = '/usr/sbin/sysctl -n machdep.cpu.brand_string' ProcInfo = os.popen(command).read().strip() ProcNam...
normal
{ "blob_id": "f652fa6720582d50f57f04d82fb2f5af17859ebd", "index": 8211, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Mac(SystemArray=[], ProcessorArray=[]):\n OSName = str()\n OSVersionMajor = str()\n OSArchitecture = str()\n command = '/usr/sbin/sysctl -n machdep.cpu.brand_string'\n...
[ 0, 1, 2, 3 ]
# Q. In How many ways N stair can be climb if allowesd steps are 1, 2 or 3. # triple Sort def noOfSteps(n, k): if n<0: return 0 if n == 0: return 1 t_steps = 0 for i in range(1, k+1): t_steps += noOfSteps(n-i, k) return t_steps def noOfStepsDP(n,k): dp = [0]*max((...
normal
{ "blob_id": "6c2699ff8e739595a2648d53745dc3c788536d7b", "index": 1907, "step-1": "<mask token>\n\n\ndef noOfStepsDP(n, k):\n dp = [0] * max(n + 1, 3)\n dp[0] = 1\n dp[1] = 1\n dp[2] = 2\n for i in range(3, n + 1):\n dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3]\n return dp[n]\n\n\n<mask toke...
[ 1, 2, 3, 4, 5 ]
''' Twitter settings Input your app credentials below https://apps.twitter.com ''' # consumer key CONSUMER_KEY = '' # consumer secret CONSUMER_SECRET = '' ''' App settings ''' # Where to save tokens (JSON) TOKENS_PATH = '/tmp/twitter-tokens.json' # Redirect-back to URL after authenticated (optional) REDIRECT_TO = ''...
normal
{ "blob_id": "9cc64edc81ab39b0ab2cd47661c9809545b03ac6", "index": 3230, "step-1": "<mask token>\n", "step-2": "<mask token>\nCONSUMER_KEY = ''\nCONSUMER_SECRET = ''\n<mask token>\nTOKENS_PATH = '/tmp/twitter-tokens.json'\nREDIRECT_TO = ''\nFLASK_SECRET = 'S$2[ShC-=BKKOQ.Z-|fa 6f;,5 <[QngmG)}5,s%0vX>B}?o-0X9PM;....
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- from fw.api import dadata_proxy from flask import current_app from fw.cache.cache_wrapper import CacheWrapper cache = CacheWrapper() def dadata_suggest(method, data): return dadata_proxy.dadata_suggest(method, data) def dadata_clean(method, data): return dadata_proxy.dadata_clean(...
normal
{ "blob_id": "af4d2380f92ea636594695e5ad4ba766d6874dd3", "index": 1355, "step-1": "<mask token>\n\n\ndef dadata_clean(method, data):\n return dadata_proxy.dadata_clean(method, data)\n\n\ndef get_detailed_address(address):\n from fw.utils.address_utils import get_detailed_address as _get_detailed_address\n ...
[ 9, 11, 12, 13, 14 ]
from .file_uploader_routes import FILE_UPLOADER_BLUEPRINT
normal
{ "blob_id": "c7dacdb53efb6935314c5e3718a4a2f1d862b07d", "index": 2340, "step-1": "<mask token>\n", "step-2": "from .file_uploader_routes import FILE_UPLOADER_BLUEPRINT\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
x = 5 y = x print(id(x)) print(id(y)) print() y = 3 print(id(x)) print(id(y)) print() z = [1, 4, 3, 25] w = z print(z) print(w) print(id(z)) print(id(w)) print() w[1] = 10 print(z) print(w) print(id(z)) print(id(w)) # So when you assign a mutable, you're actually assigning a reference to the mutable, # and I...
normal
{ "blob_id": "956adc5961188458393b56564649ad0a3a787669", "index": 7327, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(id(x))\nprint(id(y))\nprint()\n<mask token>\nprint(id(x))\nprint(id(y))\nprint()\n<mask token>\nprint(z)\nprint(w)\nprint(id(z))\nprint(id(w))\nprint()\n<mask token>\nprint(z)\nprin...
[ 0, 1, 2, 3 ]
from mpi4py import MPI from random import random comm = MPI.COMM_WORLD mydata = comm.rank data = comm.gather(mydata) if comm.rank == 0: print("Data = ", data)
normal
{ "blob_id": "acf3d188bd6c99774ddf538dcc83f99ad56c7057", "index": 7431, "step-1": "<mask token>\n", "step-2": "<mask token>\nif comm.rank == 0:\n print('Data = ', data)\n", "step-3": "<mask token>\ncomm = MPI.COMM_WORLD\nmydata = comm.rank\ndata = comm.gather(mydata)\nif comm.rank == 0:\n print('Data = ...
[ 0, 1, 2, 3, 4 ]
import matplotlib.pyplot as pt import numpy as np from scipy.optimize import leastsq #################################### # Setting up test data def norm(x, media, sd): norm = [] for i in range(x.size): norm += [1.0/(sd*np.sqrt(2*np.pi))*np.exp(-(x[i] - media)**2/(2*sd**2))] return np.array(norm)...
normal
{ "blob_id": "b3ce17401476afe2edfda3011d5602ba492cd705", "index": 5817, "step-1": "<mask token>\n\n\ndef res(p, y, x):\n m, dm, sd1, sd2 = p\n m1 = m\n m2 = m1 + m\n y_fit = norm(x, m1, sd1) + norm(x, m2, sd2)\n error = y - y_fit\n return error\n\n\n<mask token>\n", "step-2": "<mask token>\n\n...
[ 1, 2, 3, 4, 5 ]
from setuptools import setup setup(name='RedHatSecurityAdvisory', version='0.1', description='Script that automatically checks the RedHat security advisories to see if a CVE applies', author='Pieter-Jan Moreels', url='https://github.com/PidgeyL/RedHat-Advisory-Checker', entry_points={'con...
normal
{ "blob_id": "3f8c13be547099aa6612365452926db95828b9a0", "index": 554, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='RedHatSecurityAdvisory', version='0.1', description=\n 'Script that automatically checks the RedHat security advisories to see if a CVE applies'\n , author='Pieter-Jan Mo...
[ 0, 1, 2, 3 ]
from selenium import webdriver import math import time browser = webdriver.Chrome() website = 'http://suninjuly.github.io/find_link_text' link_text = str(math.ceil(math.pow(math.pi, math.e) * 10000)) browser.get(website) find_link = browser.find_element_by_link_text(link_text) find_link.click() input_first_name = brows...
normal
{ "blob_id": "aa17e22bc13436333b1db4aee41eeced373119a8", "index": 5704, "step-1": "<mask token>\n", "step-2": "<mask token>\nbrowser.get(website)\n<mask token>\nfind_link.click()\n<mask token>\ninput_first_name.send_keys('Timur')\n<mask token>\ninput_last_name.send_keys('Atabaev')\n<mask token>\ninput_city.send...
[ 0, 1, 2, 3 ]
#!/usr/bin/python3 def square_matrix_simple(matrix=[]): '''This function will compute the square root of all integers in a matrix. ''' new_matrix = [] for index in matrix: jndex = 0 new_row = [] while jndex < len(index): ...
normal
{ "blob_id": "b090e92fe62d9261c116529ea7f480daf8b3e84e", "index": 6543, "step-1": "<mask token>\n", "step-2": "def square_matrix_simple(matrix=[]):\n \"\"\"This function will compute the square root of all integers in\n a matrix. \"\"\"\n new_matrix = ...
[ 0, 1, 2 ]
""" Copyright © 2017 Bilal Elmoussaoui <bil.elmoussaoui@gmail.com> This file is part of Authenticator. Authenticator is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at ...
normal
{ "blob_id": "a7d8efe3231b3e3b9bfc5ef64a936816e8b67d6c", "index": 3127, "step-1": "<mask token>\n\n\n@Gtk.Template(resource_path=\n '/com/github/bilelmoussaoui/Authenticator/settings.ui')\nclass SettingsWindow(Handy.PreferencesWindow):\n <mask token>\n dark_theme_switch: Gtk.Switch = Gtk.Template.Child()...
[ 10, 11, 13, 19, 21 ]
#-*- coding: utf-8 -*- espacos = ["__1__", "__2__", "__3__", "__4__"] facil_respostas=["ouro","leao","capsula do poder","relampago de plasma"] media_respostas=["Ares","Saga","Gemeos","Athena"] dificil_respostas=["Shion","Aries","Saga","Gemeos"] def inicio_game(): apresentacao=raw_input("Bem vindo ao qui...
normal
{ "blob_id": "d205c38e18b1acf8043a5976a90939b14358dc40", "index": 7855, "step-1": "#-*- coding: utf-8 -*-\r\nespacos = [\"__1__\", \"__2__\", \"__3__\", \"__4__\"]\r\nfacil_respostas=[\"ouro\",\"leao\",\"capsula do poder\",\"relampago de plasma\"]\r\nmedia_respostas=[\"Ares\",\"Saga\",\"Gemeos\",\"Athena\"]\r\ndi...
[ 0 ]
import io import xlsxwriter import zipfile from django.conf import settings from django.http import Http404, HttpResponse from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin from django.contrib.auth.decorators import login_required from django.contrib import messages from django.views.generic...
normal
{ "blob_id": "a9ebd323d4b91c7e6a7e7179329ae80e22774927", "index": 4843, "step-1": "<mask token>\n\n\nclass PeriodoUpdateView(LoginRequiredMixin, UpdateView):\n <mask token>\n <mask token>\n <mask token>\n\n def get_form_kwargs(self, *args, **kwargs):\n kwargs = super(PeriodoUpdateView, self).ge...
[ 67, 76, 95, 101, 108 ]
import math print ("programa que calcula hipotenusa tomando el valor de los catetos en tipo double---") print ("------------------------------------------------------------------------") print (" ") catA = float(input("igrese el valor del cateto A")) catB = float(input("ingrese el valor del catebo B")) def calcularHi...
normal
{ "blob_id": "af217d0cc111f425282ee21bd47d9007a69a6239", "index": 6297, "step-1": "<mask token>\n\n\ndef calcularHipotenusa(catA, catB):\n hipotenusa = catA ** 2 + catB ** 2\n hipotenusa = math.sqrt(hipotenusa)\n hipotenusa = float(hipotenusa)\n print('la hipotenusa es: ', hipotenusa)\n\n\n<mask token...
[ 1, 2, 3, 4, 5 ]
try: from setuptools import setup, find_packages except ImportError: import ez_setup ez_setup.use_setuptools() from setuptools import setup, find_packages setup( name = "pip-utils", version = "0.0.1", url = 'https://github.com/mattpaletta/pip-utils', packages = find_packages(), inc...
normal
{ "blob_id": "5fe81a6143642d671686c6623a9ecc93e04a82bf", "index": 5711, "step-1": "<mask token>\n", "step-2": "try:\n from setuptools import setup, find_packages\nexcept ImportError:\n import ez_setup\n ez_setup.use_setuptools()\n from setuptools import setup, find_packages\nsetup(name='pip-utils', ...
[ 0, 1, 2 ]
''' Generate the output images and videos, including rendering of the pipeline ''' import os import matplotlib.image as mpimg import cv2 from moviepy.editor import VideoFileClip from networkx.drawing.nx_agraph import to_agraph import lanespipeline import lanefinder from compgraph import CompGraph, CompGraphRunner C...
normal
{ "blob_id": "456d79a69c170a59af742648f16e0171cd5a2412", "index": 1412, "step-1": "<mask token>\n\n\ndef create_dir(directory):\n if not os.path.exists(directory):\n os.makedirs(directory)\n\n\ndef get_full_paths_to_files(files_dir, filenames):\n return [os.path.join(files_dir, f) for f in filenames]...
[ 5, 6, 7, 8, 10 ]
# https://www.hackerrank.com/challenges/bon-appetit n, k = map(int, input().split()) prices = [int(temp) for temp in input().split()] taken = int(input()) if (sum(prices) - prices[k]) // 2 == taken: print("Bon Appetit") else: print(taken - (sum(prices) - prices[k])// 2)
normal
{ "blob_id": "aa15f684d23d97a45a416b1fdcfb192710ebb56f", "index": 2151, "step-1": "<mask token>\n", "step-2": "<mask token>\nif (sum(prices) - prices[k]) // 2 == taken:\n print('Bon Appetit')\nelse:\n print(taken - (sum(prices) - prices[k]) // 2)\n", "step-3": "n, k = map(int, input().split())\nprices =...
[ 0, 1, 2, 3 ]
# stdlib from typing import Any # third party import numpy as np # syft absolute import syft as sy from syft.core.common.uid import UID from syft.core.node.new.action_object import ActionObject from syft.core.node.new.action_store import DictActionStore from syft.core.node.new.context import AuthedServiceContext from...
normal
{ "blob_id": "b76d3b6a4c15833ee2b25fede5923e1fe1dc4dd7", "index": 5422, "step-1": "<mask token>\n\n\ndef test_signing_key() ->None:\n test_signing_key = SyftSigningKey.from_string(test_signing_key_string)\n assert isinstance(test_signing_key, SyftSigningKey)\n assert str(test_signing_key) == test_signing...
[ 3, 7, 10, 11, 12 ]
from src.produtos import * class Estoque(object): def __init__(self): self.categorias = [] self.subcategorias = [] self.produtos = [] self.menu_estoque() def save_categoria(self, categoria): pass def save_subcategorias(self, subcategoria): pa...
normal
{ "blob_id": "9f3ca0d5a10a27d926a0f306665889418f8d6a0c", "index": 5884, "step-1": "<mask token>\n\n\nclass Estoque(object):\n <mask token>\n\n def save_categoria(self, categoria):\n pass\n <mask token>\n\n def save_produtos(self, produto):\n pass\n <mask token>\n\n def create_subca...
[ 7, 11, 12, 17, 18 ]
""" Декоратор parser_stop - парсер результата вывода комманды docker stop. """ from functools import wraps def parser_stop(func): @wraps(func) def wrapper(*args, **kwargs): result = func(*args, **kwargs) stdout = result['stdout'] """ stdout: строки разделены \n """ ...
normal
{ "blob_id": "4af573fa17f86ee067b870dce1f6ee482d1b14ff", "index": 8281, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parser_stop(func):\n\n @wraps(func)\n def wrapper(*args, **kwargs):\n result = func(*args, **kwargs)\n stdout = result['stdout']\n \"\"\"\n stdou...
[ 0, 1, 2, 3 ]
N = int(input()) l = [] for n in range(N): x = int(input()) l.append(x) l.sort() print(*l, sep='\n')
normal
{ "blob_id": "a699b43c57c315967a6d1881d7012fee4a93607b", "index": 6347, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor n in range(N):\n x = int(input())\n l.append(x)\nl.sort()\nprint(*l, sep='\\n')\n", "step-3": "N = int(input())\nl = []\nfor n in range(N):\n x = int(input())\n l.append...
[ 0, 1, 2 ]
#!/usr/bin/env python # Copyright (c) 2019, University of Stuttgart # All rights reserved. # # Permission to use, copy, modify, and distribute this software for any purpose # with or without fee is hereby granted, provided that the above copyright # notice and this permission notice appear in all copies. # # THE ...
normal
{ "blob_id": "007cce815f3ad4e47593ff00ff2e73d5d9961d9e", "index": 3211, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(2):\n renderer.set_drawing_axis(i)\n renderer.draw_ws_obstacles()\n renderer.draw_ws_point(source, color='k', shape='o')\n renderer.background_matrix_eval = Fal...
[ 0, 1, 2, 3, 4 ]
def decorate(a): def inner(f): def decorated(*args, **kwargs): return f(a, *args, **kwargs) return decorated return inner @decorate(3) def func(a, b, c): print a, b, c func(1, 2)
normal
{ "blob_id": "d2049b20e00b45df9fb0772d9a654a58a00191c5", "index": 9865, "step-1": "def decorate(a):\n def inner(f):\n def decorated(*args, **kwargs):\n return f(a, *args, **kwargs)\n return decorated\n return inner\n\n\n@decorate(3)\ndef func(a, b, c):\n print a, b, c\n\n\nfunc(1...
[ 0 ]
# addtwo_run-py """ Train and test a TCN on the add two dataset. Trying to reproduce https://arxiv.org/abs/1803.01271. """ print('Importing modules') import torch import torch.nn as nn import torch.optim as optim import torch.nn.functional as F from torch.utils.tensorboard import SummaryWriter from torch.uti...
normal
{ "blob_id": "fe1a9804862942491b11b9baceecd37bf628fbb8", "index": 8732, "step-1": "<mask token>\n\n\ndef run():\n torch.manual_seed(1729)\n \"\"\" Setup \"\"\"\n args = parse()\n device = torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')\n print(device)\n \"\"\" Dataset \"\"\"\n ...
[ 1, 2, 3, 4, 5 ]
from os import environ from process import process from s3Service import put_object environ['ACCESS_KEY'] = '1234567890' environ['SECRET_KEY'] = '1234567890' environ['ENDPOINT_URL'] = 'http://localhost:4566' environ['REGION'] = 'us-east-1' environ['BUCKET_GLOBAL'] = 'fl2-statement-global' environ['BUCKET_GLOBAL_BACKUP...
normal
{ "blob_id": "a4eca0f5b7d5a03ca3600554ae3fe3b94c59fc68", "index": 8622, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef execute(event, context):\n print(event)\n pass\n", "step-3": "<mask token>\nenviron['ACCESS_KEY'] = '1234567890'\nenviron['SECRET_KEY'] = '1234567890'\nenviron['ENDPOINT_U...
[ 0, 1, 2, 3, 4 ]
class Action(dict): def __init__(self, action, player=None, target=None): self['action'] = action self['player'] = player if target != None: self['target'] = target
normal
{ "blob_id": "1c9345923fe83aa0ee7165ce181ce05ac55e2b2f", "index": 7773, "step-1": "<mask token>\n", "step-2": "class Action(dict):\n <mask token>\n", "step-3": "class Action(dict):\n\n def __init__(self, action, player=None, target=None):\n self['action'] = action\n self['player'] = player...
[ 0, 1, 2 ]
from django.apps import AppConfig class ScambioConfig(AppConfig): name = 'scambio'
normal
{ "blob_id": "b091d00f5b5e997de87b36adbe9ce603a36ca49c", "index": 3347, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ScambioConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass ScambioConfig(AppConfig):\n name = 'scambio'\n", "step-4": "from django.apps import App...
[ 0, 1, 2, 3 ]
from django.contrib import admin from xchanger.models import Currency, Rates, UpdateInfo class CurrencyAdmin(admin.ModelAdmin): pass class UpdAdmin(admin.ModelAdmin): pass class RatesAdmin(admin.ModelAdmin): list_filter = ['c_code_id', 'upd_id'] admin.site.register(Currency, CurrencyAdmin) admin.sit...
normal
{ "blob_id": "20ccdd319bfbbb4f17e8518eb60d125112c05d8e", "index": 6828, "step-1": "<mask token>\n\n\nclass RatesAdmin(admin.ModelAdmin):\n list_filter = ['c_code_id', 'upd_id']\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass CurrencyAdmin(admin.ModelAdmin):\n pass\n\n\nclass UpdAdmin(admin.ModelA...
[ 2, 4, 5, 6 ]
# 4, [[1,0],[2,0],[3,1],[3,2]] # 3->1->0 # \ ^ # \ | # \> 2 # 1,0,2,3 # stack 3 # # 0 1 2 3 # 1,0 # stack 1 # 0 # # def findOrder(numCourses, prerequisites): # if len(prerequisites) == 0: # order = [] # for i in range(0, numCourses): # order.append(i) # return or...
normal
{ "blob_id": "56892e125934d5de937b92a08bd7707c12c70928", "index": 689, "step-1": "<mask token>\n", "step-2": "def findOrder(numCourses, prerequisites):\n if len(prerequisites) == 0:\n order = []\n for i in range(0, numCourses):\n order.append(i)\n return order\n edges = {}\...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # This file is part of CbM (https://github.com/ec-jrc/cbm). # Author : Konstantinos Anastasakis # Credits : GTCAP Team # Copyright : 2021 European Commission, Joint Research Centre # License : 3-Clause BSD from ipywidgets import (Text, VBox, HBox, Label, Password...
normal
{ "blob_id": "22afc6b9df87ef1eba284da20a807366278c24d4", "index": 1343, "step-1": "<mask token>\n\n\ndef rest_api(mode=None):\n \"\"\"\"\"\"\n values = config.read()\n wt_url = Text(value=values['api']['url'], placeholder='Add URL',\n description='API URL:', disabled=False)\n wt_user = Text(val...
[ 2, 3, 4, 5, 6 ]
""" This file goes through the data to find the frequencies of words in the corpus """ import csv import time, datetime import calendar from collections import defaultdict import chardet import re REVIEW_ID_COL = 0; USER_ID_COL = 1 BUSINESS_ID_COL = 2 STARS_COL = 3 DATE_COL = 4 TEXT_COL = 5 USEFUL_CO...
normal
{ "blob_id": "ba54b3a148a34ced74a337665ddd5f2d9084553b", "index": 1489, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('yelp_review.csv', encoding='utf8') as csvfile:\n wordFrequencies = defaultdict(int)\n\n def beautifyDate(res):\n dt = time.strptime(res, '%Y-%m-%d')\n retur...
[ 0, 1, 2, 3, 4 ]
import torch import torchvision.transforms.functional as F import numpy as np import yaml from pathlib import Path IGNORE_LABEL = 255 STATS = { "vit": {"mean": (0.5, 0.5, 0.5), "std": (0.5, 0.5, 0.5)}, "deit": {"mean": (0.485, 0.456, 0.406), "std": (0.229, 0.224, 0.225)}, } def seg_to_rgb(seg, colors): i...
normal
{ "blob_id": "6c641ace8f1e5e8c42fa776bd7604daf243f9a41", "index": 2113, "step-1": "<mask token>\n\n\ndef dataset_cat_description(path, cmap=None):\n desc = yaml.load(open(path, 'r'), Loader=yaml.FullLoader)\n colors = {}\n names = []\n for i, cat in enumerate(desc):\n names.append(cat['name'])\...
[ 2, 4, 5, 6, 7 ]
import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) IS_TESTING = False FOLDER_TO_ORGANIZE = '' FOLDER_FOR_OTHERS = '' FOLDER_TO_ORGANIZE_TEST = '' LOG_FILE = '' IGNORE_HIDDEN_FILES = True FILES_DESTINATION = { 'images': ['.jpg', '.jpeg', '.png'], 'documents': ['.pdf', '.xlsx', '....
normal
{ "blob_id": "83e2f9c56c45a288aabd777fb244089367649258", "index": 1165, "step-1": "<mask token>\n", "step-2": "<mask token>\nBASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))\nIS_TESTING = False\nFOLDER_TO_ORGANIZE = ''\nFOLDER_FOR_OTHERS = ''\nFOLDER_TO_ORGANIZE_TEST = ''\nLOG_FILE = ''\nI...
[ 0, 1, 2, 3 ]
import os, sys, string import linecache, math import numpy as np import datetime , time from pople import NFC from pople import uniqatoms from pople import orca_printbas ####### orca_run - S def orca_run(method, basis,optfreq,custombasis, correlated, values, charge, multip, sym, R_coord): """ Runs orca ...
normal
{ "blob_id": "019e8d7159fe07adc245e6476ac1fed5e9c457b5", "index": 3035, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef orca_run(method, basis, optfreq, custombasis, correlated, values,\n charge, multip, sym, R_coord):\n \"\"\"\n Runs orca\n\n Parameters:\n me...
[ 0, 1, 2, 3 ]
import os import pathlib from global_settings import * def get_bits(x): return np.where(x < 0, 0, 1) def check_wrong_bits(bits, bits_estimated): return len(np.argwhere(bits != bits_estimated)) def mkdir(file_path): folder = os.path.dirname(file_path) if not os.path.exists(folder): os.make...
normal
{ "blob_id": "74ffbd55867c4b2c6ccbef7d94e0c65aef139057", "index": 7602, "step-1": "<mask token>\n\n\ndef get_bits(x):\n return np.where(x < 0, 0, 1)\n\n\n<mask token>\n\n\ndef mkdir(file_path):\n folder = os.path.dirname(file_path)\n if not os.path.exists(folder):\n os.makedirs(folder)\n\n\n<mask ...
[ 7, 9, 11, 13, 14 ]
import csv import datetime with open('/Users/wangshibao/SummerProjects/analytics-dashboard/myapp/CrimeHistory.csv','rU') as f: reader = csv.reader(f) header = reader.next() date_time = "20140501 00:00" date_time = datetime.datetime.strptime(date_time, "%Y%m%d %H:%M") print date_t...
normal
{ "blob_id": "cfb49d78dc14e6f4b6d2357d292fd6275edec711", "index": 6844, "step-1": "import csv\nimport datetime\nwith open('/Users/wangshibao/SummerProjects/analytics-dashboard/myapp/CrimeHistory.csv','rU') as f:\n reader = csv.reader(f)\n header = reader.next()\n date_time = \"20140501 00:00\...
[ 0 ]
# Generated by Django 3.1 on 2020-08-28 14:03 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('api_rest', '0004_auto_20200828_0749'), ] operations = [ migrations.RemoveField( model_name='event', name='user_id', ...
normal
{ "blob_id": "bfd8385e8f4886b91dde59c04785134b9cd6a2b6", "index": 3893, "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 = [('api_rest', ...
[ 0, 1, 2, 3, 4 ]
import deform import deform.widget from deform import (widget) # decorator, default_renderer, field, form, import colander # import htmllaundry # from htmllaundry import sanitize from validators import (cyber_validator, phone_validator, stor_validator, ...
normal
{ "blob_id": "3a3400426b054b2fc3d060141a1f84e5db553e59", "index": 3424, "step-1": "<mask token>\n\n\n@colander.deferred\ndef deferred_country_widget(node, kw):\n country_codes_data = kw.get('country_codes_data', [])\n return widget.Select2Widget(values=country_codes_data)\n\n\n<mask token>\n\n\n@colander.de...
[ 5, 6, 7, 8, 9 ]
# -*- coding: utf-8 -*- """Testing constants for Bio2BEL FlyBase.""" import logging import os log = logging.getLogger(__name__) dir_path = os.path.dirname(os.path.realpath(__file__)) TEST_FILE = os.path.join(dir_path, 'test_gene_map_table.tsv.gz')
normal
{ "blob_id": "bad719d968b4e358f863b7ef13bc12127f726806", "index": 682, "step-1": "<mask token>\n", "step-2": "<mask token>\nlog = logging.getLogger(__name__)\ndir_path = os.path.dirname(os.path.realpath(__file__))\nTEST_FILE = os.path.join(dir_path, 'test_gene_map_table.tsv.gz')\n", "step-3": "<mask token>\ni...
[ 0, 1, 2, 3 ]
#8 def matrix(m): for i in range(len(m)): for j in range (len(m[0])): m[i][j]=(m[i][j])**2 a=[[1,2,3],[4,5,6],[8,9,0]] print('The matrix is ',a) matrix(a) print('The updated matrix is ',a)
normal
{ "blob_id": "f46dd5217c8e015546d7fff7ee52569ecc2c8e41", "index": 5487, "step-1": "<mask token>\n", "step-2": "def matrix(m):\n for i in range(len(m)):\n for j in range(len(m[0])):\n m[i][j] = m[i][j] ** 2\n\n\n<mask token>\n", "step-3": "def matrix(m):\n for i in range(len(m)):\n ...
[ 0, 1, 2, 3, 4 ]
#List methods allow you to modify lists. The following are some list methods for you to practice with. Feel free to google resources to help you with this assignment. #append(element) adds a single element to the list #1. 'Anonymous' is also deserving to be in the hacker legends list. Add him in to the hacker legends ...
normal
{ "blob_id": "53fd020946a2baddb1bb0463d2a56744de6e3822", "index": 5506, "step-1": "<mask token>\n", "step-2": "<mask token>\nhacker_legends.append('Anonymous')\nprint(hacker_legends)\n<mask token>\nnetworking.insert(3, 'SSH')\nprint(networking)\n<mask token>\nip_addy.remove(5102018)\nprint(ip_addy)\n<mask token...
[ 0, 1, 2, 3 ]
from keras.preprocessing.text import text_to_word_sequence import os # keras NLP tools filter out certain tokens by default # this function replaces the default with a smaller set of things to filter out def filter_not_punctuation(): return '"#$%&()*+-/:;<=>@[\\]^_`{|}~\t\n' def get_first_n_words(text, n): ...
normal
{ "blob_id": "365e2059d5ed3d7f8d9dbb4e44f563b79d68b087", "index": 1856, "step-1": "<mask token>\n\n\ndef get_labelled_data_from_directories(data_dir, maxlen=None):\n texts = []\n labels_index = {}\n labels = []\n for name in sorted(os.listdir(data_dir)):\n path = os.path.join(data_dir, name)\n ...
[ 1, 2, 3, 4, 5 ]
from flask import Flask, render_template, redirect, request, session app = Flask(__name__) app.secret_key = 'ThisIsSecret' #this line is always needed when using the import 'session' @app.route('/') #methods=['GET'] by default def index(): return render_template('index.html') @app.route('/ninja'...
normal
{ "blob_id": "001198459b038186ab784b6a9bed755924784866", "index": 4687, "step-1": "from flask import Flask, render_template, redirect, request, session\r\n\r\napp = Flask(__name__)\r\napp.secret_key = 'ThisIsSecret' #this line is always needed when using the import 'session'\r\n\r\n\r\n@app.route('/') #meth...
[ 0 ]
# -*- coding: utf-8 -*- # @File : config.py # @Author: TT # @Email : tt.jiaqi@gmail.com # @Date : 2018/12/4 # @Desc : config file from utils.general import getchromdriver_version from chromedriver.path import path import os import sys chromedriver = os.path.abspath(os.path.dirname(__file__)) + "\\chromedriver\\"+ g...
normal
{ "blob_id": "5b4a196de60a3a30bc571c559fe5f211563b8999", "index": 5449, "step-1": "<mask token>\n", "step-2": "<mask token>\nchromedriver = os.path.abspath(os.path.dirname(__file__)\n ) + '\\\\chromedriver\\\\' + getchromdriver_version()\ndownload_path = os.path.abspath(os.path.dirname(__file__)) + '\\\\'\nS...
[ 0, 1, 2, 3 ]
import abc import numpy as np import ray from tqdm.autonotebook import tqdm from src.algorithm.info_theory.it_estimator import (CachingEstimator, MPCachingEstimator) from src.algorithm.utils import differ, independent_roll, union class FeatureSelector(metaclass=ab...
normal
{ "blob_id": "983473129bfd56138a615e0f5bdb1353e9c6d8af", "index": 6441, "step-1": "<mask token>\n\n\nclass FeatureSelector(metaclass=abc.ABCMeta):\n <mask token>\n\n def _setup(self):\n self.n_features = self.trajectories[0].shape[1] - 1\n self.id_reward = self.n_features\n self.set_rew...
[ 16, 18, 20, 22, 23 ]
from firstfuncs_1618 import * figdir='/home/isabela/Documents/projects/OSNAP/figures_OSNAPwide/Freshwater/Linear/' figdir_paper='/home/isabela/Documents/projects/OSNAP/figures_OSNAPwide/Freshwater/paperfigs' ######################################################################################################## #####...
normal
{ "blob_id": "40b94a3be27ebb0d8e3e67fddabe1dc68646169c", "index": 9881, "step-1": "<mask token>\n\n\ndef get_U_S_T_from_WM(WM):\n U = {}\n S = {}\n T = {}\n for wm in WM.WM:\n U[str(wm.values)] = float(WM['TRANS'].sel(WM=wm).groupby(\n 'TIME.month').mean('TIME').mean(dim='month').val...
[ 10, 11, 13, 14, 16 ]
# Copyright 2017 The LUCI Authors. All rights reserved. # Use of this source code is governed under the Apache License, Version 2.0 # that can be found in the LICENSE file. DEPS = [ 'step', ] def RunSteps(api): try: api.step('test step', [{}]) except AssertionError as e: assert str(e) == 'Type <type \'...
normal
{ "blob_id": "25d210144ef209fd5e4ff7e4e4c2e77fd7eb79ac", "index": 3480, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef GenTests(api):\n yield api.test('basic')\n", "step-3": "<mask token>\n\n\ndef RunSteps(api):\n try:\n api.step('test step', [{}])\n except AssertionError as e:\n...
[ 0, 1, 2, 3, 4 ]
"""Sherlock Tests This package contains various submodules used to run tests. """ import sys import os import subprocess as sp from time import sleep # uncomment this if using nose sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../sherlock'))) # import sherlock
normal
{ "blob_id": "8f7b1313ba31d761edcadac7b0d04b62f7af8dff", "index": 4759, "step-1": "<mask token>\n", "step-2": "<mask token>\nsys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__),\n '../sherlock')))\n", "step-3": "<mask token>\nimport sys\nimport os\nimport subprocess as sp\nfrom time i...
[ 0, 1, 2, 3 ]
import pygame import numpy as np import random from enum import Enum from .config import * class Actions(Enum): FORWARD = 0 RIGHT = 1 LEFT = 2 BACK = 3 class MazeEnv(): ''' TODO ''' def __init__(self, GW, GH, SW, SH): global GRID_WIDTH, GRID_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, BOX_WID...
normal
{ "blob_id": "751d2a07b97d080988c54511ca13a97a969e06bd", "index": 6405, "step-1": "<mask token>\n\n\nclass MazeEnv:\n <mask token>\n\n def __init__(self, GW, GH, SW, SH):\n global GRID_WIDTH, GRID_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, BOX_WIDTH, BOX_HEIGHT\n GRID_WIDTH = GW\n GRID_HEIGHT...
[ 9, 10, 12, 13, 14 ]
class Background(object): def __init__(self, name): self.name = name self.description = '' self.prTraits = [] self.ideals = [] self.bonds = [] self.flaws = [] def getBackName(self): return self.name def setBackDesc(self,desc): self.descriptio...
normal
{ "blob_id": "45449e728dadd241b00f5c4bfb3fd3950f04037c", "index": 2627, "step-1": "class Background(object):\n\n def __init__(self, name):\n self.name = name\n self.description = ''\n self.prTraits = []\n self.ideals = []\n self.bonds = []\n self.flaws = []\n\n def ...
[ 11, 13, 14, 15, 16 ]
import os import tensorflow as tf import torch from tqdm import tqdm from glob import glob import numpy as np from collections.abc import Iterable from utils.hparams import HParam #from utils.audio import Audio #import librosa #python encoder_inference.py --in_dir training_libri_mel/train/ --gpu_str 5 #python tfrecord...
normal
{ "blob_id": "df40b0628d6a180a98cd385145ee7c65ecb78256", "index": 270, "step-1": "<mask token>\n\n\nclass TFRecordProducer:\n\n def remove_list(self, list1, list2):\n i, j = 0, 0\n tmp_list1 = []\n tmp_list2 = []\n while i < len(list1) and j < len(list2):\n item1 = int(li...
[ 4, 5, 6, 9, 10 ]
import re #lines = open("input.1").read() lines = open("input.2").read() lines = lines.splitlines() moves = {} moves["nw"] = [-1, -1] moves["ne"] = [ 0, -1] moves["w"] = [-1, 0] moves["e"] = [ 1, 0] moves["sw"] = [ 0, 1] moves["se"] = [ 1, 1] tiles = {} def fliptile(tile): if tile == "B": tile = "...
normal
{ "blob_id": "167c36627c7c3377266bde266e610792ba29b3e4", "index": 3808, "step-1": "import re\n\n#lines = open(\"input.1\").read()\nlines = open(\"input.2\").read()\nlines = lines.splitlines()\n\nmoves = {}\nmoves[\"nw\"] = [-1, -1]\nmoves[\"ne\"] = [ 0, -1]\nmoves[\"w\"] = [-1, 0]\nmoves[\"e\"] = [ 1, 0]\nmov...
[ 0 ]
__author__ = 'liwenchang' #-*- coding:utf-8 -*- import os import time import win32api, win32pdhutil, win32con, win32com.client import win32pdh, string def check_exsit(process_name): WMI = win32com.client.GetObject('winmgmts:') processCodeCov = WMI.ExecQuery('select * from Win32_Process where Name="%s"' % pro...
normal
{ "blob_id": "bb6d6061365fad809448d09a1c031b984423b5e0", "index": 8658, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef check_exsit(process_name):\n WMI = win32com.client.GetObject('winmgmts:')\n processCodeCov = WMI.ExecQuery(\n 'select * from Win32_Process where Name=\"%s\"' % proces...
[ 0, 2, 3, 4, 5 ]
# (C) Datadog, Inc. 2018 # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) from .agent import agent from .clean import clean from .config import config from .create import create from .dep import dep from .env import env from .meta import meta from .release import release from .run impor...
normal
{ "blob_id": "7a69a9fd6ee5de704a580e4515586a1c1d2b8017", "index": 5874, "step-1": "<mask token>\n", "step-2": "<mask token>\nALL_COMMANDS = (agent, clean, config, create, dep, env, meta, release, run,\n test, validate)\n", "step-3": "from .agent import agent\nfrom .clean import clean\nfrom .config import c...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- ################################## # @program synda # @description climate models data transfer program # @copyright Copyright "(c)2009 Centre National de la Recherche Scientifique CNRS. # All Rights Reserved" # @license CeCILL (https://raw.g...
normal
{ "blob_id": "0e6e84a31b626639e2aa149fd1ef89f3ef251cd7", "index": 207, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Context(Base):\n\n def __init__(self, dataset='', capsys=None):\n super(Context, self).__init__(capsys=capsys)\n self.dataset = ''\n self.dataset = datase...
[ 0, 4, 5, 6, 7 ]
# Import import sys from .step import Step from .repeat import Repeat # Workout class Workout(object): def __init__(self): self.workout = [] self.steps = [] self.postfixEnabled = True # TODO: check that len(name) <= 6 def addStep(self, name, duration): self.workout.append(...
normal
{ "blob_id": "3f80c4c212259a8f3ff96bcc745fd28a85dac3ba", "index": 8807, "step-1": "<mask token>\n\n\nclass Workout(object):\n <mask token>\n <mask token>\n\n def addRepeat(self, names, durations, count):\n self.workout.append(Repeat(names, durations, count))\n\n def generateCode(self, filename=...
[ 3, 4, 5, 6, 7 ]
import numpy as np def GradientDescent(f, gradf, x0, epsilon, num_iter, line_search, disp=False, callback=None, **kwargs): x = x0.copy() iteration = 0 opt_arg = {"f": f, "grad_f": gradf} for key in kwargs: opt_arg[key] = kwargs[key] while True: gradient = -gradf(x) alpha = line_search(x...
normal
{ "blob_id": "dca36de5556b120b8b93eac0ad7b971ad735d907", "index": 313, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef GradientDescent(f, gradf, x0, epsilon, num_iter, line_search, disp=\n False, callback=None, **kwargs):\n x = x0.copy()\n iteration = 0\n opt_arg = {'f': f, 'grad_f': gr...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python import os, sys # Assuming /tmp/foo.txt exists and has read/write permissions. ret = os.access("/tmp/foo.txt", os.F_OK) print "F_OK - return value %s"% ret ret = os.access("/tmp/foo.txt", os.R_OK) print "R_OK - return value %s"% ret ret = os.access("/tmp/foo.txt", os.W_OK) print "W_OK -...
normal
{ "blob_id": "c9b76fed088b85cf68e96778016d8974fea84933", "index": 4050, "step-1": "#!/usr/bin/python\r\nimport os, sys\r\n\r\n# Assuming /tmp/foo.txt exists and has read/write permissions.\r\n\r\nret = os.access(\"/tmp/foo.txt\", os.F_OK)\r\nprint \"F_OK - return value %s\"% ret\r\n\r\nret = os.access(\"/tmp/foo....
[ 0 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.6 on 2017-10-18 07:31 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): initial = True dependencies = [ ('auth', '0008_alter_user_username_max_length'), ] operations = [...
normal
{ "blob_id": "ab343f88c84d45cf90bddd52623362f047c72d3c", "index": 5754, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
# from models import dist_model # model = dist_model.DistModel() from os.path import join import models import util.util as util import matplotlib.pylab as plt use_gpu = True fig_outdir = r"C:\Users\ponce\OneDrive - Washington University in St. Louis\ImageDiffMetric" #%% net_name = 'squeeze' SpatialDist = models.Percep...
normal
{ "blob_id": "8fcbaf2663c22015a0c47f00c2d4fb8db6a5c308", "index": 6209, "step-1": "<mask token>\n", "step-2": "<mask token>\nif use_gpu:\n img0 = img0.cuda()\n<mask token>\nif use_gpu:\n img1 = img1.cuda()\n<mask token>\nplt.figure(figsize=[9, 3.5])\nplt.subplot(131)\nplt.imshow(img0_)\nplt.subplot(132)\n...
[ 0, 1, 2, 3, 4 ]
def solution(record): answer = [] db = {} chatting = [] for log in record: log_list = log.split() if log_list[0] == 'Enter': db[log_list[1]] = log_list[2] chatting.append([True, log_list[1]]) elif log_list[0] == 'Leave': chatting.append([Fals...
normal
{ "blob_id": "3ffe16494eb45896563a2952f3bcf80fc19b2750", "index": 1226, "step-1": "<mask token>\n", "step-2": "def solution(record):\n answer = []\n db = {}\n chatting = []\n for log in record:\n log_list = log.split()\n if log_list[0] == 'Enter':\n db[log_list[1]] = log_lis...
[ 0, 1, 2, 3 ]
# [SIG Python Task 1] """ Tasks to performs: a) Print 'Hello, World! From SIG Python - <your name>' to the screen b) Calculate Volume of a Sphere c) Create a customised email template for all students, informing them about a workshop. PS: This is called a docstring... and it will not be interepreted ...
normal
{ "blob_id": "150e0180567b74dfcd92a6cd95cf6c6bf36f6b5d", "index": 4228, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('hello, World! From SIG Python - Gaurangi Rawat')\n<mask token>\nprint('volume=', volume)\n<mask token>\nprint(email_msg)\n", "step-3": "<mask token>\nprint('hello, World! From SI...
[ 0, 1, 2, 3 ]
def solution(n, money): save = [0] * (n+1) save[0] = 1 for i in range(len(money)): for j in range(1, n+1): if j - money[i] >= 0: save[j] += (save[j - money[i]] % 1000000007) return save[n]
normal
{ "blob_id": "deeba82536d0366b3793bcbe78f78e4cfeabb612", "index": 6241, "step-1": "<mask token>\n", "step-2": "def solution(n, money):\n save = [0] * (n + 1)\n save[0] = 1\n for i in range(len(money)):\n for j in range(1, n + 1):\n if j - money[i] >= 0:\n save[j] += sav...
[ 0, 1, 2 ]
#!/usr/bin/python3 #https://github.com/pfnet-research/chainer-gan-lib/blob/master/wgan_gp/updater.py import numpy as np import chainer import chainer.functions as F from chainer import Variable from chainer.dataset import convert class WGANUpdater(chainer.training.updaters.StandardUpdater): def __init__(self, *a...
normal
{ "blob_id": "a7099b2506de08893ca849146813505d88784895", "index": 2402, "step-1": "<mask token>\n\n\nclass WGANUpdater(chainer.training.updaters.StandardUpdater):\n\n def __init__(self, *args, **kwargs):\n self.gen, self.dis = kwargs.pop('models')\n self.n_dis = kwargs.pop('n_dis')\n self....
[ 3, 4, 5, 6, 7 ]
from django.contrib.auth.forms import UserCreationForm from django.contrib.auth.views import LoginView from django.shortcuts import render from django.views import View from django.views.generic import CreateView from resume.forms import NewResumeForm from vacancy.forms import NewVacancyForm class MenuView(View): ...
normal
{ "blob_id": "a75691af17f6d1effd469d5c2ded340c71521ee1", "index": 9310, "step-1": "<mask token>\n\n\nclass MyLoginView(LoginView):\n redirect_authenticated_user = True\n template_name = 'login.html'\n\n\nclass HomeView(View):\n\n def get(self, request, *args, **kwargs):\n form = NewVacancyForm() i...
[ 4, 6, 7, 8, 10 ]
import scraperwiki html = scraperwiki.scrape('http://www.denieuwereporter.nl/') # scrape headlines van denieuwereporter-alle h1 koppen import lxml.html root = lxml.html.fromstring(html) tds = root.cssselect('h1') for h1 in tds: #print lxml.html.tostring(h1) print h1.text_content() record = {'h1': h1.text_c...
normal
{ "blob_id": "107b09696ac671e689235da55aaf4c26ae7c321c", "index": 6353, "step-1": "import scraperwiki\nhtml = scraperwiki.scrape('http://www.denieuwereporter.nl/')\n# scrape headlines van denieuwereporter-alle h1 koppen\n\nimport lxml.html\nroot = lxml.html.fromstring(html)\ntds = root.cssselect('h1')\nfor h1 in ...
[ 0 ]
# # -*- coding: utf-8 -*- # Copyright 2019 Fortinet, Inc. # GNU General Public License v3.0+ # (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) """ The fortios firewall monitor class It is in this file the runtime information is collected from the device for a given resource, parsed, and the facts tree is popu...
normal
{ "blob_id": "62bc8fec6833c5e8bc1598941eaad141ab6c9d5a", "index": 3758, "step-1": "<mask token>\n\n\nclass FirewallFacts(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass FirewallFacts(object):\n <mask token>\n <mask token>\n\n def populate_facts(self...
[ 1, 2, 5, 6, 7 ]
import pandas as pd dict_data = {'c0': [1, 2, 3], 'c1': [4, 5, 6], 'c2': [ 7, 8, 9], 'c3': [10, 11, 12], 'c4': [13, 14, 15]} df = pd.DataFrame(dict_data) print(type(df)) print('\n') print(df) # <class 'pandas.core.frame.DataFrame'> # c0 c1 c2 c3 c4 # 0 1 4 7 10 13 # 1 2 5 8 11 14 # 2 ...
normal
{ "blob_id": "22f4ae755e7ea43604db39452ca80f44f540708a", "index": 9503, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(type(df))\nprint('\\n')\nprint(df)\n", "step-3": "<mask token>\ndict_data = {'c0': [1, 2, 3], 'c1': [4, 5, 6], 'c2': [7, 8, 9], 'c3': [10, \n 11, 12], 'c4': [13, 14, 15]}\ndf =...
[ 0, 1, 2, 3, 4 ]
from sklearn.naive_bayes import * from sklearn import svm from sklearn.pipeline import Pipeline from sklearn.metrics import classification_report, confusion_matrix from optparse import OptionParser from helper import FileHelper, Word2VecHelper, GraphHelper import helper from helper.VectorHelper import * import os impo...
normal
{ "blob_id": "3bc9c6a66f749858ea5801202b0ac80755c1b347", "index": 6493, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef trainW2v(args):\n clazz = [['Accidents', 'Arts', 'Attacks', 'Economy', 'Miscellaneous',\n 'Politics', 'Science', 'Sports', 'undefined'], ['Accidents', 'Arts',\n '...
[ 0, 1, 2, 3, 4 ]
import pytest import app import urllib.parse @pytest.fixture def client(): app.app.config['TESTING'] = True with app.app.test_client() as client: yield client def test_query_missing_args(client): response = client.get('/data/query') assert 'errors' in response.json and '400' in response.sta...
normal
{ "blob_id": "a598da0a749fcc5a6719cec31ede0eb13fab228e", "index": 3171, "step-1": "<mask token>\n\n\n@pytest.fixture\ndef client():\n app.app.config['TESTING'] = True\n with app.app.test_client() as client:\n yield client\n\n\ndef test_query_missing_args(client):\n response = client.get('/data/que...
[ 6, 7, 9, 10, 11 ]
# -*- coding: utf-8 -*- # DATE 2018-08-21 # AUTHER = tongzz # import MySQLdb from Elements.LoginElements import * import datetime import sys class Tradepasswd(): def __init__(self): self.db_config={ 'host': '172.28.38.59', 'usr': 'mysqladmin', 'passwd': '12...
normal
{ "blob_id": "ed66e8028d653cf6b7ea4703fef5a658665c48db", "index": 1034, "step-1": "# -*- coding: utf-8 -*-\r\n# DATE 2018-08-21\r\n# AUTHER = tongzz\r\n#\r\n\r\nimport MySQLdb\r\nfrom Elements.LoginElements import *\r\nimport datetime\r\nimport sys\r\nclass Tradepasswd():\r\n def __init__(self):\r\n sel...
[ 0 ]
from django.core import serializers from django.db import models from uuid import uuid4 from django.utils import timezone from django.contrib.auth.models import User class Message(models.Model): uuid=models.CharField(max_length=50) user=models.CharField(max_length=20) message=models.CharField(max_length=20...
normal
{ "blob_id": "1476d4f488e6c55234a34dc5b6182e3b8ad4f702", "index": 6201, "step-1": "<mask token>\n\n\nclass Message(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Message(models.Mo...
[ 1, 4, 5, 6, 7 ]
import json from logger import logger def parse_json(text): start = text.find("{") end = text.find("}") + 1 try: data = json.loads(text[start:end]) return data except Exception: logger.error("json解析失败:%s" % text)
normal
{ "blob_id": "9f8fbfb8a9c849ca0e8881c479800c8e190e4a1c", "index": 6485, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_json(text):\n start = text.find('{')\n end = text.find('}') + 1\n try:\n data = json.loads(text[start:end])\n return data\n except Exception:\n ...
[ 0, 1, 2, 3 ]
import sys, string, math s = input() print(ord(s))
normal
{ "blob_id": "ade300f2921ca860bbe92aa351df2c88238b7996", "index": 6039, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(ord(s))\n", "step-3": "<mask token>\ns = input()\nprint(ord(s))\n", "step-4": "import sys, string, math\ns = input()\nprint(ord(s))\n", "step-5": null, "step-ids": [ 0, ...
[ 0, 1, 2, 3 ]
import pandas as pd import numpy as np import inspect from script.data_handler.Base.df_plotterMixIn import df_plotterMixIn from script.util.MixIn import LoggerMixIn from script.util.PlotTools import PlotTools DF = pd.DataFrame Series = pd.Series class null_clean_methodMixIn: @staticmethod def drop_col(df: D...
normal
{ "blob_id": "198beb5a17575d781f7bce1ab36a6213ad7331b3", "index": 5853, "step-1": "<mask token>\n\n\nclass Base_dfCleaner(LoggerMixIn, null_clean_methodMixIn, df_plotterMixIn):\n <mask token>\n <mask token>\n\n def __init__(self, df: DF, df_Xs_keys, df_Ys_key, silent=False, verbose=0):\n LoggerMix...
[ 8, 15, 16, 17, 19 ]
""" openAI gym 'cart pole-v0' """ import numpy as np import tensorflow as tf from collections import deque import random import dqn import gym import matplotlib.pyplot as plt # define environment env = gym.make('CartPole-v0') # define parameters INPUT_SIZE = env.observation_space.shape[0] OUTPUT_SIZE = env.action_sp...
normal
{ "blob_id": "9a40861239268aa62075b77b3ed452f31bb14fac", "index": 2458, "step-1": "<mask token>\n\n\ndef get_copy_var_ops(src_scope_name: str, dest_scope_name: str) ->list:\n holder = []\n src_vars = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope=\n src_scope_name)\n dest_vars = tf.get_...
[ 4, 5, 6, 7, 8 ]
from tree import Tree, createIntTree t = createIntTree() print('show', t.root.show()) print('sum', t.root.sum()) print('find 3', t.root.find(3) != False) print('evens', t.root.evens()) print('min depth', t.root.min_depth())
normal
{ "blob_id": "21a7fd5148f73ac47adafc9d5c2361ebe318ae59", "index": 2842, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('show', t.root.show())\nprint('sum', t.root.sum())\nprint('find 3', t.root.find(3) != False)\nprint('evens', t.root.evens())\nprint('min depth', t.root.min_depth())\n", "step-3": ...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import pickle import pathlib from pathlib import Path from typing import List, Tuple, Dict import numpy as np import torch import torch.nn as nn from torch.optim import SGD, Adam from torch.utils.data import Dataset, DataLoader from torchtext.data import get_tokenizer from matplotlib import py...
normal
{ "blob_id": "9c653719ea511d78de9ddcc19442d9f9f7dc11dc", "index": 4560, "step-1": "<mask token>\n\n\nclass Vocabulary:\n \"\"\"\n Helper class that maps words to unique indices and the other way around\n \"\"\"\n\n def __init__(self, tokens: List[str]):\n self.word_to_idx = {'<PAD>': 0}\n ...
[ 20, 23, 25, 30, 31 ]