code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
from flask import Flask,Blueprint
from .views import login
from flask_session import Session
import redis
app = Flask(__name__,template_folder='templates',static_url_path='static')
app.debug = True
print('app.root_path===',app.root_path)
print('app.static_url_path===',app.static_url_path)
app.secret_key('uaremyhero... | normal | {
"blob_id": "9d2fdf47b5c4b56cc0177a9c0a86b1ed57c88d49",
"index": 4151,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('app.root_path===', app.root_path)\nprint('app.static_url_path===', app.static_url_path)\napp.secret_key('uaremyhero')\n<mask token>\nSession(app)\napp.register_blueprint(login.logi... | [
0,
1,
2,
3,
4
] |
# stopwatch.py - A simple stopwatch program.
import time
# Display the porgram's instructions
print(
""" \n\nInstructions\n
press Enter to begin.\n
Afterwards press Enter to "click" the stopwatch.\n
Press Ctrl-C to quit"""
)
input() # press Enter to begin
print("Started")
startTime = time.time()
lastTime = star... | normal | {
"blob_id": "cc87682d4ebb283e2d0ef7c09ad28ba708c904bd",
"index": 4407,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(\n \"\"\" \n\nInstructions\n\npress Enter to begin.\n\nAfterwards press Enter to \"click\" the stopwatch.\n\nPress Ctrl-C to quit\"\"\"\n )\ninput()\nprint('Started')\n<mask t... | [
0,
1,
2,
3,
4
] |
from p5 import *
import numpy as np
from numpy.random import default_rng
from boids import Boid
from data import Data
n=30;
width = 1920
height = 1080
flock=[]
infected=[]
rng = default_rng()
frames=0
for i in range(n):
x = rng.integers(low=0, high=1920)
y = rng.integers(low=0, high=1080)
if i==0:
... | normal | {
"blob_id": "78c4e14e5afdf857082b60bf4020f0f785d93a0d",
"index": 9704,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(n):\n x = rng.integers(low=0, high=1920)\n y = rng.integers(low=0, high=1080)\n if i == 0:\n flock.append(Boid(x, y, width, height, infected=True, curado=Fa... | [
0,
3,
4,
5,
6
] |
import numpy as np
import sys
import os
import cv2
if __name__ == "__main__":
# print(sys.argv[1])
# img = cv2.imread(sys.argv[1], 0)
# cv2.imshow('img', img)
# cv2.waitKey(0)
img = np.array([[1, 2], [1, 3], [1, 4]])
print(img.tolist())
sys.stdout.flush()
| normal | {
"blob_id": "54833c19d68bb7a1817639ef761367ce75a3a46f",
"index": 9200,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n img = np.array([[1, 2], [1, 3], [1, 4]])\n print(img.tolist())\n sys.stdout.flush()\n",
"step-3": "import numpy as np\nimport sys\nimport os\nimpor... | [
0,
1,
2,
3
] |
#!/usr/bin/python
# coding=UTF-8
import sys
import subprocess
import os
def printReportTail(reportHtmlFile):
reportHtmlFile.write("""
</body>
</html>
""")
def printReportHead(reportHtmlFile):
reportHtmlFile.write("""<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" ... | normal | {
"blob_id": "b5cbb73c152dd60e9063d5a19f6182e2264fec6d",
"index": 15,
"step-1": "#!/usr/bin/python\n# coding=UTF-8\n\nimport sys\nimport subprocess\nimport os\n\ndef printReportTail(reportHtmlFile):\n reportHtmlFile.write(\"\"\"\n</body>\n</html>\n\"\"\")\n\ndef printReportHead(reportHtmlFile):\n reportHtml... | [
0
] |
import numpy as np
from numpy import random
from sklearn.preprocessing import StandardScaler
from sklearn.cross_validation import train_test_split
from numpy.random import shuffle
import matplotlib.pyplot as plt
import numpy.linalg as la
import sklearn.preprocessing as proc
import csv
def get_accuracy(a, b, X_test, y_... | normal | {
"blob_id": "f5c4057babc873099ae2a4d8c1aca960ab9fa30a",
"index": 9692,
"step-1": "<mask token>\n\n\ndef get_accuracy(a, b, X_test, y_test):\n size = len(y_test)\n count = 0\n for i in range(size):\n x = X_test[i]\n real = y_test[i]\n x = np.array(x)\n x = x.reshape(1, 6)\n ... | [
1,
2,
3,
4,
5
] |
a = [1, 11, 21, 1211, 111221]
for i in range(30):
#next_num_list = []
next_num = ''
next_char = ''
step = 0
count = 0
# Analyze the string.
for char in str(a[i+4]):
if step == 0:
next_char = char
count += 1
step = 1
elif step == 1:
... | normal | {
"blob_id": "3cb3361e8777d31575d81d2a1191f137e4174492",
"index": 8224,
"step-1": "a = [1, 11, 21, 1211, 111221]\n\nfor i in range(30):\n\n #next_num_list = []\n next_num = ''\n\n next_char = ''\n\n step = 0\n count = 0\n\n # Analyze the string.\n for char in str(a[i+4]):\n if step == ... | [
0
] |
from functools import wraps
import os
def restoring_chdir(fn):
#XXX:dc: This would be better off in a neutral module
@wraps(fn)
def decorator(*args, **kw):
try:
path = os.getcwd()
return fn(*args, **kw)
finally:
os.chdir(path)
return decorator
clas... | normal | {
"blob_id": "3fbf1768a2fe78df591c49490dfce5fb374e7fc2",
"index": 4,
"step-1": "from functools import wraps\nimport os\n\n\ndef restoring_chdir(fn):\n #XXX:dc: This would be better off in a neutral module\n @wraps(fn)\n def decorator(*args, **kw):\n try:\n path = os.getcwd()\n ... | [
0
] |
def TongTien(m1,m2,s):
if s <=100:
tong = m1 * s
else:
tong = m1 * 100 + m2 * (s-100)
print tong
m1 = float(raw_input("nhap gia m1 :"))
m2 = float(raw_input("nhap gia m2 :"))
s = int (raw_input("nhap so dien da dung :"))
TongTien(m1,m2,s) | normal | {
"blob_id": "1de8c129769827c7fe763ce221cb9fdf8226e473",
"index": 114,
"step-1": "def TongTien(m1,m2,s):\n\n\tif s <=100:\n\t\ttong = m1 * s\n\telse:\n\t\ttong = m1 * 100 + m2 * (s-100)\n\n\n\tprint tong\n\n\nm1 = float(raw_input(\"nhap gia m1 :\"))\n\nm2 = float(raw_input(\"nhap gia m2 :\"))\n\ns = int (raw_inp... | [
0
] |
import tensorflow as tf
from vgg16 import vgg16
def content_loss(content_layer, generated_layer):
# sess.run(vgg_net.image.assign(generated_image))
# now we define the loss as the difference between the reference activations and
# the generated image activations in the specified layer
# return 1/2 * ... | normal | {
"blob_id": "f92b939bf9813e5c78bc450ff270d5fb6171792a",
"index": 4810,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef content_loss(content_layer, generated_layer):\n return tf.scalar_mul(0.5, tf.nn.l2_loss(content_layer - generated_layer))\n\n\n<mask token>\n\n\ndef get_gram_matrix(matrix, num... | [
0,
2,
3,
4,
5
] |
from .test_function import *
from .support_funcs import *
table_DIXMAAN = dict()
table_DIXMAAN['A'] = (1, 0, 0.125, 0.125, 0, 0, 0, 0)
table_DIXMAAN['B'] = (1, 0.0625, 0.0625, 0.0625, 0, 0, 0, 1)
table_DIXMAAN['C'] = (1, 0.125, 0.125, 0.125, 0, 0, 0, 0)
table_DIXMAAN['D'] = (1, 0.26, 0.26, 0.26, 0, 0, 0, 0)
table_DIXM... | normal | {
"blob_id": "7026f4549019c25cb736af556fe46fd360fba46f",
"index": 2238,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef DIXMAAN(type):\n\n def DIXMAAN_(n):\n name = 'DIXMAAN%c function (CUTE)' % type\n alpha, beta, gamma, sigma, k1, k2, k3, k4 = table_DIXMAAN[type]\n m = n /... | [
0,
1,
2,
3,
4
] |
from zeus import auth, factories
from zeus.constants import Result, Status
from zeus.models import FailureReason
from zeus.tasks import aggregate_build_stats_for_job
def test_unfinished_job(mocker, db_session, default_source):
auth.set_current_tenant(auth.Tenant(repository_ids=[default_source.
repository_... | normal | {
"blob_id": "71b78b1347456420c3fc29605887d20ba5bff06e",
"index": 4313,
"step-1": "<mask token>\n\n\ndef test_unfinished_job(mocker, db_session, default_source):\n auth.set_current_tenant(auth.Tenant(repository_ids=[default_source.\n repository_id]))\n build = factories.BuildFactory(source=default_so... | [
1,
2,
3,
4
] |
import os,sys,glob
sys.path.append("../../../../libs/VASNet/")
from VASNet_frame_scoring_lib import *
sys.path.append("../../../config")
from config import *
if __name__ == '__main__':
#************************************************************************
# Purpose: frame scoring (Summarizing Videos with A... | normal | {
"blob_id": "ce97da4aab2b9de40267730168690475c899526d",
"index": 3924,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.append('../../../../libs/VASNet/')\n<mask token>\nsys.path.append('../../../config')\n<mask token>\nif __name__ == '__main__':\n path_pretrained_model = cfg.PATH_DRDSN_PRETRAI... | [
0,
1,
2,
3
] |
from PyQt5.QtCore import QObject, pyqtSlot
from Controllers.BookController import BookController
from Model.BookModel import BookModel
from Controllers.DatabaseController import DatabaseController
#Issuance Controller class contains the issuance properties and performs database operations for the issuance
class Issuan... | normal | {
"blob_id": "1d4df09256324cce50fad096cdeff289af229728",
"index": 3132,
"step-1": "<mask token>\n\n\nclass IssuanceController(QObject):\n\n def __init__(self, model):\n super().__init__()\n self._database_controller = DatabaseController()\n self._model = model\n <mask token>\n\n @pyq... | [
8,
9,
12,
13,
14
] |
import gym
from ddpg import DDPG
def main():
#env = gym.make('LunarLanderContinuous-v2')
#log_dir = 'log/lander'
env = gym.make('Pendulum-v0')
log_dir = 'log/pendulum'
# paper settings
# agent = DDPG(env, sigma=0.2, num_episodes=1000, buffer_size=1000000, batch_size=64,
# ... | normal | {
"blob_id": "153e7e66e2b796d011b78aed102d30e37bb0b80f",
"index": 1374,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n env = gym.make('Pendulum-v0')\n log_dir = 'log/pendulum'\n agent = DDPG(env, sigma=0.2, num_episodes=250, buffer_size=1000000,\n batch_size=64, tau=0.001... | [
0,
1,
2,
3,
4
] |
from sklearn.model_selection import train_test_split
from sklearn.metrics import silhouette_samples, silhouette_score
from sklearn.metrics.cluster import homogeneity_score, completeness_score, v_measure_score
from sklearn import datasets
from random import shuffle
import os
import matplotlib
matplotlib.use('Agg')
imp... | normal | {
"blob_id": "fe63d9b0939bc91d2da14e4d966b33575eab5394",
"index": 2531,
"step-1": "<mask token>\n\n\ndef v_measure(cluster_labels, true_labels):\n h_score = homogeneity_score(true_labels, cluster_labels)\n c_score = completeness_score(true_labels, cluster_labels)\n v_score = v_measure_score(true_labels, ... | [
8,
10,
12,
13,
14
] |
from pickle import dump, load
def save(parameters):
# Функция сохранения прогресса в файл
with open('saves/save.zs', 'wb') as game_save:
dump(parameters, game_save)
game_save.close()
def load_settings():
# Функция загрузки сохранения при выборе опции продолжения игры
try:... | normal | {
"blob_id": "9d27b8844ab4070bb53afd89620177b89013956e",
"index": 4164,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef save(parameters):\n with open('saves/save.zs', 'wb') as game_save:\n dump(parameters, game_save)\n game_save.close()\n\n\n<mask token>\n",
"step-3": "<mask toke... | [
0,
1,
2,
3,
4
] |
from django.views import generic
from .models import GPS
# This is the view for my home page. It is a list view because it needs to display a list of all
# of the GPS units that are currently in the database.
class HomeView(generic.ListView):
model = GPS
template_name = 'inv_templates/home.html'
context_obj... | normal | {
"blob_id": "67db3a66e5525d41de13df665167a0db2d81056e",
"index": 2721,
"step-1": "<mask token>\n\n\nclass Remove_ItemView(generic.ListView):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Update_ItemView(generic.ListView):\n model = GPS\n template_name = 'inv_templates/update_item.html'\n... | [
7,
11,
12,
13,
14
] |
import Numberjack as Nj
class Teachers(object):
"""Will be expanded to allow constraints for individual teachers"""
def __init__(self):
self.store = list()
def add(self, teachers):
if isinstance(teachers, (list, tuple)):
self.store.extend(teachers)
elif isinstance(teac... | normal | {
"blob_id": "8787126e654808a5fec52283780d9b4f668fa50f",
"index": 8593,
"step-1": "<mask token>\n\n\nclass Subjects(object):\n\n def __init__(self):\n self.store = list()\n\n def add(self, subjects):\n if isinstance(subjects, (list, tuple)):\n self.store.extend(subjects)\n el... | [
9,
10,
12,
13,
15
] |
from email import encoders
from email.header import Header
from email.mime.text import MIMEText
from email.utils import parseaddr, formataddr
import smtplib
def _format_addr(s):
name, addr = parseaddr(s)
return formataddr((Header(name, 'UTF-8').encode(), addr))
from_addr = 'gaofeng4280@163.com'
to_addr = '1... | normal | {
"blob_id": "4dd71d01e499f3d0ee49d3bf5204fb3bbb03ede5",
"index": 2976,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef _format_addr(s):\n name, addr = parseaddr(s)\n return formataddr((Header(name, 'UTF-8').encode(), addr))\n\n\n<mask token>\nserver.set_debuglevel(1)\nserver.login()\nserver.... | [
0,
2,
3,
4
] |
import os, sys
from scrapy.cmdline import execute
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
execute('scrapy crawl laptop'.split())
| normal | {
"blob_id": "71ff8e8a62a3b2731071ed7a039b51c150ebaca4",
"index": 3671,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.append(os.path.dirname(os.path.abspath(__file__)))\nexecute('scrapy crawl laptop'.split())\n",
"step-3": "import os, sys\nfrom scrapy.cmdline import execute\nsys.path.append(os... | [
0,
1,
2
] |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""""""""""""""""""""""""""""""""""""""""""""""
" Filename: time.py
"
" Author: xss - callmexss@126.com
" Description: Show local time
" Create: 2018-07-02 20:20:17
"""""""""""""""""""""""""""""""""""""""""""""""
from datetime import datetime
print('''\... | normal | {
"blob_id": "e8eac1e4433eee769d317de9ba81d5181168fdca",
"index": 6293,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(\n \"\"\" <html>\n <body>\n <p>Generated {0}</p>\n </body>\n </html>\"\"\"\n .format(datetime.now()))\n",
"step-3": "<mask token>\nfrom da... | [
0,
1,
2,
3
] |
#!/usr/bin/python
#MTU Server
from config import *
from pymodbus.client.sync import ModbusTcpClient
import time
import numpy as np
import logging
from sklearn.decomposition import PCA
import matplotlib.pyplot as plt
import matplotlib.animation as anim
logging.basicConfig()
log = logging.getLogger()
log.setLevel(loggin... | normal | {
"blob_id": "572a9da5edcff3ff5ca0a37f982432f9712dc58c",
"index": 9279,
"step-1": "#!/usr/bin/python\n#MTU Server\nfrom config import *\nfrom pymodbus.client.sync import ModbusTcpClient\nimport time\nimport numpy as np\nimport logging\nfrom sklearn.decomposition import PCA\nimport matplotlib.pyplot as plt\nimport... | [
0
] |
"""
All rights reserved to cnvrg.io
http://www.cnvrg.io
cnvrg.io - Projects Example
last update: Nov 07, 2019.
-------------
rnn.py
==============================================================================
"""
import argparse
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow i... | normal | {
"blob_id": "fbac2d66f4d69a52c3df5d665b622659e4d8dacd",
"index": 5733,
"step-1": "<mask token>\n\n\ndef cast_types(args):\n args.epochs = int(args.epochs)\n args.batch_size = int(args.batch_size)\n args.input_shape = args.input_shape.split(' ')\n for num in args.input_shape:\n if num != '':\n ... | [
2,
3,
4,
5,
6
] |
import sys
import os
def my_add(a, b):
return a + b
| normal | {
"blob_id": "cc81e13bba0ea0186966bce7f5aac05bb106e971",
"index": 5935,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef my_add(a, b):\n return a + b\n",
"step-3": "import sys\nimport os\n\n\ndef my_add(a, b):\n return a + b\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
... | [
0,
1,
2
] |
from django.shortcuts import render
from django.http import HttpResponseRedirect
from .forms import PostForm
from django.contrib.auth.decorators import login_required
from django.shortcuts import get_object_or_404
from .models import Post
from django.contrib import messages
# Create your views here.
@login_required
def... | normal | {
"blob_id": "4a2437d3d6ba549910bc30a67bf391b9bbafd25f",
"index": 6210,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@login_required\ndef post_create(request):\n \"\"\"\n\t\tThis makes sure that the form accpets a POST requests (of some data) or Nothing.\n\t\tWithout this the form would even acce... | [
0,
1,
2,
3,
4
] |
IMAGE_SIZE=(640, 480)
| normal | {
"blob_id": "af80cb4d4ce5c071efc39e85f89bb412cff6bf6e",
"index": 4489,
"step-1": "<mask token>\n",
"step-2": "IMAGE_SIZE = 640, 480\n",
"step-3": "IMAGE_SIZE=(640, 480)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
Album,artist,year,songs="More Mayhem","Imelda May",2001,((1,"pulling the rug"),(2,"psycho"),(3,"mayhem"),(4,"kentisch town waltz"))
for song in songs:
track,title=song
print(" track number {}\t, title {}".format(track,title)) | normal | {
"blob_id": "30f02b956af68960804f0cb57695bdbf8510bc43",
"index": 7290,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor song in songs:\n track, title = song\n print(' track number {}\\t, title {}'.format(track, title))\n",
"step-3": "Album, artist, year, songs = 'More Mayhem', 'Imelda May', 200... | [
0,
1,
2,
3
] |
"""Resolwe collection serializer."""
import logging
from rest_framework import serializers
from resolwe.flow.models import Collection, Data, DescriptorSchema
from resolwe.rest.fields import ProjectableJSONField
from .base import ResolweBaseSerializer
from .descriptor import DescriptorSchemaSerializer
from .fields im... | normal | {
"blob_id": "d6f8ec0fd8be0fa7019a84af47d08ab8b5b32d92",
"index": 1449,
"step-1": "<mask token>\n\n\nclass BaseCollectionSerializer(ResolweBaseSerializer):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def get_status(self, coll... | [
6,
8,
9,
11,
12
] |
import numpy as np
import math
import matplotlib.pyplot as plt
def signif_conf(ts, p):
''' Given a timeseries (ts), and desired probability (p),
compute the standard deviation of ts (s) and use the
number of points in the ts (N), and the degrees of freedom (DOF)
to calculate chi. '''
s = np.std(ts... | normal | {
"blob_id": "84a4a0a16aea08ee874b09de163fd777be925f18",
"index": 3041,
"step-1": "import numpy as np\nimport math\nimport matplotlib.pyplot as plt\n\n\ndef signif_conf(ts, p):\n ''' Given a timeseries (ts), and desired probability (p),\n compute the standard deviation of ts (s) and use the\n number of p... | [
0
] |
from django.contrib import admin
from get_my_tweets.models import username
admin.site.register(username)
| normal | {
"blob_id": "84ece5d1a9e38b83a5b60052fc3ab089c498d2fc",
"index": 9147,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nadmin.site.register(username)\n",
"step-3": "from django.contrib import admin\nfrom get_my_tweets.models import username\nadmin.site.register(username)\n",
"step-4": null,
"step-5":... | [
0,
1,
2
] |
"""
*** Three Number Sum ***
Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum. The function
should find all triplets. The numbers in each triplet should be ordered in ascending order, and the triplets themeselves
should be ordered in ascending order with re... | normal | {
"blob_id": "240f5e9cbb38f319b6e03b1b7f9cae7655ac4385",
"index": 5258,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef threeNumberSum(array, targetSum):\n array.sort()\n triplet = []\n for i in range(len(array) - 2):\n left = i + 1\n right = len(array) - 1\n while lef... | [
0,
1,
2,
3,
4
] |
import collections
import numpy
import pytest
import random
import conftest
from svviz2.io import readstatistics
from svviz2.remap import genotyping
from svviz2.utility.intervals import Locus
def get_read_stats(isize=400):
stats = readstatistics.ReadStatistics(None)
stats.insertSizes = numpy.random.normal(400... | normal | {
"blob_id": "97a362fc65731bb8fc3743c49a669b4cd3f0e155",
"index": 9426,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_read_stats(isize=400):\n stats = readstatistics.ReadStatistics(None)\n stats.insertSizes = numpy.random.normal(400, 20, 2000).astype(int)\n stats.orientations = ['+-'... | [
0,
1,
2,
3,
4
] |
from pwn import *
hostname = "pwnable.kr"
portnum = 2222
username = "input2"
passwd = "guest"
def main():
args = ["./input"]
print("./input", end="")
for x in range(99):
print(" AA", end="")
args.append("AA")
print(args)
'''
s = ssh(host=hostname,
port=portnum,
... | normal | {
"blob_id": "9184779731d6102498934d77b6d3c0283fc594d9",
"index": 7498,
"step-1": "<mask token>\n\n\ndef main():\n args = ['./input']\n print('./input', end='')\n for x in range(99):\n print(' AA', end='')\n args.append('AA')\n print(args)\n\n\n<mask token>\n",
"step-2": "<mask token>\... | [
1,
2,
3,
4,
5
] |
# This Python file uses the following encoding: utf-8
import json
import os
import logging
from .utility_helper import (
check_path,
)
from .formats import (
OUTPUT_FORMATS,
FORMATS
)
class OptionsManager(object):
"""
This clas is responsible for storing & retrieving the options.
Args:
... | normal | {
"blob_id": "92529c4d4c33a7473773f081f730e64bae4d7f54",
"index": 5742,
"step-1": "<mask token>\n\n\nclass OptionsManager(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n logging.basicConfig(format=format, level=logging.INFO, datefmt='%H:%M:%S')\n logging.getLogger().setLev... | [
4,
6,
7,
9,
11
] |
# Generated by Django 2.2.1 on 2020-02-13 05:18
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app01', '0004_auto_20200213_1202'),
]
operations = [
migrations.DeleteModel(
name='Subject',
),
migrations.Renam... | normal | {
"blob_id": "9b7601a5230bfd2370e73a71d141d6de68ade50f",
"index": 8972,
"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 = [('app01', '00... | [
0,
1,
2,
3,
4
] |
from django.conf.urls.defaults import *
## reports view
urlpatterns = patterns('commtrack_reports.views',
(r'^commtrackreports$', 'reports'),
(r'^sampling_points$', 'sampling_points'),
(r'^commtrack_testers$', 'testers'),
(r'^date_range$', 'date_range'),
(r'^create_report$', 'create_report'),
(... | normal | {
"blob_id": "6d244b719200ae2a9c1a738e746e8c401f8ba4e2",
"index": 3342,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = patterns('commtrack_reports.views', ('^commtrackreports$',\n 'reports'), ('^sampling_points$', 'sampling_points'), (\n '^commtrack_testers$', 'testers'), ('^date_range... | [
0,
1,
2,
3
] |
import sqlite3
class DatabaseHands(object):
def __init__(self, database):
self.conn = sqlite3.connect(database)
self.cur = self.conn.cursor()
self.cur.execute("CREATE TABLE IF NOT EXISTS hands"
+ "(id INTEGER PRIMARY KEY, first INTEGER,"
+ ... | normal | {
"blob_id": "f8c85f34fb55ee1c3b3020bcec87b60ae80e4ed2",
"index": 3126,
"step-1": "<mask token>\n\n\nclass DatabaseHands(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass DatabaseProbability(object):\n\n def __init__(self, database):\n self.con... | [
13,
16,
17,
19,
20
] |
from springframework.web.servlet import ModelAndView
from springframework.web.servlet.HandlerAdapter import HandlerAdapter
from springframework.web.servlet.mvc.Controller import Controller
from springframework.web.servlet.mvc.LastModified import LastModified
from springframework.utils.mock.inst import (
HttpServlet... | normal | {
"blob_id": "71e7a209f928672dbf59054b120eed6a77522dde",
"index": 6246,
"step-1": "<mask token>\n\n\nclass SimpleControllerHandlerAdapter(HandlerAdapter):\n\n def supports(self, handler: object) ->bool:\n return isinstance(handler, Controller)\n <mask token>\n <mask token>\n",
"step-2": "<mask t... | [
2,
3,
4,
5,
6
] |
from __future__ import print_function
class StackQueue(object):
"""Queue implemented with two stacks"""
def __init__(self):
self.stack1 = []
self.stack2 = []
def enqueue(self, data):
self.stack1.append(data)
def dequeue(self):
if self.stack2:
return self.s... | normal | {
"blob_id": "24f6328d578b6145bf86d7b5378a081463936df3",
"index": 9670,
"step-1": "<mask token>\n\n\nclass StackQueue(object):\n <mask token>\n <mask token>\n\n def enqueue(self, data):\n self.stack1.append(data)\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n... | [
2,
6,
8,
9,
11
] |
"""
Copyright (c) 2018, salesforce.com, inc.
All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
Graph Search Policy Network.
"""
from typing import List, NamedTuple, Union
import torch
import tor... | normal | {
"blob_id": "4a892c3532a3e3ddcd54705336dce820ff49b91b",
"index": 6289,
"step-1": "<mask token>\n\n\nclass GraphWalkAgent(nn.Module):\n\n def __init__(self, args):\n super(GraphWalkAgent, self).__init__()\n self.model = args.model\n self.relation_only = args.relation_only\n self.his... | [
10,
13,
16,
18,
20
] |
# Write files
# Writing to a file within a Python program:
# In order to write to a file, we use file.write(str).
# This method writes a string to a file.
# The method write() works like Python's print() function, except it does not add a newline ("\n") character.
# File dialogs:
# Module tkinter has a submodule cal... | normal | {
"blob_id": "0372cdbae8c5b0bbcbade86a5a7de28c1ee513b1",
"index": 2486,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntkinter.filedialog.askopenfilename()\n<mask token>\nfrom_file.close()\n<mask token>\nto_file.write('Copy\\n')\nto_file.write(contents)\nto_file.close()\n",
"step-3": "<mask token>\ntkin... | [
0,
1,
2,
3,
4
] |
#Purpose: find the bonds, angles in Zr/GPTMS .xyz outpuf file from simulation
from Tkinter import Tk
from tkFileDialog import askopenfilename
Tk().withdraw()
from pylab import *
from scipy import *
from numpy import *
import numpy as np
import math
##################################################################... | normal | {
"blob_id": "82abed3a60829eeabf6b9e8b791085d130ec3dd4",
"index": 3086,
"step-1": "#Purpose: find the bonds, angles in Zr/GPTMS .xyz outpuf file from simulation \n\nfrom Tkinter import Tk\nfrom tkFileDialog import askopenfilename\nTk().withdraw()\n\nfrom pylab import *\nfrom scipy import *\nfrom numpy import *\ni... | [
0
] |
import sys
num = int(input())
odd_sum = 0
even_sum = 0
odd_smallest = sys.maxsize
even_smallest = sys.maxsize
odd_biggest = -sys.maxsize
even_biggest = -sys.maxsize
for i in range(0, num):
element = float(input())
if i % 2 != 0:
even_sum += element
if element <= even_smallest:
even_s... | normal | {
"blob_id": "69e8601a387d0987fbb6d1da5ac0f9412fffc63d",
"index": 8768,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(0, num):\n element = float(input())\n if i % 2 != 0:\n even_sum += element\n if element <= even_smallest:\n even_smallest = element\n ... | [
0,
1,
2,
3
] |
from graph import Graph
import ast
import itertools
def add_nodes(g):
nodes = ['a', 'b', 'c', 'd']
for n in nodes:
g.add_node(n)
def add_desc(g):
desc = [('b', 'a'), ('b', 'c'), ('d', 'c')]
for d in desc:
g.add_desc(d)
def add_edges(g):
edges = [('b', 'a'), ('b', 'c'), ('d', '... | normal | {
"blob_id": "8efee4ad16e938e85a500e5aebf5154b5708b277",
"index": 9287,
"step-1": "<mask token>\n\n\ndef add_nodes(g):\n nodes = ['a', 'b', 'c', 'd']\n for n in nodes:\n g.add_node(n)\n\n\ndef add_desc(g):\n desc = [('b', 'a'), ('b', 'c'), ('d', 'c')]\n for d in desc:\n g.add_desc(d)\n\n... | [
4,
6,
7,
8,
9
] |
from django.urls import path
from . import views
urlpatterns = [
path('product', views.ProductCreateAndList.as_view()),
path('product/<int:pk>', views.ProductRetrieve.as_view()),
]
| normal | {
"blob_id": "d21b89285d4b4c73a08bda746cea31b5a13d1050",
"index": 1967,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('product', views.ProductCreateAndList.as_view()), path(\n 'product/<int:pk>', views.ProductRetrieve.as_view())]\n",
"step-3": "from django.urls import path\nfrom ... | [
0,
1,
2,
3
] |
import json
import redis
redis_client = redis.StrictRedis(host="redis", port=6379, db=1, password="pAssw0rd")
def publish_data_on_redis(data, channel):
redis_client.publish(channel, json.dumps(data)) | normal | {
"blob_id": "d61024ecbd092852fc3396e6919d6d3c8aa554db",
"index": 6178,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef publish_data_on_redis(data, channel):\n redis_client.publish(channel, json.dumps(data))\n",
"step-3": "<mask token>\nredis_client = redis.StrictRedis(host='redis', port=6379,... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
"""
Default organizer for bioinfoinformatics project directiories - RNA-Seq based model
"""
import os
import sys
#main path
curr_path = os.getcwd()
print("\nYour current directory is: " + curr_path + "\n\nIt contains the following files and directories:\n\n" + str(os.listdir("."))) # displays... | normal | {
"blob_id": "0131657a7675904ee2743448f514a9f11e0dc0ad",
"index": 7561,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(\"\"\"\nYour current directory is: \"\"\" + curr_path +\n \"\"\"\n\nIt contains the following files and directories:\n\n\"\"\" + str(os.\n listdir('.')))\n<mask token>\nos.mkd... | [
0,
1,
2,
3,
4
] |
from application.processing_data.twitter import TwitterAPIv2
from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential
from .twitter import TwitterAPIv2
categories={
'Noise Complaints': {
'loud',
'party',
'noisy',
'noise',
'... | normal | {
"blob_id": "65aa761110877bd93c2d2cb3d097fa3e126f72b1",
"index": 1297,
"step-1": "from application.processing_data.twitter import TwitterAPIv2\nfrom azure.ai.textanalytics import TextAnalyticsClient\nfrom azure.core.credentials import AzureKeyCredential\nfrom .twitter import TwitterAPIv2\n\ncategories={\n 'No... | [
0
] |
import json
from week2.Stack import Stack
class TransactionStack:
def __init__(self):
self.stack = Stack()
with open("json_file/Transaction_Stack.json") as data:
try:
temp = json.load(data)
except Exception:
pass
else:
... | normal | {
"blob_id": "30a2358e8396d24d6c3cd72d04321aa9f9f83995",
"index": 8233,
"step-1": "<mask token>\n\n\nclass TransactionStack:\n <mask token>\n\n def transaction_stack(self, transaction, customer_name, company_name,\n no_of_share, cost, time):\n new_transaction = {'transaction': transaction, 'cu... | [
2,
4,
5,
6,
7
] |
def bullets(chunks):
print("bullets")
final_string = "Your list in latex can be created with the following command: \n"
final_string += "> \\begin{itemize} \n"
for e in chunks:
print(final_string)
final_string += f"> \item {e} \n"
final_string += "> \end{itemize}"
retur... | normal | {
"blob_id": "7a920b3609bb29cd26b159b48290fa6978839416",
"index": 7377,
"step-1": "<mask token>\n",
"step-2": "def bullets(chunks):\n print('bullets')\n final_string = (\n 'Your list in latex can be created with the following command: \\n')\n final_string += '> \\\\begin{itemize} \\n'\n for e... | [
0,
1,
2,
3,
4
] |
import time
from typing import List
from classiclikeiguana.timeout import timeout
class ExecutionMetrics:
def __init__(self, duration, succeeded: bool, timed_out: bool, lines: int, error: List[str] = None):
if error is None:
error = list()
self.duration = duration
self.succeed... | normal | {
"blob_id": "f870c776a62f3b743356c5515cd25e588dbfca15",
"index": 8183,
"step-1": "<mask token>\n\n\nclass ExecutionMetrics:\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass ExecutionMetrics:\n\n def __init__(self, duration, succeeded: bool, timed_out: bool, lines:... | [
1,
3,
4,
5,
6
] |
from graphviz import Digraph
dot = Digraph()
dot.edge("BaseException", "SystemExit")
dot.edge("BaseException", "KeyboardInterrupt")
dot.edge("BaseException", "GeneratorExit")
dot.edge("BaseException", "Exception")
dot.edge("Exception", "StopIteration")
dot.edge("Exception", "StopAsyncIteration")
dot.edge("Exception",... | normal | {
"blob_id": "a7db627c49b53cd3a073d866a0373336a46b4053",
"index": 1088,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndot.edge('BaseException', 'SystemExit')\ndot.edge('BaseException', 'KeyboardInterrupt')\ndot.edge('BaseException', 'GeneratorExit')\ndot.edge('BaseException', 'Exception')\ndot.edge('Exce... | [
0,
1,
2,
3,
4
] |
#!python3
import requests
import time
log_file = open("logfile.txt", "w")
def generateLog(ctime1, request_obj):
log_file.write(ctime1 + "\t")
log_file.write("Status code: " + str(request_obj.status_code))
log_file.write("\n")
def is_internet():
"""Internet function"""
print(time.... | normal | {
"blob_id": "f229f525c610d9925c9300ef22208f9926d6cb69",
"index": 9985,
"step-1": "<mask token>\n\n\ndef generateLog(ctime1, request_obj):\n log_file.write(ctime1 + '\\t')\n log_file.write('Status code: ' + str(request_obj.status_code))\n log_file.write('\\n')\n\n\ndef is_internet():\n \"\"\"Internet ... | [
2,
3,
4,
5,
6
] |
from datetime import date
from django.conf import settings
from django.utils.decorators import decorator_from_middleware_with_args
from django.views.decorators.cache import cache_page
from django.middleware.cache import CacheMiddleware
lt_cache = cache_page(settings.CACHES['eregs_longterm_cache']['TIMEOUT'],
cache=... | normal | {
"blob_id": "5b440484c5d7f066c54837c2812967a0ff360399",
"index": 9905,
"step-1": "<mask token>\n\n\nclass DailyCacheMiddleware(CacheMiddleware):\n <mask token>\n\n @property\n def key_prefix(self):\n return date.today().isoformat() + '/' + (self.__key_prefix or '')\n\n @key_prefix.setter\n ... | [
3,
4,
5,
6
] |
# encoding: utf-8
# module Revit.GeometryConversion calls itself GeometryConversion
# from RevitNodes,Version=1.2.1.3083,Culture=neutral,PublicKeyToken=null
# by generator 1.145
# no doc
# no imports
# no functions
# classes
class CurveUtils(object):
# no doc
@staticmethod
def CurvesAreSimilar(a,b):
... | normal | {
"blob_id": "f5ca2fb2ce8bcb7a67abe3123d4c50949e9c2f2f",
"index": 2029,
"step-1": "# encoding: utf-8\r\n# module Revit.GeometryConversion calls itself GeometryConversion\r\n# from RevitNodes,Version=1.2.1.3083,Culture=neutral,PublicKeyToken=null\r\n# by generator 1.145\r\n# no doc\r\n# no imports\r\n\r\n# no func... | [
0
] |
#!usr/bin/python
# -*- coding:utf8 -*-
import time
import random
import asyncio
async def consumer(queue, name):
while True:
val = await queue.get()
print(f'{name} get a val: {val} at {time.strftime("%X")}')
await asyncio.sleep(1)
async def producer(queue, name):
for i in range(20):
... | normal | {
"blob_id": "e1172e2d9f20e56241829b3e4ccb4bcf6b5440be",
"index": 9233,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nasync def consumer(queue, name):\n while True:\n val = await queue.get()\n print(f\"{name} get a val: {val} at {time.strftime('%X')}\")\n await asyncio.sleep(1... | [
0,
1,
2,
3
] |
import pymel.all as pm
from collections import Counter
# example
# v.Create( sel[0], pm.datatypes.Color.red, sel[1], 'leftEye', 0.2 )
# select mesh 1st then the control
def Create( obj, targetColor, control, attr, offset ) :
shape = obj.getShape()
name = obj.name()
if( type(shape) == pm.Mesh ) :
outVerts = []
... | normal | {
"blob_id": "9061db3bb3aa3178262af58e56126302b9effdff",
"index": 6509,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef Create(obj, targetColor, control, attr, offset):\n shape = obj.getShape()\n name = obj.name()\n if type(shape) == pm.Mesh:\n outVerts = []\n verts = shape.v... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
import socket
name = socket.gethostname()
| normal | {
"blob_id": "79c043fc862e77bea5adc3f1c6bb9a6272f19c75",
"index": 78,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nname = socket.gethostname()\n",
"step-3": "import socket\nname = socket.gethostname()\n",
"step-4": "#!/usr/bin/env python\n\nimport socket\n\nname = socket.gethostname()\n",
"step-5"... | [
0,
1,
2,
3
] |
print("HELLO3")
| normal | {
"blob_id": "74be250df785590ecf45e048b0d6189e2b445889",
"index": 2181,
"step-1": "<mask token>\n",
"step-2": "print('HELLO3')\n",
"step-3": "print(\"HELLO3\")\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
class Tool:
def __init__(self, name, weight):
self.name = name
self.weight = weight
def __repr__(self):
return f'Tool({self.name!r},{self.weight})'
tools = [
Tool('수준계', 3.5),
Tool('해머', 1.25),
Tool('스크류드라이버', .5),
Tool('끌', .25)
]
print(repr(tools))
tools.sort(reverse... | normal | {
"blob_id": "173b8e66ead62e3aa70805e42e06ea05257d5ee2",
"index": 2965,
"step-1": "class Tool:\n <mask token>\n\n def __repr__(self):\n return f'Tool({self.name!r},{self.weight})'\n\n\n<mask token>\n",
"step-2": "class Tool:\n\n def __init__(self, name, weight):\n self.name = name\n ... | [
2,
3,
4,
5,
6
] |
def swap(a,b):
print(a,b)
a=input("enter a value 1 : ")
b=input("enter b value 2 : ")
a,b=b,a
print("the vaalues after swaping the variables are below:")
print("the value of a is : ",a)
print("the value of b is : ",b)
| normal | {
"blob_id": "4fbe4d474e10e08eafee3bcc6173f8cd6b797dde",
"index": 3203,
"step-1": "<mask token>\n",
"step-2": "def swap(a, b):\n print(a, b)\n\n\n<mask token>\n",
"step-3": "def swap(a, b):\n print(a, b)\n\n\n<mask token>\nprint('the vaalues after swaping the variables are below:')\nprint('the value of ... | [
0,
1,
2,
3,
4
] |
import ROOT
from PhysicsTools.NanoAODTools.postprocessing.framework.datamodel import Collection
from PhysicsTools.NanoAODTools.postprocessing.framework.eventloop import Module
from TreeProducer import *
from TreeProducerCommon import *
from CorrectionTools.PileupWeightTool import *
from CorrectionTools.BTaggingTool i... | normal | {
"blob_id": "1721bba2cae1e330bffeb9df05341df9522ff885",
"index": 4394,
"step-1": "import ROOT\nfrom PhysicsTools.NanoAODTools.postprocessing.framework.datamodel import Collection \nfrom PhysicsTools.NanoAODTools.postprocessing.framework.eventloop import Module\n\nfrom TreeProducer import *\nfrom TreeProducerComm... | [
0
] |
import FitImport as imp
import numpy as np
from math import *
from sklearn.kernel_ridge import KernelRidge
from sklearn.grid_search import GridSearchCV
from sklearn import cross_validation
from sklearn.cross_validation import train_test_split
from sklearn.metrics import mean_squared_error
GSFOLDS = 3
FOLDS = 5
NPTS = ... | normal | {
"blob_id": "7d3a33968a375141c1c451ecd531ce8d97906c7f",
"index": 3065,
"step-1": "<mask token>\n\n\ndef GetPrediction(X, regr):\n return regr.predict(X)\n\n\ndef GetRMSE(Y, YP):\n return sqrt(mean_squared_error(Y, YP))\n\n\ndef SplitFitGKRR(X, Y):\n Xt, XT, Yt, YT = cross_validation.train_test_split(X, ... | [
5,
7,
8,
10,
11
] |
"""
If you are using MultiScript Editor make sure to set PYTHONPATH to Winexs' editor.
You can use set PYTHONPATH=c:/users/username/myscripts
Set paths according to your project!
"""
CHROME_WEBDRIVER = 'c:/users/username/project/chromedriver.exe'
WEBSITE_PDF_CONVERTER = 'https://www.ilovepdf.com/merge_pdf'
PDF_FILES ... | normal | {
"blob_id": "0fdbdfe98496ebedb112c85b79836292ffa3a5a9",
"index": 9076,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nCHROME_WEBDRIVER = 'c:/users/username/project/chromedriver.exe'\nWEBSITE_PDF_CONVERTER = 'https://www.ilovepdf.com/merge_pdf'\nPDF_FILES = 'c:/users/username/project'\n",
"step-3": "\"\... | [
0,
1,
2
] |
# -*- python -*-
# ex: set syntax=python:
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# See master.experimental/slaves.cfg for documentation.
slaves = [
#########################################... | normal | {
"blob_id": "e807cef534226f3efb4a8df471598727fa068f02",
"index": 3805,
"step-1": "<mask token>\n",
"step-2": "slaves = []\n",
"step-3": "# -*- python -*-\n# ex: set syntax=python:\n\n# Copyright (c) 2012 The Chromium Authors. All rights reserved.\n# Use of this source code is governed by a BSD-style license ... | [
0,
1,
2
] |
from cudasim.ParsedModel import ParsedModel
import re
import copy
class Writer:
def __init__(self):
pass
# replace the species and parameters recursively
@staticmethod
def rep(string, find, replace):
ex = find + "[^0-9]"
while re.search(ex, string) is not None:
res... | normal | {
"blob_id": "acd0b9019ef413699b47ecb2b66a0980cf3aa81f",
"index": 9792,
"step-1": "<mask token>\n\n\nclass Writer:\n <mask token>\n\n @staticmethod\n def rep(string, find, replace):\n ex = find + '[^0-9]'\n while re.search(ex, string) is not None:\n res = re.search(ex, string)\n ... | [
2,
3,
4,
5,
6
] |
# Copyright (C) 2020 Claudio Marques - All Rights Reserved
dataset_path = "data/output/dataset{toReplace}.csv"
dataset_path_final = "data/output/final/datasetFinal.csv"
log_path = "data/logs/output_append.log"
numberOfThreads = 45
inputFileMalign = "data/input/malign/all.log"
outputFileMalign = "data/output/fil... | normal | {
"blob_id": "305133d4840741bd5c318a99a96660d8988dd61a",
"index": 7772,
"step-1": "<mask token>\n",
"step-2": "dataset_path = 'data/output/dataset{toReplace}.csv'\ndataset_path_final = 'data/output/final/datasetFinal.csv'\nlog_path = 'data/logs/output_append.log'\nnumberOfThreads = 45\ninputFileMalign = 'data/i... | [
0,
1,
2
] |
print("hello world")
print("lol")
print("new changes in vis") | normal | {
"blob_id": "6c88e55a76cbd84cee0ebd6c51d930cc2da100d2",
"index": 2945,
"step-1": "<mask token>\n",
"step-2": "print('hello world')\nprint('lol')\nprint('new changes in vis')\n",
"step-3": "print(\"hello world\")\nprint(\"lol\")\nprint(\"new changes in vis\")",
"step-4": null,
"step-5": null,
"step-ids"... | [
0,
1,
2
] |
import SimpleITK as sitk
import numpy as np
from sklearn.ensemble import RandomForestClassifier
# # Estimation function # #
# --------------------------- #
# Linear registration function
# --------------------------- #
# --- Input --- #
# im_ref : The common image [numpy.ndarray]
# im_mov : The group ima... | normal | {
"blob_id": "2b7d9ded82fa980eeae06beb2d84d89612d53df1",
"index": 821,
"step-1": "<mask token>\n\n\ndef est_lin_transf(im_ref, im_mov, mov_mask=None, show_parameters=False):\n initial_transform = sitk.CenteredTransformInitializer(im_ref, im_mov,\n sitk.ScaleSkewVersor3DTransform(), sitk.\n Center... | [
5,
6,
7,
8,
9
] |
# EXERCISE:
# Plotting distributions pairwise (2)
# In this exercise, you will generate pairwise joint distributions again. This time, you will make two particular
# additions:
# - You will display regressions as well as scatter plots in the off-diagonal subplots. You will do this with the
# argument kind='reg' (whe... | normal | {
"blob_id": "0eaaa81d3c8bc61368701e1916b42ede88b90d04",
"index": 412,
"step-1": "<mask token>\n",
"step-2": "print(auto.head())\nsns.pairplot(auto, kind='reg', hue='origin')\nplt.show()\n",
"step-3": "# EXERCISE:\n\n# Plotting distributions pairwise (2)\n\n# In this exercise, you will generate pairwise joint... | [
0,
1,
2
] |
from mcpi.minecraft import Minecraft
import random, time
while True:
x, y, z = mc.player.getTilePos()
color = random.randrange(0, 9)
mc.setBlock(x, y, z - 1, 38, color)
time.sleep(0.01)
| normal | {
"blob_id": "a2e00af84f743e949b53840ae6d5509e08935486",
"index": 7978,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n x, y, z = mc.player.getTilePos()\n color = random.randrange(0, 9)\n mc.setBlock(x, y, z - 1, 38, color)\n time.sleep(0.01)\n",
"step-3": "from mcpi.minecraft i... | [
0,
1,
2
] |
#!python3
"""
I1. a
Ex1
5
1 3 5
2 1 4
3 2 4
4 1 5
5 2 3
"""
n = int(input().strip())
t = [None] * n
for i in range(n):
x,x1 = [int(i) for i in input().strip().split(' ')]
x,x1 = x-1, x1-1
t[i] = [x, x1]
res = [0]
while len(res) < n:
a = res[-1]
b = t[a][0]
... | normal | {
"blob_id": "0e3c6e14ff184401a3f30a6198306a17686e6ebe",
"index": 2382,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(n):\n x, x1 = [int(i) for i in input().strip().split(' ')]\n x, x1 = x - 1, x1 - 1\n t[i] = [x, x1]\n<mask token>\nwhile len(res) < n:\n a = res[-1]\n b = t[... | [
0,
1,
2,
3
] |
from django.urls import path,include
from.import views
from user.views import DetailsChangeView, HomeView, PasswordChangeView,SignUpView,LoginView,SettingsView,LogoutView,CreatePostView,CommentPostView,PasswordChangeView
urlpatterns = [
path('', HomeView.as_view(), name = 'HomeView'),
path('LoginView/', LoginV... | normal | {
"blob_id": "5bd8cee2595215fda6ab523a646cf918e3d84a50",
"index": 937,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('', HomeView.as_view(), name='HomeView'), path(\n 'LoginView/', LoginView.as_view(), name='LoginView'), path(\n 'SignUpView/', SignUpView.as_view(), name='SignUpV... | [
0,
1,
2,
3
] |
import re
from captcha.fields import CaptchaField
from django import forms
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from news.models import News, Comment, Profile
class UserRegisterForm(Use... | normal | {
"blob_id": "1b4a012f5b491c39c0abd139dd54f2095ea9d221",
"index": 3016,
"step-1": "<mask token>\n\n\nclass ContactForm(forms.Form):\n \"\"\"Форма обратной связи\"\"\"\n subject = forms.CharField(label='Тема', widget=forms.TextInput(attrs={\n 'class': 'form-control'}))\n content = forms.CharField(l... | [
7,
11,
14,
16,
18
] |
# -*- coding: utf-8 -*-
"""
Created on Thu Nov 15 06:50:48 2018
@author: Tony
"""
import glob
import pandas as pd
path =r'C:\Users\Tony\Downloads\daily_dataset\daily_dataset' # use your path
frame = pd.DataFrame()
list_ = []
def aggSumFn(path,grpByCol):
allFiles = glob.glob(path + "/*.csv")
... | normal | {
"blob_id": "252d6b381af09dbafb1d10c188eb154e53213033",
"index": 8845,
"step-1": "<mask token>\n\n\ndef aggSumFn(path, grpByCol):\n allFiles = glob.glob(path + '/*.csv')\n for file_ in allFiles:\n df = pd.read_csv(file_, index_col=None, header=0)\n list_.append(df)\n frame = pd.concat(list... | [
1,
2,
3,
4,
5
] |
#Horror_Novel_Generator.py
import markovify as mk
import random as rng
from fpdf import FPDF
def makePDF(filename):
#Get text, separating title and paragraphs
#Assumes first line is title
file= open(filename, "r")
title= file.readline()
pars= []
for line in file:
pars.append... | normal | {
"blob_id": "58fb2676b599b5f7fb9041cfae113a9d428d8ef8",
"index": 4503,
"step-1": "<mask token>\n\n\ndef makePDF(filename):\n file = open(filename, 'r')\n title = file.readline()\n pars = []\n for line in file:\n pars.append(line)\n file.close()\n pdf = FPDF(unit='pt')\n pdf.add_page()... | [
2,
3,
4,
5,
6
] |
def generator(factor, modulus=-1, maxx=2147483647):
def next(prev):
nxt = (prev*factor) % maxx
if modulus > 0:
while nxt % modulus != 0:
nxt = (nxt * factor) % maxx
return nxt
return next
def main(a, b, a_mod=-1, b_mod=-1, N=40000000, a_fact=16807, b_fact=48... | normal | {
"blob_id": "6162911befc8ad37591f7c19b14b349c655ccac0",
"index": 3856,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(a, b, a_mod=-1, b_mod=-1, N=40000000, a_fact=16807, b_fact=48271):\n genA = generator(a_fact, a_mod)\n genB = generator(b_fact, b_mod)\n match = 0\n mask = (255 <... | [
0,
1,
2,
3,
4
] |
def find_max(a, b):
if a > b:
return a
return b
def find_max_three(a, b, c):
return find_max(a, find_max(b, c))
| normal | {
"blob_id": "71dc429033b159f6ed806358f2286b4315e842d9",
"index": 9617,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef find_max_three(a, b, c):\n return find_max(a, find_max(b, c))\n",
"step-3": "def find_max(a, b):\n if a > b:\n return a\n return b\n\n\ndef find_max_three(a, b, ... | [
0,
1,
2
] |
for row in range(7):
for col in range(5):
if (col == 0) or (row % 3 == 0):
print("*", end=" ")
else:
print(" ", end=" ")
print()
| normal | {
"blob_id": "634c826d30b22c6061531c514914e9ca62b21605",
"index": 7158,
"step-1": "<mask token>\n",
"step-2": "for row in range(7):\n for col in range(5):\n if col == 0 or row % 3 == 0:\n print('*', end=' ')\n else:\n print(' ', end=' ')\n print()\n",
"step-3": "for r... | [
0,
1,
2
] |
import tensorflow as tf
def makeMnistModel():
mnist = tf.keras.datasets.mnist
(X_train, y_train), (_, _) = mnist.load_data()
X_train = X_train / 255.0
model = tf.keras.models.Sequential([tf.keras.layers.Flatten(input_shape
=(28, 28)), tf.keras.layers.Dense(128, activation='relu'), tf.keras
... | normal | {
"blob_id": "1555583cd3d8938cbaeeac2d1f74bb9c3858f26d",
"index": 4207,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef makeMnistModel():\n mnist = tf.keras.datasets.mnist\n (X_train, y_train), (_, _) = mnist.load_data()\n X_train = X_train / 255.0\n model = tf.keras.models.Sequential([... | [
0,
1,
2,
3
] |
import datetime
if __name__ == "__main__" :
keys = {'a','e','i', 'o', 'u', 'y'}
values = [1]
dictionnaire = {cle : list(values) for cle in keys}
print("dictionnaire : ", dictionnaire)
values.append(2)
#for cle in keys : dictionnaire.update({cle:values})
#dictionnaire.update({cle2 ... | normal | {
"blob_id": "468c070aebff3124927c5595d68bb94321dd75e5",
"index": 4406,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n keys = {'a', 'e', 'i', 'o', 'u', 'y'}\n values = [1]\n dictionnaire = {cle: list(values) for cle in keys}\n print('dictionnaire : ', dictionnaire... | [
0,
1,
2,
3
] |
import http.client
from urllib.parse import urlencode
client = http.client.HTTPConnection("127.0.0.1:9000")
post_data = {
"usertag": "test",
"password": '123456',
'code': "print('Hello Web')"
}
head_dict = {'Content-Type': 'application/x-www-form-urlencoded'}
post_data = urlencode(post_data)
client.request(... | normal | {
"blob_id": "ee1ce3ea4b31246703530478d6550b0c8866197e",
"index": 1190,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nclient.request(method='POST', url='/', body=post_data.encode('utf-8'),\n headers=head_dict)\n<mask token>\nclient.close()\nprint(content)\n",
"step-3": "<mask token>\nclient = http.c... | [
0,
1,
2,
3,
4
] |
# first we have to label the Banana / Apple / Tomato in the images
# we will use lables me
# pip install pyqt5
# pip install labelme
# after labeling the images. lets test it.
#Each image has a json file
import pixellib
from pixellib.custom_train import instance_custom_training
train_maskRcnn = instance_custom_tra... | normal | {
"blob_id": "cb4ca5f91c7cd47197784085258536166055afe9",
"index": 4212,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntrain_maskRcnn.modelConfig(network_backbone='resnet101', num_classes=3,\n batch_size=1)\ntrain_maskRcnn.load_pretrained_model('c:/models/mask_rcnn_coco.h5')\ntrain_maskRcnn.load_datase... | [
0,
1,
2,
3,
4
] |
from django.shortcuts import render
from django.views.generic import DetailView
from .models import Course
# Create your views here.
def courses_list_view(request):
products = Course.objects.all()
title = "دوره ها"
context = {
"object_list": products,
"title": title,
}
return re... | normal | {
"blob_id": "aaa9665ac6d639e681fddd032058f490ce36d12a",
"index": 7684,
"step-1": "<mask token>\n\n\nclass CoursesDetailView(DetailView):\n <mask token>\n <mask token>\n\n def get_context_data(self, *args, object_list=None, **kwargs):\n context = super(CoursesDetailView, self).get_context_data(*ar... | [
2,
3,
4,
5,
6
] |
import sys
sys.path.append('.')
import torch
from torch.nn import functional as F
import os
import yaml
from src.new_grad_cam import gc
def test(conf):
device = conf['device']
dataset = conf['test_dataset']
classes = conf['data']['classes']
weights_path = conf['weights_path']
results_dir = conf['r... | normal | {
"blob_id": "b57b6df1b7e551f64033a0c47e5a22eab9fd5fd4",
"index": 7616,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test(conf):\n device = conf['device']\n dataset = conf['test_dataset']\n classes = conf['data']['classes']\n weights_path = conf['weights_path']\n results_dir = con... | [
0,
1,
2,
3
] |
from p5 import *
capture = None
def setup():
global capture
createCanvas(390, 240)
capture = createCapture(VIDEO)
capture.size(320, 240)
def draw():
background(255)
image(capture, 0, 0, 320, 240)
run()
| normal | {
"blob_id": "93bfca1e756951faacd29871ad19afad374e25d6",
"index": 9647,
"step-1": "<mask token>\n\n\ndef setup():\n global capture\n createCanvas(390, 240)\n capture = createCapture(VIDEO)\n capture.size(320, 240)\n\n\ndef draw():\n background(255)\n image(capture, 0, 0, 320, 240)\n\n\n<mask tok... | [
2,
3,
4,
5
] |
#파이썬 심화
#클래스 메소드, 인스턴스 메소드, 스테이틱 메소드
# 기본 인스턴스 메소드
class Student(object):
"""
Student Class
Author : Kim
Date : 2020.11.07
Description : Class, Static, Instance Method
"""
#Class Variable
tuition_per = 1.0
def __init__(self, id, first_name, last_name, email, grade... | normal | {
"blob_id": "f507fbe7c92134c0a7149aafe7de88debebd42f5",
"index": 7760,
"step-1": "class Student(object):\n <mask token>\n <mask token>\n <mask token>\n\n def full_name(self):\n return '{} {}'.format(self._first_name, self._last_name)\n\n def detail_info(self):\n return 'Student Detai... | [
5,
7,
11,
13,
16
] |
from typing import Dict, List, Sequence, Iterable, Tuple
from allennlp.data.dataset_readers.dataset_reader import DatasetReader
from allennlp.data.instance import Instance
from allennlp.common.file_utils import cached_path
import logging
from overrides import overrides
import itertools
from allennlp.data.tokenizers imp... | normal | {
"blob_id": "21172985bf36302f6b0b2101e353d9fbcafb0673",
"index": 6653,
"step-1": "<mask token>\n\n\n@DatasetReader.register('bertclassification')\nclass ClassificationReader(DatasetReader):\n <mask token>\n\n @overrides\n def _read(self, file_path: str) ->Iterable[Instance]:\n file_path = cached_... | [
3,
4,
5,
6,
7
] |
from rest_framework import viewsets
from .models import *
from serializer import *
from django.http import HttpResponse
from django.views import View
from django.core import serializers
# Create your views here.
class ProyectoViewSet(viewsets.ModelViewSet):
queryset = Proyecto.objects.all()
serializer_class =... | normal | {
"blob_id": "bedae2621bfcc64deb0d13d7cbce3cfb89720245",
"index": 4346,
"step-1": "<mask token>\n\n\nclass ProyectoSistemaViewSet(viewsets.ModelViewSet):\n queryset = ProyectoSistema.objects.all()\n serializer_class = ProyectoSistemaSerializer\n\n\nclass UsuarioProyectoSistemaViewSet(viewsets.ModelViewSet):... | [
6,
8,
9,
12,
14
] |
#
# MIT License
#
# Copyright (c) 2018 Matteo Poggi m.poggi@unibo.it
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, c... | normal | {
"blob_id": "fbd8af4ab3e4ebdcb07509db776d38f9c26fd06a",
"index": 9446,
"step-1": "<mask token>\n\n\nclass trinet(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def generate_image_left(self, img, disp):\n return bilinear_sampler_1d_h(img, -disp)\n\n def generate_... | [
8,
14,
15,
17,
18
] |
import logging
from xdcs.app import xdcs
logger = logging.getLogger(__name__)
def asynchronous(func):
def task(*args, **kwargs):
try:
func(*args, **kwargs)
except Exception as e:
logger.exception('Exception during asynchronous execution: ' + str(e))
raise e
... | normal | {
"blob_id": "1b529d8bafc81ef4dd9ff355de6abbd6f4ebddf1",
"index": 706,
"step-1": "<mask token>\n\n\ndef lazy(func):\n\n\n class Lazy:\n\n def __init__(self, original) ->None:\n self._value_computed = False\n self._value = None\n self._original = [original]\n\n def... | [
1,
2,
3,
4,
5
] |
import socket
import threading
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 12321
server.bind(('', port))
server.listen()
client_names = []
clients = []
def broadcast(message):
for client in clients:
client.send(message)
def handle(client):
while True:
try:
... | normal | {
"blob_id": "f1fbbbe4258d0fb0a43505f4718730934fd595ec",
"index": 1831,
"step-1": "<mask token>\n\n\ndef broadcast(message):\n for client in clients:\n client.send(message)\n\n\ndef handle(client):\n while True:\n try:\n message = client.recv(1024)\n broadcast(message)\n ... | [
3,
4,
5,
6,
7
] |
#https://docs.python.org/3.4/library/itertools.html#module-itertools
l = [(1, 2, 9), (1, 3, 12), (2, 3, 8), (2, 4, 4), (2, 5, 7), (3, 5, 5), (3, 6, 2), (4, 5, 2), (4, 7, 10),
(5, 6, 11), (5, 7, 2), (6, 8, 4), (7, 8, 4), (7, 9, 3), (8, 9, 13)]
b = ['America', 'Sudan', 'Srilanka', 'Pakistan', 'Nepal', 'India'... | normal | {
"blob_id": "629353392e3a4f346f734543ae3f2b8dc616a6c3",
"index": 5816,
"step-1": "<mask token>\n\n\ndef itertools_groupby_example(list_of_nodes):\n graph = defaultdict(list)\n for key, group in groupby(l, lambda x: x[0]):\n graph[key].append(list(group))\n print(dict(graph))\n\n\ndef itertools_fa... | [
7,
10,
11,
12,
14
] |
# (c) 2019, Ansible by Red Hat, inc
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
#
from __future__ import absolute_import, division, print_function
__metaclass__ = type
from ansible_collections.arista.eos.tests.unit.compat.mock import patch
from ansible_collections.ari... | normal | {
"blob_id": "6efe3975f4d5d9f431391b3560c37a3e89e27f3d",
"index": 9172,
"step-1": "<mask token>\n\n\nclass TestEosLacpInterfacesModule(TestEosModule):\n <mask token>\n\n def setUp(self):\n super(TestEosLacpInterfacesModule, self).setUp()\n self.mock_get_config = patch(\n 'ansible_co... | [
4,
8,
11,
15,
16
] |
"""
Registers $v0 and $v1 are used to return values from functions.
Registers $t0 – $t9 are caller-saved registers that are used to
hold temporary quantities that need not be preserved across calls
Registers $s0 – $s7 (16–23) are callee-saved registers that hold long-lived
values that should be preserved across calls.... | normal | {
"blob_id": "63bc191a81a200d3c257de429c082cc8d13c98f4",
"index": 9952,
"step-1": "<mask token>\n\n\nclass MipsVisitor:\n <mask token>\n\n def __init__(self, inherit_graph, output_file='mips_code.mips'):\n self.inherit_graph, _ = inherit_graph\n self.offset = dict()\n self.type_index = ... | [
25,
31,
32,
48,
50
] |
from django.conf.urls import url, include
from . import views
from django.conf import settings
from django.conf.urls.static import static
app_name = 'stock_main'
urlpatterns = [
url(r'^$', views.Stock_main.as_view(), name='stock_main'),
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_RO... | normal | {
"blob_id": "16302f23edf16e201c3f3e9800dc4a9290ddc29e",
"index": 7038,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n",
"step-3": "<mask token>\napp_name = 'stock_main'\nurlpatterns = [url('^$', views.Stock_main.as_view(), n... | [
0,
1,
2,
3,
4
] |
"""
Sprites - animations for objects.
"""
import config
import os
import pygame
class Sheet(object):
""" An single large image composed of smaller images used for sprite
animations. All the sprites on the sheet must be the same size. The width x
height give the sprite dimensions in pixels. The rows x colu... | normal | {
"blob_id": "080aa8b99cdded7a947880a1c3399f68b28ae44d",
"index": 6318,
"step-1": "<mask token>\n\n\nclass Sprite(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass CompositeSprite(Sprite):\n \"\"\" A sprite that is composed of multiples sprites layered on top of each\n... | [
16,
18,
19,
21,
26
] |
import os
import argparse
import torch
import model.model as module_arch
from utils.util import remove_weight_norms
from train import get_instance
from librosa import load
from librosa.output import write_wav
from time import time
def main(config, resume, infile, outfile, sigma, dur, half):
# build model architec... | normal | {
"blob_id": "a2421a8673a524c32539555596711a71a8e00dbf",
"index": 439,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(config, resume, infile, outfile, sigma, dur, half):\n model = get_instance(module_arch, 'arch', config)\n model.summary()\n checkpoint = torch.load(resume)\n state... | [
0,
1,
2,
3,
4
] |
__path__.append(
'/cvmfs/cms.cern.ch/slc6_amd64_gcc481/cms/cmssw-patch/CMSSW_7_0_6_patch3/python/ggAnalysis'
)
| normal | {
"blob_id": "0345c3c2049c972370cd7bde5a6e0a1dfa5dfe66",
"index": 3719,
"step-1": "<mask token>\n",
"step-2": "__path__.append(\n '/cvmfs/cms.cern.ch/slc6_amd64_gcc481/cms/cmssw-patch/CMSSW_7_0_6_patch3/python/ggAnalysis'\n )\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,... | [
0,
1
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.