code stringlengths 13 6.09M | order_type stringclasses 2
values | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
#Displaying multiple images using matplotlib
import pandas as pd
import numpy as np
import cv2
import matplotlib.pyplot as plt
def main():
imgpath1="C:\Shreyas\OpenCv\DIP_OpenCV\lena.png"
imgpath2="C:\Shreyas\OpenCv\DIP_OpenCV\lena.png"
img1=cv2.imread(imgpath1,1)
img2=cv2.imread(imgpath2,... | normal | {
"blob_id": "2867a7b24b4911b2936cb34653fa57431c14d6a3",
"index": 7319,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main():\n imgpath1 = 'C:\\\\Shreyas\\\\OpenCv\\\\DIP_OpenCV\\\\lena.png'\n imgpath2 = 'C:\\\\Shreyas\\\\OpenCv\\\\DIP_OpenCV\\\\lena.png'\n img1 = cv2.imread(imgpath1, 1)... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class UpdateDbDataView(View):
<|reserved_special_token_0|>
def get(self, request, testupdatadb_id):
if request.user.username == 'check':
return render(request, 'canNotAddupdatedbdata.html', {
'django_server_yuming': DJANGO_SERVER_YUMING})
... | flexible | {
"blob_id": "129c7f349e2723d9555da44ae62f7cfb7227b9ae",
"index": 5618,
"step-1": "<mask token>\n\n\nclass UpdateDbDataView(View):\n <mask token>\n\n def get(self, request, testupdatadb_id):\n if request.user.username == 'check':\n return render(request, 'canNotAddupdatedbdata.html', {\n ... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open('chr01.txt') as a:
while 1:
seq = a.read(2)
seq = seq.replace('00', 'c').replace('01', 'g').replace('10', 'a'
).replace('11', 't')
seq2 += seq
if not seq:
break... | flexible | {
"blob_id": "c2f859e0ed0e812768dec04b2b1f9ddd349350f6",
"index": 9780,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open('chr01.txt') as a:\n while 1:\n seq = a.read(2)\n seq = seq.replace('00', 'c').replace('01', 'g').replace('10', 'a'\n ).replace('11', 't')\n s... | [
0,
1,
2,
3
] |
'''
Please Note:
Note: It is intended for some problems to be ambiguous. You should gather all requirements up front before implementing one.
Please think of all the corner cases and clarifications yourself.
Validate if a given string is numeric.
Examples:
1."0" => true
2." 0.1 " => true
3."abc" => false
4."1 a" =>... | normal | {
"blob_id": "50be2cbdaec6ed76e5d9367c6a83222f9153db82",
"index": 7426,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Solution:\n\n def isNumber(self, A):\n while len(A) > 0 and A[0] == ' ':\n ... | [
0,
1,
2,
3,
4
] |
#!/oasis/scratch/csd181/mdburns/python/bin/python
import sys
import pickle
import base64
from process import process
import multiprocessing as mp
EPOCH_LENGTH=.875
EPOCH_OFFSET=.125
NUM_FOLDS=5
if __name__ == "__main__":
mp.freeze_support()
p= mp.Pool(2)
for instr in sys.stdin:
this_key=''
sys.stderr.wr... | normal | {
"blob_id": "e477a59e86cfeb3f26db1442a05d0052a45c42ff",
"index": 6397,
"step-1": "#!/oasis/scratch/csd181/mdburns/python/bin/python\nimport sys\nimport pickle\nimport base64\nfrom process import process\nimport multiprocessing as mp\n\nEPOCH_LENGTH=.875\nEPOCH_OFFSET=.125\nNUM_FOLDS=5\n\nif __name__ == \"__main_... | [
0
] |
<|reserved_special_token_0|>
def create_backup(ServerName=None, Description=None):
"""
Creates an application-level backup of a server. While the server is BACKING_UP , the server can not be modified and no additional backup can be created.
Backups can be created for RUNNING , HEALTHY and UNHEALTHY server... | flexible | {
"blob_id": "1947bd280234189ed35277c449cd708a204ea7a4",
"index": 6651,
"step-1": "<mask token>\n\n\ndef create_backup(ServerName=None, Description=None):\n \"\"\"\n Creates an application-level backup of a server. While the server is BACKING_UP , the server can not be modified and no additional backup can ... | [
11,
12,
16,
19,
20
] |
from selenium import webdriver
from time import sleep
import os.path
import time
import datetime
driver =webdriver.Chrome(executable_path=r'C:/Users/Pathak/Downloads/chromedriver_win32/chromedriver.exe')
counter=0
while True :
driver.get("https://www.google.co.in/maps/@18.9967228,73.118955,21z/data=!5m1!... | normal | {
"blob_id": "30e7fc169eceb3d8cc1a4fa6bb65d81a4403f2c7",
"index": 5800,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwhile True:\n driver.get(\n 'https://www.google.co.in/maps/@18.9967228,73.118955,21z/data=!5m1!1e1?hl=en&authuser=0'\n )\n start = 'C://Users//Pathak//Downloads//chrom... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@register.filter(name='range')
def filter_range(start, end=None):
if end is None:
return range(start)
else:
return range(start, end)
<|reserved_special_token_1|>
<|reserved_special_token_0|>
register =... | flexible | {
"blob_id": "f733885eed5d1cbf6e49db0997655ad627c9d795",
"index": 599,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@register.filter(name='range')\ndef filter_range(start, end=None):\n if end is None:\n return range(start)\n else:\n return range(start, end)\n",
"step-3": "<mask... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def get_lp(s):
"""gets latest prices from google"""
sl = []
for stock in s.symbols:
quote = get(stock, 'LON')
x = quote.replace(',', '')
x = float(x)
sl.append(x)
return sl
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def g... | flexible | {
"blob_id": "7247ef463998f6738c21ad8efa988a32f7fb99c0",
"index": 4760,
"step-1": "<mask token>\n\n\ndef get_lp(s):\n \"\"\"gets latest prices from google\"\"\"\n sl = []\n for stock in s.symbols:\n quote = get(stock, 'LON')\n x = quote.replace(',', '')\n x = float(x)\n sl.app... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class GameMap(list):
<|reserved_special_token_0|>
def __init__(self):
super().__init__()
self.xmax = 5
self.ymax = 5
self.__nb_elephants = 0
self.__nb_rhinoceros = 0
self.nb_boulders = 0
self.nb_crosses = 0
self.play... | flexible | {
"blob_id": "7cb75195df567a5b65fe2385423b0082f3b9de4b",
"index": 1051,
"step-1": "<mask token>\n\n\nclass GameMap(list):\n <mask token>\n\n def __init__(self):\n super().__init__()\n self.xmax = 5\n self.ymax = 5\n self.__nb_elephants = 0\n self.__nb_rhinoceros = 0\n ... | [
8,
9,
11,
15,
18
] |
#################################################
### THIS FILE WAS AUTOGENERATED! DO NOT EDIT! ###
#################################################
# file to edit: dev_nb/10_DogcatcherFlatten.ipynb
import pandas as pd
import argparse
import csv
import os
import numpy as np
import string
def FivePrimeArea(df):
... | normal | {
"blob_id": "5c5922fd3a7a5eec121d94e69bc972089e435175",
"index": 9406,
"step-1": "<mask token>\n\n\ndef FivePrimeArea(df):\n df = df.sort_values(by=['chr', 'end'], ascending=True)\n df['FA_start'] = df['gene_start']\n df_exon = df[df['type'] == 'exon'].copy()\n df_exon = df_exon.drop_duplicates(subse... | [
4,
6,
8,
9,
11
] |
from django.urls import path
from django.contrib.auth import views as auth_views
from . views import register, channel
urlpatterns = [
path('register/', register, name="register"),
path('channel/', channel, name="channel"),
path('login/', auth_views.LoginView.as_view(template_name='user/login.html'), name... | normal | {
"blob_id": "d76c1507594bb0c1ed7a83e6c5961097c7fbf54a",
"index": 9859,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = [path('register/', register, name='register'), path(\n 'channel/', channel, name='channel'), path('login/', auth_views.\n LoginView.as_view(template_name='user/login.h... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Register(decompil.ir.Register):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class BaseDecoder:
name = None
opcode = Non... | flexible | {
"blob_id": "865d7c606b287dbce158f721c6cf768cd078eb48",
"index": 9231,
"step-1": "<mask token>\n\n\nclass Register(decompil.ir.Register):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass BaseDecoder:\n name = None\n opcode = None\n op... | [
18,
24,
25,
29,
33
] |
from __future__ import division
import re
import sys
import six
from six.moves import queue
import os
import io
from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types
from google.cloud import speech as speech1
from google.cloud.speech import enums as enums2
fr... | normal | {
"blob_id": "6868a8b5d36403f1417301acdca5f5dc9e45c682",
"index": 9849,
"step-1": "<mask token>\n\n\nclass Google_Cloud:\n <mask token>\n\n def sentiment(self):\n google_sentiment = self.client.analyze_sentiment(self.document\n ).document_sentiment\n sent = {}\n sent['sentime... | [
7,
8,
10,
11,
14
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(A.upper() + ' World!')
<|reserved_special_token_1|>
A = input('입력해주세요.\n')
print(A.upper() + ' World!')
<|reserved_special_token_1|>
A = input("입력해주세요.\n") #입력값을 in_AAA로 칭한다
#\n은 문법의 줄... | flexible | {
"blob_id": "8a54a71b08d10c5da9ca440e8e4f61f908e00d54",
"index": 9496,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(A.upper() + ' World!')\n",
"step-3": "A = input('입력해주세요.\\n')\nprint(A.upper() + ' World!')\n",
"step-4": "A = input(\"입력해주세요.\\n\") #입력값을 in_AAA로 칭한다\r\n ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
app_name = 'core'
urlpatterns = [path('', views.index, name='home'), path(
'property_for_rent/', views.propertyForRent, name='property_rent'),
path('property_for_sale/', views.propertyForSale, name='property_sale'),
pa... | flexible | {
"blob_id": "e2671911894871c32ad933fde8e05c913a4cc942",
"index": 7149,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp_name = 'core'\nurlpatterns = [path('', views.index, name='home'), path(\n 'property_for_rent/', views.propertyForRent, name='property_rent'),\n path('property_for_sale/', views.... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def inicio():
global P, M, G, en
B1 = Button(ventana, text='CAJAS PEQUEÑAS', command=A, state='normal',
bg='yellow').grid(column=1, row=1)
B2 = Button(ventana, text='CAJAS MEDIANAS', command=B, state='normal',
bg='orange').grid(column=2, row=1)
B3 = Button(... | flexible | {
"blob_id": "393af07fa7a5c265dbdd3047ef33a77130edf259",
"index": 1915,
"step-1": "<mask token>\n\n\ndef inicio():\n global P, M, G, en\n B1 = Button(ventana, text='CAJAS PEQUEÑAS', command=A, state='normal',\n bg='yellow').grid(column=1, row=1)\n B2 = Button(ventana, text='CAJAS MEDIANAS', comman... | [
5,
6,
7,
8,
9
] |
# Complete the hurdleRace function below.
def hurdleRace(k, height):
if k < max(height):
return max(height) - k
return 0
print(hurdleRace(2, [2,5,4,5,2]))
| normal | {
"blob_id": "c139cbc3e693d75ad196e10257ff3028aa835709",
"index": 428,
"step-1": "<mask token>\n",
"step-2": "def hurdleRace(k, height):\n if k < max(height):\n return max(height) - k\n return 0\n\n\n<mask token>\n",
"step-3": "def hurdleRace(k, height):\n if k < max(height):\n return m... | [
0,
1,
2,
3
] |
x = 5
print(x , " "*3 , "5")
print("{:20d}".format(x))
| normal | {
"blob_id": "88542a18d98a215f58333f5dd2bf5c4b0d37f32f",
"index": 5539,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(x, ' ' * 3, '5')\nprint('{:20d}'.format(x))\n",
"step-3": "x = 5\nprint(x, ' ' * 3, '5')\nprint('{:20d}'.format(x))\n",
"step-4": "x = 5\nprint(x , \" \"*3 , \"5\")\nprint(\"{:2... | [
0,
1,
2,
3
] |
# 5/1/2020
# Import median function from numpy
import numpy as np
from numpy import median
# Plot the median number of absences instead of the mean
sns.catplot(x="romantic", y="absences",
data=student_data,
kind="point",
hue="school",
ci=None,
estimator = median)
# S... | normal | {
"blob_id": "11072601e31ceba13f8adf6c070f84ca5add35e9",
"index": 3300,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsns.catplot(x='romantic', y='absences', data=student_data, kind='point',\n hue='school', ci=None, estimator=median)\nplt.show()\n",
"step-3": "import numpy as np\nfrom numpy import m... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def convert_to_bs(ad_date):
date_components = decompose_date(ad_date)
year, month, day = date_components
bs_year, bs_month, bs_day = _ad_to_bs(year, month, day)
formatted_date = '{}-{:02}-{:02}'.format(bs_year, bs_month, bs_day)
return formatted_date
<|reserved_speci... | flexible | {
"blob_id": "e7295336a168aa2361a9090e79465eab5f564599",
"index": 5076,
"step-1": "<mask token>\n\n\ndef convert_to_bs(ad_date):\n date_components = decompose_date(ad_date)\n year, month, day = date_components\n bs_year, bs_month, bs_day = _ad_to_bs(year, month, day)\n formatted_date = '{}-{:02}-{:02}... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
GPIO.setmode(GPIO.BCM)
<|reserved_special_token_0|>
for x in range(len(pins)):
GPIO.setup(pins[x], GPIO.IN, pull_up_down=GPIO.PUD_UP)
while True:
input_state = 0
for i in range(len(pins)):
input_state = GPIO.in... | flexible | {
"blob_id": "d292de887c427e3a1b95d13cef17de1804f8f9ee",
"index": 6535,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nGPIO.setmode(GPIO.BCM)\n<mask token>\nfor x in range(len(pins)):\n GPIO.setup(pins[x], GPIO.IN, pull_up_down=GPIO.PUD_UP)\nwhile True:\n input_state = 0\n for i in range(len(pins... | [
0,
1,
2,
3,
4
] |
#!/usr/bin/env python3
# given a set A and n other sets.
# find whether set A is a strict superset of each of the n sets
# print True if yes, otherwise False
A = set(map(int, input().split()))
b = []
for _ in range(int(input())):
b.append(A > set(map(int, input().split())))
print(all(b))
| normal | {
"blob_id": "a9eb2b3f26396918c792de3f126e51bde334b709",
"index": 7777,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor _ in range(int(input())):\n b.append(A > set(map(int, input().split())))\nprint(all(b))\n",
"step-3": "A = set(map(int, input().split()))\nb = []\nfor _ in range(int(input())):\n... | [
0,
1,
2,
3
] |
from boa3.builtin import public
@public
def Main() ->int:
a = 'just a test'
return len(a)
| normal | {
"blob_id": "e44e19dbeb6e1e346ca371ca8730f53ee5b95d47",
"index": 5402,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@public\ndef Main() ->int:\n a = 'just a test'\n return len(a)\n",
"step-3": "from boa3.builtin import public\n\n\n@public\ndef Main() ->int:\n a = 'just a test'\n retur... | [
0,
1,
2
] |
<|reserved_special_token_0|>
class CategoryViewSet(viewsets.ModelViewSet):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class CategoryViewSet(viewsets.ModelViewSet):
<|reserved_special_token_0|>
... | flexible | {
"blob_id": "5723e7889663142832a8131bb5f4c35d29692a49",
"index": 6325,
"step-1": "<mask token>\n\n\nclass CategoryViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass CategoryViewSet(viewsets.ModelViewSet):\n <mask token>\n <mask tok... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
with open(file_name, 'a') as file_object:
json.dump(favourite_number, file_object)
print(f'{favourite_number} is saved in {file_name}')
<|reserved_special_token_1|>
<|reserved_special_token_0|>
file_name = 'supporting_files... | flexible | {
"blob_id": "7a359d4b31bd1fd35cd1a9a1de4cbf4635e23def",
"index": 7932,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nwith open(file_name, 'a') as file_object:\n json.dump(favourite_number, file_object)\nprint(f'{favourite_number} is saved in {file_name}')\n",
"step-3": "<mask token>\nfile_name = 's... | [
0,
1,
2,
3,
4
] |
# Дано натуральное число. Требуется определить,
# является ли год с данным номером високосным.
# Если год является високосным, то выведите `YES`, иначе выведите `NO`.
# Напомним, что в соответствии с григорианским календарем, год является високосным,
# если его номер кратен 4, но не кратен 100, а также если он кратен 4... | normal | {
"blob_id": "99e6e734c7d638e3cf4d50d9605c99d5e700e82a",
"index": 1699,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif year % 4 == 0 and not year % 100 == 0:\n print('YES')\nelif year % 400 == 0:\n print('yes')\nelse:\n print('NO')\n",
"step-3": "year = int(input('введите год '))\nif year % ... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
class Task:
<|reserved_special_token_0|>
def set_ready(self, ready: float) ->None:
self._ready = ready
<|reserved_special_token_0|>
def __call__(self) ->None:
self._f()
<|reserved_special_token_0|>
def __str__(self):
return 'Task(' + str(... | flexible | {
"blob_id": "b094693b11fdc4f5fbff30e79a9f82d40104611d",
"index": 2697,
"step-1": "<mask token>\n\n\nclass Task:\n <mask token>\n\n def set_ready(self, ready: float) ->None:\n self._ready = ready\n <mask token>\n\n def __call__(self) ->None:\n self._f()\n <mask token>\n\n def __str... | [
4,
5,
6,
7,
9
] |
import sys
from ulang.runtime.main import main
main(sys.argv)
| normal | {
"blob_id": "e0c5498d9b18a6a32fcd2725ef4f6a1adaef6c68",
"index": 2098,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmain(sys.argv)\n",
"step-3": "import sys\nfrom ulang.runtime.main import main\nmain(sys.argv)\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
<|reserved_special_token_0|>
def get_cosinus_simularity(tf_idf_map, key_words):
sum_common_terms = 0
sum_tf_idf_terms = 0
for term in tf_idf_map:
if term in key_words:
sum_common_terms += tf_idf_map[term]
sum_tf_idf_terms += math.pow(tf_idf_map[term], 2)
cosinus_similarity ... | flexible | {
"blob_id": "39197b3f9f85d94457584d7e488ca376e52207f1",
"index": 5832,
"step-1": "<mask token>\n\n\ndef get_cosinus_simularity(tf_idf_map, key_words):\n sum_common_terms = 0\n sum_tf_idf_terms = 0\n for term in tf_idf_map:\n if term in key_words:\n sum_common_terms += tf_idf_map[term]\... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class SparkFinSpace(FinSpace):
import pyspark
<|reserved_special_token_0|>
def upload_dataframe(self, data_frame: pyspark.sql.dataframe.DataFrame):
resp = self.client.get_user_ingestion_info()
upload_location = resp['ingestionPath']
data_frame.write.pa... | flexible | {
"blob_id": "4f4af4caf81397542e9cd94c50b54303e2f81881",
"index": 3926,
"step-1": "<mask token>\n\n\nclass SparkFinSpace(FinSpace):\n import pyspark\n <mask token>\n\n def upload_dataframe(self, data_frame: pyspark.sql.dataframe.DataFrame):\n resp = self.client.get_user_ingestion_info()\n u... | [
3,
5,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def isValid(s):
if not s:
return True
x = Counter(s)
print(x)
first_c = x.pop(s[0])
cnt = 0
for k, c in x.items():
if c != first_c:
if first_c == 1:
cnt += 1
... | flexible | {
"blob_id": "760daa908ca92e7fb1393bdf28fee086dc1648ef",
"index": 6418,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef isValid(s):\n if not s:\n return True\n x = Counter(s)\n print(x)\n first_c = x.pop(s[0])\n cnt = 0\n for k, c in x.items():\n if c != first_c:\n ... | [
0,
1,
2,
3,
4
] |
class ListNode:
def __init__(self, value = 0, next = None):
self.value = value
self.next = next
def count(node: ListNode) -> int:
if node is None:
return 0
else:
return count(node.next) + 1
# Test Cases
LL1 = ListNode(1, ListNode(4, ListNode(5)))
print(count(None)) # 0
print(co... | normal | {
"blob_id": "8c6169bd812a5f34693b12ce2c886969542f1ab8",
"index": 2352,
"step-1": "class ListNode:\n\n def __init__(self, value=0, next=None):\n self.value = value\n self.next = next\n\n\n<mask token>\n",
"step-2": "class ListNode:\n\n def __init__(self, value=0, next=None):\n self.va... | [
2,
3,
4,
5,
6
] |
class GameOfLife:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_1|>
class GameOfLife:
@staticmethod
def simulate(board):
for row in range(len(board)):
for col in range(len(board[0])):
ones = Gam... | flexible | {
"blob_id": "862c5794a4da794678de419f053ae15b11bca6e7",
"index": 7453,
"step-1": "class GameOfLife:\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "class GameOfLife:\n\n @staticmethod\n def simulate(board):\n for row in range(len(board)):\n for col in range(len(boar... | [
1,
2,
3,
4
] |
from collections import Counter
from docx import Document
import docx2txt
plain_text = docx2txt.process("kashmiri.docx")
list_of_words = plain_text.split()
#print(Counter(list_of_words))
counter_list_of_words = Counter(list_of_words)
elements = counter_list_of_words.items()
# for a, b in sorted(elements, key=lambda x:... | normal | {
"blob_id": "9ad36f157abae849a1550cb96e650746d57f491d",
"index": 9732,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor word, frequency in sorted(elements, key=lambda x: x[1], reverse=True):\n cell = table.add_row().cells\n cell[0].text = str(word)\n cell[1].text = str(frequency)\ndoc.save('re... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def parsing_ethernet_header(data):
ethernet_header = struct.unpack('!6c6c2s', data)
ether_dest = convert_ethernet_address(ethernet_header[0:6])
ether_src = convert_ethernet_address(ethernet_header[6:12])
ip_header = '0x' + ethernet_header[12].hex()
print('=========ethe... | flexible | {
"blob_id": "9b715fb95e89804a57ea77a98face673b57220c6",
"index": 4494,
"step-1": "<mask token>\n\n\ndef parsing_ethernet_header(data):\n ethernet_header = struct.unpack('!6c6c2s', data)\n ether_dest = convert_ethernet_address(ethernet_header[0:6])\n ether_src = convert_ethernet_address(ethernet_header[6... | [
7,
8,
9,
10,
11
] |
<|reserved_special_token_0|>
def main():
daily_signal_checker('china_stocks.csv', location='chineseStocks/')
<|reserved_special_token_0|>
def daily_signal_checker(stocks, location):
ndays = 6
stock_list = pd.read_csv(stocks)
for code in stock_list['Code']:
tmp = backtest_database(code, '20... | flexible | {
"blob_id": "8d5e652fda3fb172e6faab4153bca8f78c114cd1",
"index": 7973,
"step-1": "<mask token>\n\n\ndef main():\n daily_signal_checker('china_stocks.csv', location='chineseStocks/')\n\n\n<mask token>\n\n\ndef daily_signal_checker(stocks, location):\n ndays = 6\n stock_list = pd.read_csv(stocks)\n for... | [
3,
4,
6,
7,
8
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def somaSerie(valor):
soma = 0
for i in range(valor):
soma += (i ** 2 + 1) / (i + 3)
return soma
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def somaSerie(valor):
soma = 0
for i in range(valor):
soma += (... | flexible | {
"blob_id": "8114d8162bab625854804d1df2b4a9c11818d35e",
"index": 3747,
"step-1": "<mask token>\n",
"step-2": "def somaSerie(valor):\n soma = 0\n for i in range(valor):\n soma += (i ** 2 + 1) / (i + 3)\n return soma\n\n\n<mask token>\n",
"step-3": "def somaSerie(valor):\n soma = 0\n for ... | [
0,
1,
2,
3,
4
] |
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
n=int(input("Enter the number of votes : "))
print()
p... | normal | {
"blob_id": "0e2b4e8e8c5a728e5123dfa704007b0f6adaf1e1",
"index": 4561,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint()\n<mask token>\ndriver.get('https://strawpoll.com/jhzd6qwjw')\nfor i in range(0, n + 1):\n driver.delete_all_cookies()\n try:\n button = WebDriverWait(driver, 10).unti... | [
0,
1,
2,
3,
4
] |
import random
import copy
random.seed(42)
import csv
import torch
import time
import statistics
import wandb
from model import Net, LinearRegression, LogisticRegression
def byGuide(data, val=None, test=None):
val_guides = val
if val == None:
val_guides = [
"GGGTGGGGGGAGTTTGCTCCTGG",
"GA... | normal | {
"blob_id": "a0059563b2eed4ca185a8e0971e8e0c80f5fb8f8",
"index": 6668,
"step-1": "<mask token>\n\n\ndef byGuide(data, val=None, test=None):\n val_guides = val\n if val == None:\n val_guides = ['GGGTGGGGGGAGTTTGCTCCTGG', 'GACCCCCTCCACCCCGCCTCCGG',\n 'GGCCTCCCCAAAGCCTGGCCAGG', 'GAACACAAAGCA... | [
15,
16,
19,
21,
24
] |
# BotSetup.py
from websockets.exceptions import InvalidStatusCode
from dokbot.DokBotCog import DokBotCog
from events.EventCog import EventCog
from dotenv import load_dotenv
from datetime import datetime
from .DokBot import DokBot
import utils.Logger as Log
import logging
import os
import sys
import traceback
import di... | normal | {
"blob_id": "a7123fa221555b15162dbab0d93a86965190b805",
"index": 4141,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef run() ->None:\n os.environ['TZ'] = 'Europe/Brussels'\n if sys.platform != 'win32':\n from time import tzset\n tzset()\n print(datetime.now())\n load_dote... | [
0,
1,
2,
3
] |
import time
import torch
from torch.utils.data import DataLoader
from nn_model import NNModel
def train(dataset: 'Dataset', epochs: int=10):
loader = DataLoader(dataset, batch_size=2, shuffle=True)
model = NNModel(n_input=2, n_output=3)
# model.to(device='cpu')
optimizer = torch.optim.Adam(model.p... | normal | {
"blob_id": "68bcb76a9c736e21cc1f54c6343c72b11e575b5d",
"index": 5093,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef train(dataset: 'Dataset', epochs: int=10):\n loader = DataLoader(dataset, batch_size=2, shuffle=True)\n model = NNModel(n_input=2, n_output=3)\n optimizer = torch.optim.A... | [
0,
1,
2,
3
] |
# Generated by Django 2.1.2 on 2018-10-26 05:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('candidate', '0004_remove_candidate_corrected_loc'),
]
operations = [
migrations.AlterField(
model_name='candidate',
... | normal | {
"blob_id": "eb75f6e959e9153e6588a0322d1ebc75e21e73ef",
"index": 8153,
"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 = [('candidate',... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@pytest.fixture(scope='session')
def my_setup(request):
print('\nDoing setup')
def fin():
print('\nDoing teardown')
if os.path.exists(test_generated_dir):
rmtree(test_generated_dir)
k... | flexible | {
"blob_id": "7ff029e2f0054146e438f4e4f13269e83e28c469",
"index": 8727,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.fixture(scope='session')\ndef my_setup(request):\n print('\\nDoing setup')\n\n def fin():\n print('\\nDoing teardown')\n if os.path.exists(test_generated_d... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class RectInsetTest(TestCase):
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
class RectCloneAndMagic(TestCase):
def test_clone_and_compare(self):
rect1 = Rect(left=10, bottom=30, width=100... | flexible | {
"blob_id": "ff65e92699c6c9379ac40397b3318c3f6bf7d49a",
"index": 3720,
"step-1": "<mask token>\n\n\nclass RectInsetTest(TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\nclass RectCloneAndMagic(TestCase):\n\n def test_clone_and_compare(self):\n rect1 = Rect(left=10... | [
4,
15,
19,
20,
23
] |
<|reserved_special_token_0|>
class RandomProjectionsFeature(PipelineNode):
<|reserved_special_token_0|>
def get_dtype(self):
return self._dtype
<|reserved_special_token_0|>
class RandomProjectionsEnergyFeature(PipelineNode):
def __init__(self, recording, name='random_projections_energy_fea... | flexible | {
"blob_id": "6fe22b3f98bff1a9b775fce631ae94a4ee22b04c",
"index": 4371,
"step-1": "<mask token>\n\n\nclass RandomProjectionsFeature(PipelineNode):\n <mask token>\n\n def get_dtype(self):\n return self._dtype\n <mask token>\n\n\nclass RandomProjectionsEnergyFeature(PipelineNode):\n\n def __init_... | [
22,
24,
28,
31,
40
] |
from sklearn.preprocessing import LabelEncoder
from sklearn.model_selection import train_test_split
from sklearn.model_selection import StratifiedShuffleSplit
from sklearn.metrics import classification_report
from BlogTutorials.pyimagesearch.preprocessing.imagetoarraypreprocessor import ImageToArrayPreprocessor
from Bl... | normal | {
"blob_id": "28cdb59e97f3052dd80f8437574f9ffe09fc1e84",
"index": 6690,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nle.fit(labels)\n<mask token>\nprint('[info] compile model...')\n<mask token>\nmodel.compile(loss='categorical_crossentropy', optimizer=opt, metrics=[\n 'accuracy'])\n<mask token>\nprin... | [
0,
1,
2,
3,
4
] |
class Solution(object):
def twoSum(self, numbers, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
idx1 = 0
idx2 = len(numbers)-1
while(idx1<idx2): # can also use a for-loop: for num in numbers:
left = numbers[id... | normal | {
"blob_id": "51b3beee8659bccee0fbb64b80fdce18b693674b",
"index": 9481,
"step-1": "<mask token>\n",
"step-2": "class Solution(object):\n <mask token>\n",
"step-3": "class Solution(object):\n\n def twoSum(self, numbers, target):\n \"\"\"\n :type nums: List[int]\n :type target: int\n ... | [
0,
1,
2,
3
] |
import unittest
import subprocess
import tempfile
import os
import filecmp
import shutil
import cfg
import utils
class TestFunctionalHumannEndtoEndBiom(unittest.TestCase):
"""
Test humann with end to end functional tests
"""
def test_humann_fastq_biom_output(self):
"""
Test the standa... | normal | {
"blob_id": "27702f72ae147c435617acaab7dd7e5a5a737b13",
"index": 8152,
"step-1": "<mask token>\n\n\nclass TestFunctionalHumannEndtoEndBiom(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def test_humann_gene_families_biom_input(self):\n \"\"\"\n Test the standard hu... | [
2,
4,
5,
6,
7
] |
import os
import sys
import logging.config
import sqlalchemy as sql
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Float, String, Text, Integer
import pandas as pd
import numpy as np
sys.path.append('./config')
import config
logging.basicC... | normal | {
"blob_id": "76f2312a01bf8475220a9fcc16209faddfccd2ae",
"index": 9754,
"step-1": "<mask token>\n\n\nclass BeanAttributes(Base):\n \"\"\" Defines the data model for the table `bean_attributes`. \"\"\"\n __tablename__ = 'bean_attributes'\n id = Column(Integer, primary_key=True)\n species = Column(Strin... | [
5,
6,
7,
8,
9
] |
#!/usr/bin/env pybricks-micropython
from pybricks import ev3brick as brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import (Port, Stop, Direction, Button, Color,
... | normal | {
"blob_id": "f6ebc3c37a69e5ec49d91609db394eec4a94cedf",
"index": 9982,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nbrick.sound.beep()\nwait(1000)\nmotor_a.run_target(500, 720)\nwait(1000)\nbrick.sound.beep(1000, 500)\n",
"step-3": "<mask token>\nmotor_a = Motor(Port.A)\nbrick.sound.beep()\nwait(1000... | [
0,
1,
2,
3,
4
] |
from django.db import models
# Create your models here.
class Pastebin(models.Model):
name= models.CharField(max_length=30)
textpaste = models.CharField(max_length=80)
pasteurl = models.AutoField(primary_key=True)
def __str__(self):
return self.name
| normal | {
"blob_id": "3badf65a5301cc9cf26811e3989631aec5d31910",
"index": 2709,
"step-1": "<mask token>\n\n\nclass Pastebin(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Pastebin(models.Model):\n <mask token>\n <mask token>\n <mask... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class MultinomialNB:
<|reserved_special_token_0|>
def fit(self, X, y):
X_separated_by_class = [[x for x, t in zip(X, y) if t == c] for c in
np.unique(y)]
self.n_classes = len(np.unique(y))
prior_numerator = [len(x) for x in X_separated_by_class... | flexible | {
"blob_id": "5dfe86d654e4184bab4401f8b634326996e42e9c",
"index": 2646,
"step-1": "<mask token>\n\n\nclass MultinomialNB:\n <mask token>\n\n def fit(self, X, y):\n X_separated_by_class = [[x for x, t in zip(X, y) if t == c] for c in\n np.unique(y)]\n self.n_classes = len(np.unique(y... | [
8,
9,
14,
15,
16
] |
"""Config for a linear regression model evaluated on a diabetes dataset."""
from dbispipeline.evaluators import GridEvaluator
import dbispipeline.result_handlers as result_handlers
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from nlp4musa2020.dataloaders.alf200k import ALF200... | normal | {
"blob_id": "473c653da54ebdb7fe8a9eefc166cab167f43357",
"index": 3994,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndataloader = ALF200KLoader(path='data/processed/dataset-lfm-genres.pickle',\n load_feature_groups=['rhymes', 'statistical', 'statistical_time',\n 'explicitness', 'audio'], text_vect... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
def spConfig():
return saml2.config.Config()
def saml_client():
saml2_config_default = {'entityid': absolute_url(), 'service': {'sp': {
'endpoints': {'assertion_consumer_service': [(absolute_url(
'/auth/saml'), saml2.BINDING_HTTP_POST)]}}}}
spConfig().load(de... | flexible | {
"blob_id": "b233d212f3a6c453786dc54b2d43578e1faae417",
"index": 7292,
"step-1": "<mask token>\n\n\ndef spConfig():\n return saml2.config.Config()\n\n\ndef saml_client():\n saml2_config_default = {'entityid': absolute_url(), 'service': {'sp': {\n 'endpoints': {'assertion_consumer_service': [(absolut... | [
4,
5,
6,
7,
8
] |
fileName = str(input("Please write the name of the file you would like to open: "))
file_handle = open(fileName, "w")
contents = str(input("Please write the content you would like to save."))
file_handle.write(contents)
file_handle.close()
print(contents) | normal | {
"blob_id": "aed09a3c04f284fa0b8844a47c5bc9d1621a9b5f",
"index": 2034,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfile_handle.write(contents)\nfile_handle.close()\nprint(contents)\n",
"step-3": "fileName = str(input(\n 'Please write the name of the file you would like to open: '))\nfile_handle =... | [
0,
1,
2,
3
] |
__author__ = 'Orka'
from movie_list import MovieList
from movie_random import MovieRandom
from remove_chosen_movie_from_list import RemoveChosenMovieFromList
from save_list_to_CSV import SaveListToCSV
from length_limit import LengthLimit
file_name = 'cinema.csv'
function = 'r+'
filename_save = 'cinema.csv'
f... | normal | {
"blob_id": "e35a106a3852a7a004fdae6819d4075e1fe929d6",
"index": 4373,
"step-1": "<mask token>\n\n\nclass LaunchMovieLottery(object):\n <mask token>\n\n def movie_list(self):\n movie_list = MovieList(file_name, function)\n self.return_movie_list = movie_list.return_movie_list()\n self.... | [
5,
6,
7,
8,
9
] |
import pandas as pd
import numpy as np
import geopandas as gp
from sys import argv
import os
import subprocess
n, e, s, w = map(int, argv[1:5])
output_dir = argv[5]
print(f'{(n, e, s, w)=}')
for lat in range(s, n + 1):
for lon in range(w, e + 1):
latdir = 'n' if lat >= 0 else 's'
londir = 'e' if ... | normal | {
"blob_id": "9f36b846619ca242426041f577ab7d9e4dad6a43",
"index": 3797,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(f'(n, e, s, w)={n, e, s, w!r}')\nfor lat in range(s, n + 1):\n for lon in range(w, e + 1):\n latdir = 'n' if lat >= 0 else 's'\n londir = 'e' if lon >= 0 else 'w'\n... | [
0,
1,
2,
3,
4
] |
<|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": "39ac4e0d543048ea02123baa39b6c8ce7618d16b",
"index": 6802,
"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', '002... | [
0,
1,
2,
3,
4
] |
<|reserved_special_token_0|>
class LanguageDefinition:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
@staticmethod
def create_project_files(project_path: str, added_file_paths: List[str]
=None) ->str:
"""
Create supporting project files for a translated file.
... | flexible | {
"blob_id": "672add6aa05e21d3605c05a23ff86281ffc3b17c",
"index": 9827,
"step-1": "<mask token>\n\n\nclass LanguageDefinition:\n <mask token>\n <mask token>\n\n @staticmethod\n def create_project_files(project_path: str, added_file_paths: List[str]\n =None) ->str:\n \"\"\"\n Creat... | [
6,
7,
8,
9
] |
#!/usr/bin/python
import sys
import numpy as np
import random
import matplotlib.pyplot as plt
#Your code here
def loadData(fileDj):
data = []
fid = open(fileDj)
for line in fid:
line = line.strip()
m = [float(x) for x in line.split(' ')]
data.append(m)
return data
## K-means... | normal | {
"blob_id": "000dd63089fd0c6184fd032fe75ccc920beee7a8",
"index": 127,
"step-1": "<mask token>\n\n\ndef loadData(fileDj):\n data = []\n fid = open(fileDj)\n for line in fid:\n line = line.strip()\n m = [float(x) for x in line.split(' ')]\n data.append(m)\n return data\n\n\ndef get... | [
9,
10,
12,
13,
14
] |
<|reserved_special_token_0|>
class Node:
<|reserved_special_token_0|>
<|reserved_special_token_0|>
<|reserved_special_token_0|>
def save_sample(self, val):
if self.file:
self.file.write('{}\n'.format(self.val))
def sample(self, isBurn=False):
if self.observed:
... | flexible | {
"blob_id": "4c5db1af9fd1c9b09f6e64a44d72351807c0f7a5",
"index": 8136,
"step-1": "<mask token>\n\n\nclass Node:\n <mask token>\n <mask token>\n <mask token>\n\n def save_sample(self, val):\n if self.file:\n self.file.write('{}\\n'.format(self.val))\n\n def sample(self, isBurn=Fal... | [
18,
19,
23,
24,
26
] |
import pytest
from debbiedowner import make_it_negative, complain_about
def test_negativity():
assert make_it_negative(8) == -8
assert complain_about('enthusiasm') == "I hate enthusiasm. Totally boring."
def test_easy():
assert 1 == 1
def test_cleverness():
assert make_it_negative(-3) == 3 | normal | {
"blob_id": "e73e40a63b67ee1a6cca53a328af05e3eb3d8519",
"index": 703,
"step-1": "<mask token>\n\n\ndef test_negativity():\n assert make_it_negative(8) == -8\n assert complain_about('enthusiasm') == 'I hate enthusiasm. Totally boring.'\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_negativity... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName(_fromUtf8('Form'))
Form.resize(666, 538)
palette = QtGui.QPalette()
self.eventSkip = 0
self.db = Database()
brush = QtGui.QBrush(QtGui.QColor(8, 129, 2))
brush.s... | flexible | {
"blob_id": "8339113fd6b0c286cc48ec04e6e24978e2a4b44e",
"index": 9991,
"step-1": "<mask token>\n\n\nclass Ui_Form(object):\n\n def setupUi(self, Form):\n Form.setObjectName(_fromUtf8('Form'))\n Form.resize(666, 538)\n palette = QtGui.QPalette()\n self.eventSkip = 0\n self.db... | [
8,
10,
11,
12,
13
] |
import sys
sys.stdin = open('input.txt', 'rt')
BLOCK_0 = 1
BLOCK_1 = 2
BLOCK_2 = 3
N = int(input())
X, Y = 10, 10
# x: 행 , y: 열A
GRN = 0
BLU = 1
maps = [[0]*Y for _ in range(X)]
dx = [1, 0]
dy = [0, 1]
def outMaps(x, y):
global X, Y
if 0<=x<X and 0<=y<Y: return False
else: return True
def meetBlock(x, y, ... | normal | {
"blob_id": "937d01eaa82cbfe07b20fae9320c554a0960d7b1",
"index": 571,
"step-1": "<mask token>\n\n\ndef meetBlock(x, y, maps):\n if maps[x][y] == 1:\n return True\n else:\n return False\n\n\ndef onlyUpdate(n_blocks, xs, ys, maps):\n for i in range(n_blocks):\n maps[xs[i]][ys[i]] = 1\... | [
9,
10,
11,
12,
14
] |
<|reserved_special_token_0|>
class Item(object):
def __init__(self, name, category):
self.name = name
self.category = category
class Category(object):
def __init__(self, name):
self.name = name
class ItemTable(Table):
name = Col('Name')
category_name = Col('Category', att... | flexible | {
"blob_id": "3191fa5f9c50993d17e12e4e2e9d56cfce2108e7",
"index": 5646,
"step-1": "<mask token>\n\n\nclass Item(object):\n\n def __init__(self, name, category):\n self.name = name\n self.category = category\n\n\nclass Category(object):\n\n def __init__(self, name):\n self.name = name\n\... | [
6,
7,
8,
9,
10
] |
# 上传文件
import os
from selenium import webdriver
# 获取当前路径的 “files” 文件夹
file_path = os.path.abspath("./files//")
# 浏览器打开文件夹的 upfile.html 文件
driver = webdriver.Firefox()
upload_page = "file:///" + file_path + "/upfile.html"
driver.get(upload_page)
# 定位上传按钮,添加本地文件
driver.find_element_by_id("inputfile").send_keys(file_p... | normal | {
"blob_id": "9e28fa1f221df13f9cc8e6b71586da961ebdc0e0",
"index": 4580,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndriver.get(upload_page)\ndriver.find_element_by_id('inputfile').send_keys(file_path + '\\\\test.txt')\n",
"step-3": "<mask token>\nfile_path = os.path.abspath('./files//')\ndriver = web... | [
0,
1,
2,
3,
4
] |
import sklearn.metrics as metrics
import sklearn.cross_validation as cv
from sklearn.externals import joblib
import MachineLearning.Reinforcement.InternalSQLManager as sqlManager
class ReinforcementLearner:
def __init__(self, clf=None, load=False, clfName=None):
"""
Initialise the Classifier, eith... | normal | {
"blob_id": "c9be3d25824093528e2bee51c045d05e036daa67",
"index": 9715,
"step-1": "<mask token>\n\n\nclass ReinforcementLearner:\n\n def __init__(self, clf=None, load=False, clfName=None):\n \"\"\"\n Initialise the Classifier, either from the provided model or from the stored classifier\n\n ... | [
3,
4,
5,
6,
8
] |
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 31 13:42:47 2018
@author: zhan
"""
from scipy.spatial.distance import pdist, squareform, cdist
import numpy as np
import scipy.io as sci
import os,sys
import datetime
###################################################################
# I_tr:featur... | normal | {
"blob_id": "db140bf66f3e3a84a60a6617ea4c03cc6a1bc56d",
"index": 6271,
"step-1": "#!/usr/bin/env python2\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Wed Jan 31 13:42:47 2018\n\n@author: zhan\n\"\"\"\nfrom scipy.spatial.distance import pdist, squareform, cdist\nimport numpy as np\nimport scipy.io as sci\nimport ... | [
0
] |
<|reserved_special_token_0|>
def has_dupulicates(word):
d = dict()
for c in word:
if c not in d:
d[c] = 1
else:
d[c] += 1
for k in d:
if d[k] == 1:
print(k)
else:
print(k, d[k])
return d
<|reserved_special_token_0|>
<|... | flexible | {
"blob_id": "8cd234c2ec1b36abd992cc1a46147376cc241ede",
"index": 3276,
"step-1": "<mask token>\n\n\ndef has_dupulicates(word):\n d = dict()\n for c in word:\n if c not in d:\n d[c] = 1\n else:\n d[c] += 1\n for k in d:\n if d[k] == 1:\n print(k)\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@dataclass
class Root:
a: List[object] = field(default_factory=list, metadata={'type':
'Element', 'namespace': '', 'min_occurs': 2, 'max_occurs': 4,
'sequence': 1})
b: List[object] = field(default_factory... | flexible | {
"blob_id": "7e318ae7317eac90d6ce9a6b1d0dcc8ff65abef0",
"index": 9430,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@dataclass\nclass Root:\n a: List[object] = field(default_factory=list, metadata={'type':\n 'Element', 'namespace': '', 'min_occurs': 2, 'max_occurs': 4,\n 'sequence'... | [
0,
1,
2,
3
] |
import kubernetes.client
from kubernetes.client.rest import ApiException
from pprint import pprint
from kubeops_api.models.cluster import Cluster
class ClusterMonitor():
def __init__(self,cluster):
self.cluster = cluster
self.token = self.cluster.get_cluster_token()
self.cluster.change_to(... | normal | {
"blob_id": "da41f26489c477e0df9735606457bd4ee4e5a396",
"index": 4465,
"step-1": "<mask token>\n\n\nclass ClusterMonitor:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass ClusterMonitor:\n\n def __init__(self, cluster):\n self.cluster = cluster\n self.token = self.clu... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def synonym_alternatives_range(WordVectors_npArray,
AlternativesVectorOne_npArray, AlternativesVectorTwo_npArray,
AlternativesVectorThree_npArray, AlternativesVectorFour_npArray):
"""
"""
synonym_alternatives_range = np.zeros(len(WordVectors_npArray))
for word_int ... | flexible | {
"blob_id": "ea0a59953f2571f36e65f8f958774074b39a9ae5",
"index": 6996,
"step-1": "<mask token>\n\n\ndef synonym_alternatives_range(WordVectors_npArray,\n AlternativesVectorOne_npArray, AlternativesVectorTwo_npArray,\n AlternativesVectorThree_npArray, AlternativesVectorFour_npArray):\n \"\"\"\n \"\"\"... | [
1,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class RefTrackCollectionRegistry(object):
<|reserved_special_token_0|>
def __init__(self):
self._genome2TrackIndexReg = defaultdict(set)
self._trackIndex2CollectionReg = defaultdict(set)
self._allCollections = set()
if not os.path.exists(REF_COLL_G... | flexible | {
"blob_id": "9c2cc5b993f020b8a1c96ea4cd5c2fb2da44a251",
"index": 1534,
"step-1": "<mask token>\n\n\nclass RefTrackCollectionRegistry(object):\n <mask token>\n\n def __init__(self):\n self._genome2TrackIndexReg = defaultdict(set)\n self._trackIndex2CollectionReg = defaultdict(set)\n sel... | [
6,
7,
8,
10,
11
] |
import datetime
import pendulum
import requests
from prefect import task, Flow, Parameter
from prefect.engine.signals import SKIP
from prefect.tasks.notifications.slack_task import SlackTask
from prefect.tasks.secrets import Secret
city = Parameter(name="City", default="San Jose")
api_key = Secret("WEATHER_API_KEY")
... | normal | {
"blob_id": "7f52354487f85a0bf1783c8aa76f228ef17e6d6b",
"index": 5119,
"step-1": "<mask token>\n\n\n@task(max_retries=2, retry_delay=datetime.timedelta(seconds=5))\ndef pull_forecast(city, api_key):\n \"\"\"\n Extract the 5-day 3-hour forecast for the provided City.\n \"\"\"\n base_url = 'http://api.... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def matrix_divided(matrix, div):
"""Divides a Matrix
Args:
matrix: A list of lists of ints or floats
div: a non zero int or float
Exceptions:
TypeError: if the matrix and/or div is not as stated or the ... | flexible | {
"blob_id": "95c5971a102fb2ed84ab0de0471278d0167d8359",
"index": 22,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef matrix_divided(matrix, div):\n \"\"\"Divides a Matrix\n\n Args:\n matrix: A list of lists of ints or floats\n div: a non zero int or float\n\n Exceptions:\n TypeEr... | [
0,
1,
2
] |
<|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": "4e383130b185c6147315517d166ffe66be1be40d",
"index": 4577,
"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 = []\n operat... | [
0,
1,
2,
3,
4
] |
from django.conf.urls import url, include
from api.resources import PlayerResource, GameResource
from . import views
player_resource = PlayerResource()
game_resource = GameResource()
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^api/', include(player_resource.urls)),
url(r'^api/', include(... | normal | {
"blob_id": "ff959a388438a6d9c6d418e28c676ec3fd196ea0",
"index": 6076,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nplayer_resource = PlayerResource()\ngame_resource = GameResource()\nurlpatterns = [url('^$', views.index, name='index'), url('^api/', include(\n player_resource.urls)), url('^api/', in... | [
0,
1,
2,
3
] |
"""
Copyright (c) 2007 by the Pallets team.
Some rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the f... | normal | {
"blob_id": "53cd9d5a79e97bb1af69446a82c747248c3cc298",
"index": 1367,
"step-1": "<mask token>\n\n\ndef _get_headers(environ):\n \"\"\"\n Returns only proper HTTP headers.\n \"\"\"\n for key, value in iteritems(environ):\n key = str(key)\n if key.startswith('HTTP_') and key not in ('HTT... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class DatasetFileManager(ABC):
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
class DatasetFileManager(ABC):
@abstractmethod
def read_dataset(self):
pass
<|rese... | flexible | {
"blob_id": "5ef65ace397be17be62625ed27b5753d15565d61",
"index": 555,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass DatasetFileManager(ABC):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass DatasetFileManager(ABC):\n\n @abstractmethod\n def read_dataset(self):\n pass\n",... | [
0,
1,
2,
3
] |
from app.routes import home
from .home import bp as home
from .dashboard import bp as dashboard
| normal | {
"blob_id": "358a4948ac1f60e0966328cebf401777042c3d0e",
"index": 5239,
"step-1": "<mask token>\n",
"step-2": "from app.routes import home\nfrom .home import bp as home\nfrom .dashboard import bp as dashboard\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
__all__ = ['resolver']
<|reserved_special_token_1|>
<|reserved_special_token_0|>
from acres.resolution import resolver
__all__ = ['resolver']
<|reserved_special_token_1|>
"""
Package with a facade to the several expansion st... | flexible | {
"blob_id": "e31267871453d87aee409f1c751c36908f7f151a",
"index": 804,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['resolver']\n",
"step-3": "<mask token>\nfrom acres.resolution import resolver\n__all__ = ['resolver']\n",
"step-4": "\"\"\"\nPackage with a facade to the several expansion ... | [
0,
1,
2,
3
] |
import requests
def squeezed (client_name):
return client_name.replace('Индивидуальный предприниматель', 'ИП')
def get_kkm_filled_fn(max_fill=80):
## возвращает список ККМ с заполнением ФН больше max_fill в %
LOGIN_URL = 'https://pk.platformaofd.ru/auth/login'
API_URL = 'https://pk.platformaofd.ru/api/mon... | normal | {
"blob_id": "cd2e03666a890d6e9ea0fcb45fe28510d684916d",
"index": 83,
"step-1": "<mask token>\n\n\ndef squeezed(client_name):\n return client_name.replace('Индивидуальный предприниматель', 'ИП')\n\n\ndef get_kkm_filled_fn(max_fill=80):\n LOGIN_URL = 'https://pk.platformaofd.ru/auth/login'\n API_URL = 'ht... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
@app.route('/transactions/isfull', methods=['GET'])
def isFull():
return jsonify(node.isFull()), 200
@app.route('/transactions/new', methods=['POST'])
def newTransaction():
transaction = request.get_json()
if node.isValidTxn(node.isValidChain(), transaction):
return ... | flexible | {
"blob_id": "45b46a08d8b304ac12baf34e0916b249b560418f",
"index": 7459,
"step-1": "<mask token>\n\n\n@app.route('/transactions/isfull', methods=['GET'])\ndef isFull():\n return jsonify(node.isFull()), 200\n\n\n@app.route('/transactions/new', methods=['POST'])\ndef newTransaction():\n transaction = request.g... | [
8,
11,
12,
13,
14
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
print(x & y)
print(x >> y)
print(x ^ y)
print(x | y)
<|reserved_special_token_1|>
x = 25
y = 43
print(x & y)
print(x >> y)
print(x ^ y)
print(x | y)
| flexible | {
"blob_id": "34d011727c93bb4c8ccf64017e7185717ef98667",
"index": 2603,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(x & y)\nprint(x >> y)\nprint(x ^ y)\nprint(x | y)\n",
"step-3": "x = 25\ny = 43\nprint(x & y)\nprint(x >> y)\nprint(x ^ y)\nprint(x | y)\n",
"step-4": null,
"step-5": null,
... | [
0,
1,
2
] |
<|reserved_special_token_0|>
def hashfile(path, blocksize=65536):
afile = open(path, 'rb')
hasher = hashlib.md5()
buf = afile.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = afile.read(blocksize)
afile.close()
return hasher.hexdigest()
<|reserved_special_token_0|... | flexible | {
"blob_id": "e99c158e54fd86b00e4e045e7fb28d961089800d",
"index": 3289,
"step-1": "<mask token>\n\n\ndef hashfile(path, blocksize=65536):\n afile = open(path, 'rb')\n hasher = hashlib.md5()\n buf = afile.read(blocksize)\n while len(buf) > 0:\n hasher.update(buf)\n buf = afile.read(blocks... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
def erato(n):
m = int(n ** 0.5)
sieve = [(True) for _ in range(n + 1)]
sieve[1] = False
for i in range(2, m + 1):
if sieve[i]:
for j in range(i + i, n + 1, i):
sieve[j] = False
return sieve
<|reserved_... | flexible | {
"blob_id": "28eb1d7a698480028fb64827746b3deec0f66a9a",
"index": 6224,
"step-1": "<mask token>\n",
"step-2": "def erato(n):\n m = int(n ** 0.5)\n sieve = [(True) for _ in range(n + 1)]\n sieve[1] = False\n for i in range(2, m + 1):\n if sieve[i]:\n for j in range(i + i, n + 1, i):... | [
0,
1,
2,
3,
4
] |
from django.shortcuts import render
from django.views.generic import DetailView
from .models import Course
# Create your views here.
def courses_list_view(request):
products = Course.objects.all()
title = "دوره ها"
context = {
"object_list": products,
"title": title,
}
return re... | normal | {
"blob_id": "aaa9665ac6d639e681fddd032058f490ce36d12a",
"index": 7684,
"step-1": "<mask token>\n\n\nclass CoursesDetailView(DetailView):\n <mask token>\n <mask token>\n\n def get_context_data(self, *args, object_list=None, **kwargs):\n context = super(CoursesDetailView, self).get_context_data(*ar... | [
2,
3,
4,
5,
6
] |
<|reserved_special_token_0|>
class Queue:
def __init__(self):
self.items = []
def isEmpty(self):
return self.items == []
def enqueue(self, item):
self.items.insert(0, item)
def dequeue(self):
return self.items.pop()
def size(self):
return len(self.items... | flexible | {
"blob_id": "ec200ee66e3c4a93bbd8e75f0e8b715f54b5479d",
"index": 6781,
"step-1": "<mask token>\n\n\nclass Queue:\n\n def __init__(self):\n self.items = []\n\n def isEmpty(self):\n return self.items == []\n\n def enqueue(self, item):\n self.items.insert(0, item)\n\n def dequeue(se... | [
11,
12,
13,
16,
17
] |
from IPython import display
display.Image("./image.png") | normal | {
"blob_id": "3f5096ef5677373a1e436f454109c7b7577c0205",
"index": 6169,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ndisplay.Image('./image.png')\n",
"step-3": "from IPython import display\ndisplay.Image('./image.png')\n",
"step-4": "from IPython import display\ndisplay.Image(\"./image.png\")",
"s... | [
0,
1,
2,
3
] |
<|reserved_special_token_0|>
@bp.route('/login', methods=('POST',))
def login() ->Any:
"""Flask view for logging a user in."""
user_dict = UserSchema().load(request.json, partial=('id',
'qualifications') + PERMISSIONS)
username = user_dict['username']
password = user_dict['password']
if is... | flexible | {
"blob_id": "2d36ae916ad257615016ed6c0bc67e506ee313c9",
"index": 1528,
"step-1": "<mask token>\n\n\n@bp.route('/login', methods=('POST',))\ndef login() ->Any:\n \"\"\"Flask view for logging a user in.\"\"\"\n user_dict = UserSchema().load(request.json, partial=('id',\n 'qualifications') + PERMISSION... | [
4,
6,
7,
8,
9
] |
#####################将政策文件中的内容抽取出来:标准、伦理、 3部分内容##########################
###########step 1:把3部分内容找到近义词,组成一个词表######
###########step 2:把文件与词表相匹配,判断文件到底在讲啥######
from nltk.corpus import wordnet as wn
import os
import codecs
# goods = wn.synsets('beautiful')
# beautifuls = wn.synsets('pretty')
# bads = wn.synsets... | normal | {
"blob_id": "caca4309034f08874e1e32828a601e7e3d4d3efd",
"index": 2058,
"step-1": "<mask token>\n\n\ndef readOnePolicy(path2):\n ethic_set = wn.synsets('ethic')\n standard_set = wn.synsets('standard')\n privacy_set = wn.synsets('privacy')\n education_set = wn.synsets('education')\n investment_set =... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def getDates():
dates = store.mapStore('dates')
data = store.mapStore('data')
exceptions = store.mapStore('exceptions')
if len(exceptions) > 0:
return False
try:
d0 = date(2020, 1, 13)
d1 = data[0, FIRST:]
i = 0
newdates = []
... | flexible | {
"blob_id": "5b4651f37cdcbb13f8ddd03327ef65af0f9cf61d",
"index": 1944,
"step-1": "<mask token>\n\n\ndef getDates():\n dates = store.mapStore('dates')\n data = store.mapStore('data')\n exceptions = store.mapStore('exceptions')\n if len(exceptions) > 0:\n return False\n try:\n d0 = dat... | [
3,
4,
6,
7,
8
] |
import thinkbayes2 as thinkbayes
from thinkbayes2 import Pmf
import thinkplot
class Dice2(Pmf):
def __init__(self, sides):
Pmf.__init__(self)
for x in range(1, sides + 1):
self.Set(x, 1)
self.Normalize()
if __name__ == "__main__":
d6 = Dice2(6)
dices = [d6] * 6
th... | normal | {
"blob_id": "236dd70dec8d53062d6c38c370cb8f11dc5ef9d0",
"index": 556,
"step-1": "<mask token>\n\n\nclass Dice2(Pmf):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Dice2(Pmf):\n\n def __init__(self, sides):\n Pmf.__init__(self)\n for x in range(1, sides + 1):\n ... | [
1,
2,
3,
4,
5
] |
<|reserved_special_token_0|>
def health():
return 'OK', 200
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def health():
return 'OK', 200
def verify_token(token):
"""
Verifies Token from Authorization header
"""
if config.API_TOKEN is None:
... | flexible | {
"blob_id": "167bd2c405171443c11fbd13575f8c7b20877289",
"index": 8470,
"step-1": "<mask token>\n\n\ndef health():\n return 'OK', 200\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef health():\n return 'OK', 200\n\n\ndef verify_token(token):\n \"\"\"\n Verifies Token from Authorization header\... | [
1,
2,
3,
4
] |
<|reserved_special_token_0|>
def test2():
answer = convert_c_to_f(-40.0)
expected = -40.0
assert answer == expected
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
def test_convert_c_to_f():
answer = convert_c_to_f(20.0)
expected = 68.0
assert answ... | flexible | {
"blob_id": "d75187ed435c3d3aeeb31be4a0a4ed1754f8d160",
"index": 4436,
"step-1": "<mask token>\n\n\ndef test2():\n answer = convert_c_to_f(-40.0)\n expected = -40.0\n assert answer == expected\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_convert_c_to_f():\n answer = convert_c_to_f(20... | [
1,
2,
3,
4
] |
"""
* @section LICENSE
*
* @copyright
* Copyright (c) 2017 Intel Corporation
*
* @copyright
* 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
*
* @copyright
* http://www.apache.org... | normal | {
"blob_id": "f11e6a53d8dfc60f73f346772df7a3cab14088ce",
"index": 2751,
"step-1": "\"\"\"\n * @section LICENSE\n *\n * @copyright\n * Copyright (c) 2017 Intel Corporation\n *\n * @copyright\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance wit... | [
0
] |
<|reserved_special_token_0|>
<|reserved_special_token_1|>
<|reserved_special_token_0|>
@pytest.fixture
def dataproc_launcher(pytestconfig) ->DataprocClusterLauncher:
cluster_name = pytestconfig.getoption('--dataproc-cluster-name')
region = pytestconfig.getoption('--dataproc-region')
project_id = pytest... | flexible | {
"blob_id": "ff13ac0ee401471fe5446e8149f019d9da7f3ddf",
"index": 5147,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.fixture\ndef dataproc_launcher(pytestconfig) ->DataprocClusterLauncher:\n cluster_name = pytestconfig.getoption('--dataproc-cluster-name')\n region = pytestconfig.getopt... | [
0,
1,
2,
3
] |
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import os, shutil, time, pickle, warnings, logging
import yaml
from sklearn import preprocessing
from sklearn.model_selection import StratifiedKFold, KFold
from sklearn import metrics
from scipy.special import erfinv
from scipy.stats import mode
wa... | normal | {
"blob_id": "4d0b08f8ca77d188aa218442ac0689fd2c057a89",
"index": 8357,
"step-1": "<mask token>\n\n\ndef data_split_GroupKFold(df, col_index, col_group, n_splits=5, random_state=42\n ):\n \"\"\"\n\n :param df:\n :param col_index:\n :param col_group:\n :param n_splits:\n :param random_state:\n... | [
2,
4,
5,
6,
7
] |
<|reserved_special_token_0|>
def test_linear_slope_2():
eta = ETA(100)
eta._timing_data = deque([(10, 20), (20, 40), (30, 60), (40, 80)])
getattr(eta, '_calculate')()
assert 50 == eta.eta_epoch
assert 2.0 == eta.rate
assert 2.0 == eta.rate_unstable
def test_linear_transform():
"""Wolfram... | flexible | {
"blob_id": "810017cd5814fc20ebcdbdf26a32ea1bcfc88625",
"index": 2164,
"step-1": "<mask token>\n\n\ndef test_linear_slope_2():\n eta = ETA(100)\n eta._timing_data = deque([(10, 20), (20, 40), (30, 60), (40, 80)])\n getattr(eta, '_calculate')()\n assert 50 == eta.eta_epoch\n assert 2.0 == eta.rate\... | [
2,
3,
4,
5
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.