code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
from google.appengine.api import users from google.appengine.ext import ndb from datetime import datetime from datetime import timedelta import os import logging import webapp2 import jinja2 JINJA_ENVIRONMENT = jinja2.Environment( loader=jinja2.FileSystemLoader(os.path.dirname(__file__)), extensions=['jinja2....
normal
{ "blob_id": "309090167c2218c89494ce17f7a25bd89320a202", "index": 3855, "step-1": "<mask token>\n\n\nclass UserProfile(ndb.Model):\n <mask token>\n <mask token>\n <mask token>\n\n @classmethod\n def query_profile(cls, ancestor_key):\n return cls.query(ancestor=ancestor_key).get()\n\n\nclass ...
[ 5, 7, 8, 9, 10 ]
#!/usr/bin/python import os # http://stackoverflow.com/questions/4500564/directory-listing-based-on-time def sorted_ls(path): mtime = lambda f: os.stat(os.path.join(path, f)).st_mtime return list(sorted(os.listdir(path), key=mtime)) def main(): print "Content-type: text/html\n\n" print "<html><head><t...
normal
{ "blob_id": "f4715a1f59ceba85d95223ef59003410e35bfb7f", "index": 4037, "step-1": "#!/usr/bin/python\nimport os\n\n# http://stackoverflow.com/questions/4500564/directory-listing-based-on-time\ndef sorted_ls(path):\n mtime = lambda f: os.stat(os.path.join(path, f)).st_mtime\n return list(sorted(os.listdir(pa...
[ 0 ]
from selenium import webdriver from urllib.request import urlopen, Request from subprocess import check_output import json #from flask import Flask # https://data-live.flightradar24.com/zones/fcgi/feed.js?bounds=-32.27,-34.08,-73.15,-70.29 def get_json_aviones(north, south, west, east): #driver = webdriver.Chrom...
normal
{ "blob_id": "9ba5af7d2b6d4f61bb64a055efb15efa8e08d35c", "index": 5379, "step-1": "<mask token>\n\n\ndef get_json_buques(centerx, centery, zoom):\n count = 0\n while True:\n ignore = False\n count += 1\n print(centerx, centery, zoom)\n out = check_output(['phantomjs', 'GetBarcos....
[ 1, 2, 3, 4, 5 ]
from django.contrib import admin from main.models import Assignment, Review, Sample, Question, SampleMultipleFile # Register your models here. admin.site.register(Assignment) admin.site.register(Review) admin.site.register(Question) class MultipleFileInline(admin.TabularInline): model = SampleMultipleFile class S...
normal
{ "blob_id": "d18c45c08face08ce8f7dad915f1896c24c95cbf", "index": 2991, "step-1": "<mask token>\n\n\nclass SampleAdmin(admin.ModelAdmin):\n inlines = [MultipleFileInline]\n prepopulated_fields = {'slug': ('heading',)}\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass MultipleFileInline(admin.Tabula...
[ 2, 4, 5, 6, 7 ]
from ContactBook import ContactBook import csv def run(): contact_book = ContactBook() with open("22_agenda/contactos.csv",'r') as f: reader = csv.reader(f) for idx,row in enumerate(reader): if idx == 0: continue else: contact_bo...
normal
{ "blob_id": "f5831b84c1177d8b869db05d332bd364b3f72fff", "index": 4282, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run():\n contact_book = ContactBook()\n with open('22_agenda/contactos.csv', 'r') as f:\n reader = csv.reader(f)\n for idx, row in enumerate(reader):\n ...
[ 0, 1, 2, 3, 4 ]
import numpy as np from scipy import stats a = np.random.normal(25.0, 5.0, 10000) b = np.random.normal(26.0, 5.0, 10000) print(stats.ttest_ind(a, b)) # bad change, with a ery low chance of randomness b = np.random.normal(25.0, 5.0, 10000) print(stats.ttest_ind(a, b)) # no change, outcome is likely random
normal
{ "blob_id": "ba85f3c8a9e40f30076c13487a97567f7bc646dc", "index": 8041, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(stats.ttest_ind(a, b))\n<mask token>\nprint(stats.ttest_ind(a, b))\n", "step-3": "<mask token>\na = np.random.normal(25.0, 5.0, 10000)\nb = np.random.normal(26.0, 5.0, 10000)\npri...
[ 0, 1, 2, 3, 4 ]
def sum_numbers(numbers=None): sum = 0 if numbers == None: for number in range(1, 101): sum += number return sum for number in numbers: sum += number return sum
normal
{ "blob_id": "a85d06d72b053b0ef6cb6ec2ba465bfb8975b28e", "index": 3879, "step-1": "<mask token>\n", "step-2": "def sum_numbers(numbers=None):\n sum = 0\n if numbers == None:\n for number in range(1, 101):\n sum += number\n return sum\n for number in numbers:\n sum += num...
[ 0, 1 ]
#!/usr/bin/python # -*- coding: utf-8 -*- # # All about users. # # author: ze.apollo@gmail.com # from client import ClientHelper from mongodb import MongoDBClient class FixedData: def get_data( self, id ): data = self.get_data_from_mongodb( id ) if ( data ): return data else: ...
normal
{ "blob_id": "b1530c664fa236e61ff50bca502bf79730c3386c", "index": 6647, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass FixedData:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass FixedData:\n\n def get_data(self, id):\n data = self.get_data_from_mongodb(id)\n if data:\...
[ 0, 1, 2, 3, 4 ]
n = int(input('Informe um numero: ')) print('----------------') print('{} x {:2} = {:2}'.format(n, 1, 1 * n)) print('{} x {:2} = {:2}'.format(n, 2, 2 * n)) print('{} x {:2} = {:2}'.format(n, 3, 3 * n)) print('{} x {:2} = {:2}'.format(n, 4, 4 * n)) print('{} x {:2} = {:2}'.format(n, 5, 5 * n)) print('{} x {:2} = {:2}'.f...
normal
{ "blob_id": "9e814e3f1162e248c5d778c2df9960b199854a27", "index": 9306, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint('----------------')\nprint('{} x {:2} = {:2}'.format(n, 1, 1 * n))\nprint('{} x {:2} = {:2}'.format(n, 2, 2 * n))\nprint('{} x {:2} = {:2}'.format(n, 3, 3 * n))\nprint('{} x {:2} = ...
[ 0, 1, 2 ]
#Array In Python from array import array numbers = array("i",[1,2,3]) numbers[0] = 0 print(list(numbers))
normal
{ "blob_id": "ae5f87f1c383478ea5f370af1c85d63a472a7788", "index": 455, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(list(numbers))\n", "step-3": "<mask token>\nnumbers = array('i', [1, 2, 3])\nnumbers[0] = 0\nprint(list(numbers))\n", "step-4": "from array import array\nnumbers = array('i', [1,...
[ 0, 1, 2, 3, 4 ]
from typing import Sequence, Union, Tuple import kdtree from colour import Color AnsiCodeType = Union[str, int, Tuple[int, int, int]] class ColorPoint(object): def __init__(self, source: Color, target: Color, ansi: AnsiCodeType) -> None: """ Map source color to target color, st...
normal
{ "blob_id": "e239c2089fc6d4ab646c490b6e3de8953cec5634", "index": 8093, "step-1": "<mask token>\n\n\nclass ColorPoint(object):\n <mask token>\n <mask token>\n\n def __getitem__(self, item) ->float:\n \"\"\"\n >>> cp = ColorPoint(Color('#880073'), Color('white'), '')\n >>> cp[0] # hu...
[ 7, 8, 9, 10, 12 ]
import sys import numpy as np from pymongo import MongoClient from sklearn import linear_model, preprocessing assert str(sys.argv[1]) is not None client = MongoClient(str(sys.argv[1])) db = client.nba_py variables = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13',...
normal
{ "blob_id": "36682c4ab90cdd22b644906e22ede71254eb42ff", "index": 2091, "step-1": "<mask token>\n", "step-2": "<mask token>\nassert str(sys.argv[1]) is not None\n<mask token>\nfor k in ALPHA_VALS:\n total_train_error = 0\n total_train_variance = 0\n total_test_error = 0\n total_test_variance = 0\n ...
[ 0, 1, 2, 3, 4 ]
import ssl import sys import psycopg2 #conectarte python con postresql import paho.mqtt.client #pip install paho-mqtt import json conn = psycopg2.connect(host = 'raja.db.elephantsql.com', user= 'oyoqynnr', password ='myHVlpJkEO21o29GKYSvMCGI3g4y05bh', dbname= 'oyoqynnr') def on_connect(client, userdata, flags, r...
normal
{ "blob_id": "f1b36e3ce3189c8dca2e41664ac1a6d632d23f79", "index": 5078, "step-1": "<mask token>\n\n\ndef on_connect(client, userdata, flags, rc):\n print('Conectado (%s)' % client._client_id)\n client.subscribe(topic='unimet/#', qos=0)\n\n\ndef ventasTIENDA(client, userdata, message):\n a = json.loads(me...
[ 3, 4, 5, 6, 7 ]
from netsec_2017.Lab_3.packets import RequestItem, RequestMoney, RequestToBuy, FinishTransaction, SendItem, SendMoney from netsec_2017.Lab_3.PLS.client import PLSClient, PLSStackingTransport from netsec_2017.Lab_3.peepTCP import PeepClientTransport, PEEPClient import asyncio import playground import random, logging fro...
normal
{ "blob_id": "a12f9435eb4b090bc73be14ad64fdf43c5caa4d2", "index": 7471, "step-1": "<mask token>\n\n\nclass ShopClientProtocol(asyncio.Protocol):\n <mask token>\n <mask token>\n\n def connection_made(self, transport):\n print('ShopClient connection_made is called\\n')\n self.transport = tran...
[ 5, 7, 9, 10, 12 ]
from django.shortcuts import render import codecs import os.path from django.conf import settings OFFSET = 20 def show_raw_data(req): filename = req.GET['file'] lineno = int(req.GET['line']) from_lineno = max(0, lineno - OFFSET) to_lineno = (lineno + OFFSET) ctx = dict() cur_lineno = 1 lin...
normal
{ "blob_id": "576c28bb32b5e0b2b5a82a33cee73e3080dcf3ab", "index": 1737, "step-1": "<mask token>\n\n\ndef show_raw_data(req):\n filename = req.GET['file']\n lineno = int(req.GET['line'])\n from_lineno = max(0, lineno - OFFSET)\n to_lineno = lineno + OFFSET\n ctx = dict()\n cur_lineno = 1\n lin...
[ 4, 5, 6, 7, 8 ]
from django.db import transaction from django.forms import inlineformset_factory from django.shortcuts import render from django.urls import reverse_lazy from django.views.generic import CreateView, UpdateView from forms.models.fund_operation import FundOperation from forms.forms.fund_operation_forms import FundOperati...
normal
{ "blob_id": "3c2fb3d09edab92da08ac8850f650a2fa22fad92", "index": 8806, "step-1": "<mask token>\n\n\nclass FundOperationCreateView(CreateView):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def form_valid(self, form):\n context = self.get_context_data()\n ...
[ 9, 10, 11, 12, 14 ]
import os import RPi.GPIO as GPIO from google.cloud import firestore import time ############Explicit Credential environment path="/home/pi/Desktop/Parking.json" os.environ['GOOGLE_APPLICATION_CREDENTIALS'] =path #GPIO starts s1=2 s2=21 GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(s1,GPIO.IN) GPIO....
normal
{ "blob_id": "e1cc4e17bffcbbae3e7785e4c55acde167a8a50a", "index": 6482, "step-1": "<mask token>\n", "step-2": "<mask token>\nGPIO.setmode(GPIO.BCM)\nGPIO.setwarnings(False)\nGPIO.setup(s1, GPIO.IN)\nGPIO.setup(s2, GPIO.IN)\n<mask token>\nwhile 1:\n if GPIO.input(s1) == False:\n data1 = 1\n coun...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- ############################################################################## # # Copyright (C) 2011 Eficent (<http://www.eficent.com/>) # Jordi Ballester Alomar <jordi.ballester@eficent.com> # # This program is free software: you can redistribute it and/or modify # it und...
normal
{ "blob_id": "1ddec426e4ad50f1d0e8a57ed841fbdf8c51b00f", "index": 9871, "step-1": "<mask token>\n\n\nclass tax(osv.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass tax(osv.Model):\n _inherit = 'sgr.tax'\n\n def send_alerts(self, cr, uid...
[ 1, 5, 6, 7, 8 ]
from django.shortcuts import render # from emaillist.models import Emaillist from emaillist.models import Emaillist from django.http import HttpResponseRedirect # Create your views here. # def index(request): # emaillist_list = Emaillist.objects.all().order_by('-id') # db에서 objects 전체를 불러와서 변수에 저장 # data =...
normal
{ "blob_id": "5220ad793788927e94caf7d6a42df11292851c67", "index": 2734, "step-1": "<mask token>\n\n\ndef test_form(request):\n print('test 함수 실행하자 ')\n return render(request, 'emaillist/test_form.html')\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef test_form(request):\n print('test 함수 실행하자 ')\...
[ 1, 2, 3, 4, 5 ]
import pandas as pd df = pd.read_csv("search.csv") df0 = df[df['re_0']<df['re_1']] df1 = df[df['re_0']>df['re_1']].ix[:, ['re_1', 'im_1', 're_0', 'im_0']] df1.columns = ['re_0', 'im_0', 're_1', 'im_1'] df = pd.concat([df0, df1]).sort_values(by=["re_0"]) eps = pow(10.0, -4.0) first = True res = [] val_old = None fo...
normal
{ "blob_id": "709e54daea4fea112539af3da83b00a43a086399", "index": 2629, "step-1": "import pandas as pd\n\ndf = pd.read_csv(\"search.csv\")\n\n\ndf0 = df[df['re_0']<df['re_1']]\ndf1 = df[df['re_0']>df['re_1']].ix[:, ['re_1', 'im_1', 're_0', 'im_0']]\ndf1.columns = ['re_0', 'im_0', 're_1', 'im_1']\ndf = pd.concat(...
[ 0 ]
import unittest from app.party import Party from app.guest import Guest from app.shoppingList import ShoppingList def test_aPartywithNoGuestsShouldHaveNoPartyGuests(): party = Party() assert 0 == party.numberOfGuests() def test_aPartywithOneGuestShouldHaveOnePartyGuest(): party = Party() lisa = Guest("Lisa", 'fe...
normal
{ "blob_id": "a8df6b575afbf6db415e0676a796623f2a9b7a70", "index": 8416, "step-1": "<mask token>\n\n\ndef test_aPartywithOneGuestShouldHaveOnePartyGuest():\n party = Party()\n lisa = Guest('Lisa', 'female')\n party.attendedBy(lisa)\n assert 1 == party.numberOfGuests()\n\n\ndef test_aPartywithThreeGuest...
[ 6, 8, 9, 10, 12 ]
#!/usr/bin/env python # including libraries import roslib import sys import rospy import cv2 import math from std_msgs.msg import String from sensor_msgs.msg import Image from cv_bridge import CvBridge, CvBridgeError import numpy as np import matplotlib.pyplot as plt MAP = np.array([[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,...
normal
{ "blob_id": "b30e6af035b589d5f4bd1bc6cccdd53c157861a0", "index": 2144, "step-1": "#!/usr/bin/env python\n\n# including libraries\nimport roslib\nimport sys\nimport rospy\nimport cv2\nimport math\nfrom std_msgs.msg import String\nfrom sensor_msgs.msg import Image\nfrom cv_bridge import CvBridge, CvBridgeError\nim...
[ 0 ]
import requests import json ROOT_URL = "http://localhost:5000" def get_all_countries(): response = requests.get("{}/countries".format(ROOT_URL)) return response.json()["countries"] def get_country_probability(countryIds): body = {"countryIds": countryIds} response = requests.get("{}/countries/probability".format...
normal
{ "blob_id": "6aa7114db66a76cfa9659f5537b1056f40f47bd2", "index": 3975, "step-1": "<mask token>\n\n\ndef get_all_countries():\n response = requests.get('{}/countries'.format(ROOT_URL))\n return response.json()['countries']\n\n\ndef get_country_probability(countryIds):\n body = {'countryIds': countryIds}\...
[ 11, 12, 15, 17, 18 ]
#!/usr/bin/env python2.7 ''' lib script to encapsulate the camera info ''' from xml.dom import minidom, Node # what % of the file system remains before deleting files # amount that we will cleanup relative to the filesystem total CAMERA_XML_FILE = "/tmp/cameras.xml" def cameras_get_info(): ''' cameras_ge...
normal
{ "blob_id": "510d411d79d5df8658703241f161b3e2a9ec5932", "index": 4110, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef cameras_get_info():\n \"\"\"\n cameras_get_info - reads the camera info from the XML file and\n puts it into a python data structure and returns it.\n \"\"\"\n stat...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- """ # @Time : 2018/6/11 下午6:45 # @Author : zhanzecheng # @File : 542.01矩阵1.py # @Software: PyCharm """ # 一个简单的循环方式来解决这个问题 # 这一题的思路不错,用多次循环来计数 # TODO: check 1 class Solution: def updateMatrix(self, matrix): """ :type matrix: List[List[int]] :rtype: List[List[in...
normal
{ "blob_id": "1145050d82e614d5c248fc7e6a71720e6ff72414", "index": 6055, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def updateMatrix(self, matrix):\n \"\"\"\n :type matrix: Li...
[ 0, 1, 2, 3, 4 ]
# Let's look at the lowercase letters. import string alphabet = " " + string.ascii_lowercase
normal
{ "blob_id": "da3be0d3b815e11d292a7c7e8f5ce32b35580f98", "index": 1016, "step-1": "<mask token>\n", "step-2": "<mask token>\nalphabet = ' ' + string.ascii_lowercase\n", "step-3": "import string\nalphabet = ' ' + string.ascii_lowercase\n", "step-4": "# Let's look at the lowercase letters.\nimport string\nalp...
[ 0, 1, 2, 3 ]
class TflearnDataSourceExtraTemplate(object): """ Base class for TFLearn's DataSource (if we use wrapping). Parameters: ---------- rewrite_data_aug : bool use wrapper for data augmentation """ def __init__(self, rewrite_data_aug=False): self.rewrite_data_aug = rewrite_data_...
normal
{ "blob_id": "70c084dab8469ca34b0e3e5174101111e695f1ca", "index": 6638, "step-1": "<mask token>\n", "step-2": "class TflearnDataSourceExtraTemplate(object):\n <mask token>\n <mask token>\n", "step-3": "class TflearnDataSourceExtraTemplate(object):\n <mask token>\n\n def __init__(self, rewrite_data...
[ 0, 1, 2, 3 ]
# Copyright (c) 2017, Apple Inc. All rights reserved. # # Use of this source code is governed by a BSD-3-clause license that can be # found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause import unittest from distutils.version import StrictVersion import numpy as np from coremltools._deps ...
normal
{ "blob_id": "d3d90b8ccd0ec449c84ac0316c429b33353f4518", "index": 8900, "step-1": "<mask token>\n\n\n@unittest.skipIf(not _HAS_SKLEARN, 'Missing sklearn. Skipping tests.')\nclass ImputerTestCase(unittest.TestCase):\n <mask token>\n\n @classmethod\n def setUpClass(self):\n \"\"\"\n Set up th...
[ 4, 5, 6, 7, 8 ]
#!/usr/bin/env python3 import argparse from speaker.main import run def parse_args(): parser = argparse.ArgumentParser(description='Network speaker device.') parser.add_argument('-d', '--debug', action='store_true', help='enable debugging messages') parser.add_argument('--host', t...
normal
{ "blob_id": "bb173d8869039f8bbd3e35529cf2d99b26d2b8ff", "index": 7130, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_args():\n parser = argparse.ArgumentParser(description='Network speaker device.')\n parser.add_argument('-d', '--debug', action='store_true', help=\n 'enable de...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.1.7 on 2019-03-23 17:14 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('currency_exchange', '0007_auto_20190323_1751'), ] operations = [ migrations.AddField( model_name='tasks', name='hour...
normal
{ "blob_id": "1f63ce2c791f0b8763aeae15df4875769f6de848", "index": 4942, "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 = [('currency_ex...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 from typing import ClassVar, List print(1, 2) # Annotated function (Issue #29) def foo(x: int) -> int: return x + 1 # Annotated variables #575 CONST: int = 42 class Class: cls_var: ClassVar[str] def m(self): xs: List[int] = [] # True and False are keywords in Python ...
normal
{ "blob_id": "689c6c646311eba1faa93cc72bbe1ee4592e45bc", "index": 8392, "step-1": "<mask token>\n\n\ndef foo(x: int) ->int:\n return x + 1\n\n\n<mask token>\n\n\nclass Class:\n cls_var: ClassVar[str]\n\n def m(self):\n xs: List[int] = []\n\n\n<mask token>\n\n\ndef a():\n pass\n\n\n<mask token>\...
[ 5, 7, 8, 10, 13 ]
from __future__ import annotations from functools import cache class Solution: def countArrangement(self, n: int) -> int: cache = {} def helper(perm): digits = len(perm) if digits == 1: return 1 if perm in cache: return cache[per...
normal
{ "blob_id": "e6acc7b022001d8419095ad6364a6ae9504ec7aa", "index": 508, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n\nclass Solution:\n\n def countArrangement(self, n: int) ->int:\n\n @cache\n def dfs(bm, i):\n if i == 0:\n return 1\n cnt ...
[ 5, 6, 7, 8, 10 ]
import argparse import pandas as pd import random import time class Deck: def __init__(self, num_cols, front, back): self.flashcards = [] self.num_cols = num_cols self.front = front self.back = back class Flashcard: def __init__(self, deck, front, back, column, row): self.deck = deck self.front = front ...
normal
{ "blob_id": "d5903698eb8ed6be531b0cc522d4feff6b79da4e", "index": 954, "step-1": "<mask token>\n\n\nclass Deck:\n\n def __init__(self, num_cols, front, back):\n self.flashcards = []\n self.num_cols = num_cols\n self.front = front\n self.back = back\n\n\nclass Flashcard:\n\n def _...
[ 8, 17, 18, 19, 20 ]
import random tree_age = 1 state = "alive" value = 1 age_display = "Your tree have an age of: {}".format(tree_age) state_display = "Your tree is {}.".format(state) def tree_state(x): if x <= 19: state = "alive" return state elif x <= 49: rand = random.randrange(tree_...
normal
{ "blob_id": "763f552329a0d38900e08081a1017b33cd882868", "index": 9391, "step-1": "<mask token>\n\n\ndef tree_state(x):\n if x <= 19:\n state = 'alive'\n return state\n elif x <= 49:\n rand = random.randrange(tree_age, 51, 1)\n if rand == 50:\n state = 'dead'\n ...
[ 1, 2, 3, 4, 5 ]
# Getting familiar with OOP and using Functions and Classes :) class Dog(): species = 'mammal' def __init__(self,breed,name): self.breed = breed self.name = name def bark(self,number): print(f'Woof! My name is {self.name} and the number is {number}') my_dog = Dog('Corgi'...
normal
{ "blob_id": "c8137aacfb0f35c9630515442d5bdda870e9908a", "index": 4827, "step-1": "<mask token>\n\n\nclass Circle:\n <mask token>\n\n def __init__(self, radius=1):\n self.radius = radius\n self.area = radius * radius * Circle.pi\n\n def get_circumference(self):\n return self.radius *...
[ 10, 11, 13, 16, 18 ]
# -*- coding: utf-8 -*- """ openapi.schematics ~~~~~~~~~~~~~~~~~~ Schematics plugin for apispec based on ext.MarshmallowPlugin """ import warnings from apispec import BasePlugin from .common import resolve_schema_instance, make_schema_key from .openapi import OpenAPIConverter def resolver(schema): "...
normal
{ "blob_id": "1c5655563d05498f016fb2d41a07331b9e8de5e8", "index": 2019, "step-1": "<mask token>\n\n\nclass SchematicsPlugin(BasePlugin):\n <mask token>\n\n def __init__(self, schema_name_resolver=None):\n super().__init__()\n self.schema_name_resolver = schema_name_resolver or resolver\n ...
[ 9, 12, 13, 14, 16 ]
from utils import * import copy import torch.nn as nn CUDA = torch.cuda.is_available() def train_one_epoch(data_loader, net, loss_fn, optimizer): net.train() tl = Averager() pred_train = [] act_train = [] for i, (x_batch, y_batch) in enumerate(data_loader): if CUDA: ...
normal
{ "blob_id": "6ef78e4308f6e693f50df714a5d7af1785e49d7a", "index": 7682, "step-1": "<mask token>\n\n\ndef set_up(args):\n set_gpu(args.gpu)\n ensure_path(args.save_path)\n torch.manual_seed(args.random_seed)\n torch.backends.cudnn.deterministic = True\n\n\n<mask token>\n\n\ndef test(args, data, label, ...
[ 2, 4, 6, 7, 8 ]
#!/usr/bin/env python3 import sys import os import math import tempfile import zlib import lzma import struct import bitstruct # a swf file unpacker and analyzer # majority of information taken from https://www.adobe.com/devnet/swf.html (version 19) # some additional information taken from https://github.com/cla...
normal
{ "blob_id": "4556febd5fddf390f370a8e24871eacf08d34c9f", "index": 7087, "step-1": "<mask token>\n\n\nclass SWFRect(object):\n\n def __init__(self, xmin, xmax, ymin, ymax):\n self.xmin = xmin\n self.xmax = xmax\n self.ymin = ymin\n self.ymax = ymax\n\n def __str__(self):\n ...
[ 17, 18, 20, 22, 24 ]
#!/usr/bin/env python3 def GetDensity(T, P, config): return P/(T*config["Flow"]["mixture"]["gasConstant"]) def GetViscosity(T, config): if (config["Flow"]["mixture"]["viscosityModel"]["type"] == "Constant"): viscosity = config["Flow"]["mixture"]["viscosityModel"]["Visc"] elif (config["Flow"]["mixture"]...
normal
{ "blob_id": "0e47a7d9cd6809886674291d6a535dd18205a012", "index": 5455, "step-1": "<mask token>\n", "step-2": "def GetDensity(T, P, config):\n return P / (T * config['Flow']['mixture']['gasConstant'])\n\n\n<mask token>\n", "step-3": "def GetDensity(T, P, config):\n return P / (T * config['Flow']['mixtur...
[ 0, 1, 2, 3 ]
from setuptools import setup setup( name='nodepool_harness', version='0.1dev', description='Nodepool harness', packages=['nodepool_harness', 'statsd', 'apscheduler'], install_requires=["PyYAML", "python-novaclient", "paramiko", "sqlalchemy"], entry_points = { 'console_scripts': [ ...
normal
{ "blob_id": "61ff5fae02d18d51595e8050d97244574e7d8af1", "index": 6419, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='nodepool_harness', version='0.1dev', description=\n 'Nodepool harness', packages=['nodepool_harness', 'statsd',\n 'apscheduler'], install_requires=['PyYAML', 'python-nov...
[ 0, 1, 2, 3 ]
import requests import sxtwl import datetime from datetime import date import lxml from lxml import etree # 日历中文索引 ymc = [u"十一", u"十二", u"正", u"二", u"三", u"四", u"五", u"六", u"七", u"八", u"九", u"十"] rmc = [u"初一", u"初二", u"初三", u"初四", u"初五", u"初六", u"初七", u"初八", u"初九", u"初十", \ u"十一", u"十二", u"十三", u"十四", u"十五", u"十...
normal
{ "blob_id": "e1d0648825695584d3ea518db961a9178ea0c66a", "index": 50, "step-1": "<mask token>\n\n\ndef china_lunar():\n today = str(date.today())\n today_list = today.split('-')\n lunar_day = lunar.getDayBySolar(int(datetime.datetime.now().year), int(\n datetime.datetime.now().month), int(datetime...
[ 4, 6, 7, 8, 9 ]
# Generated by Django 2.1.1 on 2019-11-20 12:34 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('sandbox_report', '0006_sandboxreportlink_sandboxreportval'), ] operations = [ migrations.DeleteModel( name='SandboxReportLink', ...
normal
{ "blob_id": "b92497396e711d705760db547b43cc65beba6cfd", "index": 6172, "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 = [('sandbox_rep...
[ 0, 1, 2, 3, 4 ]
import socket import threading #WebSocket Server Address WS_ADDR = ("127.0.0.1",9876) def ws_handler(sock,addr): print 'ws handshaking...' print 'connected...' print 'closing...' def websocket_server(): print 'listening for a WS connection... ' svSock = socket.socket() svSock.setsockopt(soc...
normal
{ "blob_id": "668fe3d561d94be73f2f721fac89e9e25005769b", "index": 2652, "step-1": "import socket\nimport threading\n\n#WebSocket Server Address\nWS_ADDR = (\"127.0.0.1\",9876)\n\n\ndef ws_handler(sock,addr):\n print 'ws handshaking...'\n print 'connected...'\n print 'closing...'\n\n\ndef websocket_server...
[ 0 ]
import sys import os from pyparsing import * import csv def parse_cave_details(details): ########################################################################## # Define the Bretz Grammar. # Sample cave description: # Boring Caverns SE1/4 NW1/4 sec. 16, T. 37 N., R. 10 W., Pulaski County ...
normal
{ "blob_id": "1fc1d2e1a7d18b1ef8ee6396210afe47a63ab09f", "index": 3267, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef parse_cave_details(details):\n aliquotQuadrantID = Literal('NE') | Literal('SE') | Literal('SW'\n ) | Literal('NW')\n aliquotQuadrantString = aliquotQuadrantID + Supp...
[ 0, 1, 2, 3, 4 ]
from flask import Flask import os app = Flask(__name__) @app.route("/healthz") def healthz(): return "ok" @app.route("/alive") def alive(): return "ok" @app.route("/hello") # def healthz(): # introduces application crash bug def hello(): myhost = os.uname()[1] body = ("V1 - Hello World! - %s" % m...
normal
{ "blob_id": "0259fddbe3ce030030a508ce7118a6a03930aa51", "index": 7375, "step-1": "<mask token>\n\n\n@app.route('/healthz')\ndef healthz():\n return 'ok'\n\n\n@app.route('/alive')\ndef alive():\n return 'ok'\n\n\n@app.route('/hello')\ndef hello():\n myhost = os.uname()[1]\n body = 'V1 - Hello World! -...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-03-31 07:54 from __future__ import unicode_literals import codenerix.fields from django.db import migrations, models import django.db.models.deletion class Migration(migrations.Migration): dependencies = [ ('codenerix_products', '0005_remove_p...
normal
{ "blob_id": "0aed35827e6579f7a9434d252d0b9150ab24adf9", "index": 4573, "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 = [('codenerix_p...
[ 0, 1, 2, 3, 4 ]
from compas.geometry import Frame
normal
{ "blob_id": "d4e3751b2d4796c72be497007fe4c7d8ca67e18e", "index": 6874, "step-1": "<mask token>\n", "step-2": "from compas.geometry import Frame\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
class Error(Exception): pass class TunnelInstanceError(Error): def __init__(self, expression, message): self.expression = expression self.message = message class TunnelManagerError(Error): def __init__(self, expression, message): self.expression = expression self.messag...
normal
{ "blob_id": "661b622708692bd9cd1b3399835f332c86e39bf6", "index": 8835, "step-1": "<mask token>\n\n\nclass TunnelManagerError(Error):\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TunnelManagerError(Error):\n\n def __init__(self, expression, message):\n self.expression = expression\n ...
[ 1, 2, 3, 4, 5 ]
# dg_kernel plots import os import re import numpy as np import matplotlib.pyplot as plt import matplotlib.colors as mcolors import csv import sys NE_SIZE = 128 TITLE_SIZE = 35 TEXT_SIZE = 30 MARKER_SIZE = 10 LINE_WIDTH = 5 colors = { idx:cname for idx, cname in enumerate(mcolors.cnames) } eventname = 'L1_DCM' cal...
normal
{ "blob_id": "872b13a93c9aba55c143ee9891543f059c070a36", "index": 4631, "step-1": "# dg_kernel plots\n\nimport os\nimport re\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.colors as mcolors\nimport csv\nimport sys\n\nNE_SIZE = 128\nTITLE_SIZE = 35 \nTEXT_SIZE = 30 \nMARKER_SIZE = 10\nLINE...
[ 0 ]
#!/usr/bin/env python # coding:utf-8 import time from SocketServer import (TCPServer as TCP, StreamRequestHandler as SRH) HOST = '127.0.0.1' PORT = 8888 BUFSIZE = 1024 ADDR = (HOST, PORT) class MyRequestHandler(SRH): def handle(self): print '...connected from :', self.client_addr...
normal
{ "blob_id": "377143635939cf113e4188b5c4f55cec068a17b1", "index": 4171, "step-1": "#!/usr/bin/env python\n# coding:utf-8\nimport time\nfrom SocketServer import (TCPServer as TCP,\n StreamRequestHandler as SRH)\n\nHOST = '127.0.0.1'\nPORT = 8888\nBUFSIZE = 1024\nADDR = (HOST, PORT)\n\nclas...
[ 0 ]
#!/usr/bin/env python ################################################################################ # # HDREEnable.py # # Version: 1.000 # # Author: Gwynne Reddick # # Description: # # # Usage: # # Last Update 16:49 08/12/10 # ################################################################################ # pa...
normal
{ "blob_id": "78a96020abfd393438c2fce1dfd5fd159a23ca5a", "index": 9666, "step-1": "<mask token>\n\n\ndef itemexists(name):\n lx.eval('select.item {%s} set' % name)\n selected = lx.evalN('item.name ?')\n return name in selected\n\n\ndef lockcamera():\n if not itemexists('HDRECam_Grp'):\n lx.eval...
[ 6, 7, 9, 10, 11 ]
import socket END = bytearray() END.append(255) print(END[0]) def recvall(sock): # Odbiór danych BUFF_SIZE = 4096 # 4 KiB data = b'' while True: # odbieramy dane, pakiety 4KiB part = sock.recv(BUFF_SIZE) data += part if len(part) < BUFF_SIZE: # 0 lub koniec danych ...
normal
{ "blob_id": "aa13278a4686e9bab7948c2f212f87f9bd6eee00", "index": 969, "step-1": "<mask token>\n\n\ndef recvall(sock):\n BUFF_SIZE = 4096\n data = b''\n while True:\n part = sock.recv(BUFF_SIZE)\n data += part\n if len(part) < BUFF_SIZE:\n break\n return data\n\n\n<mask...
[ 5, 6, 8, 9, 10 ]
from pyramid.view import view_config, view_defaults from ecoreleve_server.core.base_view import CRUDCommonView from .individual_resource import IndividualResource, IndividualsResource, IndividualLocationsResource @view_defaults(context=IndividualResource) class IndividualView(CRUDCommonView): @view_config(name='...
normal
{ "blob_id": "a3cfd507e30cf232f351fbc66d347aaca99a0447", "index": 4059, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@view_defaults(context=IndividualResource)\nclass IndividualView(CRUDCommonView):\n <mask token>\n", "step-3": "<mask token>\n\n\n@view_defaults(context=IndividualResource)\nclas...
[ 0, 1, 2, 3 ]
../pyline/pyline.py
normal
{ "blob_id": "3fe98c865632c75c0ba0e1357379590f072bf662", "index": 7840, "step-1": "../pyline/pyline.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
import pytest from chess.board import Board, ImpossibleMove from chess.pieces import King, Rook, Pawn, Knight def test_board_has_32_pieces(): board = Board() assert board.pieces_quantity() == 32 def test_board_can_be_instatiated_with_any_set_of_pieces(): board = Board(initial_pieces={'a2': Pawn('white'...
normal
{ "blob_id": "5f471fb75b1c4f6fc7aa4cb4f99f9c1a1a9f0ea1", "index": 8595, "step-1": "<mask token>\n\n\ndef test_board_can_be_instatiated_with_any_set_of_pieces():\n board = Board(initial_pieces={'a2': Pawn('white'), 'a6': Pawn('black')})\n assert board.pieces_quantity() == 2\n\n\ndef test_piece_cant_capture_a...
[ 3, 7, 9, 10, 11 ]
'''Module main''' import argparse import api import quoridor import quoridorx def analyser_commande(): '''Analyseur de ligne de commande.''' parser = argparse.ArgumentParser(description='Jeu Quoridor - phase 3') parser.add_argument("idul", help="IDUL du joueur.") parser.add_argument("-l", '--lister'...
normal
{ "blob_id": "f69544a9123f1738cd7d21c1b4fc02dd73fb9d1b", "index": 6008, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef analyser_commande():\n \"\"\"Analyseur de ligne de commande.\"\"\"\n parser = argparse.ArgumentParser(description='Jeu Quoridor - phase 3')\n parser.add_argument('idul', ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python import argparse import pymssql import json #get the lcmMediaId from DB. def getMediaId(contentProviderMediaName): #test db conn = pymssql.connect(host='CHELLSSSQL23.karmalab.net', user='TravCatalog', password='travel', database='LodgingCatalogMaster_Phoenix') #prod db #conn = pyms...
normal
{ "blob_id": "a5b7f565a1797e5f326bcf26ff7c8ad2469dca70", "index": 7442, "step-1": "<mask token>\n\n\ndef getMediaId(contentProviderMediaName):\n conn = pymssql.connect(host='CHELLSSSQL23.karmalab.net', user=\n 'TravCatalog', password='travel', database=\n 'LodgingCatalogMaster_Phoenix')\n cur ...
[ 1, 2, 3, 4, 5 ]
"""For logging training information to files.""" import os def delete_log(file_path): """Delete a log file. Args: file_path: String, the full path to the log file. Raises: ValueError: if file not found. """ if os.path.exists(file_path): print('Deleting log %s...' % file_path)...
normal
{ "blob_id": "1355c3abfd2683f6dc869703fdb79a04e264099c", "index": 3421, "step-1": "<mask token>\n\n\nclass Logger:\n <mask token>\n\n def __init__(self, file_path, print_too=True, override=False):\n \"\"\"Create a new Logger.\n\n Args:\n file_path: String, the full path to the target ...
[ 3, 4, 5, 6, 7 ]
# -*- coding: utf-8 -*- from __future__ import absolute_import from __future__ import division from __future__ import print_function from __future__ import unicode_literals import logging from django.db import transaction from ralph_scrooge.models import ProfitCenter from ralph_scrooge.plugins import plugin_runner ...
normal
{ "blob_id": "d3f52d4713ba4b7b4cd736b26809968e259be63c", "index": 6883, "step-1": "<mask token>\n\n\n@plugin_runner.register(chain='scrooge')\ndef ralph3_profit_center(**kwargs):\n new_pc = total = 0\n for pc in get_from_ralph('profit-centers', logger):\n created = update_profit_center(pc)\n i...
[ 1, 2, 3, 4, 5 ]
""" - Define a new class Student which is derived from Human and has: grade field. do_hobby - print 'dancing' or some another hobby """ import andy.Lesson_7.exercise_1 class Student(andy.Lesson_7.exercise_1.Human): def __init__(self, firstname, lastname, grade): super().__init__(firstname, lastname) ...
normal
{ "blob_id": "497f56891670f635feff983058e86055e54be493", "index": 2618, "step-1": "<mask token>\n\n\nclass Student(andy.Lesson_7.exercise_1.Human):\n\n def __init__(self, firstname, lastname, grade):\n super().__init__(firstname, lastname)\n self.grade = grade\n\n def do_hobby(self):\n ...
[ 3, 4, 5, 6, 7 ]
import glob from collections import defaultdict from stylalto.datasets.extractor import read_alto_for_training, extract_images_from_bbox_dict_for_training, split_dataset data = defaultdict(list) images = {} for xml_path in glob.glob("./input/**/*.xml", recursive=True): current, image = read_alto_for_training(xml_...
normal
{ "blob_id": "41e642c4acb212470577ef43908a1dcf2e0f5730", "index": 7159, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor xml_path in glob.glob('./input/**/*.xml', recursive=True):\n current, image = read_alto_for_training(xml_path)\n images[image] = current\n for key in current:\n data[k...
[ 0, 1, 2, 3, 4 ]
import cv2 # open webcam (웹캠 열기) webcam = cv2.VideoCapture(0) if not webcam.isOpened(): print("Could not open webcam") exit() sample_num = 0 captured_num = 0 # loop through frames while webcam.isOpened(): # read frame from webcam status, frame = webcam.read() sample_num = s...
normal
{ "blob_id": "856a27e953a6b4e1f81d02e00717a8f95a7dea5f", "index": 7790, "step-1": "<mask token>\n", "step-2": "<mask token>\nif not webcam.isOpened():\n print('Could not open webcam')\n exit()\n<mask token>\nwhile webcam.isOpened():\n status, frame = webcam.read()\n sample_num = sample_num + 1\n ...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/python class Symbol(object): pass class Fundef(Symbol): def __init__(self, name, type, args): self.name = name self.type = type self.args = args class VariableSymbol(Symbol): def __init__(self, name, type): self.name = name self.type = type class ...
normal
{ "blob_id": "6cc23e370d1ec1e3e043c3fa6819f9166b6e3b40", "index": 4434, "step-1": "<mask token>\n\n\nclass Scope(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def name(self):\n return self.name\n\n\nclass SymbolTable(object):\n\n def __init__(self, scope_name):\...
[ 14, 17, 19, 22, 24 ]
import math,random,numpy as np def myt(): x=[0]*10 y=[] for i in range(100000): tmp = int(random.random()*10) x[tmp] = x[tmp]+1 tmpy=[0]*10 tmpy[tmp] = 1 for j in range(10): tmpy[j] = tmpy[j] + np.random.laplace(0,2,None) y.append(tmpy) result...
normal
{ "blob_id": "7b7705cdaa8483f6abbc3f4fb3fa1ca506742da8", "index": 6042, "step-1": "import math,random,numpy as np\n\ndef myt():\n x=[0]*10\n y=[]\n for i in range(100000):\n tmp = int(random.random()*10)\n x[tmp] = x[tmp]+1\n tmpy=[0]*10\n tmpy[tmp] = 1\n for j in range...
[ 0 ]
print('Boolean Exercise') print(False or False) print(False and False) print(not True or not False)
normal
{ "blob_id": "2385882f040ef4bd0a3611bebfbb2ae5b3cd1dc6", "index": 4204, "step-1": "<mask token>\n", "step-2": "print('Boolean Exercise')\nprint(False or False)\nprint(False and False)\nprint(not True or not False)\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
import tensorflow as tf from rnn_cells import gru_cell, lstm_cell from tensorflow.python.ops import rnn def shape_list(x): ps = x.get_shape().as_list() ts = tf.shape(x) return [ts[i] if ps[i] is None else ps[i] for i in range(len(ps))] def bi_dir_lstm(X, c_fw, h_fw, c_bw, h_bw, units, scope='bi_dir_lstm')...
normal
{ "blob_id": "e550a2d46e46f0e07d960e7a214fbaa776bab0d5", "index": 4697, "step-1": "<mask token>\n\n\ndef shape_list(x):\n ps = x.get_shape().as_list()\n ts = tf.shape(x)\n return [(ts[i] if ps[i] is None else ps[i]) for i in range(len(ps))]\n\n\ndef bi_dir_lstm(X, c_fw, h_fw, c_bw, h_bw, units, scope='bi...
[ 6, 7, 8, 9, 12 ]
name_list =[ ] a = 1 for a in range(1,33): name = input("请输入要加入列表的名字:") name_list.append("name") print(name) print(list_ name)
normal
{ "blob_id": "3f7dddcfde9d33f30f00156fc41700da2692afc3", "index": 2006, "step-1": "name_list =[ ]\na = 1\nfor a in range(1,33):\n name = input(\"请输入要加入列表的名字:\")\n name_list.append(\"name\")\n print(name)\nprint(list_ name)\n", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "ste...
[ 0 ]
myfavoritenumber = 5 print(myfavoritenumber) x = 5 x = x + 1 print(x) x, y, z = 1, 2, 3 print(x, y, z)
normal
{ "blob_id": "e6c7b15e5b42cfe6c5dec2eaf397b67afd716ebd", "index": 3858, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(myfavoritenumber)\n<mask token>\nprint(x)\n<mask token>\nprint(x, y, z)\n", "step-3": "myfavoritenumber = 5\nprint(myfavoritenumber)\nx = 5\nx = x + 1\nprint(x)\nx, y, z = 1, 2, 3...
[ 0, 1, 2 ]
# Complete the hurdleRace function below. def hurdleRace(k, height): if k < max(height): return max(height) - k return 0 print(hurdleRace(2, [2,5,4,5,2]))
normal
{ "blob_id": "c139cbc3e693d75ad196e10257ff3028aa835709", "index": 428, "step-1": "<mask token>\n", "step-2": "def hurdleRace(k, height):\n if k < max(height):\n return max(height) - k\n return 0\n\n\n<mask token>\n", "step-3": "def hurdleRace(k, height):\n if k < max(height):\n return m...
[ 0, 1, 2, 3 ]
# -*- coding: utf-8 -*- """ Created on Mon Aug 13 14:10:15 2018 9.5 项目:将一个文件夹备份到一个 ZIP 文件 @author: NEVERGUVEIP """ #! python3 import zipfile,os def backupToZip(folder): #backup the entire contents of 'folder' into a ZIP file folder = os.path.abspath(folder) os.chdir(folder) #figure out the fil...
normal
{ "blob_id": "7af19f69e6c419649a5999f594118ad13833a537", "index": 7398, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef backupToZip(folder):\n folder = os.path.abspath(folder)\n os.chdir(folder)\n number = 1\n while True:\n zipFilename = os.path.basename(folder) + '_' + str(numbe...
[ 0, 1, 2, 3, 4 ]
# ---------------------------------------------------------------------------- # Copyright (c) 2016-2018, q2-chemistree development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE, distributed with this software. # ------------------------------------------...
normal
{ "blob_id": "4296dc5b79fd1d2c872eb1115beab52a0f067423", "index": 4816, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PluginSetupTests(unittest.TestCase):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass PluginSetupTests(unittest.TestCase):\n\n def test_plugin_setup(self):\n ...
[ 0, 1, 2, 3, 4 ]
import sys import random import pygame import pygame.locals import time # TODO high scores, difficulties # Absolutes (in pixels where not otherwise stated) CELL_SIDE_LENGTH = 40 # Side length of each cell CELL_MARGIN = 2 # Gap between cells GRID_HEIGHT = 10 # How many cells are in the grid GRID_WIDTH = 10 X_...
normal
{ "blob_id": "030bc0c7bdbbb09f722ffe4c82866726062f5317", "index": 1962, "step-1": "<mask token>\n\n\nclass Game:\n\n def __init__(self):\n pygame.init()\n global CLOCK, SURFACE\n CLOCK = pygame.time.Clock()\n SURFACE = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))\n ...
[ 10, 16, 17, 21, 22 ]
"""empty message Revision ID: 6374505f9e6e Revises: 9dc91bb7d2ba Create Date: 2016-11-14 10:55:08.418923 """ # revision identifiers, used by Alembic. revision = '6374505f9e6e' down_revision = '9dc91bb7d2ba' from alembic import op import sqlalchemy as sa import sqlalchemy.types as ty def upgrade(): ### command...
normal
{ "blob_id": "7badb7c9f1e00dfc379468b7bd73a3f09bffe6de", "index": 1191, "step-1": "<mask token>\n\n\ndef downgrade():\n op.alter_column('run', 'polarion_id', type_=ty.String(1024))\n op.alter_column('auto_result', 'skip', type_=ty.String(65535))\n op.alter_column('auto_result', 'failure', type_=ty.String...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Automatically create and parse commands based on a YAML configuration file. NOTE: we can't have a logger here, before knowing the level of debug. """ import os import sys import argparse from controller import __version__, PROJECTRC, PROJECTRC_ALTERNATIVE from controller.conf_utilities im...
normal
{ "blob_id": "94559d9fd296acd468c33d6b0541b974575b8852", "index": 4119, "step-1": "<mask token>\n\n\nclass ArgParser:\n <mask token>\n\n def add_parser_argument(self, parser, option_name, options):\n params = self.prepare_params(options)\n alias = params.pop('alias', None)\n positional ...
[ 4, 5, 6, 7, 8 ]
def func(n): return n * 2 def my_map(f, seq): return [f(item) for item in seq] def main(): numbers = [1, 2, 3, 4] result = list(map(func, numbers)) print(result) result = [func(item) for item in numbers] print(result) if __name__ == '__main__': main()
normal
{ "blob_id": "55acae8129ddaba9a860d5d356e91f40607ac95a", "index": 8614, "step-1": "<mask token>\n", "step-2": "def func(n):\n return n * 2\n\n\ndef my_map(f, seq):\n return [f(item) for item in seq]\n\n\n<mask token>\n", "step-3": "def func(n):\n return n * 2\n\n\ndef my_map(f, seq):\n return [f(i...
[ 0, 2, 3, 4 ]
import json import os import uuid from django.core.files.uploadedfile import SimpleUploadedFile from django.conf import settings from django.contrib.contenttypes.models import ContentType from nautobot.dcim.models import Site from nautobot.extras.choices import JobResultStatusChoices from nautobot.extras.jobs import ...
normal
{ "blob_id": "d2298ad1e4737b983ba6d1f2fff59750137510b5", "index": 904, "step-1": "<mask token>\n\n\nclass JobTest(TestCase):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def test_field_order(self):\n \"\"\"\n Job test with field order.\n \"\...
[ 10, 15, 16, 17, 20 ]
""" Note: names of methods in this module, if seem weird, are the same as in Hunspell's ``suggest.cxx`` to keep track of them. """ from typing import Iterator, Union, List, Set from spylls.hunspell.data import aff MAX_CHAR_DISTANCE = 4 def replchars(word: str, reptable: List[aff.RepPattern]) -> Iterator[Union[str...
normal
{ "blob_id": "cfba55505f3290a14b98d594bc871a74812c7c57", "index": 5594, "step-1": "<mask token>\n\n\ndef replchars(word: str, reptable: List[aff.RepPattern]) ->Iterator[Union[\n str, List[str]]]:\n \"\"\"\n Uses :attr:`aff.REP <spylls.hunspell.data.aff.Aff.REP>` table (typical misspellings) to replace\n ...
[ 6, 9, 12, 13, 14 ]
import tkinter as tk from tkinter import ttk, messagebox, Menu ventana = tk.Tk() EntryArr = [] Label = ["¿Que es la analisis psicologico?", "¿Como se lee la mente?", "¿Cuantas persepciones psicologicas existen?", "¿Padre de la Psicologia moderna?", "Parte del cuerpo donde esta la psyco"] Arr3 = tk.IntVar() opciones1 ...
normal
{ "blob_id": "aeab80e2d0006ffa938366ef046d2ab3d387f88c", "index": 1152, "step-1": "<mask token>\n\n\ndef click():\n i = 0\n cal = 0\n info = ''\n for x in EntryArr:\n if not x.get():\n messagebox.showinfo('Error', 'Campos no llenos')\n return\n else:\n in...
[ 3, 5, 6, 7, 8 ]
# -*- coding: utf-8 -*- from django.contrib.auth import logout, login, authenticate from django.contrib.auth.models import User from django.http import HttpResponse, Http404, HttpResponseRedirect from django.middleware.csrf import get_token from django.template.context import Context from django.utils.translation impor...
normal
{ "blob_id": "11163dc99ee65ab44494c08d81e110e9c42390ae", "index": 3130, "step-1": "<mask token>\n\n\ndef main(request):\n c = base_context(request)\n template = get_template('index.html')\n c['title'] = _('Request')\n form = RequestForm()\n user = request.user\n c['user'] = user\n if user.is_...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.20 on 2019-04-11 03:58 from __future__ import unicode_literals from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('produksi', '0055_auto_20190409_1316'), ] operations = [ migrations.R...
normal
{ "blob_id": "1eb5df463bbd39002c5dbc3f88459e2f26d4b465", "index": 8505, "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 = [('produksi', ...
[ 0, 1, 2, 3, 4 ]
import random import time from typing import Dict, List, Optional from bemani.client.base import BaseClient from bemani.protocol import Node class ReflecBeatColette(BaseClient): NAME = 'TEST' def verify_pcb_boot(self, loc: str) -> None: call = self.call_node() pcb = Node.void('pcb') ...
normal
{ "blob_id": "f781377a52400abd617e7f0c5529726120b78476", "index": 3426, "step-1": "<mask token>\n\n\nclass ReflecBeatColette(BaseClient):\n <mask token>\n\n def verify_pcb_boot(self, loc: str) ->None:\n call = self.call_node()\n pcb = Node.void('pcb')\n pcb.set_attribute('method', 'boot...
[ 13, 14, 16, 18, 20 ]
from fastapi import APIRouter, Depends from fastapi.responses import RedirectResponse import app.setting as setting from app.dependencies import get_project_by_prefix from app.entities.project import Project router = APIRouter( prefix="/go", ) @router.get("/{prefix_id}") def redirect_to_board(project: Project ...
normal
{ "blob_id": "49b295c3e323695779eb32181193ef88b678b34d", "index": 6340, "step-1": "<mask token>\n\n\n@router.get('/{prefix_id}')\ndef redirect_to_board(project: Project=Depends(get_project_by_prefix)):\n return RedirectResponse(url=project.notion_board_url)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\n...
[ 1, 2, 3, 4, 5 ]
import constants from auth.storage import Storage from utils import create_error_with_status from flask import jsonify, request, current_app def register_user(): try: email = request.json["email"] password = request.json["password"] except KeyError: status = constants.statuses["user"...
normal
{ "blob_id": "73a4b3497952f90029ba24b73b835de53fc687ec", "index": 3349, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef register_user():\n try:\n email = request.json['email']\n password = request.json['password']\n except KeyError:\n status = constants.statuses['user']['...
[ 0, 1, 2, 3 ]
# %load q03_skewness_log/build.py from scipy.stats import skew import pandas as pd import numpy as np data = pd.read_csv('data/train.csv') # Write code here: def skewness_log(df): df['SalePrice_New'] = np.log(df['SalePrice']) df['GrLivArea_New'] = np.log(df['GrLivArea']) skewed_slPri = skew(df['SalePrice...
normal
{ "blob_id": "f5bd41f4aaff616a332d80ec44c364ffc91c58f0", "index": 265, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef skewness_log(df):\n df['SalePrice_New'] = np.log(df['SalePrice'])\n df['GrLivArea_New'] = np.log(df['GrLivArea'])\n skewed_slPri = skew(df['SalePrice_New'])\n skewness_...
[ 0, 1, 2, 3, 4 ]
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, ForeignKey, Float from sqlalchemy.orm import relationship, backref ORMBase = declarative_base() def create_all(engine): ORMBase.metadata.create_all(engine)
normal
{ "blob_id": "c7ca8235864ce5de188c4aa2feb9ad82d4fa9b0f", "index": 4023, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef create_all(engine):\n ORMBase.metadata.create_all(engine)\n", "step-3": "<mask token>\nORMBase = declarative_base()\n\n\ndef create_all(engine):\n ORMBase.metadata.create_...
[ 0, 1, 2, 3 ]
import calendar import json from datetime import datetime from datapoller.download import download from datapoller.settings import * from messaging.Messaging import sendMessage from messaging.settings import RABBIT_NOTIFY_QUEUE from sessioncontroller.utils import is_level_interesting_for_kp __author__ = 'arik' shared...
normal
{ "blob_id": "e8f090a02bfd5ee8a6832351357594af2d6692f9", "index": 8702, "step-1": "<mask token>\n\n\ndef registerModelStorage(dict):\n global sharedDict\n sharedDict = dict\n\n\ndef updateModel():\n lastLevels, validTime = download(NOWCAST_DATA_URL)\n sharedDict['lastLevels'] = lastLevels\n sharedD...
[ 3, 4, 5, 6, 8 ]
import graphics import ply.lex as lex import ply.yacc as yacc import jstokens import jsgrammar def interpret(trees): # Hello, friend for tree in trees: # Hello, # ("word-element","Hello") nodetype=tree[0] # "word-element" if nodetype == "word-element": graphics.word(tree[1]) ...
normal
{ "blob_id": "f3b3bee494493263f8b00827e6f3ff3a1dcd8c37", "index": 6144, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef interpret(trees):\n for tree in trees:\n nodetype = tree[0]\n if nodetype == 'word-element':\n graphics.word(tree[1])\n elif nodetype == 'tag-el...
[ 0, 1, 2, 3 ]
# add some description here import glob import matplotlib.pyplot as plt import numpy as np import pandas as pd import xarray as xr import pandas as pd import os import pickle from scipy.interpolate import griddata from mpl_toolkits.basemap import Basemap from mpl_toolkits.axes_grid1 import make_axes_locatable from mat...
normal
{ "blob_id": "4c1fea4dcf143ec976d3956039616963760d5af6", "index": 5030, "step-1": "<mask token>\n", "step-2": "<mask token>\nmatplotlib.style.use('ggplot')\n<mask token>\nsys.path.append('masterThesisPack/')\n<mask token>\nraw.wind_along.plot(ax=ax)\nax.axhline(y=3 * std, c='k', ls='dashed')\nax.axhline(y=-3 * ...
[ 0, 1, 2, 3, 4 ]
from pwn import * p = process("./weeb_hunting") elf = ELF("/lib/x86_64-linux-gnu/libc-2.23.so") pwnlib.gdb.attach(p) r = p.recv() while "You found a" not in r: r = p.recvuntil(">") p.send("AAAA\n") p.send("AAAA\n") r = p.recv() while "You found a" not in r: r = p.recvuntil(">") p.send("AAAA\n") p.send("AAAA\n")...
normal
{ "blob_id": "5eb4c71869b077dac0d61072c99d801030395fc2", "index": 636, "step-1": "<mask token>\n", "step-2": "<mask token>\npwnlib.gdb.attach(p)\n<mask token>\nwhile 'You found a' not in r:\n r = p.recvuntil('>')\n p.send('AAAA\\n')\np.send('AAAA\\n')\n<mask token>\nwhile 'You found a' not in r:\n r = ...
[ 0, 1, 2, 3, 4 ]
# using python3 class Rational: def __init__(self, numer, denom): self.numer = numer self.denom = denom def __add__(self, other): return Rational( self.numer * other.denom + other.numer * self.denom, self.denom * other.denom ) def __sub__(self, oth...
normal
{ "blob_id": "8098b9c27689dd4168ef05c03d4ec00f67f8090e", "index": 4771, "step-1": "class Rational:\n\n def __init__(self, numer, denom):\n self.numer = numer\n self.denom = denom\n <mask token>\n <mask token>\n\n def __mul__(self, other):\n return Rational(self.numer * other.numer...
[ 3, 6, 7, 8, 9 ]
from django.contrib import admin from django.urls import path from . import view urlpatterns = [ path('', view.enterMarks), path('MarkSheet', view.getMarks, name='MarkSheet'), ]
normal
{ "blob_id": "511c555c88fb646b7b87678044b43a5a623a5ac7", "index": 4670, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', view.enterMarks), path('MarkSheet', view.getMarks,\n name='MarkSheet')]\n", "step-3": "from django.contrib import admin\nfrom django.urls import path\nfrom . ...
[ 0, 1, 2, 3 ]
learningRateBase = 0.001 learningRateDecreaseStep = 80 epochNum = 100 generateNum = 3 batchSize = 16 trainPoems = "./data/poems.txt" checkpointsPath = "./model/"
normal
{ "blob_id": "2fb299f5454c251dc1c77c2597ee23bf414c716e", "index": 4845, "step-1": "<mask token>\n", "step-2": "learningRateBase = 0.001\nlearningRateDecreaseStep = 80\nepochNum = 100\ngenerateNum = 3\nbatchSize = 16\ntrainPoems = './data/poems.txt'\ncheckpointsPath = './model/'\n", "step-3": "learningRateBase...
[ 0, 1, 2 ]
import mysql.connector import hashlib import time from datetime import datetime from datetime import timedelta from pymongo import MongoClient from pymongo import IndexModel, ASCENDING, DESCENDING class MongoManager: def __init__(self, server_ip='localhost', client=None, expires=timedelta(days=30)): ""...
normal
{ "blob_id": "4cb5dcf0d943ef15421bb6bced65804533d232e3", "index": 4950, "step-1": "import mysql.connector\nimport hashlib\nimport time \nfrom datetime import datetime\nfrom datetime import timedelta\n\nfrom pymongo import MongoClient\nfrom pymongo import IndexModel, ASCENDING, DESCENDING\n\n\nclass MongoManager:\...
[ 0 ]
#!/bin/usr/python ''' Author: SaiKumar Immadi Basic DBSCAN clustering algorithm written in python 5th Semester @ IIIT Guwahati ''' # You can use this code for free. Just don't plagiarise it for your lab assignments import sys from math import sqrt from random import randint import matplotlib.pyplot as plt def main(a...
normal
{ "blob_id": "624ecf743d5be1acc33df14bd721b3103d232f0e", "index": 2444, "step-1": "#!/bin/usr/python\n'''\nAuthor: SaiKumar Immadi\nBasic DBSCAN clustering algorithm written in python\n5th Semester @ IIIT Guwahati\n'''\n\n# You can use this code for free. Just don't plagiarise it for your lab assignments\n\nimpor...
[ 0 ]
import os import inspect import pytest from ._common import copy_default_profile_collection, patch_first_startup_file from bluesky_queueserver.manager.profile_tools import global_user_namespace, load_devices_from_happi from bluesky_queueserver.manager.profile_ops import load_profile_collection def create_local_impor...
normal
{ "blob_id": "ad1ec5dd8fae290ab6cb73b17c5522e062261359", "index": 6698, "step-1": "<mask token>\n\n\ndef create_local_imports_files(tmp_path):\n path_dir = os.path.join(tmp_path, 'dir_local_imports')\n fln_func = os.path.join(path_dir, 'file_func.py')\n fln_gen = os.path.join(path_dir, 'file_gen.py')\n ...
[ 5, 6, 7, 8, 9 ]
#!/usr/local/bin/python3 """ Copyright (c) 2015-2019 Ad Schellevis <ad@opnsense.org> All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain th...
normal
{ "blob_id": "f4ae34be2be2b47b3394e6da751c53c51a1c3174", "index": 6678, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n fieldnames = None\n field_max_width = dict()\n result = {'headers': [], 'details': []}\n is_header = True\n tidpid = dict()\n for line in su...
[ 0, 1, 2, 3 ]
#returns true if given date is a leap year, false otherwise def is_leap_year(date): #if divisible by 400, definitely a leap year if date % 400 == 0: return True #if divisible by 100 (and not 400), not a leap year elif date % 100 == 0: return False #divisible by 4 and not by 100? leap year elif date % 4 == 0: r...
normal
{ "blob_id": "496d52a984bb8c0e72948ab0c8db5e6035427a68", "index": 5209, "step-1": "<mask token>\n", "step-2": "def is_leap_year(date):\n if date % 400 == 0:\n return True\n elif date % 100 == 0:\n return False\n elif date % 4 == 0:\n return True\n else:\n return False\n",...
[ 0, 1, 2 ]
{% load code_generator_tags %}from rest_framework.serializers import ModelSerializer {% from_module_import app.name|add:'.models' models %}{% comment %} {% endcomment %}{% for model in models %} class {{ model.name }}Serializer(ModelSerializer): class Meta: model = {{ model.name }} depth = 1 ...
normal
{ "blob_id": "888ec915d89f1fd8fd6465f1035f7c658af78596", "index": 6166, "step-1": "{% load code_generator_tags %}from rest_framework.serializers import ModelSerializer\n{% from_module_import app.name|add:'.models' models %}{% comment %}\n{% endcomment %}{% for model in models %}\n\n\nclass {{ model.name }}Serial...
[ 0 ]
# This implementation of EPG takes data as XML and produces corresponding pseudonymized data from lxml import etree from utils import generalize_or_supress from hashlib import sha256 from count import getLast, saveCount import pickle from hmac import new from random import random from json import loads from bigchain i...
normal
{ "blob_id": "8f554166c28fe4c9a093568a97d39b6ba515241b", "index": 3196, "step-1": "<mask token>\n\n\ndef EPGAD(ReportPath, Hi=None, GUi=None):\n if Hi == None:\n Hi = sha256(str(random()).encode()).hexdigest()\n jsn = open(ReportPath, 'rt').read()\n jsnld = loads(jsn)\n print('Report Loaded')\n...
[ 1, 2, 3, 4, 5 ]
import PySimpleGUI as sg class TelaLisatrClientes(): def __init__(self): self.__window = None def init_components(self, lista_clientes): layout = [ [sg.Text('Dados do cliente')], [sg.Listbox(values=lista_clientes, size=(60, 10))], [sg.Submit()] ] ...
normal
{ "blob_id": "624b34d160ea6db4f5249544f1614a20f506ca9e", "index": 895, "step-1": "<mask token>\n\n\nclass TelaLisatrClientes:\n <mask token>\n\n def init_components(self, lista_clientes):\n layout = [[sg.Text('Dados do cliente')], [sg.Listbox(values=\n lista_clientes, size=(60, 10))], [sg....
[ 2, 3, 4, 5, 6 ]