code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
<|reserved_special_token_0|>
def fetch_dset_dirs(dset_name=None):
"""
Finds the global pathname to a list of directories which represent a
dataset by name.
"""
assert dset_name is None or dset_name in DATASET_DIRS, 'invalid name'
dset_name = 'default' if dset_name is None else dset_name
ho... | flexible | {
"blob_id": "fd0db093b72dad4657d71788405fcca4ba55daff",
"index": 8529,
"step-1": "<mask token>\n\n\ndef fetch_dset_dirs(dset_name=None):\n \"\"\"\n Finds the global pathname to a list of directories which represent a\n dataset by name.\n \"\"\"\n assert dset_name is None or dset_name in DATASET_DI... | [
3,
4,
6,
7,
8
] |
from concurrent import futures
import time
import math
import logging
import grpc
import tensorflow as tf
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc
import sys
sys.path.append('/home/yitao/Documents/fun-project/tensorflow-related/miniature-winner/')... | normal | {
"blob_id": "0ec5d6ce11851a577046cf73cf98c91b6dfb9f67",
"index": 1550,
"step-1": "<mask token>\n\n\ndef worker():\n display_subtitle = ''\n while True:\n item = q.get()\n image = np.zeros((480, 640))\n if item is not None:\n vertices = item\n show_img = plot_verti... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
def printTest2():
if 0 == 0:
print(' ')
print(
'# jcj-jcj-jcj- TOP START OF PROGRAM - jcj-jcj-jcj-jcj-jcj-jcj-jcj-jcj-jcj'
)
thisProgramIs = 'menuScrnTxt.py'
print('Top of Start of program ' + thisProgramIs)
print(' ')
... | flexible | {
"blob_id": "e4f7e0c40edde4aac6ba0a7529a2e028a09689ae",
"index": 7260,
"step-1": "<mask token>\n\n\ndef printTest2():\n if 0 == 0:\n print(' ')\n print(\n '# jcj-jcj-jcj- TOP START OF PROGRAM - jcj-jcj-jcj-jcj-jcj-jcj-jcj-jcj-jcj'\n )\n thisProgramIs = 'menuScrnTxt.p... | [
3,
4,
5,
6,
7
] |
n = int(input())
a = sorted([int(input()) for _ in range(n)])
x = a[:n//2]
y = a[(n + 1)//2:]
ans = 0
for i in range(len(x)):
ans += abs(x[i] - y[i])
for i in range(1, len(y)):
ans += abs(x[i - 1] - y[i])
if n % 2 == 1:
ans += max(
abs(a[n // 2] - x[-1]),
abs(a[n // 2] - y[0]),
)
print... | normal | {
"blob_id": "0e9d0927e8d69b0c0fad98479d47f2409c95a751",
"index": 794,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(len(x)):\n ans += abs(x[i] - y[i])\nfor i in range(1, len(y)):\n ans += abs(x[i - 1] - y[i])\nif n % 2 == 1:\n ans += max(abs(a[n // 2] - x[-1]), abs(a[n // 2] - y[... | [
0,
1,
2,
3
] |
import pkg_resources
from twisted.enterprise import adbapi
from twisted.internet import defer
# Start a logger with a namespace for a particular subsystem of our application.
from twisted.logger import Logger
log = Logger("database")
class Database:
def __init__(self, context, db_filename="database.sqlite"):
... | normal | {
"blob_id": "45c1510d19af0979326a1b9975ec363b0b80a291",
"index": 8123,
"step-1": "<mask token>\n\n\nclass Database:\n\n def __init__(self, context, db_filename='database.sqlite'):\n session_files = context['session_files']\n db_filename = session_files.session_dir / db_filename\n database... | [
8,
9,
12,
15,
16
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def add():
print(a)
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def add():
print(a)
add()
<|reserved_special_token_1|>
a = 'aa'
def add():
print(a)
add()
<... | flexible | {
"blob_id": "97857c1c5468a96187d44abc23ffaaf2a7ead1a6",
"index": 1869,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef add():\n print(a)\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\ndef add():\n print(a)\n\n\nadd()\n",
"step-4": "a = 'aa'\n\n\ndef add():\n print(a)\n\n\nadd()\n"... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def generate_qr(query):
img = qrcode.make(query)
<|reserved_special_token_1|>
import qrcode
def generate_qr(query):
img = qrcode.make(query)
| flexible | {
"blob_id": "e97bcf31657317f33f4a138ede80bb9171337f52",
"index": 4730,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef generate_qr(query):\n img = qrcode.make(query)\n",
"step-3": "import qrcode\n\n\ndef generate_qr(query):\n img = qrcode.make(query)\n",
"step-4": null,
"step-5": null,... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(101):
result += i
print(result)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
result = 0
for i in range(101):
result += i
print(result)
<|reserved_special_token_1|>
"""
챕터: day4
주제: 반복문(for... | flexible | {
"blob_id": "d2754099adebdb4bd2b028fdf9015571ad773754",
"index": 9313,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(101):\n result += i\nprint(result)\n",
"step-3": "<mask token>\nresult = 0\nfor i in range(101):\n result += i\nprint(result)\n",
"step-4": "\"\"\"\n챕터: day4\n주제:... | [
0,
1,
2,
3
] |
from mininet.cli import CLI
from mininet.term import makeTerms
from mininet.util import irange
from log import log
from utils import (UITextStyle, display)
from dijkstra import (get_routing_decision, get_route_cost)
# Check if route directly connects two switches
def isDirect(route):
return (len(route) == 2)
# ... | normal | {
"blob_id": "7636925982434b12307383ba7b01f931f7ea6e24",
"index": 5927,
"step-1": "<mask token>\n\n\nclass DongPhamTestCli(CLI):\n <mask token>\n\n def __init__(self, _mininet, _env):\n self.env = _env\n self.net = _mininet\n self._testCLI = {}\n CLI.__init__(self, _mininet)\n ... | [
10,
18,
21,
26,
27
] |
<|reserved_special_token_0|>
def urls():
os.system('urls.bat')
def urls_1():
os.system('urls_1.bat')
<|reserved_special_token_0|>
def urls_3():
os.system('urls_3.bat')
def urls_4():
os.system('urls_4.bat')
def urls_5():
os.system('urls_5.bat')
def urls_6():
os.system('urls_6.bat')
... | flexible | {
"blob_id": "8e0d729fa55aabede123d89a507296b7d8a45c8b",
"index": 1705,
"step-1": "<mask token>\n\n\ndef urls():\n os.system('urls.bat')\n\n\ndef urls_1():\n os.system('urls_1.bat')\n\n\n<mask token>\n\n\ndef urls_3():\n os.system('urls_3.bat')\n\n\ndef urls_4():\n os.system('urls_4.bat')\n\n\ndef url... | [
39,
53,
59,
67,
75
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test():
T = [1, 2, 3, 1, 0, 4]
res = find_days(T)
assert res == [1, 1, 3, 2, 1, 0]
<|reserved_special_token_1|>
from solution import find_days
import pudb
def test():
T = [1, 2, 3, 1, 0, 4]
res = fin... | flexible | {
"blob_id": "db36c82717aa0bacffce7a3e2724ed2bb586c7fb",
"index": 7862,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test():\n T = [1, 2, 3, 1, 0, 4]\n res = find_days(T)\n assert res == [1, 1, 3, 2, 1, 0]\n",
"step-3": "from solution import find_days\nimport pudb\n\n\ndef test():\n ... | [
0,
1,
2,
3
] |
"""
The MIT License (MIT)
Copyright (c) 2015 Tommy Carpenter
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, copy, modify, mer... | normal | {
"blob_id": "da0076ab18531e5b8a1de909cb9178de6327d6b0",
"index": 3440,
"step-1": "<mask token>\n\n\ndef _filtering_parsing_helper(filter_cols_key, filter_vals_key,\n filter_invert_key):\n filter_vals = os.environ[filter_vals_key].split('|')\n inverts = [int(y) for y in os.environ[filter_invert_key].spli... | [
5,
6,
7,
8,
9
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Migration(migrations.Migration):
dependencies = [(... | flexible | {
"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
] |
import cv2
import numpy as np
img = cv2.imread('Scan1.jpg')
img_height, img_width, dim = img.shape
cv2.imshow('image1', img[0:int(img_height / 2), 0:int(img_width / 2)])
cv2.imshow('image2', img[int(img_height / 2):img_height, 0:int(img_width / 2)])
cv2.imshow('image3', img[0:int(img_height / 2), int(img_width / 2):img... | normal | {
"blob_id": "8c6f890631e9696a7907975b5d0bb71d03b380da",
"index": 839,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ncv2.imshow('image1', img[0:int(img_height / 2), 0:int(img_width / 2)])\ncv2.imshow('image2', img[int(img_height / 2):img_height, 0:int(img_width / 2)])\ncv2.imshow('image3', img[0:int(img_... | [
0,
1,
2,
3
] |
from otree.api import (
models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer,
Currency as c, currency_range
)
import random
import itertools
doc = """
Public good game section (Rounds and feedback).
"""
class Constants(BaseConstants):
name_in_url = 'public_goods'
players... | normal | {
"blob_id": "e766bba4dec0d37858f1f24083c238763d694109",
"index": 7874,
"step-1": "from otree.api import (\n models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer,\n Currency as c, currency_range\n)\nimport random\nimport itertools\n\ndoc = \"\"\"\n Public good game section (Rounds an... | [
0
] |
from Graph import create_random_graph
def find_accessible_vertices_backwards(graph, end_vertex):
if end_vertex not in graph.parse_vertices():
raise ValueError("The end vertex is not in the graph.")
visited = []
queue = []
next_vertex = {}
distance_to_end = {}
queue.append... | normal | {
"blob_id": "f882589729d74a910d20856d4dc02546fe316e0d",
"index": 2994,
"step-1": "<mask token>\n\n\ndef main():\n random_graph = create_random_graph(5, 10)\n print('THE GRAPH:')\n for vertex in random_graph.parse_vertices():\n for edge in random_graph.parse_outbound_edges(vertex):\n pr... | [
1,
2,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(Dialogos.saludo[0])
<|reserved_special_token_0|>
print('\nHola', nombre, 'tienes,', edad, 'años.')
if edad >= 18:
print('¡Tienes edad suficiente para jugar!')
quiere_jugar = input('¿Quieres jugar? ').lower()
if q... | flexible | {
"blob_id": "fe45fc6cd16be37b320844c5a8b43a964c016dd1",
"index": 5018,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(Dialogos.saludo[0])\n<mask token>\nprint('\\nHola', nombre, 'tienes,', edad, 'años.')\nif edad >= 18:\n print('¡Tienes edad suficiente para jugar!')\n quiere_jugar = input('¿Q... | [
0,
1,
2,
3,
4
] |
import pymel.core as PM
import socket
def getShadingGroupMembership():
'''
Get a dictionary of shading group set information
{'shadingGroup': [assignmnet1, assignment2...]}
'''
result = {}
#sgs = PM.ls(sl= 1, et='shadingEngine')
sgs = PM.listConnections(s= 1, t='shadingEngine')
for sg i... | normal | {
"blob_id": "4e38ad17ad66ac71b0df3cbcaa33cb546e96ce9d",
"index": 2257,
"step-1": "import pymel.core as PM\nimport socket\n\ndef getShadingGroupMembership():\n '''\n Get a dictionary of shading group set information\n {'shadingGroup': [assignmnet1, assignment2...]}\n '''\n result = {}\n #sgs = P... | [
0
] |
<|reserved_special_token_0|>
class Beacon:
def __init__(self, pos, sensor) ->None:
self.pos = pos
self.sensor = sensor
<|reserved_special_token_0|>
def __repr__(self) ->str:
return f'{self}'
<|reserved_special_token_0|>
<|reserved_special_token_0|>
@property
def ... | flexible | {
"blob_id": "f3a1a926feabcabc870f0a41ae239939c331d09d",
"index": 4106,
"step-1": "<mask token>\n\n\nclass Beacon:\n\n def __init__(self, pos, sensor) ->None:\n self.pos = pos\n self.sensor = sensor\n <mask token>\n\n def __repr__(self) ->str:\n return f'{self}'\n <mask token>\n ... | [
24,
28,
30,
34,
35
] |
from fixate.reporting.csv import register_csv, unregister_csv
| normal | {
"blob_id": "c70db0fc9d98657e318ecab7eb8af60cc2b19a2c",
"index": 4145,
"step-1": "<mask token>\n",
"step-2": "from fixate.reporting.csv import register_csv, unregister_csv\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
"""Some random mathematical helper functions.
"""
from __future__ import division, print_function
import math
# STATISTICS
def mean(L):
"""Calculate mean of given List"""
return sum(L) / len(L)
def variance(L, is_sample=0):
"""calculate variance (or sample variance) of given List"""
m = mean(L)
return sum((x... | normal | {
"blob_id": "34acb6da1dc9403a311ce3bca0a828a77b7b36da",
"index": 7403,
"step-1": "<mask token>\n\n\ndef std_dev(L, is_sample=0):\n \"\"\"calculate standard deviation of given List\"\"\"\n return math.sqrt(variance(L, is_sample))\n\n\ndef z_score(num, mean, std_dev):\n \"\"\"calculate z-score given sampl... | [
7,
14,
15,
17,
19
] |
"""
LeetCode Problem: 242. Valid Anagram
Link: https://leetcode.com/problems/valid-anagram/
Written by: Mostofa Adib Shakib
Language: Python
"""
class Solution(object):
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
length1 = len(s... | normal | {
"blob_id": "a4f932a8566afe0265dc1057d0f6534a608697f7",
"index": 365,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution(object):\n\n def isAnagram(self, s, t):\n \"\"\"\n :type s: str\n :t... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class SADQ_GQF(object):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def should_explore(self):
self.epsilon = self.epsilon_schedule.value(self.steps)
self.summary.add_scalar(tag='%s/Epsilon' % self.name, scalar_value=
self.epsilon, glo... | flexible | {
"blob_id": "424a0e8a7a80e24aec4bdb9b8c84fd9a5e6090c6",
"index": 6782,
"step-1": "<mask token>\n\n\nclass SADQ_GQF(object):\n <mask token>\n <mask token>\n\n def should_explore(self):\n self.epsilon = self.epsilon_schedule.value(self.steps)\n self.summary.add_scalar(tag='%s/Epsilon' % self... | [
11,
16,
19,
22,
23
] |
from django import forms
from .models import HhRequest
class WorkRequestForm(forms.ModelForm):
"""Форма заявки на премию"""
class Meta:
model = HhRequest
fields = ('profile', 'sphere', 'experience', 'work_request', 'resume')
widgets = {
'profile': forms.Select(
... | normal | {
"blob_id": "3887516e4222504defe439e62bd24b12db3cdd84",
"index": 695,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass WorkRequestForm(forms.ModelForm):\n <mask token>\n\n\n class Meta:\n model = HhRequest\n fields = 'profile', 'sphere', 'experience', 'work_request', 'resume'\... | [
0,
1,
2,
3,
4
] |
#-*-coding:utf-8 -*-
import subprocess
def get_audio(text):
stat = subprocess.call(['./tts', text])
if stat == 0:
return "Success"
else:
print "Failed"
if __name__ == '__main__':
text = "我是聊天机器人"
get_audio(text) | normal | {
"blob_id": "93eafb5b23bac513fc5dcc177a4e8a080b2a49b4",
"index": 9054,
"step-1": "#-*-coding:utf-8 -*-\n\nimport subprocess\n\ndef get_audio(text):\n stat = subprocess.call(['./tts', text])\n \n if stat == 0:\n return \"Success\"\n else:\n print \"Failed\"\n\nif __name__ == '__main__':\... | [
0
] |
from django.conf import settings
from django.db import models
def get_image_filename(instance, filename):
a = f'post_images/{instance.post.title}.svg'
return a
def get_main_image_filename(instance, filename):
a = f'post_images/{instance.title}_main.svg'
return a
# Create your models here.
class Po... | normal | {
"blob_id": "1bbadf02c4b9ca22a0099bcc09fa4c62c9901c39",
"index": 1069,
"step-1": "<mask token>\n\n\nclass Styles(models.Model):\n <mask token>\n\n @staticmethod\n def make_style():\n index_list = ['모던', '미니멀리즘', '한국', '스칸다나비아', '인더스트리얼', '프로방스',\n '로맨틱', '클래식', '엔틱']\n for i in ... | [
9,
15,
23,
27,
32
] |
<|reserved_special_token_0|>
@app.route('/', methods=['GET'])
def showHomepage():
return render_template('home.html')
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@app.route('/', methods=['GET'])
def showHomepage():
return render_template('home.html')
if __na... | flexible | {
"blob_id": "3001534be3364be1148cd51a4a943fd8c975d87e",
"index": 8384,
"step-1": "<mask token>\n\n\n@app.route('/', methods=['GET'])\ndef showHomepage():\n return render_template('home.html')\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\n@app.route('/', methods=['GET'])\ndef showHomepage():\n return... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
ic(compare('tranpsosed', 'transposed'))
print(f'Example Time: {(perf_counter_ns() - start) / 1000000000.0} Seconds')
ic(compare_info('momther', 'mother'))
<|reserved_special_token_1|>
<|reserved_special_token_0|>
start = perf_... | flexible | {
"blob_id": "98b0e42f3ed1a234f63c4d3aa76ceb9fce7c041d",
"index": 3631,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nic(compare('tranpsosed', 'transposed'))\nprint(f'Example Time: {(perf_counter_ns() - start) / 1000000000.0} Seconds')\nic(compare_info('momther', 'mother'))\n",
"step-3": "<mask token>... | [
0,
1,
2,
3,
4
] |
__author__ = 'samar'
import mv_details
import product
| normal | {
"blob_id": "7ac53779a98b6e4b236b1e81742163d2c610a274",
"index": 4556,
"step-1": "<mask token>\n",
"step-2": "__author__ = 'samar'\n<mask token>\n",
"step-3": "__author__ = 'samar'\nimport mv_details\nimport product\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
#!/usr/bin/env python
# encoding: utf-8
import tweepy #https://github.com/tweepy/tweepy
import csv
import scraperwiki
import json
#Twitter API credentials - these need adding
consumer_key = ""
consumer_secret = ""
access_key = ""
access_secret = ""
def get_all_tweets(screen_name):
#Twitter only allows access to a ... | normal | {
"blob_id": "02230b44568808757fe45fd18d28881d9bc3e410",
"index": 8074,
"step-1": "#!/usr/bin/env python\n# encoding: utf-8\n\nimport tweepy #https://github.com/tweepy/tweepy\nimport csv\nimport scraperwiki\nimport json\n\n#Twitter API credentials - these need adding\nconsumer_key = \"\"\nconsumer_secret = \"\"\n... | [
0
] |
<|reserved_special_token_0|>
def load_dataset(filename):
df = pd.read_csv(filename, encoding='latin1', names=['Sentence', 'Intent'])
intent = df['Intent']
unique_intent = list(set(intent))
sentences = list(df['Sentence'])
return intent, unique_intent, sentences
def cleaning(sentences):
words... | flexible | {
"blob_id": "707855a4e07b68d9ae97c2e1dc8bfd52f11c314c",
"index": 1812,
"step-1": "<mask token>\n\n\ndef load_dataset(filename):\n df = pd.read_csv(filename, encoding='latin1', names=['Sentence', 'Intent'])\n intent = df['Intent']\n unique_intent = list(set(intent))\n sentences = list(df['Sentence'])\... | [
7,
9,
10,
11,
12
] |
#!/usr/bin/python
###########################################################################
#
# Copyright 2019 Dell, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.... | normal | {
"blob_id": "102ba5c1cb4beda6f9b82d37d9b343fe4f309cfb",
"index": 5268,
"step-1": "#!/usr/bin/python\n###########################################################################\n#\n# Copyright 2019 Dell, Inc.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file exc... | [
0
] |
<|reserved_special_token_0|>
class PictureUploadForm(forms.ModelForm):
class Meta:
model = Picture
exclude = ()
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class PictureUpdateForm(forms.Form):
width = forms.IntegerField()
height = forms.IntegerField()
size = f... | flexible | {
"blob_id": "3d45fd7dcb3b382efaefe2797ebeb33216a840fa",
"index": 680,
"step-1": "<mask token>\n\n\nclass PictureUploadForm(forms.ModelForm):\n\n\n class Meta:\n model = Picture\n exclude = ()\n <mask token>\n <mask token>\n\n\nclass PictureUpdateForm(forms.Form):\n width = forms.Integer... | [
5,
6,
7,
8,
9
] |
SOURCE_FILE = "D:\\temp\\twitter\\tweet.js"
TWITTER_USERNAME = 'roytang'
auto_tags = ["mtg"]
syndicated_sources = ["IFTTT", "Tumblr", "instagram.com", "Mailchimp", "Twitter Web", "TweetDeck", "mtgstorm"]
debug_id = None
# debug_id = "11143081155"
import frontmatter
import json
import requests
import urllib.request
fr... | normal | {
"blob_id": "001d2ae89a2d008fdf6621a1be73de94c766c65f",
"index": 4570,
"step-1": "<mask token>\n\n\ndef get_content(t):\n content = t['full_text']\n if 'entities' in t:\n raw_urls = re.findall(\n 'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\\\(\\\\),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+'\n ... | [
3,
8,
11,
14,
15
] |
# filename: cycle_break.py
# for i in range(1, 101):
# if i % 3 == 0 and i % 8 == 0:
# print(i)
# break
num = 1
while num <= 100:
if num % 4 == 0 and num % 6 == 0:
print(num)
break
num += 1 | normal | {
"blob_id": "d04506e67071abf36d43a828d90fbe0f14230103",
"index": 3208,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile num <= 100:\n if num % 4 == 0 and num % 6 == 0:\n print(num)\n break\n num += 1\n",
"step-3": "num = 1\nwhile num <= 100:\n if num % 4 == 0 and num % 6 == 0... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def max_depth_bottom_up(root):
if not root:
return 0
max_so_far = 0
def max_depth(node, depth):
nonlocal max_so_far
if not node.left and not node.right:
max_so_far = max(max_so_far, depth)
else:
if node.left:
... | flexible | {
"blob_id": "555646a5d57152034b467cbce16b6c183bcfbb37",
"index": 6658,
"step-1": "<mask token>\n\n\ndef max_depth_bottom_up(root):\n if not root:\n return 0\n max_so_far = 0\n\n def max_depth(node, depth):\n nonlocal max_so_far\n if not node.left and not node.right:\n max... | [
8,
9,
12,
14,
15
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
setup(name='CoreMLModules', version='0.1.0', url=
'https://github.com/AfricasVoices/CoreMLModules', packages=[
'core_ml_modules'], setup_requires=['pytest-runner'], install_requires=
['numpy', 'scikit-learn', 'nltk'], ... | flexible | {
"blob_id": "24cd3a1a05a1cfa638b8264fd89b36ee63b29f89",
"index": 1625,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsetup(name='CoreMLModules', version='0.1.0', url=\n 'https://github.com/AfricasVoices/CoreMLModules', packages=[\n 'core_ml_modules'], setup_requires=['pytest-runner'], install_requ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def replace_bold_tags(l=''):
line_with_bold = re.match('(.*)__(.*)__(.*)', l)
if line_with_bold:
return line_with_bold.group(1) + STRONG.format(line_with_bold.group(2)
) + line_with_bold.group(3)
return l
<|reserved_special_token_0|>
def apply_p_tag_if_... | flexible | {
"blob_id": "6b0b60ec571cf026d0f0cff3d9517362c16b459b",
"index": 6092,
"step-1": "<mask token>\n\n\ndef replace_bold_tags(l=''):\n line_with_bold = re.match('(.*)__(.*)__(.*)', l)\n if line_with_bold:\n return line_with_bold.group(1) + STRONG.format(line_with_bold.group(2)\n ) + line_with... | [
5,
6,
8,
9,
10
] |
# -*- coding: utf-8 -
#
# This file is part of gaffer. See the NOTICE for more information.
import os
from .base import Command
from ...httpclient import Server
class Load(Command):
"""\
Load a Procfile application to gafferd
======================================
This command allows you... | normal | {
"blob_id": "eb5256543d6095668d6eeaf6cfdc9f744d7c73c5",
"index": 2267,
"step-1": "<mask token>\n\n\nclass Load(Command):\n <mask token>\n <mask token>\n <mask token>\n\n def find_groupname(self, g, s):\n tries = 0\n while True:\n groups = s.groups()\n if g not in g... | [
2,
3,
5,
6,
7
] |
import os
import numpy as np
import torch
from torch import nn
from torch.nn import functional as F
import torch.utils.data as td
import torchvision as tv
import pandas as pd
from PIL import Image
from matplotlib import pyplot as plt
from utils import imshow, NNRegressor
class DnCNN(NNRegressor):
def __init__(se... | normal | {
"blob_id": "9c60d82d42716abb036dc7297a2dca66f0508984",
"index": 7626,
"step-1": "<mask token>\n\n\nclass UDnCNN(NNRegressor):\n <mask token>\n <mask token>\n\n\nclass DUDnCNN(NNRegressor):\n\n def __init__(self, D, C=64):\n super(DUDnCNN, self).__init__()\n self.D = D\n k = [0]\n ... | [
4,
7,
8,
10,
11
] |
import datetime
class Schedule:
def __init__(self, start, end, name, other): # Constructor
self.start = self.str_convert(start) # Schedule start time (ex. 9:00)
self.end = self.str_convert(end) # Schedule end time (ex. 22:00)
... | normal | {
"blob_id": "f56978d5738c2f8cb4ed5ce4f11d3aae6a9689b1",
"index": 4604,
"step-1": "<mask token>\n\n\nclass Schedule:\n\n def __init__(self, start, end, name, other):\n self.start = self.str_convert(start)\n self.end = self.str_convert(end)\n self.name = name\n self.other = other\n ... | [
9,
10,
12,
13,
14
] |
from .feature import slide_show
def main(args=None):
if args:
slide_show(args[0])
| normal | {
"blob_id": "8680c033662a89ed6fc73e65ec544b93558c4208",
"index": 688,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(args=None):\n if args:\n slide_show(args[0])\n",
"step-3": "from .feature import slide_show\n\n\ndef main(args=None):\n if args:\n slide_show(args[0])\n"... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class predict_guitar:
<|reserved_special_token_0|>
def softmax(self, vector):
"""Softmax function for calculating probs"""
e = np.exp(vector)
return e / e.sum()
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "8743be809953f59bd14431e509042c4c51d9fab4",
"index": 4175,
"step-1": "<mask token>\n\n\nclass predict_guitar:\n <mask token>\n\n def softmax(self, vector):\n \"\"\"Softmax function for calculating probs\"\"\"\n e = np.exp(vector)\n return e / e.sum()\n <mask token>\n",
... | [
2,
3,
4,
5,
6
] |
from django import forms
from crawlr.models import Route, Category, UserProfile
from django.contrib.auth.models import User
class CategoryForm(forms.ModelForm):
name = forms.CharField(max_length=128,
help_text = "Please enter the category name.")
views = forms.IntegerField(widget=for... | normal | {
"blob_id": "abf25cf3d4435754b916fa06e5e887b1e3589a1c",
"index": 5073,
"step-1": "<mask token>\n\n\nclass RouteForm(forms.ModelForm):\n error_messages = {'duplicate_title':\n 'Please enter a unique name for the crawl'}\n title = forms.CharField(max_length=128, help_text=\n 'Please enter the n... | [
6,
7,
8,
9,
10
] |
class Solution:
# complexity: 2*n^2 + 4*n^2 -> 8*n^2
def numSmallerByFrequency(self, queries: List[str], words: List[str]) -> List[int]:
# complexity: n*2*l where l is the length of the word -> 2*n^2
words_freq = {
word: word.count(min(word)) for word in words
}
quer... | normal | {
"blob_id": "e9918f4fac2e13b36d9b20ffc28dc6508aad6f9b",
"index": 2159,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def numSmallerByFrequency(self, queries: List[str], words: List[str]\n ) ->List[int]:\n words_freq = {word: word.... | [
0,
1,
2,
3
] |
import helper
__author__ = 'AdrianLeo'
helper.greeting("Hey, dummy")
| normal | {
"blob_id": "03156992355a756b2ae38735a98251eb611d4245",
"index": 2611,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nhelper.greeting('Hey, dummy')\n",
"step-3": "<mask token>\n__author__ = 'AdrianLeo'\nhelper.greeting('Hey, dummy')\n",
"step-4": "import helper\n__author__ = 'AdrianLeo'\nhelper.greet... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for _sym, _val in locals().items():
if _sym.startswith('EVENT_') or _sym.startswith('IA2_EVENT_'):
winEventIDsToEventNames[_val] = _sym
<|reserved_special_token_1|>
<|reserved_special_token_0|>
CHILDID_SELF = 0
IA2_... | flexible | {
"blob_id": "5ec2ac3e0d66026da1b0c957d10c95e95c201f8f",
"index": 9032,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _sym, _val in locals().items():\n if _sym.startswith('EVENT_') or _sym.startswith('IA2_EVENT_'):\n winEventIDsToEventNames[_val] = _sym\n",
"step-3": "<mask token>\nCHILDI... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def search(url):
browser = webdriver.Chrome(executable_path=
'C:\\Users\\inaee\\Downloads\\chromedriver_win32\\chromedriver.exe')
browser.get(url)
time.sleep(1)
element = browser.find_element_by_tag_name('body')
for i in range(30):
element.send_keys(Key... | flexible | {
"blob_id": "142a2ba3ec2f6b35f4339ed9fffe7357c1a85fa0",
"index": 219,
"step-1": "<mask token>\n\n\ndef search(url):\n browser = webdriver.Chrome(executable_path=\n 'C:\\\\Users\\\\inaee\\\\Downloads\\\\chromedriver_win32\\\\chromedriver.exe')\n browser.get(url)\n time.sleep(1)\n element = brow... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class Category(db.Model):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
clas... | flexible | {
"blob_id": "743aa4ccbb9a131b5ef3d04475789d3d1da1a2fa",
"index": 2407,
"step-1": "<mask token>\n\n\nclass Category(db.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Category(db.Model):\n __tablename__... | [
1,
3,
4,
5,
6
] |
import cv2
import numpy as np
# THRESHOLDING FUNCTION IMPLEMENTATION
def thresholding(img):
# visualizing image in HSV parameters
imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
# the values for lowerWhite and upperWhite are found by tweaking the HSV min/max params in the
# trackbar by running ColorPick... | normal | {
"blob_id": "44175d2559f9c7d6171b6e45d24719d50dc80fb7",
"index": 7221,
"step-1": "<mask token>\n\n\ndef thresholding(img):\n imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)\n lowerWhite = np.array([80, 0, 0])\n upperWhite = np.array([255, 160, 255])\n maskWhite = cv2.inRange(imgHSV, lowerWhite, upperWh... | [
4,
7,
8,
9,
10
] |
# coding=utf-8
# @FileName: test_json.py
# @Author: ZhengQiang
# Date: 2020/1/15 5:26 下午
import json
a = "{\"ddd\": {{}}}"
def boyhook(dic):
print('test')
if dic['name']:
return dic['name'], dic['age']
return dic
new_boy = json.loads(a, object_hook=boyhook)
print(new_boy) | normal | {
"blob_id": "2bc5711839ccbe525551b60211d8cd79ddb7775a",
"index": 7019,
"step-1": "<mask token>\n\n\ndef boyhook(dic):\n print('test')\n if dic['name']:\n return dic['name'], dic['age']\n return dic\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef boyhook(dic):\n print('test')\n if d... | [
1,
2,
3,
4,
5
] |
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
] |
from flask import Blueprint, request
from ecdsa import SigningKey, NIST384p
import base64, codecs
from cryptography.fernet import Fernet
ecdsa_app = Blueprint('ecdsa_app', __name__, url_prefix='/ecdsa_app')
f = Fernet(Fernet.generate_key())
sk = SigningKey.generate(curve=NIST384p)
vk = sk.get_verifying_key()
@ecd... | normal | {
"blob_id": "4eb7abb24451f3f895d0731de7b29a85d90c1539",
"index": 8246,
"step-1": "<mask token>\n\n\n@ecdsa_app.get('/create_pkey')\ndef private_key():\n return {'status': 'success', 'result': sk.to_string().hex()}\n\n\n@ecdsa_app.post('/op')\ndef check_op():\n input = request.get_json()\n operators = ['... | [
4,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
ax.set_aspect('equal')
<|reserved_special_token_1|>
ax = fig.gca()
ax.set_aspect('equal')
<|reserved_special_token_1|>
# Adjust figure when using plt.gcf
ax = fig.gca()
ax.set_aspect('equal')
| flexible | {
"blob_id": "24246427e2fde47bbc9d068605301f54c6ecbae5",
"index": 1797,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nax.set_aspect('equal')\n",
"step-3": "ax = fig.gca()\nax.set_aspect('equal')\n",
"step-4": "# Adjust figure when using plt.gcf\nax = fig.gca()\nax.set_aspect('equal')\n",
"step-5": ... | [
0,
1,
2,
3
] |
# write dictionary objects to be stored in a binary file
import pickle
#dictionary objects to be stored in a binary file
emp1 = {"Empno" : 1201, "Name" : "Anushree", "Age" : 25, "Salary" : 47000}
emp2 = {"Empno" : 1211, "Name" : "Zoya", "Age" : 30, "Salary" : 48000}
emp3 = {"Empno" : 1251, "Name" : "Simarjeet", "Age"... | normal | {
"blob_id": "23937ae531cc95069a1319f8c77a459ba7645363",
"index": 4331,
"step-1": "<mask token>\n",
"step-2": "<mask token>\npickle.dump(emp1, empObj)\npickle.dump(emp2, empObj)\npickle.dump(emp3, empObj)\npickle.dump(emp4, empObj)\nprint('Successfully written four dictionaries')\nempObj.close()\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
''' The previous code does not correcly compute the stiffening coefficients
This program uses the clustering data to re-compute the stiffening coefficients '''
import glob
import sys
import time
#-----------------------------------------------------------------------------------#
#-----------------------------------... | normal | {
"blob_id": "095d7abfc8297e0bf741a4ebb351a7776055623f",
"index": 326,
"step-1": "''' The previous code does not correcly compute the stiffening coefficients \nThis program uses the clustering data to re-compute the stiffening coefficients '''\n\nimport glob\nimport sys\nimport time\n\n#--------------------------... | [
0
] |
from typing import Union
from django.db.models import Q, Value
from django.db.models.functions import Lower, Replace, Trim
from .normalization import (
normalize_doi,
normalize_funkcja_autora,
normalize_grupa_pracownicza,
normalize_isbn,
normalize_kod_dyscypliny,
normalize_nazwa_dyscypliny,
... | normal | {
"blob_id": "47025a30d79341ff0819fe87638e35960a5fc87d",
"index": 6446,
"step-1": "<mask token>\n\n\ndef matchuj_wydzial(nazwa):\n try:\n return Wydzial.objects.get(nazwa__iexact=nazwa.strip())\n except Wydzial.DoesNotExist:\n pass\n\n\ndef matchuj_tytul(tytul: str, create_if_not_exist=False) ... | [
11,
12,
13,
15,
16
] |
from psycopg2 import ProgrammingError, IntegrityError
import datetime
from loguru import logger
from db.connect import open_cursor, open_connection
_log_file_name = __file__.split("/")[-1].split(".")[0]
logger.add(f"logs/{_log_file_name}.log", rotation="1 day")
class DataTypeSaveError(Exception):
pass
class ... | normal | {
"blob_id": "8339ac512d851ea20938a1fbeedcb751cb2b8a6a",
"index": 4337,
"step-1": "<mask token>\n\n\nclass BaseDataClass:\n\n def _create_insert_query(self):\n column_names = ''\n row_values = ''\n values = []\n for column_name, row_value in self.__dict__.items():\n if co... | [
6,
12,
18,
19,
20
] |
offset = input()
cal = 1030 + int(offset) * 100
if 0 < cal < 2400:
print('Tuesday')
elif cal < 0:
print('Monday')
else:
print('Wednesday')
| normal | {
"blob_id": "aefb49410e077180a660d17c4c646265a75969a7",
"index": 7509,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif 0 < cal < 2400:\n print('Tuesday')\nelif cal < 0:\n print('Monday')\nelse:\n print('Wednesday')\n",
"step-3": "offset = input()\ncal = 1030 + int(offset) * 100\nif 0 < cal <... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def bubble_sort(arr):
for i in range(1, len(arr)):
for j in range(0, len(arr) - i):
if arr[j] > arr[j + 1]:
tmp = arr[j]
arr[j] = arr[j + 1]
arr[j + 1] = tmp
return arr
<|reserved_s... | flexible | {
"blob_id": "6682c864a3da6f2c894a3a40359726b4eb97d040",
"index": 6109,
"step-1": "<mask token>\n",
"step-2": "def bubble_sort(arr):\n for i in range(1, len(arr)):\n for j in range(0, len(arr) - i):\n if arr[j] > arr[j + 1]:\n tmp = arr[j]\n arr[j] = arr[j + 1]... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
urlpatterns += staticfiles_urlpatterns()
<|reserved_special_token_1|>
<|reserved_special_token_0|>
appname = 'home'
urlpatterns = [path('', views.home, name='home')]
urlpatterns += staticfiles_urlpatterns()
<|reserved_special... | flexible | {
"blob_id": "dd23cd068eea570fc187dad2d49b30376fbd4854",
"index": 4856,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns += staticfiles_urlpatterns()\n",
"step-3": "<mask token>\nappname = 'home'\nurlpatterns = [path('', views.home, name='home')]\nurlpatterns += staticfiles_urlpatterns()\n",
... | [
0,
1,
2,
3,
4
] |
from collections import namedtuple
import argparse
import pdb
import traceback
import sys
import os
from qca_hex_analyzer import WmiCtrlAnalyzer, HtcCtrlAnalyzer, HttAnalyzer, AllAnalyzer
import hexfilter
description = \
"Tool used to analyze hexdumps produced by a qca wireless kernel " \
"driver (such as ath... | normal | {
"blob_id": "3b381668dbb9b4e5a2e323dc4d6b5e3951736882",
"index": 1804,
"step-1": "<mask token>\n\n\ndef auto_int(x):\n return int(x, 0)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef auto_int(x):\n return int(x, 0)\n\n\ndef load_options():\n global parsed_args\n base_parser = argparse.Argum... | [
1,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
for i in range(1, 11):
km = KMeans(n_clusters=i, init='random', n_init=10, max_iter=300, tol=
0.0001, random_state=0)
km.fit(arr)
distortions.append(km.inertia_)
<|reserved_special_token_0|>
print('The number o... | flexible | {
"blob_id": "09417014963172fc71b4268aafdec1405c04f34d",
"index": 3472,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, 11):\n km = KMeans(n_clusters=i, init='random', n_init=10, max_iter=300, tol=\n 0.0001, random_state=0)\n km.fit(arr)\n distortions.append(km.inertia_)\n... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class CategoryView(View):
"""文章分类页"""
def get(self, request, category_id):
category = Category.objects.get(id=int(category_id))
category_articles = category.article_set.all()
new_articles = category_articles.order_by('-modified_time')
category_hot_... | flexible | {
"blob_id": "2fd40f4d69223933d53d8ed2abd5f6d3ccd2f509",
"index": 3850,
"step-1": "<mask token>\n\n\nclass CategoryView(View):\n \"\"\"文章分类页\"\"\"\n\n def get(self, request, category_id):\n category = Category.objects.get(id=int(category_id))\n category_articles = category.article_set.all()\n ... | [
6,
7,
8,
9,
11
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class Solution:
def rotateRight(self, head: ListNode, k: int) ->ListNode:
if head is None or head.next is None or k == 0:
return head
tmp, length... | flexible | {
"blob_id": "a79c9799ed237a943ae3d249a4d66eb2f8693e83",
"index": 1896,
"step-1": "<mask token>\n",
"step-2": "class Solution:\n <mask token>\n",
"step-3": "class Solution:\n\n def rotateRight(self, head: ListNode, k: int) ->ListNode:\n if head is None or head.next is None or k == 0:\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Hydra(FlaskTopModel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.config['CLIENT_ID'] = 4
self.config['BASE_IMAGE_URL'
] = 'https://static.pharminfo.fr/images/cip/{cip}/{name}.{ext}'
self.config['SQLALC... | flexible | {
"blob_id": "de3a4053b5b0d4d2d5c2dcd317e64cf9b4faeb75",
"index": 562,
"step-1": "<mask token>\n\n\nclass Hydra(FlaskTopModel):\n\n def __init__(self, *args, **kwargs):\n super().__init__(*args, **kwargs)\n self.config['CLIENT_ID'] = 4\n self.config['BASE_IMAGE_URL'\n ] = 'https... | [
3,
6,
7,
8,
9
] |
#!/usr/bin/env python
"""
Main training workflow
"""
from __future__ import division
import os
import time
import glob
import torch
import random
import signal
import argparse
from models.trainer import build_trainer
from models import data_loader, model_builder
from models.pytorch_pretrained_bert.modeling import... | normal | {
"blob_id": "3adb50a6375a73f786369dd22712a657b66f758e",
"index": 8432,
"step-1": "<mask token>\n\n\nclass Running(object):\n <mask token>\n\n def __init__(self, args, device_id):\n \"\"\"\n :param args: parser.parse_args()\n :param device_id: 0 or -1\n \"\"\"\n self.args ... | [
7,
16,
17,
18,
24
] |
from skimage.measure import structural_similarity as ssim
import matplotlib.pyplot as plt
import numpy as np
import cv2
import os
import pathlib
import warnings
from PIL import Image
from numpy import array
source_path = "/home/justin/Desktop/FeatureClustering/"
feature_length = len(os.listdir(source_path))
vector_da... | normal | {
"blob_id": "ff1346060141ee3504aa5ee9de3a6ec196bcc216",
"index": 3918,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor folder in os.listdir(source_path):\n for filename in os.listdir(source_path + folder + '/'):\n if filename != '---.png':\n linename = filename.split('-')\n ... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def generate_random_email_and_password():
"""
Function to generate random email id and password
"""
email = fake.email()
password_string = fake.password()
random_info = {'email': email, 'password': password_string}
return random_info
def generate_random_coupo... | flexible | {
"blob_id": "0dab663847fdb4efa419882519616b7a89d0bbe8",
"index": 1716,
"step-1": "<mask token>\n\n\ndef generate_random_email_and_password():\n \"\"\"\n Function to generate random email id and password\n \"\"\"\n email = fake.email()\n password_string = fake.password()\n random_info = {'email'... | [
4,
7,
8,
9,
11
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
app.config.from_object(config)
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
app = Flask(__name__)
app.config.from_object(config)
queue = Queue()
mq = RabbitMQ(app, queue)
<|reserved_spe... | flexible | {
"blob_id": "ccf9c389a65d1420e87deec2100e37bccdcb5539",
"index": 6323,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp.config.from_object(config)\n<mask token>\n",
"step-3": "<mask token>\napp = Flask(__name__)\napp.config.from_object(config)\nqueue = Queue()\nmq = RabbitMQ(app, queue)\n<mask token>... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def getDepths(imgs, img_names, intersectionCoords, stakeValidity,
templateIntersections, upperBorder, tensors, actualTensors,
intersectionDist, blobDistTemplate, debug, debug_directory, image_dates,
imageSummary):
... | flexible | {
"blob_id": "24a538dcc885b37eb0147a1ee089189f11b20f8a",
"index": 7945,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef getDepths(imgs, img_names, intersectionCoords, stakeValidity,\n templateIntersections, upperBorder, tensors, actualTensors,\n intersectionDist, blobDistTemplate, debug, debu... | [
0,
1,
2,
3
] |
from .dla import get_network as get_dla
from lib.utils.tless import tless_config
_network_factory = {'dla': get_dla}
def get_network(cfg):
arch = cfg.network
heads = cfg.heads
head_conv = cfg.head_conv
num_layers = int(arch[arch.find('_') + 1:]) if '_' in arch else 0
arch = arch[:arch.find('_')] i... | normal | {
"blob_id": "7df94c86ff837acf0f2a78fe1f99919c31bdcb9b",
"index": 4881,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_network(cfg):\n arch = cfg.network\n heads = cfg.heads\n head_conv = cfg.head_conv\n num_layers = int(arch[arch.find('_') + 1:]) if '_' in arch else 0\n arch = ... | [
0,
1,
2,
3
] |
import base64
import string
def hexStringtoBytes(hexstring):
byteArray = bytes.fromhex(hexstring)
return byteArray
def xorBytes(bytes1, bytes2):
xored = bytes([x^bytes2[i] for i,x in enumerate(bytes1)])
return xored
def xorAgainstCharacter(byteArray, character):
str2 = [ord(character)] ... | normal | {
"blob_id": "a32fb683f8d46f901e8dcd2d075ace22ee81e076",
"index": 451,
"step-1": "<mask token>\n\n\ndef hexStringtoBytes(hexstring):\n byteArray = bytes.fromhex(hexstring)\n return byteArray\n\n\ndef xorBytes(bytes1, bytes2):\n xored = bytes([(x ^ bytes2[i]) for i, x in enumerate(bytes1)])\n return xo... | [
3,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
class Vector:
def __init__(self, name, type, url_path):
self._name = name
self._conn = sqlite3.connect(url_path)
self._cur = self._conn.cursor()
self._cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
tables = self._cur.fetchall... | flexible | {
"blob_id": "0a6cb6d3fad09ab7f0e19b6c79965315c0e0d634",
"index": 4793,
"step-1": "<mask token>\n\n\nclass Vector:\n\n def __init__(self, name, type, url_path):\n self._name = name\n self._conn = sqlite3.connect(url_path)\n self._cur = self._conn.cursor()\n self._cur.execute(\"SELEC... | [
3,
6,
8,
9,
10
] |
import sys
from elftools.elf.elffile import ELFFile
from capstone import *
def process_file(filename):
with open(filename, 'rb') as f:
elffile = ELFFile(f)
code = elffile.get_section_by_name('.text')
rodata = elffile.get_section_by_name('.rodata')
plt = elffile.get_section_by_name('... | normal | {
"blob_id": "5bfaadcd54aaf239d0d89158bfb723c0174c56b1",
"index": 9176,
"step-1": "import sys\nfrom elftools.elf.elffile import ELFFile\nfrom capstone import *\n\ndef process_file(filename):\n with open(filename, 'rb') as f:\n elffile = ELFFile(f)\n code = elffile.get_section_by_name('.text')\n ... | [
0
] |
<|reserved_special_token_0|>
def get_mask(mask):
r = mask[:, :, 0]
g = mask[:, :, 1]
return r // (r.max() or 1) * -1 + g // (g.max() or 1)
<|reserved_special_token_0|>
def extend(image, mask):
brightness = calculate_brightness(image)
energy = calculate_energy(brightness)
mult = image.shape... | flexible | {
"blob_id": "7130a382784955780a3f258c81ce05c61915af56",
"index": 5000,
"step-1": "<mask token>\n\n\ndef get_mask(mask):\n r = mask[:, :, 0]\n g = mask[:, :, 1]\n return r // (r.max() or 1) * -1 + g // (g.max() or 1)\n\n\n<mask token>\n\n\ndef extend(image, mask):\n brightness = calculate_brightness(i... | [
3,
6,
7,
9,
10
] |
env = 'DEV' ## this had to be in uppercase
platform = 'hive'
from datahub.emitter.kafka_emitter import DatahubKafkaEmitter, KafkaEmitterConfig
from datahub.emitter.rest_emitter import DatahubRestEmitter
from datahub.ingestion.extractor.schema_util import *
from datahub.metadata.schema_classes import (
DatasetSn... | normal | {
"blob_id": "7ad5e803afa42790e878bfb923eddcfde2d21928",
"index": 1501,
"step-1": "<mask token>\n\n\ndef add_owner_mce(m) ->MetadataChangeEventClass:\n entity = m['Table']\n schema = m['Schema']\n dataset_name = f'{schema}.{entity}'\n owners = [OwnerClass(owner=owner, type=OwnershipTypeClass.DATAOWNER... | [
2,
3,
4,
5,
6
] |
#coding=utf-8
from django.contrib import admin
from models import *
#增加额外的方法
def make_published(modeladmin, request, queryset):
queryset.update(state=1)
class OrderInfoAdmin(admin.ModelAdmin):
list_display = ('ordernum', 'total', 'state')
search_fields = ('total', )
list_filter = ('bpub_date',)
ac... | normal | {
"blob_id": "74a0282495bf4bbd34b397e0922074659a66d6ff",
"index": 4809,
"step-1": "<mask token>\n\n\nclass OrderInfoAdmin(admin.ModelAdmin):\n list_display = 'ordernum', 'total', 'state'\n search_fields = 'total',\n list_filter = 'bpub_date',\n actions = [make_published]\n\n\nclass address_infoAdmin(a... | [
4,
5,
6,
7,
8
] |
# Generated by Django 2.2 on 2020-10-26 15:16
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('viajes', '0001_initial'),
]
operations = [
migrations.AlterModelOptions(
name='viajes',
options={'verbose_name': 'Movilización... | normal | {
"blob_id": "760a5a168575a0ea12b93cb58c1e81e313704e35",
"index": 6276,
"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 = [('viajes', '0... | [
0,
1,
2,
3,
4
] |
#!/bin/env python3
import os
##print(os.environ)
##print("**********************************************************************")
##print("**********************************************************************")
##print("**********************************************************************")
##print(str(os.environ.ge... | normal | {
"blob_id": "b49696d6cac5fbf97172aa7cf16903d002262b5c",
"index": 1940,
"step-1": "<mask token>\n\n\ndef AddOverflow(h):\n nxbins = h.GetXaxis().GetNbins()\n nybins = h.GetYaxis().GetNbins()\n idxx = 0.0\n idxy = nybins + 1\n for ix in range(nxbins):\n idxx = ix + 1\n ovf_bincont = h.... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print('x is {}'.format(x))
print(type(x))
<|reserved_special_token_0|>
print('x is {}'.format(x))
print(type(x))
<|reserved_special_token_1|>
x = 7
x = 7 // 3
<|reserved_special_token_0|>
x = 0.1 + 0.1 + 0.1 - 0.3
print('x is {... | flexible | {
"blob_id": "62a7958ba5ebb6da866d6ef156e52136df22f235",
"index": 107,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('x is {}'.format(x))\nprint(type(x))\n<mask token>\nprint('x is {}'.format(x))\nprint(type(x))\n",
"step-3": "x = 7\nx = 7 // 3\n<mask token>\nx = 0.1 + 0.1 + 0.1 - 0.3\nprint('x i... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class Classifier(nn.Module):
def __init__(self, args, prob=0.5):
super(Classifier, self).__init__()
self.fc1 = nn.Linear(48 * 4 * 4, 100)
self.bn1_fc = nn.BatchNorm1d(100)
self.fc2 = nn.Linear(100, 100)
self.bn2_fc = nn.BatchNorm1d(100)
... | flexible | {
"blob_id": "9140da0b6c04f39a987a177d56321c56c01586e8",
"index": 3739,
"step-1": "<mask token>\n\n\nclass Classifier(nn.Module):\n\n def __init__(self, args, prob=0.5):\n super(Classifier, self).__init__()\n self.fc1 = nn.Linear(48 * 4 * 4, 100)\n self.bn1_fc = nn.BatchNorm1d(100)\n ... | [
5,
7,
8,
10,
11
] |
from django.contrib.auth.models import User
from django.core import validators
from django.db import models
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.contrib.auth.models import Group
from django.conf import settings
@receiver(post_save, sender=settings.AUTH_USER_... | normal | {
"blob_id": "a139042d0c6fa4941b7149a33b0a48018e9f511b",
"index": 9003,
"step-1": "<mask token>\n\n\nclass Category(models.Model):\n \"\"\"Категории\"\"\"\n name = models.CharField('Категория', max_length=150)\n url = models.SlugField(max_length=160, unique=True)\n\n def __str__(self):\n return... | [
8,
9,
10,
14,
15
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
from .game_action_manager import GameActionManager
from .menu_action_manager import OptionsActionManager, CharacterSelectionActionManager, MainMenuActionManager
<|reserved_special_token_1|>
# -*- coding:Utf-8 -*-
from .game_action_manager import GameActi... | flexible | {
"blob_id": "48294209d51fbe4dfb2a5130311a10c8a1dd027c",
"index": 9237,
"step-1": "<mask token>\n",
"step-2": "from .game_action_manager import GameActionManager\nfrom .menu_action_manager import OptionsActionManager, CharacterSelectionActionManager, MainMenuActionManager\n",
"step-3": "# -*- coding:Utf-8 -*-... | [
0,
1,
2
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
seed_everything(12345)
<|reserved_special_token_0|>
if torch.cuda.is_available():
classifier = classifier.cuda()
trainer.fit(classifier, dm)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
seed_everything(12345)
d... | flexible | {
"blob_id": "05ca7bbc3285a9e37921c0e514a2e31b05abe051",
"index": 6396,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nseed_everything(12345)\n<mask token>\nif torch.cuda.is_available():\n classifier = classifier.cuda()\ntrainer.fit(classifier, dm)\n",
"step-3": "<mask token>\nseed_everything(12345)\... | [
0,
1,
2,
3,
4
] |
from card import Card;
from deck import Deck;
import people;
import chip;
import sys;
import time;
def display_instructions() :
print('\nInstructions: The objective of this game is to obtain a hand of cards whose value is as close to 21 ');
print('as possible without going over. The numbered cards hav... | normal | {
"blob_id": "a7050ebd545c4169b481672aed140af610aea997",
"index": 4879,
"step-1": "<mask token>\n\n\ndef create_players(num):\n players_list = []\n for i in range(num):\n name = input(f'Player {i + 1}, what is your name? ')\n while name == '':\n name = input('Please enter your name:... | [
7,
19,
20,
21,
22
] |
<|reserved_special_token_0|>
def callback():
print('callback invoked')
def stopper(loop):
print('stopper invoked')
loop.stop()
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def callback():
print('callback invoked')
def stopper(loop):
print('stopp... | flexible | {
"blob_id": "3b96cc4ef538a06251958495e36fe5dbdf80c13d",
"index": 4952,
"step-1": "<mask token>\n\n\ndef callback():\n print('callback invoked')\n\n\ndef stopper(loop):\n print('stopper invoked')\n loop.stop()\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef callback():\n print('callback invok... | [
2,
3,
4,
5,
6
] |
# #!/usr/bin/python
# last edit abigailc@Actaeon on jan 27 2017
#pulling the taxonomy functions out of makespeciestree because I need to make them faster...
#insects is running for literally >20 hours.
names_file = "/Users/abigailc/Documents/Taxonomy_Stuff/taxdump/names.dmp"
nodes_file = "/Users/abigailc/Documents/... | normal | {
"blob_id": "5c1324207e24f2d723be33175101102bd97fe7a2",
"index": 4860,
"step-1": "<mask token>\n\n\ndef Ret_Sister_Same_Rank(string, nodes_file, names_file):\n print(string)\n interest_taxid = Str_To_Taxid(string, names_file)\n print(interest_taxid)\n up_taxid = Return_Parent(interest_taxid, nodes_fi... | [
2,
15,
18,
21,
27
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def check_p():
import inspect
import re
local_vars = inspect.currentframe().f_back.f_locals
return len(re.findall('p\\s*=\\s*0', str(local_vars))) == 0
<|reserved_special_token_1|>
def check_orthogonal(u, v):
... | flexible | {
"blob_id": "36e538ca7fbdbf6e2e6ca1ae126e4e75940bb5cd",
"index": 4316,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef check_p():\n import inspect\n import re\n local_vars = inspect.currentframe().f_back.f_locals\n return len(re.findall('p\\\\s*=\\\\s*0', str(local_vars))) == 0\n",
"... | [
0,
1,
2,
3
] |
n = 5
a = '1'
if n == 1:
print(a)
else:
for i in range(2, n + 1):
if i == 2:
a = '11'
else:
count = 1
for j in range(len(a) - 1):
if j == len(a) - 2 :
if a[j] == a[j + 1]:
count += 1
... | normal | {
"blob_id": "26a778f16cc50d1a8791fb672fb8907464865f3f",
"index": 1349,
"step-1": "n = 5\na = '1'\nif n == 1:\n print(a)\nelse:\n for i in range(2, n + 1):\n if i == 2:\n a = '11'\n else:\n count = 1\n for j in range(len(a) - 1):\n if j == len(a)... | [
0
] |
# This defines a new interface, called MyClosedInterface
# which is closed (does not allow new members to be added).
# "eci" is the schema id for this extension.
{"fs": { "eci": {
"info": {
"name": "Example closed Interface extension",
"version": "1.0",
"date": "Sept. 22, 2016",
"author": "Jeff Teete... | normal | {
"blob_id": "892f90edbd8bd54841b815a6bc29d136c5e84a38",
"index": 7175,
"step-1": "<mask token>\n",
"step-2": "{'fs': {'eci': {'info': {'name': 'Example closed Interface extension',\n 'version': '1.0', 'date': 'Sept. 22, 2016', 'author': 'Jeff Teeters',\n 'contact': 'jteeters@berkeley.edu', 'description':... | [
0,
1,
2
] |
# coding: utf8
from __future__ import absolute_import
import numpy as np
def arr2str(arr, sep=", ", fmt="{}"):
"""
Make a string from a list seperated by ``sep`` and each item formatted
with ``fmt``.
"""
return sep.join([fmt.format(v) for v in arr])
def indent_wrap(s, indent=0, wrap=80):
"... | normal | {
"blob_id": "3b4799f43ec497978bea3ac7ecf8c6aaeb2180b4",
"index": 3867,
"step-1": "<mask token>\n\n\ndef indent_wrap(s, indent=0, wrap=80):\n \"\"\"\n Wraps and indents a string ``s``.\n\n Parameters\n ----------\n s : str\n The string to wrap.\n indent : int\n How far to indent ea... | [
2,
3,
4,
5,
6
] |
import os
import json
import csv
import re
import requests
import spacy
import nltk
from nltk.parse import CoreNLPParser
from nltk.corpus import stopwords
from nltk.stem import PorterStemmer
stemmer = PorterStemmer()
from time import time
nlp = spacy.load('es_core_news_sm')
from modules_api import conts_log
sw_spanish=... | normal | {
"blob_id": "afb0359f4cdf5ed32bb785d969e9bf8919bb6add",
"index": 3408,
"step-1": "<mask token>\n\n\ndef preprocessing_terms(termlist, lang_in, timeEx, patternBasedClean,\n pluralClean, numbersClean, accentClean):\n date = '2020-06-03'\n print('terms:', termlist)\n print('lang:', lang_in)\n process... | [
8,
9,
10,
13,
14
] |
<|reserved_special_token_0|>
class Chick(Sprite):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class Chick(Sprite):
def on_create(self):
self.image = 'chick-a.png'
self.goto_random_position()
self.opacity = ... | flexible | {
"blob_id": "cc7942c406e9bcb5af43f131fdf0a6441f81c16a",
"index": 4260,
"step-1": "<mask token>\n\n\nclass Chick(Sprite):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Chick(Sprite):\n\n def on_create(self):\n self.image = 'chick-a.png'\n self.goto_random_position()... | [
1,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class Linear(functions.Learn):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class LinearNode(functions.Node):
def __init__(self, in_size, out_size, eps):
super().__init__(Linear(eps))
self.param_name = ['w', 'b']... | flexible | {
"blob_id": "ec9a152e39a0c51319e4db58eea4496cff5b2fd6",
"index": 3427,
"step-1": "<mask token>\n\n\nclass Linear(functions.Learn):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass LinearNode(functions.Node):\n\n def __init__(self, in_size, out_size, eps):\n super().__init__(Linear(eps))... | [
3,
5,
6,
7,
8
] |
from __future__ import print_function
import os, sys, time
import fitz
import PySimpleGUI as sg
"""
PyMuPDF utility
----------------
For a given entry in a page's getImagleList() list, function "recoverpix"
returns either the raw image data, or a modified pixmap if an /SMask entry
exists.
The item's first two entries ... | normal | {
"blob_id": "856afd30a2ed01a1d44bbe91a7b69998e9a51bb7",
"index": 3170,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef recoverpix(doc, item):\n x = item[0]\n s = item[1]\n if s == 0:\n return doc.extractImage(x)\n\n def getimage(pix):\n if pix.colorspace.n != 4:\n ... | [
0,
1,
3,
4,
5
] |
import itertools
from typing import Tuple, List, Dict, Optional, Hashable, Collection
class Hypergraph:
"""
Represents a hypergraph, consisting of nodes, directed edges,
hypernodes (each of which is a set of nodes) and hyperedges (directed edges
from hypernodes to hypernodes). Contains functionality to... | normal | {
"blob_id": "4a3611ecd70d80575f9f68bf45d67532a17b9c93",
"index": 7527,
"step-1": "<mask token>\n\n\nclass Hypergraph:\n <mask token>\n\n def __init__(self):\n self.nodes = dict()\n self.hypernodes = dict()\n self.adj_out = dict()\n self.adj_in = dict()\n <mask token>\n\n d... | [
8,
10,
15,
16,
20
] |
# 내 풀이
with open("sequence.protein.2.fasta", "w") as fw:
with open("sequence.protein.fasta", "r") as fr:
for line in fr:
fw.write(line)
# 강사님 풀이
# fr = open('sequence.protein.fasta','r'):
# lines=fr.readlines()
# seq_list=list()
# for line in lines:
| normal | {
"blob_id": "84fb0e364ee3cd846148abfc9326f404f008c510",
"index": 7908,
"step-1": "<mask token>\n",
"step-2": "with open('sequence.protein.2.fasta', 'w') as fw:\n with open('sequence.protein.fasta', 'r') as fr:\n for line in fr:\n fw.write(line)\n",
"step-3": "# 내 풀이\nwith open(\"sequence... | [
0,
1,
2
] |
# Copyright 2016 Huawei, Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by appli... | normal | {
"blob_id": "cc9485dea0975a0974f037b129816a9359b2b622",
"index": 2875,
"step-1": "<mask token>\n\n\nclass TestConsoleUrlShow(TestConsole):\n _server = compute_fakes.create_one_server()\n\n def setUp(self):\n super(TestConsoleUrlShow, self).setUp()\n self.sdk_client.find_server.return_value = ... | [
10,
15,
18,
19,
20
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
run_Game('DQN_PER', 'Breakout', lifes=5, episodes=40001)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
from run_AtariGame import run_Game
run_Game('DQN_PER', 'Breakout', lifes=5, episodes=40001)
<|reserved_special... | flexible | {
"blob_id": "f49a133fa94aae791ef0f1eec54cf0629f45a0ed",
"index": 5153,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nrun_Game('DQN_PER', 'Breakout', lifes=5, episodes=40001)\n",
"step-3": "<mask token>\nfrom run_AtariGame import run_Game\nrun_Game('DQN_PER', 'Breakout', lifes=5, episodes=40001)\n",
... | [
0,
1,
2,
3
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.