code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
import functools import re import nltk.data from nltk.corpus import stopwords from nltk.probability import FreqDist from nltk.tokenize import RegexpTokenizer def clean(string): string = re.sub(r"\'s", " \'s", string) string = re.sub(r"\'ve", " \'ve", string) string = re.sub(r"n\'t", " n\'t", string) s...
normal
{ "blob_id": "837e84d4a58d8fd0d0ffc24973d196ae57f9a260", "index": 1723, "step-1": "<mask token>\n\n\ndef reorder_sentences(output_sentences, input):\n\n def custom_sort(s1, s2):\n return input.find(s1) - input.find(s2)\n output_sentences.sort(key=functools.cmp_to_key(custom_sort))\n return output_...
[ 1, 4, 5, 6, 7 ]
# Generated by Django 3.1.2 on 2020-10-25 01:19 import datetime from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('jobs', '0001_initial'), ] operations = [ migrations.AddField( model_name='job', name='link', ...
normal
{ "blob_id": "562888201719456ed2f3c32e81ffd7d2c39dabc3", "index": 7303, "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 = [('jobs', '000...
[ 0, 1, 2, 3, 4 ]
#デフォルト引数の破壊 #以下、破壊的な操作 def sample(x, arg=[]): arg.append(x) return arg print(sample(1)) print(sample(2)) print(sample(3)) #対策・・・デフォルト引数にはイミュータブルなものを使用する def sample(x, arg=None): if arg is None: arg = [] arg.append(x) return arg print(sample(1)) print(sample(2)) pr...
normal
{ "blob_id": "1b645ab0a48b226e26009f76ea49fd3f10f5cc7b", "index": 3880, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sample(x, arg=None):\n if arg is None:\n arg = []\n arg.append(x)\n return arg\n\n\n<mask token>\n", "step-3": "def sample(x, arg=[]):\n arg.append(x)\n re...
[ 0, 1, 2, 3, 4 ]
import numpy as np from Ejercicio1 import norma_l2 def sorting_l2(mat): mat_l2 = norma_l2(mat) mat_sort_index = np.argsort(mat_l2) mat_sort_l2 = mat[mat_sort_index, :] return mat_sort_l2[::-1]
normal
{ "blob_id": "e280b003c95681ed4a887b0939077efeac9deefe", "index": 1377, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef sorting_l2(mat):\n mat_l2 = norma_l2(mat)\n mat_sort_index = np.argsort(mat_l2)\n mat_sort_l2 = mat[mat_sort_index, :]\n return mat_sort_l2[::-1]\n", "step-3": "impo...
[ 0, 1, 2 ]
import torch import torch.nn as nn from torch.nn import functional as F class FocalLoss1(nn.Module): def __init__(self, alpha=0.25, gamma=2, reduction='mean', ignore_lb=255): super().__init__() self.alpha = alpha self.gamma = gamma self.reduction = reduction self.ignore_lb ...
normal
{ "blob_id": "9e9303d58c7e091bf7432060fad292c16ecf85ee", "index": 9280, "step-1": "<mask token>\n\n\nclass FocalLoss(nn.Module):\n \"\"\"https://www.kaggle.com/c/human-protein-atlas-image-classification/discussion/78109\"\"\"\n\n def __init__(self, gamma=2):\n super().__init__()\n self.gamma =...
[ 4, 6, 7, 8, 9 ]
# Generated by Django 2.2.5 on 2019-10-09 12:06 from django.conf import settings from django.db import migrations, models import django.db.models.deletion import mptt.fields class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MOD...
normal
{ "blob_id": "5485fe4f612ededc11e3a96dfd546e97a56cbe2a", "index": 3316, "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 ]
#!usr/bin/env python3 from argoverse.map_representation.map_api import ArgoverseMap from frame import Frame import matplotlib.pyplot as plt import pickle import numpy as np from argo import draw_local_map # Frames in cluster visualization def frame_in_pattern_vis(xmin, xmax, ymin, ymax): dataset = 'ARGO' if ...
normal
{ "blob_id": "1284de6474e460f0d95f5c76d066b948bce59228", "index": 5575, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef velocity_field_visualization(xmin, xmax, ymin, ymax):\n with open('data_sample/argo_MixtureModel_%d_%d_%d_%d' % (xmin, xmax,\n ymin, ymax), 'rb') as mix_np:\n mix...
[ 0, 1, 2, 3, 4 ]
import numpy d1 = numpy.array([1.,0.,0.]) d2 = numpy.array([0.,1.,0.]) d3 = numpy.array([0.,0.,1.]) s0 = numpy.array([0.,0.,1.]) m2 = numpy.array([1.,0.,0.]) print "x y zeta" for x in xrange(-100, 101): for y in xrange(-100, 101): s = x*d1 + y*d2 + 100*d3 e1 = numpy.cross(s, s0) e1 /= numpy.linalg.norm(...
normal
{ "blob_id": "3d16f2da03c067d410bec7bfe96d874322533d30", "index": 6693, "step-1": "import numpy\n\nd1 = numpy.array([1.,0.,0.])\nd2 = numpy.array([0.,1.,0.])\nd3 = numpy.array([0.,0.,1.])\ns0 = numpy.array([0.,0.,1.])\nm2 = numpy.array([1.,0.,0.])\n\nprint \"x y zeta\"\nfor x in xrange(-100, 101):\n for y in xra...
[ 0 ]
# -*- coding: utf-8 -*- from django.test import TestCase from ..printer import Printer class TestSunlumoProjectPrinter(TestCase): def test_printer(self): sl_prj = Printer('./sunlumo_mapserver/test_data/test_sunlumo.qgs') tmpFile = '/tmp/printtmp' sl_prj.printToPdf({ 'tmpFile...
normal
{ "blob_id": "5e0cba6952cdc677c640a0df325426ffc89189cd", "index": 658, "step-1": "<mask token>\n\n\nclass TestSunlumoProjectPrinter(TestCase):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass TestSunlumoProjectPrinter(TestCase):\n\n def test_printer(self):\n sl_prj = Printer(...
[ 1, 2, 3, 4, 5 ]
""" pyautogui 屏幕像素获取、屏幕像素匹配 @author : zhouhuajian @version : v1.0 """ from pyautogui import pixel, pixelMatchesColor, screenshot """ 主要内容: 1. pixel() - 获取屏幕像素; 2. pixelMatchesColor() - 屏幕像素匹配颜色。 """ def test_pixel_pixelMatchesColor(): """屏幕像素获取、屏幕像素匹配""" # img = screenshot() # print(img) # print(i...
normal
{ "blob_id": "c15faf9df8fa2e1ad89ea2c922ab0551eaa69d3f", "index": 1936, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_pixel_pixelMatchesColor():\n \"\"\"屏幕像素获取、屏幕像素匹配\"\"\"\n print(pixelMatchesColor(44, 107, (148, 212, 234), tolerance=20))\n print(pixelMatchesColor(44, 107, (100, 21...
[ 0, 1, 2, 3, 4 ]
#-*- coding: UTF-8 -*- import re import time import sys import command.server.handle_utility as Utility from ee.common import logger from ee.common import xavier as Xavier1 sys.path.append('/opt/seeing/app/') from b31_bp import xavier1 as Xavier2 global agv agv=sys.argv[1] Xavier=Xavier1 xavier_module = {"tcp:7801":Xa...
normal
{ "blob_id": "10e1756dc1d6c7b6b7e3569de78e9fa4cdfb0d7e", "index": 7136, "step-1": "<mask token>\n\n\ndef dac_voltage_set_handle(params):\n help_info = ('dac set(<channel>,<value>)$\\r\\n \\t channel(' +\n help_str +\n ')\\tvalue: (if ad5761: (0~10000) unit:mv,else :(0~5000) unit:mv) $\\r\\n'...
[ 2, 3, 4, 5, 6 ]
# __author__ = 'Vasudev Gupta' import tf_lightning as tl import tensorflow as tf class TestModel(tl.LightningModule): # just a random model with random dataset def __init__(self): # simple test model super().__init__() self.model = tf.keras.Sequential([ tf.keras.layers.D...
normal
{ "blob_id": "f2397ba3fe1452238f251111f35b06b4a93e0359", "index": 2441, "step-1": "<mask token>\n\n\nclass TestModel(tl.LightningModule):\n <mask token>\n <mask token>\n <mask token>\n\n def training_step(self, batch, batch_idx, optimizer_idx):\n pred = self(batch)\n loss = tf.reduce_mea...
[ 7, 11, 12, 14, 15 ]
# Create your views here. from django.http import HttpResponse, HttpResponseRedirect from django.template import Context, loader from django.db import transaction from django.db.models import Q from maximus.models import Mercenary, Team, TeamMember, Tournament, TournamentTeam, TournamentMatchup, Matchup, MatchupStatis...
normal
{ "blob_id": "f66f82c5c2842fc4fcae2251d4a16a9850230041", "index": 3547, "step-1": "<mask token>\n\n\ndef edit_team(request):\n\n def get():\n team_id = request.GET['team']\n team = Team.objects.get(id=team_id)\n model = Context({'team': team})\n t = loader.get_template('edit_team.ht...
[ 6, 7, 9, 10, 11 ]
from zope import schema from zope import interface from zope import component from raptus.mailcone.rules_regex import _ from raptus.mailcone.rules import interfaces class IRegexItem(interfaces.IConditionItem): """ Interface for regex match filter """ regex = schema.TextLine(title=_('Regex'), required=True...
normal
{ "blob_id": "fe83b45bdc5970d63deab66b26b16752cd8ad8ef", "index": 7241, "step-1": "<mask token>\n\n\nclass IRegexItem(interfaces.IConditionItem):\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass IRegexItem(interfaces.IConditionItem):\n <mask token>\n regex = sch...
[ 1, 2, 3, 4 ]
from ._monitor import TMonitor as TMonitor, TqdmSynchronisationWarning as TqdmSynchronisationWarning from ._tqdm_pandas import tqdm_pandas as tqdm_pandas from .cli import main as main from .gui import tqdm as tqdm_gui, trange as tgrange from .std import TqdmDeprecationWarning as TqdmDeprecationWarning, TqdmExperimental...
normal
{ "blob_id": "25b7af2a8036f35a0bca665867d1729b7c9c113c", "index": 5846, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef tnrange(*args, **kwargs):\n ...\n", "step-3": "<mask token>\n\n\ndef tqdm_notebook(*args, **kwargs):\n ...\n\n\ndef tnrange(*args, **kwargs):\n ...\n", "step-4": "fro...
[ 0, 1, 2, 3 ]
import os import telebot bot = telebot.TeleBot(os.environ.get('TELEGRAM_ACCESS_TOCKEN', 'TOKEN'))
normal
{ "blob_id": "ce7b7980d1e93f23e7e3ef048ddadc0c779ef9ce", "index": 7981, "step-1": "<mask token>\n", "step-2": "<mask token>\nbot = telebot.TeleBot(os.environ.get('TELEGRAM_ACCESS_TOCKEN', 'TOKEN'))\n", "step-3": "import os\nimport telebot\nbot = telebot.TeleBot(os.environ.get('TELEGRAM_ACCESS_TOCKEN', 'TOKEN'...
[ 0, 1, 2 ]
import unittest from month import Month class MonthUnitTests(unittest.TestCase): def test_header(self): cal = Month(5, 2012) result = cal.header() self.assertEqual(" May 2012", result) def test_header_different_month(self): cal = Month(3, 2012) result = cal.header() self.assertEqual(" March 20...
normal
{ "blob_id": "36c1d75171d772138b820651e11a3a7bc3a6521c", "index": 8226, "step-1": "<mask token>\n\n\nclass MonthUnitTests(unittest.TestCase):\n\n def test_header(self):\n cal = Month(5, 2012)\n result = cal.header()\n self.assertEqual(' May 2012', result)\n\n def test_header_differ...
[ 13, 14, 15, 16, 17 ]
#------------------------------------------------------------ # Copyright 2016 Congduc Pham, University of Pau, France. # # Congduc.Pham@univ-pau.fr # # This file is part of the low-cost LoRa gateway developped at University of Pau # # This program is free software: you can redistribute it and/or modify # it under the...
normal
{ "blob_id": "475cb57ce5fda0d0389bfa1b9b227a2147e1abde", "index": 9389, "step-1": "#------------------------------------------------------------\n# Copyright 2016 Congduc Pham, University of Pau, France.\n# \n# Congduc.Pham@univ-pau.fr\n#\n# This file is part of the low-cost LoRa gateway developped at University ...
[ 0 ]
#!/usr/bin/python import os from base_exploit import * from reporter import * from netfw import * import sys class remote_shell(base_exploit): id = EXPLOIT_ID_REMOTE_SHELL def exploit(self, ip, port): # Create a connection to requested destination s = socket(AF_INET, SOCK_DGRAM) s.con...
normal
{ "blob_id": "f19e853af675c16dfbb911bf2b756de0f1e3f2f8", "index": 7189, "step-1": "#!/usr/bin/python\n\nimport os\nfrom base_exploit import *\nfrom reporter import *\nfrom netfw import *\nimport sys\n\nclass remote_shell(base_exploit):\n id = EXPLOIT_ID_REMOTE_SHELL\n\n def exploit(self, ip, port):\n ...
[ 0 ]
#!/usr/bin/python # Always prefer setuptools over distutils from setuptools import setup, find_packages setup( name="isc-dhcpd-parser", version="0.1", description="Parser for isc-dhcp config files (dhcpd.conf)", author="Pavel Podkorytov", author_email="pod.pavel@gmail.com", classifiers=[ ...
normal
{ "blob_id": "79141679bb2839de9d4a25b6c6c285905dddbb0d", "index": 6460, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='isc-dhcpd-parser', version='0.1', description=\n 'Parser for isc-dhcp config files (dhcpd.conf)', author=\n 'Pavel Podkorytov', author_email='pod.pavel@gmail.com', class...
[ 0, 1, 2, 3 ]
pokerAssignments = {'2': 20, '3': 30, '4': 40, '5': 50, '6': 60, '7': 70, '8': 80, '9': 90, 'T': 100, 'J': 110, 'Q': 120, 'K': 130, 'A': 140, 'C': 0, 'S': 1, 'H': 2, 'D': 3} #Used to assign each card to a unique three-digit integer configScoring = {(1, 1): 0, (1, 2): 1, (2, 2): 2, (1, 3): 3, (2, 3): 6, (1, 4): 7} #Tra...
normal
{ "blob_id": "a2a3e8d52fd467178460b178c5dbf9ccd72706e7", "index": 8251, "step-1": "<mask token>\n\n\ndef initialize():\n hands_file = open('euler54_poker.txt')\n hands_string = hands_file.read()\n tempList = []\n newString = hands_string.replace('\\n', ' ').replace(' ', '')\n for i in range(0, len(...
[ 6, 7, 8, 9, 10 ]
def simple_formatter(zipcode: str, address: str) ->str: return f'{zipcode}は「{address}」です'
normal
{ "blob_id": "b1dce573e6da81c688b338277af214838bbab9dd", "index": 8649, "step-1": "<mask token>\n", "step-2": "def simple_formatter(zipcode: str, address: str) ->str:\n return f'{zipcode}は「{address}」です'\n", "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0, 1 ] }
[ 0, 1 ]
# coding: utf-8 """ Idomoo API OpenAPI spec version: 2.0 Contact: dev.support@idomoo.com """ import pprint import six class GIFOutput(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ """ Attributes: ...
normal
{ "blob_id": "2362c9a12f97f32f6136aaf16a55cf4acbaf9294", "index": 4753, "step-1": "<mask token>\n\n\nclass GIFOutput(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, gif_fps=None, color_depth=None, gif_loop=None,\n height=None, start=None, duration=...
[ 27, 28, 29, 31, 33 ]
from django import forms class RemoveProdutoDoCarrinhoForm(forms.Form): class Meta: fields = ('produto_id') produto_id = forms.CharField(widget=forms.HiddenInput()) class QuantidadeForm(forms.Form): class Meta: fields = ('quantidade', 'produto_id') # <input type="hidden" name="produt...
normal
{ "blob_id": "fd5fca0e9abbb669ddff4d676147acc4344cdd1c", "index": 509, "step-1": "<mask token>\n\n\nclass QuantidadeForm(forms.Form):\n\n\n class Meta:\n fields = 'quantidade', 'produto_id'\n produto_id = forms.CharField(widget=forms.HiddenInput())\n quantidade = forms.IntegerField(min_value=1, ma...
[ 2, 3, 4, 5, 6 ]
#!usr/bin/python #--*--coding:utf-8--*-- import sys import re if __name__ == '__main__': category = re.compile('\[\[Category\:.*\]\]')#.は改行以外の任意の文字列にマッチ for line in open(sys.argv[1]): if category.search(line) is not None:#比較にはisを用いなければならない print line.strip()
normal
{ "blob_id": "14b6dc403be76abef5fde2cca5d773c88faa4b40", "index": 6083, "step-1": "#!usr/bin/python\n#--*--coding:utf-8--*--\n\nimport sys\nimport re\n\nif __name__ == '__main__':\n category = re.compile('\\[\\[Category\\:.*\\]\\]')#.は改行以外の任意の文字列にマッチ\n for line in open(sys.argv[1]):\n if category.search(li...
[ 0 ]
one=[7.236287049225701e-06, -1.445911565527231e-12, -1.7498772740084537e-13, 5.109944355076077e-11, -2.5430545472048434e-10, -1.1709514644876058e-15, 3.210132219509301e-16, 2.502027767038304e-05, -1.975229899156637e-06, -1.4769695480936238e-08, 8.945619840357268e-10, 135323228000.64511, 130464457208.5385] two=[6.101651...
normal
{ "blob_id": "bdf3cb1830021b10d6c8966b3341fd9297d9a371", "index": 2045, "step-1": "<mask token>\n", "step-2": "<mask token>\n[1.5780628845471506e-10, -1.411490597458207e-12, -2.483949940281473e-13, \n 5.026488748046414e-11, -1.6612576871621329e-10, -1.6989844545344268e-15,\n 8.109443782655016e-16, 2.40404...
[ 0, 1, 2, 3 ]
"""Command line interface to the OSF These functions implement the functionality of the command-line interface. """ from __future__ import print_function from functools import wraps import getpass import os import sys from six.moves import configparser from six.moves import input from tqdm import tqdm from .api im...
normal
{ "blob_id": "ca551d8e55ebb15a03077af5695782c6d72ff2fd", "index": 8091, "step-1": "<mask token>\n\n\ndef config_from_env(config):\n username = os.getenv('OSF_USERNAME')\n if username is not None:\n config['username'] = username\n project = os.getenv('OSF_PROJECT')\n if project is not None:\n ...
[ 7, 9, 10, 12, 13 ]
import csv import hashdate as hd with open('Grainger_Library.csv', newline='') as f: reader = csv.reader(f) data = list(reader) del data[0] gld = [] glo = [] data.sort(key=lambda x:x[1]) for i in range(0,len(data)): gld.append((data[i][1],data[i][2])) print('ahd:') #print(ahd) glh = hd.hashdate(365,2020...
normal
{ "blob_id": "79ff164c36cc5f0a2382a571ec183952a03e66cc", "index": 9570, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('Grainger_Library.csv', newline='') as f:\n reader = csv.reader(f)\n data = list(reader)\ndel data[0]\n<mask token>\ndata.sort(key=lambda x: x[1])\nfor i in range(0, len(d...
[ 0, 1, 2, 3, 4 ]
/home/co/Documents/ImageClassifier/tensorflow/tensorflow/contrib/tfprof/__init__.py
normal
{ "blob_id": "ca0616694b30f69263db48282bf8b8c130de0fbb", "index": 8774, "step-1": "/home/co/Documents/ImageClassifier/tensorflow/tensorflow/contrib/tfprof/__init__.py", "step-2": null, "step-3": null, "step-4": null, "step-5": null, "step-ids": [ 0 ] }
[ 0 ]
import pandas as pd # 칼럼값으로 추가 - 함수 작성 # 1. cv_diff_value : 종가 일간 변화량 def cv_diff_value(prevalue, postvalue): return postvalue - prevalue # 2. cv_diff_rate : 종가 일간 변화율 def cv_diff_rate(prevalue, postvalue): return (postvalue - prevalue) / prevalue * 100 # 3. cv_maN_value : 종가의 N일 이동평균 def cv_maN_value(cv, ...
normal
{ "blob_id": "a967b97f090a71f28e33c5ca54cb64db3967aea3", "index": 7002, "step-1": "<mask token>\n\n\ndef cv_diff_value(prevalue, postvalue):\n return postvalue - prevalue\n\n\ndef cv_diff_rate(prevalue, postvalue):\n return (postvalue - prevalue) / prevalue * 100\n\n\ndef cv_maN_value(cv, N):\n str_repla...
[ 5, 6, 7, 8, 9 ]
'''import math x = 5 print("sqrt of 5 is", math.sqrt(64)) str1 = "bollywood" str2 = 'ody' if str2 in str1: print("String found") else: print("String not found") print(10+20)''' #try: #block of code #except Exception l: #block of code #else: #this code executes if except block is executed try...
normal
{ "blob_id": "c5b40b373953a2375eeca453a65c49bdbb8715f1", "index": 6586, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n fh = open('testfile.txt', 'w')\n fh.write('This is my test file for exception handling! !')\nexcept IOError:\n print(\"Error: can't find file or read data\")\nelse:\n p...
[ 0, 1, 2 ]
from clients.models import Budget from clients.models import Spend from datetime import date as datetimedate from datetime import datetime from datetime import timedelta from django.db import models from rest_framework.exceptions import ParseError import math import pandas as pd class CampaignPerformance: """ Get...
normal
{ "blob_id": "a860e6670719a733e75c7580cf2e07765b0777eb", "index": 2806, "step-1": "<mask token>\n\n\nclass CampaignPerformance:\n <mask token>\n\n def __init__(self, campaign, start):\n self.campaign = campaign\n self.start = start\n self.BUDGETS_NAME = 'Budgets'\n self.required_...
[ 9, 12, 13, 15, 16 ]
from day6input import * groups = input.split('\n\n') count = 0 #1 groupanswers = [] #2 for group in groups: allananswers = set(list('abcdefghijklmnopqrstuvwxyz')) #2 answers = set() #1 people = group.split('\n') for person in people: allananswers = allananswers & set(list(person)) #2 ...
normal
{ "blob_id": "8f1ec65ca60605747f46f596e0b5848922bcd0b5", "index": 2127, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor group in groups:\n allananswers = set(list('abcdefghijklmnopqrstuvwxyz'))\n answers = set()\n people = group.split('\\n')\n for person in people:\n allananswers = a...
[ 0, 1, 2, 3, 4 ]
from xai.brain.wordbase.verbs._hinder import _HINDER #calss header class _HINDERED(_HINDER, ): def __init__(self,): _HINDER.__init__(self) self.name = "HINDERED" self.specie = 'verbs' self.basic = "hinder" self.jsondata = {}
normal
{ "blob_id": "420beba5b6fd575ab9be0c907ae0698ba7be5220", "index": 4622, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass _HINDERED(_HINDER):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass _HINDERED(_HINDER):\n\n def __init__(self):\n _HINDER.__init__(self)\n self.name ...
[ 0, 1, 2, 3, 4 ]
from django.db import models class faculdades(models.Model): codigo = models.IntegerField(primary_key = True) nome = models.CharField(max_length=50) cidade = models.CharField(max_length=30) estado = models.CharField(max_length=20) pais = models.CharField(max_length=20) def __str__(self): ...
normal
{ "blob_id": "20e5220ce23aaaedbfafe599b352f5d3a220e82e", "index": 6687, "step-1": "<mask token>\n\n\nclass cursos(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __str__(self):\n return self.nome\n\n\n class Meta:\n managed = False\n db_tab...
[ 11, 13, 14, 16, 17 ]
import time import click from contextlib import contextmanager from pathlib import Path from model.data import CellsDataset from model.model import build_model, train_transform, test_transform from model.vis import plot_cells @contextmanager def timer(name): t0 = time.time() yield print("{color}[{name}] d...
normal
{ "blob_id": "5cc325758d5bd99ebe49c40af4d2e339bbf64044", "index": 7508, "step-1": "<mask token>\n\n\n@contextmanager\ndef timer(name):\n t0 = time.time()\n yield\n print('{color}[{name}] done in {et:.0f} s{nocolor}'.format(name=name,\n et=time.time() - t0, color='\\x1b[1;33m', nocolor='\\x1b[0m'))...
[ 2, 4, 5, 6, 7 ]
from django.contrib import admin from django.urls import path from . import views urlpatterns = [ path('', views.skincare, name="skin"), path('productSearch/', views.productSearch, name="productSearch"), path('detail/', views.detail, name="detail"), ]
normal
{ "blob_id": "c31c59d172b2b23ca4676be0690603f33b56f557", "index": 4867, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.skincare, name='skin'), path('productSearch/',\n views.productSearch, name='productSearch'), path('detail/', views.\n detail, name='detail')]\n", "st...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- """ MQTT handler for Event subscriptions. """ import json import time import tornado.gen import tornado.ioloop from hbmqtt.mqtt.constants import QOS_0 from tornado.queues import QueueFull from wotpy.protocols.mqtt.handlers.base import BaseMQTTHandler from wotpy.protocol...
normal
{ "blob_id": "b3f72bc12f85724ddcdaf1c151fd2a68b29432e8", "index": 6545, "step-1": "<mask token>\n\n\nclass EventMQTTHandler(BaseMQTTHandler):\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, mqtt_server, qos=QOS_0, callback_ms=None):\n super(EventMQTTHandler, self).__init__(m...
[ 6, 7, 8, 9, 10 ]
from django.conf.urls import url from django.urls import path from . import views app_name = 'Accounts' urlpatterns = [ path('update_info', views.update_info, name='update_info'), path('create_user', views.create_user, name='create_user'), path('change_password', views.change_password, name='change_passwo...
normal
{ "blob_id": "bfb778a2ecf43a697bc0e3449e9302142b20e1f4", "index": 4278, "step-1": "<mask token>\n", "step-2": "<mask token>\napp_name = 'Accounts'\nurlpatterns = [path('update_info', views.update_info, name='update_info'),\n path('create_user', views.create_user, name='create_user'), path(\n 'change_passw...
[ 0, 1, 2, 3 ]
import pygame import random from pygame.locals import * import pygame from pygame.locals import * class GameObject(pygame.sprite.Sprite): SIZE = 8 def __init__(self, x, y, surface): super(GameObject, self).__init__() self.x = x self.y = y self.surface = surface ...
normal
{ "blob_id": "c589ce4ba2ae60d14787a8939146f6140fff1f01", "index": 7914, "step-1": "<mask token>\n\n\nclass GameObject(pygame.sprite.Sprite):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass Food(gameobject.GameObject):\n\n def __init__(self, x, y, surface, ti...
[ 5, 7, 8, 10, 11 ]
import tkinter as tk # Import tkinker for GUI creation from PIL import Image, ImageTk # Allow images to be used as backgrounds import socket # Importing sockets for low level implementation of networks import select # Importing select to poll between the user input and received message import sys # Getting inp...
normal
{ "blob_id": "5e17299e6a409e433e384935a815bab6ce178ff5", "index": 3031, "step-1": "<mask token>\n\n\ndef sigint_handler(signum, frame):\n print('\\n Disconnecting from server')\n sys.exit()\n\n\n<mask token>\n\n\ndef sendUsernameToServer(username_entry):\n username = username_entry.encode('utf-8')\n u...
[ 4, 5, 6, 7, 9 ]
import requests import unittest import time from common import HTMLTestReport class Get(unittest.TestCase): TMPTOKEN = '' TOKEN = '' def setUp(self): pass # 获取临时token,opterTmpToken def test_gettmptoken(self): url = 'https://jdapi.jd100.com/uc/core/v1/sys/opterTmpToken' par...
normal
{ "blob_id": "773c217f7f76bd82ed3dabf7ae1aba1871f0932f", "index": 8539, "step-1": "<mask token>\n\n\nclass Get(unittest.TestCase):\n <mask token>\n <mask token>\n\n def setUp(self):\n pass\n <mask token>\n\n def test_gettoken(self):\n url = 'https://jdapi.jd100.com/uc/v1/sys/opterToke...
[ 6, 7, 8, 11, 12 ]
""" Classes and functions for generalized q-sampling """ import numpy as np from dipy.reconst.odf import OdfModel, OdfFit, gfa from dipy.reconst.cache import Cache import warnings from dipy.reconst.multi_voxel import multi_voxel_fit from dipy.reconst.recspeed import local_maxima, remove_similar_vertices class General...
normal
{ "blob_id": "2f193cb1eaf7b5e99d20025716a248144af90b92", "index": 1925, "step-1": "<mask token>\n\n\nclass GeneralizedQSamplingModel(OdfModel, Cache):\n\n def __init__(self, gtab, method='gqi2', sampling_length=1.2,\n normalize_peaks=False):\n \"\"\" Generalized Q-Sampling Imaging [1]_\n\n ...
[ 14, 16, 17, 19, 20 ]
# -*- coding: utf-8 -*- import os from apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore class Config: SECRET_KEY = os.environ.get('SECRET_KEY') # github GITHUB_OAUTH2 = { #github上获取 'client_id': '', 'client_secret': '', 'callback_url': '', 'scope': 'user'...
normal
{ "blob_id": "af7a124c873dda02ba2a78e85965aa243d791863", "index": 3432, "step-1": "# -*- coding: utf-8 -*-\nimport os\nfrom apscheduler.jobstores.sqlalchemy import SQLAlchemyJobStore\n\n\nclass Config:\n SECRET_KEY = os.environ.get('SECRET_KEY')\n # github\n GITHUB_OAUTH2 = {\n #github上获取\n ...
[ 0 ]
from functools import partial def power_func(x, y, a=1, b=0): return a * x ** y + b new_func = partial(power_func, 2, a=4) print(new_func(4, b=1)) print(new_func(1))
normal
{ "blob_id": "c9f1768e2f2dd47d637c2e577067eb6cd163e972", "index": 8331, "step-1": "<mask token>\n\n\ndef power_func(x, y, a=1, b=0):\n return a * x ** y + b\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef power_func(x, y, a=1, b=0):\n return a * x ** y + b\n\n\n<mask token>\nprint(new_func(4, b=1))...
[ 1, 2, 3, 4 ]
import xarray as xr import pandas as pd import numpy as np import matplotlib.pyplot as plt import pickle import seaborn as sns %load_ext autoreload %autoreload 2 %matplotlib data_dir = Path('/Volumes/Lees_Extend/data/ecmwf_sowc/data/') # READ in model (maybe want to do more predictions on historical data) from src.m...
normal
{ "blob_id": "d265781c6b618752a1afcf65ac137052c26388a6", "index": 985, "step-1": "import xarray as xr\nimport pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport pickle\nimport seaborn as sns\n\n%load_ext autoreload\n%autoreload 2\n%matplotlib\n\ndata_dir = Path('/Volumes/Lees_Extend/data/ec...
[ 0 ]
from flask import Flask, Blueprint, render_template, request, redirect from repositories import manufacturer_repository, product_repository from models.manufacturer import Manufacturer from models.product import Product manufacturers_blueprint = Blueprint("manufacturers", __name__) @manufacturers_blueprint.route("/ma...
normal
{ "blob_id": "841e859feff2151667d70e7bf1829129d1f92cf7", "index": 9889, "step-1": "<mask token>\n\n\n@manufacturers_blueprint.route('/manufacturers', methods=['GET'])\ndef manufacturers():\n manufacturers = manufacturer_repository.select_all()\n return render_template('manufacturers/index.html', manufacture...
[ 5, 6, 7, 9, 10 ]
# -*- coding: utf-8 -*- import os import subprocess import virtualenv from templateserver import __version__ as version DEFAULT_TEMPLATE_DIR = 'templates' DEFAULT_MEDIA_DIR = 'media' DEFAULT_STATIC_DIR = 'static' DEFAULT_ENV_DIR = '.env' DEFAULT_RUNSERVER_PATH = 'runserver.py' RUNSERVER_TEMPLATE = os.path.abspath(os...
normal
{ "blob_id": "3f41cb1acbbb1a397ae1288bca1cbcd27c0d3f33", "index": 5143, "step-1": "# -*- coding: utf-8 -*-\nimport os\nimport subprocess\nimport virtualenv\nfrom templateserver import __version__ as version\n\n\nDEFAULT_TEMPLATE_DIR = 'templates'\nDEFAULT_MEDIA_DIR = 'media'\nDEFAULT_STATIC_DIR = 'static'\nDEFAUL...
[ 0 ]
def search4vowels(word): """ Return sny vowels founded in a supplied word.""" vowels = set('aeiou') found = vowels.intersection(set(word)) #return found for vowels in found: print(vowels)
normal
{ "blob_id": "8a21a7005fb17cc82759079022b540cf4fd062c5", "index": 3458, "step-1": "<mask token>\n", "step-2": "def search4vowels(word):\n \"\"\" Return sny vowels founded in a supplied word.\"\"\"\n vowels = set('aeiou')\n found = vowels.intersection(set(word))\n for vowels in found:\n print...
[ 0, 1, 2 ]
from django.shortcuts import render_to_response, get_object_or_404 from django.http import HttpResponseNotFound from django.template import RequestContext from bgame.models import Game, Period, Player, ROLES from bgame.forms import GameForm import logging log = logging.getLogger(__name__) def index(request): games...
normal
{ "blob_id": "6c825cb60475a1570e048cab101567bd5847d2c2", "index": 5113, "step-1": "from django.shortcuts import render_to_response, get_object_or_404\nfrom django.http import HttpResponseNotFound\nfrom django.template import RequestContext\nfrom bgame.models import Game, Period, Player, ROLES\nfrom bgame.forms im...
[ 0 ]
#-*- coding: utf-8 -*- from __future__ import unicode_literals from django.core.files import File as DjangoFile from django.core.management.base import BaseCommand, NoArgsCommand from filer.models.filemodels import File from leonardo.module.media.models import * from filer.settings import FILER_IS_PUBLIC_DEFAULT from ...
normal
{ "blob_id": "864e9063ec1ed80cd1da3128a38633cbeb2f8bba", "index": 3775, "step-1": "<mask token>\n\n\nclass Command(NoArgsCommand):\n \"\"\"\n Import directory structure into the filer ::\n\n manage.py --path=/tmp/assets/images\n manage.py --path=/tmp/assets/news --folder=images\n \"\"\"\n ...
[ 4, 6, 9, 11, 12 ]
import json import urllib while True: # Get input URL url = raw_input("Enter URL: ") # Check valid input if len(url) < 1: break # Get data print("Retrieving", url) connection = urllib.urlopen(url) data = connection.read() print("Retrieved", len(data), "characters") # P...
normal
{ "blob_id": "4cdd5fc15096aac01ad6d97d38ef7397859de18b", "index": 5470, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile True:\n url = raw_input('Enter URL: ')\n if len(url) < 1:\n break\n print('Retrieving', url)\n connection = urllib.urlopen(url)\n data = connection.read()\n ...
[ 0, 1, 2, 3 ]
from setuptools import setup, find_packages from setuptools.extension import Extension from sys import platform cython = True try: from Cython.Build import cythonize cython = True except ImportError: cython = False # Define the C++ extension if platform == "darwin": extra_compile_args = ['-O3', '-pthread',...
normal
{ "blob_id": "312cc666c88fcd22882c49598db8c5e18bd3dae1", "index": 26, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n from Cython.Build import cythonize\n cython = True\nexcept ImportError:\n cython = False\nif platform == 'darwin':\n extra_compile_args = ['-O3', '-pthread', '-funroll-lo...
[ 0, 1, 2, 3, 4 ]
pal = [] for i in range(100, 1000): for j in range(100, 1000): s = str(i * j) if s[::-1] == s: pal.append(int(s)) print(max(pal))
normal
{ "blob_id": "179a9cf0713001e361f39aa30192618b392c78c7", "index": 6972, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(100, 1000):\n for j in range(100, 1000):\n s = str(i * j)\n if s[::-1] == s:\n pal.append(int(s))\nprint(max(pal))\n", "step-3": "pal = []\nfo...
[ 0, 1, 2 ]
from collections import defaultdict class Solution: def multiply(self, A: List[List[int]], B: List[List[int]]) -> List[List[int]]: output = [[0 for j in range(len(B[0]))] for i in range(len(A))] rows = defaultdict(list) cols = defaultdict(list) for i in ran...
normal
{ "blob_id": "8425ee79fcb41799e5edbbab822f93dd40e39d8e", "index": 6481, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Solution:\n\n def multiply(self, A: List[List[int]], B: List[List[int]]) ->List[List[int]\n ]:\n ...
[ 0, 1, 2, 3, 4 ]
dic = {"city": "Moscow", "temperature": 20} # print(dic["city"]) # dic["temperature"] -= 5 # print(dic) print(dic.get("country", "Russia")) dic["date"] = "27.05.2019" print(dic)
normal
{ "blob_id": "f145274c8caa1e725d12003874eb54a580a6e35e", "index": 784, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(dic.get('country', 'Russia'))\n<mask token>\nprint(dic)\n", "step-3": "dic = {'city': 'Moscow', 'temperature': 20}\nprint(dic.get('country', 'Russia'))\ndic['date'] = '27.05.2019'\...
[ 0, 1, 2, 3 ]
# Exercise 1 - linear.py import numpy as np import keras # Build the model model = keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])]) # Set the loss and optimizer function model.compile(optimizer='sgd', loss='mean_squared_error') # Initialize input data xs = np.array([-1.0, 0.0, 1.0, 2.0, 3.0, 4.0], dtype=...
normal
{ "blob_id": "c8fecb6bfbd39e7a82294c9e0f9e5eaf659b7fed", "index": 1610, "step-1": "<mask token>\n", "step-2": "<mask token>\nmodel.compile(optimizer='sgd', loss='mean_squared_error')\n<mask token>\nmodel.fit(xs, ys, epochs=500)\n<mask token>\nprint(model.predict(dataIn, 1, 1))\n", "step-3": "<mask token>\nmod...
[ 0, 1, 2, 3, 4 ]
import os from MdApi import MdApi class Adapter(MdApi): def __init__(self): super(Adapter, self).__init__() def connect(self): self.createFtdcMdApi(os.getcwd()) self.registerFront('tcp://180.168.146.187:10010') def onFrontConnected(self): print 'front succ...
normal
{ "blob_id": "0e58834120c34b5152026bde6d089be19244e21a", "index": 269, "step-1": "import os\n\nfrom MdApi import MdApi\n\nclass Adapter(MdApi):\n\n def __init__(self):\n \n super(Adapter, self).__init__()\n\n\n def connect(self):\n\n\n self.createFtdcMdApi(os.getcwd())\n\n self.r...
[ 0 ]
"""Tests for flatten_me.flatten_me.""" import pytest ASSERTIONS = [ [[1, [2, 3], 4], [1, 2, 3, 4]], [[['a', 'b'], 'c', ['d']], ['a', 'b', 'c', 'd']], [['!', '?'], ['!', '?']], [[[True, False], ['!'], ['?'], [71, '@']], [True, False, '!', '?', 71, '@']] ] @pytest.mark.parametrize("n, result", ASSERTI...
normal
{ "blob_id": "c233ce4e14e9a59a9fb0f29589ced947efeb73a9", "index": 3120, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@pytest.mark.parametrize('n, result', ASSERTIONS)\ndef test_flatten_me(n, result):\n \"\"\"Test flatten_me() for proper output in test cases.\"\"\"\n from flatten_me import flat...
[ 0, 1, 2, 3, 4 ]
# (c) Copyright 2015-2016 Hewlett Packard Enterprise Development LP # (c) Copyright 2017 SUSE LLC import json from bll.plugins import service import logging import pecan import pymysql.cursors LOG = logging.getLogger(__name__) class PreferencesSvc(service.SvcBase): """ Simple service to manage user preferenc...
normal
{ "blob_id": "fb787e688da975d37f9fcc39bf5e02957b186982", "index": 7512, "step-1": "<mask token>\n\n\nclass PreferencesSvc(service.SvcBase):\n <mask token>\n\n def __init__(self, *args, **kwargs):\n super(PreferencesSvc, self).__init__(*args, **kwargs)\n config = pecan.conf.db.to_dict()\n ...
[ 8, 10, 11, 13, 14 ]
from api import * version_api = api(0) def is_bad_version(v): return version_api.is_bad(v) def first_bad_version(n): # -- DO NOT CHANGE THIS SECTION version_api.n = n # -- api_calls_count = 0 left, right = 1, n while left < right: mid = (left + right) // 2 is_bad = is_bad_versio...
normal
{ "blob_id": "df4c03d9faedf2d347593825c7221937a75a9c10", "index": 5360, "step-1": "<mask token>\n\n\ndef is_bad_version(v):\n return version_api.is_bad(v)\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\ndef is_bad_version(v):\n return version_api.is_bad(v)\n\n\ndef first_bad_version(n):\n version_ap...
[ 1, 2, 3, 4, 5 ]
import random # Imports MongoClient for base level access to the local MongoDB from pymongo import MongoClient # Imports datetime class to create timestamp for weather data storage from datetime import datetime # Importing DailyReportModel class to use the implemented method to insert data into daily_report_model ...
normal
{ "blob_id": "a8b1b218e6649545000803c91c803580cfdbd4f1", "index": 459, "step-1": "<mask token>\n", "step-2": "<mask token>\ndb_handle.drop_database(DB_NAME)\n<mask token>\nwith open(RELATIVE_CONFIG_PATH + USER_COLLECTION + '.csv', 'r') as user_fh:\n for user_row in user_fh:\n user_row = user_row.rstri...
[ 0, 1, 2, 3, 4 ]
from setuptools import setup setup(name='google-drive-helpers', version='0.1', description='Helper functions for google drive', url='https://github.com/jdoepfert/google-drive-helpers', license='MIT', packages=['gdrive_helpers'], install_requires=[ 'google-api-python-client...
normal
{ "blob_id": "c0218acadb9e03359ac898cf3bb4898f516400e5", "index": 5361, "step-1": "<mask token>\n", "step-2": "<mask token>\nsetup(name='google-drive-helpers', version='0.1', description=\n 'Helper functions for google drive', url=\n 'https://github.com/jdoepfert/google-drive-helpers', license='MIT',\n ...
[ 0, 1, 2, 3 ]
""" GetState Usage: get_state.py <pem-file> <ip-file> [options] Options: -h, --help print help message and exit --output DIR set the output directory [default: logs] """ from docopt import docopt import paramiko import os def get_logs(ip_addr, pem_file, log_dir): pem = paramiko.RSAKey...
normal
{ "blob_id": "a1df804325a074ed980ec864c72fe231e2968997", "index": 4024, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_logs(ip_addr, pem_file, log_dir):\n pem = paramiko.RSAKey.from_private_key_file(pem_file)\n client = paramiko.SSHClient()\n client.set_missing_host_key_policy(paramik...
[ 0, 1, 2, 3, 4 ]
from . import utility from . import regular_gram_schmidt as RGSC from . import custom_gram_schmidt as CGSC def RegularGramSchmidt(): while True: vectors = utility.get_matrix_from_user(5) if len(vectors) > 0: calc = RGSC.RegularGramSchmidt() result_matrix = calc.calc(vectors...
normal
{ "blob_id": "b6b3d94db62b47aac9bf78e8224a38ccff9335e3", "index": 7591, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef RegularGramSchmidt():\n while True:\n vectors = utility.get_matrix_from_user(5)\n if len(vectors) > 0:\n calc = RGSC.RegularGramSchmidt()\n ...
[ 0, 1, 2, 3, 4 ]
import strawberry as stb from app.crud import cruduser from app.db import get_session @stb.type class Query: @stb.field async def ReadUser(self, info, username: str): ses = await get_session() fields = info.field_nodes[0].selection_set.selections[0] return await cruduser.get_user(ses,...
normal
{ "blob_id": "0992297ffc19b1bc4dc3d5e8a75307009c837032", "index": 5134, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@stb.type\nclass Query:\n\n @stb.field\n async def ReadUser(self, info, username: str):\n ses = await get_session()\n fields = info.field_nodes[0].selection_set.se...
[ 0, 1, 2 ]
import json startTime = "" endTime = "" controller = 0 for files in range(30): file = open("NewResults" + str(files+1) + ".data") for line in file: if line != "\n": j = json.loads(line) if controller == 0: startTime = j['metrics'][0]['startTime'] helper = startTime.split(" ") hour = helper[1].sp...
normal
{ "blob_id": "03284f20e614a5f8f5c21939acf49490d6ffd3a3", "index": 7812, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor files in range(30):\n file = open('NewResults' + str(files + 1) + '.data')\n for line in file:\n if line != '\\n':\n j = json.loads(line)\n if contr...
[ 0, 1, 2, 3, 4 ]
#!/usr/bin/env python3 # Rhino Motor Driver (RMCS 2303) - Basic Modbus Communication # ----------------------------------------------------------- """ BSD 3-Clause License Copyright (c) 2021, Rajesh Subramanian All rights reserved. Redistribution and use in source and binary forms, with or without ...
normal
{ "blob_id": "df3dcbf3c8d621f5db2a07765a0a28e7626387d9", "index": 3485, "step-1": "<mask token>\n\n\nclass Controller:\n\n def __init__(self, port_name, slave_address):\n self.__instrument = modbus.Instrument(port_name, slave_address,\n modbus.MODE_ASCII)\n self.__instrument.serial.bau...
[ 16, 19, 24, 27, 29 ]
from django.apps import AppConfig class EasyTechConfig(AppConfig): name = 'easy_tech'
normal
{ "blob_id": "0ef172ced411213c0f7daccd632f8d5ec97379c3", "index": 5604, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass EasyTechConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass EasyTechConfig(AppConfig):\n name = 'easy_tech'\n", "step-4": "from django.apps import...
[ 0, 1, 2, 3 ]
# Import other modules from zelda_utilities.constants import * # Helps establish the current frame for sprite animation/image changing class Animation: def __init__(self): # Animation clock self.next_frame = pygame.time.get_ticks() # Starting frame self.frame = 0 # ~12 fr...
normal
{ "blob_id": "0b36bf9ac7887101be5503a0edce19e1111e5ca0", "index": 6607, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Animation:\n\n def __init__(self):\n self.next_frame = pygame.time.get_ticks()\n self.frame = 0\n self.frame_time = 1000 // ANIMATION_RATE\n <mask tok...
[ 0, 2, 3, 4, 5 ]
import time import datetime from pushover import init, Client from scraper import * from config import * # Get the current time timeNow = time.strftime("%a %b %d, %I:%M %p").lstrip("0").replace(" 0", " ") # Initialise Pushover for notifications client = Client(user_key, api_token=api_token) # Loop for times of ISS ...
normal
{ "blob_id": "a573c6870392024ec2e84571ccb0bad3f5c4033a", "index": 4261, "step-1": "<mask token>\n\n\ndef issCheck():\n for i in column.keys():\n for x in column[i]:\n if i == 'Date':\n issNow = x\n if issNow == timeNow:\n client.send_message('I...
[ 1, 2, 3, 4, 5 ]
#Bingo Game #Anthony Swift #06/05/2019 ''' A simple bingo game. Player is presented with a randomly generated grid of numbers. Player is asked to enter the number called out by the caller, each time a number is called out. A chip ('X') is placed on the grid when the number entered (that has been called) match...
normal
{ "blob_id": "7be62ce45f815c4f4cf32df696cc444f92ac6d5c", "index": 8901, "step-1": "<mask token>\n\n\ndef welcome():\n print('\\nWelcome to the Bingo Game.')\n\n\ndef initialise_grid():\n grid = [['', '', '', '', ''], ['', '', '', '', ''], ['', '', '', '', ''\n ], ['', '', '', '', ''], ['', '', '', ''...
[ 14, 15, 16, 17, 18 ]
import json def main(): with open('./src/test/predictions.json', 'r') as f: data = json.load(f) total = len(data['label']) google = 0 sphinx = 0 for i in range(len(data['label'])): label = data['label'][i] google_entry = data['google'][i] sphinx_entry = data['p...
normal
{ "blob_id": "9fc184fe3aa498138138403bef719c59b85b3a80", "index": 4392, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n with open('./src/test/predictions.json', 'r') as f:\n data = json.load(f)\n total = len(data['label'])\n google = 0\n sphinx = 0\n for i in range(l...
[ 0, 1, 2, 3, 4 ]
import unittest import brainfuck import sys from StringIO import StringIO def run_program(program, input = None): old_stdout = sys.stdout old_stdin = sys.stdin try: out = StringIO() sys.stdout = out if input is not None: input = StringIO(input) sys.stdin = ...
normal
{ "blob_id": "19ab44cec863560513aadd88b5fd4bb40f75e371", "index": 2579, "step-1": "<mask token>\n\n\nclass TestInterpreter(unittest.TestCase):\n <mask token>\n\n def test_HelloWorld(self):\n result = run_program(\n \"\"\"\n ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>...
[ 4, 6, 7, 9, 10 ]
# -*- coding: utf-8 -*- __author__ = 'jz' from flask.ext import restful from flask.ext.restful import reqparse from scs_app.db_connect import * parser = reqparse.RequestParser() parser.add_argument('count', type=str) class MulActionResource(restful.Resource): def __init__(self): self.db =...
normal
{ "blob_id": "44476a32b8ab68820d73955321e57b7d1b608beb", "index": 6823, "step-1": "<mask token>\n\n\nclass MulActionResource(restful.Resource):\n\n def __init__(self):\n self.db = get_connection()\n\n def post(self, type):\n args = parser.parse_args()\n count = args.get('count')\n ...
[ 3, 4, 5, 6, 7 ]
# -*- coding:utf-8 -*- import os import numpy as np import tensorflow as tf from translate import datautil import seq2seq_model _buckets = [] convo_hist_limit = 1 max_source_length = 1 max_target_length = 2 flags = tf.app.flags FLAGS = flags.FLAGS tf.reset_default_graph max_train_data_size = 0 data_dir = 'datacn...
normal
{ "blob_id": "b7007778ea9dfac3af8c31d66d32d8157dc0d69b", "index": 1517, "step-1": "<mask token>\n\n\ndef getfanyiInfo():\n vocaben, rev_vocaben = datautil.initialize_vocabulary(os.path.join(\n datautil.data_dir, datautil.vocabulary_fileen))\n vocab_sizeen = len(vocaben)\n vocabch, rev_vocabch = da...
[ 2, 4, 5, 6, 7 ]
def tort(n, a, b): return min(n * a, b) def main(): n, a, b = map(int, input().split()) print(tort(n, a, b)) if __name__ == '__main__': main()
normal
{ "blob_id": "7c06bd52c924d3e401f50625109c5b8b489df157", "index": 7434, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef main():\n n, a, b = map(int, input().split())\n print(tort(n, a, b))\n\n\n<mask token>\n", "step-3": "def tort(n, a, b):\n return min(n * a, b)\n\n\ndef main():\n n,...
[ 0, 1, 2, 3 ]
import cv2 import dlib import faceBlendCommon as face from matplotlib import pyplot as plt from scipy.spatial import distance as dist import numpy as np import cmapy import math def eye_aspect_ratio(eye): A = dist.euclidean(eye[1], eye[5]) B = dist.euclidean(eye[2], eye[4]) C = dist.euclidean(eye[0], eye[...
normal
{ "blob_id": "65ff3b5137c94890c3293a2ae3f57dee1f60a54c", "index": 9097, "step-1": "<mask token>\n\n\ndef findIris(eyeMask, im, thresh):\n r = im[:, :, 2]\n _, binaryIm = cv2.threshold(r, thresh, 255, cv2.THRESH_BINARY_INV)\n kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (4, 4))\n morph = cv2.d...
[ 3, 6, 8, 10, 11 ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.3 on 2017-03-09 14:28 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('proposal', '0016_project_callobjectives'), ] operations = [ migrations.Alte...
normal
{ "blob_id": "d5c7b8966e73c607d1d1c5da9814ef507dc53b59", "index": 6852, "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 = [('proposal', ...
[ 0, 1, 2, 3, 4 ]
from django.shortcuts import render from django.views.generic import TemplateView from django.conf import settings import os, csv class InflationView(TemplateView): template_name = 'inflation.html' def get(self, request, *args, **kwargs): # чтение csv-файла и заполнение контекста context = {}...
normal
{ "blob_id": "6645887b25d75f4657fb231b80d8ebdec2bac7c9", "index": 8718, "step-1": "<mask token>\n\n\nclass InflationView(TemplateView):\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass InflationView(TemplateView):\n <mask token>\n\n def get(self, request, *args, **kwargs):\n ...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' Frame filtering ''' import numpy as np import cv2 def filter_frames(frames, method=cv2.HISTCMP_CORREL, target_size=(64, 64), threshold=0.65): """Filter noisy frames out Args: frames (list<numpy.ndarray[H, W, 3]>): video frames method (int, o...
normal
{ "blob_id": "1da93e9113089f1a2881d4094180ba524d0d4a86", "index": 8531, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef filter_frames(frames, method=cv2.HISTCMP_CORREL, target_size=(64, 64),\n threshold=0.65):\n \"\"\"Filter noisy frames out\n\n Args:\n frames (list<numpy.ndarray[H,...
[ 0, 1, 2, 3 ]
# -*- coding:utf-8 -*- # class TreeLinkNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None # self.next = None class Solution: """ 给定一个二叉树和其中的一个结点,请找出中序遍历顺序的下一个结点并且返回。 注意,树中的结点不仅包含左右子结点,同时包含指向父结点的指针。 """ def GetNext(self, pNode): ...
normal
{ "blob_id": "57f8584a8d058e5f9d4e0b7b75c7ec8dbbfef24a", "index": 9681, "step-1": "<mask token>\n", "step-2": "class Solution:\n <mask token>\n <mask token>\n", "step-3": "class Solution:\n <mask token>\n\n def GetNext(self, pNode):\n\n def left_most(p):\n if p == None:\n ...
[ 0, 1, 2, 3, 4 ]
""" 实战练习: 1.打开网页 https://www.runoob.com/try/try.php?filename=jqueryui-api-droppable 2.操作窗口右侧页面,将元素1拖拽到元素2 3.这时候会有一个alert弹框,点击弹框中的‘确定’ 3.然后再按’点击运行’ 4.关闭网页 """ import pytest from selenium import webdriver from time import sleep from selenium.webdriver import ActionChains class TestFrame: def setup(self): self...
normal
{ "blob_id": "74843dea00a88513c3a9237eb024e1e14e8b1ff8", "index": 3088, "step-1": "<mask token>\n\n\nclass TestFrame:\n <mask token>\n\n def teardown(self):\n self.driver.quit()\n\n def test_frame(self):\n self.driver.switch_to.frame('iframeResult')\n action = ActionChains(self.drive...
[ 3, 4, 5, 6, 7 ]
"""Functional tests for h2 frames.""" __author__ = "Tempesta Technologies, Inc." __copyright__ = "Copyright (C) 2023 Tempesta Technologies, Inc." __license__ = "GPL2" from h2.errors import ErrorCodes from h2.exceptions import StreamClosedError from framework import deproxy_client, tester from helpers import checks_f...
normal
{ "blob_id": "e474cb3db74b5344bd861aacf779cb9f77830ef6", "index": 5661, "step-1": "<mask token>\n\n\nclass TestH2FrameEnabledDisabledTsoGroGso(\n TestH2FrameEnabledDisabledTsoGroGsoBase, NetWorker):\n\n def test_headers_frame_with_continuation(self):\n client, server = self.setup_tests()\n sel...
[ 27, 33, 37, 46, 48 ]
import os from matplotlib import pyplot as plt from matplotlib import colors import numpy as np class figure: def __init__(self, dire, dpi, span, data, CIM, learn_loss=None, eval_loss=None, different_dir_app=True, reference_steps=0, reveal_trend=1): self.dire = self.new_num_directory(di...
normal
{ "blob_id": "dce6ef64cf1a758ed25e11f626ce31206d18f960", "index": 8645, "step-1": "<mask token>\n\n\nclass figure:\n <mask token>\n\n def new_num_directory(self, path):\n n = 1\n while True:\n if not os.path.exists(path + '_' + str(n)):\n os.mkdir(path + '_' + str(n))...
[ 4, 11, 12, 13, 14 ]
# My Godzilla Hat Code - @alt_bier from adafruit_circuitplayground.express import cpx import random #cpx.pixels.brightness = 0.5 # 50 pct cpx.pixels.fill((0, 0, 0)) # Turn off the NeoPixels if they're on! # Function to give us a nice color swirl on the built in NeoPixel (R,G,B) def wheeln(pos, sft): if (pos + sf...
normal
{ "blob_id": "1dd223854c10e69a397098511eab50b9ebd347c8", "index": 6027, "step-1": "<mask token>\n\n\ndef wheeln(pos, sft):\n if pos + sft > 255:\n pos = pos + sft - 256\n else:\n pos = pos + sft\n if pos < 0 or pos > 255:\n return 0, 0, 0\n if pos < 85:\n return int(255 - p...
[ 4, 5, 6, 7, 8 ]
# Generated by Django 3.2.8 on 2021-10-20 08:25 from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('app', '0006_auto_20211020_0817'), ] operations = [ migrations.AlterModelOptions( name='currencies', options={'verbose_name':...
normal
{ "blob_id": "a6cc0078fb37f9c63e119046193f521290c9fb21", "index": 4634, "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 = [('app', '0006...
[ 0, 1, 2, 3, 4 ]
# Generated by Django 2.1.3 on 2019-01-02 12:08 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('leasing', '0037_make_lease_basis_of_rent_archivable'), ] operations = [ migrations.AddField( model_name='invoicepayment', ...
normal
{ "blob_id": "8cd290dc1e682222c97172a0f23e5b93c54838a7", "index": 2201, "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 = [('leasing', '...
[ 0, 1, 2, 3, 4 ]
from StockDatabase import StockDatabase from RNNinner import RecurrentAnalyzer import torch import matplotlib.pyplot as plt import numpy as np database = StockDatabase() database.read_data() prices = torch.tensor(database.normalize(database.get_stock_prices('AAPL', length=2000))) print(prices.shape) model = Recurre...
normal
{ "blob_id": "8abfb6a9ca3a7a909a1e8125e8c03e29b2bacda8", "index": 109, "step-1": "<mask token>\n", "step-2": "<mask token>\ndatabase.read_data()\n<mask token>\nprint(prices.shape)\n<mask token>\nmodel.load_state_dict(torch.load('rnn_inner'))\nmodel.init_hidden()\nmodel.eval()\nwith torch.no_grad():\n preds =...
[ 0, 1, 2, 3 ]
import random import tqdm from keras.models import load_model from ModelUtil import precision, recall, f1 from tqdm import tqdm import cv2 as cv import numpy as np import os import pandas as pd from PIL import Image os.environ['CUDA_VISIBLE_DEVICES']='1' model_path = '/home/bo/Project/densenet.hdf5' train_img_path...
normal
{ "blob_id": "c2b3594d25e2d1670d9b99e0d3484c680f59421f", "index": 9465, "step-1": "<mask token>\n\n\ndef preprocess_image(image_path, desired_size=SIZE):\n \"\"\"\n Resize the picture to the desired size\n :param image_path: the path of image folder\n :param desired_size: the size that image will be c...
[ 9, 10, 12, 13, 14 ]
#!/usr/bin/python """ An extensible private pypi index. NOTES ON PACKAGE NAMES ---------------------- MPyPi tries the following when it does not find a package with the given name in the index: - replaces all _ with - and - lowercases the package name """ from __future__ import print_function from __future__ ...
normal
{ "blob_id": "bd25b97de78f04510e43f13d356eb6c0025e223d", "index": 8121, "step-1": "<mask token>\n\n\ndef canonicalize_name(name):\n return _canonicalize_regex.sub('-', name).lower()\n\n\ndef page_index(packages):\n yield PAGE_FMT\n for p in packages:\n name = p.name\n url = name\n yi...
[ 5, 6, 7, 8, 10 ]
from elements import Node, Bar, Material, Group, Load from pprint import pprint # query # next((e for e in result['coordinates']['nodes'] if e.n == int(el[0])), None) class Reader(): def read(self, filePath): """ Reads text file with nodes and returns the result dict with all objects and their nested p...
normal
{ "blob_id": "c796123fbbf3adcde59779a104dcafb30a673a79", "index": 6422, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Reader:\n <mask token>\n", "step-3": "<mask token>\n\n\nclass Reader:\n\n def read(self, filePath):\n \"\"\"\n Reads text file with nodes and returns the resul...
[ 0, 1, 2, 3, 4 ]
# -*- coding: utf-8 -*- import os from flask import Flask, request,render_template,url_for from flask_uploads import UploadSet, configure_uploads, IMAGES, patch_request_class import sys sys.path.insert(1, 'script') from backend import model import io from PIL import Image import base64 import numpy as np app = Fla...
normal
{ "blob_id": "93d0d73d56b04bba505265958fccff229f5eaf49", "index": 872, "step-1": "<mask token>\n\n\n@app.route('/', methods=['GET', 'POST'])\ndef upload_file():\n if request.method == 'POST' and 'photo' in request.files:\n filename = photos.save(request.files['photo'])\n file_url = photos.url(fil...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- """ Created on Mon Apr 16 21:26:03 2018 @author: Brandon """os.getcwd() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'os' is not definimport os >>> os.getcwd() 'C:\\Users\\Brandon\\AppData\\Local\\Programs\\Python\\Python36-32' >>> os.chdir() Tracebac...
normal
{ "blob_id": "dc97703d39e7db29e0ba333c2797f4be6d015fd7", "index": 7886, "step-1": "# -*- coding: utf-8 -*-\n\"\"\"\nCreated on Mon Apr 16 21:26:03 2018\n\n@author: Brandon\n\"\"\"os.getcwd()\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\nNameError: name 'os' is not definimport os\n>...
[ 0 ]
#!/usr/bin/env python2 ## -*- coding: utf-8 -*- import sys def sx(bits, value): sign_bit = 1 << (bits - 1) return (value & (sign_bit - 1)) - (value & sign_bit) SymVar_0 = int(sys.argv[1]) ref_263 = SymVar_0 ref_278 = ref_263 # MOV operation ref_5710 = ref_278 # MOV operation ref_5786 = ref_5710 # MOV operati...
normal
{ "blob_id": "22d3ff0fca9a5537da37bfbc968d83ec6f919752", "index": 5162, "step-1": "#!/usr/bin/env python2\n## -*- coding: utf-8 -*-\n\nimport sys\n\ndef sx(bits, value):\n sign_bit = 1 << (bits - 1)\n return (value & (sign_bit - 1)) - (value & sign_bit)\n\nSymVar_0 = int(sys.argv[1])\nref_263 = SymVar_0\nre...
[ 0 ]
import numpy as np import tensorflow as tf from tfrecords_handler.moving_window.tfrecord_mean_reader import TFRecordReader from configs.global_configs import training_data_configs class StackingModelTester: def __init__(self, **kwargs): self.__use_bias = kwargs["use_bias"] self.__use_peepholes = ...
normal
{ "blob_id": "3b7839347f24d39904d29d40e688a5dfd63534d7", "index": 3560, "step-1": "<mask token>\n\n\nclass StackingModelTester:\n\n def __init__(self, **kwargs):\n self.__use_bias = kwargs['use_bias']\n self.__use_peepholes = kwargs['use_peepholes']\n self.__input_size = kwargs['input_size...
[ 3, 4, 5, 6, 7 ]
from django import forms class UploadForm(forms.Form): file = forms.FileField(label="Json с данными об отправлении")
normal
{ "blob_id": "0878bfa1151371ff3aaa59f8be5ea9af74ada331", "index": 4978, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass UploadForm(forms.Form):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass UploadForm(forms.Form):\n file = forms.FileField(label='Json с данными об отправлении')\n",...
[ 0, 1, 2, 3, 4 ]
""" * Team Id : LM#4787 * Author List : Arjun S, Vinod, Arvind, Vishnu * Filename: ArenaPreprocessor.py * Theme: Launch A Module * Functions: arena_preprocess, getTransformationMatrix, get_robot_space * Global Variables: None """ import cv2 import numpy as np """ * Function Name...
normal
{ "blob_id": "228852f960e9343d9f45abdd3204cfab7bb54bc6", "index": 8230, "step-1": "<mask token>\n\n\ndef arena_preprocess(frame, M):\n processed_arena = cv2.warpPerspective(frame, M, (900, 600))\n in_corners = np.array([[10, 18], [10, 590], [890, 590], [890, 15]])\n h, w = processed_arena.shape[:2]\n ...
[ 1, 2, 3, 4, 5 ]
# -*- coding: utf-8 -*- from django.conf.urls import patterns, include, url from django.contrib.auth.views import login, logout from django.contrib import admin from magmag_core.app import application from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf.urls.static import static from mag...
normal
{ "blob_id": "538e582df7bfcf281973a5296adc14ca067be0a5", "index": 2581, "step-1": "<mask token>\n", "step-2": "<mask token>\nadmin.autodiscover()\n<mask token>\nurlpatterns += staticfiles_urlpatterns()\nurlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)\n", "step-3": "<mask token>\na...
[ 0, 1, 2, 3, 4 ]
operation = input('operation type: ').lower() num1 = input("First number: ") num2 = input("First number: ") try: num1, num2 = float(num1), float(num2) if operation == 'add': result = num1 + num2 print(result) elif operation == 'subtract': result = num1 - num2 print(result) ...
normal
{ "blob_id": "bafb6c09ecd0017428441e109733ebcb189863ad", "index": 3598, "step-1": "<mask token>\n", "step-2": "<mask token>\ntry:\n num1, num2 = float(num1), float(num2)\n if operation == 'add':\n result = num1 + num2\n print(result)\n elif operation == 'subtract':\n result = num1 ...
[ 0, 1, 2, 3 ]