code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
# -*- coding: utf-8 -*- """ Created on Wed Dec 18 21:03:43 2019 @author: 00124175 """ """ 读取txt文件 该文本中的分割符既有空格又有制表符('/t'),sep参数用'/s+',可以匹配任何空格。 """ #header=None:没有每列的column name,可以自己设定 #encoding='gb2312':其他编码中文显示错误 #sep=',':用逗号来分隔每行的数据 #index_col=0:设置第1列数据作为index import pandas as pd data = pd.read_table("1206sjl.txt"...
normal
{ "blob_id": "ab760ec4cbb9f616f38b0f0f2221987460c6f618", "index": 6492, "step-1": "<mask token>\n", "step-2": "<mask token>\nmydata.rename(columns=lambda x: x.strip(' '), inplace=True)\n<mask token>\nprint(my_need_data.iloc[:, 0:3])\nmy_need_data.to_csv('result_csv.csv', index=0)\n", "step-3": "<mask token>\n...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python import pathlib from blastsight.view.viewer import Viewer """ In this demo, we'll show how you can create a basic animation. An animation is interpreted as changing the state of the viewer one frame at the time. That means we'll define a function that makes a change in one single frame. The fun...
normal
{ "blob_id": "00be3d813ce4335ff9ea02ed9f1884d3210f3d5a", "index": 3101, "step-1": "<mask token>\n\n\ndef autorotate(angle):\n v.set_rotation_angle([0.0, -angle, 0.0])\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef autorotate(angle):\n v.set_rotation_angle([0.0, -angle, 0.0])\n\n\n<mask token>\nv.a...
[ 1, 2, 3, 4, 5 ]
############################## # SConscript for OgreOpcode # ############################## #SCons scripts maintained by: # Van Aarde "nanocell" Krynauw. #TODO: # - Add commandline options to specify include dirs, defines, compiler defs, libraries, etc. # - Add Sconscripts for the samples. # - Add a binary SConstruc...
normal
{ "blob_id": "ed1df078ad2e8d770f3d8c41493b5537ed106e3a", "index": 1954, "step-1": "##############################\n# SConscript for OgreOpcode #\n##############################\n#SCons scripts maintained by:\n# Van Aarde \"nanocell\" Krynauw.\n\n#TODO:\n# - Add commandline options to specify include dirs, defin...
[ 0 ]
import gc import network import lib.gate as gate import time from micropython import const from ubluetooth import BLE import lib.webserver as webserver bt = BLE() bt.active(True) _IRQ_SCAN_RESULT = const(5) _IRQ_SCAN_DONE = const(6) def byteToMac(addr): m = memoryview(addr) a = "{:0>2X}:{:0>2...
normal
{ "blob_id": "99c60befed32a9aa80b6e66b682d9f475e05a8d1", "index": 2562, "step-1": "<mask token>\n\n\ndef handler(event, data):\n if event == _IRQ_SCAN_RESULT:\n addr_type, addr, adv_type, rssi, adv_data = data\n print(addr_type, memoryview(addr), adv_type, rssi, memoryview(adv_data)\n ...
[ 2, 5, 6, 7, 8 ]
from flask import request,Flask, render_template from bs4 import BeautifulSoup as bs from urllib.request import Request,urlopen import re app = Flask(__name__) @app.route('/') def addRegion(): return render_template('Website WordCount.html') @app.route('/output_data', methods=['POST','GET']) def output_data(): ...
normal
{ "blob_id": "11dfb09286b8a5742550b5300c776ed82e69ead5", "index": 2577, "step-1": "<mask token>\n\n\n@app.route('/')\ndef addRegion():\n return render_template('Website WordCount.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n@app.route('/')\ndef addRegion():\n return render_template('Website W...
[ 1, 3, 4, 5, 6 ]
### 15/04/2020 ### Author: Omer Goder ### Looping through a list months = ['january','fabruary','march','april','may','june','july','august','september','october','november','december'] # Using a for loop to print a list for month in months: print("The next month is:\t" + month) print('\n') print("\nEnd ...
normal
{ "blob_id": "bc8bc5c3b6954302d005fe618827c644f93ad14e", "index": 6030, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor month in months:\n print('The next month is:\\t' + month)\n print('\\n')\nprint(\"\"\"\nEnd of program\n\"\"\")\n", "step-3": "months = ['january', 'fabruary', 'march', 'april...
[ 0, 1, 2, 3 ]
class Rectangle(): def __init__(self,length,breadth): self.length=length self.breadth=breadth def area(self): return(self.length*self.breadth) def perimeter(self): return(2*(self.length+self.breadth)) r1=Rectangle(4,5) r2=Rectangle(5,7) a1=r1.area() a2=r2.area() p1=r1.perim...
normal
{ "blob_id": "d5691403812cd3742f8e8b74d4ca613eca784ffd", "index": 9677, "step-1": "class Rectangle:\n <mask token>\n <mask token>\n\n def perimeter(self):\n return 2 * (self.length + self.breadth)\n\n\n<mask token>\n", "step-2": "class Rectangle:\n\n def __init__(self, length, breadth):\n ...
[ 2, 3, 4, 6, 7 ]
import turtle hexagon = turtle.Turtle() for i in range(6): hexagon.forward(100) hexagon.left(60)
normal
{ "blob_id": "f6401eca2dc0ea86a934e859c35fa2d6c85a61b3", "index": 8695, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(6):\n hexagon.forward(100)\n hexagon.left(60)\n", "step-3": "<mask token>\nhexagon = turtle.Turtle()\nfor i in range(6):\n hexagon.forward(100)\n hexagon.left...
[ 0, 1, 2, 3 ]
""" Python Challenge - Level 1 - What about making trans? """ import string #import requests #res = requests.get('http://www.pythonchallenge.com/pc/def/map.html') #res.raise_for_status() #print(res.text) INPUT_TEXT = string.ascii_lowercase # abcdefghijklmnopqrstuvwxyz OUTPUT_TEXT = INPUT_TEXT[2:]+INPUT_TEXT[:2...
normal
{ "blob_id": "3c03f71ef9de8825ecd7c89208c79f43c9fb7a56", "index": 9594, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('http://www.pythonchallenge.com/pc/def/ocr.html')\n", "step-3": "<mask token>\nINPUT_TEXT = string.ascii_lowercase\nOUTPUT_TEXT = INPUT_TEXT[2:] + INPUT_TEXT[:2]\nTRANSLATION_TABL...
[ 0, 1, 2, 3, 4 ]
from scipy.stats import itemfreq from sklearn.model_selection import StratifiedKFold from keras_utils.keras_utils import * from keras.utils.np_utils import to_categorical from keras.layers import Input, Embedding, Dense, GlobalAveragePooling1D, Flatten from keras.layers import add, multiply, LSTM, Bidirectiona...
normal
{ "blob_id": "0b125e7e9e763d4fd71e381ca823f9e9aa8ea606", "index": 8198, "step-1": "<mask token>\n\n\nclass MaskedGlobalAveragePooling1D(GlobalAveragePooling1D):\n\n def __init__(self, **kwargs):\n super(MaskedGlobalAveragePooling1D, self).__init__(**kwargs)\n self.supports_masking = True\n\n\ncla...
[ 7, 11, 13, 14, 15 ]
# -*- coding: utf-8 -*- import random from cocos.actions import MoveTo, CallFuncS from cocos.sprite import Sprite import define def kill(spr): spr.unschedule(spr.update) arena = spr.parent.parent if not spr.is_big: arena.batch.add(Dot()) spr.killer.add_score() else: spr.killer...
normal
{ "blob_id": "be06a0ad22f4ae9ab4c0acea6a7c601c14a90fc4", "index": 1995, "step-1": "<mask token>\n\n\nclass Dot(Sprite):\n <mask token>\n\n def update(self, dt):\n arena = self.parent.parent\n snake = arena.snake\n self.check_kill(snake)\n for s in arena.enemies:\n self...
[ 2, 4, 5, 6, 7 ]
########################################################################################## ## Scene Classification ## ## Authors : Chris Andrew, Santhoshini Reddy, Nikath Yasmeen, Sai Hima, Sriya Ragini ## ###############################################...
normal
{ "blob_id": "b8b20d6c977a6c1df6a592188c6e799f12da6a23", "index": 9734, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in f:\n l = line.strip()\n l = l.split(',')\n l = map(float, l)\n data.append(l)\nf.close()\nfor i in range(100):\n shuffle(data)\nfor l in data:\n train_data.a...
[ 0, 1, 2, 3, 4 ]
""" Implements a Neural Network """ from vectorflux import VectorFlux from mnist import read, show, normalize from vectorflux.layers import Dense from vectorflux.layers.Dropout import Dropout train = list(read('train')) test = list(read('test')) print("Train size: {}".format(len(train))) print("Test size: {}".forma...
normal
{ "blob_id": "94d296b5a13bfa59dba5812da31707f9db9080af", "index": 1292, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Train size: {}'.format(len(train)))\nprint('Test size: {}'.format(len(test)))\n<mask token>\nvf.add(Dense(800, activation='sigmoid', input_shape=784, optimizer='Momentum'))\nvf.add...
[ 0, 1, 2, 3, 4 ]
from PyQt5.QtWidgets import * from select_substituents_table import * from save_selection_dialog import * class SelectSubsDialog(QDialog): def __init__(self, r_group): super().__init__() self.r_group = r_group self.substituents = None self.new_set_saved = False self.setWi...
normal
{ "blob_id": "849db3a92e0544661dd465b3e7f6949f8de5633b", "index": 5099, "step-1": "<mask token>\n\n\nclass SelectSubsDialog(QDialog):\n <mask token>\n\n def enable_save_buttons(self):\n self.confirm_button.setEnabled(True)\n self.save_as_set_button.setEnabled(True)\n\n def get_substituents(...
[ 7, 8, 9, 11, 12 ]
""" Merkle: Implementation of Merkle Trees over Blake2 """ from typing import List, Any from hashlib import blake2b class Merkle: """ We consider the merkle tree as a commitment protocol implementing the interface: * commit_() : commits to a list by computing the merkle tree. * open_() : opens the...
normal
{ "blob_id": "547926904f9a4b88a988e3b59c49b94fe0e30de4", "index": 1955, "step-1": "<mask token>\n\n\nclass Merkle:\n <mask token>\n <mask token>\n\n def commit_(leafs):\n assert len(leafs) & len(leafs\n ) - 1 == 0, 'List must be of a power two length'\n if len(leafs) == 1:\n ...
[ 6, 7, 9, 10, 11 ]
class CustomPrinter(object): def __init__(self, val): self.val = val def to_string(self): res = "{" for m in xrange(64): res += hex(int(self.val[m])) if m != 63: res += ", " res += " }" return res def lookup_type(val): if str...
normal
{ "blob_id": "4d5b2ed016cfc6740c3ee5397c894fabc1bec73f", "index": 6963, "step-1": "class CustomPrinter(object):\n <mask token>\n\n def to_string(self):\n res = '{'\n for m in xrange(64):\n res += hex(int(self.val[m]))\n if m != 63:\n res += ', '\n re...
[ 2, 3, 4, 5, 6 ]
from asteroidhunter import __version__ import unittest, requests, json, os, pytest from dotenv import load_dotenv load_dotenv() from asteroidhunter.asteroid_closest_approach import asteroid_closest_approach def test_version(): assert __version__ == '0.1.0' @pytest.mark.vcr() def test_asteroid_closest_approach()...
normal
{ "blob_id": "7dd4dc60b23c72ba450025bececb0e6d89df69c3", "index": 8263, "step-1": "<mask token>\n\n\ndef test_version():\n assert __version__ == '0.1.0'\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef test_version():\n assert __version__ == '0.1.0'\n\n\n@pytest.mark.vcr()\ndef test_asteroid_closest...
[ 1, 2, 3, 4 ]
import numpy as np import math class KMeans(object): def __init__(self, data, option): self.data = data self.membership = None self.centroids = None self.option = option self.temp_data = None def fit(self, K): data = np.asmatrix(self.data[0]) if self.o...
normal
{ "blob_id": "5cf73e003b744b438c0db67ab39fb10a3f879f2f", "index": 8556, "step-1": "<mask token>\n\n\nclass KMeans(object):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass KMeans(object):\n\n def __init__(self, data, option):\n self.data = data\n self...
[ 1, 2, 4, 5, 6 ]
"""asks the user for english words to latinize""" def latinize_word(word): """performs bee latin on a word""" if word[0].lower() in 'bcdfghjklmnpqrstvwxyz': word = word[1:] + word[0] + 'uzz' else: word += 'buzz' return word.lower() def latinize_sentence(sentence): """performs bee...
normal
{ "blob_id": "5810739300067e8f207d09bf971484a278372a9a", "index": 5246, "step-1": "<mask token>\n\n\ndef latinize_word(word):\n \"\"\"performs bee latin on a word\"\"\"\n if word[0].lower() in 'bcdfghjklmnpqrstvwxyz':\n word = word[1:] + word[0] + 'uzz'\n else:\n word += 'buzz'\n return ...
[ 1, 2, 3, 4, 5 ]
# %% import numpy as np from numpy import sin, cos, pi import gym import seagul.envs from seagul.integration import rk4,euler from control import lqr, ctrb from torch.multiprocessing import Pool import matplotlib.pyplot as plt import matplotlib #matplotlib.use('Qt5Agg') import time global_start = time.time() # %% ...
normal
{ "blob_id": "358d4573ff386d6874d5bb5decfe71c71141bf1c", "index": 2525, "step-1": "<mask token>\n\n\ndef control(q):\n gs = np.array([pi / 2, 0, 0, 0])\n return -k.dot(q - gs)\n\n\ndef reward_fn(s, a):\n reward = np.sin(s[0]) + 2 * np.sin(s[0] + s[1])\n done = reward < 2\n return reward, done\n\n\n...
[ 5, 6, 7, 8, 9 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.8 on 2018-04-27 08:05 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('talk', '0023_auto_20180207_1121'), ] operations = [ migrations.AddField( ...
normal
{ "blob_id": "f85a703b47d981397ed6048e941030a3fbee7b6d", "index": 229, "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 = [('talk', '0023...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.1.7 on 2019-03-24 07:08 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('adminsite', '0005_auto_20190324_0706'), ] operations = [ migrations.RenameField( model_name='district', old_name='District',...
normal
{ "blob_id": "6e56c7792d88385cc28c48a7d6dd32b9d6917c64", "index": 2913, "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 = [('adminsite',...
[ 0, 1, 2, 3, 4 ]
from django.apps import AppConfig class CfCoreConfig(AppConfig): name = 'cf_core'
normal
{ "blob_id": "01847c9e601eae6775cd4324483740c30e344557", "index": 382, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass CfCoreConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass CfCoreConfig(AppConfig):\n name = 'cf_core'\n", "step-4": "from django.apps import AppCon...
[ 0, 1, 2, 3 ]
from django.apps import AppConfig class PersianConfig(AppConfig): name = 'persian'
normal
{ "blob_id": "6b0d1de4c77841f20670331db3332cf87be7ad84", "index": 3931, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PersianConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass PersianConfig(AppConfig):\n name = 'persian'\n", "step-4": "from django.apps import App...
[ 0, 1, 2, 3 ]
from rest_framework import serializers from .models import SensorValue class SensorValueSerializer(serializers.ModelSerializer): timestamp = serializers.DateTimeField(required=False) class Meta: model = SensorValue fields = ("id", "timestamp", "sensor_type", "value")
normal
{ "blob_id": "39312ec60c9ef1c9c95cf4206b6d0bbdb0aedf94", "index": 9042, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass SensorValueSerializer(serializers.ModelSerializer):\n <mask token>\n\n\n class Meta:\n model = SensorValue\n fields = 'id', 'timestamp', 'sensor_type', 'valu...
[ 0, 1, 2, 3, 4 ]
# from django.contrib.auth import forms # class UserRegister(froms.M): # class Meta: # fields = []
normal
{ "blob_id": "c1f432ff70b21064f36cf9651f8cff9c69361d5c", "index": 9073, "step-1": "# from django.contrib.auth import forms\n\n\n\n# class UserRegister(froms.M):\n# class Meta:\n# fields = []\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 1 ] }
[ 1 ]
import logging import os from os.path import exists, abspath, join, dirname from os import mkdir os.environ["MKL_NUM_THREADS"] = "1" os.environ["MP_NUM_THREADS"] = "1" from smallab.runner_implementations.multiprocessing_runner import MultiprocessingRunner from plannin_experiment import PlanningExperiment mpl_logger ...
normal
{ "blob_id": "88d8d04dd7117daed0e976f3abc52c5d7bf18434", "index": 9334, "step-1": "<mask token>\n", "step-2": "<mask token>\nmpl_logger.setLevel(logging.WARNING)\n<mask token>\nif __name__ == '__main__':\n if 'experiments' in os.getcwd():\n os.chdir('../..')\n this_dir = dirname(abspath(__file__))\...
[ 0, 1, 2, 3, 4 ]
##### # Created on Oct 15 13:13:11 2019 # # @author: inesverissimo # # Do pRF fit on median run, make iterative fit and save outputs #### import os # issue with tensorflow, try this suggestion #NUM_PARALLEL_EXEC_UNITS = 16 #os.environ['OMP_NUM_THREADS'] = str(NUM_PARALLEL_EXEC_UNITS) #os.environ["KMP_AFFINI...
normal
{ "blob_id": "d9156e240d49e0a6570a5bc2315f95a7a670fd4f", "index": 6327, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv) < 2:\n raise NameError(\n 'Please add subject number (ex:1) as 1st argument in the command line!'\n )\nelif len(sys.argv) < 3:\n raise NameError(\n ...
[ 0, 1, 2, 3, 4 ]
import numpy import cv2 from keras.models import model_from_json from keras.layers import Dense from keras.utils import np_utils import os from keras.optimizers import SGD, Adam numpy.random.seed(42) file_json = open('model.json', "r") model_json = file_json.read() file_json.close() model = model_from_json(model_json)...
normal
{ "blob_id": "05021c3b39a0df07ca3d7d1c3ff9d47be6723131", "index": 4084, "step-1": "<mask token>\n", "step-2": "<mask token>\nnumpy.random.seed(42)\n<mask token>\nfile_json.close()\n<mask token>\nmodel.load_weights('weights.h5')\nprint('Model loaded')\n<mask token>\nmodel.compile(loss='categorical_crossentropy',...
[ 0, 1, 2, 3, 4 ]
from phylo_utils.data import fixed_equal_nucleotide_frequencies from phylo_utils.substitution_models.tn93 import TN93 class K80(TN93): _name = 'K80' _freqs = fixed_equal_nucleotide_frequencies.copy() def __init__(self, kappa, scale_q=True): super(K80, self).__init__(kappa, kappa, 1, self._freqs, ...
normal
{ "blob_id": "0f0595793e98187c6aaf5b1f4b59affb06bb598e", "index": 3159, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass K80(TN93):\n <mask token>\n <mask token>\n\n def __init__(self, kappa, scale_q=True):\n super(K80, self).__init__(kappa, kappa, 1, self._freqs, scale_q=scale_q\n...
[ 0, 2, 3, 4 ]
# import sys # sys.stdin = open("농작물input.txt") T = int(input()) for n in range(1, T+1): N = int(input()) arr = [list(map(int, list(input()))) for _ in range(N)] # print(arr) a = N//2 b = N//2 result = 0 for i in range(N): for j in range(a, b+1): result += arr[i][j] ...
normal
{ "blob_id": "2236591b3a30f51442beb20c6c43cc9e6cd921d2", "index": 7530, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor n in range(1, T + 1):\n N = int(input())\n arr = [list(map(int, list(input()))) for _ in range(N)]\n a = N // 2\n b = N // 2\n result = 0\n for i in range(N):\n ...
[ 0, 1, 2, 3 ]
# Importing the random library for random choice. import random getnum = int(input("Pick a number greater than 7: ")) # Error checking. if (getnum < 7): print("Error 205: Too little characters entered") print("Run again using python passwordgenerator.py, or click the run button on your IDE.") exit() # A li...
normal
{ "blob_id": "c40bb410ad68808c2e0cc636820ec6a2ec2739b8", "index": 4053, "step-1": "<mask token>\n\n\ndef main(lista, getnum):\n password = ''\n for i in range(0, getnum):\n passchar = random.choice(lista)\n password = password + passchar\n print(password)\n passwordagain()\n\n\ndef passw...
[ 2, 3, 4, 5, 6 ]
import csv, requests from bs4 import BeautifulSoup items = [] # chooseKey, count, grade, keyType, mainCategory, mainKey, # name, pricePerOne, subCategory, subKey, totalTradeCount, # mainLabel, subLabel, description mpItems = [] # chooseKey, count, grade, keyType, mainCategory, mainKey, ...
normal
{ "blob_id": "47ad08bb153801f592d90c48d62338d0f7703899", "index": 2788, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef openCsv():\n \"\"\"Open csv file.\"\"\"\n csvFile = 'BDO_app/modules/priceCheck/itemID.csv'\n return csvFile\n\n\ndef importAll():\n \"\"\"Import all the items from cs...
[ 0, 3, 4, 5, 6 ]
"""Project agnostic helper functions that could be migrated to and external lib. """
normal
{ "blob_id": "f15bb4ab93ecb2689bf74687852e60dfa98caea9", "index": 7374, "step-1": "<mask token>\n", "step-2": "\"\"\"Project agnostic helper functions that could be migrated to and external lib.\n\"\"\"\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
columns = ['account', 'name', 'Death', 'archetype', 'profession', 'elite', 'phases.All.actual_boss.dps', 'phases.All.actual.dps', 'phases.All.actual_boss.flanking', 'phases.All.actual_boss.scholar', 'phases.All.actual_boss.condi_dps', 'phases.All.actual_boss.power_dps', 'phases.All.buffs.aegis', 'phases...
normal
{ "blob_id": "fa948838b5c2d688fe8c748166f23ffc8e677f93", "index": 9265, "step-1": "<mask token>\n", "step-2": "columns = ['account', 'name', 'Death', 'archetype', 'profession', 'elite',\n 'phases.All.actual_boss.dps', 'phases.All.actual.dps',\n 'phases.All.actual_boss.flanking', 'phases.All.actual_boss.sc...
[ 0, 1 ]
from django.forms import ModelForm, ChoiceField, Form, FileField, ModelChoiceField, HiddenInput, ValidationError from market.models import * class OrderForm(ModelForm): """Order form used in trader view.""" # from http://stackoverflow.com/questions/1697702/how-to-pass-initial-parameter-to-djangos-modelform-ins...
normal
{ "blob_id": "044e3479c32357e22ca3165d8601d8bd2a439fcb", "index": 2329, "step-1": "<mask token>\n\n\nclass OrderForm(ModelForm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n model = Order\n fields = 'stock', 'order...
[ 3, 4, 5, 6, 8 ]
from simulating_blobs_of_fluid.simulation import Simulation from simulating_blobs_of_fluid.fluid_renderer import FluidRenderer import arcade def main(): simulation = Simulation(particle_count=50, dt=0.016, box_width=250) FluidRenderer(simulation.box_width, 800, simulation) arcade.run() if __name__ == ...
normal
{ "blob_id": "83733e707a1be131335c4980cdf4beed365eb530", "index": 6011, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n simulation = Simulation(particle_count=50, dt=0.016, box_width=250)\n FluidRenderer(simulation.box_width, 800, simulation)\n arcade.run()\n\n\n<mask token>\n", ...
[ 0, 1, 2, 3, 4 ]
import os import pandas as pd from sklearn.decomposition import PCA import matplotlib.pyplot as plt name="/home/t3cms/thessel/Workflow1.5/stop_data/stop_train_sig_wc.csv" name_bkg="/home/t3cms/thessel/Workflow1.5/stop_data/stop_train_bkg_wc.csv" drop_cols=[0,1,2,15] names = [i for i in range(16)] #columns=[]...
normal
{ "blob_id": "f8bb2851192a53e94e503c0c63b17477878ad9a7", "index": 6926, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Before PCA', final_df)\nfor i in pca_df.columns:\n final_df[i] = pca_df[i]\nprint('After PCA', final_df)\n<mask token>\nfinal_df.iloc[:cut].to_csv('pca_stop_train_sig_wc.csv', h...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # ---------------------------------------------------------------------------- # Copyright © 2020- Spyder Project Contributors # # Released under the terms of the MIT License # ---------------------------------------------------------------------------- """Tests for the execution of pylint.""" ...
normal
{ "blob_id": "22792937415a8ee4cecff2a9683c435abe54bdab", "index": 5516, "step-1": "<mask token>\n\n\nclass MainWindowMock(QObject):\n sig_editor_focus_changed = Signal(str)\n\n def __init__(self):\n super(MainWindowMock, self).__init__(None)\n self.editor = Mock()\n self.editor.sig_edit...
[ 10, 11, 12, 14, 15 ]
from . import preprocess from . import utils import random import pickle import feather import time import datetime import sys import os import numpy as np import pandas as pd import json from ...main import api from flask import request from flask_restplus import Resource, fields import warnings warnings.simplefilter...
normal
{ "blob_id": "c76fd9b196b50e6fcced7e56517c0cd8ab30e24e", "index": 7891, "step-1": "<mask token>\n\n\n@api.route('/predict')\n@api.expect(parser)\nclass Predict(Resource):\n <mask token>\n\n\n@api.route('/predict/<string:companyid>/<string:accountid>')\n@api.expect(parser)\nclass PredictEmployeeByCompany(Resour...
[ 6, 7, 8, 10, 15 ]
import json import pika import urllib.request def validate_urls(): connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() channel.queue_declare(queue='urlValidationQueue') channel.basic_consume(validate_url, queue='urlValid...
normal
{ "blob_id": "4a09096abf073294afcf21b1eff9350329d4db33", "index": 5252, "step-1": "<mask token>\n\n\ndef validate_url(ch, method, properties, body):\n message = json.loads(body)\n valid = True\n print(f\"Got new URL to check: {message['url']}.\")\n try:\n urllib.request.urlopen('https://github....
[ 1, 2, 3, 4, 5 ]
age=int(input('请输入您的年龄:')) subject=input('请输入您的专业:') college=input('请输入您是否毕业于重点大学:(是/不是)') if (subject=='电子信息工程' and age>25) or (subject=='电子信息工程' and college=='是') or (age<28 and subject=='计算机'): print('恭喜您被录取!') else: print('抱歉,您未达到面试要求')
normal
{ "blob_id": "4282303e3e6ee122f1379bea73c619870f983f61", "index": 8580, "step-1": "<mask token>\n", "step-2": "<mask token>\nif subject == '电子信息工程' and age > 25 or subject == '电子信息工程' and college == '是' or age < 28 and subject == '计算机':\n print('恭喜您被录取!')\nelse:\n print('抱歉,您未达到面试要求')\n", "step-3": "age...
[ 0, 1, 2, 3 ]
# Copyright 2014 The Oppia Authors. 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 required by applicable ...
normal
{ "blob_id": "8a848eece6a3ed07889ba208068de4bfa0ad0bbf", "index": 6744, "step-1": "# Copyright 2014 The Oppia Authors. All Rights Reserved.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the Li...
[ 0 ]
# Copyright 2021 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agree...
normal
{ "blob_id": "48cef0377087d9245aad1fb759adf8ff07d2b66f", "index": 4464, "step-1": "<mask token>\n\n\ndef cut_text_line(geo, scale_ratio_w, scale_ratio_h, im_array, img_path, s):\n geo /= [scale_ratio_w, scale_ratio_h]\n p_min = np.amin(geo, axis=0)\n p_max = np.amax(geo, axis=0)\n min_xy = p_min.astyp...
[ 2, 4, 5, 6, 7 ]
''' Created on Sep 4, 2014 @author: Jay <smile665@gmail.com> ''' import socket def ip_validation(ip): ''' check if the ip address is in a valid format. ''' try: socket.inet_aton(ip) return True except socket.error: return False def connection_validation(ip, port): '...
normal
{ "blob_id": "2bc9c0711831d9ed9009d0f9600153709bbcd6da", "index": 9178, "step-1": "'''\nCreated on Sep 4, 2014\n\n@author: Jay <smile665@gmail.com>\n'''\n\nimport socket\n\n\ndef ip_validation(ip):\n '''\n check if the ip address is in a valid format.\n '''\n try:\n socket.inet_aton(ip)\n ...
[ 0 ]
from huobi import RequestClient from huobi.constant.test import * request_client = RequestClient(api_key=g_api_key, secret_key=g_secret_key) obj_list = request_client.get_cross_margin_loan_orders() if len(obj_list): for obj in obj_list: obj.print_object() print()
normal
{ "blob_id": "c65969bba72142f4a328f978d78e0235cd56e393", "index": 8618, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(obj_list):\n for obj in obj_list:\n obj.print_object()\n print()\n", "step-3": "<mask token>\nrequest_client = RequestClient(api_key=g_api_key, secret_key=g_secr...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python import pygame import pygame.mixer as mixer def pre_init(): mixer.pre_init(22050, -16, 2, 2048) def init(): mixer.init() pygame.mixer.set_num_channels(16) def deinit(): mixer.quit() class Music (object): our_music_volume = 0.8 our_current_music = None def __in...
normal
{ "blob_id": "2caea9e7bbef99b19ba917995513413385c7abdf", "index": 9808, "step-1": "<mask token>\n\n\nclass Music(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>\n\n @staticmethod\n def ...
[ 12, 18, 21, 24, 25 ]
"""Visit module to add odoo checks """ import os import re import astroid import isort from pylint.checkers import utils from six import string_types from .. import misc, settings ODOO_MSGS = { # C->convention R->refactor W->warning E->error F->fatal # Visit odoo module with settings.BASE_OMODULE_ID 'C...
normal
{ "blob_id": "9f34f94422f4847859e9111f34ade2e1274cb543", "index": 8775, "step-1": "<mask token>\n\n\nclass ModuleChecker(misc.WrapperModuleChecker):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n @utils.check_messages('consider-merging-classes-inherited')\n def...
[ 24, 28, 33, 42, 46 ]
from end import Client c = Client()
normal
{ "blob_id": "1be510e6715d21e814c48fe05496704e9a65d554", "index": 308, "step-1": "<mask token>\n", "step-2": "<mask token>\nc = Client()\n", "step-3": "from end import Client\nc = Client()\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
import datetime import json from dateutil import parser import mock from python_http_client.exceptions import ForbiddenError from rdr_service import clock, config from rdr_service.api_util import open_cloud_file from rdr_service.clock import FakeClock from rdr_service.dao.database_utils import format_datetime from rd...
normal
{ "blob_id": "bd179fda18551d4f3d8a4d695a9da38ee607ef1d", "index": 2168, "step-1": "<mask token>\n\n\nclass GenomicJobControllerTest(BaseTestCase):\n\n def setUp(self):\n super(GenomicJobControllerTest, self).setUp()\n self.data_file_dao = GenomicGcDataFileDao()\n self.event_data_dao = Mess...
[ 9, 13, 17, 22, 25 ]
#!/usr/bin/python class Bob(object): def __init__(self): self.question_response = "Sure." self.yell_response = "Woah, chill out!" self.silent_response = "Fine. Be that way!" self.whatever = "Whatever." def hey(self, question): if not(question) or question.strip()=='': ...
normal
{ "blob_id": "7ff7da216bdda5c30bf7c973c82886035b31247c", "index": 4093, "step-1": "<mask token>\n", "step-2": "class Bob(object):\n <mask token>\n <mask token>\n", "step-3": "class Bob(object):\n <mask token>\n\n def hey(self, question):\n if not question or question.strip() == '':\n ...
[ 0, 1, 2, 3, 4 ]
""" Utilities for calculations based on antenna positions, such as baseline and phase factor. """ import os import numpy as np import pickle c = 299792458 # m / s data_prefix = os.path.dirname(os.path.abspath(__file__)) + "/" try: ant_pos = dict(pickle.load(open(data_prefix + "ant_dict.pk", "rb"))) def base...
normal
{ "blob_id": "c455263b82c04fe2c5cc1e614f10a9962795f87e", "index": 4349, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n ant_pos = dict(pickle.load(open(data_prefix + 'ant_dict.pk', 'rb')))\n\n def baselength(ant_ID1, ant_ID2):\n \"\"\"\n (Convenience function)\n Return the...
[ 0, 1, 2, 3, 4 ]
# python2.7 #formats for oracle lists import pyperclip text = str(pyperclip.paste()).strip() lines = text.split('\n') for i in range(len(lines)): if (i+1) < len(lines): lines[i] = str('\'')+str(lines[i]).replace("\r","").replace("\n","") + str('\',') elif (i+1) == len(lines): lines[...
normal
{ "blob_id": "454fd88af552d7a46cb39167f21d641420973959", "index": 2312, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(len(lines)):\n if i + 1 < len(lines):\n lines[i] = str(\"'\") + str(lines[i]).replace('\\r', '').replace('\\n', ''\n ) + str(\"',\")\n elif i + 1 ==...
[ 0, 1, 2, 3, 4 ]
class User(): def __init__(self, first, last, gender, age): self.first_name = first self.last_name = last self.gender = gender self.age = age self.full_name = self.first_name + " " + self.last_name def describe_user(self): print("The name of the user is " + self....
normal
{ "blob_id": "93b712c60ba4bfa81d967ec59035b6fb7793ce87", "index": 1974, "step-1": "class User:\n <mask token>\n <mask token>\n\n def greet_user(self):\n if self.gender.lower() == 'male':\n print('Greetings, Mr. ' + self.last_name.title() + '!')\n elif self.gender.lower() == 'fema...
[ 2, 3, 4, 6, 7 ]
from django.http import HttpResponsePermanentRedirect from django.urls import is_valid_path from django.utils.deprecation import MiddlewareMixin from django.utils.http import escape_leading_slashes class AppendSlashMiddleware(MiddlewareMixin): response_redirect_class = HttpResponsePermanentRedirect def proc...
normal
{ "blob_id": "ec70fb9119b430dcd36549f2fac8e5e0a0e1bb00", "index": 2696, "step-1": "<mask token>\n\n\nclass AppendSlashMiddleware(MiddlewareMixin):\n <mask token>\n\n def process_request(self, request):\n redirect_url = ''\n if self.should_redirect_with_slash(request):\n path = self....
[ 4, 5, 6, 7, 8 ]
# Original code from http://www.pythonforbeginners.com/code-snippets-source-code/port-scanner-in-python #!/usr/bin/env python # modules import threading import socket import subprocess import sys import time import scapy from threading import Thread, Lock from queue import Queue from datetime import datetime from log...
normal
{ "blob_id": "7e0eefb1d913787f675adc2ba0dccb16007464e4", "index": 1764, "step-1": "<mask token>\n\n\ndef checkhost(ip):\n conf.verb = 0\n try:\n ping = sr1(IP(dst=ip) / ICMP())\n print('\\n[*] Target is up, beginning scan...')\n except Exception:\n print(\"\\n[!] Couldn't resolve tar...
[ 2, 3, 4, 5, 6 ]
for name in ["Madan", "Mohan", "Reddy", "Govindu"]: print("My name includes "+name) # Tables # for i in range(1, 11): # for j in range(1, 11): # print("{0} * {1} = {2}".format(i,j, i*j)) # print("\n") for i in range(1, 3): for j in range(4, 7): if j==5: break print...
normal
{ "blob_id": "c0376d94b34ea43e562e68cd65d4e5d2c5b04fb3", "index": 6657, "step-1": "<mask token>\n", "step-2": "for name in ['Madan', 'Mohan', 'Reddy', 'Govindu']:\n print('My name includes ' + name)\nfor i in range(1, 3):\n for j in range(4, 7):\n if j == 5:\n break\n print(j)\n",...
[ 0, 1, 2 ]
import numpy as np import cv2 from pixcel import * from scipy import ndimage import math from socket import * from config import * from time import time def find_bounding_boxes(fimage, lables): # initialize boxes array boxes = [] for lable in lables: # iterate all lables # filter out i...
normal
{ "blob_id": "f3895f38be29fb07903237d8846cc9d657b39ea9", "index": 6495, "step-1": "<mask token>\n\n\nclass RBox:\n\n def __init__(self):\n self.x = 0\n self.y = 0\n self.w = 0\n self.h = 0\n\n @staticmethod\n def fromClassicalBoundingBox(box):\n rbox = RBox()\n r...
[ 23, 26, 28, 37, 41 ]
from math import sqrt from Engine.regulators.PID import PID from Engine.regulators.regulator_base_class import RegulatorBaseClass from Engine.robot import Robot, MAX_LINEAR_ACCELERATION, MAX_ANGULAR_SPEED from Util import Pose from Util.geometry import clamp, normalize from Util.pose import Position from config.config...
normal
{ "blob_id": "98bf0a332a6753e500b24bed2af16fe4a1cb9568", "index": 1560, "step-1": "<mask token>\n\n\nclass RealVelocityController(RegulatorBaseClass):\n settings = {'kp': 10, 'ki': 0, 'kd': 1}\n v_d = 4\n emergency_break_constant = 0.4\n emergency_break_safety_factor = 1\n\n def __init__(self):\n ...
[ 10, 11, 13, 14, 15 ]
#-*- coding: utf-8 -*- import django if django.get_version() <= '1.3.1': import apps.settings as settings from django.core.management import setup_environ setup_environ(settings) elif django.get_version() >= '1.7.0': import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apps.settings") ...
normal
{ "blob_id": "8894b73829978cec29aab6ee8bf09700da7fb59f", "index": 5659, "step-1": "#-*- coding: utf-8 -*-\n\nimport django\n\nif django.get_version() <= '1.3.1':\n import apps.settings as settings\n from django.core.management import setup_environ\n setup_environ(settings)\nelif django.get_version() >= '...
[ 0 ]
import requests import datetime import collections import csv import sys import os import os.path History = collections.namedtuple('History', ['open', 'high', 'low', 'close', 'volume', 'adjustment']) def history(symbol, since, until): response = requests.get('http://ichart.finance.yahoo.com/table.csv?s=%s&d=%d&e...
normal
{ "blob_id": "1cccb37a7195b1555513a32ef33b35b0edcd5eb1", "index": 5363, "step-1": "import requests\nimport datetime\nimport collections\nimport csv\nimport sys\nimport os\nimport os.path\n\n\nHistory = collections.namedtuple('History', ['open', 'high', 'low', 'close', 'volume', 'adjustment'])\n\ndef history(symbo...
[ 0 ]
#!/usr/bin/python # -*- coding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable ...
normal
{ "blob_id": "8dab85622a29bc40f8ad6150f9e6f284853aeaf8", "index": 4235, "step-1": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\"); you may\n# not use this file except in compliance with the License. You may obtain\n# a copy of the License...
[ 0 ]
import Ploneboard import PloneboardForum import PloneboardConversation import PloneboardComment
normal
{ "blob_id": "abdf5aee77ee879c50d0e605d5fd95e28a7ef7aa", "index": 5631, "step-1": "<mask token>\n", "step-2": "import Ploneboard\nimport PloneboardForum\nimport PloneboardConversation\nimport PloneboardComment\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2017-07-20 08:05 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): initial = True depe...
normal
{ "blob_id": "e68d872232b3eab4c33cbbe4376be7dd788888e2", "index": 1242, "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 ]
import sys import time import pymorphy2 import pyglet import pyttsx3 import threading import warnings import pytils warnings.filterwarnings("ignore") """ Количество раундов, вдохов в раунде, задержка дыхания на вдохе""" rounds, breaths, hold = 4, 30, 13 def play_wav(src): wav = pyglet.media.load(sys.path[0] + '...
normal
{ "blob_id": "a98be930058269a6adbc9a28d1c0ad5d9abba136", "index": 35, "step-1": "<mask token>\n\n\ndef nums(phrase, morph=pymorphy2.MorphAnalyzer()):\n \"\"\" согласование существительных с числительными, стоящими перед ними \"\"\"\n phrase = phrase.replace(' ', ' ').replace(',', ' ,')\n numeral = ''\n ...
[ 10, 11, 13, 17, 18 ]
from __future__ import division from pyoperators import pcg from pysimulators import profile from qubic import ( create_random_pointings, equ2gal, QubicAcquisition, PlanckAcquisition, QubicPlanckAcquisition, QubicInstrument) from qubic.data import PATH from qubic.io import read_map import healpy as hp import ma...
normal
{ "blob_id": "bcb028bd25732e17ed1478e122ac3b2d1abf2520", "index": 7931, "step-1": "<mask token>\n\n\ndef statstr(vec):\n m = np.mean(vec)\n s = np.std(vec)\n return '{0:.4f} +/- {1:.4f}'.format(m, s)\n\n\ndef plotinst(inst, shift=0.12):\n for xyc, quad in zip(inst.detector.center, inst.detector.quadra...
[ 4, 5, 6, 7, 8 ]
"""The prediction classes. Instances of the class are returned by the recommender. """ class RelationshipPrediction(object): """The prediction of the predicted_relationship appearing between the given subject-object pair. @type subject: the domain-specific subject @ivar subject: the subject ...
normal
{ "blob_id": "c3de9e6129bcafd863cd330ac281345fb563cc8c", "index": 6259, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass RelationshipPrediction(object):\n <mask token>\n <mask token>\n\n def __unicode__(self):\n return u'%s <- %s: %f, %s' % (self.subject, self.object_, self.\n ...
[ 0, 2, 3, 4, 6 ]
import os import json def load_json_if_exists(path): if not os.path.isfile(path): return {} with open(path) as f: return json.load(f) def json_dump(obj, file_path): with open(file_path, 'w') as f: json.dump(obj, f) def get_folder_paths(directory): return [os.path.join(directo...
normal
{ "blob_id": "3788888a17e2598e781803f89cd63ac9c3219f59", "index": 4341, "step-1": "<mask token>\n\n\ndef json_dump(obj, file_path):\n with open(file_path, 'w') as f:\n json.dump(obj, f)\n\n\n<mask token>\n\n\ndef get_repo_path(file_path):\n if os.path.isfile(file_path):\n folder_path = os.path...
[ 8, 9, 12, 13, 14 ]
#!/usr/bin/python # -*- coding: utf-8 -*- import csv from collections import defaultdict from docopt import docopt __doc__ = """{f} Usage: {f} <used_file> {f} -h | --help Options: -h --help Show this screen and exit. """.format(f=__file__) args = docopt(__doc__) used_file = args['<used_file>'] ...
normal
{ "blob_id": "40b6d62f1e360c0df19b7e98fcb67dbd578e709f", "index": 736, "step-1": "#!/usr/bin/python\n# -*- coding: utf-8 -*-\nimport csv\nfrom collections import defaultdict\nfrom docopt import docopt\n\n__doc__ = \"\"\"{f}\n\nUsage:\n {f} <used_file>\n {f} -h | --help\n\nOptions:\n -h --help Sh...
[ 0 ]
from whylogs.core.annotation_profiling import Rectangle def test_rect(): rect = Rectangle([[0, 0], [10, 10]], confidence=0.8, labels=[{"name": "test"}]) test = Rectangle([[0, 0], [5, 5]]) assert rect.area == 100 assert rect.intersection(test) == 25 assert rect.iou(test) == 25 / 100.0 def test_r...
normal
{ "blob_id": "b65d25198d55ab4a859b9718b7b225fa92c13a2b", "index": 1202, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_rect():\n rect = Rectangle([[0, 0], [10, 10]], confidence=0.8, labels=[{'name':\n 'test'}])\n test = Rectangle([[0, 0], [5, 5]])\n assert rect.area == 100\n ...
[ 0, 1, 2, 3, 4 ]
import hashlib from django.conf import settings from django.core import mail from django.core.mail import EmailMultiAlternatives from django.template.loader import render_to_string from django.utils.crypto import get_random_string def hexdigest_sha256(*args): r = hashlib.sha256() for arg in args: r....
normal
{ "blob_id": "a35004e2b306ba1a8649ce66a1612f63a2b6bf39", "index": 2673, "step-1": "<mask token>\n\n\ndef hexdigest_sha256(*args):\n r = hashlib.sha256()\n for arg in args:\n r.update(str(arg).encode('utf-8'))\n return r.hexdigest()\n\n\n<mask token>\n\n\ndef notify_by_email(template, data, subject...
[ 2, 3, 4, 5, 6 ]
import os os.environ.setdefault('DJANGO_SETTINGS_MODULE','mkrandom.settings') import django django.setup() from main.models import Character, Vehicle, Tire, Glider char_names = [ 'Mario', 'Luigi', 'Peach', 'Daisy', 'Rosalina', 'Mario Tanooki', 'Peach cat', 'Yoshi', 'Yoshi (LBlue)', ...
normal
{ "blob_id": "dbda5df7dff3f8acc320ffe7b9c7c279ebed2cc2", "index": 7108, "step-1": "<mask token>\n", "step-2": "<mask token>\nos.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mkrandom.settings')\n<mask token>\ndjango.setup()\n<mask token>\nfor char in char_names:\n index = x - y + 1\n name = char_names[x]\...
[ 0, 1, 2, 3, 4 ]
''' REFERENCE a table with a FOREIGN KEY In your database, you want the professors table to reference the universities table. You can do that by specifying a column in professors table that references a column in the universities table. As just shown in the video, the syntax for that looks like this: ALTER TABLE a A...
normal
{ "blob_id": "deaa458e51a7a53dd954d772f9e3b1734508cf28", "index": 6770, "step-1": "'''\nREFERENCE a table with a FOREIGN KEY\n\nIn your database, you want the professors table to reference the universities table. You can do that by specifying a column in professors table that references a column in the universiti...
[ 0 ]
import tensorflow as tf import numpy as np import math import sys import os import numpy as np BASE_DIR = os.path.dirname(os.path.abspath(__file__)) sys.path.append(BASE_DIR) sys.path.append(os.path.join(BASE_DIR, '../utils')) import tf_util # from transform_nets import input_transform_net, feature_transform_net import...
normal
{ "blob_id": "e4a0f26afe8c78e4abbd85834c96ed5ba84e1f0b", "index": 3894, "step-1": "<mask token>\n\n\nclass Network:\n\n def placeholder_inputs(self, batch_size, num_point):\n source_pointclouds_pl = tf.placeholder(tf.float32, shape=(\n batch_size, num_point, 3))\n return source_pointcl...
[ 4, 6, 7, 8, 9 ]
import random from PyQt4.QtGui import ( QWidget, QHBoxLayout, QPushButton, QMainWindow, QIcon, QAction, QShortcut, QKeySequence, QFileDialog, QMessageBox) from PyQt4 import QtCore class Controls(QWidget): def __init__(self, parent): super(Controls, self).__init__(parent) ...
normal
{ "blob_id": "4e86dd74374297c3b0ce8fea93910003dac7d5d7", "index": 8742, "step-1": "<mask token>\n\n\nclass MainWindow(QMainWindow):\n playSong = QtCore.pyqtSignal(str)\n\n def __init__(self, music_dir):\n super(MainWindow, self).__init__()\n self.__music_dir = music_dir\n self.resize(40...
[ 4, 5, 6, 7, 8 ]
from typing import Any from electionguard.ballot import CiphertextAcceptedBallot from electionguard.decryption import compute_decryption_share_for_ballot from electionguard.election import CiphertextElectionContext from electionguard.scheduler import Scheduler from electionguard.serializable import write_json_object fr...
normal
{ "blob_id": "0544c67cb14549e32b6ff8ea3215c6c65c8416ec", "index": 5542, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@router.post('/decrypt-shares', tags=[TALLY])\ndef decrypt_ballot_shares(request: DecryptBallotSharesRequest=Body(...),\n scheduler: Scheduler=Depends(get_scheduler)) ->Any:\n \...
[ 0, 1, 2, 3, 4 ]
import socket from time import time, sleep from threading import Thread # Define drone class dm107s(): # Default control value def __init__(self): # 4 values for flight self.roll = 128 self.pitch = 128 self.throttle = 128 self.yaw = 128 # 0 - normal mode, 2 - eme...
normal
{ "blob_id": "ee8e117db0348aa37d6aa37e6c06255101f1cff4", "index": 2752, "step-1": "<mask token>\n\n\nclass dm107s:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def incremt(self, rl, pt, th, yw):\n self._value_to_change ...
[ 23, 29, 33, 39, 43 ]
from django.views.generic import ListView class ExperimentList(ListView): pass
normal
{ "blob_id": "10990282c8aa0b9b26a69e451132ff37257acbc6", "index": 3331, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ExperimentList(ListView):\n pass\n", "step-3": "from django.views.generic import ListView\n\n\nclass ExperimentList(ListView):\n pass\n", "step-4": null, "step-5": n...
[ 0, 1, 2 ]
# Copyright 2020 Huawei Technologies Co., Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to...
normal
{ "blob_id": "eb50f50e3c072c2f6e74ff9ef8c2fa2eef782aae", "index": 6718, "step-1": "<mask token>\n\n\ndef adj_to_bias(adj):\n \"\"\"Add self loop to adj and make sure only one hop neighbors are engaged in computing\"\"\"\n num_graphs = adj.shape[0]\n adj_temp = np.empty(adj.shape)\n for i in range(num_...
[ 2, 3, 4, 5, 6 ]
from django import forms from .models import GetInTouch class GetInTouchForm(forms.ModelForm): class Meta: model = GetInTouch fields = '__all__'
normal
{ "blob_id": "c8dc143c09aa7f677167a4942ae1c4a0fbf75128", "index": 3219, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass GetInTouchForm(forms.ModelForm):\n\n\n class Meta:\n model = GetInTouch\n fields = '__all__'\n", "step-3": "from django import forms\nfrom .models import GetI...
[ 0, 1, 2 ]
import kubernetes.client from kubernetes.client.rest import ApiException from pprint import pprint from kubeops_api.models.cluster import Cluster class ClusterMonitor(): def __init__(self,cluster): self.cluster = cluster self.token = self.cluster.get_cluster_token() self.cluster.change_to(...
normal
{ "blob_id": "da41f26489c477e0df9735606457bd4ee4e5a396", "index": 4465, "step-1": "<mask token>\n\n\nclass ClusterMonitor:\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass ClusterMonitor:\n\n def __init__(self, cluster):\n self.cluster = cluster\n self.token = self.clu...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 import os import subprocess import logging class color: PURPLE = '\033[95m' CYAN = '\033[96m' DARKCYAN = '\033[36m' BLUE = '\033[94m' GREEN = '\033[92m' YELLOW = '\033[93m' RED = '\033[91m' BOLD = '\033[1m' UNDERLINE = '\033[4m' END = '\033[0m' # Recov...
normal
{ "blob_id": "2c834c734de8f8740176bb5dbb6b123c49924718", "index": 1697, "step-1": "<mask token>\n\n\nclass color:\n PURPLE = '\\x1b[95m'\n CYAN = '\\x1b[96m'\n DARKCYAN = '\\x1b[36m'\n BLUE = '\\x1b[94m'\n GREEN = '\\x1b[92m'\n YELLOW = '\\x1b[93m'\n RED = '\\x1b[91m'\n BOLD = '\\x1b[1m'\n...
[ 5, 7, 9, 10, 12 ]
#!/usr/bin/env python # -*- coding: utf-8 -* #Perso from signalManipulation import * from manipulateData import * #Module import pickle from sklearn import svm, grid_search from sklearn.linear_model import ElasticNetCV, ElasticNet, RidgeClassifier from sklearn.metrics import confusion_matrix, f1_score, accuracy_score...
normal
{ "blob_id": "d8e8ecbf77828e875082abf8dcbfbc2c29564e20", "index": 4892, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*\n#Perso\nfrom signalManipulation import *\nfrom manipulateData import *\n\n#Module\nimport pickle\n\nfrom sklearn import svm, grid_search\nfrom sklearn.linear_model import ElasticNetCV,...
[ 0 ]
# -*- coding: utf-8 -*- """ Created on Mon May 27 17:38:50 2019 @author: User """ import numpy as np import pandas as pd dataset = pd.read_csv('University_data.csv') print(dataset.info()) features = dataset.iloc[:, :-1].values labels = dataset.iloc[:, -1:].values from sklearn.preprocessing import LabelEncoder la...
normal
{ "blob_id": "94e8f0532da76c803b23fe2217b07dc8cf285710", "index": 950, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(dataset.info())\n<mask token>\nregressor.fit(features, labels)\n<mask token>\nregressor.predict(x)\n", "step-3": "<mask token>\ndataset = pd.read_csv('University_data.csv')\nprint(...
[ 0, 1, 2, 3, 4 ]
#proper clarification for requirement is required import boto3 s3_resource = boto3.resource('s3') s3_resource.create_bucket(Bucket=YOUR_BUCKET_NAME, CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'}) s3_resource.Bucket(first_bucket_name).upload_file(Filename=first_file_name, Key=first_file_name) s3_resource...
normal
{ "blob_id": "44097da54a0bb03ac14196712111a1489a956689", "index": 5387, "step-1": "<mask token>\n", "step-2": "<mask token>\ns3_resource.create_bucket(Bucket=YOUR_BUCKET_NAME,\n CreateBucketConfiguration={'LocationConstraint': 'eu-west-1'})\ns3_resource.Bucket(first_bucket_name).upload_file(Filename=first_fi...
[ 0, 1, 2, 3, 4 ]
from flask import Flask from threading import Timer from crypto_crawler.const import BITCOIN_CRAWLING_PERIOD_SEC, COIN_MARKET_CAP_URL from crypto_crawler.crawler import get_web_content, filter_invalid_records app = Flask(__name__) crawl_enabled = True def crawl_bitcoin_price(): print("start crawling!") bitc...
normal
{ "blob_id": "ebbc6f9115e6b4ca7d1050a59cf175d123b6f3aa", "index": 4871, "step-1": "<mask token>\n\n\ndef crawl_bitcoin_price():\n print('start crawling!')\n bitcoin_prices = get_web_content(COIN_MARKET_CAP_URL)\n bitcoin_prices = filter_invalid_records(bitcoin_prices)\n if crawl_enabled:\n Time...
[ 3, 4, 5, 6, 8 ]
from flask import Flask, render_template, request, redirect, flash, session from mysqlconnection import connectToMySQL from flask_bcrypt import Bcrypt import re app = Flask(__name__) bcrypt = Bcrypt(app) app.secret_key = "something secret10" DATABASE = "exam_quote_dash" EMAIL_REGEX = re.compile(r'^[a-zA-Z0-9.+_-]+@[a-...
normal
{ "blob_id": "e732fa0e2b377a87b8b088303b277cc08cb695b3", "index": 5279, "step-1": "<mask token>\n\n\n@app.route('/')\ndef signin():\n return render_template('index.html')\n\n\n<mask token>\n\n\n@app.route('/login', methods=['POST'])\ndef login():\n mysql = connectToMySQL(DATABASE)\n query = 'SELECT * FRO...
[ 9, 10, 12, 13, 15 ]
from classifier import classifier from get_input_args import get_input_args from os import listdir #!/usr/bin/env python3 # -*- coding: utf-8 -*- # */AIPND-revision/intropyproject-classify-pet-images/calculates_results_stats_hints.py # # PRO...
normal
{ "blob_id": "f96c9753f3cbb0e554f9f05591e23943009c8955", "index": 2371, "step-1": "<mask token>\n\n\ndef calculates_results_stats(results_dic):\n \"\"\"\n Calculates statistics of the results of the program run using classifier's model \n architecture to classifying pet images. Then puts the results stat...
[ 3, 4, 7, 8, 9 ]
# Should print 516 def final_frequency(): frequency = 0 with open('input') as f: for line in f: frequency += int(line) return frequency print(final_frequency())
normal
{ "blob_id": "4d68b663933070cb287689b70d6ded07958cef22", "index": 3047, "step-1": "<mask token>\n", "step-2": "def final_frequency():\n frequency = 0\n with open('input') as f:\n for line in f:\n frequency += int(line)\n return frequency\n\n\n<mask token>\n", "step-3": "def final_fr...
[ 0, 1, 2, 3 ]
#!/usr/bin/python # coding=utf-8 import re str1 = 'http://www.chinapesticide.org.cn/myquery/querydetail?pdno=' str2 = '&pdrgno=' f = open('aaa.txt', 'r') source = f.read() rr = re.compile(r'open[(\'](.*)[\']') s=rr.findall(source) for line in s: temps = line.split(',') a = temps[0] b = temps[1] print ...
normal
{ "blob_id": "387c48fcf00480a820fb407f5bad1d9f41b28e7a", "index": 9160, "step-1": "#!/usr/bin/python\n# coding=utf-8\n\nimport re\n\nstr1 = 'http://www.chinapesticide.org.cn/myquery/querydetail?pdno='\nstr2 = '&pdrgno='\nf = open('aaa.txt', 'r')\nsource = f.read()\nrr = re.compile(r'open[(\\'](.*)[\\']')\ns=rr.fi...
[ 0 ]
#!/usr/bin/python # -*- coding: utf-8 -*- import pandas as pd import numpy as np import datetime import time from sys import exit from matplotlib import colors, pyplot as plt from functools import reduce import matplotlib.cm as cm import seaborn as sns from astropy.io import ascii, fits from astropy.wcs import wcs fr...
normal
{ "blob_id": "736fee6f9a46b8568b2dd217b81d54d689306630", "index": 970, "step-1": "<mask token>\n\n\nclass bcolors:\n HEADER = '\\x1b[95m'\n OKBLUE = '\\x1b[94m'\n OKGREEN = '\\x1b[92m'\n WARNING = '\\x1b[93m'\n FAIL = '\\x1b[91m'\n ENDC = '\\x1b[0m'\n BOLD = '\\x1b[1m'\n UNDERLINE = '\\x1b...
[ 3, 4, 5, 6, 7 ]
import scipy.io as sio import glob import numpy as np import matplotlib.pyplot as plt import math import os,sys BIN = os.path.expanduser("../tools/") sys.path.append(BIN) import myfilemanager as mfm import mystyle as ms import propsort as ps from functools import partial from scipy.ndimage import gaussian_filter1d ...
normal
{ "blob_id": "a4f56b1f93f62d80707367eaba0bba7ef4b2caca", "index": 4749, "step-1": "import scipy.io as sio\nimport glob\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport math\n\nimport os,sys\nBIN = os.path.expanduser(\"../tools/\")\nsys.path.append(BIN)\nimport myfilemanager as mfm\nimport mystyle as m...
[ 0 ]
# Generated by Django 3.1.6 on 2021-02-05 00:27 import django.core.validators from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('main_app', '0001_initial'), ] operations = [ migrations.AlterField( model_name='tea', ...
normal
{ "blob_id": "db920f4aadfb53bb26c5ba1fb182f12b95e14a2f", "index": 7899, "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 = [('main_app', ...
[ 0, 1, 2, 3, 4 ]
import numpy as np from sklearn.decomposition import PCA from sklearn.discriminant_analysis import LinearDiscriminantAnalysis from preprocessing import * from utils import * def find_optimal_param(lda, x_train, y_train): probs_train = lda.predict_proba(x_train)[:, 1] y_train = [x for _,x in sorted(zip(prob...
normal
{ "blob_id": "784b51c05dc7b5e70016634e2664c9ec25b8a65a", "index": 6506, "step-1": "<mask token>\n\n\nclass FDA_node(object):\n <mask token>\n\n def grow(self):\n self.right = FDA_node()\n self.left = FDA_node()\n\n def find_optimal_param(self, x, y):\n self.m = self.method.find_optim...
[ 5, 6, 9, 11, 12 ]
from datetime import datetime from django.core import mail from entity_event import context_loader from entity_emailer.models import Email from entity_emailer.utils import get_medium, get_from_email_address, get_subscribed_email_addresses, \ create_email_message, extract_email_subject_from_html_content class E...
normal
{ "blob_id": "d1dc807ecc92d9108db2c9bd00ee9781e174a1aa", "index": 558, "step-1": "<mask token>\n\n\nclass EntityEmailerInterface(object):\n <mask token>\n <mask token>\n\n @staticmethod\n def convert_events_to_emails():\n \"\"\"\n Converts unseen events to emails and marks them as seen.\...
[ 2, 3, 4, 5, 6 ]
class Person: def __init__(self, fname, lname): self.fname = fname self.lname = lname def GetName(self): return (self.fname + ' ' + self.lname)
normal
{ "blob_id": "ff358136bc96fa7f3eb41d019ddfd10fc4db8f0d", "index": 5558, "step-1": "<mask token>\n", "step-2": "class Person:\n <mask token>\n <mask token>\n", "step-3": "class Person:\n <mask token>\n\n def GetName(self):\n return self.fname + ' ' + self.lname\n", "step-4": "class Person:...
[ 0, 1, 2, 3, 4 ]
'''a,b = input().split() a, b = [int(a),int(b)] List = set() ArrayA = list(map(int, input().split())) temp = 1 ArrayB = list(map(int, input().split())) for i in range(max(ArrayA), min(ArrayB)+1): for j in ArrayA: if i%j is 1: temp += 1 if temp is len(ArrayA): List.add(i) temp=1 ...
normal
{ "blob_id": "73d02615863826d77d65fbf0314dc71acb97ef28", "index": 4035, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor _ in range(numberOfObs):\n obs = input().split()\n obstacle.append((int(obs[0]), int(obs[1])))\n<mask token>\nwhile 1 <= q <= board and 1 <= r <= board:\n if (q, r) in obstac...
[ 0, 1, 2, 3, 4 ]
from bs4 import BeautifulSoup from bs4 import BeautifulSoup import requests,pymysql,random,time import http.cookiejar from multiprocessing import Pool,Lock def get_proxies_ip(): db = pymysql.connect("localhost","root","xxx","xxx",charset='utf8') cursor = db.cursor() sql = "SELECT * FROM proxies_info;" ...
normal
{ "blob_id": "d49aa03cd6b8ba94d68a1bc1e064f77fded65000", "index": 8870, "step-1": "<mask token>\n\n\ndef get_headers():\n USER_AGENTS = [\n 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)'\n ,\n 'Mozilla/4.0 (compatible; MSIE 7.0...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- import serial import time import argparse def write_command(serial, comm, verbose = False, dt = None): """ Encodes a command and sends it over the serial port """ if verbose and comm != "": if dt is None: print("{} \t\t-> {}".format(comm, serial.port...
normal
{ "blob_id": "3ffcab4b36c6ca05f1e667c628ebb873ebdc0d25", "index": 7866, "step-1": "<mask token>\n\n\ndef write_command(serial, comm, verbose=False, dt=None):\n \"\"\" Encodes a command and sends it over the serial port \"\"\"\n if verbose and comm != '':\n if dt is None:\n print('{} \\t\\t...
[ 4, 6, 7, 8, 9 ]
import pyodbc from configuration.config import Configuration from models.entities import Entities from models.columns import Columns from models.relationships import Relationship from models.synonyms import Synonyms from spacy.lemmatizer import Lemmatizer from spacy.lookups import Lookups class DBModel(object): ...
normal
{ "blob_id": "76ebab93441676f9f00b2c2d63435e72c2d5d1ba", "index": 9936, "step-1": "<mask token>\n\n\nclass DBModel(object):\n <mask token>\n <mask token>\n\n def get_matcher(self, matcher, nlp):\n for entity in self.entities:\n matcher.add(entity.name.upper() + '_TABLE', None, nlp(entit...
[ 2, 3, 4, 6, 7 ]