code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
__doc__ = """ Dataset Module Utilities - mostly for handling files and datasets """ import glob import os import random from meshparty import mesh_io # Datasets ----------------------- SVEN_BASE = "seungmount/research/svenmd" NICK_BASE = "seungmount/research/Nick/" BOTH_BASE = "seungmount/research/nick_and_sven" DAT...
normal
{ "blob_id": "fd0db093b72dad4657d71788405fcca4ba55daff", "index": 8529, "step-1": "<mask token>\n\n\ndef fetch_dset_dirs(dset_name=None):\n \"\"\"\n Finds the global pathname to a list of directories which represent a\n dataset by name.\n \"\"\"\n assert dset_name is None or dset_name in DATASET_DI...
[ 3, 4, 6, 7, 8 ]
from django.db import models import django.utils.timezone as timezone # Create your models here. # Create your models here. class Categories(models.Model): # 文章分类 name = models.CharField(max_length=200, verbose_name = "分类名称") parent = models.ForeignKey('self', default=0, on_delete=models.DO_NOTHING, null = True...
normal
{ "blob_id": "512a13084a860e2784020664a3d5824d9dace6db", "index": 7764, "step-1": "<mask token>\n\n\nclass Images(models.Model):\n wordroot_text = models.CharField(max_length=255, verbose_name='词根')\n wordroot_id = models.IntegerField(default=0, null=True, blank=True,\n verbose_name='词根id, 可空')\n ...
[ 14, 20, 22, 26, 27 ]
''' Created on 2021. 4. 8. @author: user ''' import matplotlib.pyplot as plt import numpy as np plt.rc("font", family="Malgun Gothic") def scoreBarChart(names, score): plt.bar(names, score) plt.show() def multiBarChart(names, score): plt.plot(names, score, "ro--") plt.plot([1, 2, 3], [70, 8...
normal
{ "blob_id": "542602a42eb873508ce2ec39d0856f10cc1e04ff", "index": 8426, "step-1": "<mask token>\n\n\ndef scoreBarChart(names, score):\n plt.bar(names, score)\n plt.show()\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef scoreBarChart(names, score):\n plt.bar(names, score)\n plt.show()\n\n\ndef...
[ 1, 2, 3, 4, 5 ]
Xeval[[1,2],:] # *** Spyder Python Console History Log *** Xeval[:,:] optfunc.P(Xeval[:,:]) optfunc.P(Xeval) optfunc.P(Xeval[[0,1,2,3,4],:]) optfunc.P(Xeval[[0,1,],:]) optfunc.P(Xeval[[0,1],:]) optfunc.P(Xeval[[0,1,2,3],:]) optfunc.P(Xeval[[0,1,2,3,4],:]) optfunc.P(Xeval[[0,1,2],:]) Xeval[[0,1,2,3,4],:] Xev...
normal
{ "blob_id": "02b20c3f5941873dfd22a7fbedb825e66c613ace", "index": 2278, "step-1": "Xeval[[1,2],:]\r\n# *** Spyder Python Console History Log ***\r\nXeval[:,:]\r\noptfunc.P(Xeval[:,:])\r\noptfunc.P(Xeval)\r\noptfunc.P(Xeval[[0,1,2,3,4],:])\r\noptfunc.P(Xeval[[0,1,],:])\r\noptfunc.P(Xeval[[0,1],:])\r\noptfunc.P(Xev...
[ 0 ]
import numpy as np a = np.ones((3,4)) b = np.ones((4,1)) # a.shape = (3,4) # b.shape = (4,1) c = np.zeros_like(a) for i in range(3): for j in range(4): c[i][j] = a[i][j] + b[j] print(c) d = a+b.T print(d)
normal
{ "blob_id": "d6213698423902771011caf6b5206dd4e3b27450", "index": 5753, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(3):\n for j in range(4):\n c[i][j] = a[i][j] + b[j]\nprint(c)\n<mask token>\nprint(d)\n", "step-3": "<mask token>\na = np.ones((3, 4))\nb = np.ones((4, 1))\nc =...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 3.0.5 on 2020-05-02 18:58 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('weatherData', '0001_initial'), ] operations = [ migrations.AddField( model_name='city', name='username', ...
normal
{ "blob_id": "6b6b734c136f3c4ed5b2789ab384bab9a9ea7b58", "index": 9368, "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 = [('weatherData...
[ 0, 1, 2, 3, 4 ]
import sys INF = sys.maxsize def bellman_ford(graph,start): distance = {} predecessor = {} # 거리 값, 이전 정점 초기화 for node in graph: distance[node] = INF predecessor[node] = None distance[start] = 0 # V-1개마큼 반복 for _ in range(len(graph)-1): for node in graph: ...
normal
{ "blob_id": "8ebf031cb294c69bf744d543b18783d6ac5ef257", "index": 1910, "step-1": "<mask token>\n\n\ndef bellman_ford(graph, start):\n distance = {}\n predecessor = {}\n for node in graph:\n distance[node] = INF\n predecessor[node] = None\n distance[start] = 0\n for _ in range(len(gra...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.1 on 2016-10-28 17:50 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion import django.utils.timezone class Migration(migrations.Migration): initial = True dependencies = [ ] operations...
normal
{ "blob_id": "b0064a5cd494d5ad232f27c63a4df2c56a4c6a66", "index": 5241, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Migration(migrations.Migration):\n <mask token>\n <mask token>\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Migration(migrations.Migration):\n initial = T...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.2.17 on 2020-12-05 07:43 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('service', '0001_initial'), ] operations = [ migrations.AlterField( model_name='identification', name='id_card_img',...
normal
{ "blob_id": "b6a0a49e05fbc0ac7673d6c9e8ca4d263c8bb5cd", "index": 7132, "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 = [('service', '...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # Define your item pipelines here # # Don't forget to add your pipeline to the ITEM_PIPELINES setting # See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html import csv from bookstoscrapy import settings def write_to_csv(item): writer = csv.writer(open(settings.csv_file_path, '...
normal
{ "blob_id": "f0c621583caf6eea6f790649862a03a464f6574b", "index": 3727, "step-1": "<mask token>\n\n\nclass WriteToCsv(object):\n <mask token>\n\n def process_item(self, item, spider):\n write_to_csv(item)\n return item\n", "step-2": "<mask token>\n\n\nclass WriteToCsv(object):\n item_coun...
[ 2, 3, 4, 5, 6 ]
# Generated by Django 3.1.7 on 2021-04-16 05:56 from django.db import migrations import django.db.models.manager class Migration(migrations.Migration): dependencies = [ ('Checkbook', '0002_auto_20210415_2250'), ] operations = [ migrations.AlterModelManagers( name='transactio...
normal
{ "blob_id": "f15f49a29f91181d0aaf66b19ce9616dc7576be8", "index": 6740, "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 = [('Checkbook',...
[ 0, 1, 2, 3, 4 ]
class Fail(Exception): def __init__(self, message): super().__init__(message) class Student: def __init__(self, rollNo, name, marks): self.rollNo = rollNo self.name = name self.marks = marks def displayDetails(self): print('{} \t {} \t {}'.format(self.name, self....
normal
{ "blob_id": "ddf074e400551d2c147d898fe876a31d13a72699", "index": 5324, "step-1": "<mask token>\n\n\nclass Student:\n <mask token>\n\n def displayDetails(self):\n print('{} \\t {} \\t {}'.format(self.name, self.rollNo, self.marks))\n try:\n if self.marks < 40:\n raise...
[ 2, 5, 6, 7 ]
r""" 测试dispatch >>> from url_router.map import Map >>> from url_router.rule import Rule >>> m = Map([ ... Rule('/', endpoint='index'), ... Rule('/foo', endpoint='foo'), ... Rule('/bar/', endpoint='bar'), ... Rule('/any/<name>', endpoint='any'), ... Rule('/string/<string:name>', endpoint='string'), ...
normal
{ "blob_id": "3cca7408eb88f91f295c581c29d3d1e95298f337", "index": 6445, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n import doctest\n doctest.testmod()\n", "step-3": "r\"\"\" 测试dispatch\n\n>>> from url_router.map import Map\n>>> from url_router.rule import Rule\n>>> ...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals import requests from bs4 import BeautifulSoup url = "http://javmobile.net/?s=julia" r = requests.get(url) soup = BeautifulSoup(r.content, "html.parser") imgs = soup.find_all("img" , {"class": "entry-thumb"}) images = [] titles = [] srcs = [] for img...
normal
{ "blob_id": "a9df8e45c8b5068aeec2b79e21de6217a3103bb4", "index": 2492, "step-1": "# -*- coding: utf-8 -*-\nfrom __future__ import unicode_literals\nimport requests\nfrom bs4 import BeautifulSoup\n\n\nurl = \"http://javmobile.net/?s=julia\"\nr = requests.get(url)\n\nsoup = BeautifulSoup(r.content, \"html.parser\"...
[ 0 ]
from typing import List from fastapi import Depends, FastAPI, HTTPException from sqlalchemy.orm import Session from myfirstpython.fastapi import models, crud, schemas from myfirstpython.fastapi.dbconnection import engine, SessionLocal models.Base.metadata.create_all(bind=engine) app = FastAPI() # Dependency def g...
normal
{ "blob_id": "ad474f5120ca2a8c81b18071ab364e6d6cf9e653", "index": 7031, "step-1": "<mask token>\n\n\n@app.get('/jobs/', response_model=List[schemas.Job])\ndef read_jobs(skip: int=0, limit: int=100, db: Session=Depends(get_db)):\n jobs = crud.get_jobs(db, skip=skip, limit=limit)\n return jobs\n\n\n@app.get('...
[ 6, 8, 10, 11, 13 ]
from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QLineEdit, QRadioButton, QPushButton, QTableWidgetItem, QTableWidget, QApplication, QMainWindow, QDateEdit, QLabel, QDialog, QTextEdit, QCheckBox from PyQt5.QtCore import QDate, QTime, QDateTime, Qt from OOPCourseWorkTwo.GUI.SingleAnswerQuestionDi...
normal
{ "blob_id": "98f234ca0cbec419466de0504fd8d5c68fd07627", "index": 9609, "step-1": "<mask token>\n\n\nclass TeacherGUI:\n <mask token>\n\n @classmethod\n def setup(cls, ui_mainwindow):\n cls.__ui_mainwindow = ui_mainwindow\n\n @classmethod\n def display_all_active_school_classes(cls, school_c...
[ 100, 103, 113, 122, 132 ]
from typing import * class Solution: def isMonotonic(self, A: List[int]) ->bool: flag = 0 for i in range(1, len(A)): diff = A[i] - A[i - 1] if diff * flag < 0: return False if flag == 0: flag = diff return True sl = Sol...
normal
{ "blob_id": "a55d1286485e66a64aa78259ad1b1922c5c4c831", "index": 4385, "step-1": "<mask token>\n\n\nclass Solution:\n\n def isMonotonic(self, A: List[int]) ->bool:\n flag = 0\n for i in range(1, len(A)):\n diff = A[i] - A[i - 1]\n if diff * flag < 0:\n return...
[ 2, 3, 4, 5 ]
from import_export.admin import ImportExportMixin from django.contrib import admin from import_export import resources, widgets, fields from .models import Addgroup,Addsystemname,Zhuanzhebushi,Yewuzerenbumen,czyylx,Zhuanze,Data from import_export import fields, resources from import_export.widgets import ForeignKeyWidg...
normal
{ "blob_id": "016b64a2eb4af3034d54272c878fb917506d330c", "index": 648, "step-1": "<mask token>\n\n\nclass DataResource(resources.ModelResource):\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n fields = 'groupname', 'system_name', 'I6000'\n\n\nclass DataAdmin(ImportExportMixin, ...
[ 3, 4, 5, 6, 7 ]
# Generated by Django 2.2.13 on 2021-08-11 15:38 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ("notifications", "0011_auto_20171229_1747"), ] operations = [ migrations.AlterField( model_name="notification", name...
normal
{ "blob_id": "fa045ccd4e54332f6c05bf64e3318e05b8123a10", "index": 3317, "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 = [('notificatio...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python #-*- coding: utf-8 -*- import pygtk pygtk.require("2.0") import gtk from testarMsg import * class tgApp(object): def __init__(self): builder = gtk.Builder() builder.add_from_file("../tg.glade") self.window = builder.get_object("window1") self.text_area = buil...
normal
{ "blob_id": "6b6fac3bfb1b1478dd491fc4dd9c45a19aeb7bd8", "index": 6102, "step-1": "<mask token>\n\n\nclass tgApp(object):\n\n def __init__(self):\n builder = gtk.Builder()\n builder.add_from_file('../tg.glade')\n self.window = builder.get_object('window1')\n self.text_area = builder...
[ 6, 8, 9, 10, 12 ]
""" common tests """ from django.test import TestCase from src.core.common import get_method_config from src.predictive_model.classification.models import ClassificationMethods from src.predictive_model.models import PredictiveModels from src.utils.tests_utils import create_test_job, create_test_predictive_model cl...
normal
{ "blob_id": "824038a56e8aaf4adf6ec813a5728ab318547582", "index": 1638, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TestCommon(TestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TestCommon(TestCase):\n\n def test_get_method_config(self):\n job = create_test_job(pr...
[ 0, 1, 2, 3, 4 ]
# https://daphne-dev.github.io/2020/09/24/algo-022/ def solution(n): arr = [[0 for _ in range(i+1)] for i in range(n)] # 경우의수 는 3가지 # 1. y축이 증가하면서 수가 증가 # 2. x축이 증가하면서 수가 증가 # 3. y,x축이 감소하면서 수가 증가 size = n num = 0 x = 0 y = -1 while True: # 1번 for _ in range(size)...
normal
{ "blob_id": "3c029adb59cd6db1e3d4a22e6561f5e2ae827d60", "index": 2465, "step-1": "<mask token>\n", "step-2": "def solution(n):\n arr = [[(0) for _ in range(i + 1)] for i in range(n)]\n size = n\n num = 0\n x = 0\n y = -1\n while True:\n for _ in range(size):\n num += 1\n ...
[ 0, 1, 2 ]
import tensorflow.keras from PIL import Image, ImageOps from os import listdir from os.path import isfile, join import numpy as np import glob import cv2 np.set_printoptions(suppress = True) # Load the model model = tensorflow.keras.models.load_model('./converted_keras/keras_model.h5') # Create the array of the righ...
normal
{ "blob_id": "13b69ec61d6b2129f1974ce7cae91c84100b3b58", "index": 449, "step-1": "<mask token>\n", "step-2": "<mask token>\nnp.set_printoptions(suppress=True)\n<mask token>\nfor image in path:\n n1 = cv2.imread(image)\n n2 = cv2.resize(n1, (244, 244))\n images.append(n2)\n print(image)\n<mask token>...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2016-10-14 19:37 from __future__ import unicode_literals from django.conf import settings from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ...
normal
{ "blob_id": "8c05259ce577e6b6a6efdf778832e9bb817e47fd", "index": 1414, "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 = [migrations.sw...
[ 0, 1, 2, 3, 4 ]
import sys def caesar( plaintext, key ): if int( key ) < 0: return plaintext_ascii = [ ( ord( char ) + int( key ) ) for char in plaintext ] for ascii in plaintext_ascii: if ( ascii < 97 and ascii > 90 ) or ascii > 122: ascii -= 25 ciphertext = ''.join( [ chr( ascii ) for a...
normal
{ "blob_id": "9a7c6998e9e486f0497d3684f9c7a422c8e13521", "index": 7076, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef caesar(plaintext, key):\n if int(key) < 0:\n return\n plaintext_ascii = [(ord(char) + int(key)) for char in plaintext]\n for ascii in plaintext_ascii:\n if ...
[ 0, 1, 2, 3, 4 ]
# Importing datasets wrangling libraries import numpy as np import pandas as pd incd_data = pd.read_csv('data/Cancer/incd.csv', usecols=['State', 'FIPS', 'Age-Adjusted Incidence Rate([rate note]) - cases per 100,000', 'Average Annual Count', 'Recent Trend']) print(incd_data.columns)
normal
{ "blob_id": "1deab16d6c574bf532c561b8d6d88aac6e5d996c", "index": 8355, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(incd_data.columns)\n", "step-3": "<mask token>\nincd_data = pd.read_csv('data/Cancer/incd.csv', usecols=['State', 'FIPS',\n 'Age-Adjusted Incidence Rate([rate note]) - cases pe...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Module that defines a controller for database's operations over business rules """ # built-in dependencies import functools import typing # external dependencies import sqlalchemy from sqlalchemy.orm import sessionmaker # project dependencies from database.table im...
normal
{ "blob_id": "c024e12fe06e47187c25a9f384ceed566bf94645", "index": 6909, "step-1": "<mask token>\n\n\nclass _DatabaseResourceTableController:\n <mask token>\n <mask token>\n\n def register_peer(self, peer_id: str, peer_ip: str, peer_port: int,\n resource_name: str, resource_path: str, resource_hash...
[ 5, 6, 7, 9, 11 ]
import matplotlib.pyplot as plt import numpy as np x = [1, 2, 2.5, 3, 4] # x-coordinates for graph y = [1, 4, 7, 9, 15] # y-coordinates plt.axis([0, 6, 0, 20]) # creating my x and y axis range. 0-6 is x, 0-20 is y plt.plot(x, y, 'ro') # can see graph has a linear correspondence, therefore, can use linear regression ...
normal
{ "blob_id": "c69c8ba218935e5bb065b3b925cc7c5f1aa2957b", "index": 5806, "step-1": "<mask token>\n", "step-2": "<mask token>\nplt.axis([0, 6, 0, 20])\nplt.plot(x, y, 'ro')\nplt.plot(np.unique(x), np.poly1d(np.polyfit(x, y, 1))(np.unique(x)))\nplt.show()\n", "step-3": "<mask token>\nx = [1, 2, 2.5, 3, 4]\ny = [...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Alonso Vidales" __email__ = "alonso.vidales@tras2.es" __date__ = "2013-11-11" class ConnectedSets: """ This is a classic percolation problem, the algorithms uses an array of integer to represent tees, each tree will be a set of connected element...
normal
{ "blob_id": "d18c0fa29ccdabdd9e11622e8aaec91ff96117df", "index": 6650, "step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*- \n\n__author__ = \"Alonso Vidales\"\n__email__ = \"alonso.vidales@tras2.es\"\n__date__ = \"2013-11-11\"\n\nclass ConnectedSets:\n \"\"\"\n This is a classic percolation problem, ...
[ 0 ]
#!/usr/bin/env python ''' @author : Mitchell Van Braeckel @id : 1002297 @date : 10/10/2020 @version : python 3.8-32 / python 3.8.5 @course : CIS*4010 Cloud Computing @brief : A1 Part 2 - AWS DynamoDB ; Q2 - Query OECD @note : Description: There are many CSV files containing info from the OECD about agricultural p...
normal
{ "blob_id": "05186093820dffd047b0e7b5a69eb33f94f78b80", "index": 6787, "step-1": "<mask token>\n\n\ndef main():\n global dynamodb_client\n global dynamodb_resource\n global na_table\n global canada_table\n global usa_table\n global mexico_table\n global total_can_usa\n global total_can_us...
[ 5, 6, 7, 9, 10 ]
import math print(dir(math)) # Prints a list of entities residing in the math module
normal
{ "blob_id": "94056e8920d265831da67bd1d999330a47a7ef0d", "index": 1991, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(dir(math))\n", "step-3": "import math\nprint(dir(math))\n", "step-4": "import math\nprint(dir(math))\n\n# Prints a list of entities residing in the math module", "step-5": nul...
[ 0, 1, 2, 3 ]
#Voir paragraphe "3.6 Normalizing Text", page 107 de NLP with Python from nltk.stem.snowball import SnowballStemmer from nltk.stem.wordnet import WordNetLemmatizer # Il faut retirer les stopwords avant de stemmer stemmer = SnowballStemmer("english", ignore_stopwords=True) lemmatizer = WordNetLemmatizer() source = ...
normal
{ "blob_id": "1f1677687ba6ca47b18728b0fd3b9926436e9796", "index": 2949, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(stems1)\nprint(stems2)\nprint(stems3)\n", "step-3": "<mask token>\nstemmer = SnowballStemmer('english', ignore_stopwords=True)\nlemmatizer = WordNetLemmatizer()\nsource = ['having...
[ 0, 1, 2, 3, 4 ]
linha = input().split() a = float(linha[0]) b = float(linha[1]) c = float(linha[2]) t = (a*c)/2 print('TRIANGULO: {:.3f}'.format(t)) pi = 3.14159 print("CIRCULO: {:.3f}".format(pi*c**2)) print('TRAPEZIO: {:.3f}'.format( ((a+b)*c)/2 )) print("QUADRADO: {:.3f}".format(b**2)) print("RETANGULO: {:.3f}".format(a*b))
normal
{ "blob_id": "d44d9003e9b86722a0fc1dfe958de462db9cd5f1", "index": 1670, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('TRIANGULO: {:.3f}'.format(t))\n<mask token>\nprint('CIRCULO: {:.3f}'.format(pi * c ** 2))\nprint('TRAPEZIO: {:.3f}'.format((a + b) * c / 2))\nprint('QUADRADO: {:.3f}'.format(b ** 2...
[ 0, 1, 2, 3 ]
""" """ import cPickle as pickle def convert_cpu_stats_to_num_array(cpuStats): """ Given a list of statistics (tuples[timestamp, total_cpu, kernel_cpu, vm, rss]) Return five numarrays """ print "Converting cpus stats into numpy array" c0 = [] c1 = [] c2 = [] c3 = [] c4 = [] ...
normal
{ "blob_id": "85f5f9370896eac17dc72bbbf8d2dd1d7adc3a5b", "index": 7872, "step-1": "\"\"\"\n\n\"\"\"\nimport cPickle as pickle\n\n\ndef convert_cpu_stats_to_num_array(cpuStats):\n \"\"\"\n Given a list of statistics (tuples[timestamp, total_cpu, kernel_cpu, vm, rss])\n Return five numarrays\n \"\"\"\n ...
[ 0 ]
''' The while statement allows you to repeatedly execute a block of statements as long as a condition is true. A while statement is an example of what is called a looping statement. A while statement can have an optional else clause. ''' #Modifying the values using while loop in a list l1: list = [1,2,3,4,5,6,7,8,9,10...
normal
{ "blob_id": "6a3fd3323ed8792853afdf5af76161f3e20d4896", "index": 4443, "step-1": "<mask token>\n", "step-2": "<mask token>\nl1: list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]\nprint('The original list: ', l1)\n<mask token>\nwhile i < len(l1):\n l1[i] = l1[i] + 100\n i = i + 1\nprint('The modified new list is: ',...
[ 0, 1, 2, 3 ]
# coding=utf-8 # Copyright 2021-Present The THUCTC Authors from __future__ import absolute_import from __future__ import division from __future__ import print_function import math import torch import torch.nn as nn import thuctc.utils as utils from thuctc.modules.module import Module from thuctc.modules.layer_norm ...
normal
{ "blob_id": "c773b273ad6953bf9c74b11c44aff16e9fd0860e", "index": 3468, "step-1": "<mask token>\n\n\nclass Embedding(Module):\n\n def __init__(self, embed_nums, embed_dims, bias=False, name='embedding'):\n super(Embedding, self).__init__(name=name)\n self.embed_nums = embed_nums\n self.emb...
[ 7, 9, 10, 12, 13 ]
from django.db import models from django.urls import reverse from django.conf import settings from embed_video.fields import EmbedVideoField from django.contrib.auth.models import AbstractBaseUser User = settings.AUTH_USER_MODEL # Create your models here. """class User(models.Model): username = models.CharField(...
normal
{ "blob_id": "5c4a48de94cf5bfe67e6a74c33a317fa1da8d2fa", "index": 7330, "step-1": "<mask token>\n\n\nclass Post(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n ordering = ['parent_id', 'created_at']\n <mask token>\n <mask...
[ 3, 7, 8, 9, 10 ]
/home/mitchellwoodbine/Documents/github/getargs/GetArgs.py
normal
{ "blob_id": "0065a493767a2080a20f8b55f76ddeae92dc27f1", "index": 3359, "step-1": "/home/mitchellwoodbine/Documents/github/getargs/GetArgs.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
/Users/apple/miniconda3/lib/python3.7/sre_constants.py
normal
{ "blob_id": "71a5ba520f8bc42e80d8f4ce8cf332bdd5fb96de", "index": 5293, "step-1": "/Users/apple/miniconda3/lib/python3.7/sre_constants.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
# 6. Evaluate Classifier: you can use any metric you choose for this assignment # (accuracy is the easiest one). Feel free to evaluate it on the same data you # built the model on (this is not a good idea in general but for this assignment, # it is fine). We haven't covered models and evaluation yet, so don't worry ...
normal
{ "blob_id": "62de629d8f28435ea8dc3dc093cac95e7cedf128", "index": 7859, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef evaluate(model, X_te, y_te):\n \"\"\"\n Given the model and independent and dependent testing data,\n print out statements that evaluate classifier\n \"\"\"\n probs...
[ 0, 1, 2, 3, 4 ]
__author__ = 'tomer' import sqlite3 from random import randint import test_data def init_database(conn): c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS catalogs (id INTEGER PRIMARY KEY AUTOINCREMENT, catalog_name TEXT)''') c.execute('''CREATE TABLE IF NOT EXISTS products ...
normal
{ "blob_id": "46b1e5adbd956c35820d7d2b17628364388cdcd7", "index": 3638, "step-1": "<mask token>\n\n\ndef init_database(conn):\n c = conn.cursor()\n c.execute(\n \"\"\"CREATE TABLE IF NOT EXISTS catalogs\n (id INTEGER PRIMARY KEY AUTOINCREMENT, catalog_name TEXT)\"\"\"\n )\n ...
[ 9, 17, 19, 20, 21 ]
# use local image import io import os from google.cloud import vision from google.oauth2 import service_account creds = service_account.Credentials.from_service_account_file('./key.json') client = vision.ImageAnnotatorClient( credentials=creds, ) # The name of the image file to annotate file_name = os.path.joi...
normal
{ "blob_id": "800573786913ff2fc37845193b5584a0a815533f", "index": 8340, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith io.open(file_name, 'rb') as image_file:\n content = image_file.read()\n<mask token>\nprint(response)\nprint(response.safe_search_annotation.adult)\nfor label in response.label_ann...
[ 0, 1, 2, 3, 4 ]
from flask import Flask, request, g from flask_restful import Resource, Api from sqlalchemy import create_engine from flask import jsonify import json import eth_account import algosdk from sqlalchemy.orm import sessionmaker from sqlalchemy.orm import scoped_session from sqlalchemy.orm import load_only from datetime im...
normal
{ "blob_id": "d9bdf466abecb50c399556b99b41896eead0cb4b", "index": 2959, "step-1": "<mask token>\n\n\n@app.before_request\ndef create_session():\n g.session = scoped_session(DBSession)\n\n\n<mask token>\n\n\ndef check_sig(payload, sig):\n pk = payload['sender_pk']\n platform = payload['platform']\n pay...
[ 7, 8, 11, 12, 13 ]
import requests, shutil, os, glob from zipfile import ZipFile import pandas as pd from xlrd import open_workbook import csv # zipfilename = 'desiya_hotels' # try: # # downloading zip file # r = requests.get('http://staticstore.travelguru.com/testdump/1300001176/Excel.zip', auth=('testdump', 'testdump'), veri...
normal
{ "blob_id": "1ef9df43725196904ec6c0c881f4a1204174b176", "index": 375, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open(os.path.join(os.path.dirname(__file__), 'storage/robot_list.csv'),\n 'w') as file:\n writer = csv.writer(file, delimiter=',')\n headers = [cell.value for cell in sheet.r...
[ 0, 1, 2, 3, 4 ]
from sqlalchemy import create_engine from sqlalchemy import Table,Column,Integer,String,MetaData,ForeignKey from sqlalchemy.sql import select from sqlalchemy import text #Creating a database 'college.db' engine = create_engine('sqlite:///college.db', echo=True) meta = MetaData() #Creating a Students table s...
normal
{ "blob_id": "7ea6fefa75d36ff45dcea49919fdc632e378a73f", "index": 9113, "step-1": "<mask token>\n", "step-2": "<mask token>\nmeta.create_all(engine)\n<mask token>\nconn.execute(students.insert(), [{'name': 'Rajiv', 'lastname': 'Khanna'}, {\n 'name': 'Komal', 'lastname': 'Bhandari'}, {'name': 'Abdul', 'lastna...
[ 0, 1, 2, 3, 4 ]
''' Code for mmDGM Author: Chongxuan Li (chongxuanli1991@gmail.com) Version = '1.0' ''' import gpulearn_mm_z_x import sys, os import time import color n_hidden = (500,500) if len(sys.argv) > 2: n_hidden = tuple([int(x) for x in sys.argv[2:]]) nz=500 if os.environ.has_key('nz'): nz = int(os.environ['nz']) if os.en...
normal
{ "blob_id": "40158bbfd9c95a8344f34431d0b0e98c4a1bf6ed", "index": 476, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv) > 2:\n n_hidden = tuple([int(x) for x in sys.argv[2:]])\n<mask token>\nif os.environ.has_key('nz'):\n nz = int(os.environ['nz'])\nif os.environ.has_key('stepsize'):\...
[ 0, 1, 2, 3, 4 ]
''' Created on May 18, 2010 @author: Abi.Mohammadi & Majid.Vesal ''' from threading import current_thread import copy import time from deltapy.core import DeltaException, Context import deltapy.security.services as security_services import deltapy.security.session.services as session_services import deltapy.unique...
normal
{ "blob_id": "80469fd945a21c1bd2b5590047016a4b60880c88", "index": 7006, "step-1": "<mask token>\n\n\nclass Session:\n <mask token>\n\n\n class StateEnum:\n \"\"\"\n A class for defining session state.\n \"\"\"\n ACTIVE = 'Active'\n INACTIVE = 'Inactive'\n CLOSED = '...
[ 18, 21, 25, 28, 31 ]
from rest_framework.serializers import ModelSerializer from rest_framework.serializers import ReadOnlyField from rest_framework.serializers import SlugField from rest_framework.validators import UniqueValidator from django.db import models from illumidesk.teams.util import get_next_unique_team_slug from illumidesk.us...
normal
{ "blob_id": "c005ae9dc8b50e24d72dbc99329bb5585d617081", "index": 5590, "step-1": "<mask token>\n\n\nclass InvitationSerializer(ModelSerializer):\n <mask token>\n <mask token>\n\n\n class Meta:\n model = Invitation\n fields = 'id', 'team', 'email', 'role', 'invited_by', 'is_accepted'\n\n\nc...
[ 4, 6, 8, 9, 10 ]
from robocorp_ls_core.python_ls import PythonLanguageServer from robocorp_ls_core.basic import overrides from robocorp_ls_core.robotframework_log import get_logger from typing import Optional, List, Dict from robocorp_ls_core.protocols import IConfig, IMonitor, ITestInfoTypedDict, IWorkspace from functools import parti...
normal
{ "blob_id": "18b43ea8696e2e54f4c1cbbece4cde1fd3130145", "index": 194, "step-1": "<mask token>\n\n\nclass RobotFrameworkServerApi(PythonLanguageServer):\n <mask token>\n\n def __init__(self, read_from, write_to, libspec_manager=None, observer:\n Optional[IFSObserver]=None):\n from robotframewo...
[ 19, 33, 35, 44, 51 ]
from django.forms import ModelForm from contactform.models import ContactRequest class ContactRequestForm(ModelForm): class Meta: model = ContactRequest
normal
{ "blob_id": "97637e2114254b41ef6e777e60b3ddab1d4622e8", "index": 4606, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass ContactRequestForm(ModelForm):\n\n\n class Meta:\n model = ContactRequest\n", "step-3": "from django.forms import ModelForm\nfrom contactform.models import ContactRe...
[ 0, 1, 2 ]
class Enumerator(object): """For Python we just wrap the iterator""" def __init__(self, next): self.iterator = next def __next__(self): return next(self.iterator) # Python 2.7 next = __next__ def __iter__(self): return self
normal
{ "blob_id": "1ca20b0cd9217623ff039ab352acd09df8dfae1b", "index": 8235, "step-1": "class Enumerator(object):\n <mask token>\n <mask token>\n\n def __next__(self):\n return next(self.iterator)\n <mask token>\n\n def __iter__(self):\n return self\n", "step-2": "class Enumerator(object...
[ 3, 4, 5, 6, 7 ]
from io import StringIO from pathlib import Path from unittest import TestCase from doculabs.samon import constants from doculabs.samon.elements import BaseElement, AnonymusElement from doculabs.samon.expressions import Condition, ForLoop, Bind class BaseElementTest(TestCase): def assertXmlEqual(self, generated_...
normal
{ "blob_id": "c6b98cf309e2f1a0d279ec8dc728ffd3fe45dfdb", "index": 4792, "step-1": "<mask token>\n\n\nclass BaseElementTest(TestCase):\n <mask token>\n <mask token>\n\n def test_parse_expressions(self):\n xml_attrs = {(constants.XML_NAMESPACE_FLOW_CONTROL, 'if'):\n 'val == 7', (constants...
[ 5, 7, 8, 9, 11 ]
import tests.functions as functions if __name__ == "__main__": # functions.validate_all_redirects("linked.data.gov.au-vocabularies.json") conf = open("../conf/linked.data.gov.au-vocabularies.conf") new = [ "anzsrc-for", "anzsrc-seo", "ausplots-cv", "australian-phone-area...
normal
{ "blob_id": "4a620957b2cd1e5945d98e49a5eae5d5592ef5a2", "index": 3911, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n conf = open('../conf/linked.data.gov.au-vocabularies.conf')\n new = ['anzsrc-for', 'anzsrc-seo', 'ausplots-cv',\n 'australian-phone-area-codes', ...
[ 0, 1, 2, 3 ]
import heapq as heap import networkx as nx import copy import random def remove_jumps(moves): res = [] for move in moves: if move[2] > 1: move[3].reverse() res.extend(make_moves_from_path(move[3])) else: res.append(move) return res def make_moves_from...
normal
{ "blob_id": "800edfc61635564abf8297c4f33c59d48cc99960", "index": 4058, "step-1": "<mask token>\n\n\ndef make_moves_from_path(path):\n moves = []\n p = path[:]\n for i in range(len(p) - 1):\n moves.append((p[i + 1], p[i], 1, [p[i + 1], p[i]]))\n return moves\n\n\ndef find_nearest_hole(o, r, gra...
[ 7, 11, 12, 16, 19 ]
# -*- coding: utf-8 -*- ########### SVN repository information ################### # $Date: $ # $Author: $ # $Revision: $ # $URL: $ # $Id: $ ########### SVN repository information ################### ''' *GSASIIfpaGUI: Fundamental Parameters Routines* =============================================== This module contain...
normal
{ "blob_id": "3b1426e0f29093e1e462765bcf1d351a064b9639", "index": 142, "step-1": "<mask token>\n\n\ndef SetCu2Wave():\n \"\"\"Set the parameters to the two-line Cu K alpha 1+2 spectrum\n \"\"\"\n parmDict['wave'] = {i: v for i, v in enumerate((1.540596, 1.544493))}\n parmDict['int'] = {i: v for i, v i...
[ 7, 8, 9, 10, 11 ]
import configparser # CONFIG config = configparser.ConfigParser() config.read('dwh.cfg') # DISTRIBUTION SCHEMA schema = ("""CREATE SCHEMA IF NOT EXISTS public; SET search_path TO public;""") # DROP TABLES staging_events_table_drop = ("DROP TABLE IF EXISTS staging_events;") staging_songs_table_drop = ...
normal
{ "blob_id": "65b7a14c54cd988185bac54fd8a31330966f8ba9", "index": 1916, "step-1": "<mask token>\n", "step-2": "<mask token>\nconfig.read('dwh.cfg')\n<mask token>\n", "step-3": "<mask token>\nconfig = configparser.ConfigParser()\nconfig.read('dwh.cfg')\nschema = \"\"\"CREATE SCHEMA IF NOT EXISTS public;\n ...
[ 0, 1, 2, 3, 4 ]
import nox @nox.session(python=["3.9", "3.8", "3.7", "3.6"], venv_backend="conda", venv_params=["--use-local"]) def test(session): """Add tests """ session.install() session.run("pytest") @nox.session(python=["3.9", "3.8", "3.7", "3.6"]) def lint(session): """Lint the code with flake8. """ ...
normal
{ "blob_id": "9aecf297ed36784d69e2be6fada31f7c1ac37500", "index": 4778, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@nox.session(python=['3.9', '3.8', '3.7', '3.6'], venv_backend='conda',\n venv_params=['--use-local'])\ndef test(session):\n \"\"\"Add tests\n \"\"\"\n session.install()\n...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Wed Aug 18 16:11:44 2021 @author: ignacio """ import matplotlib.pyplot as plt from numpy.linalg import inv as invertir from time import perf_counter import numpy as np def matriz_laplaciana(N, t=np.single): # funcion obtenida de clase e=np.eye(N)-np.eye(N,N,...
normal
{ "blob_id": "86345702bcd423bc31e29b1d28aa9c438629297d", "index": 7331, "step-1": "<mask token>\n\n\ndef matriz_laplaciana(N, t=np.single):\n e = np.eye(N) - np.eye(N, N, 1)\n return t(e + e.T)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef matriz_laplaciana(N, t=np.single):\n e = np.eye(N) - n...
[ 1, 2, 3, 4, 5 ]
""" TestRail API Categories """ from . import _category from ._session import Session class TestRailAPI(Session): """Categories""" @property def attachments(self) -> _category.Attachments: """ https://www.gurock.com/testrail/docs/api/reference/attachments Use the following API me...
normal
{ "blob_id": "c2467e94a2ad474f0413e7ee3863aa134bf9c51f", "index": 3399, "step-1": "<mask token>\n\n\nclass TestRailAPI(Session):\n <mask token>\n\n @property\n def attachments(self) ->_category.Attachments:\n \"\"\"\n https://www.gurock.com/testrail/docs/api/reference/attachments\n U...
[ 17, 20, 21, 22, 24 ]
#!/usr/bin/python2 import gmpy2 p = 24659183668299994531 q = 28278904334302413829 e = 11 c = 589000442361955862116096782383253550042 t = (p-1)*(q-1) n = p*q # returns d such that e * d == 1 modulo t, or 0 if no such y exists. d = gmpy2.invert(e,t) # Decryption m = pow(c,d,n) print "Solved ! m = %d" % m
normal
{ "blob_id": "61c2a6499dd8de25045733f9061d660341501314", "index": 8334, "step-1": "#!/usr/bin/python2\nimport gmpy2\n\np = 24659183668299994531\nq = 28278904334302413829\ne = 11\nc = 589000442361955862116096782383253550042\nt = (p-1)*(q-1)\nn = p*q\n\n# returns d such that e * d == 1 modulo t, or 0 if no such...
[ 0 ]
import numpy as np np.set_printoptions(precision = 1) pi = np.pi def convertRadian(theta): radian = (theta) * (np.pi) / 180 return radian def mkMatrix(radian, alpha, dis): matrix = np.matrix([[np.cos(radian),(-1)*np.sin(radian)*np.cos(alpha), np.sin(radian)*np.sin(alpha), a1 * np.cos(radian)], ...
normal
{ "blob_id": "47c6f9767b97469fe7e97ab3b69650265a8021d8", "index": 6257, "step-1": "import numpy as np\n\nnp.set_printoptions(precision = 1)\npi = np.pi\n\ndef convertRadian(theta):\n radian = (theta) * (np.pi) / 180\n return radian\n\ndef mkMatrix(radian, alpha, dis):\n matrix = np.matrix([[np.cos(radian...
[ 0 ]
#Program to convert temp in degree Celsius to temp in degree Fahrenheit celsius=input("Enter temperature in Celsius") celsius=int(celsius) fah=(celsius*9/5)+32 print("Temp in ",celsius,"celsius=",fah," Fahrenheit")
normal
{ "blob_id": "e1172cadeb8b2ce036d8431cef78cfe19bda0cb8", "index": 2161, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('Temp in ', celsius, 'celsius=', fah, ' Fahrenheit')\n", "step-3": "celsius = input('Enter temperature in Celsius')\ncelsius = int(celsius)\nfah = celsius * 9 / 5 + 32\nprint('Tem...
[ 0, 1, 2, 3 ]
import pylab,numpy as np from numpy import sin from matplotlib.patches import FancyArrowPatch fig=pylab.figure() w=1 h=1 th=3.14159/25. x=np.r_[0,0,w,w,0] y=np.r_[0,h,h-w*sin(th),0-w*sin(th),0] pylab.plot(x,y) x=np.r_[0,0,w/2.0,w/2.0,0] y=np.r_[0,h/6.0,h/6.0-w/2.0*sin(th),0-w/2.0*sin(th),0] pylab.plot(x...
normal
{ "blob_id": "c485466a736fa0a4f183092e561a27005c01316d", "index": 8616, "step-1": "<mask token>\n", "step-2": "<mask token>\npylab.plot(x, y)\n<mask token>\npylab.plot(x, y, '--')\npylab.text(w / 4.0, h / 12.0 - w / 4.0 * sin(th) - h / 30.0,\n '$A_{a,subcool}$', ha='center', va='center')\n<mask token>\npylab...
[ 0, 1, 2, 3, 4 ]
arr = [] for i in range(5): arr.append(int(input())) print(min(arr[0], arr[1], arr[2]) + min(arr[3], arr[4]) - 50)
normal
{ "blob_id": "8745855d86dcdabe55f8d1622b66b3613dbfe3e1", "index": 4015, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(5):\n arr.append(int(input()))\nprint(min(arr[0], arr[1], arr[2]) + min(arr[3], arr[4]) - 50)\n", "step-3": "arr = []\nfor i in range(5):\n arr.append(int(input()))...
[ 0, 1, 2 ]
from flask import Blueprint, request from ecdsa import SigningKey, NIST384p import base64, codecs from cryptography.fernet import Fernet ecdsa_app = Blueprint('ecdsa_app', __name__, url_prefix='/ecdsa_app') f = Fernet(Fernet.generate_key()) sk = SigningKey.generate(curve=NIST384p) vk = sk.get_verifying_key() @ecd...
normal
{ "blob_id": "4eb7abb24451f3f895d0731de7b29a85d90c1539", "index": 8246, "step-1": "<mask token>\n\n\n@ecdsa_app.get('/create_pkey')\ndef private_key():\n return {'status': 'success', 'result': sk.to_string().hex()}\n\n\n@ecdsa_app.post('/op')\ndef check_op():\n input = request.get_json()\n operators = ['...
[ 4, 5, 6, 7, 8 ]
from django.db import models class Book(models.Model): title = models.TextField(max_length=32, blank=False, null=False) # from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager # # # class UserAccountManager(BaseUserManager): # def create_user(self, email, firstname,lastna...
normal
{ "blob_id": "8286407987301ace7af97d6acdcf6299ce3d8525", "index": 5440, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Book(models.Model):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Book(models.Model):\n title = models.TextField(max_length=32, blank=False, null=False)\n", "s...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ Created on Wed Jul 15 19:27:59 2020 @author: Dan """ import numpy as np def shift(v,i,j): if i <= j: return v store = v[i] for k in range(0, i-j-1): v[i-k] = v[i-k-1] v[j] = store return v def insertion(v): for i in range(1, len(v)): j = i ...
normal
{ "blob_id": "35288c9ad4d3550003e3c2f9e9034f4bce1df830", "index": 3626, "step-1": "<mask token>\n\n\ndef shift(v, i, j):\n if i <= j:\n return v\n store = v[i]\n for k in range(0, i - j - 1):\n v[i - k] = v[i - k - 1]\n v[j] = store\n return v\n\n\ndef insertion(v):\n for i in rang...
[ 2, 3, 4, 5, 6 ]
import logging import random from pyage.core.address import Addressable from pyage.core.agent.agent import AbstractAgent from pyage.core.inject import Inject, InjectOptional logger = logging.getLogger(__name__) class AggregateAgent(Addressable, AbstractAgent): @Inject("aggregated_agents:_AggregateAgent__agents")...
normal
{ "blob_id": "85903f0c6bd4c896379c1357a08ae3bfa19d5415", "index": 7065, "step-1": "<mask token>\n\n\nclass AggregateAgent(Addressable, AbstractAgent):\n\n @Inject('aggregated_agents:_AggregateAgent__agents')\n @InjectOptional('locator')\n def __init__(self, name=None):\n self.name = name\n ...
[ 7, 10, 11, 13, 15 ]
from collections import Counter import numpy as np import random import torch import BidModel from douzero.env.game import GameEnv env_version = "3.2" env_url = "http://od.vcccz.com/hechuan/env.py" Card2Column = {3: 0, 4: 1, 5: 2, 6: 3, 7: 4, 8: 5, 9: 6, 10: 7, 11: 8, 12: 9, 13: 10, 14: 11, 17: 12} Nu...
normal
{ "blob_id": "4015078ee9640c4558a4f29ebbb89f9098a31014", "index": 5720, "step-1": "<mask token>\n\n\nclass Env:\n <mask token>\n\n def __init__(self, objective):\n \"\"\"\n Objective is wp/adp/logadp. It indicates whether considers\n bomb in reward calculation. Here, we use dummy agents...
[ 13, 24, 32, 36, 37 ]
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under t...
normal
{ "blob_id": "d56fa4ea999d8af887e5f68296bfb20ad535e6ad", "index": 6748, "step-1": "<mask token>\n\n\nclass PXEBaseMixin(object):\n\n def get_properties(self):\n \"\"\"Return the properties of the interface.\n\n :returns: dictionary of <property name>:<property description> entries.\n \"\"\...
[ 4, 5, 6, 7, 8 ]
try: a=100 b=a/0 print(b) except ZeroDivisionError as z: print("Error= ",z)
normal
{ "blob_id": "9dead39e41fd0f3cff43501c659050885a50fec3", "index": 4521, "step-1": "<mask token>\n", "step-2": "try:\n a = 100\n b = a / 0\n print(b)\nexcept ZeroDivisionError as z:\n print('Error= ', z)\n", "step-3": "try:\r\n a=100\r\n b=a/0\r\n print(b)\r\nexcept ZeroDivisionError as z:...
[ 0, 1, 2 ]
from collections import Counter from collections import deque import os def wc(argval): bool = False if("|" in argval): bool = True del argval[len(argval)-1] hf=open("commandoutput.txt","r+") open("commandoutput.txt","w").close() hf=open("commandoutput.txt","w") numoflines = 0 ...
normal
{ "blob_id": "e9a4ea69a4bd9b75b8eb8092b140691aab763ae4", "index": 2963, "step-1": "from collections import Counter\nfrom collections import deque\nimport os\ndef wc(argval):\n bool = False\n if(\"|\" in argval):\n bool = True\n del argval[len(argval)-1] \n hf=open(\"commandoutput.txt\",\"r+\"...
[ 0 ]
# -*- coding: utf-8 -*- """ This module provides a function for splitting datasets.""" from skmultilearn.model_selection import IterativeStratification def iterative_train_test(X, y, test_size): """ Iteratively splits data with stratification. This function is based on the iterative_train_test_split func...
normal
{ "blob_id": "c4c068c7b50d1811f224701ad7e95d88f6734230", "index": 2867, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef iterative_train_test(X, y, test_size):\n \"\"\"\n Iteratively splits data with stratification.\n\n This function is based on the iterative_train_test_split function from ...
[ 0, 1, 2, 3 ]
from django.contrib import admin from django.contrib.admin.sites import AdminSite from obp.models import * from django.utils.html import format_html from jet.admin import CompactInline #from django.utils.translation import ugettext_lazy as _ from jet.dashboard import modules from jet.dashboard.dashboard import Dashboa...
normal
{ "blob_id": "d301ffa790d6444519e354a2b6f8d65f67d380c0", "index": 1739, "step-1": "<mask token>\n\n\nclass Client_OrderInline(admin.TabularInline):\n <mask token>\n\n\nclass MyAdminSite(AdminSite):\n site_header = 'Pizza-Day'\n index_template = 'admin/index.html'\n\n\n@admin.register(Product)\nclass Prod...
[ 16, 17, 18, 24, 25 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon May 6 10:05:25 2019 @author: MCA """ import smtplib, ssl from email import encoders from email.mime.text import MIMEText from email.mime.base import MIMEBase from email.mime.multipart import MIMEMultipart import os,sys import time def loadFiles(su...
normal
{ "blob_id": "b310c35b781e3221e2dacc7717ed77e20001bafa", "index": 5109, "step-1": "<mask token>\n\n\ndef loadFiles(subdir, filetype):\n \"\"\"\n example:\n dirs = [\"dir1\", \"dir2\"]\n file_type = \".dat\"\n files, keys, data = loadFiles(dirs[0], file_type)\n \n \"\"\"\n dirname = os.path...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 import argparse import os import sys,shutil from shutil import make_archive import pathlib from phpManager import execute,execute_outputfile from datetime import date,datetime import re import pymysql import tarfile def append_log(log,message): f = open(log, "a+") today = datetime.now()...
normal
{ "blob_id": "e09af436f2fb37d16427aa0b1416d6f2d59ad6c4", "index": 214, "step-1": "<mask token>\n\n\ndef append_log(log, message):\n f = open(log, 'a+')\n today = datetime.now()\n f.write('%s %s \\n' % (today.strftime('%Y-%m-%d %H:%M:%S'), message))\n f.close()\n\n\ndef get_root_pass():\n with open(...
[ 10, 11, 13, 14, 15 ]
''' Find the greatest product of five consecutive digits in the 1000-digit number. 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403...
normal
{ "blob_id": "db20a77778392c84bab50f6d4002dd11b73967b9", "index": 9214, "step-1": "'''\nFind the greatest product of five consecutive digits in the 1000-digit number.\n\n73167176531330624919225119674426574742355349194934\n96983520312774506326239578318016984801869478851843\n8586156078911294949545950173795833195285...
[ 0 ]
""" Django settings for geobombay project. For more information on this file, see https://docs.djangoproject.com/en/1.7/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/1.7/ref/settings/ """ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) ...
normal
{ "blob_id": "32ca107fde4c98b61d85f6648f30c7601b31c7f3", "index": 3182, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n SECRET_KEY\nexcept NameError:\n SECRET_FILE = os.path.join(BASE_DIR, 'secret.txt')\n try:\n SECRET_KEY = open(SECRET_FILE).read().strip()\n except IOError:\n ...
[ 0, 1, 2, 3, 4 ]
from snake.snake import Snake # Start application if __name__ == '__main__': s = Snake() s.run()
normal
{ "blob_id": "efed5c113e085e5b41d9169901c18c06111b9077", "index": 8894, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n s = Snake()\n s.run()\n", "step-3": "from snake.snake import Snake\nif __name__ == '__main__':\n s = Snake()\n s.run()\n", "step-4": "from sna...
[ 0, 1, 2, 3 ]
n=int(input("Enter any int number:\n")) x=1 while(x<13): print(n ," x ", x ," = ", n*x) x=x+1
normal
{ "blob_id": "a6c07146f1cbc766cd464dab620d1fb075759c12", "index": 4213, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile x < 13:\n print(n, ' x ', x, ' = ', n * x)\n x = x + 1\n", "step-3": "n = int(input('Enter any int number:\\n'))\nx = 1\nwhile x < 13:\n print(n, ' x ', x, ' = ', n * x)\...
[ 0, 1, 2, 3 ]
from pyloom import * import random import string alphabet = string.ascii_letters def random_string(N): return ''.join([random.choice(alphabet) for _ in range(N)]) class TestBloomFilter(object): def test_setup(self): bf = BloomFilter(1000) assert 10 == bf._num_hashes assert 14380 ==...
normal
{ "blob_id": "24e486edc6f80e0b7d58b5df898e6d34f53111c8", "index": 4389, "step-1": "<mask token>\n\n\nclass TestBloomFilter(object):\n\n def test_setup(self):\n bf = BloomFilter(1000)\n assert 10 == bf._num_hashes\n assert 14380 == bf._num_bits\n assert 14380 == len(bf._bitarray)\n ...
[ 5, 6, 7, 8, 9 ]
# Filename : var.py #整数 i = 5 print(i) i = i + 1 print(i) #浮点数 i = 1.1 print(i) #python的弱语言特性,可以随时改变变量的类型 i = 'change i to a string ' print(i) s = 'hello'#单引号 print(s) s = "hello"#双引号 print(s) #三引号为多行字符串 s = '''This is a "multi-line" string. This is the second line.''' print(s) s = '\''#斜杠用于转义 print(s) #r或R开头的字符...
normal
{ "blob_id": "bea7853d1f3eac50825bc6eb10438f3f656d6d04", "index": 1947, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(i)\n<mask token>\nprint(i)\n<mask token>\nprint(i)\n<mask token>\nprint(i)\n<mask token>\nprint(s)\n<mask token>\nprint(s)\n<mask token>\nprint(s)\n<mask token>\nprint(s)\n<mask tok...
[ 0, 1, 2, 3 ]
import tornado.httpserver import tornado.websocket import tornado.ioloop import tornado.web import tornado.options import serial import time from datetime import timedelta import cv2 import time from datetime import datetime #for webcam users camera=cv2.VideoCapture(0) #for picam users #import picam #camera=picam.Op...
normal
{ "blob_id": "1e9afe6435285da6c6efb678177587d7ba5a01b2", "index": 1397, "step-1": "import tornado.httpserver\nimport tornado.websocket\nimport tornado.ioloop\nimport tornado.web\nimport tornado.options\nimport serial\nimport time\nfrom datetime import timedelta\nimport cv2\nimport time\nfrom datetime import datet...
[ 0 ]
import ga.ga as ga import os import datetime def ga_optimise(synth, param_count, target, output_dir, iterations = 10, pop_size = 500): fs = ga.ga_optimise(compute_population_fitnesses = ga.compute_population_fitnesses, target = target, synth = synth, param_count = param_count, iterations = iterat...
normal
{ "blob_id": "4bc9896847e4ab92a01dfcf674362140cc31ef4f", "index": 5587, "step-1": "import ga.ga as ga\nimport os\nimport datetime\n\n\ndef ga_optimise(synth, param_count, target, output_dir, iterations = 10, pop_size = 500):\n\tfs = ga.ga_optimise(compute_population_fitnesses = ga.compute_population_fitnesses, \n...
[ 0 ]
import pickle import numpy as np import math class AdaBoostClassifier: '''A simple AdaBoost Classifier.''' def __init__(self, weak_classifier, n_weakers_limit): '''Initialize AdaBoostClassifier Args: weak_classifier: The class of weak classifier, which is recommend to be sklearn.t...
normal
{ "blob_id": "905d8be76ef245a2b8fcfb3f806f8922d351ecf0", "index": 8877, "step-1": "<mask token>\n\n\nclass AdaBoostClassifier:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def predict(self, X, threshold=0):\n \"\"\"Predict the catagories...
[ 3, 7, 8, 9, 12 ]
from sklearn.model_selection import train_test_split from azureml.core import Run from sklearn.ensemble import RandomForestClassifier import pandas as pd import argparse import os import joblib import numpy as np # Get the experiment run context run = Run.get_context() # Get arguments parser = argparse.ArgumentParse...
normal
{ "blob_id": "66c2d73c100f7fc802e66f2762c92664e4b93fcd", "index": 5736, "step-1": "<mask token>\n", "step-2": "<mask token>\nparser.add_argument('--in_n_estimator', type=int, default=8)\nparser.add_argument('--in_criterion', type=str, default='gini')\nparser.add_argument('--in_max_depth', type=int, default=2)\n...
[ 0, 1, 2, 3, 4 ]
import os from xml.dom import minidom import numpy as np def get_branches_dir(root_dir): branches_dir = [] folds = os.listdir(root_dir) while folds: branch_dir = root_dir + '/' + folds.pop() branches_dir.append(branch_dir) return branches_dir def tolist(xml, detname): try: ...
normal
{ "blob_id": "2b7bb02a25504e7481d3bc637ea09bcf9addb990", "index": 7699, "step-1": "<mask token>\n\n\ndef get_branches_dir(root_dir):\n branches_dir = []\n folds = os.listdir(root_dir)\n while folds:\n branch_dir = root_dir + '/' + folds.pop()\n branches_dir.append(branch_dir)\n return br...
[ 2, 3, 4, 5, 6 ]
from collections.abc import Iterator import json import click def print_json(obj, err=False): if isinstance(obj, Iterator): obj = list(obj) click.echo(json.dumps(obj, sort_keys=True, indent=4, ensure_ascii=False), err=err) def show_fields(*fields): def show(obj, verbose=False): ...
normal
{ "blob_id": "d340ac979f57cf4650131665e4fa5b9923f22a3e", "index": 6691, "step-1": "<mask token>\n\n\ndef print_json(obj, err=False):\n if isinstance(obj, Iterator):\n obj = list(obj)\n click.echo(json.dumps(obj, sort_keys=True, indent=4, ensure_ascii=False\n ), err=err)\n\n\n<mask token>\n", ...
[ 1, 2, 3, 4, 5 ]
REDIRECT_MAP = { '90':'19904201', '91':'19903329', '92':'19899125', '93':'19901043', '94':'19903192', '95':'19899788', '97':'19904423', '98':'19906163', '99':'19905540', '100':'19907871', '101':'19908147', '102':'19910103', '103':'19909980', '104':'19911813', ...
normal
{ "blob_id": "fb92912e1a752f3766f9439f75ca28379e23823f", "index": 3600, "step-1": "<mask token>\n", "step-2": "REDIRECT_MAP = {'90': '19904201', '91': '19903329', '92': '19899125', '93':\n '19901043', '94': '19903192', '95': '19899788', '97': '19904423', '98':\n '19906163', '99': '19905540', '100': '19907...
[ 0, 1, 2 ]
from extras.plugins import PluginTemplateExtension from .models import BGPSession from .tables import BGPSessionTable class DeviceBGPSession(PluginTemplateExtension): model = 'dcim.device' def left_page(self): if self.context['config'].get('device_ext_page') == 'left': return self.x_page(...
normal
{ "blob_id": "be566041402dc1705aa9d644edc44de8792fbb3c", "index": 4850, "step-1": "<mask token>\n\n\nclass DeviceBGPSession(PluginTemplateExtension):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass DeviceBGPSessio...
[ 1, 4, 7, 8 ]
def fib(limit): a, b = 0, 1 yield a yield b while b < limit: a, b = b, a + b yield b print sum(x for x in fib(4000000) if not x % 2) # 4613732
normal
{ "blob_id": "1c7635917e398c30e4a232f76b2c02a51e165a63", "index": 4147, "step-1": "def fib(limit):\n a, b = 0, 1\n yield a\n yield b\n while b < limit:\n a, b = b, a + b\n yield b\n\n\nprint sum(x for x in fib(4000000) if not x % 2) # 4613732\n", "step-2": null, "step-3": null, "s...
[ 0 ]
import xadmin from xadmin import views from .models import EmailVerifyRecord, Banner class BaseMyAdminView(object): ''' enable_themes 启动更改主题 use_bootswatch 启用网上主题 ''' enable_themes = True use_bootswatch = True class GlobalSettings(object): ''' site_title 左上角名称 site_footer 底部名称 ...
normal
{ "blob_id": "d7b830890400203ee45c9ec59611c0b20ab6bfc7", "index": 8496, "step-1": "<mask token>\n\n\nclass BaseMyAdminView(object):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass GlobalSettings(object):\n \"\"\"\n site_title 左上角名称\n site_footer 底部名称\n menu_style 更改左边样式\n \"\"\"\n ...
[ 8, 10, 11, 12, 13 ]
from random import choice, random, randrange from math import fsum import os import numpy as np def mat17(N, ATOM_TYPES, ndenmax=0.04302, ndenmin=0.0000013905, xmax=51.2, xmin=25.6, ymax=51.2, ymin=25.6, zmax=51.2, zmin=25.6, epmax=513.264, epmin=1.2580, sigmax=6.549291, sigmin=1.052342, qmax=0.0, qmin=0.0): #epmax DE...
normal
{ "blob_id": "ba72af921a9562d748bcd65f1837ea8eb5da5697", "index": 150, "step-1": "from random import choice, random, randrange\nfrom math import fsum\nimport os\nimport numpy as np\n\ndef mat17(N, ATOM_TYPES, ndenmax=0.04302, ndenmin=0.0000013905, xmax=51.2, xmin=25.6, ymax=51.2, ymin=25.6,\nzmax=51.2, zmin=25.6,...
[ 0 ]
from django.contrib import admin # Register your models here. from registration.models import FbAuth class AllFieldsAdmin(admin.ModelAdmin): """ A model admin that displays all field in admin excpet Many to many and pk field """ def __init__(self, model, admin_site): self.list_display = [fi...
normal
{ "blob_id": "821afa85eb783b4bf1018800f598a3294c4cbcfb", "index": 9532, "step-1": "<mask token>\n\n\nclass AllFieldsAdmin(admin.ModelAdmin):\n <mask token>\n\n def __init__(self, model, admin_site):\n self.list_display = [field.name for field in model._meta.fields if \n field.name not in [...
[ 2, 3, 4, 5, 6 ]
from csv import reader, writer from collections import OrderedDict as OrdDic import sqlite3 from jsmin import jsmin from glob import glob from csscompressor import compress from threading import Timer from glob import glob import os import shutil import logging import json class MinifyFilesPre: def __init__(self, ...
normal
{ "blob_id": "38bd9e5b2147838b6061925d72b989c83343f1c2", "index": 9800, "step-1": "<mask token>\n\n\nclass DbManager:\n\n def __init__(self, fname=None, tname=None):\n if fname:\n self.FILE_NAME = fname\n else:\n self.FILE_NAME = 'resources/static/LOG_Temp.db'\n if tn...
[ 31, 37, 39, 44, 50 ]
import numpy as np import h5py def rotate_z(theta, x): theta = np.expand_dims(theta, 1) outz = np.expand_dims(x[:, :, 2], 2) sin_t = np.sin(theta) cos_t = np.cos(theta) xx = np.expand_dims(x[:, :, 0], 2) yy = np.expand_dims(x[:, :, 1], 2) outx = cos_t * xx - sin_t * yy outy = sin_t * x...
normal
{ "blob_id": "855bfc9420a5d5031cc673231cc7993ac67df076", "index": 5515, "step-1": "<mask token>\n\n\nclass ModelFetcher(object):\n <mask token>\n\n def train_data(self):\n rng_state = np.random.get_state()\n np.random.shuffle(self._train_data)\n np.random.set_state(rng_state)\n n...
[ 3, 6, 8, 10, 11 ]
import requests response = requests.get( 'https://any-api.com:8443/https://rbaskets.in/api/version') print(response.text)
normal
{ "blob_id": "ab36b3d418be67080e2efaba15edc1354386e191", "index": 6888, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(response.text)\n", "step-3": "<mask token>\nresponse = requests.get(\n 'https://any-api.com:8443/https://rbaskets.in/api/version')\nprint(response.text)\n", "step-4": "import...
[ 0, 1, 2, 3 ]
""" Version information for NetworkX, created during installation. Do not add this file to the repository. """ import datetime version = '2.3' date = 'Thu Apr 11 20:57:18 2019' # Was NetworkX built from a development version? If so, remember that the major # and minor versions reference the "target" (rather than "...
normal
{ "blob_id": "814191a577db279389975e5a02e72cd817254275", "index": 9444, "step-1": "<mask token>\n", "step-2": "<mask token>\nversion = '2.3'\ndate = 'Thu Apr 11 20:57:18 2019'\ndev = False\nversion_info = 'networkx', '2', '3', None\ndate_info = datetime.datetime(2019, 4, 11, 20, 57, 18)\nvcs_info = None, (None,...
[ 0, 1, 2, 3 ]
from migen import * from migen.fhdl import verilog class Alignment_Corrector(Module): def __init__(self): self.din=din=Signal(32) self.aligned=aligned=Signal() self.dout=dout=Signal(32) self.correction_done=Signal() # # # first_half=Signal(16) first_half1=Signal(16) second_half=Signal(16) self.submo...
normal
{ "blob_id": "f3eed00a58491f36778b3a710d2f46be093d6eda", "index": 6320, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Alignment_Corrector(Module):\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Alignment_Corrector(Module):\n\n def __init__(self):\n self.d...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import requests import json import boto3 from lxml.html import parse CardTitlePrefix = "Greeting" def build_speechlet_response(title, output, reprompt_text, should_end_session): """ Build a speechlet JSON representation of the title, output text, reprompt text & end of session ...
normal
{ "blob_id": "237277e132c8223c6048be9b754516635ab720e2", "index": 8964, "step-1": "<mask token>\n\n\ndef build_response(session_attributes, speechlet_response):\n \"\"\"\n Build the full response JSON from the speechlet response\n \"\"\"\n return {'version': '1.0', 'sessionAttributes': session_attribu...
[ 8, 11, 13, 14, 15 ]