code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import json
def corec_set(parameter, value):
params_fn = "corec_parameters.json"
with open(params_fn) as f:
params = json.load(f)
params[parameter] = value
with open(params_fn, 'w') as f:
json.dump(params, f, indent=4)
def corec_get(parameter):
params_fn = "corec_parameters.json"
with open(params_fn)... | normal | {
"blob_id": "88b3dd7414a68de65bafb317fbd4da2b1bc933fc",
"index": 991,
"step-1": "<mask token>\n\n\ndef corec_unlock(lock):\n locks_fn = 'corec_locks.json'\n with open(locks_fn) as f:\n locks = json.load(f)\n locks[lock] = False\n with open(locks_fn, 'w') as f:\n json.dump(locks, f, inde... | [
1,
3,
4,
5,
6
] |
# 튜플(tuple) - 리스트와 구조가 비슷함
#변경, 삭제 할 수 없다.
t = ('코스모스', '민들레', '국화')
print(t)
print(t[:2])
print(t[1:])
#del t[0] - 삭제 안됨
#t[2] ="매화" - 수정 안됨
t2 = (1, 2, 3)
t3 = (4,) # 1개 추가하기 (쉼표를 붙임)
print(t2)
print(t3)
print(t2 + t3) # 요소 더하기
| normal | {
"blob_id": "45fcafdd30f890ddf5eaa090152fde2e2da4dbef",
"index": 732,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(t)\nprint(t[:2])\nprint(t[1:])\n<mask token>\nprint(t2)\nprint(t3)\nprint(t2 + t3)\n",
"step-3": "t = '코스모스', '민들레', '국화'\nprint(t)\nprint(t[:2])\nprint(t[1:])\nt2 = 1, 2, 3\nt3 = ... | [
0,
1,
2,
3
] |
"""
Вам дана последовательность строк.
В каждой строке замените все вхождения нескольких одинаковых букв на одну букву.
Буквой считается символ из группы \w.
Sample Input:
attraction
buzzzz
Sample Output:
atraction
buz
"""
from sys import stdin
import re
for word in stdin:
lst_in = word
match = re.finditer(r... | normal | {
"blob_id": "5b7c04f23fb674191639e95dff8c530933379d67",
"index": 3686,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor word in stdin:\n lst_in = word\n match = re.finditer('(\\\\w)\\\\1+', lst_in)\n for item in match:\n lst_in = lst_in.replace(item[0], item[0][0])\n print(lst_in, en... | [
0,
1,
2,
3
] |
# ----------------------
#
# *** WELCOME TO "HANGMAN" GAME ***
# Let's start programming
#
# ----------------------
def displayBoard(missedLetters, correctLetters, secretWord, alfabet_board, theme):
print(hangnam_pics[len(missedLetters)])
print("Тема:", theme)
# Показываем состояние угадываемого сло... | normal | {
"blob_id": "720ab0c0fcb40a50d73770e4ada6a78465e9ff96",
"index": 2755,
"step-1": "def displayBoard(missedLetters, correctLetters, secretWord, alfabet_board,\n theme):\n print(hangnam_pics[len(missedLetters)])\n print('Тема:', theme)\n for index in range(len(secretWord)):\n dashed_word = ''\n ... | [
4,
6,
8,
9,
10
] |
class Type(object):
"""Type of values."""
def __init__(self, jtype):
self.jtype = jtype
def __repr__(self):
return self.jtype.toString()
def __str__(self):
return self.jtype.toPrettyString(False, False)
| normal | {
"blob_id": "851162e6c40a9f4f82a983a84fd0b4d6a6a57412",
"index": 3675,
"step-1": "class Type(object):\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.jtype.toPrettyString(False, False)\n",
"step-2": "class Type(object):\n <mask token>\n\n def __init__(... | [
2,
3,
4,
5
] |
from rest_framework import generics
from animals.models import Location
from animals.serializers import LocationSerializer
class LocationList(generics.ListCreateAPIView):
queryset = Location.objects.all()
serializer_class = LocationSerializer
name = 'location-list'
class LocationDetail(generics.Retrieve... | normal | {
"blob_id": "245e407c9e92b3ac34389a48fcef4fc1b349ea18",
"index": 8252,
"step-1": "<mask token>\n\n\nclass LocationDetail(generics.RetrieveUpdateDestroyAPIView):\n queryset = Location.objects.all()\n serializer_class = LocationSerializer\n name = 'location'\n",
"step-2": "<mask token>\n\n\nclass Locati... | [
2,
3,
4,
5
] |
import json
from tqdm import tqdm
from topic.topic import get_topic_scores, get_topic_similarity
user_weights = json.load(open('data/selected_user_weights.json', 'r', encoding='utf8'))
reviews = json.load(open('data/business_reviews_test.json', 'r', encoding='utf8'))
for business, business_reviews in reviews.items(... | normal | {
"blob_id": "be90447eb7c717ae0bae28fd7f10238be733648d",
"index": 3617,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor business, business_reviews in reviews.items():\n for target_user in user_weights:\n if target_user in business_reviews:\n target_stars = business_reviews[target_u... | [
0,
1,
2,
3,
4
] |
import streamlit as st
st.write('hi')
| normal | {
"blob_id": "62ca95a871c16191fb8f56213646e8173f400630",
"index": 8017,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nst.write('hi')\n",
"step-3": "import streamlit as st\nst.write('hi')\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
import Bio
import os
import sys
from Bio import PDB
from Bio.PDB import PDBIO
from Bio.PDB.PDBParser import PDBParser
import math
import numpy
from collections import Counter
import random
from Bio.PDB import *
import gzip
def get_center(res_list):
coord = []
for atom in residue:
#... | normal | {
"blob_id": "8b29c12c294a8614d8be96c312ecffa9d3bcb3f8",
"index": 4575,
"step-1": "<mask token>\n\n\ndef get_center(res_list):\n coord = []\n for atom in residue:\n at = atom.coord\n x = at[0]\n y = at[1]\n z = at[2]\n atcord = [x, y, z]\n coord.append(atcord)\n ... | [
1,
2,
3,
4,
5
] |
import mosquitto
import json
import time
device_id = "868850013067326"
# The callback for when the client receives a CONNACK response from the server.
def on_connect(mosq, userdata, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# r... | normal | {
"blob_id": "673d6bb02ec666dbdbecb5fd7fd5041da1941cf8",
"index": 2251,
"step-1": "import mosquitto\nimport json\nimport time\ndevice_id = \"868850013067326\"\n\n# The callback for when the client receives a CONNACK response from the server.\ndef on_connect(mosq, userdata, rc):\n print(\"Connected with result ... | [
0
] |
from flask import Flask, render_template, request, jsonify, make_response
app = Flask(__name__)
@app.route("/")
def hello():
# return render_template('chat.html')
return make_response(render_template('chat.html'),200)
if __name__ == "__main__":
app.run(debug=True) | normal | {
"blob_id": "98841630964dd9513e51c3f13bfdb0719600712d",
"index": 6941,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@app.route('/')\ndef hello():\n return make_response(render_template('chat.html'), 200)\n\n\nif __name__ == '__main__':\n app.run(debug=True)\n",
"step-3": "<mask token>\napp ... | [
0,
2,
3,
4,
5
] |
_all__ = ["minning_algo"]
| normal | {
"blob_id": "5a7b68648898818e0db47f225f3d4b0972cd5b99",
"index": 7521,
"step-1": "<mask token>\n",
"step-2": "_all__ = ['minning_algo']\n",
"step-3": "_all__ = [\"minning_algo\"]\n\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
# def qs(li):
# n = len(li)
# if n <= 1:
# return li
# pivot = li[n - 1]
# left = []
# right = []
# for i in li[:n - 1]:
# if i <= pivot:
# left.append(i)
# else:
# right.append(i)
# left = qs(left)
# right = qs(right)
# return left + [... | normal | {
"blob_id": "605d8144d18207314981872ec57cec6cb2510601",
"index": 7457,
"step-1": "<mask token>\n",
"step-2": "def qs(li):\n n, p = len(li), len(li) // 2 - 1\n if n <= 1:\n return li\n\n\n<mask token>\n",
"step-3": "def qs(li):\n n, p = len(li), len(li) // 2 - 1\n if n <= 1:\n return... | [
0,
1,
2,
3
] |
import datetime
import time
import requests
from config import url
from data import DistrictList
import random
import pymysql
def base_url():
default_request = {
'base_url': url,
'headers': {
"Content-Type": "application/json;charset=UTF-8"}
}
return default_request['base_url'... | normal | {
"blob_id": "c55b6fed92a5f4f2961c6f8d5b150b22a5f622e8",
"index": 4520,
"step-1": "<mask token>\n\n\ndef base_url():\n default_request = {'base_url': url, 'headers': {'Content-Type':\n 'application/json;charset=UTF-8'}}\n return default_request['base_url']\n\n\ndef random_Num(length, string=[]):\n ... | [
10,
13,
15,
17,
18
] |
adict = {'name': 'bob', 'age': 23}
print('bob' in adict)
print('name' in adict)
for key in adict:
print('%s:%s' % (key, adict[key]))
print('%(name)s:%(age)s' % adict)
| normal | {
"blob_id": "aa4d872c6a529d8acf18f1c3b477bc1816ac2887",
"index": 575,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('bob' in adict)\nprint('name' in adict)\nfor key in adict:\n print('%s:%s' % (key, adict[key]))\nprint('%(name)s:%(age)s' % adict)\n",
"step-3": "adict = {'name': 'bob', 'age': ... | [
0,
1,
2
] |
#!/usr/bin/env python
import os
import sys
#from io import open
import googleapiclient.errors
import oauth2client
from googleapiclient.errors import HttpError
from . import auth
from . import lib
debug = lib.debug
# modified start
def get_youtube_handler():
"""Return the API Youtube object."""
... | normal | {
"blob_id": "65d08fe1a3f6e5cc2458209706307513d808bdb2",
"index": 3824,
"step-1": "<mask token>\n\n\ndef get_youtube_handler():\n \"\"\"Return the API Youtube object.\"\"\"\n options = {}\n home = os.path.expanduser('~')\n default_credentials = os.path.join(home, '.youtube-upload-credentials.json'\n ... | [
4,
5,
6,
7,
8
] |
#import bmm_mysql_connect # Import my connection module
import csv
import MySQLdb
import os
#bmm_mysql_connect.connect() # Connecting to mysql test database
#mycur = conn.cursor() # Creating my cursor
path = os.path.expanduser('~/Projects/bmm_private/login_test.txt')
login = csv.reade... | normal | {
"blob_id": "4569413c8ea985a010a1fea4835a5b368a23663a",
"index": 9455,
"step-1": "#import bmm_mysql_connect # Import my connection module\nimport csv \nimport MySQLdb \nimport os\n\n#bmm_mysql_connect.connect() # Connecting to mysql test database\n#mycur = conn.cursor() # Creating my cu... | [
0
] |
friends = ["Rolf", "Bob", "Anne"]
print(friends[0])
print(friends[1])
print(len(friends))
new_friends = [
["Rolf", 24],
["Bob", 30],
["Anne", 27],
["Charlie", 25],
["Jen", 25],
["Adam", 29]
]
print(friends[0][0])
friends.append("Jen")
print(friends)
new_friends.remove(["Anne", 27])
print(new... | normal | {
"blob_id": "355d60300cbbed817b4512e9b02cc4dd53d1293e",
"index": 2692,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(friends[0])\nprint(friends[1])\nprint(len(friends))\n<mask token>\nprint(friends[0][0])\nfriends.append('Jen')\nprint(friends)\nnew_friends.remove(['Anne', 27])\nprint(new_friends)\... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 25 15:14:15 2020
@author: luisa
"""
horast = int(input("Horas Trabajadas: "+"\n\t\t"))
tarifa = int(input("Tarifa por hora: "+"\n\t\t"))
descu = int(input("Descuentos: "+"\n\t\t"))
resp0 = horast - descu
resp1 = (resp0 * tarifa)/2
resp2 = (horast * tarifa) ... | normal | {
"blob_id": "4d9575c178b672815bb561116689b9b0721cb5ba",
"index": 919,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif horast >= 41:\n print('Valor a Pagar: ', resp3)\nelif horast <= 40:\n print('Valor a Pagar: ', resp4)\n",
"step-3": "<mask token>\nhorast = int(input('Horas Trabajadas: ' + '\\n... | [
0,
1,
2,
3
] |
import requests
from datetime import date
from datetime import timedelta
def get_offset_date(modifed_date, offset_in_days):
return date.isoformat(modifed_date + timedelta(days=int(offset_in_days)))
def get_trending_repositories(start_search_date, number_of_results=20):
github_api_uri = 'https://api.github.c... | normal | {
"blob_id": "8a7536b998a6d122e2e7529af1ebe2a0f025303f",
"index": 5620,
"step-1": "<mask token>\n\n\ndef get_offset_date(modifed_date, offset_in_days):\n return date.isoformat(modifed_date + timedelta(days=int(offset_in_days)))\n\n\ndef get_trending_repositories(start_search_date, number_of_results=20):\n g... | [
3,
4,
5,
6
] |
import bcrypt as bcrypt
from config.configuration import Configuration
class Usuario(Configuration.db.Model):
__tablename__ = "usuario"
id = Configuration.db.Column(Configuration.db.BIGINT, primary_key=True, autoincrement=True)
code = Configuration.db.Column(Configuration.db.String(80), unique=True, nul... | normal | {
"blob_id": "598a0771dd1447034f2db95c67dd0dcf968f43a7",
"index": 8229,
"step-1": "<mask token>\n\n\nclass Usuario(Configuration.db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __repr__(self):\n return '<Usuario %r>' % self.i... | [
8,
10,
12,
14,
16
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.4 on 2017-10-20 11:05
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0052_encounter_note'),
]
operations = [
migrations.CreateModel(
... | normal | {
"blob_id": "05851df7ae64d792e0c1faf96e2aca5b40e86d53",
"index": 2744,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('core', '005... | [
0,
1,
2,
3,
4
] |
disk = bytearray (1024*1024);
def config_complete():
pass
def open(readonly):
return 1
def get_size(h):
global disk
return len (disk)
def can_write(h):
return True
def can_flush(h):
return True
def is_rotational(h):
return False
def can_trim(h):
return True
def pread(h, count, of... | normal | {
"blob_id": "2e3c1bf0a4c88bda35a48008cace8c21e071384e",
"index": 8378,
"step-1": "<mask token>\n\n\ndef config_complete():\n pass\n\n\n<mask token>\n\n\ndef get_size(h):\n global disk\n return len(disk)\n\n\n<mask token>\n\n\ndef is_rotational(h):\n return False\n\n\ndef can_trim(h):\n return True... | [
7,
8,
11,
12,
13
] |
a, b, c, y = 4.4, 0.0, 4.2, 3.0
print(c + a * y * y / b)
| normal | {
"blob_id": "2c43ede960febfb273f1c70c75816848768db4e5",
"index": 6599,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(c + a * y * y / b)\n",
"step-3": "a, b, c, y = 4.4, 0.0, 4.2, 3.0\nprint(c + a * y * y / b)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
from PyQt4 import QtCore
SceneName = "sphere"
DefaultColor = QtCore.Qt.yellow
| normal | {
"blob_id": "874b87ca20385aa15cc7299707c9c1c0360ace43",
"index": 1045,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nSceneName = 'sphere'\nDefaultColor = QtCore.Qt.yellow\n",
"step-3": "from PyQt4 import QtCore\nSceneName = 'sphere'\nDefaultColor = QtCore.Qt.yellow\n",
"step-4": "from PyQt4 import Q... | [
0,
1,
2,
3
] |
# Generated by Django 3.1.1 on 2020-10-14 16:26
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('Store', '0004_remove_product_mcat'),
]
operations = [
migrations.RemoveField(
model_name='categ... | normal | {
"blob_id": "ec39dae7217ddc48b1ab5163d234542cb36c1d48",
"index": 5351,
"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 = [('Store', '00... | [
0,
1,
2,
3,
4
] |
import pickle
from numpy import *
import math
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import animation
from math import factorial
def savitzky_golay(y, window_size, order, deriv=0, rate=1):
order_range = range(order+1)
half_window = (window_size -1) // 2
b = np.mat([[k**i for i i... | normal | {
"blob_id": "8beafcd4f9c02657a828d8c37f2aecda325ba180",
"index": 9439,
"step-1": "<mask token>\n\n\ndef savitzky_golay(y, window_size, order, deriv=0, rate=1):\n order_range = range(order + 1)\n half_window = (window_size - 1) // 2\n b = np.mat([[(k ** i) for i in order_range] for k in range(-half_windo... | [
1,
2,
3,
4,
5
] |
#python的运算符实例
#'+'加号
# 俩个对象相加(可以是俩个数字,也可以是俩个字符串(将俩个字符串连接))
a=7+8
print(a)
b="GOOD"+"Job"
print(b)
#'-'减号
#取一个数字的相反数或者实现俩个数字相减
c=-7
print(c)
print(19-1)
#'*'乘号
#如果是数字则进行乘法运算,字符串则复制若干次
d=4*7
print(d)
e="hello"*7
print(e)
#'/'除号
#表示俩个数字相除(Python 3.0中会直接输出正确的值)
f=7/2
print(f)
#'**'求幂运算
g=2**3
print(g)
#'<'小于号 返回一个布尔值
... | normal | {
"blob_id": "d28f5f95b375a1e075fdfcbc0350c90cf96f0212",
"index": 9694,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(a)\n<mask token>\nprint(b)\n<mask token>\nprint(c)\nprint(19 - 1)\n<mask token>\nprint(d)\n<mask token>\nprint(e)\n<mask token>\nprint(f)\n<mask token>\nprint(g)\n<mask token>\nprin... | [
0,
1,
2,
3
] |
#!/usr/bin/python3
# encoding: utf-8
import sys
import argparse
import logging
from pathlib import Path
module = sys.modules['__main__'].__file__
__author__ = 'FFX'
__version__ = '1.0'
log = logging.getLogger(module)
def parse_command_line(argv):
"""Parse command line argument. See -h option
:param argv: ... | normal | {
"blob_id": "46adb1834f6013ca0f13a64f280182a805d76278",
"index": 215,
"step-1": "<mask token>\n\n\ndef parse_command_line(argv):\n \"\"\"Parse command line argument. See -h option\n :param argv: arguments on the command line must include caller file name.\n \"\"\"\n formatter_class = argparse.RawDesc... | [
2,
3,
4,
5,
6
] |
#!/usr/bin/env python3
import argparse
from glob import glob
import sys
import numpy as np
import matplotlib.pyplot as plt
import pysam
import math
import pandas as pd
import haplotagging_stats
import os
import collections
import seaborn as sns
NUM_CONTIGS="num_contigs"
TOTAL_LEN="total_len"
HAPLOTYPE="haplotype"
HAPL... | normal | {
"blob_id": "0c7816028e6cbd12684b0c7484835e735f1d2838",
"index": 4327,
"step-1": "<mask token>\n\n\ndef parse_args(args=None):\n parser = argparse.ArgumentParser(\n 'Plots information from haplotagging_stats tsv')\n parser.add_argument('--input_csv', '-i', dest='input_csv', default=None,\n re... | [
3,
5,
6,
7,
8
] |
class Node:
def __init__(self, info):
self.info = info
self.left = None
self.right = None
self.level = None
def __str__(self):
return str(self.info)
class BinarySearchTree:
def __init__(self):
self.root = None
def create(self, val):
i... | normal | {
"blob_id": "6ee36994f63d64e35c4e76f65e9c4f09797a161e",
"index": 511,
"step-1": "<mask token>\n\n\nclass BinarySearchTree:\n\n def __init__(self):\n self.root = None\n\n def create(self, val):\n if self.root == None:\n self.root = Node(val)\n else:\n current = sel... | [
3,
4,
5,
8,
9
] |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
#######################
# Iterative solution
#######################
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if head is None:
return h... | normal | {
"blob_id": "682495fec200ddad5a68f06bb0ec24e59036e66b",
"index": 3286,
"step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n <mask token>\n\n\nclass Solution:\n\n def reverseList(self, head):\n prev = None\n while head:\n curr = head\n head = head.next\n ... | [
6,
7,
8,
9,
11
] |
# Software Name: MOON
# Version: 5.4
# SPDX-FileCopyrightText: Copyright (c) 2018-2020 Orange and its contributors
# SPDX-License-Identifier: Apache-2.0
# This software is distributed under the 'Apache License 2.0',
# the text of which is available at 'http://www.apache.org/licenses/LICENSE-2.0.txt'
# or see the "LI... | normal | {
"blob_id": "af35075eaca9bba3d6bdb73353eaf944869cdede",
"index": 799,
"step-1": "<mask token>\n\n\ndef delete_pdp(pdp_id):\n from moon_manager.db_driver import PDPManager\n PDPManager.delete_pdp('', pdp_id)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef delete_pdp(pdp_id):\n from moon_manager.... | [
1,
2,
3,
4,
5
] |
from django.contrib import admin
from TestApp.models import Parcel
# Register your models here.
class ParcelAdmin(admin.ModelAdmin):
list_display = ['billno','shippername','rate']
admin.site.register(Parcel,ParcelAdmin)
| normal | {
"blob_id": "a550b9406e9dd301b863744bb28bc81fac0cd80c",
"index": 9607,
"step-1": "<mask token>\n\n\nclass ParcelAdmin(admin.ModelAdmin):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass ParcelAdmin(admin.ModelAdmin):\n list_display = ['billno', 'shippername', 'rate']\n\n\n<mask tok... | [
1,
2,
3,
4,
5
] |
from database import db
from database import ma
from datetime import datetime
from sqlalchemy import ForeignKeyConstraint
from models.admin import Admin, admin_limited_schema
from models.event_status import EventStatus, event_status_schema
from models.org_unit import org_unit_schema
class Event(db.Model):
# class ... | normal | {
"blob_id": "f3167d8f1a806c38fb10672605d8e94265d2fc9c",
"index": 723,
"step-1": "<mask token>\n\n\nclass Event(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask ... | [
4,
6,
7,
8,
9
] |
import os
# __file__: 当前文件
# os.path.dirname(): 所在目录
# os.path.abspath(): 当前文件/目录的绝对路径
# os.path.join(): 路径连接
# 项目路径
BASEDIR = os.path.abspath(
os.path.dirname(
os.path.dirname(
__file__)))
# 数据文件目录
DATA_DIR = os.path.join(BASEDIR, "data")
DATA_FILE = os.path.join(DATA_DIR, 'data.yaml') | normal | {
"blob_id": "7a793c2081032745ae58f92a4572954333742dfd",
"index": 3943,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nBASEDIR = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))\nDATA_DIR = os.path.join(BASEDIR, 'data')\nDATA_FILE = os.path.join(DATA_DIR, 'data.yaml')\n",
"step-3": "import os... | [
0,
1,
2,
3
] |
import pygame
def play_file(name,loop=0,time=0.0):
try: #if image exists
file='data/audio/'+name
pygame.mixer.music.load(file)
pygame.mixer.music.play(loop, time)
except ZeroDivisionError: #if image doesn't exist
print('AudioLoading: failed to load ' + name)
try:
... | normal | {
"blob_id": "98940c898d58917e652fe1514ea758768b048dbc",
"index": 9601,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef play_file(name, loop=0, time=0.0):\n try:\n file = 'data/audio/' + name\n pygame.mixer.music.load(file)\n pygame.mixer.music.play(loop, time)\n except Z... | [
0,
1,
2,
3
] |
# ============================================================================
# Archivo cnn_sisben.py
# autor Johan S. Mendez, Jose D. Mendez
# fecha 27/Agos/2020
# Clasificacion de beneficiarios del nuevo sistema de clasificacion del sisben
# agrupado en 4 grandes grupos de beneficiarios, se utiliza un red neuronal
... | normal | {
"blob_id": "bfb52a5ee6d88d63c4ef89dae26bb8cbecb091c6",
"index": 4200,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nseed(1)\n<mask token>\nset_random_seed(2)\nprint('\\x1b[91m Lectura de datos \\x1b[0m')\n<mask token>\nmodel.add(Conv1D(64, 32, input_shape=(x_train.shape[1], 1), activation='elu'))\nmode... | [
0,
1,
2,
3,
4
] |
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not us... | normal | {
"blob_id": "edc7c74a19a272bdd6da81b3ce2d214a2b613984",
"index": 5835,
"step-1": "<mask token>\n\n\nclass PipelineTest(unittest.TestCase):\n <mask token>\n\n\n class CustomTransform(PTransform):\n\n def expand(self, pcoll):\n return pcoll | '+1' >> FlatMap(lambda x: [x + 1])\n\n\n clas... | [
37,
60,
63,
68,
85
] |
class boxCar:
def __init__(self, *args, **kwargs):
print("print the keyword arguments dictionary {0} by {1}".format(kwargs, "WANGH"))
self.name = kwargs["name"]
self.domains = ["BODY","PWT","INFO","ADAS","INF"]
self.configuration = {}
def addEcu(self, ecu, domain):
i... | normal | {
"blob_id": "c3fae13b488a717419adb8292597746a383b332c",
"index": 7547,
"step-1": "class boxCar:\n\n def __init__(self, *args, **kwargs):\n print('print the keyword arguments dictionary {0} by {1}'.format(\n kwargs, 'WANGH'))\n self.name = kwargs['name']\n self.domains = ['BODY'... | [
4,
6,
7,
8,
9
] |
#!/usr/bin/python3
"""HAWK GUI interface Selenium test: tests hawk GUI with Selenium using firefox or chrome"""
import argparse, re, hawk_test_driver, hawk_test_ssh, hawk_test_results
### MAIN
# Command line argument parsing
parser = argparse.ArgumentParser(description='HAWK GUI interface Selenium test')
parser.add_... | normal | {
"blob_id": "874668d5f3ea61b6aabde7b784078b431961a9c9",
"index": 9096,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nparser.add_argument('-b', '--browser', type=str, required=True, help=\n 'Browser to use in the test. Can be: firefox, chrome, chromium')\nparser.add_argument('-H', '--host', type=str, ... | [
0,
1,
2,
3,
4
] |
from math import pi
width = float(input("Enter the width of the tire in mm (ex 205): "))
aspectRatio = float(input("Enter the aspect ratio of the tire (ex 60): "))
diameter = float(input("Enter the diameter of the wheel in inches (ex 15): "))
approxVolume = (pi * (width ** 2) * aspectRatio * ((width * aspectRatio) + ... | normal | {
"blob_id": "65752c8ac50205df0fea105123935110e4a30aba",
"index": 7913,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(f'The apporximate volume is {approxVolume:.2f} liters')\n",
"step-3": "<mask token>\nwidth = float(input('Enter the width of the tire in mm (ex 205): '))\naspectRatio = float(inpu... | [
0,
1,
2,
3,
4
] |
import sys
import os
import tensorflow as tf
import keras
from cv2 import *
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from PIL import Image
import numpy as np
import pickle
from sklearn.model_selection import train_test_split
from keras.utils import np_utils
from keras.layers ... | normal | {
"blob_id": "0681ab83843187701ac72018b6078f5141bf22e0",
"index": 3663,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nnp.random.seed(7)\n<mask token>\ntf.keras.backend.set_session(tf.Session(config=config))\nnp.set_printoptions(threshold=np.nan)\n<mask token>\nwith open('gei.txt', 'rb') as fr:\n x_tra... | [
0,
1,
2,
3,
4
] |
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth import get_user_model
from .models import Profile
User = get_user_model()
# this wan't run on creating superuser
@receiver(post_save, sender=User)
def save_profile(sender, created, instance, **kwargs):
if ... | normal | {
"blob_id": "4f93af104130f5a7c853ee0e7976fd52847e588a",
"index": 4988,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@receiver(post_save, sender=User)\ndef save_profile(sender, created, instance, **kwargs):\n if created:\n profile = Profile.objects.create(user=instance)\n profile.sa... | [
0,
1,
2,
3,
4
] |
from checkov.common.models.enums import CheckCategories, CheckResult
from checkov.terraform.checks.resource.base_resource_negative_value_check import BaseResourceNegativeValueCheck
class FunctionAppDisallowCORS(BaseResourceNegativeValueCheck):
def __init__(self):
name = "Ensure function apps are not acces... | normal | {
"blob_id": "30c2d46d6587df3cbc3e83ecb7af787fcd86eb1f",
"index": 7067,
"step-1": "<mask token>\n\n\nclass FunctionAppDisallowCORS(BaseResourceNegativeValueCheck):\n\n def __init__(self):\n name = 'Ensure function apps are not accessible from all regions'\n id = 'CKV_AZURE_62'\n supported_... | [
3,
4,
5,
6,
7
] |
import sys
N = int(input())
card = [int(x+1) for x in range(N)]
trash = []
while len(card)>1:
topCard = card.pop(0)
trash.append(topCard)
card.append(card.pop(0))
outputStr = ""
for i in range(len(trash)):
outputStr += str(trash[i]) + " "
outputStr += str(card[0])
print(outputStr)
| normal | {
"blob_id": "90e475dfd128689dd4e1a5375ced6e4cbfb73c07",
"index": 7860,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile len(card) > 1:\n topCard = card.pop(0)\n trash.append(topCard)\n card.append(card.pop(0))\n<mask token>\nfor i in range(len(trash)):\n outputStr += str(trash[i]) + ' '\n... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
import errno
import logging
import os
import re
import sys
import argparse
def parse_map(map_str):
file_map = []
for line in map_str.split('\n'):
if not line:
continue
find, replace = line.split(' -- ', 1)
file_map.append((find, replace))
return f... | normal | {
"blob_id": "03d07f5f4647e904c288e828b8f8e7de35740054",
"index": 3737,
"step-1": "<mask token>\n\n\ndef map_file(file_map, d, f):\n for find, repl in file_map:\n if '/' in find:\n source = os.path.join(d, f)\n includes_path = True\n else:\n source = f\n ... | [
8,
10,
11,
12,
14
] |
"""
code: pmap_io_test.py
"""
import os
import time
import tables as tb
import numpy as np
from pytest import mark
from .. core.system_of_units_c import units
from .. database import load_db
from .. sierpe import blr
from . import tbl_functions as tbl
from .... | normal | {
"blob_id": "c36adc3cf5de2f0ae3ee9b9823304df393ebce63",
"index": 5679,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@mark.parametrize('filename, with_', (('test_pmaps_auto.h5', \n True), ('test_pmaps_manu.h5', False)))\ndef test_pmap_writer(config_tmpdir, filename, with_,\n s12_dat... | [
0,
1,
2,
3,
4
] |
import json
parsed = {}
with open('/Users/danluu/dev/dump/terra/filtered_events.json','r') as f:
# with open('/Users/danluu/dev/dump/terra/game-data/2017-05.json','r') as f:
# with open('/Users/danluu/dev/dump/terra/ratings.json','r') as f:
parsed = json.load(f)
# print(json.dumps(parsed, indent=2))
print(js... | normal | {
"blob_id": "886024a528112520948f1fb976aa7cb187a1da46",
"index": 6767,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('/Users/danluu/dev/dump/terra/filtered_events.json', 'r') as f:\n parsed = json.load(f)\nprint(json.dumps(parsed['4pLeague_S1_D1L1_G4']['events']['faction'], indent=2))\n",
... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created for COMP5121 Lab on 2017 JUN 24
@author: King
"""
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
import sklearn.metrics as metrics
from sklearn.metrics import accuracy_score
data = [[... | normal | {
"blob_id": "33365d5ce5d2a7d28b76a7897de25e1f35d28855",
"index": 6269,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmodel.fit(data_train, label_train)\n<mask token>\nprint(model.score(data_test, label_test))\nprint(accuracy_score(label_test, predictions))\nprint(accuracy_score(label_test, predictions, ... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
from sqlalchemy.orm.session import sessionmaker, query
from FoodPandaStore.FoodPandaStore.model import *
import datetime as ... | normal | {
"blob_id": "f66306908f1fdd5c662804e73596b445c66dc176",
"index": 9521,
"step-1": "<mask token>\n\n\nclass FoodpandastoreInfo2Pipeline:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass FoodpandastoreInfo2Pipeline:\n\n def __init__(self):\n engine = db_connect()\n creat... | [
1,
2,
3,
4,
5
] |
print("Hi Tom") | normal | {
"blob_id": "e838a52fecbf69719acc6de38b5f045e792e1408",
"index": 9232,
"step-1": "<mask token>\n",
"step-2": "print('Hi Tom')\n",
"step-3": "print(\"Hi Tom\")",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
import os
import sys
import requests
import urllib.parse
import urllib.request
import json
from shutil import copyfile
def sdssDownload(band, location, size, path):
"""
.
sdssArchie populates a directory with links to raw images
from the SDSS mission. These images are all in FITS format
and su... | normal | {
"blob_id": "459bd36037158c9a6a38da6eadf45a3dc6f19e04",
"index": 4405,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef sdssDownload(band, location, size, path):\n \"\"\"\n .\n sdssArchie populates a directory with links to raw images \n from the SDSS mission. These images are all in F... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
import re
import argparse
import utils
# Les arguments à fournir en ligne de commande
parser = argparse.ArgumentParser(description="""Génère le graph des articles""")
parser.add_argument('corpus', type=str, help="Le nom du corpus (sans l'extension .tsv')")
parser.add_argument('-v', '--verbose... | normal | {
"blob_id": "a2593d5b89b9a35d91b0e1011f5b2a23a5a2062e",
"index": 2792,
"step-1": "# -*- coding: utf-8 -*-\n\nimport re\nimport argparse\n\nimport utils\n\n# Les arguments à fournir en ligne de commande\nparser = argparse.ArgumentParser(description=\"\"\"Génère le graph des articles\"\"\")\nparser.add_argument('c... | [
0
] |
from nltk.tokenize import RegexpTokenizer
token = RegexpTokenizer(r'\w+')
from nltk.corpus import stopwords
# with open('microsoft.txt','r+',encoding="utf-8") as file:
# text = file.read()
# text = '''
# Huawei Technologies founder and CEO Ren Zhengfei said on Thursday the Chinese company is willing to license its... | normal | {
"blob_id": "aed6e1966d9e4ce7250ae3cacaf8854cab4b590c",
"index": 3513,
"step-1": "<mask token>\n\n\ndef word_freq_improved_summarize(text):\n sen = text.split('.')\n small = [s.lower() for s in sen]\n punc_free = []\n for p in small:\n punc_free.extend(token.tokenize(p))\n stop_words = set(... | [
1,
2,
3,
4,
5
] |
'''
Created on June 10 2013
@author: Eugene Shim
This unit test suite is designed to test the unitTestParser module.
At the moment, the functions of that module are too simple to really
unit test effectively
'''
#Standard library modules
import unittest
#the module being tested
import unitTest... | normal | {
"blob_id": "5d0a45b93bd7972333f5574188c65484c065e9cf",
"index": 1327,
"step-1": "'''\nCreated on June 10 2013\n\n@author: Eugene Shim\n\n This unit test suite is designed to test the unitTestParser module.\n \n \n At the moment, the functions of that module are too simple to really\n unit test ef... | [
0
] |
#打印ckpt或pb模型的tensor
# ckpt模型
#第一种方法:
from tensorflow.python.tools.inspect_checkpoint import print_tensors_in_checkpoint_file
checkpoint_path="/your/path"
print_tensors_in_checkpoint_file(checkpoint_path,tensor_name='', all_tensors=True, all_tensor_names=True)
#第二种方法:
from tensorflow.python import pywrap... | normal | {
"blob_id": "50fab726b90f65a82c1206a8c7df955a8b76da99",
"index": 1572,
"step-1": "<mask token>\n\n\ndef create_graph():\n with tf.gfile.FastGFile(out_pb_path, 'rb') as f:\n graph_def = tf.GraphDef()\n graph_def.ParseFromString(f.read())\n tf.import_graph_def(graph_def, name='')\n\n\n<mask... | [
1,
2,
3,
4,
5
] |
# ******************************************************************************
# main.py
#
# Date Name Description
# ======== ========= ========================================================
# 6/5/19 Paudel Initial version,
# ***********************************************************************... | normal | {
"blob_id": "1490fecd6e983c0e3093a45d77d6fb8afdb54718",
"index": 203,
"step-1": "<mask token>\n\n\ndef parse_args():\n \"\"\"\n Usual pythonic way of parsing command line arguments\n :return: all command line arguments read\n \"\"\"\n args = argparse.ArgumentParser('GODIT')\n args.add_argument(... | [
5,
6,
7,
8,
10
] |
from datetime import datetime
import requests as req
import smtplib
import mysql.connector
#mysql constant
MYSQL_HOST='den1.mysql6.gear.host'
MYSQL_USER='winlabiot'
MYSQL_PW='winlabiot+123'
MYSQL_DB="winlabiot"
Coffee_mailing_list_table='coffee_mailing_list'
#keys in dict receive via socket
TIME='time'
AMBIENT_TEM... | normal | {
"blob_id": "5488b32970a0b734334835457c712768a756de7f",
"index": 859,
"step-1": "from datetime import datetime\nimport requests as req\n\nimport smtplib\n\nimport mysql.connector\n\n#mysql constant\nMYSQL_HOST='den1.mysql6.gear.host'\nMYSQL_USER='winlabiot'\nMYSQL_PW='winlabiot+123'\nMYSQL_DB=\"winlabiot\"\nCoff... | [
0
] |
from flask import Flask, json, request, jsonify
from flask_sqlalchemy import SQLAlchemy
from flask_marshmallow import Marshmallow
import warnings
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:1234@localhost/escuela'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS']=False
db = SQLAlche... | normal | {
"blob_id": "5c1d1eafb913822be9b6e46b15c6886f8bf3e2e1",
"index": 3622,
"step-1": "<mask token>\n\n\nclass curso(db.Model):\n idcurso = db.Column(db.Integer, primary_key=True)\n nombre_curso = db.Column(db.String(45))\n precio = db.Column(db.Integer)\n\n def __init__(self, nombre, precio):\n se... | [
9,
10,
11,
13,
14
] |
from . import chequeador_camion
from . import chequeador_camion_modelo
from . import chequeador_destino_tipo
from . import chequeador_destino
from . import chequeador_origen
from . import chequeador_minerales
| normal | {
"blob_id": "bf7319996043a41b7d0ef4e6098c3609e5db101e",
"index": 9809,
"step-1": "<mask token>\n",
"step-2": "from . import chequeador_camion\nfrom . import chequeador_camion_modelo\nfrom . import chequeador_destino_tipo\nfrom . import chequeador_destino\nfrom . import chequeador_origen\nfrom . import chequead... | [
0,
1
] |
from dataframe import *
from chaid import SuperCHAID, SuperCHAIDVisualizer
supernode_features = [manufacturing_region]
features_list = [customer_region, product_family, make_vs_buy]
dependant_variable = gm
super_tree = SuperCHAID(supernode_features, features_list, dependant_variable)
super_tree.fit(df)
visualizer = ... | normal | {
"blob_id": "0a42c54ef1412b7f3b8e95da1d65ee05dfa14089",
"index": 9709,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsuper_tree.fit(df)\n<mask token>\nvisualizer.export('tree')\n<mask token>\nprint(input_row[supernode_features + features_list])\nprint()\n<mask token>\nif result is not None:\n segment... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def quick_sort(a):
_quick_sort(a, 0, len(a)-1)
return a
def _quick_sort(a, lo, hi):
if lo < hi:
j = partition2(a, lo, hi)
_quick_sort(a, lo, j-1)
_quick_sort(a, j+1, hi)
def partition(a, lo, hi):
# simply select first element as... | normal | {
"blob_id": "52513bf3f50726587bee800f118e2ac0fa00d98b",
"index": 4354,
"step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\ndef quick_sort(a):\n _quick_sort(a, 0, len(a)-1)\n return a\n\n\ndef _quick_sort(a, lo, hi):\n\n if lo < hi:\n j = partition2(a, lo, hi)\n _quick_sort(a, lo, ... | [
0
] |
import getpass
print('****************************')
print('***** Caixa Eletronico *****')
print('****************************')
account_typed = input("Digite sua conta: ")
password_typed = getpass.getpass("Digite sua senha: ")
| normal | {
"blob_id": "44b6ee8488869da447882457897ce87b2fdea726",
"index": 7846,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('****************************')\nprint('***** Caixa Eletronico *****')\nprint('****************************')\n<mask token>\n",
"step-3": "<mask token>\nprint('*******************... | [
0,
1,
2,
3,
4
] |
import FWCore.ParameterSet.Config as cms
source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring(
'/store/user/skaplan/noreplica/ADDdiPhoton/sherpa/mgg750-2000_Ms3000/sherpaevents_10_1_Kji.root',
'/store/user/skaplan/noreplica/ADDdiPhoton/sherpa/mgg750-2000_Ms3000/sherpaevents_1_1_oTR.r... | normal | {
"blob_id": "aaeca18f3771a6032c0fe51b75502f730c888888",
"index": 9383,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsource = cms.Source('PoolSource', fileNames=cms.untracked.vstring(\n '/store/user/skaplan/noreplica/ADDdiPhoton/sherpa/mgg750-2000_Ms3000/sherpaevents_10_1_Kji.root'\n ,\n '/stor... | [
0,
1,
2,
3
] |
"""Test functions for util.mrbump_util"""
import pickle
import os
import sys
import unittest
from ample.constants import AMPLE_PKL, SHARE_DIR
from ample.util import mrbump_util
class Test(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.thisd = os.path.abspath(os.path.dirname(__file__))
... | normal | {
"blob_id": "f6dd5acc75d1a85a996629e22e81cdef316c1dcd",
"index": 8939,
"step-1": "<mask token>\n\n\nclass Test(unittest.TestCase):\n <mask token>\n\n def test_final_summary(self):\n pkl = os.path.join(self.testfiles_dir, AMPLE_PKL)\n if not os.path.isfile(pkl):\n return\n wi... | [
3,
4,
5,
6,
7
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.6 on 2017-04-03 14:45
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('productores', '0002_auto_20170327_0841'),
]
operations = [
migrations.AddFi... | normal | {
"blob_id": "2f7be68f08716d5d04d064d81eecb53eb9b80174",
"index": 7635,
"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 = [('productores... | [
0,
1,
2,
3,
4
] |
import os, sys
import math
import argparse
import shutil
import numpy as np
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import KFold
from keras.models import Sequential
from keras.layers import Dense, Dropout, Loc... | normal | {
"blob_id": "ed35a9bc3dd267c9a5fe76ccbb1b4ac5261fc3c8",
"index": 1993,
"step-1": "<mask token>\n\n\ndef get_model(num_feat=294, lr=0.001, drop_out=0.1, layer_dims=''):\n model = Sequential()\n act_fn = 'relu'\n if len(layer_dims) == 0:\n layer_dims = [10, 5, 0.2]\n else:\n layer_dims = ... | [
1,
3,
4,
5,
6
] |
import scraperwiki
import xlrd
xlbin = scraperwiki.scrape("http://www.whatdotheyknow.com/request/82804/response/208592/attach/2/ACCIDENTS%20TRAMS%20Laurderdale.xls")
book = xlrd.open_workbook(file_contents=xlbin)
sheet = book.sheet_by_index(0)
for n, s in enumerate(book.sheets()):
print "Sheet %d is called %s and... | normal | {
"blob_id": "86ec33393bb19ee432c30834ea7983b11f4d1234",
"index": 5169,
"step-1": "import scraperwiki\nimport xlrd\nxlbin = scraperwiki.scrape(\"http://www.whatdotheyknow.com/request/82804/response/208592/attach/2/ACCIDENTS%20TRAMS%20Laurderdale.xls\")\nbook = xlrd.open_workbook(file_contents=xlbin)\n\nsheet = bo... | [
0
] |
# Generated by Django 2.2.4 on 2019-09-09 11:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0002_ordered'),
]
operations = [
migrations.AlterField(
model_name='generalinfo',
name='amount_available',
... | normal | {
"blob_id": "8af9cc32b445402fa790b29382a802bd8afc1100",
"index": 5655,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n dependencies = [('core', '000... | [
0,
1,
2,
3,
4
] |
def ehcf(a, b):
p1, q1, h1, p2, q2, h2 = 1, 0, a, 0, 1, b
from math import floor
while h2 != 0:
r = floor(h1/h2)
p3 = p1-r*p2
q3 = q1-r*q2
h3 = h1-r*h2
p1,q1,h1,p2,q2,h2 = p2,q2,h2,p3,q3,h3
return (p1, q1, h1)
def findinverse(k, p):
l = ehcf(k,p)[0] % p
return l | normal | {
"blob_id": "d7b426727e11833b3825baac7b379f5ce44ea491",
"index": 5495,
"step-1": "<mask token>\n",
"step-2": "def ehcf(a, b):\n p1, q1, h1, p2, q2, h2 = 1, 0, a, 0, 1, b\n from math import floor\n while h2 != 0:\n r = floor(h1 / h2)\n p3 = p1 - r * p2\n q3 = q1 - r * q2\n h... | [
0,
1,
2,
3
] |
class TestContext:
def test_should_get_variable_from_env(self, monkeypatch, fake_context):
expected = "test"
monkeypatch.setenv("SOURCE_PATH", expected)
actual = fake_context.get("SOURCE_PATH")
assert actual == expected
def test_should_get_variable_from_local_state(self, fake_co... | normal | {
"blob_id": "e83a9a4675e5beed938860037658d33c4d347b29",
"index": 8528,
"step-1": "class TestContext:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class TestContext:\n <mask token>\n\n def test_should_get_variable_from_local_state(self, fake_context):\n expected = 'test'\n ... | [
1,
2,
3,
4,
5
] |
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_security import SQLAlchemySessionUserDatastore, Security
app = Flask(__name__, instance_relative_config=True)
app.config.from_pyfile("config.py", silent=True)
db = SQLAlchemy(app)
from .blueprints.cart.views import cart_blueprint
from .bluepr... | normal | {
"blob_id": "5d97a2afed26ec4826c8bce30c84863d21f86001",
"index": 9370,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp.config.from_pyfile('config.py', silent=True)\n<mask token>\napp.register_blueprint(static_blueprint)\napp.register_blueprint(admin_blueprint)\napp.register_blueprint(cart_blueprint)\n... | [
0,
1,
2,
3,
4
] |
"""Test radix sort."""
import random
from collections import OrderedDict
from que_ import Queue
def test_stringify_nums():
"""."""
from radixsort import stringify_nums
nums = [1, 2, 3, 4, 5]
stringified_nums = stringify_nums(nums)
assert stringified_nums == ['1', '2', '3', '4', '5']
def test_wh... | normal | {
"blob_id": "fd907dbcea01679c08aeae6bcbf6e61786f40260",
"index": 2511,
"step-1": "<mask token>\n\n\ndef test_stringify_nums():\n \"\"\".\"\"\"\n from radixsort import stringify_nums\n nums = [1, 2, 3, 4, 5]\n stringified_nums = stringify_nums(nums)\n assert stringified_nums == ['1', '2', '3', '4',... | [
4,
5,
6,
7,
8
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tensorflow
from pyspark.sql.functions import split
from pyspark.ml.fpm import FPGrowth
from pyspark.sql import SparkSession
from pyspark import SparkConf
from pyspark.sql.functions import udf, array
import re
from pyspark.sql.types import *
import pyspark.sql.functi... | normal | {
"blob_id": "e7d63c3b56459297eb67c56e93a3c640d93e5f6d",
"index": 8683,
"step-1": "<mask token>\n\n\n@udf(returnType=BooleanType())\ndef filter_host(item):\n for i in filter_hosts:\n if item.find(i) != -1:\n return False\n return True\n\n\n<mask token>\n\n\n@udf(returnType=BooleanType())\n... | [
2,
3,
4,
5,
6
] |
n=int(input("enter a number"))
cp=n
rev=0
sum=0
while(n>0):
rev=n%10
sum+=rev**3
n=n//10
if(cp==sum):
print("the given no is amstrong ")
else:
print("the given no is not amstrong ") | normal | {
"blob_id": "a8190c7c8926df18ee9439922ce8e3241e9a6140",
"index": 4550,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile n > 0:\n rev = n % 10\n sum += rev ** 3\n n = n // 10\nif cp == sum:\n print('the given no is amstrong ')\nelse:\n print('the given no is not amstrong ')\n",
"step-... | [
0,
1,
2,
3
] |
from tkinter import *
root = Tk()
photo = PhotoImage(file='flag.png')
panel = Label(root, image=photo)
panel.pack()
root.mainloop()
| normal | {
"blob_id": "2d192963bfe046bce1a0c82e0179380693f5c541",
"index": 9518,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npanel.pack()\nroot.mainloop()\n",
"step-3": "<mask token>\nroot = Tk()\nphoto = PhotoImage(file='flag.png')\npanel = Label(root, image=photo)\npanel.pack()\nroot.mainloop()\n",
"step-... | [
0,
1,
2,
3
] |
from django.shortcuts import render
from django.http import HttpResponse
from django.contrib.auth.models import User
from .models import Museo, Distrito, Comentario, Favorito, Like, Titulo, Letra, Color
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth import authenticate, login
from django.... | normal | {
"blob_id": "8b2911586e21162bec074732216c410c591f18a8",
"index": 6018,
"step-1": "<mask token>\n\n\ndef getMuseums():\n museos = Museo.objects.all()\n allMuseums = {}\n for museo in museos:\n allMuseums[museo.ID_ENTIDAD] = museo.comentario_set.count()\n return allMuseums\n\n\ndef getAccessible... | [
10,
11,
14,
17,
18
] |
from datetime import datetime
from pymongo import MongoClient
from bson import ObjectId
from config import config
class Database(object):
def __init__(self):
self.client = MongoClient(config['db']['url']) # configure db url
self.db = self.client[config['db']['name']] # configure db name
de... | normal | {
"blob_id": "bcc76e4dbcc191e7912085cbb92c5b0ebd2b047b",
"index": 6550,
"step-1": "<mask token>\n\n\nclass Database(object):\n\n def __init__(self):\n self.client = MongoClient(config['db']['url'])\n self.db = self.client[config['db']['name']]\n <mask token>\n\n def find(self, criteria, col... | [
4,
6,
7,
8,
9
] |
import numpy as np
from matplotlib import pylab as plt
from os import listdir,path
from os.path import isfile,join,isdir
def get_files(directory_path):
dirpath=directory_path
files=[f for f in listdir(dirpath) if (isfile(join(dirpath, f)) and ".npy" in f)]
files=sorted(files)
n_files=len(files)
pr... | normal | {
"blob_id": "b240e328ee6c5677991d3166c7b00f1b3a51787e",
"index": 4765,
"step-1": "<mask token>\n\n\ndef get_files(directory_path):\n dirpath = directory_path\n files = [f for f in listdir(dirpath) if isfile(join(dirpath, f)) and \n '.npy' in f]\n files = sorted(files)\n n_files = len(files)\n ... | [
1,
2,
3,
4,
5
] |
import time
import numpy as np
import matplotlib.pyplot as plt
class stochasticGradient :
def __init__( self , kwargs ) :
self.inputVectors = kwargs["inputVectors"]
self.expectedOutput = kwargs["expectedOutput"]
self.noOfEpochs = kwargs["noO... | normal | {
"blob_id": "775900d4c059c89bfb10f5c3c2a924a41a049438",
"index": 8205,
"step-1": "<mask token>\n\n\nclass stochasticGradient:\n\n def __init__(self, kwargs):\n self.inputVectors = kwargs['inputVectors']\n self.expectedOutput = kwargs['expectedOutput']\n self.noOfEpochs = kwargs['noOfEpoch... | [
17,
18,
23,
26,
29
] |
""" Tests for challenge116 """
import pytest
from robber import expect
from pemjh.challenge116 import main
@pytest.mark.parametrize('input, expected',
[
pytest.param(5, 12, marks=pytest.mark.example),
pytest.param(50, 20492570... | normal | {
"blob_id": "c9279434736d4e94564170fe98163ad3be9470b1",
"index": 4844,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.mark.parametrize('input, expected', [pytest.param(5, 12, marks=\n pytest.mark.example), pytest.param(50, 20492570929, marks=pytest.mark.\n regression)])\ndef test_challe... | [
0,
1,
2,
3
] |
from api import db
from api.models.author import AuthorModel
class QuoteModel(db.Model):
id = db.Column(db.Integer, primary_key=True)
author_id = db.Column(db.Integer, db.ForeignKey(AuthorModel.id))
quote = db.Column(db.String(255), unique=False)
rate = db.Column(db.Integer)
def __init__(self, au... | normal | {
"blob_id": "38f41fa87230ddc0b3a8c411b4c569f59f0ea065",
"index": 2509,
"step-1": "<mask token>\n\n\nclass QuoteModel(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, author, quote, rating=1):\n self.author = author\n self.quote = quote\n ... | [
3,
4,
5,
7,
8
] |
from datetime import datetime
class Location:
def __init__(self, location_dict):
self.x = location_dict['x']
self.y = location_dict['y']
self.id = location_dict['id']
self.events = []
self.latest_average_value = 0
self.latest_event_count = 0
self.average_... | normal | {
"blob_id": "efbfe95acbe0b97e863c8788bca4a71633da36b3",
"index": 1906,
"step-1": "<mask token>\n\n\nclass Location:\n <mask token>\n <mask token>\n\n def update_overall_average_value(self):\n value_sum = 0\n for event in self.events:\n value_sum += event.value\n value_cou... | [
2,
3,
4,
5,
6
] |
#!/usr/bin/env python
import sys
def trim_reads(fastq, selection, extra_cut, orientation, output, outputType,
seqLen, trim):
# Store all read/sequence ids that did not match with KoRV
ids = []
with open(selection, 'r') as f:
for line in f:
ids.append(line.strip())
... | normal | {
"blob_id": "3f3ed40bf800eddb2722171d5fd94f6c292162de",
"index": 5865,
"step-1": "<mask token>\n\n\ndef main():\n trim = sys.stdin.read()\n if len(sys.argv) > 7:\n trim_reads(sys.argv[1], sys.argv[2], int(sys.argv[3]), int(sys.argv\n [4]), sys.argv[5], sys.argv[6], int(sys.argv[7]), trim)... | [
1,
2,
3,
4,
5
] |
for _ in range(int(input())):
n = int(input())
s = input()
cur = 0
for i in s[::-1]:
if i==')':
cur+=1
else:
break
print("Yes") if cur>n//2 else print("No")
| normal | {
"blob_id": "31b420adebbe0d3ee6da2ed8236ece1526bdb063",
"index": 6290,
"step-1": "<mask token>\n",
"step-2": "for _ in range(int(input())):\n n = int(input())\n s = input()\n cur = 0\n for i in s[::-1]:\n if i == ')':\n cur += 1\n else:\n break\n print('Yes') ... | [
0,
1,
2
] |
# Code By it4min
# t.me/it4min
# t.me/LinuxArmy
# -- Combo List Maker v1 --
import time, os
os.system("clear")
banner = '''
\033[92m .o88b. .d88b. .88b d88. d8888b. .d88b.
d8P Y8 .8P Y8. 88'YbdP`88 88 `8D .8P Y8.
8P 88 88 88 88 88 88oooY' 88 88
8b 88 88 88 88 88 88~~~b. 88 88
Y8b... | normal | {
"blob_id": "6ab5ac0caa44366268bb8b70ac044376d9c062f0",
"index": 6976,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nos.system('clear')\n<mask token>\nprint(banner)\n<mask token>\nos.system('clear')\nprint('\\n' + '\\x1b[94m - Loading Data ...')\ntime.sleep(3)\nfor u in usrf:\n userlist.append(u... | [
0,
1,
2,
3,
4
] |
from angrytux.model.game_objects.obstacle_states.HittedState import HittedState
from angrytux.model.game_objects.obstacle_states.ObstacleState import ObstacleState
class NewState(ObstacleState):
@property
def delete(self) ->bool:
"""
Don't delete this obstacle
:return: False
"... | normal | {
"blob_id": "7d21e76383b80e8a4433fb11cb3b64efee7a6d3b",
"index": 7008,
"step-1": "<mask token>\n\n\nclass NewState(ObstacleState):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass NewState(ObstacleState):\n <mask token>\n\n def hit(self) ->None:\n \"\"\"\n Just rem... | [
1,
2,
3,
4
] |
# Generated by Django 2.2.7 on 2019-11-23 18:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('ml', '0003_auto_20191123_1835'),
]
operations = [
migrations.AlterField(
model_name='ml',
name='file',
f... | normal | {
"blob_id": "2bf5ec4b4c0f0eed8364dcc9f1be599a804846f2",
"index": 4981,
"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 = [('ml', '0003_... | [
0,
1,
2,
3,
4
] |
"""Code for constructing and executing Tasks"""
from bcipy.tasks.rsvp.calibration.alert_tone_calibration import RSVPAlertToneCalibrationTask
from bcipy.tasks.rsvp.calibration.inter_sequence_feedback_calibration import (
RSVPInterSequenceFeedbackCalibration
)
from bcipy.tasks.rsvp.calibration.calibration import RSVP... | normal | {
"blob_id": "f2e6d23e6d8c5aa6e80a652dc6cb8bda45824d0c",
"index": 1026,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef start_task(display_window, daq, exp_type, parameters, file_save,\n signal_model=None, language_model=None, fake=True, auc_filename=None):\n \"\"\"Creates a Task and starts e... | [
0,
1,
2,
3,
4
] |
# 在写Python爬虫的时候,最麻烦的不是那些海量的静态网站,而是那些通过JavaScript获取数据的站点。Python本身对js的支持就不好,所以就有良心的开发者来做贡献了,这就是Selenium,他本身可以模拟真实的浏览器,浏览器所具有的功能他一个都不拉下,加载js更是小菜了
# https://zhuanlan.zhihu.com/p/27115580
# C:\Users\hedy\AppData\Local\Programs\Python\Python36\Scripts\;C:\Users\hedy\AppData\Local\Programs\Python\Python36\
# pip 换源
# http://... | normal | {
"blob_id": "e2948c0ad78ce210b08d65b3e0f75d757e286ad9",
"index": 3883,
"step-1": "# 在写Python爬虫的时候,最麻烦的不是那些海量的静态网站,而是那些通过JavaScript获取数据的站点。Python本身对js的支持就不好,所以就有良心的开发者来做贡献了,这就是Selenium,他本身可以模拟真实的浏览器,浏览器所具有的功能他一个都不拉下,加载js更是小菜了\n# https://zhuanlan.zhihu.com/p/27115580\n# C:\\Users\\hedy\\AppData\\Local\\Programs\\P... | [
1
] |
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.asymmetric import padding
import cryptography.hazmat.primitives.ciphers as ciphers
import struct
import secrets
import random
from typing import List
LOCO_PUBLICKEY = serializ... | normal | {
"blob_id": "db9919ab15988828d24b4430a124841f225860cc",
"index": 5764,
"step-1": "<mask token>\n\n\nclass V2SLClient:\n <mask token>\n <mask token>\n\n def handshake(self):\n encrypted_key = LOCO_PUBLICKEY.encrypt(self._aeskey, padding.OAEP(\n padding.MGF1(hashes.SHA1()), hashes.SHA1()... | [
4,
5,
6,
8,
11
] |
#!/usr/bin/env python
import os
import sys
import click
import logging
from signal import signal, SIGPIPE, SIG_DFL
from ..helpers.file_helpers import return_filehandle
from ..helpers.sequence_helpers import get_seqio_fastq_record
signal(SIGPIPE, SIG_DFL)
def subset_fastq(fastq, subset):
'''Subset FASTQ file. P... | normal | {
"blob_id": "873a53983e3aeb66bd290450fb9c15a552bd163c",
"index": 4017,
"step-1": "<mask token>\n\n\n@click.command()\n@click.option('--fastq', help='FASTQ file to subset, can be compressed')\n@click.option('--subset', metavar='<INT>', help=\n 'Take every N reads (default:10)', default=10)\n@click.option('--lo... | [
1,
2,
3,
4,
5
] |
import datetime
from threading import Thread
import cv2
class WebcamVideoStream:
#Constructor
def __init__(self, src=0):
# initialize the video camera stream and read the first frame
# from the stream
self.stream = cv2.VideoCapture(src)
(self.grabbed, self.frame) = self.stream.read()
# initialize the v... | normal | {
"blob_id": "8a4fe88bfa39eeeda42198260a1b22621c33183e",
"index": 7894,
"step-1": "<mask token>\n\n\nclass WebcamVideoStream:\n <mask token>\n\n def start(self):\n Thread(target=self.update, args=()).start()\n return self\n\n def update(self):\n while True:\n if self.stopp... | [
4,
5,
6,
7,
8
] |
L5 = [0]*10
print(L5)
L5[2] = 20
print(L5)
print(L5[1:4])
L5.append(30)
print(L5)
L5.remove(30) #Elimina la primera ocurrencia del objeto
print(L5)
L6 = [1,2,3,4,5,6]
print(L6[1::2])
print(L6[::2]) | normal | {
"blob_id": "052824082854c5f7721efb7faaf5a794e9be2789",
"index": 6517,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(L5)\n<mask token>\nprint(L5)\nprint(L5[1:4])\nL5.append(30)\nprint(L5)\nL5.remove(30)\nprint(L5)\n<mask token>\nprint(L6[1::2])\nprint(L6[::2])\n",
"step-3": "L5 = [0] * 10\nprint... | [
0,
1,
2,
3
] |
# encoding=utf8
import json
import time
from util import http_util
available = 1
disable = 0
# 交易所域名
REST_URL = "https://api.bithumb.com"
PAYMENT_CURRENCY_BTC = "BTC"
PAYMENT_CURRENCY_KRW = "KRW"
# 成功码
SUCCESS_CODE = "0000"
# 没有交易对的错误码
NO_SYMBOL_CODE = ["5600", "5500"]
# bithumb提现的最小值,获取地址:https://apidocs.bithumb... | normal | {
"blob_id": "f268dc4c2ae2c17e7d0d3921d29e6b952fc63c7d",
"index": 9802,
"step-1": "<mask token>\n\n\ndef get_ticker(order_currency, payment_currency):\n \"\"\"\n 获取指定交易对的ticker信息:https://apidocs.bithumb.com/docs/ticker\n https://api.bithumb.com/public/ticker/BTC_KRW\n :return:\n {\n \"status\":\... | [
3,
6,
7,
8,
9
] |
from .routes import generate_routes
| normal | {
"blob_id": "06339e9cd506f147d03c54aee82473e233b4ec2e",
"index": 8853,
"step-1": "<mask token>\n",
"step-2": "from .routes import generate_routes\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
"""This module runs cdb on a process and !exploitable on any exceptions.
"""
import ctypes
import logging
import os
from pprint import pformat
from subprocess import Popen
from threading import Timer
import time
from certfuzz.debuggers.debugger_base import Debugger as DebuggerBase
from certfuzz.debuggers.ou... | normal | {
"blob_id": "706f8d83bc9b4fab6f6d365c047c33913daece61",
"index": 5014,
"step-1": "<mask token>\n\n\nclass MsecDebugger(DebuggerBase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def debugger_app(self):\n \"\"\"\n Returns the name of the debugger ... | [
8,
9,
12,
15,
16
] |
from .hailjwt import JWTClient, get_domain, authenticated_users_only
__all__ = ['JWTClient', 'get_domain', 'authenticated_users_only']
| normal | {
"blob_id": "39fb8d9f93be1e6c1ed2a425d14061737d643ab6",
"index": 9330,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['JWTClient', 'get_domain', 'authenticated_users_only']\n",
"step-3": "from .hailjwt import JWTClient, get_domain, authenticated_users_only\n__all__ = ['JWTClient', 'get_domai... | [
0,
1,
2
] |
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
'''
ans = set()
n = len(nums)
for x, val in enumerate(nums):
for y in range(x + 1, n + 1):
ans.add(frozenset(nums[x:y]))
for u in range(0, x + 1):
fo... | normal | {
"blob_id": "7d873ed216355d1688ec79ff337304d8ebfd2754",
"index": 7625,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def subsets(self, nums: List[int]) ->List[List[int]]:\n \"\"\"\n ans = set()\n n = len(nums)\n for ... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.