index
int64
0
100k
blob_id
stringlengths
40
40
code
stringlengths
7
7.27M
steps
listlengths
1
1.25k
error
bool
2 classes
5,600
14cb702054b8caaa8899a2a3d8b65aae9b063cb6
import pandas import os from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import Select from selenium.common.exceptions import NoSuchElementException import json CONFIG_FILE_NAME = os.path.join(os.path.dirname(__file__), 'input_info.json') def create_ne...
[ "import pandas\nimport os\nfrom selenium import webdriver\nfrom selenium.webdriver.common.keys import Keys\nfrom selenium.webdriver.support.ui import Select\nfrom selenium.common.exceptions import NoSuchElementException\nimport json\n\nCONFIG_FILE_NAME = os.path.join(os.path.dirname(__file__), 'input_info.json')\n\...
false
5,601
e714fe0e27ec9ea5acb3120a4d2114d3d7674fcf
import os import json from page import Page from random import choice from os.path import join, expanduser from file_handler import f_read, f_readlines, open_local import config class LetterPage(Page): def __init__(self, page_num,n): super(LetterPage, self).__init__(page_num) self.title = "Letters"...
[ "import os\nimport json\nfrom page import Page\nfrom random import choice\nfrom os.path import join, expanduser\nfrom file_handler import f_read, f_readlines, open_local\nimport config\n\nclass LetterPage(Page):\n def __init__(self, page_num,n):\n super(LetterPage, self).__init__(page_num)\n self.t...
false
5,602
3b737aaa820da8f70a80480c6404e4d3a9d2262e
""" COMPARISON OPERATORS """ __author__ = 'Sol Amour - amoursol@gmail.com' __twitter__ = '@solamour' __version__ = '1.0.0' greaterThan = 10 > 5 # Is '10' greater than '5' ? Evaluates to True greaterThanOrEqualTo = 10 >= 10 # Is '10' greater than or equal to '10' # ? Evaluates to True lessThan = 5 < 10 # Is '5' les...
[ "\"\"\"\nCOMPARISON OPERATORS\n\"\"\"\n__author__ = 'Sol Amour - amoursol@gmail.com'\n__twitter__ = '@solamour'\n__version__ = '1.0.0'\n\ngreaterThan = 10 > 5 # Is '10' greater than '5' ? Evaluates to True\ngreaterThanOrEqualTo = 10 >= 10 # Is '10' greater than or equal to '10' \n# ? Evaluates to True\nlessThan =...
false
5,603
e279ca43ce2c582c702f1c6a0c1acf37eb9bcefe
from django.shortcuts import render def index(request): return render(request, 'munchiesfastfood/home.html', {'drinks':['Pineapple Juice','Green Juice','Soft Drinks','Carlo Rosee Drinks'], 'dishes':['Beef Steak','Tomato with Chicken','Sausages from Italy','Beef Grilled']})
[ "from django.shortcuts import render\n\ndef index(request):\n\treturn render(request, 'munchiesfastfood/home.html', {'drinks':['Pineapple Juice','Green Juice','Soft Drinks','Carlo Rosee Drinks'], 'dishes':['Beef Steak','Tomato with Chicken','Sausages from Italy','Beef Grilled']})\n", "from django.shortcuts import...
false
5,604
0ef172ced411213c0f7daccd632f8d5ec97379c3
from django.apps import AppConfig class EasyTechConfig(AppConfig): name = 'easy_tech'
[ "from django.apps import AppConfig\n\n\nclass EasyTechConfig(AppConfig):\n name = 'easy_tech'\n", "<import token>\n\n\nclass EasyTechConfig(AppConfig):\n name = 'easy_tech'\n", "<import token>\n\n\nclass EasyTechConfig(AppConfig):\n <assignment token>\n", "<import token>\n<class token>\n" ]
false
5,605
f01a1b6d0de4ba685c489af2742159447f943d2d
# -*- coding: utf-8 -*- """ Created on Thu May 24 18:18:36 2018 @author: Nicole """ from __future__ import division import Rod import matplotlib.pyplot as plt import math class Truss: def __init__(self,node1,node2,size,result,ax): self.node1=node1 self.node2=node2 self.rod=Rod.Rod(node1,...
[ "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu May 24 18:18:36 2018\n\n@author: Nicole\n\"\"\"\n\n\nfrom __future__ import division\nimport Rod\nimport matplotlib.pyplot as plt\nimport math\n\nclass Truss:\n def __init__(self,node1,node2,size,result,ax):\n self.node1=node1\n self.node2=node2\n ...
false
5,606
26b0a762b8eb30f0ef3c5a914f032c2a7d24f750
# 12.02.17 """ nomencalura a__b__c a: parametro t-temperatura tm-temperatura minima tM-teperatura massima b: intervallo di tempo a-anno c: tabella fonte dati g-giornaliero """ import db_02 as DB def t_tm_tM__a__g(db, anno): cmd = """ SELECT data, t, tmin, tmax FROM Giornaliero WHERE strft...
[ "# 12.02.17\n\n\"\"\"\nnomencalura\na__b__c\n\na: parametro\n t-temperatura\n tm-temperatura minima\n tM-teperatura massima\n\nb: intervallo di tempo\n a-anno\n\nc: tabella fonte dati\n g-giornaliero\n\"\"\"\n\nimport db_02 as DB\n\n\ndef t_tm_tM__a__g(db, anno):\n cmd = \"\"\"\nSELECT data, t, tm...
false
5,607
e5c30488c8c1682171c57a11a8ecedc5ccd4d851
import numpy as np import matplotlib.pyplot as plt import sys import os from azavg_util import plot_azav from binormalized_cbar import MidpointNormalize from diagnostic_reading import ReferenceState dirname = sys.argv[1] datadir = dirname + '/data/' plotdir = dirname + '/plots/' if (not os.path.isdir(plotdir)): ...
[ "import numpy as np\nimport matplotlib.pyplot as plt\nimport sys\nimport os\nfrom azavg_util import plot_azav\nfrom binormalized_cbar import MidpointNormalize\nfrom diagnostic_reading import ReferenceState\n\ndirname = sys.argv[1]\n\ndatadir = dirname + '/data/'\nplotdir = dirname + '/plots/'\n\nif (not os.path.isd...
false
5,608
9a0e37aaa41f3b21ed7ad11096cd6c5dd0bb8564
import time t0 = time.time() while abs(t0-time.time()<60): pass
[ "import time\nt0 = time.time()\nwhile abs(t0-time.time()<60):\n pass\n", "import time\nt0 = time.time()\nwhile abs(t0 - time.time() < 60):\n pass\n", "<import token>\nt0 = time.time()\nwhile abs(t0 - time.time() < 60):\n pass\n", "<import token>\n<assignment token>\nwhile abs(t0 - time.time() < 60):\...
false
5,609
175e8ecdd0c9faa5fc981447f821763e0eb58b4d
import h5py import numpy as np from matplotlib import pyplot from IPython.Shell import IPShellEmbed ipshell = IPShellEmbed("Dropping to IPython shell") filename = "SPY-VXX-20090507-20100427.hdf5" start_day = 1 end_day = 245 #start_day = 108 #end_day = 111 start_day = 120 end_day = 245 start_day = 1 end_day = 120 s...
[ "import h5py\nimport numpy as np\nfrom matplotlib import pyplot\n\nfrom IPython.Shell import IPShellEmbed\nipshell = IPShellEmbed(\"Dropping to IPython shell\")\n\nfilename = \"SPY-VXX-20090507-20100427.hdf5\"\n\nstart_day = 1\nend_day = 245\n\n#start_day = 108\n#end_day = 111\n\nstart_day = 120\nend_day = 245\nsta...
false
5,610
a1db566f4da16e7725212aeab29e946ef7c1672e
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models import django.utils.timezone class Migration(migrations.Migration): dependencies = [ ('home_application', '0019_auto_20170809_1810'), ] operations = [ migrations.CreateModel( ...
[ "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\n\nfrom django.db import migrations, models\nimport django.utils.timezone\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('home_application', '0019_auto_20170809_1810'),\n ]\n\n operations = [\n migrations.C...
false
5,611
9d302ff2de8280bd8786794cdd533107d2a458bc
import urllib3 import json def download(url): print('Downloading ', url) userAgent = 'Mozilla/5.0 (Linux; U; Android 10; zh-cn; MI 9 Build/QKQ1.190825.002) AppleWebKit/533.1 (KHTML, like Gecko) Version/5.0 Mobile Safari/533.1' userAgent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/5...
[ "import urllib3\nimport json\ndef download(url):\n print('Downloading ', url)\n userAgent = 'Mozilla/5.0 (Linux; U; Android 10; zh-cn; MI 9 Build/QKQ1.190825.002) AppleWebKit/533.1 (KHTML, like Gecko) Version/5.0 Mobile Safari/533.1'\n userAgent = 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) App...
false
5,612
e89600f109335ffdb00c13f617d61496c547ba61
import requests, os def lambda_handler(event, context): print(requests) apiKey = os.environ['newrelic_api_key'] headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'X-api-key' : apiKey} r = requests.get('https://api.newrelic.com/v2/applications.json', headers=headers) return ...
[ "import requests, os\n\ndef lambda_handler(event, context):\n\n print(requests)\n apiKey = os.environ['newrelic_api_key']\n headers = {'content-type': 'application/json', 'Accept-Charset': 'UTF-8', 'X-api-key' : apiKey}\n r = requests.get('https://api.newrelic.com/v2/applications.json', headers=headers)...
false
5,613
ede675c971ed233e93c14aa4d2ffb66fe7ba775a
""" This is the hourly animation program. It displays a series of images across the board. It is hard coded to work with the Sonic images. Adjustments would need to be made to the y values which are distance traveled. Change sonicFrame < 8 value to the total number of frames the new animation has. """ from runImages im...
[ "\"\"\"\nThis is the hourly animation program. It displays a series of images across the board.\nIt is hard coded to work with the Sonic images. Adjustments would need to be made to\nthe y values which are distance traveled. Change sonicFrame < 8 value to the total\nnumber of frames the new animation has.\n\"\"\"\n...
false
5,614
20a238826640099e6c69aaa383c5fa7e9b02b13b
""" Contains derivative computation for BSSN formulation of ET equations. """ # first derivative import cog D = ["alpha", "beta0", "beta1", "beta2", "B0", "B1", "B2", "chi", "Gt0", "Gt1", "Gt2", "K", "gt0", "gt1", "gt2", "gt3", "gt4", "gt5", "At0", "At1", "At2", "At3", "At4", "At5" ] # cust...
[ "\"\"\"\nContains derivative computation for BSSN formulation of ET equations. \n\"\"\"\n\n# first derivative\nimport cog\n\nD = [\"alpha\", \"beta0\", \"beta1\", \"beta2\",\n \"B0\", \"B1\", \"B2\",\n \"chi\", \"Gt0\", \"Gt1\", \"Gt2\", \"K\",\n \"gt0\", \"gt1\", \"gt2\", \"gt3\", \"gt4\", \"gt5\",\...
false
5,615
3b19ee0bbd24b76dd8b933859f6a56c459926861
from javascript import JSConstructor from javascript import JSObject cango = JSConstructor(Cango2D) shapes2d = JSObject(shapes2D) tweener = JSConstructor(Tweener) drag2d = JSConstructor(Drag2D) svgtocgo2d = JSConstructor(svgToCgo2D) cgo = cango("plotarea") x1, y1 = 40, 20 cx1, cy1 = 90, 120 x2, y2 = 120, 100 cx2, cy2...
[ "from javascript import JSConstructor\nfrom javascript import JSObject\n \ncango = JSConstructor(Cango2D)\nshapes2d = JSObject(shapes2D)\ntweener = JSConstructor(Tweener)\ndrag2d = JSConstructor(Drag2D)\nsvgtocgo2d = JSConstructor(svgToCgo2D)\ncgo = cango(\"plotarea\")\nx1, y1 = 40, 20\ncx1, cy1 = 90, 120\nx2, y2 =...
false
5,616
d03a8076b77851ae4df5cf657ff898eb132c49c3
# Lahman.py # Convert to/from web native JSON and Python/RDB types. import json # Include Flask packages from flask import Flask from flask import request import copy import SimpleBO # The main program that executes. This call creates an instance of a # class and the constructor starts the runtime. app = Flask(__na...
[ "# Lahman.py\n\n# Convert to/from web native JSON and Python/RDB types.\nimport json\n\n# Include Flask packages\nfrom flask import Flask\nfrom flask import request\nimport copy\n\nimport SimpleBO\n\n# The main program that executes. This call creates an instance of a\n# class and the constructor starts the runtime...
false
5,617
f4aaf0449bff68814090552ea4f6ccac85dacf1b
# coding=utf-8 """SCALE UI: feature tests.""" import pytest import xpaths from function import ( wait_on_element, is_element_present, wait_on_element_disappear ) from pytest_bdd import ( given, scenario, then, when, ) @pytest.mark.dependency(name='Set_Group') @scenario('features/NAS-T1250...
[ "# coding=utf-8\n\"\"\"SCALE UI: feature tests.\"\"\"\n\nimport pytest\nimport xpaths\nfrom function import (\n wait_on_element,\n is_element_present,\n wait_on_element_disappear\n)\nfrom pytest_bdd import (\n given,\n scenario,\n then,\n when,\n)\n\n\n@pytest.mark.dependency(name='Set_Group')\...
false
5,618
129c7f349e2723d9555da44ae62f7cfb7227b9ae
from django.shortcuts import render from django.views.generic import View #导入View from .models import UpdateDbData,User from wanwenyc.settings import DJANGO_SERVER_YUMING from .forms import UpdateDbDataForm # Create your views here. #添加场景的view class UpdateDbDataView(View): #继承View """ 测试数据复制编写页面处理 ...
[ "from django.shortcuts import render\nfrom django.views.generic import View #导入View\n\n\nfrom .models import UpdateDbData,User\nfrom wanwenyc.settings import DJANGO_SERVER_YUMING\n\nfrom .forms import UpdateDbDataForm\n\n\n\n# Create your views here.\n#添加场景的view\nclass UpdateDbDataView(View): #继承View\n \"\"\...
false
5,619
700d6e0c7dab58ed0157265ff78021923c17e397
j= float(input("juros")) Q0= 1500 t= 36 Qf=Q0*(1+j)**t print(round(Qf,2))
[ "j= float(input(\"juros\"))\nQ0= 1500\nt= 36\nQf=Q0*(1+j)**t\nprint(round(Qf,2))", "j = float(input('juros'))\nQ0 = 1500\nt = 36\nQf = Q0 * (1 + j) ** t\nprint(round(Qf, 2))\n", "<assignment token>\nprint(round(Qf, 2))\n", "<assignment token>\n<code token>\n" ]
false
5,620
8a7536b998a6d122e2e7529af1ebe2a0f025303f
import requests from datetime import date from datetime import timedelta def get_offset_date(modifed_date, offset_in_days): return date.isoformat(modifed_date + timedelta(days=int(offset_in_days))) def get_trending_repositories(start_search_date, number_of_results=20): github_api_uri = 'https://api.github.c...
[ "import requests\nfrom datetime import date\nfrom datetime import timedelta\n\n\ndef get_offset_date(modifed_date, offset_in_days):\n return date.isoformat(modifed_date + timedelta(days=int(offset_in_days)))\n\n\ndef get_trending_repositories(start_search_date, number_of_results=20):\n github_api_uri = 'https...
false
5,621
40aa9e7cf0aaca24054297ca80aaf468ba485966
""" binary_adder.py: Takes two arrays representing binary numbers, adds them together. """ __author__ = "David Vaillant" __credits__ = "CLRS, Chapter 2.1" def binary_add(x, y): """ Adds two binary arrays together. """ # Makes sure that the arrays have the same length. # Could be chang...
[ "\"\"\" binary_adder.py: Takes two arrays representing binary numbers,\n adds them together. \"\"\"\n\n__author__ = \"David Vaillant\"\n__credits__ = \"CLRS, Chapter 2.1\"\n\ndef binary_add(x, y):\n \"\"\" Adds two binary arrays together. \"\"\"\n # Makes sure that the arrays have the same...
false
5,622
d827c59871d58e098009c22320af73f8f40169bb
from scrapy.selector import HtmlXPathSelector from scrapy.spiders import CrawlSpider, Rule from scrapy.linkextractors.sgml import SgmlLinkExtractor from scrapy.item import Item, Field import scrapy import config from scrapy.linkextractors import LinkExtractor from scrapy.http import Request class BrokenItem(Item): ...
[ "from scrapy.selector import HtmlXPathSelector\nfrom scrapy.spiders import CrawlSpider, Rule\nfrom scrapy.linkextractors.sgml import SgmlLinkExtractor\nfrom scrapy.item import Item, Field\nimport scrapy\nimport config\nfrom scrapy.linkextractors import LinkExtractor\nfrom scrapy.http import Request\n\n\n\nclass Bro...
true
5,623
12ca9a81574d34d1004ac9ebcb2ee4b31d7171e2
variable_1 = 100 variable_2 = 500 variable_3 = 222.5 variable_4 = 'Hello' variable_5 = 'world' print(variable_1, variable_2, variable_3, sep=', ') print(variable_4, variable_5, sep=', ', end='!\n') user_age = input('Введите ваш возраст: ') user_name = input('Введите ваше имя: ') print(variable_4 + ', ' +...
[ "variable_1 = 100\r\nvariable_2 = 500\r\nvariable_3 = 222.5\r\nvariable_4 = 'Hello'\r\nvariable_5 = 'world'\r\n\r\nprint(variable_1, variable_2, variable_3, sep=', ')\r\nprint(variable_4, variable_5, sep=', ', end='!\\n')\r\n\r\nuser_age = input('Введите ваш возраст: ')\r\nuser_name = input('Введите ваше имя: ')\r\...
false
5,624
61388b2edb35055cccbdc98ed52caedcd0b02983
import numpy as np import string import networkx as nx import matplotlib.pyplot as plt def PlotUndirectedGraph(A,color): NodesNames = list(string.ascii_uppercase); NNodes = A.shape[0] G = nx.DiGraph() for i in range(NNodes): G.add_node(NodesNames[i]) for i in range(NNodes): for ...
[ "import numpy as np \nimport string \nimport networkx as nx\nimport matplotlib.pyplot as plt\n\n\n\ndef PlotUndirectedGraph(A,color):\n NodesNames = list(string.ascii_uppercase);\n NNodes = A.shape[0]\n G = nx.DiGraph()\n for i in range(NNodes):\n G.add_node(NodesNames[i])\n for i in range(NNo...
false
5,625
f9234741c6356b4677b5d32ffea86549d001c258
""" Quick select (randomized selection algorithm) - based on quick sort (ch8_sorting); used to obtain the ith-smallest element in an unordered list of items (e.g.numbers) """ def swap(unsorted_array, a, b): temp = unsorted_array[a] unsorted_array[a] = unsorted_array[b] unsorted_array[b] = temp def part...
[ "\"\"\"\nQuick select (randomized selection algorithm)\n- based on quick sort (ch8_sorting); used to obtain the ith-smallest element in an unordered list of items (e.g.numbers)\n\n\"\"\"\n\n\ndef swap(unsorted_array, a, b):\n temp = unsorted_array[a]\n unsorted_array[a] = unsorted_array[b]\n unsorted_array...
false
5,626
60b1a77d2de4a52ae9597f88917c4a3996c99923
from src.secStructure import * from suffix_trees import STree import math import re def test_processData(): # Test1: ignoring peak position data = ['example/example1.fa', 'example/example2.fa'] struct_data = ['example/exampleStrucData/exampleStructuralData1.fa', 'example/exampleStrucDat...
[ "from src.secStructure import *\nfrom suffix_trees import STree\nimport math\nimport re\n\n\ndef test_processData():\n # Test1: ignoring peak position\n data = ['example/example1.fa', 'example/example2.fa']\n struct_data = ['example/exampleStrucData/exampleStructuralData1.fa',\n 'example/...
false
5,627
f494d8aeee8c72cce8fc14e44ca896bcf30c100a
from config import Config from flask import Flask from flask_cors import CORS from flask_migrate import Migrate from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) CORS(app) app.config.from_object(Config) app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///ws.db' # app.config['SQLALCHEMY_DATABASE_URI'] = 'mys...
[ "from config import Config\nfrom flask import Flask\nfrom flask_cors import CORS\nfrom flask_migrate import Migrate\nfrom flask_sqlalchemy import SQLAlchemy\n\napp = Flask(__name__)\nCORS(app)\napp.config.from_object(Config)\napp.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///ws.db'\n# app.config['SQLALCHEMY_DATABA...
false
5,628
8c69813bc576a56c25c828fe24e2707e65ac0d0d
#!/usr/bin/python """ demo_mininet_topo.py Sample topology class with Mininet. G = {V, E} V = {h1, h2, h3, h4, h51, h52, s0, s1, s4, s5} # of hosts = 6 # of switches = 4 E = { (h1, s1), (h2, s1), (h3, s1), (h4, s4), (h51, s5), (h52, s5), (s0, s1), (s0, s4), (s5, s4) } """ from mininet.topo import Top...
[ "#!/usr/bin/python\n\n\"\"\"\ndemo_mininet_topo.py\n\nSample topology class with Mininet.\n\nG = {V, E}\nV = {h1, h2, h3, h4, h51, h52, s0, s1, s4, s5}\n\t# of hosts = 6\n\t# of switches = 4\nE = {\n\t\t(h1, s1), (h2, s1), (h3, s1), \n\t \t(h4, s4), \n\t\t(h51, s5), (h52, s5), \n\t\t(s0, s1), (s0, s4), (s5, s4)\n\t...
false
5,629
9e05f883d80d7583c9f7e16b2fb5d3f67896388d
from auction_type import AuctionType from bid import Bid class Auction(object): def __init__(self, name, type, status, start_price, buy_now_price): self.name = name self.type = type self.status = status if AuctionType.BID == type: self.start_price = start_price ...
[ "from auction_type import AuctionType\nfrom bid import Bid\n\n\nclass Auction(object):\n def __init__(self, name, type, status, start_price, buy_now_price):\n self.name = name\n self.type = type\n self.status = status\n\n if AuctionType.BID == type:\n self.start_price = sta...
false
5,630
535c0975c688a19963e4c53f6029626d286b41d6
import random import colorama from termcolor import colored from reusables.string_manipulation import int_to_words from app.common_functions import comma_separated, add_dicts_together, remove_little_words, odds from app.load_data import items, buildings, wild_mobs, names, adjectives colorama.init() def find_uniqu...
[ "import random\n\nimport colorama\nfrom termcolor import colored\nfrom reusables.string_manipulation import int_to_words\n\nfrom app.common_functions import comma_separated, add_dicts_together, remove_little_words, odds\nfrom app.load_data import items, buildings, wild_mobs, names, adjectives\n\n\ncolorama.init()\n...
false
5,631
abdf5aee77ee879c50d0e605d5fd95e28a7ef7aa
import Ploneboard import PloneboardForum import PloneboardConversation import PloneboardComment
[ "import Ploneboard\nimport PloneboardForum\nimport PloneboardConversation\nimport PloneboardComment\n", "<import token>\n" ]
false
5,632
ba379ed90bccd05d058f69f33a960779f8b8bcd5
from model import * from data import * import os import matplotlib.pyplot as plt from sklearn.metrics import confusion_matrix data_gen_args = dict(horizontal_flip = True, vertical_flip = True) imageTargetSize = (256, 256) trainPath = '/work/scratch/zhangbin/EmbryoTracking_ClaireBinZhang/Motili...
[ "from model import *\nfrom data import *\nimport os\nimport matplotlib.pyplot as plt\nfrom sklearn.metrics import confusion_matrix\n\ndata_gen_args = dict(horizontal_flip = True,\n vertical_flip = True)\n\n\nimageTargetSize = (256, 256)\n\n\ntrainPath = '/work/scratch/zhangbin/EmbryoTracking_Cla...
false
5,633
bd419d0a197a5e5a99a370e45cdb53a276ac5507
from sklearn import cluster from sklearn.metrics import adjusted_rand_score import matplotlib.pyplot as plt def test_Kmeans(*data): x,labels_true = data clst = cluster.KMeans() clst.fit(x) predicted_labels = clst.predict(x) print("ARI: %s" % adjusted_rand_score(labels_true, predicted_labels)) p...
[ "from sklearn import cluster\nfrom sklearn.metrics import adjusted_rand_score\nimport matplotlib.pyplot as plt\n\ndef test_Kmeans(*data):\n x,labels_true = data\n clst = cluster.KMeans()\n clst.fit(x)\n predicted_labels = clst.predict(x)\n print(\"ARI: %s\" % adjusted_rand_score(labels_true, predicte...
false
5,634
82fc86e44d02c45d7904139e4dfdff069e2bdb90
import time from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as EC def open_browser(browser="chrome"): driver = None if browser == "chrome": driver = webdriver.Chrome() elif browser == "firefox": ...
[ "import time\n\nfrom selenium import webdriver\nfrom selenium.webdriver.support.wait import WebDriverWait\nfrom selenium.webdriver.support import expected_conditions as EC\n\n\ndef open_browser(browser=\"chrome\"):\n driver = None\n if browser == \"chrome\":\n driver = webdriver.Chrome()\n elif brow...
false
5,635
508d016161131481ace41f3d3bda005423125fe5
def parse(filename): t1, t2 = open(filename).read().strip().split("\n\n") return tuple(map(lambda x: list(map(int, x.split("\n")[1:])), [t1, t2])) def score(deck): res = 0 for i in range(len(deck)): res += deck[i] * (len(deck)-i) return res def solution1(deck1, deck2): while len(deck1) > 0 and len(deck2) > 0:...
[ "def parse(filename):\n\tt1, t2 = open(filename).read().strip().split(\"\\n\\n\")\n\treturn tuple(map(lambda x: list(map(int, x.split(\"\\n\")[1:])), [t1, t2]))\n\ndef score(deck):\n\tres = 0\n\tfor i in range(len(deck)):\n\t\tres += deck[i] * (len(deck)-i)\n\treturn res\n\ndef solution1(deck1, deck2):\n\twhile len...
false
5,636
be5178f013e639d5179ed1af380dd7a63044bff2
import pandas as pd import matplotlib.pyplot as plt plt.rcParams['font.sans-serif'] = ['SimHei'] def get_ratings(file_path): # 图书的ISBN中可能包含字符,所以在使用pandas读取文件时,需要指定编码 ratings = pd.read_table(file_path, header=0, sep=';', encoding='ISO-8859-1') print('前5条数据:\n{}\n'.format(rating...
[ "import pandas as pd\nimport matplotlib.pyplot as plt\n\nplt.rcParams['font.sans-serif'] = ['SimHei']\n\n\ndef get_ratings(file_path):\n # 图书的ISBN中可能包含字符,所以在使用pandas读取文件时,需要指定编码\n ratings = pd.read_table(file_path, header=0,\n sep=';', encoding='ISO-8859-1')\n print('前5条数据:\\n{}\...
false
5,637
38a2113c0531648a90cf70c4b18d640d5ebb3f47
''' quick and dirty remote shell using sockets and file descriptors ''' import socket import os s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.bind(('',8082)) s.listen(1) conn,__=s.accept() os.dup2(conn.fileno(),0) os.dup2(conn.fileno(),1) #print("asdf") os.system('/bin/bash') conn.close()
[ "'''\nquick and dirty remote shell using sockets and file descriptors\n'''\nimport socket\nimport os\n\ns=socket.socket(socket.AF_INET,socket.SOCK_STREAM)\ns.bind(('',8082))\n\ns.listen(1)\n\nconn,__=s.accept()\n\nos.dup2(conn.fileno(),0)\nos.dup2(conn.fileno(),1)\n\n#print(\"asdf\")\nos.system('/bin/bash')\n\t\nco...
false
5,638
6546d04d3755d62d1a8756bdec1a10f6f018dcea
from django.apps import AppConfig class FitnerappConfig(AppConfig): name = 'fitnerapp'
[ "from django.apps import AppConfig\n\n\nclass FitnerappConfig(AppConfig):\n name = 'fitnerapp'\n", "<import token>\n\n\nclass FitnerappConfig(AppConfig):\n name = 'fitnerapp'\n", "<import token>\n\n\nclass FitnerappConfig(AppConfig):\n <assignment token>\n", "<import token>\n<class token>\n" ]
false
5,639
1babf9f27e6792d2a1c2545a1e3bcd08fefa0975
import cv2 import numpy as np import random def main(): img = cv2.imread('test_image.png',0) res = np.zeros((img.shape[0],img.shape[1],3),np.uint8) thresh = cv2.threshold(img, 50, 255, 0)[1] _, contours,_ = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) for cnt in contours: ...
[ "import cv2\nimport numpy as np \nimport random\n\n\ndef main():\n img = cv2.imread('test_image.png',0)\n res = np.zeros((img.shape[0],img.shape[1],3),np.uint8)\n thresh = cv2.threshold(img, 50, 255, 0)[1]\n _, contours,_ = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)\n for cnt in c...
false
5,640
8c3c066ed37fe0f67acfd2d5dc9d57ec2b996275
def solution(A): if not A: return 1 elif len(A) == 1: if A[0] == 1: return 2 else: return 1 A.sort() prev = 0 for i in A: if i != (prev + 1): return i - 1 else: prev = i return prev + 1
[ "def solution(A):\n if not A:\n return 1\n elif len(A) == 1:\n if A[0] == 1:\n return 2\n else:\n return 1\n\n A.sort()\n prev = 0\n for i in A:\n if i != (prev + 1):\n return i - 1\n else:\n prev = i\n\n return prev + ...
false
5,641
ea414835554ea3dcac2017036692cf178526f91b
# Generated by Django 3.0.7 on 2020-12-16 15:29 from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('play', '0001_initial'), ] operations = [ migrations.CreateModel( name='playerA', ...
[ "# Generated by Django 3.0.7 on 2020-12-16 15:29\r\n\r\nfrom django.db import migrations, models\r\nimport django.db.models.deletion\r\n\r\n\r\nclass Migration(migrations.Migration):\r\n\r\n dependencies = [\r\n ('play', '0001_initial'),\r\n ]\r\n\r\n operations = [\r\n migrations.CreateModel...
false
5,642
74d1491280eba1ceb06ccf6f45546cdb41149687
#!/usr/bin python3 # coding: utf-8 """ AUTHOR: bovenson EMAIL: szhkai@qq.com FILE: 03.py DATE: 17-9-25 下午7:59 DESC: """ from socket import socket
[ "#!/usr/bin python3\n# coding: utf-8\n\n\"\"\"\nAUTHOR: bovenson\nEMAIL: szhkai@qq.com\nFILE: 03.py\nDATE: 17-9-25 下午7:59\nDESC:\n\"\"\"\n\nfrom socket import socket\n", "<docstring token>\nfrom socket import socket\n", "<docstring token>\n<import token>\n" ]
false
5,643
4cc1c8668a84cc6faadf60053568d155b8852c5f
# -*- coding: utf-8 -*- """Application configuration. See https://github.com/sloria/cookiecutter-flask for configuration options with other flask-extensions """ import os class Config(object): """Base configuration.""" SECRET_KEY = os.environ.get('DELIVERY_ASSISTANT_SECRET', 'secret-key') # TODO: Change me...
[ "# -*- coding: utf-8 -*-\n\"\"\"Application configuration.\n\nSee https://github.com/sloria/cookiecutter-flask for configuration options with other flask-extensions\n\"\"\"\nimport os\n\n\nclass Config(object):\n \"\"\"Base configuration.\"\"\"\n\n SECRET_KEY = os.environ.get('DELIVERY_ASSISTANT_SECRET', 'sec...
false
5,644
2bbfbc597a4e1f8b46f58a4c6002a9943eff557a
# pylint: skip-file from sorter.lib.request_data import read_url from urllib2 import HTTPError class fake_urllib(object): def __init__(self, should_fail=False): self.should_fail = should_fail def urlopen(self, uri): if self.should_fail == True: raise HTTPError('FAKER.GTLD', 404, 'F...
[ "# pylint: skip-file\nfrom sorter.lib.request_data import read_url\nfrom urllib2 import HTTPError\n\nclass fake_urllib(object):\n def __init__(self, should_fail=False):\n self.should_fail = should_fail\n\n def urlopen(self, uri):\n if self.should_fail == True:\n raise HTTPError('FAKER...
false
5,645
5d6ec1b23dcbc935fe80dd09a2e967eb7e37a363
from knox.models import AuthToken from rest_framework import generics, permissions, status from rest_framework.response import Response from accounts.serializers import UserSerializer, RegisterSerializer, LoginSerializer, ChangePasswordSerializer # Register API class RegisterAPI(generics.CreateAPIView): permiss...
[ "from knox.models import AuthToken\nfrom rest_framework import generics, permissions, status\nfrom rest_framework.response import Response\n\nfrom accounts.serializers import UserSerializer, RegisterSerializer, LoginSerializer, ChangePasswordSerializer\n\n\n# Register API\n\nclass RegisterAPI(generics.CreateAPIView...
false
5,646
3191fa5f9c50993d17e12e4e2e9d56cfce2108e7
from flask_table import Table, Col """Lets suppose that we have a class that we get an iterable of from somewhere, such as a database. We can declare a table that pulls out the relevant entries, escapes them and displays them. """ class Item(object): def __init__(self, name, category): self.name = name...
[ "from flask_table import Table, Col\n\n\n\"\"\"Lets suppose that we have a class that we get an iterable of from\nsomewhere, such as a database. We can declare a table that pulls out\nthe relevant entries, escapes them and displays them.\n\n\"\"\"\n\n\nclass Item(object):\n def __init__(self, name, category):\n ...
false
5,647
5485a1210a0c0361dbb000546ee74df725fad913
#!/usr/bin/env python3.4 # -*- coding: utf-8 -*- """ Das Pong-Spielfeld wird simuliert. Court moduliert ein anpassbares Spielfeld für Pong mit einem standardmäßigen Seitenverhältnis von 16:9. Jenes Spielfeld verfügt über einen Ball und zwei Schläger, jeweils links und rechts am Spielfeldrand, sowie einen Punktestand ...
[ "#!/usr/bin/env python3.4\n# -*- coding: utf-8 -*-\n\n\"\"\"\nDas Pong-Spielfeld wird simuliert.\n\nCourt moduliert ein anpassbares Spielfeld für Pong mit einem standardmäßigen Seitenverhältnis von 16:9.\nJenes Spielfeld verfügt über einen Ball und zwei Schläger, jeweils links und rechts am Spielfeldrand,\nsowie ei...
false
5,648
6e78d1fb2364d334f47fea89b065d859c025ca2f
#!/usr/bin/env python #!-*-coding:utf-8 -*- """ @version: python3.7 @author: ‘v-enshi‘ @license: Apache Licence @contact: 123@qq.com @site: @software: PyCharm @file: Images_fade.py @time: 2019/1/16 17:17 """ from PIL import Image import numpy as np filename = "hw0_data/westbrook.jpg" im=Image.open(filename) #open th...
[ "#!/usr/bin/env python\n#!-*-coding:utf-8 -*-\n\"\"\"\n@version: python3.7\n@author: ‘v-enshi‘\n@license: Apache Licence \n@contact: 123@qq.com\n@site: \n@software: PyCharm\n@file: Images_fade.py\n@time: 2019/1/16 17:17\n\"\"\"\nfrom PIL import Image\nimport numpy as np\n\nfilename = \"hw0_data/westbrook.jpg\"\nim=...
false
5,649
a0dcfb738451c11ed4ff1428629c3f7bbf5c52c9
from django.db import models ch=[ ('Garment','Garment'), ('Hardgoods','Hardgoods'), ('Home Furnishing','Home Furnishing'), ] class Factory(models.Model): name = models.CharField(max_length=30,choices=ch) def __str__(self): return self.name class Fabric(models.Model): n...
[ "from django.db import models\r\n\r\n\r\nch=[\r\n ('Garment','Garment'),\r\n ('Hardgoods','Hardgoods'),\r\n ('Home Furnishing','Home Furnishing'),\r\n]\r\nclass Factory(models.Model):\r\n name = models.CharField(max_length=30,choices=ch)\r\n\r\n def __str__(self):\r\n return self.name\r\n\r\nc...
false
5,650
5282e9a9e87fd7fd6053f816048f371fbe190046
#!/usr/bin/python # -*- coding: utf-8 -*- from tp_global import * from cgibase import cgibase from tp_mongodb import * import json import requests class Ccase_model(cgibase): def __init__(self): return cgibase.__init__(self) def onInit(self): cgibase.SetNoCheckCookie(self) opr = cgiba...
[ "#!/usr/bin/python\n# -*- coding: utf-8 -*-\n\nfrom tp_global import *\nfrom cgibase import cgibase\nfrom tp_mongodb import *\nimport json\nimport requests\n\nclass Ccase_model(cgibase):\n def __init__(self):\n return cgibase.__init__(self)\n\n def onInit(self):\n cgibase.SetNoCheckCookie(self)\...
false
5,651
7b726dd8ebbd5c49f9ce5bddb4779fcfbaaeb479
from .gsclient import GSClient from .gspath import GSPath __all__ = [ "GSClient", "GSPath", ]
[ "from .gsclient import GSClient\nfrom .gspath import GSPath\n\n__all__ = [\n \"GSClient\",\n \"GSPath\",\n]\n", "from .gsclient import GSClient\nfrom .gspath import GSPath\n__all__ = ['GSClient', 'GSPath']\n", "<import token>\n__all__ = ['GSClient', 'GSPath']\n", "<import token>\n<assignment token>\n" ]
false
5,652
3313f01ed98433f4b150c4d8e877ac09eb8403b4
from django.conf.urls import url from tree import views urlpatterns = [ url('/home', views.home), url('/about', views.about), ]
[ "\nfrom django.conf.urls import url\nfrom tree import views\n\nurlpatterns = [\n url('/home', views.home),\n url('/about', views.about),\n]", "from django.conf.urls import url\nfrom tree import views\nurlpatterns = [url('/home', views.home), url('/about', views.about)]\n", "<import token>\nurlpatterns = [...
false
5,653
0a50b31155afce2558ec066267a9fd0c56964759
from Store import Store from MusicProduct import MusicProduct class MusicStore(Store): def make_product(self, name): '''Overides from parent - return a new MusicProduct Object'''
[ "from Store import Store\nfrom MusicProduct import MusicProduct\n\nclass MusicStore(Store):\n\n def make_product(self, name):\n '''Overides from parent - return a new MusicProduct Object'''\n", "from Store import Store\nfrom MusicProduct import MusicProduct\n\n\nclass MusicStore(Store):\n\n def make_...
false
5,654
b328ee0b6c5afaf496297cefe477f933af458a03
import unittest from utils import getParams from utils.httpUtil import HttpUtil from utils.logger import Log logger = Log(logger='cms_getMarket').get_log() class NavTest(unittest.TestCase): @classmethod def setUpClass(cls) -> None: cls.url = getParams.get_url('cms_getMarket', 'getMarket') Htt...
[ "import unittest\nfrom utils import getParams\nfrom utils.httpUtil import HttpUtil\nfrom utils.logger import Log\nlogger = Log(logger='cms_getMarket').get_log()\n\n\nclass NavTest(unittest.TestCase):\n\n @classmethod\n def setUpClass(cls) -> None:\n cls.url = getParams.get_url('cms_getMarket', 'getMark...
false
5,655
8af9cc32b445402fa790b29382a802bd8afc1100
# Generated by Django 2.2.4 on 2019-09-09 11:00 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('core', '0002_ordered'), ] operations = [ migrations.AlterField( model_name='generalinfo', name='amount_available', ...
[ "# Generated by Django 2.2.4 on 2019-09-09 11:00\n\nfrom django.db import migrations, models\n\n\nclass Migration(migrations.Migration):\n\n dependencies = [\n ('core', '0002_ordered'),\n ]\n\n operations = [\n migrations.AlterField(\n model_name='generalinfo',\n name='a...
false
5,656
fbe091b1cf3ecc2f69d34e3b1c399314b38ebc4a
import arcade WINDOW_WIDTH = 740 WINDOW_HEIGHT = 740 dark_green = (170, 216, 81) light_green = (162, 210, 73) snake_color = (72, 118, 235) def square(square_x, square_y, square_width, square_height, square_color): """ Code that sets up the squares for generation """ arcade.draw_rectangle_filled(square_x, squ...
[ "import arcade\n\nWINDOW_WIDTH = 740\nWINDOW_HEIGHT = 740\ndark_green = (170, 216, 81)\nlight_green = (162, 210, 73)\nsnake_color = (72, 118, 235)\n\n\ndef square(square_x, square_y, square_width, square_height, square_color):\n \"\"\" Code that sets up the squares for generation \"\"\"\n arcade.draw_rectangl...
false
5,657
75b1d2fb927063669a962f72deb57323001c0b7a
''' Created on 17 june, 2018 @author: sp977u@att.com (Satish Palnati) This class is for ''' import sys from PySide.QtGui import * from PySide.QtCore import * from PySide import QtGui from PySide import QtCore class PingWindow: wind_close_flg = False def __init__(self,last_parent): ...
[ "'''\r\nCreated on 17 june, 2018\r\n@author: sp977u@att.com (Satish Palnati)\r\nThis class is for \r\n\r\n'''\r\nimport sys\r\nfrom PySide.QtGui import * \r\nfrom PySide.QtCore import *\r\nfrom PySide import QtGui\r\nfrom PySide import QtCore\r\n\r\nclass PingWindow:\r\n\r\n wind_close_flg = False\r\n\r\n d...
false
5,658
92e414c76f4c585092a356d7d2957e91c1477c5f
__version__ = "2.1.2" default_app_config = "channels.apps.ChannelsConfig" DEFAULT_CHANNEL_LAYER = "default"
[ "__version__ = \"2.1.2\"\n\ndefault_app_config = \"channels.apps.ChannelsConfig\"\nDEFAULT_CHANNEL_LAYER = \"default\"\n", "__version__ = '2.1.2'\ndefault_app_config = 'channels.apps.ChannelsConfig'\nDEFAULT_CHANNEL_LAYER = 'default'\n", "<assignment token>\n" ]
false
5,659
8894b73829978cec29aab6ee8bf09700da7fb59f
#-*- coding: utf-8 -*- import django if django.get_version() <= '1.3.1': import apps.settings as settings from django.core.management import setup_environ setup_environ(settings) elif django.get_version() >= '1.7.0': import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "apps.settings") ...
[ "#-*- coding: utf-8 -*-\n\nimport django\n\nif django.get_version() <= '1.3.1':\n import apps.settings as settings\n from django.core.management import setup_environ\n setup_environ(settings)\nelif django.get_version() >= '1.7.0': \n import os\n os.environ.setdefault(\"DJANGO_SETTINGS_MODULE\", \"a...
true
5,660
d307c3479e34a12971f62a765aca2ba0850d80d1
import scrapy import datetime from tzscrape.items import CitizenItem class CitizenSpider(scrapy.Spider): name = 'citizen' allowed_domains = ['thecitizen.co.tz'] start_urls = ['http://www.thecitizen.co.tz/'] def parse(self, response): # headlines for href in response.xpath('//*[@itempro...
[ "import scrapy\nimport datetime\nfrom tzscrape.items import CitizenItem\n\nclass CitizenSpider(scrapy.Spider):\n name = 'citizen'\n allowed_domains = ['thecitizen.co.tz']\n start_urls = ['http://www.thecitizen.co.tz/']\n\n def parse(self, response):\n # headlines\n for href in response.xpa...
false
5,661
e474cb3db74b5344bd861aacf779cb9f77830ef6
"""Functional tests for h2 frames.""" __author__ = "Tempesta Technologies, Inc." __copyright__ = "Copyright (C) 2023 Tempesta Technologies, Inc." __license__ = "GPL2" from h2.errors import ErrorCodes from h2.exceptions import StreamClosedError from framework import deproxy_client, tester from helpers import checks_f...
[ "\"\"\"Functional tests for h2 frames.\"\"\"\n\n__author__ = \"Tempesta Technologies, Inc.\"\n__copyright__ = \"Copyright (C) 2023 Tempesta Technologies, Inc.\"\n__license__ = \"GPL2\"\n\nfrom h2.errors import ErrorCodes\nfrom h2.exceptions import StreamClosedError\n\nfrom framework import deproxy_client, tester\nf...
false
5,662
90ae14d8af163343520365a5565a7c44de57059d
""" """ import os from alert_triage.util import filelock MODIFIED_ALERTS_FILE = "/tmp/alert_triage_modified_alerts" def read_modified_alert_ids(): """ Read modified alert IDs from file, then remove them from the file.""" # Return an empty list if the file doesn't exist. if not os.path.exists(MODIFIED_AL...
[ "\"\"\"\n\"\"\"\n\nimport os\n\nfrom alert_triage.util import filelock\n\nMODIFIED_ALERTS_FILE = \"/tmp/alert_triage_modified_alerts\"\n\ndef read_modified_alert_ids():\n \"\"\" Read modified alert IDs from file, then remove them from the file.\"\"\"\n # Return an empty list if the file doesn't exist.\n if...
false
5,663
e5a7b0cbc82b57578f6dcbf676e8f589c6e9ac1b
__author__ = 'mvoronin'
[ "__author__ = 'mvoronin'\n", "<assignment token>\n" ]
false
5,664
87bcf53d1c93645a08b10ba0d02edf0d5b0a4906
#Άσκηση 3.2: Ουρά δύο άκρων print("Οδηγίες: Το πρόγραμμα καταχωρει αριθμους σε μια λίστα! Τρέχει σε άπειρο βρόχο, έως ότου πληκτρολογήσεις 'q'. \nΑν θελήσεις να βγάλεις το πρώτο στοιχείο της λίστας, πληκτρολόγησε '0r' ενώ,\nαν θέλεις να βγάλεις το τελευταιο, πληκτρολόγησε 'r'\n ") newNumber = input("Για να ξεκιν...
[ "#Άσκηση 3.2: Ουρά δύο άκρων\r\n\r\nprint(\"Οδηγίες: Το πρόγραμμα καταχωρει αριθμους σε μια λίστα! Τρέχει σε άπειρο βρόχο, έως ότου πληκτρολογήσεις 'q'. \\nΑν θελήσεις να βγάλεις το πρώτο στοιχείο της λίστας, πληκτρολόγησε '0r' ενώ,\\nαν θέλεις να βγάλεις το τελευταιο, πληκτρολόγησε 'r'\\n \")\r\n\r\nnewNumber = i...
false
5,665
ab3d443c60ca8ee82f594ae04e9b485a53d53f36
from ocr_helpers import FilePathResolver, ProblemsWriter from ocr_google_client import CfaProblemsBuilder from ocr_google_client_2016 import ParserTwoThousandSixteenAnswers, ParserTwoThousandSixteenQuestions def resolve_build_and_write(year, day_part, file_part, nb_blocks_footer=0, nb_words_footer=0, headers=None, sk...
[ "from ocr_helpers import FilePathResolver, ProblemsWriter\nfrom ocr_google_client import CfaProblemsBuilder\nfrom ocr_google_client_2016 import ParserTwoThousandSixteenAnswers, ParserTwoThousandSixteenQuestions\n\n\ndef resolve_build_and_write(year, day_part, file_part, nb_blocks_footer=0, nb_words_footer=0, header...
false
5,666
6d2bc28e7742f1063a04ae96fc195515ad70598b
from django.shortcuts import render class Person(object): def __init__(self,username): self.username = username def index(request): # p = Person("张三") # context = { # 'person': p # } # context = { # 'person': { # 'username':'zhiliao', # } # } # p...
[ "from django.shortcuts import render\n\nclass Person(object):\n def __init__(self,username):\n self.username = username\n\ndef index(request):\n # p = Person(\"张三\")\n # context = {\n # 'person': p\n # }\n # context = {\n # 'person': {\n # 'username':'zhiliao',\n # ...
false
5,667
eb1737ac671129ed3459ce4feacb81d414eef371
# -*- coding: utf-8 -*- # Copyright European Organization for Nuclear Research (CERN) since 2012 # # 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-...
[ "# -*- coding: utf-8 -*-\n# Copyright European Organization for Nuclear Research (CERN) since 2012\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/lic...
false
5,668
aa51b2d4bfe4051f3302d14cf2123a3881a8a2e3
import cpt_tools from gui_helpers.gui_config import * chisqr_str = '\u03c72' mu_str = '\u03bc' sigma_str = '\u03c3' class FitWidget( object ) : def __init__( self, plotter_widget, analyzer = None ) : self.plotter_widget = plotter_widget self.plotter = plotter_widget.plotter s...
[ "import cpt_tools\nfrom gui_helpers.gui_config import * \n\n\nchisqr_str = '\\u03c72'\nmu_str = '\\u03bc'\nsigma_str = '\\u03c3'\n\n\n\nclass FitWidget( object ) :\n\n def __init__( self, plotter_widget, analyzer = None ) :\n\n self.plotter_widget = plotter_widget \n self.plotter = plotter_w...
false
5,669
dc28d8aa17347f07041ae218bbe4e1b0add27c24
import cherrypy import config try: from simplejson import json except ImportError: import json import routes import urllib import re def redirect(url, status=None): """Raise a redirect to the specified address. """ raise cherrypy.HTTPRedirect(url, status) def require_method(*allowed_methods): ...
[ "import cherrypy\nimport config\ntry:\n from simplejson import json\nexcept ImportError:\n import json\nimport routes\nimport urllib\nimport re\n\ndef redirect(url, status=None):\n \"\"\"Raise a redirect to the specified address.\n\n \"\"\"\n raise cherrypy.HTTPRedirect(url, status)\n\ndef require_me...
false
5,670
325770130473153d092d3058587e9666625e12d0
# coding=utf-8 """ @Author: Freshield @Contact: yangyufresh@163.com @File: a1_test_call.py @Time: 2021-01-20 17:40 @Last_update: 2021-01-20 17:40 @Desc: None @==============================================@ @ _____ _ _ _ _ @ @ | __|___ ___ ___| |_|_|___| |_| | @ @ | __| ...
[ "# coding=utf-8\n\"\"\"\n@Author: Freshield\n@Contact: yangyufresh@163.com\n@File: a1_test_call.py\n@Time: 2021-01-20 17:40\n@Last_update: 2021-01-20 17:40\n@Desc: None\n@==============================================@\n@ _____ _ _ _ _ @\n@ | __|___ ___ ___| |_|_|___| |_| | ...
false
5,671
7f2ffa653486d000c9eee0087fc1e6ca0c84003c
class Solution: def jump(self, nums: List[int]) -> int: if len(nums) < 2: return 0 jump = 1 curr_max = max_reach = nums[0] for i ...
[ "class Solution:\n def jump(self, nums: List[int]) -> int:\n \n if len(nums) < 2: return 0 \n \n jump = 1 \n curr_max = max_reach = nums[0] \n \n ...
false
5,672
33c39b098cb9d3368b8f74a7433e0943fe252da5
import unittest, warnings from pony.orm import * from pony.orm import core from pony.orm.tests.testutils import raises_exception db = Database('sqlite', ':memory:') class Person(db.Entity): id = PrimaryKey(int) name = Required(str) tel = Optional(str) db.generate_mapping(check_tables=False)...
[ "import unittest, warnings\r\n\r\nfrom pony.orm import *\r\nfrom pony.orm import core\r\nfrom pony.orm.tests.testutils import raises_exception\r\n\r\ndb = Database('sqlite', ':memory:')\r\n\r\nclass Person(db.Entity):\r\n id = PrimaryKey(int)\r\n name = Required(str)\r\n tel = Optional(str)\r\n\r\ndb.gener...
false
5,673
2bccfba2448059a41185b117b224813e344b50f8
from simple_avk.AVK import SimpleAVK from simple_avk.exceptions import MethodError, LongpollError
[ "from simple_avk.AVK import SimpleAVK\nfrom simple_avk.exceptions import MethodError, LongpollError\n", "<import token>\n" ]
false
5,674
4549f26cf8051535f9d3486d111fc7afe7514dea
from rest_framework import permissions class AdminUrlUserPermission(permissions.BasePermission): def has_permission(self, request, view): return (request.user.is_authenticated and (request.user.role == 'admin' or request.user.is_superuser)) def has_object_permissi...
[ "from rest_framework import permissions\n\n\nclass AdminUrlUserPermission(permissions.BasePermission):\n def has_permission(self, request, view):\n return (request.user.is_authenticated\n and (request.user.role == 'admin'\n or request.user.is_superuser))\n\n def has_o...
false
5,675
7537deb4560e880365b23a99584d0b1f8fa3daf4
from click.testing import CliRunner from apitest.actions.cli import cli def test_sendto_cli_runs_ok(): runner = CliRunner() result = runner.invoke(cli, ["sendto"]) assert result.exit_code == 0
[ "from click.testing import CliRunner\nfrom apitest.actions.cli import cli\n\n\ndef test_sendto_cli_runs_ok():\n runner = CliRunner()\n result = runner.invoke(cli, [\"sendto\"])\n \n assert result.exit_code == 0\n", "from click.testing import CliRunner\nfrom apitest.actions.cli import cli\n\n\ndef test...
false
5,676
9101fc5b8ba04a1b72e0c79d5bf3e4118e1bad75
#! /usr/bin/python import math import sys import os import subprocess #PTYPES = [ "eth_ip_udp_head_t", "ip_udp_head_t", "eth_32ip_udp_head_t", "eth_64ip_udp_head_t", "eth64_64ip64_64udp_head_t", "eth6464_64ip64_64udp_head_t" ] #PTYPES = [ "eth_ip_udp_head_t", "eth_32ip_udp_head_t", "eth_64ip_udp_head_t", "eth64_64...
[ "#! /usr/bin/python\n\nimport math\nimport sys\nimport os\nimport subprocess\n\n\n#PTYPES = [ \"eth_ip_udp_head_t\", \"ip_udp_head_t\", \"eth_32ip_udp_head_t\", \"eth_64ip_udp_head_t\", \"eth64_64ip64_64udp_head_t\", \"eth6464_64ip64_64udp_head_t\" ]\n#PTYPES = [ \"eth_ip_udp_head_t\", \"eth_32ip_udp_head_t\", \"...
true
5,677
6f6d3fbb9a6a118e0f4026a7f9054b90b8cf2fca
# from dataclasses import InitVar, dataclass # standard library imports from math import floor # third-party imports import gym import torch from torch.nn import Conv2d, Linear, MaxPool2d, Module, ModuleList, ReLU, Sequential from torch.nn import functional as F # local imports from tmrl.nn import TanhNormalLayer fro...
[ "# from dataclasses import InitVar, dataclass\n# standard library imports\nfrom math import floor\n\n# third-party imports\nimport gym\nimport torch\nfrom torch.nn import Conv2d, Linear, MaxPool2d, Module, ModuleList, ReLU, Sequential\nfrom torch.nn import functional as F\n\n# local imports\nfrom tmrl.nn import Tan...
false
5,678
82e7e22293551e061dcb295c52714c22df0ed0ce
class tenDParameters: def __init__(self, b: float, DM: float, pm_l: float, pm_b: float, vrad: float, sb: float, spml: float, spmb: float, sdm: float, vc: float): self.b = b self.DM = DM # this is actually pm_l * cos b, apparently self.pm_l = pm...
[ "class tenDParameters:\n def __init__(self,\n b: float,\n DM: float,\n pm_l: float,\n pm_b: float,\n vrad: float,\n sb: float,\n spml: float,\n spmb: float,\n sdm: float,\n vc: float):\n self.b = b\n self.DM = DM\n # this is actually pm_l * cos b, apparently\n ...
false
5,679
c36adc3cf5de2f0ae3ee9b9823304df393ebce63
""" code: pmap_io_test.py """ import os import time import tables as tb import numpy as np from pytest import mark from .. core.system_of_units_c import units from .. database import load_db from .. sierpe import blr from . import tbl_functions as tbl from ....
[ "\"\"\"\ncode: pmap_io_test.py\n\"\"\"\nimport os\nimport time\n\nimport tables as tb\nimport numpy as np\n\nfrom pytest import mark\n\nfrom .. core.system_of_units_c import units\nfrom .. database import load_db\nfrom .. sierpe import blr\n\nfrom . import tbl_...
false
5,680
d123083358a4fd69f6f8de27fa177afac3bf80ce
from functools import update_wrapper from django.db import models # Create your models here. class Product(models.Model): product_id=models.AutoField product_name=models.CharField(max_length=50) category=models.CharField(max_length=50,default="") subcategory=models.CharField(max_length=50,default="")...
[ "from functools import update_wrapper\nfrom django.db import models\n\n# Create your models here.\n\n\nclass Product(models.Model):\n product_id=models.AutoField\n product_name=models.CharField(max_length=50)\n category=models.CharField(max_length=50,default=\"\")\n subcategory=models.CharField(max_leng...
false
5,681
44e1208a2165fe68f71d0aa49baa29b26c961e02
import pandas as pd import copy as cp import numpy as np from autoencoder import * from encoding import smtEncoding import matplotlib import matplotlib.pyplot as plt from data_generator import * from marabou_encoding import marabouEncoding def main(): ''' Trains an autoencoder on (generated) data and checks advers...
[ "import pandas as pd\nimport copy as cp\nimport numpy as np\nfrom autoencoder import *\nfrom encoding import smtEncoding\nimport matplotlib\nimport matplotlib.pyplot as plt\nfrom data_generator import *\nfrom marabou_encoding import marabouEncoding\n\ndef main():\n\t\n\t'''\n\tTrains an autoencoder on (generated) d...
false
5,682
3ff3b8a1d8e74c09da9d6f39e4abf0963002a812
#!/usr/bin/python import sys import cgi import urllib2 url = sys.argv[1] try: response = urllib2.urlopen(url) redir = response.geturl() except Exception: import traceback redir = 'generic exception: ' + traceback.format_exc() print redir
[ "#!/usr/bin/python\nimport sys\nimport cgi\nimport urllib2\n\n\nurl = sys.argv[1]\n\ntry:\n\tresponse = urllib2.urlopen(url)\n\tredir = response.geturl()\nexcept Exception:\n\timport traceback\n\tredir = 'generic exception: ' + traceback.format_exc()\n\nprint redir\n" ]
true
5,683
2044140fb2678f9507946007fdfb7edbaf11798e
from random import shuffle """all sorting algorithm implementation""" class Sorts: def quick_sort(self, elements): """quick sort implementation""" if len(elements) < 2: return elements else: shuffle(elements) pivot = elements[0] print("pivot ...
[ "from random import shuffle\r\"\"\"all sorting algorithm implementation\"\"\"\r\r\rclass Sorts:\r def quick_sort(self, elements):\r \"\"\"quick sort implementation\"\"\"\r if len(elements) < 2:\r return elements\r else:\r shuffle(elements)\r pivot = elements[...
false
5,684
0c14a6fa8b25e1791a6eb9c71290db8bb316819a
# https://kyu9341.github.io/algorithm/2020/03/11/algorithm14226/ # https://developingbear.tistory.com/138 # https://devbelly.tistory.com/108 # 이모티콘 s개 생성 # 3가지 연산 이용 # bfs 이용 => visited를 이모티콘 방문 여부 2차원 배열 => 이모티콘의 수 와 클립보드에 저장된 이모티콘의 갯수를 이용 from collections import deque s = int(input()) q = deque() # visited[이모티콘의 수][클...
[ "# https://kyu9341.github.io/algorithm/2020/03/11/algorithm14226/\n# https://developingbear.tistory.com/138\n# https://devbelly.tistory.com/108\n# 이모티콘 s개 생성\n# 3가지 연산 이용\n# bfs 이용 => visited를 이모티콘 방문 여부 2차원 배열 => 이모티콘의 수 와 클립보드에 저장된 이모티콘의 갯수를 이용\nfrom collections import deque\ns = int(input())\nq = deque()\n# visi...
false
5,685
9594cda360847d2878aa2bd9c9c85fe50562b6ab
#!/usr/bin/python import json, sys, getopt, re # Usage: ./get_code.py -i <inputfile> def main(argv): inputfile = argv[0] with open(inputfile) as json_data: d=json.load(json_data) json_data.close() code_array = d["hits"]["hits"] output_json = [] for element in code_array: gistid = ele...
[ "#!/usr/bin/python\n\nimport json, sys, getopt, re\n\n# Usage: ./get_code.py -i <inputfile>\n\ndef main(argv): \n inputfile = argv[0]\n \n with open(inputfile) as json_data: \n d=json.load(json_data)\n json_data.close()\n code_array = d[\"hits\"][\"hits\"]\n \n output_json = []\n \n for element in cod...
true
5,686
6591ad20d4a07f29f22b50b6e8998c51e53600d6
def getArticle(): text = [] idx = 1 with open('article.txt','r') as f: data = f.readlines() for i in data: if i != '\n': s = "{ 'id':" + str(idx) + "," + "'text':" + i.rstrip() + " }" text.append(s) idx+=1 return text a = getArticle() print a ''' create a list of 100 words article use javascri...
[ "def getArticle():\n\ttext = []\n\tidx = 1\n\twith open('article.txt','r') as f:\n\t\tdata = f.readlines()\n\t\tfor i in data:\n\t\t\tif i != '\\n':\n\t\t\t\ts = \"{ 'id':\" + str(idx) + \",\" + \"'text':\" + i.rstrip() + \" }\" \n\t\t\t\ttext.append(s)\n\t\t\t\tidx+=1\n\treturn text\n\na = getArticle()\nprint a\n...
true
5,687
559e46aa4e9b55f8c01acf30fa01e106ab914116
# -*- coding: utf-8 -*- """ .. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de> """ import argparse from glob import glob import os import cv2 import numpy as np import matplotlib.pyplot as plt import torch import torch.nn.functional as F from src.args import ArgumentParserRGBDSegmentation from src.build_...
[ "# -*- coding: utf-8 -*-\n\"\"\"\n.. codeauthor:: Daniel Seichter <daniel.seichter@tu-ilmenau.de>\n\"\"\"\nimport argparse\nfrom glob import glob\nimport os\n\nimport cv2\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport torch\nimport torch.nn.functional as F\n\nfrom src.args import ArgumentParserRGBDSeg...
false
5,688
d8d0c181fcfc9e0692369cc7a65259c43a68e931
# # struct_test.py # Nazareno Bruschi <nazareno.bruschi@unibo.it> # # Copyright (C) 2019-2020 University of Bologna # # 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.o...
[ "#\n# struct_test.py\n# Nazareno Bruschi <nazareno.bruschi@unibo.it>\n#\n# Copyright (C) 2019-2020 University of Bologna\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# ht...
false
5,689
7b45c9e31bfb868b1abde6af0d8579b52f86d9c3
from flask import Flask from flask_sqlalchemy import SQLAlchemy from subprocess import call app = Flask(__name__) app.config['SECRET_KEY'] = "SuperSecretKey" #app.config['SQLALCHEMY_DATABASE_URI'] = "postgresql://fmnibhaashbxuy:73b8e2e2485adfd45f57da653d63950b88fdcae12202a84f80c7f4c297e9e30a@ec2-23-23-222-184.compute-...
[ "from flask import Flask\nfrom flask_sqlalchemy import SQLAlchemy\nfrom subprocess import call\n\napp = Flask(__name__)\napp.config['SECRET_KEY'] = \"SuperSecretKey\"\n#app.config['SQLALCHEMY_DATABASE_URI'] = \"postgresql://fmnibhaashbxuy:73b8e2e2485adfd45f57da653d63950b88fdcae12202a84f80c7f4c297e9e30a@ec2-23-23-22...
false
5,690
5dccd015a90927e8d2a9c0ea4b11b24bfd4bb65e
import os import pprint import math import sys import datetime as dt from pathlib import Path import RotateCipher import ShiftCipher import TranspositionCipher def process_textfile( string_path: str, encryption_algorithm: str, algorithm_key: float, output_folderpath: str = str( ...
[ "import os\r\nimport pprint\r\nimport math\r\nimport sys\r\nimport datetime as dt\r\nfrom pathlib import Path\r\n\r\nimport RotateCipher\r\nimport ShiftCipher\r\nimport TranspositionCipher\r\n\r\n\r\ndef process_textfile(\r\n string_path: str,\r\n encryption_algorithm: str,\r\n algorithm_key: float,\r\n ...
false
5,691
25987c15c28e3939f9f531dbc1d4bd9bf622b5a9
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Nov 14 01:32:26 2019 @author: himanshu """ import numpy as np from scipy.interpolate import interp1d from option import Option class FFTPricing: def __init__(self, option : Option, riskFreeRate, ...
[ "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Thu Nov 14 01:32:26 2019\n\n@author: himanshu\n\"\"\"\n\nimport numpy as np\nfrom scipy.interpolate import interp1d\nfrom option import Option\n\nclass FFTPricing:\n \n def __init__(self,\n option : Option,\n ...
false
5,692
08b53ba116b0c5875d39af4ce18296d547d5891d
import json def get_json_data(page): with open('geekshop/json_data.json', encoding='utf-8-sig') as file: json_data = json.load(file) return json_data[page] def get_json_products_data(file_path): with open(file_path, encoding='utf-8-sig') as file: json_data = json.load(file) return js...
[ "import json\n\n\ndef get_json_data(page):\n with open('geekshop/json_data.json', encoding='utf-8-sig') as file:\n json_data = json.load(file)\n return json_data[page]\n\n\ndef get_json_products_data(file_path):\n with open(file_path, encoding='utf-8-sig') as file:\n json_data = json.load(fil...
false
5,693
4d57fa22282d7b3f8adabedd7a04e32767181890
from functions.service_funcs.get_data import get_data_character def clean_room(update): char, db_sess = get_data_character(update, return_sess=True) # удаляем старую комнату и всю инфу о ней if char and char.room: if char.room.mobs: for mob in char.room.mobs: db_sess.de...
[ "from functions.service_funcs.get_data import get_data_character\n\n\ndef clean_room(update):\n char, db_sess = get_data_character(update, return_sess=True)\n # удаляем старую комнату и всю инфу о ней\n if char and char.room:\n if char.room.mobs:\n for mob in char.room.mobs:\n ...
false
5,694
2f15814d97708e33585ea6b45e89b5a5e69d82fe
import json import nltk with open('posts.json', 'r') as infile: posts = [] for line in infile: posts.append(json.loads(line[0:len(line)-2])) for post in posts: print '\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n' print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
[ "import json\nimport nltk\n\nwith open('posts.json', 'r') as infile:\n\tposts = []\n\tfor line in infile:\n\t\tposts.append(json.loads(line[0:len(line)-2]))\n\nfor post in posts:\n print '\\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\\n'\n print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...
true
5,695
b874bb37fa59d9f1194c517bedbdbafae748786e
S = input() T = [] sen = ["dream", "dreamer", "erase", "eraser"] s_len = len(S) while len(T) <= s_len:
[ "S = input()\n\nT = []\nsen = [\"dream\", \"dreamer\", \"erase\", \"eraser\"]\ns_len = len(S)\n\n\nwhile len(T) <= s_len:\n " ]
true
5,696
05d21a27097cf3295e9328aeafa466973a4d2611
/home/salmane/anaconda3/lib/python3.7/_weakrefset.py
[ "/home/salmane/anaconda3/lib/python3.7/_weakrefset.py" ]
true
5,697
5e79a8a8fe79aac900fc0c2ff1caaa73ea08ada2
from django import template register = template.Library() @register.filter(name='phone_number') def phone_number(number): # Convert a 10 character string into (xxx) xxx-xxxx. first = number[0:3] second = number[3:6] third = number[6:10] return '(' + first + ')' + ' ' + second + '-' + third
[ "from django import template\n\nregister = template.Library()\n\n\n@register.filter(name='phone_number')\ndef phone_number(number): # Convert a 10 character string into (xxx) xxx-xxxx.\n\tfirst = number[0:3]\n\tsecond = number[3:6]\n\tthird = number[6:10]\n\treturn '(' + first + ')' + ' ' + second + '-' + third\n",...
false
5,698
1f94ef0aae1128089b34fc952766cc3927677cdf
#!/usr/bin/python3 # -*- coding: utf-8 -*- #Modules externes import os import re import logging import csv import xml.etree.ElementTree as ET from chardet import detect #Modules maison from Abes_Apis_Interface.AbesXml import AbesXml from Alma_Apis_Interface import Alma_Apis_Records from Alma_Apis_Interface import Alma...
[ "#!/usr/bin/python3\n# -*- coding: utf-8 -*-\n#Modules externes\nimport os\nimport re\nimport logging\nimport csv\nimport xml.etree.ElementTree as ET\nfrom chardet import detect\n\n#Modules maison\nfrom Abes_Apis_Interface.AbesXml import AbesXml\nfrom Alma_Apis_Interface import Alma_Apis_Records\nfrom Alma_Apis_Int...
false
5,699
8251a9c798b3cdc2f374d0a0406ccfaa11b7c5e3
__version__ = '0.2.11' # This list defines all the modules that will be loaded if a user invokes # from climLab import * # totally out of date! #__all__ = ["constants", "thermo", "orbital_table", # "long_orbital_table", "insolation", "ebm", # "column", "convadj"] #from climlab import radiatio...
[ "__version__ = '0.2.11'\n\n# This list defines all the modules that will be loaded if a user invokes\n# from climLab import *\n\n# totally out of date!\n\n#__all__ = [\"constants\", \"thermo\", \"orbital_table\",\n# \"long_orbital_table\", \"insolation\", \"ebm\",\n# \"column\", \"convadj\"]\...
false