code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
# -*- coding: utf-8 -*- from rest_framework import serializers from django.contrib.auth.models import User from core.models import Detalhe, Viagem, Hospital, Equipamento, Caixa class UserSerializer(serializers.HyperlinkedModelSerializer): class Meta: model = User fields = '__all__' class CaixaSeri...
normal
{ "blob_id": "b5c68211cfa255e47ee316dc5b0627719eacae78", "index": 8504, "step-1": "<mask token>\n\n\nclass ViagemSerializer(serializers.ModelSerializer):\n detalhes = DetalheSerializer(many=True, read_only=True)\n caixa = CaixaSerializer(read_only=True)\n localPartida = HospitalSerializer(read_only=True)...
[ 2, 6, 7, 8, 9 ]
# -*- coding: utf-8 -*- c = int(input()) t = input() m = [] for i in range(12): aux = [] for j in range(12): aux.append(float(input())) m.append(aux) aux = [] soma = 0 for i in range(12): soma += m[i][c] resultado = soma / (t == 'S' and 1 or 12) print('%.1f' % resultado)
normal
{ "blob_id": "6edb1f99ca9af01f28322cbaf13f278e79b94e92", "index": 5882, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(12):\n aux = []\n for j in range(12):\n aux.append(float(input()))\n m.append(aux)\n aux = []\n<mask token>\nfor i in range(12):\n soma += m[i][c]\n<m...
[ 0, 1, 2, 3 ]
''' 'Daniel Moulton '3/24/15 'Implementation of the mergesort sorting algorithm in python. 'Utilizes a series of random numbers as the initial input 'Uses a top down approach to recursively sort the original list and output the final result. ''' from random import randrange def mergeSort(original_list): #initiali...
normal
{ "blob_id": "294229849dcfac8d4afeab79dae3c652c853fc47", "index": 1924, "step-1": "<mask token>\n\n\ndef mergeSort(original_list):\n return subSort(original_list)\n\n\ndef subSort(sub_list):\n if len(sub_list) < 2:\n return sub_list\n index = len(sub_list) // 2\n left_list = sub_list[0:index]\n...
[ 4, 5, 6, 7, 8 ]
# settings import config # various modules import sys import time import multiprocessing import threading from queue import Queue import time import os import signal import db import time from random import randint # telepot's msg loop & Bot from telepot.loop import MessageLoop from telepot import Bot import asyncio...
normal
{ "blob_id": "315fed1806999fed7cf1366ef0772318a0baa84d", "index": 8789, "step-1": "# settings\nimport config\n\n# various modules\nimport sys\nimport time\nimport multiprocessing\nimport threading\nfrom queue import Queue\nimport time\nimport os\nimport signal\nimport db\nimport time\nfrom random import randint\n...
[ 0 ]
from typing import Dict, Tuple import torch from tqdm import tqdm import schnetpack.properties as structure from schnetpack.data import AtomsLoader __all__ = ["calculate_stats"] def calculate_stats( dataloader: AtomsLoader, divide_by_atoms: Dict[str, bool], atomref: Dict[str, torch.Tensor] = None, ) ->...
normal
{ "blob_id": "b2944a95dbe25057155aaf6198a97d85b3bb620b", "index": 6436, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef calculate_stats(dataloader: AtomsLoader, divide_by_atoms: Dict[str,\n bool], atomref: Dict[str, torch.Tensor]=None) ->Dict[str, Tuple[torch.\n Tensor, torch.Tensor]]:\n \...
[ 0, 1, 2, 3, 4 ]
import tensorflow as tf class Config(object): # Source and Target files from_train_file='data/dev.en' to_train_file='data/dev.vi' # Special characters and ID's _PAD = b"_PAD" _GO = b"_GO" _EOS = b"_EOS" _UNK = b"_UNK" _START_VOCAB = [_PAD, _GO, _EOS, _UNK] PAD_ID = 0 GO_I...
normal
{ "blob_id": "c27c2df1830f066ca4f973c46967722869090d05", "index": 1373, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Config(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Tue Oct 9 16:22:21 2018 @author: SDis """ #import Code.Members_module class Resources: """ Parent class for Books and eResources containg the main data fields and related setters and getters""" def __init__(self, title, author, publisher, year): self.title = tit...
normal
{ "blob_id": "0709d413ddbe41a0c97f94b7819fdfded241d3fc", "index": 691, "step-1": "<mask token>\n\n\nclass Resources:\n <mask token>\n\n def __init__(self, title, author, publisher, year):\n self.title = title\n self.author = author\n self.publisher = publisher\n self.year = year\...
[ 4, 8, 9, 10, 13 ]
import socket import json from typing import Dict listadionica = ["GS", "MS", "WFC", "VALBZ", "BOND", "VALE", "XLF"] class Burza: def __init__ (self, test): if test: host_name = "test-exch-partitivnisumari" port = 25000 else: host_name = "production" ...
normal
{ "blob_id": "5a895c864c496e1073d75937909c994432a71d75", "index": 9760, "step-1": "import socket\nimport json\n\nfrom typing import Dict\n\nlistadionica = [\"GS\", \"MS\", \"WFC\", \"VALBZ\", \"BOND\", \"VALE\", \"XLF\"]\n\nclass Burza:\n def __init__ (self, test):\n\n if test:\n host_name = ...
[ 0 ]
import cv2 import numpy as np img = cv2.imread('Scan1.jpg') img_height, img_width, dim = img.shape cv2.imshow('image1', img[0:int(img_height / 2), 0:int(img_width / 2)]) cv2.imshow('image2', img[int(img_height / 2):img_height, 0:int(img_width / 2)]) cv2.imshow('image3', img[0:int(img_height / 2), int(img_width / 2):img...
normal
{ "blob_id": "8c6f890631e9696a7907975b5d0bb71d03b380da", "index": 839, "step-1": "<mask token>\n", "step-2": "<mask token>\ncv2.imshow('image1', img[0:int(img_height / 2), 0:int(img_width / 2)])\ncv2.imshow('image2', img[int(img_height / 2):img_height, 0:int(img_width / 2)])\ncv2.imshow('image3', img[0:int(img_...
[ 0, 1, 2, 3 ]
import random from .action import Action from ..transition.step import Step from ..value.estimators import ValueEstimator def greedy(steps: [Step], actions: [Action], value_estimator: ValueEstimator) -> int: estimations = [value_estimator(steps, action) for action in actions] return actions[estimations.index...
normal
{ "blob_id": "eab45dafd0366af8ab904eb33719b86777ba3d65", "index": 2925, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef e_greedy(steps: [Step], actions: [Action], value_estimator:\n ValueEstimator, e: float) ->int:\n return random.sample(actions, 1) if random.uniform(0, 1) < e else greedy(\n ...
[ 0, 1, 2, 3, 4 ]
import numpy as np import tensorflow as tf K_model = tf.keras.models.load_model('K_model.h5') K_model.summary() features, labels = [], [] # k_file = open('dataset_20200409.tab') k_file = open('ts.tab') for line in k_file.readlines(): line = line.rstrip() contents = line.split("\t") label = contents.pop()...
normal
{ "blob_id": "1c2a862f995869e3241dd835edb69399141bfb64", "index": 8926, "step-1": "<mask token>\n", "step-2": "<mask token>\nK_model.summary()\n<mask token>\nfor line in k_file.readlines():\n line = line.rstrip()\n contents = line.split('\\t')\n label = contents.pop()\n labels.append([float(label)])...
[ 0, 1, 2, 3, 4 ]
# len(): tamanho da string # count(): conta quantas vezes um caractere aparece # lower(), upper() # replace(): substitui as letras por outra # split(): quebra uma string a partir dos espacos em branco a = len('Karen') print(a) b = 'Rainha Elizabeth'.count('a') print(b) c = 'karen nayara'.replace('a','@') print(c) d = ...
normal
{ "blob_id": "3079fdbe6319454ad166d06bda5670554a5746ee", "index": 1004, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(a)\n<mask token>\nprint(b)\n<mask token>\nprint(c)\n<mask token>\nprint(d)\n", "step-3": "a = len('Karen')\nprint(a)\nb = 'Rainha Elizabeth'.count('a')\nprint(b)\nc = 'karen nayar...
[ 0, 1, 2, 3 ]
# line_count.py import sys count = 0 for line in sys.stdin: count += 1 # print goes to sys.stdout print count
normal
{ "blob_id": "46194829fc54c2f3e51febde572e05bcff261fb2", "index": 7126, "step-1": "# line_count.py\nimport sys\ncount = 0\nfor line in sys.stdin:\n\tcount += 1\n# print goes to sys.stdout\nprint count", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
# Libraries from sqlalchemy import Column, ForeignKey, Integer, String from sqlalchemy.ext.associationproxy import association_proxy from sqlalchemy.orm import relationship # Taskobra from taskobra.orm.base import ORMBase from taskobra.orm.relationships import SystemComponent class System(ORMBase): __tablename__ ...
normal
{ "blob_id": "2fc2fd6631cee5f3737dadaac1a115c045af0986", "index": 5058, "step-1": "<mask token>\n\n\nclass System(ORMBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def add_component(self, component):\n for system_component in self.s...
[ 3, 4, 5, 6, 8 ]
from abstract_class_V import V import torch import torch.nn as nn class V_test_abstract(V): def __init__(self): super(V_test_abstract, self).__init__() def V_setup(self,y,X,nu): self.explicit_gradient = False self.need_higherorderderiv = True self.dim = X.shape[1] self...
normal
{ "blob_id": "27e9e63338d422b5fca6f7a67fa3d255602a3358", "index": 225, "step-1": "<mask token>\n\n\nclass V_test_abstract(V):\n\n def __init__(self):\n super(V_test_abstract, self).__init__()\n <mask token>\n\n def forward(self):\n z = self.beta[:self.dim]\n r1_local = self.beta[self...
[ 3, 4, 5, 6, 7 ]
# day one question 1 solution # find product of two numbers in input.txt list that sum to 2020 # pull everything out of input file nums = [] with open('input.txt', 'r') as file: for line in file: nums.append(int(line)) target = 0 product = 0 # for each number in the input, figure out what it's complement...
normal
{ "blob_id": "38504dae7b010c2df8c16b752c2179b6b3561c0e", "index": 7770, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('input.txt', 'r') as file:\n for line in file:\n nums.append(int(line))\n<mask token>\nfor ini in nums:\n target = 2020 - ini\n for chk in nums:\n if chk ...
[ 0, 1, 2, 3 ]
import array as arr # from array import * # To remove use of 'arr' everytime. studentMarks = arr.array('i', [2,30,45,50,90]) # i represnts datatype of array which is int here. # accessing array print(studentMarks[3]) studentMarks.append(95) # using for loop for i in studentMarks: print(i) # usin...
normal
{ "blob_id": "d442d5c7afd32dd149bb47fc9c4355409c53dab8", "index": 6719, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(studentMarks[3])\nstudentMarks.append(95)\nfor i in studentMarks:\n print(i)\n<mask token>\nwhile i < len(studentMarks):\n print(studentMarks[i])\n i += 1\n", "step-3": "...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # This file just executes its arguments, except that also adds OUT_DIR to the # environ. This is for compatibility with cargo. import subprocess import sys import os os.environ["OUT_DIR"] = os.path.abspath(".") assert os.path.isdir(os.environ["OUT_DIR"]) sys.exit(subprocess.call(sys.argv[1:], env...
normal
{ "blob_id": "be238268b9fdd565f3cb0770839789b702940ef9", "index": 8248, "step-1": "<mask token>\n", "step-2": "<mask token>\nassert os.path.isdir(os.environ['OUT_DIR'])\nsys.exit(subprocess.call(sys.argv[1:], env=os.environ))\n", "step-3": "<mask token>\nos.environ['OUT_DIR'] = os.path.abspath('.')\nassert os...
[ 0, 1, 2, 3, 4 ]
""" This handy script will download all wallpapears from simpledesktops.com Requirements ============ BeautifulSoup - http://www.crummy.com/software/BeautifulSoup/ Python-Requests - http://docs.python-requests.org/en/latest/index.html Usage ===== cd /path/to/the/script/ python simpledesktops.py """ from StringIO imp...
normal
{ "blob_id": "452d5d98b6c0b82a1f4ec18f29d9710a8c0f4dc9", "index": 7371, "step-1": "\"\"\"\nThis handy script will download all wallpapears from simpledesktops.com\n\nRequirements\n============\nBeautifulSoup - http://www.crummy.com/software/BeautifulSoup/\nPython-Requests - http://docs.python-requests.org/en/late...
[ 0 ]
""" OO 05-18-2020 Task ---------------------------------------------------------------------------------------------------------- Your company needs a function that meets the following requirements: - For a given array of 'n' integers, the function returns the index of the element with the minimum value ...
normal
{ "blob_id": "8fdc9a52b00686e10c97fa61e43ddbbccb64741b", "index": 8946, "step-1": "<mask token>\n\n\nclass TestDataEmptyArray(object):\n\n @staticmethod\n def get_array():\n return []\n\n\nclass TestDataUniqueValues(object):\n\n @staticmethod\n def get_array():\n return [5, 3, 2]\n\n ...
[ 9, 10, 11, 13, 14 ]
#coding=utf-8 import pandas as pd # 学生成绩表 df_grade = pd.read_excel("学生成绩表.xlsx") df_grade.head() # 学生信息表 df_sinfo = pd.read_excel("学生信息表.xlsx") df_sinfo.head() # 只筛选第二个表的少量的列 df_sinfo = df_sinfo[["学号", "姓名", "性别"]] df_sinfo.head() # join df_merge = pd.merge(left=df_grade, right=df_sinfo, left_on="学号", right_on="学...
normal
{ "blob_id": "f6c48731b2a4e0a6f1f93034ee9d11121c2d0427", "index": 6810, "step-1": "<mask token>\n", "step-2": "<mask token>\ndf_grade.head()\n<mask token>\ndf_sinfo.head()\n<mask token>\ndf_sinfo.head()\n<mask token>\ndf_merge.head()\n<mask token>\nfor name in ['姓名', '性别'][::-1]:\n new_columns.remove(name)\n...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'MainMenu.ui' # # Created by: PyQt5 UI code generator 5.9.2 # # WARNING! All changes made in this file will be lost! from PyQt5 import QtCore, QtGui, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWind...
normal
{ "blob_id": "f4094a81f90cafc9ae76b8cf902221cbdbc4871a", "index": 6711, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Ui_MainWindow(object):\n <mask token>\n\n def retranslateUi(self, MainWindow):\n _translate = QtCore.QCoreApplication.translate\n MainWindow.setWindowTitle(_...
[ 0, 2, 3, 4, 5 ]
from igbot import InstaBot from settings import username, pw from sys import argv def execute_script(InstaBot): InstaBot.get_unfollowers() #InstaBot.unfollow() #InstaBot.follow() #InstaBot.remove_followers() def isheadless(): if len(argv) > 1: if argv[1] == 'head': return False else: raise ValueError("...
normal
{ "blob_id": "f379092cefe83a0a449789fbc09af490081b00a4", "index": 3818, "step-1": "<mask token>\n\n\ndef isheadless():\n if len(argv) > 1:\n if argv[1] == 'head':\n return False\n else:\n raise ValueError(\"optional arg must be : 'head'\")\n return True\n\n\n<mask token>\...
[ 1, 2, 3, 4, 5 ]
print(4 / 2, 4 / 3, 4 / 4) print(5 / 2, 5 / 3, 5 / 4) print(4 // 2, 4 // 3, 4 // 4) print(5 // 2, 5 // 3, 5 // 4) print(4.0 / 2, 4 / 3.0, 4.0 / float(4)) print(5.0 / 2, 5 / 3.0, 5.0 / float(4)) print(4.0 // 2, 4 // 3.0, 4.0 // float(4)) print(5.0 // 2, 5 // 3.0, 5.0 // float(4))
normal
{ "blob_id": "988e1f0631c434cbbb6d6e973792a65ebbd9405e", "index": 9474, "step-1": "<mask token>\n", "step-2": "print(4 / 2, 4 / 3, 4 / 4)\nprint(5 / 2, 5 / 3, 5 / 4)\nprint(4 // 2, 4 // 3, 4 // 4)\nprint(5 // 2, 5 // 3, 5 // 4)\nprint(4.0 / 2, 4 / 3.0, 4.0 / float(4))\nprint(5.0 / 2, 5 / 3.0, 5.0 / float(4))\np...
[ 0, 1 ]
from __future__ import print_function import matplotlib.pyplot as plt import numpy as np import os import sys import tarfile import tensorflow as tf from IPython.display import display, Image from scipy import ndimage from sklearn.linear_model import LogisticRegression from six.moves.urllib.request import u...
normal
{ "blob_id": "28c4c09b81d63785750cee36a8efd77760cac451", "index": 7231, "step-1": "<mask token>\n\n\ndef rotate_img(image, angle, color, filter=Image.NEAREST):\n if image.mode == 'P' or filter == Image.NEAREST:\n matte = Image.new('1', image.size, 1)\n else:\n matte = Image.new('L', image.size...
[ 5, 8, 9, 11, 12 ]
import librosa import soundfile import os, glob import numpy as np from sklearn.model_selection import train_test_split from sklearn.neural_network import MLPClassifier from sklearn.metrics import accuracy_score emotionsRavdessData = { '01': 'neutral', '02': 'calm', '03': 'happy', '04': 'sad', '05'...
normal
{ "blob_id": "8cd54362680aa3a96babe100b9231f6f16b3f577", "index": 6670, "step-1": "<mask token>\n\n\ndef extract_feature(file_name, mfcc, chroma, mel):\n with soundfile.SoundFile(file_name) as file:\n X = file.read(dtype='float32')\n sample_rate = file.samplerate\n if chroma:\n ...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- """ Created on Thu Jun 28 16:36:56 2018 @author: Alex """ #%% Import packages import pickle import numpy as np import matplotlib.pyplot as plt import networkx as nx import os os.chdir('C:\\Users\\Alex\\Documents\\GitHub\\insight-articles-project\\src\\topic modeling\\') from plotly_network ...
normal
{ "blob_id": "d98db745be2ab9c506a98539b25e9b46e4997136", "index": 3422, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.chdir(\n 'C:\\\\Users\\\\Alex\\\\Documents\\\\GitHub\\\\insight-articles-project\\\\src\\\\topic modeling\\\\'\n )\n<mask token>\nwith open(filename, 'rb') as fp:\n topic_assi...
[ 0, 1, 2, 3, 4 ]
from tempfile import mkdtemp from shutil import rmtree from os.path import join import os MAX_UNCOMPRESSED_SIZE = 100e6 # 100MB # Extracts a zipfile into a directory safely class ModelExtractor(object): def __init__(self, modelzip): self.modelzip = modelzip def __enter__(self): if not self._...
normal
{ "blob_id": "04670041dab49f8c2d4a0415030356e7ea92925f", "index": 902, "step-1": "<mask token>\n\n\nclass ModelExtractor(object):\n\n def __init__(self, modelzip):\n self.modelzip = modelzip\n\n def __enter__(self):\n if not self.__is_model_good():\n raise ValueError('Invalid model ...
[ 5, 6, 7, 8, 9 ]
# Check given matrix is valid sudoku or Not.
normal
{ "blob_id": "502da0f0dafe42d3464fabb1d92ae1b0d7ef11f3", "index": 431, "step-1": "# Check given matrix is valid sudoku or Not.\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 1 ] }
[ 1 ]
from queue import Queue class Stack: def __init__(self): self.q1 = Queue() self.q2 = Queue() def empty(self): return self.q1.empty() def push(self, element): if self.empty(): self.q1.enqueue(element) else: self.q2.enqueue(element) ...
normal
{ "blob_id": "4f5f4aadfeabb13790b417b334c5f73c6d0345a7", "index": 9256, "step-1": "<mask token>\n\n\nclass Stack:\n\n def __init__(self):\n self.q1 = Queue()\n self.q2 = Queue()\n\n def empty(self):\n return self.q1.empty()\n\n def push(self, element):\n if self.empty():\n ...
[ 5, 7, 8, 9, 11 ]
from flask import Blueprint, render_template, request, session, url_for, redirect from flask_socketio import join_room, leave_room, send, emit from models.game.game import Game from models.games.games import Games from decorators.req_login import requires_login game_blueprint = Blueprint('game', __name__) @game_bluep...
normal
{ "blob_id": "1ccb23435d8501ed82debf91bd6bf856830d01cb", "index": 6063, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@game_blueprint.route('/<string:game_id>')\n@requires_login\ndef game_index(game_id):\n return render_template('game/game.html')\n", "step-3": "<mask token>\ngame_blueprint = Blu...
[ 0, 1, 2, 3 ]
from collections import Counter N = int(input()) lst = list(map(int, input().split())) ans = [] for i in range(N): ans.append(abs(i + 1 - lst[i])) s = Counter(ans) rst = [] for i in s: rst.append([i, s[i]]) rst.sort(key=lambda x: x[0], reverse=True) for i in rst: if i[1] > 1: print(i[0], i[1])
normal
{ "blob_id": "decd5d50025fc3b639be2f803d917ff313cf7219", "index": 8838, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(N):\n ans.append(abs(i + 1 - lst[i]))\n<mask token>\nfor i in s:\n rst.append([i, s[i]])\nrst.sort(key=lambda x: x[0], reverse=True)\nfor i in rst:\n if i[1] > 1:\...
[ 0, 1, 2, 3 ]
''' Temperature Container ''' class TempHolder: range_start = 0 range_end = 0 star_count_lst = [0,0,0,0,0,0] counter = 0 def __init__(self, in_range_start, in_range_end): self.range_start = in_range_start self.range_end = in_range_end self.counter = 0 self.s...
normal
{ "blob_id": "330b843501e0fdaff21cc4eff1ef930d54ab6e8d", "index": 747, "step-1": "<mask token>\n\n\nclass FRSHTTHolder:\n frshtt_code = ''\n star_count_lst = [0, 0, 0, 0, 0, 0]\n counter = 0\n\n def __init__(self, in_frshtt_code):\n self.frshtt_code = in_frshtt_code\n self.counter = 0\n ...
[ 11, 13, 15, 19, 23 ]
# Create a program that will ask the users name, age, and reddit username. # Have it tell them the information back, in the format: # # Your name is (blank), you are (blank) years old, and your username is (blank) # # For extra credit, have the program log this information in a file to be accessed later. # name = ...
normal
{ "blob_id": "00531c5a7fdcd24204b0546c081bbe7d63d0a6b2", "index": 1520, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Your name is ' + name + ', you are ' + age +\n ' years old, and your username is ' + reddit)\n", "step-3": "name = input('What is your name? ')\nage = input('How old are you? ...
[ 0, 1, 2, 3 ]
# This program just for testing push from Mac. def subset2(num): mid_result = [] result = [] subset2_helper(num, mid_result, result, 0) print(result) def subset2_helper(num, mid_result, result, position): result.append(mid_result[:]) for i in range(position, len(num)): mid_result.append...
normal
{ "blob_id": "829910af55ca84838537a2e1fa697713c7a6c6ca", "index": 8400, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef subset2_helper(num, mid_result, result, position):\n result.append(mid_result[:])\n for i in range(position, len(num)):\n mid_result.append(num[i])\n subset2_h...
[ 0, 1, 2, 3, 4 ]
"""Test suite for phlsys_tryloop.""" from __future__ import absolute_import import datetime import itertools import unittest import phlsys_tryloop # ============================================================================= # TEST PLAN # -----------------------------------------...
normal
{ "blob_id": "87130c2bbf919cacd3d5dd823cd310dcad4dc790", "index": 8157, "step-1": "\"\"\"Test suite for phlsys_tryloop.\"\"\"\n\nfrom __future__ import absolute_import\n\nimport datetime\nimport itertools\nimport unittest\n\nimport phlsys_tryloop\n\n# ==============================================================...
[ 0 ]
from odoo import models, fields, api, _ import odoo.addons.decimal_precision as dp class netdespatch_config(models.Model): _name = 'netdespatch.config' name = fields.Char(String='Name') url = fields.Char(string='URL') # Royal Mail rm_enable = fields.Boolean('Enable Royal Mail') domestic_name =...
normal
{ "blob_id": "407f549cf68660c8f8535ae0bed373e2f54af877", "index": 5731, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass netdespatch_config(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>...
[ 0, 1, 2, 3, 4 ]
# Copyright 2014 Rackspace Hosting # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless r...
normal
{ "blob_id": "120021e44f6df9745db35ea2f38f25acecca9252", "index": 3201, "step-1": "<mask token>\n\n\n@test(depends_on_classes=[AfterConfigurationsCreation], groups=[tests.\n DBAAS_API_CONFIGURATIONS])\nclass ListConfigurations(ConfigurationsTestBase):\n\n @test\n def test_configurations_list(self):\n ...
[ 29, 40, 43, 52, 53 ]
# This module is used to load pascalvoc datasets (2007 or 2012) import os import tensorflow as tf from configs.config_common import * from configs.config_train import * from configs.config_test import * import sys import random import numpy as np import xml.etree.ElementTree as ET # Original dataset organisation. DIR...
normal
{ "blob_id": "c33d625ebd6a40551d2ce0393fd78619601ea7ae", "index": 5834, "step-1": "<mask token>\n\n\nclass Dataset(object):\n\n def __init__(self):\n self.items_descriptions = {'image':\n 'A color image of varying height and width.', 'shape':\n 'Shape of the image', 'object/bbox':\...
[ 11, 12, 13, 14, 16 ]
#!/usr/bin/env python3.4 # -*- coding: utf-8 -*- """ Das Pong-Spielfeld wird simuliert. Court moduliert ein anpassbares Spielfeld für Pong mit einem standardmäßigen Seitenverhältnis von 16:9. Jenes Spielfeld verfügt über einen Ball und zwei Schläger, jeweils links und rechts am Spielfeldrand, sowie einen Punktestand ...
normal
{ "blob_id": "5485a1210a0c0361dbb000546ee74df725fad913", "index": 5647, "step-1": "<mask token>\n\n\nclass court:\n <mask token>\n\n def __init__(self):\n \"\"\"\n Initialisiert ein court-Objekt.\n Hierzu zählen Spielfeld, Spieler sowie die Startposition des Balles.\n\n :return v...
[ 20, 21, 23, 26, 29 ]
from django.shortcuts import get_object_or_404, render from django.http import Http404 from django.urls import reverse # Create your views here. from django.template import loader from django.http import HttpResponse, HttpResponseRedirect from .models import Categories, News, SalesSentences from .models_gfl import Info...
normal
{ "blob_id": "531d1cab3d0860de38f8d1fefee28f10fc018bdb", "index": 9005, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef index(request):\n listTopNews = News.objects.filter(category__category='topside-news')\n listBottomNews = News.objects.filter(category__category='bottomside-news')\n list...
[ 0, 1, 2, 3 ]
#딕셔너리로 데이터 표현 # sales = {'hong':0,'lee':0,'park':0} # d = {'z':10, 'b':20,'c':30} # print(d) # d.pop('b') # print(d) # d['f']=40 # print(d) # d.pop('z') # d['z'] = 40 # print(d.keys()) #반복문(while) #조건이 참일동안 수행 #while True: # print('python!!!') # a = 0 # while a < 10: # a += 1 # print(a) # a = 0 # while Tr...
normal
{ "blob_id": "38bd18e9c1d17f25c10321ab561372eed58e8abc", "index": 4243, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor x in data:\n if x < min:\n min = x\nprint(min)\n", "step-3": "data = [5, 6, 2, 8, 9, 1]\nmin = 10\nfor x in data:\n if x < min:\n min = x\nprint(min)\n", "step...
[ 0, 1, 2, 3 ]
from app import db, session, Node_Base, Column, relationship from datetime import datetime import models import os import json
normal
{ "blob_id": "1711f74fae36ba761a7c0d84b95271b4e5043d27", "index": 6312, "step-1": "<mask token>\n", "step-2": "from app import db, session, Node_Base, Column, relationship\nfrom datetime import datetime\nimport models\nimport os\nimport json\n", "step-3": null, "step-4": null, "step-5": null, "step-ids"...
[ 0, 1 ]
from django.shortcuts import render, redirect from .game import run from .models import Match from team.models import Team, Player from django.urls import reverse # Create your views here. def startgame(request): match = Match(team1_pk = 1, team2_pk = 2) team1 = Team.objects.get(pk = match.team1_pk) team...
normal
{ "blob_id": "e1829904cea51909b3a1729b9a18d40872e7c13c", "index": 6163, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef results(request):\n team1damage = 0\n team2damage = 0\n winner = run(1, 2)\n team1 = Team.objects.get(pk=1)\n team2 = Team.objects.get(pk=2)\n player1 = Player.o...
[ 0, 1, 2, 3, 4 ]
from states.state import State class MoveDigState(State): #init attributes of state def __init__(self): super().__init__("MoveDig", "ScanDig") self.transitionReady = False self.digSiteDistance = 0 #implementation for each state: overridden def run(self, moveInstructions): ...
normal
{ "blob_id": "ce4ecff2012cfda4a458912713b0330a218fa186", "index": 873, "step-1": "<mask token>\n\n\nclass MoveDigState(State):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass MoveDigState(State):\n\n def __init__(self):\n super().__init__('MoveDig', 'ScanDi...
[ 1, 2, 4, 5, 6 ]
''' Utility functions to do get frequencies of n-grams Author: Jesus I. Ramirez Franco December 2018 ''' import nltk import pandas as pd from nltk.stem.snowball import SnowballStemmer from pycorenlp import StanfordCoreNLP import math from nltk.tokenize import RegexpTokenizer from nltk.corpus import stopwords import st...
normal
{ "blob_id": "367c3b4da38623e78f2853f9d3464a414ad049c2", "index": 9596, "step-1": "<mask token>\n\n\ndef clean_doc(text, language='english'):\n \"\"\"\n\tRemoves unknown characters and punctuation, change capital to lower letters and remove\n\tstop words. If stem=False\n\tInputs:\n\tsentence (string): a sting ...
[ 3, 8, 10, 11, 12 ]
# SPDX-FileCopyrightText: 2019-2021 Python201 Contributors # SPDX-License-Identifier: MIT # # Configuration file for the Sphinx documentation builder. # # This file does only contain a selection of the most common options. For a # full list see the documentation: # http://www.sphinx-doc.org/en/master/config # -- Path ...
normal
{ "blob_id": "1ead23c6ea4e66b24e60598ae20606e24fa41482", "index": 1024, "step-1": "<mask token>\n", "step-2": "<mask token>\nyear = datetime.datetime.now().year\nproject = 'python201'\ncopyright = f'2019-{year} Geoffrey Lentner, 2018 Ashwin Srinath'\nauthor = 'Geoffrey Lentner, Ashwin Srinath'\nversion = '0.0.1...
[ 0, 1, 2, 3 ]
import configparser import sqlite3 import time import uuid from duoquest.tsq import TableSketchQuery def input_db_name(conn): while True: db_name = input('Database name (default: concert_singer) > ') if not db_name: db_name = 'concert_singer' cur = conn.cursor() cur.ex...
normal
{ "blob_id": "54ec1961f4835f575e7129bd0b2fcdeb97be2f03", "index": 93, "step-1": "<mask token>\n\n\ndef input_db_name(conn):\n while True:\n db_name = input('Database name (default: concert_singer) > ')\n if not db_name:\n db_name = 'concert_singer'\n cur = conn.cursor()\n ...
[ 6, 7, 8, 11, 12 ]
import json import os import ipdb from tqdm import tqdm import argparse from os import listdir from os.path import isfile, join import pickle import joblib from collections import Counter from shutil import copyfile import networkx as nx import spacy import nltk import numpy as np nltk.download('stopwords') nltk_stopw...
normal
{ "blob_id": "2da7892722afde5a6f87e3bd6d5763c895ac96c9", "index": 284, "step-1": "<mask token>\n\n\nclass Lang:\n\n def __init__(self):\n super(Lang, self).__init__()\n self.word2index = {}\n self.word2count = {}\n self.index2word = {}\n self.n_words = 0\n\n def index_word...
[ 5, 8, 9, 11, 13 ]
version https://git-lfs.github.com/spec/v1 oid sha256:0c22c74b2d9d62e2162d2b121742b7f94d5b1407ca5e2c6a2733bfd7f02e3baa size 5016
normal
{ "blob_id": "c5f0b1dde320d0042a1bf4de31c308e18b53cbeb", "index": 6766, "step-1": "version https://git-lfs.github.com/spec/v1\noid sha256:0c22c74b2d9d62e2162d2b121742b7f94d5b1407ca5e2c6a2733bfd7f02e3baa\nsize 5016\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ...
[ 0 ]
# Mezzanine Django Framework createdb error on Max OSX 10.9.2 import django django.version
normal
{ "blob_id": "56afde2a31ad9dddee35e84609dff2eb0fc6fe1a", "index": 9438, "step-1": "<mask token>\n", "step-2": "<mask token>\ndjango.version\n", "step-3": "import django\ndjango.version\n", "step-4": "# Mezzanine Django Framework createdb error on Max OSX 10.9.2\nimport django\ndjango.version\n", "step-5":...
[ 0, 1, 2, 3 ]
# Copyright (c) Microsoft Corporation. # Licensed under the MIT License from .attack_models import (DriftAttack, AdditiveGaussian, RandomGaussian, BitFlipAttack, RandomSignFlipAttack) from typing import Dict def get_attack(attack_config: Dict): if attack_config["attack_model"] == 'drif...
normal
{ "blob_id": "11320922d24b27c5cfa714f88eb0a757deef987f", "index": 8546, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_attack(attack_config: Dict):\n if attack_config['attack_model'] == 'drift':\n return DriftAttack(attack_config=attack_config)\n elif attack_config['attack_model']...
[ 0, 1, 2, 3, 4 ]
def heapify(lst, index, heap_size): largest = index left_index = 2 * index + 1 right_index = 2 * index + 2 if left_index < heap_size and lst[left_index] > lst[largest]: largest = left_index if right_index < heap_size and lst[right_index] > lst[largest]: largest = right_index if l...
normal
{ "blob_id": "d8ea396ff8514cc10e02072ea478f0276584153d", "index": 3274, "step-1": "<mask token>\n", "step-2": "def heapify(lst, index, heap_size):\n largest = index\n left_index = 2 * index + 1\n right_index = 2 * index + 2\n if left_index < heap_size and lst[left_index] > lst[largest]:\n lar...
[ 0, 1, 2 ]
#5.8-5.9 users = ['user1', 'user2', 'user3', 'user4', 'admin'] #users = [] if users: for user in users: if user == 'admin': print(f"Hello, {user}, would you like to see a status report?") else: print(f"Hello, {user}, thank you for logging in again") else: print("We need t...
normal
{ "blob_id": "c355be4e05d1df7f5d6f2e32bbb5a8086babe95b", "index": 7946, "step-1": "<mask token>\n", "step-2": "<mask token>\nif users:\n for user in users:\n if user == 'admin':\n print(f'Hello, {user}, would you like to see a status report?')\n else:\n print(f'Hello, {use...
[ 0, 1, 2, 3 ]
def raizCubica(numero): r = pow(numero,(1/3)) return r numeros = [] raices = [] for x in range(5): numeros.insert(x, float(input("Ingrese Numero: "))) raices.insert(x, round(raizCubica(numeros[x]),3)) print("Numeros: ", numeros) print("Raices: ", raices)
normal
{ "blob_id": "180f7f0ade9770c6669680bd13ac8f2fd55cc8c7", "index": 357, "step-1": "<mask token>\n", "step-2": "def raizCubica(numero):\n r = pow(numero, 1 / 3)\n return r\n\n\n<mask token>\n", "step-3": "def raizCubica(numero):\n r = pow(numero, 1 / 3)\n return r\n\n\n<mask token>\nfor x in range(5...
[ 0, 1, 2, 3, 4 ]
n = int(input()) num = list(map(int, input().split())) plus_cnt = 0 div_max = 0 for i in num: div = 0 while i > 0: if i % 2 == 0: i //= 2 div += 1 else: i -= 1 plus_cnt += 1 div_max = max(div_max, div) print(plus_cnt + div_max)
normal
{ "blob_id": "9247896850e5282265cd08240f6f505e675ce5f0", "index": 5904, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in num:\n div = 0\n while i > 0:\n if i % 2 == 0:\n i //= 2\n div += 1\n else:\n i -= 1\n plus_cnt += 1\n div_max ...
[ 0, 1, 2 ]
import os from setuptools import setup from django_spaghetti import __version__ with open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme: README = readme.read() # allow setup.py to be run from any path os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir))) setup( nam...
normal
{ "blob_id": "6e557c2b85031a0038afd6a9987e3417b926218f", "index": 6184, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(os.path.join(os.path.dirname(__file__), 'README.rst')) as readme:\n README = readme.read()\nos.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))\nse...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- import datetime from south.db import db from south.v2 import SchemaMigration from django.db import models class Migration(SchemaMigration): def forwards(self, orm): # Adding field 'PhoneUser.last_contacted' db.add_column(u'smslink_phoneuser', 'last_contacted', ...
normal
{ "blob_id": "2c1de638ac25a9f27b1af94fa075b7c1b9df6884", "index": 993, "step-1": "<mask token>\n\n\nclass Migration(SchemaMigration):\n\n def forwards(self, orm):\n db.add_column(u'smslink_phoneuser', 'last_contacted', self.gf(\n 'django.db.models.fields.DateTimeField')(null=True, blank=True)...
[ 2, 3, 4, 5, 6 ]
def _get_single_variable(self, name, shape=None, dtype=dtypes.float32, initializer=None, regularizer=None, partition_info=None, reuse=None, trainable=True, collections=None, caching_device=None, validate_shape=True, use_resource=None): 'Get or create a single Variable (e.g. a shard or entire variable).\n\n See t...
normal
{ "blob_id": "51ef1c0f6a17e12b2324a80f962b2ce47cc05bcc", "index": 1348, "step-1": "<mask token>\n", "step-2": "def _get_single_variable(self, name, shape=None, dtype=dtypes.float32,\n initializer=None, regularizer=None, partition_info=None, reuse=None,\n trainable=True, collections=None, caching_device=No...
[ 0, 1, 2 ]
import os def take_shot(filename): os.system("screencapture "+filename+".png")
normal
{ "blob_id": "f4c90a6d6afdcf78ec6742b1924a5c854a5a4ed6", "index": 1825, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef take_shot(filename):\n os.system('screencapture ' + filename + '.png')\n", "step-3": "import os\n\n\ndef take_shot(filename):\n os.system('screencapture ' + filename + '.p...
[ 0, 1, 2, 3 ]
'''引入数据,并对数据进行预处理''' # step 1 引入数据 import pandas as pd with open('D:\\Desktop\西瓜数据集3.0.csv', 'r', encoding='utf-8') as data_obj: df = pd.read_csv(data_obj) # Step 2 对数据进行预处理 # 对离散属性进行独热编码,定性转为定量,使每一个特征的取值作为一个新的特征 # 增加特征量 Catagorical Variable -> Dummy Variable # 两种方法:Dummy Encoding VS One Hot Encoding # 相同点:将Cat...
normal
{ "blob_id": "682b3e1d6d40f4b279052ac27df19268d227fef8", "index": 6899, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('D:\\\\Desktop\\\\西瓜数据集3.0.csv', 'r', encoding='utf-8') as data_obj:\n df = pd.read_csv(data_obj)\n<mask token>\npd.set_option('display.max_columns', 1000)\n<mask token>\nfor...
[ 0, 1, 2, 3, 4 ]
import urllib.request import urllib.parse import json content = input("请输入需要翻译的内容:") url = 'http://fanyi.youdao.com/translate?smartresult=dict&smartresult=rule' data = {} data['action'] = 'FY_BY_CLICKBUTTION' data['bv'] = '1ca13a5465c2ab126e616ee8d6720cc3' data['client'] = 'fanyideskweb' data['doctype'] = 'json' dat...
normal
{ "blob_id": "e01b1f57a572571619d6c0981370030dc6105fd2", "index": 8636, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('翻译结果:%s' % target['translateResult'][0][0]['tgt'])\n", "step-3": "<mask token>\ncontent = input('请输入需要翻译的内容:')\nurl = 'http://fanyi.youdao.com/translate?smartresult=dict&smartres...
[ 0, 1, 2, 3, 4 ]
# POST API for Red Alert project - NLP and Metalearning components # Insikt Intelligence S.L. 2019 import pandas as pd import pickle from flask import Flask, render_template, request, jsonify from utilities import load_data, detect_language from preprocessing import preprocess, Tagger, remove_stopwords import json fro...
normal
{ "blob_id": "b51e0ee80a2488197470627821204d1f74cd62a1", "index": 5437, "step-1": "<mask token>\n\n\n@app.route('/probability', methods=['POST'])\ndef make_probability():\n try:\n data = request.get_json()\n except Exception as e:\n raise e\n if data == {}:\n return bad_request()\n ...
[ 7, 8, 10, 11, 12 ]
#Use bisection search to determine square root def square_calculator(user_input): """ accepts input from a user to determine the square root returns the square root of the user input """ precision = .000000000001 counter = 0 low = 0 high = user_input guess = (low + high) / 2.0 w...
normal
{ "blob_id": "2bc20f3410d068e0592c8a45e3c13c0559059f24", "index": 4498, "step-1": "<mask token>\n", "step-2": "def square_calculator(user_input):\n \"\"\"\n accepts input from a user to determine the square root\n returns the square root of the user input\n \"\"\"\n precision = 1e-12\n counter...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """Tests for the storage format CLI arguments helper.""" import argparse import unittest from plaso.cli import tools from plaso.cli.helpers import storage_format from plaso.lib import errors from tests.cli import test_lib as cli_test_lib class StorageFormatArgumentsHe...
normal
{ "blob_id": "2075e7e05882524c295c8542ca7aefae2cf3e0fc", "index": 5951, "step-1": "<mask token>\n\n\nclass StorageFormatArgumentsHelperTest(cli_test_lib.CLIToolTestCase):\n <mask token>\n <mask token>\n\n def testAddArguments(self):\n \"\"\"Tests the AddArguments function.\"\"\"\n argument_...
[ 3, 5, 6, 7, 8 ]
#####################将政策文件中的内容抽取出来:标准、伦理、 3部分内容########################## ###########step 1:把3部分内容找到近义词,组成一个词表###### ###########step 2:把文件与词表相匹配,判断文件到底在讲啥###### from nltk.corpus import wordnet as wn import os import codecs # goods = wn.synsets('beautiful') # beautifuls = wn.synsets('pretty') # bads = wn.synsets...
normal
{ "blob_id": "caca4309034f08874e1e32828a601e7e3d4d3efd", "index": 2058, "step-1": "<mask token>\n\n\ndef readOnePolicy(path2):\n ethic_set = wn.synsets('ethic')\n standard_set = wn.synsets('standard')\n privacy_set = wn.synsets('privacy')\n education_set = wn.synsets('education')\n investment_set =...
[ 1, 2, 3, 4, 5 ]
import matplotlib.pyplot as plt Ci_MSB = [32,16,8,4,2,1] Ci_LSB = [16,8,4,2,1] CB = 1 CP_B = 0 CP_LSB = (32-1)*(CB+CP_B-1)+10 print(CP_LSB) CP_MSB = 0 Csum_LSB = sum(Ci_LSB)+CP_LSB Csum_MSB = sum(Ci_MSB)+CP_MSB Cx = Csum_LSB*Csum_MSB+(CB+CP_B)*Csum_LSB+(CB+CP_B)*Csum_MSB Wi_MSB = [Ci_MSB[i]*(CB+CP_B+Csum_LSB)/Cx for i...
normal
{ "blob_id": "b5ac3695a224d531f5baa53a07d3c894d44e8c4c", "index": 395, "step-1": "<mask token>\n\n\ndef AtoD(vin):\n code = [(0) for i in range(12)]\n code[0] = 1 if vin > 0 else 0\n for i in range(6):\n vin = vin - Wi_MSB[i] * (code[i] - 0.5) * 2\n code[i + 1] = 1 if vin > 0 else 0\n fo...
[ 2, 3, 4, 5, 6 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.10 on 2018-02-26 13:14 from __future__ import unicode_literals import datetime from django.db import migrations, models import django.db.models.deletion from django.utils.timezone import utc class Migration(migrations.Migration): dependencies = [ ('user...
normal
{ "blob_id": "c6170678b523a105312d8ce316853859657d3c94", "index": 2235, "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 = [('user_detail...
[ 0, 1, 2, 3, 4 ]
import torch import torch.nn as nn import torch.nn.functional as F class Encoder(nn.Module): def __init__(self): super(Encoder, self).__init__() self.conv1 = nn.Conv2d(1, 32, kernel_size=5, stride=1) self.bn1 = nn.BatchNorm2d(32) self.conv2 = nn.Conv2d(32, 48, kernel_size=5, stride...
normal
{ "blob_id": "9140da0b6c04f39a987a177d56321c56c01586e8", "index": 3739, "step-1": "<mask token>\n\n\nclass Classifier(nn.Module):\n\n def __init__(self, args, prob=0.5):\n super(Classifier, self).__init__()\n self.fc1 = nn.Linear(48 * 4 * 4, 100)\n self.bn1_fc = nn.BatchNorm1d(100)\n ...
[ 5, 7, 8, 10, 11 ]
n = eval(input("Entrez valeur: ")) res = 0 while n > 0: res += n%10 n //= 10 print(res, n) print(res)
normal
{ "blob_id": "391ecb2f23cc0ce59bd9fac6f97bd4c1788444b9", "index": 4416, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile n > 0:\n res += n % 10\n n //= 10\n print(res, n)\nprint(res)\n", "step-3": "n = eval(input('Entrez valeur: '))\nres = 0\nwhile n > 0:\n res += n % 10\n n //= 10\n ...
[ 0, 1, 2, 3 ]
class Job: def __init__(self, id, duration, tickets): self.id = id self.duration = duration self.tickets = tickets def run(self, time_slice): self.duration -= time_slice def done(self): return self.duration <= 0
normal
{ "blob_id": "cf7bd8aa9c92d1c3acb9ccc1658d66fa0e7a142d", "index": 3777, "step-1": "class Job:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "class Job:\n <mask token>\n\n def run(self, time_slice):\n self.duration -= time_slice\n <mask token>\n", "step-3": "class Job:\n ...
[ 1, 2, 3, 4 ]
import sys import numpy as np import math import matplotlib.pyplot as plt import random def load_files(training, testing): tr_feat = np.genfromtxt(training, usecols=range(256), delimiter=",") tr_feat /= 255.0 tr_feat = np.insert(tr_feat, 0, 0, axis=1) tr_exp = np.genfromtxt(training, usecols=range(-1)...
normal
{ "blob_id": "4af05a13264c249be69071447101d684ff97063e", "index": 6725, "step-1": "<mask token>\n\n\ndef load_files(training, testing):\n tr_feat = np.genfromtxt(training, usecols=range(256), delimiter=',')\n tr_feat /= 255.0\n tr_feat = np.insert(tr_feat, 0, 0, axis=1)\n tr_exp = np.genfromtxt(traini...
[ 4, 5, 6, 7, 8 ]
import torch,cv2,os,time import numpy as np import matplotlib.pyplot as plt from tqdm import tqdm import torch.nn as nn import torch.nn.functional as F import torch.optim as optim # GPU kullanımı device=torch.device(0) class NET(nn.Module): def __init__(self): super(). __init__() ...
normal
{ "blob_id": "ad63beedc460b3d64a51d0b1f81f8e44cb559749", "index": 1655, "step-1": "<mask token>\n\n\nclass NET(nn.Module):\n <mask token>\n\n def uzunluk(self, x):\n x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))\n x = F.max_pool2d(F.relu(self.conv2(x)), (2, 2))\n x = F.max_pool2d(F.re...
[ 3, 4, 5, 6, 7 ]
# Generated by Django 3.2.6 on 2021-08-15 05:17 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('website', '0001_initial'), ] operations = [ migrations.AlterField( model_name='tasks', name='cleanlinessLevel', ...
normal
{ "blob_id": "6f9f204cbd6817d5e40f57e71614ad03b64d9003", "index": 3152, "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 = [('website', '...
[ 0, 1, 2, 3, 4 ]
import pandas import pytest from tns_watcher import get_tns from utils import load_config, log, Mongo """ load config and secrets """ config = load_config(config_file="config.yaml")["kowalski"] class TestTNSWatcher: """ Test TNS monitoring """ @pytest.mark.xfail(raises=pandas.errors.ParserError) ...
normal
{ "blob_id": "e7ffa852d16e8e55b4e2b6ab2383561fe359a169", "index": 1778, "step-1": "<mask token>\n\n\nclass TestTNSWatcher:\n <mask token>\n\n @pytest.mark.xfail(raises=pandas.errors.ParserError)\n def test_tns_watcher(self):\n log('Connecting to DB')\n mongo = Mongo(host=config['database'][...
[ 2, 3, 4, 5, 6 ]
from datetime import datetime, timezone, timedelta import json import urllib.request from mysql_dbcon import Connection from model import SlackChannel, SlackUser, SlackMessage # TODO set timezone at config jst = timezone(timedelta(hours=+9), 'JST') def get_new_message_list(channel_id: int): with Connection() a...
normal
{ "blob_id": "2b141f12bec2006e496bf58a3fcb0167c95ab3b6", "index": 2530, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_new_message_list(channel_id: int):\n with Connection() as cn:\n token, channel = cn.s.query(SlackChannel.token, SlackChannel.channel\n ).filter(SlackChann...
[ 0, 1, 2, 3, 4 ]
from flask import Blueprint web = Blueprint('web', __name__) from app.web import auth from app.web import user from app.web import book
normal
{ "blob_id": "02182f0379e58b64bbe17cc5f433e8aae7814976", "index": 196, "step-1": "<mask token>\n", "step-2": "<mask token>\nweb = Blueprint('web', __name__)\n<mask token>\n", "step-3": "from flask import Blueprint\nweb = Blueprint('web', __name__)\nfrom app.web import auth\nfrom app.web import user\nfrom app....
[ 0, 1, 2 ]
#!/usr/bin/env python # encoding: utf-8 import tweepy #https://github.com/tweepy/tweepy import csv import scraperwiki import json #Twitter API credentials - these need adding consumer_key = "" consumer_secret = "" access_key = "" access_secret = "" def get_all_tweets(screen_name): #Twitter only allows access to a ...
normal
{ "blob_id": "02230b44568808757fe45fd18d28881d9bc3e410", "index": 8074, "step-1": "#!/usr/bin/env python\n# encoding: utf-8\n\nimport tweepy #https://github.com/tweepy/tweepy\nimport csv\nimport scraperwiki\nimport json\n\n#Twitter API credentials - these need adding\nconsumer_key = \"\"\nconsumer_secret = \"\"\n...
[ 0 ]
#!/usr/bin/env python3 # This is a tool to export the WA framework answers to a XLSX file # # This code is only for use in Well-Architected labs # *** NOT FOR PRODUCTION USE *** # # Licensed under the Apache 2.0 and MITnoAttr License. # # Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Lice...
normal
{ "blob_id": "c5e003d625d7798eaf4ef5bca28f6311edccb316", "index": 7235, "step-1": "<mask token>\n\n\nclass DateTimeEncoder(json.JSONEncoder):\n\n def default(self, z):\n if isinstance(z, datetime.datetime):\n return str(z)\n else:\n return super().default(z)\n\n\n<mask token...
[ 13, 15, 16, 18, 19 ]
#include os #include math output_file = 'output/mvnt' def file_writeout(srvN, pos); with open(output_file, 'a') as f: f.write(srvN, ' to ', pos) return 0 class leg(legN): def __init__(legN): srvHY = 'srv' + legN + 'HY' srvHX = 'srv' + legN + 'HX' srvEY = 'srv' + le...
normal
{ "blob_id": "901f87752026673c41a70655e987ecc2d5cb369f", "index": 7273, "step-1": "#include os\n#include math\n\noutput_file = 'output/mvnt'\n\ndef file_writeout(srvN, pos);\n with open(output_file, 'a') as f:\n f.write(srvN, ' to ', pos)\n return 0\n \nclass leg(legN):\n def __init__(legN)...
[ 0 ]
import numpy as np import cv2 from DataTypes import FishPosition class FishSensor(object): def __init__(self): self.cap = cv2.VideoCapture(0) self.cap.set(3, 280) self.cap.set(4, 192) #cv2.namedWindow("image") #lower_b, lower_g, lower_r = 0, 0, 80 lower_b, lower_g, lower_r = ...
normal
{ "blob_id": "9cea27abebda10deefa9e05ddefa72c893b1eb18", "index": 1676, "step-1": "import numpy as np\nimport cv2\nfrom DataTypes import FishPosition\n\nclass FishSensor(object):\n def __init__(self):\n\t self.cap = cv2.VideoCapture(0)\n\t self.cap.set(3, 280)\n\t self.cap.set(4, 192)\n\n\t #cv2.na...
[ 0 ]
""" Deprecated entry point for a component that has been moved. """ # currently excluded from documentation - see docs/README.md from ldclient.impl.integrations.files.file_data_source import _FileDataSource from ldclient.interfaces import UpdateProcessor class FileDataSource(UpdateProcessor): @classmethod def...
normal
{ "blob_id": "ee68ebe146f948f3497577f40741e59b7421e652", "index": 8186, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass FileDataSource(UpdateProcessor):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass FileDataSource(UpdateProcessor):\n\n @classmethod\n def factory(cls, **kwargs):...
[ 0, 1, 2, 3, 4 ]
import arcade WINDOW_WIDTH = 740 WINDOW_HEIGHT = 740 dark_green = (170, 216, 81) light_green = (162, 210, 73) snake_color = (72, 118, 235) def square(square_x, square_y, square_width, square_height, square_color): """ Code that sets up the squares for generation """ arcade.draw_rectangle_filled(square_x, squ...
normal
{ "blob_id": "fbe091b1cf3ecc2f69d34e3b1c399314b38ebc4a", "index": 5656, "step-1": "<mask token>\n\n\ndef generate_grid():\n \"\"\" Code that generates the grid \"\"\"\n y_offset = -10\n for a in range(20):\n x_offset = 10\n for b in range(1):\n y_offset += 20\n for c in ra...
[ 5, 7, 8, 9, 10 ]
from Store import Store from MusicProduct import MusicProduct class MusicStore(Store): def make_product(self, name): '''Overides from parent - return a new MusicProduct Object'''
normal
{ "blob_id": "0a50b31155afce2558ec066267a9fd0c56964759", "index": 5653, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MusicStore(Store):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass MusicStore(Store):\n\n def make_product(self, name):\n \"\"\"Overides from parent - retur...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Wed May 8 15:05:51 2019 @author: Brian Heckman and Kyle Oprisko """ import csv """this file opens a csv file created in the csv creator class. The main purpose of this class is to normalize the data in the csv file, so that it can be read by the neural network. """ ...
normal
{ "blob_id": "ecbca04a58c19469e63ee2310e2b2f6b86c41199", "index": 1011, "step-1": "<mask token>\n\n\nclass CSV_Normalize:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask t...
[ 11, 12, 19, 21, 23 ]
#!/usr/bin/env python3 def twoNumberSum(array, targetSum): # Write your code here. # O(n^2) time | O(1) space ''' Double for loop, quadratic run time No variables increase as the input size increases, therefore constant space complexity. ''' for i in range(len(array) - 1): firstNu...
normal
{ "blob_id": "a406efcab62b2af67484da776f01fc4e6d20b697", "index": 984, "step-1": "#!/usr/bin/env python3\n\ndef twoNumberSum(array, targetSum):\n # Write your code here.\n\n # O(n^2) time | O(1) space\n ''' Double for loop, quadratic run time\n No variables increase as the input size increases,\n ...
[ 0 ]
from typing import List class LanguageDefinition: """Language definition containing general constants and methods.""" @staticmethod def get_translated_file_name(filename: str): """ :returns: Translated file name. """ return filename @staticmethod def create_projec...
normal
{ "blob_id": "672add6aa05e21d3605c05a23ff86281ffc3b17c", "index": 9827, "step-1": "<mask token>\n\n\nclass LanguageDefinition:\n <mask token>\n <mask token>\n\n @staticmethod\n def create_project_files(project_path: str, added_file_paths: List[str]\n =None) ->str:\n \"\"\"\n Creat...
[ 6, 7, 8, 9 ]
from django.core.urlresolvers import reverse from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotFound from django.shortcuts import render_to_response from django.template import RequestContext from whydjango.casestudies.forms import SubmitCaseStudyForm def case_study_submission(request, tem...
normal
{ "blob_id": "fe3e104cf213b21c33a4b5c6e1a61315c4770eda", "index": 6821, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef case_study_submission(request, template_name='casestudies/submit.html'):\n form = SubmitCaseStudyForm(request.POST or None)\n if form.is_valid():\n form.save()\n ...
[ 0, 1, 2, 3 ]
import string import pandas as pd import nltk from nltk import word_tokenize from nltk.stem import SnowballStemmer from nltk.tokenize import WordPunctTokenizer import json from sklearn.model_selection import train_test_split from keras.preprocessing.text import Tokenizer import pickle import re import nlpaug.augmenter....
normal
{ "blob_id": "326b2dcbef339aeb196bef23debad75fa079b121", "index": 6435, "step-1": "<mask token>\n\n\nclass Processing:\n <mask token>\n\n @property\n def vocab_size(self):\n return self.__vocab_size\n\n def normalize(self, s):\n s = s.lower()\n replacements = ('á', 'a'), ('é', 'e'...
[ 12, 16, 17, 18, 19 ]
# -*- coding: utf-8 -*- """ Created on Fri Oct 23 15:26:47 2015 @author: tomhope """ import cPickle as pickle from nltk.tokenize import word_tokenize from sklearn.feature_extraction.text import CountVectorizer import re def tokenize_speeches(text): text = re.sub('[\[\]<>\'\+\=\/(.?\",&*!_#:;@$%|)0-9]'," ", text) ...
normal
{ "blob_id": "17548459b83fe4dea29f20dc5f91196b2b86ea60", "index": 4655, "step-1": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Fri Oct 23 15:26:47 2015\n\n@author: tomhope\n\"\"\"\nimport cPickle as pickle\nfrom nltk.tokenize import word_tokenize\nfrom sklearn.feature_extraction.text import CountVectorizer\nimpor...
[ 0 ]
import cv2 import numpy as np import matplotlib.pyplot as plt ''' def diff_of_gaussians(img): grey_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB) blur_img_grey = cv2.GaussianBlur(grey_img, (9,9), 0) blur_img_colour = cv2.GaussianBlur(img, (9,9), 0) #plt.fig...
normal
{ "blob_id": "c3a7a8a006f717057a7ad2920f19d82842b04a85", "index": 9510, "step-1": "<mask token>\n\n\ndef canny(img):\n grey_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)\n blurred_img = cv2.GaussianBlur(grey_img, (9, 9), 0)\n canny_filtered = cv2.Canny(blurred_img, 30, 150)\n return canny_filtered\n\n\n...
[ 4, 5, 6, 7, 8 ]
class Port(object): def __init__(self, mac): self.mac = mac
normal
{ "blob_id": "cd89c9eaea9d331288fd07f1968ef9dce89b4a4b", "index": 7228, "step-1": "<mask token>\n", "step-2": "class Port(object):\n <mask token>\n", "step-3": "class Port(object):\n\n def __init__(self, mac):\n self.mac = mac\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, ...
[ 0, 1, 2 ]
from . import cli cli.run()
normal
{ "blob_id": "235623c3f557dbc28fbff855a618e4d26932ca65", "index": 7630, "step-1": "<mask token>\n", "step-2": "<mask token>\ncli.run()\n", "step-3": "from . import cli\ncli.run()\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
# coding: utf-8 import pandas as pd import os import numpy as np import json as json import mysql.connector as sqlcnt import datetime as dt import requests from mysql.connector.constants import SQLMode import os import glob import re import warnings warnings.filterwarnings("ignore") from pathlib import Path # In[...
normal
{ "blob_id": "2060f57cfd910a308d60ad35ebbbf9ffd5678b9c", "index": 3519, "step-1": "<mask token>\n", "step-2": "<mask token>\nwarnings.filterwarnings('ignore')\n<mask token>\nos.chdir(lib_path)\n<mask token>\nprint(res.summary())\n<mask token>\nX0\n<mask token>\nb\n<mask token>\ncovid_actual.loc[:, 'Date':'human...
[ 0, 1, 2, 3, 4 ]
import Adafruit_BBIO.GPIO as GPIO from pydrs import SerialDRS import time import sys sys.dont_write_bytecode = True class SyncRecv: def __init__(self): self._comport = '/dev/ttyUSB0' self._baudrate = '115200' self._epwm_sync_pin = 'GPIO2_23' # Input in BBB perspective ...
normal
{ "blob_id": "c716f43dbe62f662c60653f09be946a27c3fff66", "index": 8069, "step-1": "<mask token>\n\n\nclass SyncRecv:\n\n def __init__(self):\n self._comport = '/dev/ttyUSB0'\n self._baudrate = '115200'\n self._epwm_sync_pin = 'GPIO2_23'\n self._sync_in_pin = 'GPIO2_25'\n self...
[ 2, 4, 5, 6, 7 ]
from flask import render_template from database import db from api import app from models import create_models # Create a URL route in application for "/" @app.route('/') def home(): return render_template('home.html') # If in stand alone mode, run the application if __name__ == '__main__': db.connect() c...
normal
{ "blob_id": "5a0a8205977e59ff59a5d334a487cf96eee514d2", "index": 7211, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef home():\n return render_template('home.html')\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\n@app.route('/')\ndef home():\n return render_template('ho...
[ 0, 1, 2, 3, 4 ]
from urllib.request import urlopen from json import loads with urlopen('http://api.nbp.pl/api/exchangerates/tables/A/') as site: data = loads(site.read().decode('utf-8')) rates = data[0]['rates'] exchange = input('Jaką wartość chcesz wymienić na złotówki? ') value, code = exchange.split(' ') val...
normal
{ "blob_id": "3f3d7cdf7732b2a1568cd97574e1443225667327", "index": 9622, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith urlopen('http://api.nbp.pl/api/exchangerates/tables/A/') as site:\n data = loads(site.read().decode('utf-8'))\n rates = data[0]['rates']\n exchange = input('Jaką wartość chc...
[ 0, 1, 2, 3 ]
# # Copyright (C) 2020 RFI # # Author: James Parkhurst # # This code is distributed under the GPLv3 license, a copy of # which is included in the root directory of this package. # import logging import numpy from maptools.util import read, write # Get the logger logger = logging.getLogger(__name__) def array_rebin(...
normal
{ "blob_id": "18dc01f3e1672407800e53d80a85ffc8d5b86c17", "index": 7497, "step-1": "<mask token>\n\n\ndef rebin(*args, **kwargs):\n \"\"\"\n Rebin the map\n\n \"\"\"\n if len(args) > 0 and type(args[0]) == 'str' or 'input_filename' in kwargs:\n func = mapfile_rebin\n else:\n func = arr...
[ 1, 3, 4, 5, 6 ]
def divisible_by(numbers, divisor): res = [] for e in numbers: if e % divisor == 0: res.append(e) return res
normal
{ "blob_id": "d7ff5bf5d8f397500fcac30b73f469316c908f15", "index": 5042, "step-1": "<mask token>\n", "step-2": "def divisible_by(numbers, divisor):\n res = []\n for e in numbers:\n if e % divisor == 0:\n res.append(e)\n return res\n", "step-3": null, "step-4": null, "step-5": nul...
[ 0, 1 ]
from sense_hat import SenseHat import time import random #Set game_mode to True for single roll returning value #False for demonstration purposes class ElectronicDie: def __init__(self, mode): self.game_mode = mode sense = SenseHat() #Colours O = (0,0,0) B = (0, 0, 255) #Settings #...
normal
{ "blob_id": "edfad88c837ddd3bf7cceeb2f0b1b7a5356c1cf7", "index": 8998, "step-1": "<mask token>\n\n\nclass ElectronicDie:\n\n def __init__(self, mode):\n self.game_mode = mode\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ...
[ 4, 5, 6, 7, 8 ]