code
stringlengths
13
1.2M
order_type
stringclasses
1 value
original_example
dict
step_ids
listlengths
1
5
from django.db import models # Create your models here. class UserInfo(models.Model): uname = models.CharField('用户名', max_length=50, null=False) upassword = models.CharField('密码', max_length=200, null=False) email = models.CharField('邮箱', max_length=50, null=True) phone = models.CharField('手机号', max_le...
normal
{ "blob_id": "dbec74ecf488ca98f3f441e252f79bc2bc0959c1", "index": 4068, "step-1": "<mask token>\n\n\nclass UserInfo(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n verbose_n...
[ 4, 5, 6, 7, 8 ]
import unittest from theoktany.serializers import serialize class SerializerTest(unittest.TestCase): class TestObject(object): def __init__(self, **kwargs): for name, value in kwargs.items(): self.__setattr__(name, value) def test_serialize(self): object_dict = ...
normal
{ "blob_id": "4e4d6a9ed07aa03c79dade05e01f226017b13de5", "index": 9250, "step-1": "<mask token>\n\n\nclass SerializerTest(unittest.TestCase):\n\n\n class TestObject(object):\n\n def __init__(self, **kwargs):\n for name, value in kwargs.items():\n self.__setattr__(name, value)\n...
[ 3, 4, 5, 7 ]
import django.dispatch property_viewed = django.dispatch.Signal(providing_args=["property","user", "request", "response"])
normal
{ "blob_id": "00099cab0c816c76fc0fa94d7905175feb6919cf", "index": 9795, "step-1": "<mask token>\n", "step-2": "<mask token>\nproperty_viewed = django.dispatch.Signal(providing_args=['property', 'user',\n 'request', 'response'])\n", "step-3": "import django.dispatch\nproperty_viewed = django.dispatch.Signal...
[ 0, 1, 2, 3 ]
from helper import * async def main(URL, buy_time): browser, page = await get_window() # 30s登陆时间 await page.goto('https://account.xiaomi.com/pass/serviceLogin?callback=http%3A%2F%2Forder.mi.com%2Flogin%2Fcallback%3Ffollowup%3Dhttps%253A%252F%252Fwww.mi.com%252F%26sign%3DNzY3MDk1YzczNmUwMGM4ODAxOWE0NjRiNTU...
normal
{ "blob_id": "1e87f625fb7bd9f9bf4233229332c909702954a5", "index": 4334, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nasync def main(URL, buy_time):\n browser, page = await get_window()\n await page.goto(\n 'https://account.xiaomi.com/pass/serviceLogin?callback=http%3A%2F%2Forder.mi.com%...
[ 0, 1, 2, 3 ]
from pkg.models.board import Board class BaseAI: _board: Board = None def __init__(self, board=None): if board is not None: self.set_board(board) def set_board(self, board): self._board = board def find_move(self, for_player): pass
normal
{ "blob_id": "b794a4cca3303ac7440e9aad7bc210df62648b51", "index": 5476, "step-1": "<mask token>\n\n\nclass BaseAI:\n _board: Board = None\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass BaseAI:\n _board: Board = None\n <mask token>\n <mask token>\n\n d...
[ 1, 2, 3, 4, 5 ]
''' This script will do auto-check in/out for ZMM100 fingerprint access control device by ZKSoftware. At my office, the manager uses an application to load data from the fingerprint device. After he loads data, log in device's database is cleared. So in my case, I write this script to automate checking in/out everyday...
normal
{ "blob_id": "3d1e6be71f92910cdc9eb2bf60ea7f8f1187f706", "index": 3698, "step-1": "<mask token>\n\n\ndef get_server_ip(device_ip):\n import socket\n s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)\n s.connect((device_ip, 80))\n return s.getsockname()[0]\n\n\ndef transfer_file(from_ip, to_ip, remo...
[ 6, 12, 13, 14, 16 ]
#!/usr/bin/python3 def add_tuple(tuple_a=(), tuple_b=()): if len(tuple_a) < 1: a_x = 0 else: a_x = tuple_a[0] if len(tuple_a) < 2: a_y = 0 else: a_y = tuple_a[1] if len(tuple_b) < 1: b_x = 0 else: b_x = tuple_b[0] if len(tuple_b) < 2: b...
normal
{ "blob_id": "1522ebb52504f7f27a526b597fe1e262bbcbfbb0", "index": 4429, "step-1": "<mask token>\n", "step-2": "def add_tuple(tuple_a=(), tuple_b=()):\n if len(tuple_a) < 1:\n a_x = 0\n else:\n a_x = tuple_a[0]\n if len(tuple_a) < 2:\n a_y = 0\n else:\n a_y = tuple_a[1]\n ...
[ 0, 1, 2 ]
# from cis_dna import import cis_config as conf import protocol_pb2 as proto import uuid import random import math import dna_decoding import numpy as np def move(cell): pass def is_alive(cell): starvation_threshold = conf.ENERGY_THRESHOLD if cell.energy_level < starvation_threshold: return Fals...
normal
{ "blob_id": "de557c3c1455acc0a3facfca5729a010f3d123dc", "index": 4208, "step-1": "<mask token>\n\n\ndef is_alive(cell):\n starvation_threshold = conf.ENERGY_THRESHOLD\n if cell.energy_level < starvation_threshold:\n return False\n else:\n return True\n\n\n<mask token>\n\n\ndef dna_copy_or_...
[ 2, 6, 7, 8, 9 ]
#!/usr/bin/env python # coding=utf-8 import sys,os dir = '/home/ellen/yjoqm/fdfs_client/pic' def scp_file(filename): cmd = 'scp ellen@61.147.182.142:/home/ellen/yjoqm/fdfs_client/pic/%s .' %filename os.system(cmd) def main(args): args = sys.argv[1] scp_file(args) print 'done~~~~' if __name_...
normal
{ "blob_id": "e2489f9d3041c45129fdd71da6652a6093c96d2d", "index": 8487, "step-1": "#!/usr/bin/env python\n# coding=utf-8\nimport sys,os\n\ndir = '/home/ellen/yjoqm/fdfs_client/pic'\n\ndef scp_file(filename):\n cmd = 'scp ellen@61.147.182.142:/home/ellen/yjoqm/fdfs_client/pic/%s .' %filename\n os.system(cmd)...
[ 0 ]
import torch import re import sys import os import shutil import filecmp import numpy as np from collections import defaultdict from shutil import copyfile sys.path.append('../') class BoardParser: def __init__(self): self.file = open('../board_output', 'rb') self.data = None def update(se...
normal
{ "blob_id": "3668e8009dca4ea261bdfbd325331c338fdac5a9", "index": 627, "step-1": "<mask token>\n\n\nclass StatusParser:\n\n def __init__(self):\n self.board = np.memmap('../tmp/board', mode='r', dtype=np.int8,\n shape=(20, 10))\n self.combo = np.memmap('../tmp/combo', mode='r', dtype=n...
[ 11, 12, 13, 15, 17 ]
"""main.py""" import tkinter as tk from tkinter import ttk from ttkthemes import ThemedStyle import wikipedia as wk from newsapi import NewsApiClient as nac import datetime import random class MainWindow: """Application controller object.""" def __init__(self): self.p = None self...
normal
{ "blob_id": "874fa927a1c0f1beeb31ca7b0de7fd2b16218ea4", "index": 2756, "step-1": "<mask token>\n\n\nclass MainWindow:\n <mask token>\n <mask token>\n\n def search_wikipedia(self):\n \"\"\"Safely browse wikipedia articles.\"\"\"\n self.summary.delete('1.0', tk.END)\n possibilities = ...
[ 8, 9, 11, 12, 13 ]
import simplejson as json json_list = [ "/content/squash-generation/squash/final/Custom.json", "/content/squash-generation/squash/temp/Custom/final_qa_set.json", "/content/squash-generation/squash/temp/Custom/generated_questions.json", "/content/squash-generation/squash...
normal
{ "blob_id": "f37d016dc49820239eb42198ca922e8681a2e0a6", "index": 6929, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in json_list:\n with open(i) as f:\n obj = json.load(f)\n f.close()\n outfile = open(i, 'w')\n outfile.write(json.dumps(obj, indent=4, sort_keys=True))\n o...
[ 0, 1, 2, 3, 4 ]
n = input("Enter a number: ") def fact(num): factorial = 1 if int(num) >= 1: for i in range (1,int(n)+1): factorial = factorial * i return factorial print(fact(n))
normal
{ "blob_id": "93b00b5c1bec38d2a4ac109f1533d3c0d9e99044", "index": 5763, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef fact(num):\n factorial = 1\n if int(num) >= 1:\n for i in range(1, int(n) + 1):\n factorial = factorial * i\n return factorial\n\n\n<mask token>\n", "...
[ 0, 1, 2, 3, 4 ]
import subprocess class Audio: def __init__(self): self.sox_process = None def kill_sox(self, timeout=1): if self.sox_process is not None: self.sox_process.terminate() try: self.sox_process.wait(timeout=timeout) except subprocess.TimeoutExpir...
normal
{ "blob_id": "d35d26cc50da9a3267edd2da706a4b6e653d22ac", "index": 6555, "step-1": "<mask token>\n\n\nclass Audio:\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Audio:\n\n def __init__(self):...
[ 1, 6, 8, 9, 10 ]
''' Created on 4 Oct 2016 @author: MetalInvest ''' def isHammerHangman(high, low, open, close): body = abs(open - close) leg = min(open, close) - low return leg / body >= 2.0 and high/max(open, close) <= 1.08 def isEngulfing(df, bottom = True): open_0 = df['open'][-1] close_0 = d...
normal
{ "blob_id": "6e739c30b3e7c15bd90b74cfd5a1d6827e863a44", "index": 4413, "step-1": "<mask token>\n\n\ndef isHammerHangman(high, low, open, close):\n body = abs(open - close)\n leg = min(open, close) - low\n return leg / body >= 2.0 and high / max(open, close) <= 1.08\n\n\ndef isEngulfing(df, bottom=True):...
[ 2, 3, 4, 5, 6 ]
from django.shortcuts import render, redirect from django.utils.crypto import get_random_string def index(request): if not "word" in request.session: request.session["word"] = 'Empty' if not "count" in request.session: request.session["count"] = 0 if request.method == "GET": return...
normal
{ "blob_id": "2ec5e43860a1d248a2f5cd1abc26676342275425", "index": 8589, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef reset(request):\n request.session['count'] = 0\n return redirect('/')\n", "step-3": "<mask token>\n\n\ndef index(request):\n if not 'word' in request.session:\n ...
[ 0, 1, 2, 3, 4 ]
import datetime import shutil from pathlib import Path from jinja2 import Environment, FileSystemLoader from dataclasses import dataclass PATH_TO_TEMPLATES = Path('TEMPLATES/') PATH_TO_RESOURCES = Path('RESOURCES/') PATH_TO_OUTPUT = Path('../docs/') URL_ROOT = "https://katys.cz/" link_to_homepage = "/" # TODO: alwa...
normal
{ "blob_id": "5cc18af40befab444df44bf3da1f0175e5d18983", "index": 8206, "step-1": "<mask token>\n\n\n@dataclass()\nclass Page(object):\n title: str\n keywords: str\n description: str\n content_file: str\n url: str\n language: str\n last_mod: datetime.datetime\n phone: str = '+420 603 217 8...
[ 3, 5, 6, 9, 10 ]
import requests import os from dotenv import load_dotenv from datetime import datetime load_dotenv(".env") # loads the environment file USERNAME = os.getenv("USER") TOKEN = os.getenv("TOKEN") pixela_endpoint = "https://pixe.la/v1/users" # MAKING AN ACCOUNT user_params = { "token": TOKEN, ...
normal
{ "blob_id": "ba34dfcad0cb9bac9c462bdf60e55dee6ba9d58d", "index": 9255, "step-1": "<mask token>\n", "step-2": "<mask token>\nload_dotenv('.env')\n<mask token>\nprint(response.text)\n<mask token>\n", "step-3": "<mask token>\nload_dotenv('.env')\nUSERNAME = os.getenv('USER')\nTOKEN = os.getenv('TOKEN')\npixela_...
[ 0, 1, 2, 3, 4 ]
''' Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC". Note: If there is no such window in S that covers all characters in T, return the empty string "". If there are multipl...
normal
{ "blob_id": "665a868ee71f247a621d82108e545257296e0427", "index": 7048, "step-1": "<mask token>\n\n\nclass Solution:\n <mask token>\n <mask token>\n <mask token>\n", "step-2": "<mask token>\n\n\nclass Solution:\n <mask token>\n\n def minWindow(self, source, target):\n s_char_count = defaul...
[ 1, 3, 4, 5, 6 ]
import math def vol_shell(r1, r2): a=abs((4/3)*math.pi*((r1**3)-(r2**3))) return round(a,3) print(vol_shell(3,3))
normal
{ "blob_id": "cd234911c1f990b8029dfa792d132847bf39a6aa", "index": 445, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef vol_shell(r1, r2):\n a = abs(4 / 3 * math.pi * (r1 ** 3 - r2 ** 3))\n return round(a, 3)\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef vol_shell(r1, r2):\n a = ...
[ 0, 1, 2, 3, 4 ]
# This handle the url for routing from django.urls import path from . import views # Defines views to pass dynamic data to listings page urlpatterns = [ path('', views.index, name='listings'), path('<int:listing_id>', views.listing, name='listing'), path('search', views.search, name='search') ]
normal
{ "blob_id": "be894830bb0dde6bacaea6be823391e0445603c3", "index": 1192, "step-1": "<mask token>\n", "step-2": "<mask token>\nurlpatterns = [path('', views.index, name='listings'), path(\n '<int:listing_id>', views.listing, name='listing'), path('search',\n views.search, name='search')]\n", "step-3": "fr...
[ 0, 1, 2, 3 ]
# Generated by Django 2.2 on 2021-01-31 14:11 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('app', '0004_product_pr_number'), ] operations = [ migrations.RemoveField( model_name='payment', name='PA_id', ...
normal
{ "blob_id": "388772386f25d6c2f9cc8778b7ce1b2ad0920851", "index": 6986, "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', '0004...
[ 0, 1, 2, 3, 4 ]
import requests import json l = list() with open ( "token.txt", "r") as f: token = f.read() # создаем заголовок, содержащий наш токен headers = {"X-Xapp-Token" : token} with open('dataset_24476_4.txt', 'r') as id: for line in id: address = "https://api.artsy.net/api/artists/" +...
normal
{ "blob_id": "e1ecc08f66e094841647f72b78bcd29ed8d32668", "index": 5976, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('token.txt', 'r') as f:\n token = f.read()\n headers = {'X-Xapp-Token': token}\n with open('dataset_24476_4.txt', 'r') as id:\n for line in id:\n addr...
[ 0, 1, 2, 3, 4 ]
#! /usr/bin/env python import sys import socket def handle_connection(sock): do_close = False while 1: try: data = sock.recv(4096) if not data: # closed! stop monitoring this socket. do_close = True break print 'd...
normal
{ "blob_id": "fde4c10e2ed0ed38d683a220e2985c3f3f336601", "index": 7258, "step-1": "#! /usr/bin/env python\nimport sys\nimport socket\n\ndef handle_connection(sock):\n do_close = False\n \n while 1:\n try:\n data = sock.recv(4096)\n if not data: # closed! stop ...
[ 0 ]
from data_structures.datacenter import Datacenter, urllib, json, URL = "http://www.mocky.io/v2/5e539b332e00007c002dacbe" def get_data(url, max_retries=5, delay_between_retries=1): """ Fetch the data from http://www.mocky.io/v2/5e539b332e00007c002dacbe and return it as a JSON object. ​ Args: ...
normal
{ "blob_id": "e56a7912b9940b1cab6c19d0047f1f60f0083f66", "index": 4911, "step-1": "from data_structures.datacenter import Datacenter, urllib, json,\n\n\nURL = \"http://www.mocky.io/v2/5e539b332e00007c002dacbe\"\n\n\ndef get_data(url, max_retries=5, delay_between_retries=1):\n \"\"\"\n Fetch the data from ht...
[ 0 ]
#!/g/kreshuk/lukoianov/miniconda3/envs/inferno/bin/python3 # BASIC IMPORTS import argparse import os import subprocess import sys import numpy as np # INTERNAL IMPORTS from src.datasets import CentriollesDatasetOn, CentriollesDatasetBags, GENdataset from src.utils import get_basic_transforms, log_info, get_resps_tran...
normal
{ "blob_id": "604c94e50b1fb9b5e451c4432113498410a4ac1f", "index": 5262, "step-1": "<mask token>\n", "step-2": "<mask token>\nif __name__ == '__main__':\n parser = argparse.ArgumentParser(description=\n 'Run learning of simple CNN implementation')\n parser.add_argument('--model_name', type=str, defa...
[ 0, 1, 2, 3 ]
from py.test import raises from ..lazymap import LazyMap def test_lazymap(): data = list(range(10)) lm = LazyMap(data, lambda x: 2 * x) assert len(lm) == 10 assert lm[1] == 2 assert isinstance(lm[1:4], LazyMap) assert lm.append == data.append assert repr(lm) == '<LazyMap [0, 1, 2, 3, 4, 5,...
normal
{ "blob_id": "3e7d80fdd1adb570934e4b252bc25d5746b4c68e", "index": 3912, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_lazymap():\n data = list(range(10))\n lm = LazyMap(data, lambda x: 2 * x)\n assert len(lm) == 10\n assert lm[1] == 2\n assert isinstance(lm[1:4], LazyMap)\n ...
[ 0, 1, 2, 3 ]
# Stanley H.I. Lio # hlio@hawaii.edu # All Rights Reserved. 2018 import logging, time, sys from serial import Serial from . import aanderaa_3835 from . import aanderaa_4330f from . import aanderaa_4531d from . import aanderaa_4319a logger = logging.getLogger(__name__) # works with 3835 (DO), 4330F (DO), 4531D (DO),...
normal
{ "blob_id": "c52ad4040c14471319939605c400ff4d4ad982a7", "index": 5213, "step-1": "<mask token>\n\n\ndef aanderaa_read_universal(port, max_retry=3, parsers=[aanderaa_4531d.\n parse_4531d, aanderaa_4330f.parse_4330f, aanderaa_3835.parse_3835,\n aanderaa_4319a.parse_4319a]):\n logger.debug('aanderaa_read_u...
[ 1, 2, 3, 4, 5 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 5 10:04:05 2019 @author: cristina """ import numpy as np from itertools import chain from numpy import linalg as LA diag = LA.eigh import matplotlib.pyplot as plt plt.rcParams.update({'font.size': 13}) import time pi = np.pi exp = np.exp t1 = tim...
normal
{ "blob_id": "f2ad95574b65b4d3e44b85c76f3a0150a3275cec", "index": 2356, "step-1": "<mask token>\n\n\ndef LDOS_up(omega, E, u, Damping):\n t = sum(u ** 2 / (omega - E + 1.0j * Damping))\n tt = -1 / pi * np.imag(t)\n return tt\n\n\ndef LDOS_down(omega, E, v, Damping):\n t = sum(v ** 2 / (omega + E + 1.0...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python from __future__ import division import sys import math logs = sys.stderr from collections import defaultdict import time from mytime import Mytime import gflags as flags FLAGS=flags.FLAGS flags.DEFINE_string("weights", None, "weights file (feature instances and weights)", short_name="w") flag...
normal
{ "blob_id": "e5fd0fc13a39444a934eea3bd24056073d28eff2", "index": 9869, "step-1": "#!/usr/bin/env python\n\nfrom __future__ import division\n\nimport sys\nimport math\nlogs = sys.stderr\nfrom collections import defaultdict\n\nimport time\nfrom mytime import Mytime\n\nimport gflags as flags\nFLAGS=flags.FLAGS\n\nf...
[ 0 ]
from django.apps import AppConfig class PrimaryuserConfig(AppConfig): name = 'PrimaryUser'
normal
{ "blob_id": "82c10076ba73723b696e3e33280296c2a24f20b9", "index": 4187, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass PrimaryuserConfig(AppConfig):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass PrimaryuserConfig(AppConfig):\n name = 'PrimaryUser'\n", "step-4": "from django.app...
[ 0, 1, 2, 3 ]
from django.db import models from datetime import datetime # Create your models here. class Notifications(models.Model): username= models.CharField(max_length=20) phone_number= models.BigIntegerField(default= 0) email= models.EmailField() firstname= models.CharField(max_length=20) app_name= models...
normal
{ "blob_id": "51ed99a68486bd52499bbc28e68ff2312e02ea1f", "index": 6604, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass Notifications(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n ...
[ 0, 1, 2, 3, 4 ]
# -*- coding:utf-8 -*- import time from abc import ABCMeta, abstractmethod from xlreportform.worksheet import WorkSheet __author__ = "Andy Yang" class Bases(metaclass=ABCMeta): def __init__(self): pass @abstractmethod def set_style(self): """set workshet's style, indent,bor...
normal
{ "blob_id": "092c6d637fe85136b4184d05f0ac7db17a8efb3b", "index": 6087, "step-1": "<mask token>\n\n\nclass Bases(metaclass=ABCMeta):\n\n def __init__(self):\n pass\n\n @abstractmethod\n def set_style(self):\n \"\"\"set workshet's style, indent,border,font,and so on\"\"\"\n\n @abstractmet...
[ 13, 14, 15, 16, 17 ]
# message 为定义的变量 message = 'Hello Python World ' print(message)
normal
{ "blob_id": "ee5e970f32b1d601f9dc3ab37a5028ce7ff8a32e", "index": 1368, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(message)\n", "step-3": "message = 'Hello Python World '\nprint(message)\n", "step-4": "# message 为定义的变量\r\nmessage = 'Hello Python World '\r\nprint(message)", "step-5": null...
[ 0, 1, 2, 3 ]
import csv from pprint import pprint as pp with open('nodes_tags.csv', 'r') as f: tags = csv.DictReader(f) for row in tags: if row['key'] == 'FIXME': pp(row)
normal
{ "blob_id": "d0981d279f7090d5309aa564252dba731a34a66b", "index": 1424, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('nodes_tags.csv', 'r') as f:\n tags = csv.DictReader(f)\n for row in tags:\n if row['key'] == 'FIXME':\n pp(row)\n", "step-3": "import csv\nfrom pprint...
[ 0, 1, 2 ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals import markdown from django.db import models from django.contrib.auth.models import User from datetime import datetime class MovieRankings(models.Model): """ 各种电影排行榜. """ name = models.CharField(max_length=100) def __unicode__(self)...
normal
{ "blob_id": "449ae193f8817d4ee2fe67eadf72d9c19b2c5e53", "index": 1319, "step-1": "<mask token>\n\n\nclass MovieRankings(models.Model):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Movie(models.Model):\n \"\"\"\n 电影的数据库表格\n \"\"\"\n movie_name = models.CharField(max_length=64, blan...
[ 8, 10, 11, 12, 13 ]
# -*- coding: utf-8 -*- __author__ = 'tqs' from win32com.client import Dispatch import win32com.client import time import os import re import win32api ''' windows操作部分说明: 考试波及知识点: 1.删除文件及文件夹 2.复制文件及文件夹 3.移动文件及文件夹 4.文件及文件夹改名 5.文件属性 考试样例: 1、在“蕨类植物”文件夹中,新建一个子文件夹“薄囊蕨类”。 2、将文件“淡水藻.ddd”移动到“藻类植物”文件夹中。 3、设置“螺旋藻.aaa”文件属性为“只读”...
normal
{ "blob_id": "b453006b4d4c5f17bb58110fe8197d7796ca0c6c", "index": 467, "step-1": "<mask token>\n\n\nclass ExcelOperation:\n\n def __init__(self, filename=None):\n self.xlApp = win32com.client.Dispatch('Excel.Application')\n if filename:\n self.filename = filename\n self.xlBo...
[ 42, 52, 64, 71, 87 ]
#!/usr/bin/python3 #coding:utf-8 """ Author: Xie Song Email: 18406508513@163.com Copyright: Xie Song License: MIT """ import torch def get_sgd_optimizer(args, model): opimizer = torch.optim.SGD(model.parameters(),lr=args.lr,weight_decay=1e-4) return opimizer
normal
{ "blob_id": "5dca187cfe221f31189ca9a9309ece4b9144ac66", "index": 2812, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_sgd_optimizer(args, model):\n opimizer = torch.optim.SGD(model.parameters(), lr=args.lr, weight_decay\n =0.0001)\n return opimizer\n", "step-3": "<mask token>\n...
[ 0, 1, 2, 3 ]
from modeltranslation.translator import register, TranslationOptions from .models import * @register(PageTitleModel) class TitleTranslationOptions(TranslationOptions): fields = ( 'name', ) @register(NewsModel) class ProjectTranslationOptions(TranslationOptions): fields = ( 'name', ...
normal
{ "blob_id": "9c29f04746de6847ad1bbdf08964d14e6c3766db", "index": 8700, "step-1": "<mask token>\n\n\n@register(NewsModel)\nclass ProjectTranslationOptions(TranslationOptions):\n fields = 'name', 'text'\n", "step-2": "<mask token>\n\n\n@register(PageTitleModel)\nclass TitleTranslationOptions(TranslationOption...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Oct 7 07:51:26 2017 @author: hcorrada """ from plagiarism_lib.article_db import ArticleDB from plagiarism_lib.minhash import MinHash from plagiarism_lib.lsh import LSH import pandas as pd import numpy as np def _read_truthfile(filepath): with op...
normal
{ "blob_id": "18b73a06c80272aff5c0e4b10473e95bd58466f3", "index": 1197, "step-1": "<mask token>\n\n\ndef _get_stats(candidate_pairs, truth_pairs):\n tp = len(candidate_pairs.intersection(truth_pairs))\n prec = 1.0 * tp / len(candidate_pairs)\n rec = 1.0 * tp / len(truth_pairs)\n print(' returned: %d,...
[ 1, 2, 3, 4, 5 ]
Desafios: 1: Crie um script python que leia o nome de uma pessoa e mostre uma mensagem de boas-vindas de acordo com o valor digitado. Script: Desafio 01: 1: Crie um script python que leia o nome de uma pessoa e mostre uma mensagem de boas-vindas de acordo com o valor digitado.""" nome=input('Qual é o seu nome?') print...
normal
{ "blob_id": "80454a3935f0d42b5535440fc316af1b5598d8a1", "index": 7090, "step-1": "Desafios:\n1: Crie um script python que leia o nome de uma pessoa e mostre uma mensagem de boas-vindas de acordo com o valor digitado.\n\nScript:\nDesafio 01:\n1: Crie um script python que leia o nome de uma pessoa\ne mostre uma me...
[ 0 ]
#!/usr/bin/env python # script :: creating a datamodel that fits mahout from ratings.dat ratings_dat = open('../data/movielens-1m/users.dat', 'r') ratings_csv = open('../data/movielens-1m/users.txt', 'w') for line in ratings_dat: arr = line.split('::') new_line = '\t'.join(arr) ratings_csv.write(new_line) rati...
normal
{ "blob_id": "2dd59681a0dcb5d3f1143385100c09c7783babf4", "index": 76, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor line in ratings_dat:\n arr = line.split('::')\n new_line = '\\t'.join(arr)\n ratings_csv.write(new_line)\nratings_dat.close()\nratings_csv.close()\n", "step-3": "ratings_dat ...
[ 0, 1, 2, 3 ]
"""Support for Deebot Vaccums.""" import logging from typing import Any, Mapping, Optional import voluptuous as vol from deebot_client.commands import ( Charge, Clean, FanSpeedLevel, PlaySound, SetFanSpeed, SetRelocationState, SetWaterInfo, ) from deebot_client.commands.clean import CleanAc...
normal
{ "blob_id": "1ab690b0f9c34b1886320e1dfe8b54a5ec6cd4d1", "index": 8712, "step-1": "<mask token>\n\n\nclass DeebotVacuum(DeebotEntity, StateVacuumEntity):\n <mask token>\n\n def __init__(self, vacuum_bot: VacuumBot):\n \"\"\"Initialize the Deebot Vacuum.\"\"\"\n device_info = vacuum_bot.device_...
[ 5, 6, 9, 10, 13 ]
# strspn(str1,str2) str1 = '12345678' str2 = '456' # str1 and chars both in str1 and str2 print(str1 and str2) str1 = 'cekjgdklab' str2 = 'gka' nPos = -1 for c in str1: if c in str2: nPos = str1.index(c) break print(nPos)
normal
{ "blob_id": "5c30b0e952ddf2e05a7ad5f8d9bbd4f5e22f887d", "index": 62, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(str1 and str2)\n<mask token>\nfor c in str1:\n if c in str2:\n nPos = str1.index(c)\n break\nprint(nPos)\n", "step-3": "str1 = '12345678'\nstr2 = '456'\nprint(str1 ...
[ 0, 1, 2, 3 ]
a= input("Enter number") a= a.split() b=[] for x in a: b.append(int(x)) print(b) l=len(b) c=0 s=0 for i in range(l): s=len(b[:i]) for j in range(s): if b[s]<b[j]: c=b[s] b.pop(s) b.insert(b.index(b[j]),c) print(b,b[:i],b[s])
normal
{ "blob_id": "24de4f486d4e976850e94a003f8d9cbe3e518402", "index": 33, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor x in a:\n b.append(int(x))\nprint(b)\n<mask token>\nfor i in range(l):\n s = len(b[:i])\n for j in range(s):\n if b[s] < b[j]:\n c = b[s]\n b.pop(s...
[ 0, 1, 2, 3 ]
from PIL import Image, ImageDraw, ImageFont import sys ### Create 1024,1024 pixel image with a white background. img = Image.new("RGB", (1024, 1024), color = (255,255,255)) ### Take text to be drawn on the image from the command terminal. text = sys.argv[1] ### Chose favourite font and set size of the font. fnt = Im...
normal
{ "blob_id": "053fa80c80d40cd28acb7d6a8bf1b2c30be9b36e", "index": 7786, "step-1": "<mask token>\n", "step-2": "<mask token>\nd.text(xy=(320, 420), text=text, font=fnt, fill=(0, 0, 0))\nimg.save(text + '.png')\n", "step-3": "<mask token>\nimg = Image.new('RGB', (1024, 1024), color=(255, 255, 255))\ntext = sys....
[ 0, 1, 2, 3, 4 ]
import xlrd from django.shortcuts import redirect from django.contrib import messages from django.utils.translation import ugettext_lazy as _ from django.core import validators from utils.views import render_to from accounts.models import Account from .models import ExternalSubscriber from .forms import ExternalSubsc...
normal
{ "blob_id": "2ec41e02c95a270455c096e85829b7220eeda0c7", "index": 1317, "step-1": "<mask token>\n\n\ndef validate_email(value, row_number):\n error_message = _(u'Invalid e-mail address on \"%d\" line.')\n return validators.EmailValidator(validators.email_re, unicode(\n error_message % row_number), 'i...
[ 2, 3, 4, 5, 6 ]
#!/usr/bin/python import math def Main(): try: radius = float(input("Please enter the radius: ")) area = math.pi * radius**2 print("Area =", area) except: print("You did not enter a number") if __name__ == "__main__": Main()
normal
{ "blob_id": "33c4e0504425c5d22cefb9b4c798c3fd56a63771", "index": 3641, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef Main():\n try:\n radius = float(input('Please enter the radius: '))\n area = math.pi * radius ** 2\n print('Area =', area)\n except:\n print('You...
[ 0, 1, 2, 3, 4 ]
""" Image Check / Compress Image""" import re import os from PIL import Image from common.constant import PATH def check_image(file_type): match = re.match("image/*", file_type) return match def compress_image(data): with open(PATH.format(data['name']), 'wb+') as file: file.write(data['binary'...
normal
{ "blob_id": "13fa650557a4a8827c9fb2e514bed178df19a32c", "index": 1295, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef check_image(file_type):\n match = re.match('image/*', file_type)\n return match\n\n\n<mask token>\n", "step-3": "<mask token>\n\n\ndef check_image(file_type):\n match =...
[ 0, 1, 2, 3, 4 ]
# Obtener en otra lista unicamente números impares: my_list = [1, 4, 5, 6, 9, 13, 19, 21] # Vamos a hacer una list comprehension: lista_impares = [num for num in my_list if num % 2 != 0] print(my_list) print(lista_impares) print('') # Vamos a usar filter: lista_pares = list(filter(lambda x: x % 2 == 0 , my_list)) p...
normal
{ "blob_id": "e1913c80375e4871119182d0267e9f228818624f", "index": 4309, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(my_list)\nprint(lista_impares)\nprint('')\n<mask token>\nprint(my_list)\nprint(lista_pares)\n", "step-3": "my_list = [1, 4, 5, 6, 9, 13, 19, 21]\nlista_impares = [num for num in m...
[ 0, 1, 2, 3 ]
import re from .models import ValidatedStudent from rest_framework.authtoken.models import Token from django.contrib.auth.models import User def get_token_from_request(request): token_tuple = request.COOKIES.get('money_api_token') matches = re.search(r'(<Token: (\S*)>)', token_tuple) token = matches.group...
normal
{ "blob_id": "2187f38dc9b14ecc355e98fe15d36fdefd548f04", "index": 1159, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef get_token_from_request(request):\n token_tuple = request.COOKIES.get('money_api_token')\n matches = re.search('(<Token: (\\\\S*)>)', token_tuple)\n token = matches.groups...
[ 0, 1, 2, 3, 4 ]
"""Module for the bot""" from copy import deepcopy from time import sleep import mcpi.minecraft as minecraft from mcpi.vec3 import Vec3 import mcpi.block as block from search import SearchProblem, astar, bfs from singleton import singleton _AIR = block.AIR.id _WATER = block.WATER.id _LAVA = block.LAVA.id _BEDROCK =...
normal
{ "blob_id": "54f0ed5f705d5ada28721301f297b2b0058773ad", "index": 2, "step-1": "<mask token>\n\n\nclass _GenericBot:\n <mask token>\n\n def __init__(self, pos, inventory=None):\n \"\"\"Initialize with an empty inventory.\n\n inventory is a dictionary. If None, an empty one will be used.\"\"\"\...
[ 52, 53, 58, 60, 79 ]
# -*- coding: utf-8 -*- # @Time : 2022-03-09 21:51 # @Author : 袁肖瀚 # @FileName: WDCNN-DANN.py # @Software: PyCharm import torch import numpy as np import torch.nn as nn import argparse from model import WDCNN1 from torch.nn.init import xavier_uniform_ import torch.utils.data as Data import matplotlib.py...
normal
{ "blob_id": "fd45657083942dee13f9939ce2a4b71ba3f67397", "index": 3587, "step-1": "<mask token>\n\n\ndef weight_init(m):\n class_name = m.__class__.__name__\n if class_name.find('Conv') != -1:\n xavier_uniform_(m.weight.data)\n if class_name.find('Linear') != -1:\n xavier_uniform_(m.weight....
[ 3, 5, 7, 9, 10 ]
# maze = [0, 3, 0, 1, -3] with open('./day_5/input.txt') as f: maze = f.readlines() f.close maze = [int(line.strip()) for line in maze] # I think I will just expand on the original functions # from now on rather than separating part one from two def escape_maze(maze): end = len(maze) - 1 step_counter = 0 ...
normal
{ "blob_id": "a4dfac7e15064d92c806a4e3f972f06e4dca6b11", "index": 5181, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef escape_maze(maze):\n end = len(maze) - 1\n step_counter = 0\n offset = 0\n while True:\n cur_index = offset\n offset = offset + maze[cur_index]\n ...
[ 0, 1, 2, 3, 4 ]
import numpy as np from scipy import stats from scipy import interpolate from math import factorial from scipy import signal """ A continuous wavelet transform based peak finder. Tested exclusively on Raman spectra, however, it should work for most datasets. Parameters ---------- lowerBound: The lowest value of the...
normal
{ "blob_id": "8f5d9918260e2f50fb229a7067f820a186101b99", "index": 1080, "step-1": "<mask token>\n\n\nclass _spectra:\n\n def __init__(self, x, y):\n self.x = x\n self.y = y\n <mask token>\n\n def y(self):\n return intensities\n\n\n<mask token>\n", "step-2": "<mask token>\n\n\nclass...
[ 3, 5, 6, 8, 11 ]
from math import ceil n, k = map(int, input().split()) d = list(map(int, input().split())) packs = [0]*k for i in d: packs[i%k] += 1 counter = packs[0]//2 if (k % 2) == 0: counter += packs[k//2]//2 for i in range(1, ceil(k/2)): counter += min(packs[i], packs[k-i]) print(counter*2)
normal
{ "blob_id": "2226382c494af33957a44d9f1682f7deacf574a2", "index": 2075, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in d:\n packs[i % k] += 1\n<mask token>\nif k % 2 == 0:\n counter += packs[k // 2] // 2\nfor i in range(1, ceil(k / 2)):\n counter += min(packs[i], packs[k - i])\nprint(cou...
[ 0, 1, 2, 3, 4 ]
# Authors: Robert Luke <mail@robertluke.net> # # License: BSD (3-clause) import numpy as np from mne.io.pick import _picks_to_idx def run_GLM(raw, design_matrix, noise_model='ar1', bins=100, n_jobs=1, verbose=0): """ Run GLM on data using supplied design matrix. This is a wrapper function fo...
normal
{ "blob_id": "8279c6d5f33d5580bef20e497e2948461a1de62c", "index": 7951, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef run_GLM(raw, design_matrix, noise_model='ar1', bins=100, n_jobs=1,\n verbose=0):\n \"\"\"\n Run GLM on data using supplied design matrix.\n\n This is a wrapper functio...
[ 0, 1, 2, 3, 4 ]
import sys import os from django.conf import settings BASE_DIR=os.path.dirname(__file__) settings.configure( DEBUG=True, SECRET_KEY='ki==706e99f0ps9w5s*!kx%1^=5jq_k1c&4r@#e&ng9=xlm5_', ROOT_URLCONF='sitebuilder.urls', MIDDLEWARE_CLASSES=(), INSTALLED_APPS=( 'django.contrib.staticfiles', 'django.contrib.webd...
normal
{ "blob_id": "d30e5e24dd06a4846fdde3c9fcac0a5dac55ad0d", "index": 5916, "step-1": "<mask token>\n", "step-2": "<mask token>\nsettings.configure(DEBUG=True, SECRET_KEY=\n 'ki==706e99f0ps9w5s*!kx%1^=5jq_k1c&4r@#e&ng9=xlm5_', ROOT_URLCONF=\n 'sitebuilder.urls', MIDDLEWARE_CLASSES=(), INSTALLED_APPS=(\n 'd...
[ 0, 1, 2, 3, 4 ]
# --- Do not remove these libs --- from freqtrade.strategy.interface import IStrategy from typing import Dict, List from functools import reduce from pandas import DataFrame # -------------------------------- import datetime import talib.abstract as ta import freqtrade.vendor.qtpylib.indicators as qtpylib import numpy...
normal
{ "blob_id": "7b047ba110732d1b0a749bcbbaa9b55306ca2071", "index": 6434, "step-1": "<mask token>\n\n\nclass ema(IStrategy):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask ...
[ 2, 4, 5, 6, 7 ]
#from tinyTensor.Node import Node import tinyTensor import plotly.plotly as py from graphviz import render #from tinyTensor.Operation import Operation def init(): global _default_graph _default_graph = None def postOrder(node): nodes_postorder = [] def recurse(node): if isinstan...
normal
{ "blob_id": "7bd2a29bff1e435cf813dd54109d7f4e17612425", "index": 474, "step-1": "<mask token>\n\n\nclass Graph:\n <mask token>\n\n def appendNode(self, node):\n if node.name in self.placeholderNames and node.isPlaceholder:\n raise Exception(\n 'Placeholder name \"{}\" is al...
[ 5, 7, 8, 9, 10 ]
from rest_framework import serializers from .models import * class MovieSerializer(serializers.Serializer): movie_name = serializers.ListField(child=serializers.CharField()) class FilmSerializer(serializers.ModelSerializer): class Meta: model = Movie fields = '__all__'
normal
{ "blob_id": "0509afdce0d28cc04f4452472881fe9c5e4fbcc4", "index": 7825, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass MovieSerializer(serializers.Serializer):\n <mask token>\n\n\nclass FilmSerializer(serializers.ModelSerializer):\n\n\n class Meta:\n model = Movie\n fields = ...
[ 0, 2, 3, 4 ]
print("Praktikum Programa Komputer ") print("Exercise 7.21") print("") print("===========================") print("Nama : Ivanindra Rizky P") print("NIM : I0320054") print("") print("===========================") print("") import random a = [23, 45, 98, 36] print('a = ', a) print('random 1') print('choice ...
normal
{ "blob_id": "6b731e329eec3947a17ef8ee8280f2ddf980c81c", "index": 7154, "step-1": "<mask token>\n", "step-2": "print('Praktikum Programa Komputer ')\nprint('Exercise 7.21')\nprint('')\nprint('===========================')\nprint('Nama : Ivanindra Rizky P')\nprint('NIM : I0320054')\nprint('')\nprint('===========...
[ 0, 1, 2, 3, 4 ]
import sys from Node import Node from PriorityQueue import PriorityQueue def Print(text): if text is None or len(text) == 0: print('invalid text.') print('--------------------------------------------------------------') return text_set = set() for i in text: t...
normal
{ "blob_id": "bcdd36b534fd3551de9cb40efc11581f4d95a002", "index": 9717, "step-1": "<mask token>\n\n\ndef Print(text):\n if text is None or len(text) == 0:\n print('invalid text.')\n print('--------------------------------------------------------------')\n return\n text_set = set()\n ...
[ 5, 7, 8, 9, 10 ]
with open('rosalind_ba3d.txt','r') as f: kmer_length = int(f.readline().strip()) seq = f.readline().strip() dict = {} for offset in range(len(seq)-kmer_length+1): prefix = seq[offset:offset+kmer_length-1] suffix = seq[offset+1:offset+kmer_length] if prefix in dict: dict[prefix].append(suffix) else: ...
normal
{ "blob_id": "050f060bb9d3d46f8b87c9802356bd0da8f926f8", "index": 6244, "step-1": "<mask token>\n", "step-2": "with open('rosalind_ba3d.txt', 'r') as f:\n kmer_length = int(f.readline().strip())\n seq = f.readline().strip()\n<mask token>\nfor offset in range(len(seq) - kmer_length + 1):\n prefix = seq[...
[ 0, 1, 2, 3 ]
import data import numpy as np import matplotlib.pyplot as plt import xgboost as xgb import pandas as pd import csv from matplotlib2tikz import save as tikz_save import trial_sets def print_stats(trial_id, dl): wrist_device, _, true_device = dl.load_oxygen(trial_id, iid=False) print("Length of Dataframe: " ...
normal
{ "blob_id": "836e2fd6eca7453ab7a3da2ecb21705552b5f627", "index": 5157, "step-1": "<mask token>\n\n\ndef print_stats(trial_id, dl):\n wrist_device, _, true_device = dl.load_oxygen(trial_id, iid=False)\n print('Length of Dataframe: ' + str(data.get_df_length(wrist_device)))\n wrist_oxygen = wrist_device.v...
[ 4, 6, 7, 8, 9 ]
from dagster import job, op @op def do_something(): return "foo" @job def do_it_all(): do_something()
normal
{ "blob_id": "53cf6e97c3b71b1063d5b6bce5aa444933b69809", "index": 3229, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\n@job\ndef do_it_all():\n do_something()\n", "step-3": "<mask token>\n\n\n@op\ndef do_something():\n return 'foo'\n\n\n@job\ndef do_it_all():\n do_something()\n", "step-4"...
[ 0, 1, 2, 3, 4 ]
import os import numpy as np import torch from torch import nn from torch.nn import functional as F import torch.utils.data as td import torchvision as tv import pandas as pd from PIL import Image from matplotlib import pyplot as plt from utils import imshow, NNRegressor class DnCNN(NNRegressor): def __init__(se...
normal
{ "blob_id": "9c60d82d42716abb036dc7297a2dca66f0508984", "index": 7626, "step-1": "<mask token>\n\n\nclass UDnCNN(NNRegressor):\n <mask token>\n <mask token>\n\n\nclass DUDnCNN(NNRegressor):\n\n def __init__(self, D, C=64):\n super(DUDnCNN, self).__init__()\n self.D = D\n k = [0]\n ...
[ 4, 7, 8, 10, 11 ]
#!/usr/bin/python from Tkinter import * root = Tk() root.title("Simple Graph") root.resizable(0,0) points = [] spline = 0 tag1 = "theline" def point(event): c.create_oval(event.x, event.y, event.x+1, event.y+1, fill="black", width="10.0") points.append(event.x) points.append(event.y) print(event.x) print(ev...
normal
{ "blob_id": "d88485e37d4df4cb0c8d79124d4c9c9ba18d124e", "index": 9074, "step-1": "#!/usr/bin/python\nfrom Tkinter import *\n\nroot = Tk()\n\nroot.title(\"Simple Graph\")\n\nroot.resizable(0,0)\n\npoints = []\n\nspline = 0\n\ntag1 = \"theline\"\n\ndef point(event):\n\tc.create_oval(event.x, event.y, event.x+1, ev...
[ 0 ]
txt = './KF_neko.txt.mecab' mapData = {} listData = [] with open('./KF31.txt', 'w') as writeFile: with open(txt, 'r') as readFile: for text in readFile: # print(text) # \tで区切って先頭だけ見る listData = text.split('\t') # 表層形 surface = listData[0] ...
normal
{ "blob_id": "778ee9a0ea7f57535b4de88a38cd741f2d46e092", "index": 6966, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith open('./KF31.txt', 'w') as writeFile:\n with open(txt, 'r') as readFile:\n for text in readFile:\n listData = text.split('\\t')\n surface = listData[0...
[ 0, 1, 2, 3 ]
n, m = map(int, input().split()) li = list(map(int, input().split())) max = 0 for i in range(0, n): for j in range(i+1, n): for k in range(j+1, n): tmp = li[i] + li[j] + li[k] if(tmp <= m and max < tmp): max = tmp print(max)
normal
{ "blob_id": "83d0a32ef2d365d17caa9d311c367ed5828559ac", "index": 4153, "step-1": "<mask token>\n", "step-2": "<mask token>\nfor i in range(0, n):\n for j in range(i + 1, n):\n for k in range(j + 1, n):\n tmp = li[i] + li[j] + li[k]\n if tmp <= m and max < tmp:\n m...
[ 0, 1, 2, 3 ]
# coding=UTF-8 """ View for managing accounts """ from django.contrib import messages from django.http import Http404, HttpResponse from django.shortcuts import redirect from django import forms from athena.core import render_to_response from athena.users.models import User from athena.users import must_be_admin def...
normal
{ "blob_id": "a01ca49c3fa8ea76de2880c1b04bf15ccd341edd", "index": 924, "step-1": "<mask token>\n\n\ndef klist(**kwargs):\n kwargs.update({'teachers': [x for x in User.objects.filter(status=1) if\n not x.is_demo()], 'admins': User.objects.filter(status=2)})\n return kwargs\n\n\n<mask token>\n\n\n@must...
[ 3, 6, 7, 8, 10 ]
#!/usr/bin/env python from __future__ import print_function from __future__ import division from __future__ import absolute_import # Workaround for segmentation fault for some versions when ndimage is imported after tensorflow. import scipy.ndimage as nd import argparse import numpy as np from pybh import tensorpack...
normal
{ "blob_id": "a283fd1e4098ea8bb3cc3580438c90e5932ba22f", "index": 5852, "step-1": "<mask token>\n\n\ndef dict_from_dataflow_generator(df):\n for sample in df.get_data():\n yield sample[0]\n\n\ndef split_lmdb_dataset(lmdb_input_path, lmdb_output_path1,\n lmdb_output_path2, split_ratio1, batch_size, sh...
[ 5, 6, 7, 8, 9 ]
# -*- encoding: utf-8 -*- """ views: vistas sistema recomendador @author Camilo Ramírez @contact camilolinchis@gmail.com camilortte@hotmail.com @camilortte on Twitter @copyright Copyright 2014-2015, RecomendadorUD @license GPL @date 2014-10...
normal
{ "blob_id": "c6cbd4d18363f00b73fac873ba45d6063bee7e64", "index": 3074, "step-1": "# -*- encoding: utf-8 -*-\n\"\"\"\n \n views: vistas sistema recomendador\n\n @author Camilo Ramírez\n @contact camilolinchis@gmail.com \n camilortte@hotmail.com\n @camilortte on Twi...
[ 0 ]
# -coding: UTF-8 -*- # @Time : 2020/06/24 20:01 # @Author: Liangping_Chen # @E-mail: chenliangping_2018@foxmail.com import requests def http_request(url,data,token=None,method='post'): header = {'X-Lemonban-Media-Type': 'lemonban.v2', 'Authorization':token} #判断是get请求还是post请求 if method=='ge...
normal
{ "blob_id": "dd7c7fa6493a43988e1c8079797f6ff9b4d239dd", "index": 4672, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef http_request(url, data, token=None, method='post'):\n header = {'X-Lemonban-Media-Type': 'lemonban.v2', 'Authorization': token}\n if method == 'get':\n result = reque...
[ 0, 1, 2, 3, 4 ]
lista = [2, 3.2, 4, 52, 6.25] s = sum(lista) print(s)
normal
{ "blob_id": "05aa8eac846154024d25d639da565135e41403c2", "index": 9611, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(s)\n", "step-3": "lista = [2, 3.2, 4, 52, 6.25]\ns = sum(lista)\nprint(s)\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
''' Statistics models module. This module contains the database models for the Statistics class and the StatisticsCategory class. @author Hubert Ngu @author Jason Hou ''' from django.db import models class Statistics(models.Model): ''' Statistics model class. This represents a single tuple in the ...
normal
{ "blob_id": "728f9402b3ce4b297be82b3ba1a17c4180ac7c0d", "index": 8839, "step-1": "<mask token>\n\n\nclass Statistics(models.Model):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n...
[ 4, 5, 6, 7, 8 ]
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True, reshape=False) def fully_connected(prev_layer, num_units, batch_norm, is_training=False): layer = tf.layers.dense(prev_layer, num_units, use_bias=False, activation=None)...
normal
{ "blob_id": "17b3f51779bda5a48c4d77c35d6bbdd2aadb13cd", "index": 1432, "step-1": "<mask token>\n\n\ndef fully_connected(prev_layer, num_units, batch_norm, is_training=False):\n layer = tf.layers.dense(prev_layer, num_units, use_bias=False,\n activation=None)\n if batch_norm:\n layer = tf.laye...
[ 1, 3, 4, 5, 6 ]
#!/usr/bin/env python # coding:utf-8 """ 200. 岛屿数量 难度 中等 给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量。一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的。你可以假设网格的四个边均被水包围。 示例 1: 输入: 11110 11010 11000 00000 输出: 1 示例 2: 输入: 11000 11000 00100 00011 输出: 3 """ # ===============================================================================...
normal
{ "blob_id": "b46f19708e9e2a1be2bbd001ca6341ee7468a60d", "index": 7147, "step-1": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n directions = [(-1, 0), (0, 1), (1, 0), (0, -1)]\n\n def numIslands(self, grid):\n \"\"\"\n :type grid: List[List[str]]\n :rtype: int\n ...
[ 3, 5, 7, 10, 12 ]
import os import platform import _winreg def gid(x): find=x winreg = _winreg REG_PATH1 = r"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" REG_PATH2 = r"SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" registry_key = winreg.OpenKey( winreg.HKEY_LOCAL_MACHINE, REG_PATH1, 0, win...
normal
{ "blob_id": "a444e215b64b3a2d7f736e38227b68c1a1b952a0", "index": 7133, "step-1": "import os\nimport platform\nimport _winreg\n\n\ndef gid(x):\n find=x\n winreg = _winreg\n REG_PATH1 = r\"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\"\n REG_PATH2 = r\"SOFTWARE\\WOW6432Node\\Microsoft\\Windo...
[ 0 ]
from mpi4py import MPI import matplotlib from tmm import coh_tmm import pandas as pd import os from numpy import pi from scipy.interpolate import interp1d from joblib import Parallel, delayed import numpy as np import glob import matplotlib.pyplot as plt import pickle as pkl import seaborn as sns from scipy.optimize im...
normal
{ "blob_id": "f23bc0c277967d8e7a94a49c5a81ed5fb75d36cc", "index": 9327, "step-1": "<mask token>\n\n\nclass Memory:\n <mask token>\n <mask token>\n\n\n<mask token>\n\n\nclass DesignTracker:\n\n def __init__(self, epochs, **kwargs):\n \"\"\"\n This class tracks the best designs discovered.\n ...
[ 11, 16, 20, 22, 26 ]
# import time module, Observer, FileSystemEventHandler import os import time from watchdog.observers import Observer from watchdog.events import FileSystemEventHandler import pyAesCrypt import logging logging.basicConfig(filename="Decryptor.log", level=logging.INFO, format="%(asctime)s:%(filename)s:...
normal
{ "blob_id": "6261d06ac7bdcb3ae25cd06338c4c41c3c5f5023", "index": 7615, "step-1": "<mask token>\n\n\nclass OnMyWatch:\n <mask token>\n <mask token>\n\n def run(self):\n event_handler = Handler()\n self.observer.schedule(event_handler, self.watchDirectory,\n recursive=True)\n ...
[ 4, 7, 8, 10, 11 ]
# -*- coding: utf-8 - # # This file is part of gaffer. See the NOTICE for more information. import os from .base import Command from ...httpclient import Server class Load(Command): """\ Load a Procfile application to gafferd ====================================== This command allows you...
normal
{ "blob_id": "eb5256543d6095668d6eeaf6cfdc9f744d7c73c5", "index": 2267, "step-1": "<mask token>\n\n\nclass Load(Command):\n <mask token>\n <mask token>\n <mask token>\n\n def find_groupname(self, g, s):\n tries = 0\n while True:\n groups = s.groups()\n if g not in g...
[ 2, 3, 5, 6, 7 ]
# (C) Copyright IBM 2020. # # This code is licensed under the Apache License, Version 2.0. You may # obtain a copy of this license in the LICENSE.txt file in the root directory # of this source tree or at http://www.apache.org/licenses/LICENSE-2.0. # # Any modifications or derivative works of this code must retain this...
normal
{ "blob_id": "2e2de50a7d366ca1a98d29b33ed157a1e8445ada", "index": 3523, "step-1": "<mask token>\n\n\ndef git_short_hash():\n try:\n git_str = '+' + os.popen('git log -1 --format=\"%h\"').read().strip()\n except:\n git_str = ''\n else:\n if git_str == '+':\n git_str = ''\n ...
[ 2, 3, 4, 5, 6 ]
import logging from abc import ABC from thraxisgamespatterns.application.handler_map_factory import TGHandlerMapFactory from thraxisgamespatterns.eventhandling.event_distributor import TGEventDistributor from thraxisgamespatterns.factories.logging_rule_engine_factory import TGLoggingRuleEngineFactory class TGAbstract...
normal
{ "blob_id": "d499b4e189a0c3c6efa6a07871dbc6c2996a2dcb", "index": 2245, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\nclass TGAbstractRegistry(ABC):\n <mask token>\n", "step-3": "<mask token>\n\n\nclass TGAbstractRegistry(ABC):\n\n def __init__(self):\n self.rule_engine = TGLoggingRule...
[ 0, 1, 2, 3 ]
# Question link: https://www.hackerrank.com/challenges/30-scope/problem # Code section: def computeDifference(self): # Add your code here self.maximumDifference = -111111 for i in range(0,len(self.__elements)-1): for j in range(i+1, len(self.__elements)): diff = abs(self._...
normal
{ "blob_id": "eb90912d09fca52a43b28ec4c988e3658ddfc219", "index": 605, "step-1": "# Question link: https://www.hackerrank.com/challenges/30-scope/problem\n# Code section:\n\n def computeDifference(self):\n # Add your code here\n self.maximumDifference = -111111\n for i in range(0,len(self.__elem...
[ 0 ]
import numpy as np import pandas as pd import matplotlib.pyplot as plt from scipy import stats import datetime #takes in a sorted data frame holding the actuals, the predicted values (sorted descending) and the percentile of each obsevation #and returns a new dataframe with all of the appropriate calculations ...
normal
{ "blob_id": "8e71ea23d04199e8fb54099c404c5a4e9af6c4b1", "index": 9336, "step-1": "<mask token>\n\n\ndef lift_calculations(df):\n df['sample_num'] = range(len(df))\n df['actual_sum'] = df['actual'].cumsum()\n df['per_sample_covered'] = (df['sample_num'] + 1) * 100 / len(df)\n df['per_pos_captured'] = ...
[ 5, 7, 8, 10, 11 ]
import main from pytest import approx def test_duration(): ins = main.convert() names = ins.multiconvert() for name in names: induration, outduration = ins.ffprobe(name[0], name[1]) assert induration == approx(outduration) induration, outduration = ins.ffprobe(name[0], name[2]) ...
normal
{ "blob_id": "92c247b827d2ca4dce9b631a2c09f2800aabe216", "index": 6129, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef test_duration():\n ins = main.convert()\n names = ins.multiconvert()\n for name in names:\n induration, outduration = ins.ffprobe(name[0], name[1])\n assert...
[ 0, 1, 2, 3, 4 ]
import veil_component with veil_component.init_component(__name__): from .material import list_category_materials from .material import list_material_categories from .material import list_issue_materials from .material import list_issue_task_materials from .material import get_material_image_url ...
normal
{ "blob_id": "acad268a228b544d60966a8767734cbf9c1237ac", "index": 9979, "step-1": "<mask token>\n", "step-2": "<mask token>\nwith veil_component.init_component(__name__):\n from .material import list_category_materials\n from .material import list_material_categories\n from .material import list_issue_...
[ 0, 1, 2, 3 ]
#!/usr/bin/env python # coding: utf-8 import os os.environ['CUDA_VISIBLE_DEVICES'] = '0' import tensorflow as tf print(tf.__version__) print(tf.keras.__version__) print(tf.__path__) import numpy as np from tqdm import tqdm, tqdm_notebook from utils import emphasis import tensorflow.keras.backend as K from tensorflow....
normal
{ "blob_id": "08a0ab888886184f7447465508b6494b502821ea", "index": 8903, "step-1": "#!/usr/bin/env python\n# coding: utf-8\n\nimport os\nos.environ['CUDA_VISIBLE_DEVICES'] = '0'\nimport tensorflow as tf\nprint(tf.__version__)\nprint(tf.keras.__version__)\nprint(tf.__path__)\nimport numpy as np\n\nfrom tqdm import ...
[ 0 ]
# #writing a file # fout = open('Session14/output.txt', 'w') # line1 = "How many roads must a man walk down\n" # fout.write(line1) # line2 = "Before you call him a man?\n" # fout.write(line2) # #when you are done writing, you should close the file. # fout.close() # #if you dont close the file, it gets closed for you wh...
normal
{ "blob_id": "de1262da699a18266ad8673597391f625783a44d", "index": 5721, "step-1": "<mask token>\n\n\ndef walk2(dirname):\n \"\"\"Prints the names of all files in \n dirname and its subdirectories.\n\n dirname: string name of directory\n \"\"\"\n for root, dirs, files in os.walk(dirname):\n f...
[ 1, 2, 3, 4, 5 ]
# Adjust figure when using plt.gcf ax = fig.gca() ax.set_aspect('equal')
normal
{ "blob_id": "24246427e2fde47bbc9d068605301f54c6ecbae5", "index": 1797, "step-1": "<mask token>\n", "step-2": "<mask token>\nax.set_aspect('equal')\n", "step-3": "ax = fig.gca()\nax.set_aspect('equal')\n", "step-4": "# Adjust figure when using plt.gcf\nax = fig.gca()\nax.set_aspect('equal')\n", "step-5": ...
[ 0, 1, 2, 3 ]
import logging import os import time import urllib from collections import namedtuple from statistics import mean from urllib.request import urlopen import bs4 import regex as re from tika import parser from scipy.stats import ks_2samp import config from TFU.trueformathtml import TrueFormatUpmarkerHTML from TFU.truefo...
normal
{ "blob_id": "4d2cb3e0bdd331a1de7f07eb0109f02c9cf832a8", "index": 7441, "step-1": "<mask token>\n\n\nclass PaperReader:\n <mask token>\n\n def __init__(self, _threshold=0.001, _length_limit=20000):\n with open(config.wordlist, 'r') as f:\n self.wordlist = [w for w in list(f.readlines()) if...
[ 8, 10, 11, 12, 13 ]
# Example solution for HW 5 # %% # Import the modules we will use import os import numpy as np import pandas as pd import matplotlib.pyplot as plt # %% # ** MODIFY ** # Set the file name and path to where you have stored the data filename = 'streamflow_week5.txt' #modified filename filepath = os.path.join('../data', ...
normal
{ "blob_id": "5024db0538f0022b84c203882df9c35979ba978a", "index": 4571, "step-1": "<mask token>\n", "step-2": "<mask token>\nprint(os.getcwd())\nprint(filepath)\n<mask token>\nprint(data.tail(14))\nprint(data.tail(14).describe())\nprint(data.tail(7).describe())\n<mask token>\nprint(data_2019['flow'].describe())...
[ 0, 1, 2, 3, 4 ]
import random #importing the random library from python answers = ["It is certain", "Without a doubt", "Yes, definitely", "You may rely on it", "As I see it, yes", "Most likely", "Outlook good", "Yes", "Signs point to yes", "Reply hazy, try again", "Ask again later", "Better not tell yo...
normal
{ "blob_id": "b5e9af166f3b55e44d9273077e5acd05b1fd68fa", "index": 2335, "step-1": "<mask token>\n", "step-2": "<mask token>\nwhile ans:\n ans = input('Ask the magic 8 ball a question. (Press enter to leave): \\n')\n print(random.choice(answers))\n", "step-3": "<mask token>\nanswers = ['It is certain', '...
[ 0, 1, 2, 3, 4 ]
# ---------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License # ---------------------------------------------------------------------- """Contains the Plugin object""" import itertools import os import sys ...
normal
{ "blob_id": "d8befc4a79176aefcccd3dceddf04ca965601e5c", "index": 2856, "step-1": "<mask token>\n\n\n@Interface.staticderived\nclass Plugin(PluginBase):\n <mask token>\n <mask token>\n\n @staticmethod\n @Interface.override\n def Generate(open_file_func, global_custom_structs, global_custom_enums,\n...
[ 8, 9, 10, 11, 15 ]
import csv import sys if len(sys.argv[1:]) == 5 : (name_pos, start_pos, length_pos, first_note_pos, second_note_pos) = [int(pos) for pos in sys.argv[1:]] elif len(sys.argv[1:]) == 4 : (name_pos, start_pos, length_pos, first_note_pos) = [int(pos) for pos in sys.argv[1:]] second_note_pos = None e...
normal
{ "blob_id": "d7653a205fb8203fed4009846780c63dd1bcb505", "index": 3603, "step-1": "<mask token>\n", "step-2": "<mask token>\nif len(sys.argv[1:]) == 5:\n name_pos, start_pos, length_pos, first_note_pos, second_note_pos = [int\n (pos) for pos in sys.argv[1:]]\nelif len(sys.argv[1:]) == 4:\n name_pos...
[ 0, 1, 2, 3, 4 ]
from gerador_senha import gerar_senha gerar_senha()
normal
{ "blob_id": "e81da535408cc36655328b37ca99b4f775f3a78e", "index": 8435, "step-1": "<mask token>\n", "step-2": "<mask token>\ngerar_senha()\n", "step-3": "from gerador_senha import gerar_senha\ngerar_senha()\n", "step-4": null, "step-5": null, "step-ids": [ 0, 1, 2 ] }
[ 0, 1, 2 ]
import logging from .const import ( DOMAIN, CONF_SCREENS ) from typing import Any, Callable, Dict, Optional from homeassistant.helpers.entity import Entity from homeassistant.helpers.typing import ( ConfigType, DiscoveryInfoType, HomeAssistantType, ) from homeassistant.core import callback from home...
normal
{ "blob_id": "6f1b08a5ae1a07a30d89f3997461f4f97658f364", "index": 4920, "step-1": "<mask token>\n\n\nclass StateConverters:\n <mask token>\n <mask token>\n <mask token>\n\n\nclass DGUSScreen(Entity):\n\n def __init__(self, hass, screen):\n self._state = None\n self._hass = hass\n ...
[ 7, 10, 11, 13, 14 ]
def IsPn(a): temp = (24*a+1)**0.5+1 if temp % 6 == 0: return True else: return False def IsHn(a): temp = (8*a+1)**0.5+1 if temp % 4 == 0: return True else: return False def CalTn(a): return (a**2+a)/2 i = 286 while 1: temp = CalTn(i) if IsHn(temp) and IsPn(temp): break i += 1 print i,temp
normal
{ "blob_id": "7474e60feff61c4ef15680ecc09d910e6e1d6322", "index": 4603, "step-1": "def IsPn(a):\n\ttemp = (24*a+1)**0.5+1\n\tif temp % 6 == 0:\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef IsHn(a):\n\ttemp = (8*a+1)**0.5+1\n\tif temp % 4 == 0:\n\t\treturn True\n\telse:\n\t\treturn False\n\ndef CalTn(a):\n\tr...
[ 0 ]
""" Given two strings, a and b, that may or may not be of the same length, determine the minimum number of character deletions required to make a and b anagrams. Any characters can be deleted from either of the strings. """ from collections import Counter import math import os import random import re import sys # Com...
normal
{ "blob_id": "3b15767988f1d958fc456f7966f425f93deb9017", "index": 8302, "step-1": "<mask token>\n", "step-2": "<mask token>\n\n\ndef makeAnagram(a, b):\n ct_a = Counter(a)\n ct_b = Counter(b)\n ct_a.subtract(ct_b)\n return sum(abs(i) for i in ct_a.values())\n\n\n<mask token>\n", "step-3": "<mask t...
[ 0, 1, 2, 3, 4 ]