code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
#2) write a program to make banking system develop business logic
#in one module and call functionality in another .py file
class Customer: #user defined class
def __init__(self,name,phoneno,address,pin,accno,balance) : #constructor with multiple arguments
self._name=name
self._pno=phoneno
... | normal | {
"blob_id": "cf5a9b8dad5a02610fa5ce2a849b6f9fc50a0aa8",
"index": 1872,
"step-1": "class Customer:\n\n def __init__(self, name, phoneno, address, pin, accno, balance):\n self._name = name\n self._pno = phoneno\n self._add = address\n self._pin = pin\n self._acc = accno\n ... | [
5,
6,
7,
8,
9
] |
##class Human:
## pass
##hb1-HB("Sudhir")
##hb2=HB("Sreenu")
class Student:
def __init__(self,name,rollno):
self.name=name
self.rollno=rollno
std1=Student("Siva",123)
| normal | {
"blob_id": "97656bca3ce0085fb2f1167d37485fb7ee812730",
"index": 4825,
"step-1": "<mask token>\n",
"step-2": "class Student:\n <mask token>\n\n\n<mask token>\n",
"step-3": "class Student:\n\n def __init__(self, name, rollno):\n self.name = name\n self.rollno = rollno\n\n\n<mask token>\n",... | [
0,
1,
2,
3,
4
] |
tp = 1, 2, 3
print(tp + (4,))
| normal | {
"blob_id": "8e9db58488f6ee8aa0d521a19d9d89504d119076",
"index": 6689,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(tp + (4,))\n",
"step-3": "tp = 1, 2, 3\nprint(tp + (4,))\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
1,
2
]
} | [
0,
1,
2
] |
##This script looks at a path for a dated file, then parses it by row into two different files/folders based on fields being blank within each row.
import os.path
from datetime import date
##sets date variables/format
today = date.today()
todayFormatted = today.strftime("%m%d%Y")
print(todayFormatted)
##Se... | normal | {
"blob_id": "07a546928df1acfedf7a7735dc813de9da8373e0",
"index": 1275,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(todayFormatted)\n<mask token>\nos.chdir(basepath)\nif not os.path.isfile(filename):\n print('File does not exist.')\nelse:\n with open(filename) as f:\n content = f.rea... | [
0,
2,
3,
4,
5
] |
# coding=utf-8
# flake8:noqa
from .string_helper import (
camelize, uncamelize,
camelize_for_dict_key, camelize_for_dict_key_in_list,
uncamelize_for_dict_key, uncamelize_for_dict_key_in_list
)
from .datetime_helper import datetime_format
from .class_helper import override
from .paginate import paginate2di... | normal | {
"blob_id": "64a590d31be98f7639034662b2a322e5572cc1ae",
"index": 3554,
"step-1": "<mask token>\n",
"step-2": "from .string_helper import camelize, uncamelize, camelize_for_dict_key, camelize_for_dict_key_in_list, uncamelize_for_dict_key, uncamelize_for_dict_key_in_list\nfrom .datetime_helper import datetime_fo... | [
0,
1,
2
] |
from django.shortcuts import render_to_response
from mousedb.animal.models import Animal, Strain
from django.contrib.auth.decorators import login_required
from django.template import RequestContext
from django.db import connection
import datetime
@login_required
def todo(request):
eartag_list = Animal.objects.filter(... | normal | {
"blob_id": "89518f43934710ef2e7471a91128e20d2306d6f6",
"index": 9291,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@login_required\ndef todo(request):\n eartag_list = Animal.objects.filter(MouseID__isnull=True, Alive=True\n ).order_by('Strain', 'Background', 'Rack', 'Cage')\n genotype... | [
0,
1,
2,
3,
4
] |
def fibonacci(num):
f_1 = 0
f_2 = 1
answer = 0
for i in range(num-1):
answer = f_1 + f_2
f_1 = f_2
f_2 = answer
return answer
# 아래는 테스트로 출력해 보기 위한 코드입니다.
print(fibonacci(3))
| normal | {
"blob_id": "c3d0a9bdbfd5b6f2b960ee2c1f11ec4acf508310",
"index": 8458,
"step-1": "<mask token>\n",
"step-2": "def fibonacci(num):\n f_1 = 0\n f_2 = 1\n answer = 0\n for i in range(num - 1):\n answer = f_1 + f_2\n f_1 = f_2\n f_2 = answer\n return answer\n\n\n<mask token>\n",... | [
0,
1,
2,
3
] |
"""
Naive Bayes Class
- Bernoulli Naive Bayes
- Multinomial Naive Bayes
- Gaussian Naive Bayes
Arthor: Zhenhuan(Steven) Sun
"""
import numpy as np
class BernoulliNB:
def __init__(self, k=1.0, binarize=0.0):
# Laplace Smoothing Factor
self.K = k
# the degree... | normal | {
"blob_id": "5dfe86d654e4184bab4401f8b634326996e42e9c",
"index": 2646,
"step-1": "<mask token>\n\n\nclass MultinomialNB:\n <mask token>\n\n def fit(self, X, y):\n X_separated_by_class = [[x for x, t in zip(X, y) if t == c] for c in\n np.unique(y)]\n self.n_classes = len(np.unique(y... | [
8,
9,
14,
15,
16
] |
from scheme import *
from tests.util import *
class TestDateTime(FieldTestCase):
def test_instantiation(self):
with self.assertRaises(TypeError):
DateTime(minimum=True)
with self.assertRaises(TypeError):
DateTime(maximum=True)
def test_processing(self):
field ... | normal | {
"blob_id": "92b22ea23ad0cf4e16c7d19d055b7ec152ca433a",
"index": 5191,
"step-1": "<mask token>\n\n\nclass TestDateTime(FieldTestCase):\n <mask token>\n <mask token>\n\n def test_utc_processing(self):\n field = DateTime(utc=True)\n self.assert_processed(field, None)\n self.assert_not... | [
3,
7,
8,
9
] |
# This file is part of the printrun suite.
#
# printrun is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# printrun is distributed in ... | normal | {
"blob_id": "3cc473f6bb4b2e1dd806edb8b096a6118fe7056a",
"index": 7202,
"step-1": "<mask token>\n\n\nclass NoViz:\n <mask token>\n <mask token>\n <mask token>\n\n def addfile(self, *a, **kw):\n pass\n\n def addgcode(self, *a, **kw):\n pass\n\n def addgcodehighlight(self, *a, **kw):... | [
9,
10,
11,
15,
16
] |
import os
import h5py
import numpy as np
import torch
from datasets.hdf5 import get_test_datasets
from unet3d import utils
from unet3d.config import load_config
from unet3d.model import get_model
logger = utils.get_logger('UNet3DPredictor')
def predict(model, hdf5_dataset, config):
"""
Return prediction ma... | normal | {
"blob_id": "6fba773025268d724283e510a03d0592282adb0a",
"index": 1780,
"step-1": "<mask token>\n\n\ndef save_predictions(prediction_maps, output_file, dataset_names):\n \"\"\"\n Saving probability maps to a given output H5 file. If 'average_channels'\n is set to True average the probability_maps across ... | [
2,
6,
7,
8,
9
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##########
# websocket-client
# https://pypi.python.org/pypi/websocket-client/
# sudo -H pip install websocket-client
#####
from websocket import create_connection
ws = create_connection( "ws://192.168.1.132:81/python" )
msg = '#0000FF'
print "Envoi d’un message à l’ESP"... | normal | {
"blob_id": "3b26181097025add5919e752aa53e57eea49c943",
"index": 4923,
"step-1": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n##########\n# websocket-client\n# https://pypi.python.org/pypi/websocket-client/\n# sudo -H pip install websocket-client\n#####\n\nfrom websocket import create_connection\nws = crea... | [
0
] |
import os
WOO_HOST = os.environ.get('WOO_HOST')
#WooCommerce key credentials
WOO_CONSUMER_KEY = os.environ.get('WOO_CONSUMER_KEY')
WOO_CONSUMER_SECRET = os.environ.get('WOO_CONSUMER_SECRET')
#XML feed fields and settings
XML_FEED_FILENAME = os.environ.get('XML_FEED_FILENAME', 'feedXML')
XML_SITE_NAME = os.environ.ge... | normal | {
"blob_id": "386fa51b9b285d36c75d6446f9348f6713e0dbaa",
"index": 2794,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntry:\n from local_settings import *\nexcept ImportError:\n pass\nif SENTRY_URL:\n import sentry_sdk\n sentry_sdk.init(SENTRY_URL)\n",
"step-3": "<mask token>\nWOO_HOST = os.... | [
0,
1,
2,
3,
4
] |
import numpy as np
import pandas as pd
from unrar import rarfile
import numpy as np
import pandas as pd
import tushare as ts
import os
year_month='201911'
contract_kind='NI'
rar_data_file_path='C:/Users/lenovo/Documents/WeChat Files/yiranli13/FileStorage/File/2020-01/'
main_code_path='C:/Users/lenovo/Documents/WeCha... | normal | {
"blob_id": "1c2967c26c845281ceb46cc1d8c06768298ef6b6",
"index": 9407,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef renew_commodity_future(year_month: str, contract_kind: str,\n main_code_path: str, rar_data_file_path: str, clean_data_path: str,\n time_range_path: str, end_date: str, comm... | [
0,
1,
2,
3,
4
] |
from rest_framework import serializers
from urlshortner.models import UrlShortnerModel
from urlshortner.constants import HOST
class UrlShortRequest(serializers.Serializer):
url = serializers.CharField(required=True, max_length=255) # Long Url
expiry = serializers.DateTimeField(required=False)
class UrlLong... | normal | {
"blob_id": "6c16afe89d5d0fd6aa6911e3de9e9cebb57bf35e",
"index": 1752,
"step-1": "<mask token>\n\n\nclass UrlLongRequest(serializers.Serializer):\n url = serializers.CharField(required=True, max_length=64)\n\n def validate_url(self, url):\n if url.startswith(HOST):\n return url\n e... | [
4,
5,
6,
7,
8
] |
# SPDX-License-Identifier: Apache-2.0
# Licensed to the Ed-Fi Alliance under one or more agreements.
# The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
# See the LICENSE and NOTICES files in the project root for more information.
import json
from typing import Dict
from pandas import... | normal | {
"blob_id": "d6a760774b45454c959c2932d7b28deee7f81872",
"index": 318,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef submissions_to_user_submission_activities_dfs(submissions_df: DataFrame\n ) ->Dict[str, DataFrame]:\n \"\"\"\n Convert a Submission API DataFrame to a Dict of UserActivity... | [
0,
1,
2,
3,
4
] |
import pandas as pd
iris_nan = pd.read_csv("MLData/iris_nan.csv")
iris_nan.head()
Y = iris_nan["class"].values
X = iris_nan.drop("class", axis=1)
# Our iris dataframe presents some NaN values, and we need to fix that.
# We got some methods to apply on a pandas dataframe:
# 1: Drop records presenting a NaN value: We... | normal | {
"blob_id": "00429a16ac009f6f706ef11bc29b0aec77b9ebe6",
"index": 9536,
"step-1": "<mask token>\n",
"step-2": "<mask token>\niris_nan.head()\n<mask token>\niris_nan.dropna()\niris_nan.dropna(axis=1)\n<mask token>\niris_nan.fillna(mean_replace)\n<mask token>\niris_nan.fillna(median_replace)\n<mask token>\niris_n... | [
0,
1,
2,
3,
4
] |
"""Defines all Rady URL."""
from django.conf.urls import url, include
from django.contrib import admin
apiv1_urls = [
url(r"^users/", include("user.urls")),
url(r"^meetings/", include("meeting.urls")),
url(r"^docs/", include("rest_framework_docs.urls")),
url(r"^auth/", include("auth.urls")),
url(... | normal | {
"blob_id": "aa00e4569aeae58e3f0ea1a8326e35c0776f7727",
"index": 4849,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napiv1_urls = [url('^users/', include('user.urls')), url('^meetings/',\n include('meeting.urls')), url('^docs/', include(\n 'rest_framework_docs.urls')), url('^auth/', include('auth.... | [
0,
1,
2,
3
] |
from random import random
def random_numbers():
print('start generator')
while True:
val = random()
print(f'will yield {val}')
yield val
def run_random_numbers():
print(f'{random_numbers=}')
rnd_gen = random_numbers()
print(f'{rnd_gen=}')
print(f'{next(rnd_gen)=}')
... | normal | {
"blob_id": "e5979aeb7cff0e2a75966924382bae87aebcfcb2",
"index": 3312,
"step-1": "<mask token>\n\n\ndef exercise_gen(ret_val, times):\n \"\"\"Return `ret_value` `times` times.\n If generator will receive some value from outside, update `ret_value`\"\"\"\n\n\ndef exercise1():\n \"\"\"Make it pass\"\"\"\n... | [
2,
4,
6,
9,
10
] |
import datetime # to add timestamps on every block in blockchain
import hashlib # library that is ued to hash the block
import json # to communicate in json data
# Flask to implement webservices jsonify to see the jsop message/response
# request help us to connect all the nodes of the blockchain together froming the... | normal | {
"blob_id": "e85d3660968410b83b14ba610150c0c8cc880119",
"index": 9191,
"step-1": "<mask token>\n\n\nclass Blockchain:\n\n def __init__(self):\n self.chain = []\n self.transactions = []\n self.create_block(proof=0, previous_hash='0')\n self.nodes = set()\n\n def create_block(self... | [
6,
15,
17,
19,
20
] |
from enum import Enum
import os
from pathlib import Path
from typing import Optional
from loguru import logger
import pandas as pd
from pydantic.class_validators import root_validator, validator
from tqdm import tqdm
from zamba.data.video import VideoLoaderConfig
from zamba.models.config import (
ZambaBaseModel,
... | normal | {
"blob_id": "9d8d8e97f7d3dbbb47dc6d4105f0f1ffb358fd2f",
"index": 6977,
"step-1": "<mask token>\n\n\nclass DensePoseConfig(ZambaBaseModel):\n <mask token>\n video_loader_config: VideoLoaderConfig\n output_type: DensePoseOutputEnum\n render_output: bool = False\n embeddings_in_json: bool = False\n ... | [
4,
5,
7,
8,
9
] |
import requests
import datetime
from yahoo_finance import Share
def getYahooStock(ticker, date1, date2):
companyData = Share(ticker)
dataList = companyData.get_historical(date1, date2)
endData = dataList[0];
startData = dataList[len(dataList) - 1];
print ticker, float(startData['Open']), float(endD... | normal | {
"blob_id": "07854dc9e0a863834b8e671d29d5f407cdd1c13e",
"index": 9599,
"step-1": "import requests\nimport datetime\nfrom yahoo_finance import Share\n\ndef getYahooStock(ticker, date1, date2):\n companyData = Share(ticker)\n dataList = companyData.get_historical(date1, date2)\n endData = dataList[0];\n ... | [
0
] |
import datetime
now = datetime.datetime.now()
# Printing value of now.
print ("Time now : ", now)
| normal | {
"blob_id": "0110d26e17a5402c22f519d0aeb2aacca3279d00",
"index": 7792,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Time now : ', now)\n",
"step-3": "<mask token>\nnow = datetime.datetime.now()\nprint('Time now : ', now)\n",
"step-4": "import datetime\nnow = datetime.datetime.now()\nprint('T... | [
0,
1,
2,
3,
4
] |
from django.apps import AppConfig
class QuadraticEquationsSolverConfig(AppConfig):
name = 'quadratic_equations_solver'
| normal | {
"blob_id": "730fc527f3d2805559e8917e846b0b13f4a9f6ee",
"index": 2316,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass QuadraticEquationsSolverConfig(AppConfig):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass QuadraticEquationsSolverConfig(AppConfig):\n name = 'quadratic_equations... | [
0,
1,
2,
3
] |
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#Modules externes
import os
import re
import logging
import csv
import xml.etree.ElementTree as ET
from chardet import detect
#Modules maison
from Abes_Apis_Interface.AbesXml import AbesXml
from Alma_Apis_Interface import Alma_Apis_Records
from Alma_Apis_Interface import Alma... | normal | {
"blob_id": "1f94ef0aae1128089b34fc952766cc3927677cdf",
"index": 5698,
"step-1": "<mask token>\n\n\ndef get_encoding_type(file):\n with open(file, 'rb') as f:\n rawdata = f.read()\n return detect(rawdata)['encoding']\n\n\ndef item_change_location(item, location, call):\n \"\"\"Change location and... | [
3,
4,
5,
6,
7
] |
#game that has a timer and you need to stop the timer
#with 0 at the end.
import simplegui
#necessary global variables
#time for the timer
time = 0
#the display for the timer(string form)
watch = ''
#tries and correct presses
tries = 0
correct = 0
#changes time to watch(number to string of form A:B... | normal | {
"blob_id": "b3c22b4a453aa55da980b090df2749ff9f1066e6",
"index": 5932,
"step-1": "<mask token>\n\n\ndef increment():\n global time\n time = time + 1\n\n\ndef start():\n timer.start()\n\n\ndef stop():\n global correct, tries\n timer.stop()\n if time != 0:\n tries = tries + 1\n if t... | [
4,
5,
6,
8,
10
] |
import tensorflow as tf
from keras import layers, Model, Input
from keras.utils import Progbar, to_categorical
from keras.datasets.mnist import load_data
import numpy as np
import matplotlib.pyplot as plt
import config
import datetime
img_height, img_width, _ = config.IMAGE_SHAPE
(X, Y), (_, _) = load_data()
X = X.re... | normal | {
"blob_id": "e265b2b2ccc0841ccb8b766de4ae2a869f2d280d",
"index": 8326,
"step-1": "<mask token>\n\n\nclass Generator(Model):\n\n def __init__(self, name):\n super(Generator, self).__init__(name=name)\n self.dense = layers.Dense(7 * 7 * 128)\n self.conv1 = layers.Conv2DTranspose(128, kernel... | [
8,
12,
13,
15,
19
] |
#Problem available at: https://www.hackerrank.com/challenges/weather-observation-station-6/problem
SELECT DISTINCT CITY from STATION where substr(CITY,1,1) in ('a','e','i','o','u'); | normal | {
"blob_id": "1cba7889370cc7de47bb5cd1eaeadfece056e68a",
"index": 5912,
"step-1": "#Problem available at: https://www.hackerrank.com/challenges/weather-observation-station-6/problem\nSELECT DISTINCT CITY from STATION where substr(CITY,1,1) in ('a','e','i','o','u');",
"step-2": null,
"step-3": null,
"step-4"... | [
0
] |
"""
module rational number
"""
def _gcd(num_a, num_b):
"""
gratest common divisor
"""
if num_a == 0 or num_b == 0:
raise ArithmeticError('gcd of zero')
var_p = num_a
var_q = num_b
if var_p < var_q:
var_p = num_b
var_q = num_a
var_r = var_p % var_q
while var_r... | normal | {
"blob_id": "b1ab28a99fdcce66f0a1e4e25821073673f531cf",
"index": 657,
"step-1": "<mask token>\n\n\nclass Rational(object):\n <mask token>\n\n def __init__(self, num, den):\n \"\"\"\n simple constructor\n \"\"\"\n if den == 0:\n raise ZeroDivisionError('division by zer... | [
17,
30,
33,
35,
41
] |
from SpritesClass import Sprite
from JogadorClass import Jogador
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
class Tela:
def __init__(self,j,t0):
self.telas = ["jogo","game over"] #telas existentes
self.estagio = "jogo"
self.j = j
#sprites
se... | normal | {
"blob_id": "d1f0baa1ff87ece50aaded5e60908269e81b6734",
"index": 1952,
"step-1": "<mask token>\n\n\nclass Tela:\n <mask token>\n <mask token>\n\n def setEstagio(self, temp):\n if temp in self.telas:\n self.estagio = temp\n else:\n print('Tela não existe, erro de digit... | [
3,
5,
6,
7,
8
] |
"""
* @section LICENSE
*
* @copyright
* Copyright (c) 2017 Intel Corporation
*
* @copyright
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* @copyright
* http://www.apache.org... | normal | {
"blob_id": "f11e6a53d8dfc60f73f346772df7a3cab14088ce",
"index": 2751,
"step-1": "\"\"\"\n * @section LICENSE\n *\n * @copyright\n * Copyright (c) 2017 Intel Corporation\n *\n * @copyright\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance wit... | [
0
] |
points_dict = {
'+': 5,
'-': 4,
'*': 3,
'/': 2,
'(': -1,
}
op_list = ['+','-','*','/']
def fitness(x1,op,x2):
#Mengembalikan point dari penyambungan expresi dengan operasi dan bilangan berikutnya
try:
hasil = eval(f"{x1} {op} {x2}")
diff = points_dict[op] - abs(24-hasil)
... | normal | {
"blob_id": "c420fb855fbf5691798eadca476b6eccec4aee57",
"index": 7409,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef calc_points(expr):\n points = 0\n hasil = eval(expr)\n points -= abs(24 - hasil)\n for c in expr:\n points += points_dict.get(c, 0)\n return points\n\n\ndef ... | [
0,
3,
5,
6,
7
] |
import numpy as np
from scipy import fft
import math
from sklearn import svm
from activity_recognition import WiiGesture
class WiiGestureClassifier():
"""
This class uses the FFT on the average of all three sensor values
to provide the training data for the SVM
Three good distinguishable gestures are... | normal | {
"blob_id": "0b7bba826b82c3751c072395431e17bc1dc9bb90",
"index": 6037,
"step-1": "<mask token>\n\n\nclass WiiGestureClassifier:\n <mask token>\n\n def __init__(self):\n super(self.__class__, self).__init__()\n <mask token>\n\n def parseArrays(self, data):\n parsedData = []\n for ... | [
7,
8,
10,
13,
14
] |
# -*- coding: utf-8 -*-
import logging
from django.contrib.auth import authenticate, login as django_login, logout as django_logout
from django.contrib.auth.models import User
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.core.urlresolvers import reverse
from django.db.utils imp... | normal | {
"blob_id": "b739a5d359b4d1c0323c7cd8234e4fe5eb9f3fcb",
"index": 6286,
"step-1": "<mask token>\n\n\n@require_superuser\ndef index(request):\n template_name = 'users/index.html'\n msg = ''\n try:\n users = User.objects.exclude(id=request.user.id)\n except:\n msg = _('Unable to list users... | [
8,
9,
10,
11,
12
] |
# list audio files
import glob
def listFiles(path):
return glob.glob(path + '*.wav')
import random
def getNextFile(files):
return random.choice(files)
import pyaudio
import wave
CHUNK = 1024
def getRandomFile(folder = 'test/'):
files = listFiles(folder)
filename = getNextFile(files)
return filename
def pl... | normal | {
"blob_id": "a3bcd383656284a2236e79b5d5d7acdfe433a13b",
"index": 8409,
"step-1": "<mask token>\n\n\ndef getNextFile(files):\n return random.choice(files)\n\n\n<mask token>\n\n\ndef getRandomFile(folder='test/'):\n files = listFiles(folder)\n filename = getNextFile(files)\n return filename\n\n\ndef pl... | [
3,
4,
5,
6,
7
] |
# Generated by Django 2.1.4 on 2019-04-23 23:37
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('mach... | normal | {
"blob_id": "b9608208f71f25ae05ed9bd7bdf94b8882a26e06",
"index": 3091,
"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
# -*- coding: utf-8 -*-
"""
Created on Sun Nov 5 11:56:41 2017
@author: cgao
"""
from beautifultable import BeautifulTable
#1. 新旧税率Bracket
def tax_calculator(taxable_income, bracket, rate):
bracket2 = bracket[1:]
bracket2.append(float('Inf'))
bracket3 = [y-x for x,y in zip(brack... | normal | {
"blob_id": "70cb5673a13967247b6da1fa5948000db39a92c8",
"index": 7253,
"step-1": "<mask token>\n\n\ndef old_bracket(taxable_income, joint=True):\n rate = [0.1, 0.15, 0.25, 0.28, 0.33, 0.35, 0.396]\n if not joint:\n bracket = [0, 9325, 37950, 91900, 191650, 416700, 418400]\n else:\n bracket... | [
7,
10,
13,
15,
16
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Vertex():
def __init__(self, key):
self.id = key
self.connections = {}
def add_neighbor(self, nbr, weight=0):
self.connections[nbr] = weight
def get_connections(self):
return self.connections.keys()
def get_id(sel... | normal | {
"blob_id": "3af78dcc0bb0b6f253af01d2945ad6ada02ca7a0",
"index": 7270,
"step-1": "class Vertex:\n <mask token>\n <mask token>\n\n def get_connections(self):\n return self.connections.keys()\n <mask token>\n <mask token>\n <mask token>\n\n\nclass Graph:\n\n def __init__(self):\n ... | [
10,
12,
13,
15,
17
] |
config = {'numIndividuals': 50, 'maxNumGen': 20, 'eliteProp': 0.1,
'mutantProp': 0.2, 'inheritanceProb': 0.7}
| normal | {
"blob_id": "85d1069d85e285bc5c36811f569dabd793b5064b",
"index": 4460,
"step-1": "<mask token>\n",
"step-2": "config = {'numIndividuals': 50, 'maxNumGen': 20, 'eliteProp': 0.1,\n 'mutantProp': 0.2, 'inheritanceProb': 0.7}\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1... | [
0,
1
] |
'''
Paulie Jo Gonzalez
CS 4375 - os
Lab 0
Last modified: 02/14/2021
This code includes a reference to C code for my_getChar method provided by Dr. Freudenthal.
'''
from os import read
next_c = 0
limit = 0
def get_char():
global next_c, limit
if next_c == limit:
next_c = 0
limit = read(0, 10... | normal | {
"blob_id": "67ac5d82bc37b67cfdae73b6667b73b70ed33cfb",
"index": 8868,
"step-1": "<mask token>\n\n\ndef get_char():\n global next_c, limit\n if next_c == limit:\n next_c = 0\n limit = read(0, 100)\n if limit == 0:\n return ''\n if next_c >= len(limit) - 1:\n return... | [
1,
2,
3,
4,
5
] |
from authtools.models import AbstractNamedUser
class User(AbstractNamedUser):
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = ['name']
| normal | {
"blob_id": "e7d7a002547047a9bcae830be96dd35db80a86e8",
"index": 7001,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass User(AbstractNamedUser):\n <mask token>\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass User(AbstractNamedUser):\n USERNAME_FIELD = 'email'\n REQUIRED_FIELDS... | [
0,
1,
2,
3
] |
from binance.client import Client
from binance.websockets import BinanceSocketManager
from binance.enums import *
import time
import threading
import winsound
# Replace your_api_key, your_api_secret with your api_key, api_secret
client = Client(your_api_key, your_api_secret)
# Calculate list of symbols
def calculate... | normal | {
"blob_id": "dcc85b143f2394b7839f2fb9c2079a7dd9fa8e88",
"index": 4733,
"step-1": "<mask token>\n\n\ndef calculate_data_list():\n counter = 0\n btc = 'BTC'\n symbols = []\n all_positions = []\n positions_final = []\n volume = []\n c = []\n price_change = []\n data = client.get_ticker()\... | [
5,
8,
9,
11,
12
] |
#!/usr/bin/python
#==========================================================================
#
# Copyright Insight Software Consortium
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at... | normal | {
"blob_id": "4f87c2602e3233889888e419296f67fe40a2db0f",
"index": 5886,
"step-1": "#!/usr/bin/python\n#==========================================================================\n#\n# Copyright Insight Software Consortium\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not... | [
0
] |
import pyForp
import pprint
pp = pprint.PrettyPrinter(indent=4)
def fib(n):
if n < 2:
return n
return fib(n-2) + fib(n-1)
forp = pyForp.pyForp()
forp.start()
print fib(2)
forp.stop()
pp.pprint(forp.dump())
| normal | {
"blob_id": "80f9c4b7261a894aad2c738d976cfb8efc4d228c",
"index": 4784,
"step-1": "import pyForp\nimport pprint\npp = pprint.PrettyPrinter(indent=4)\ndef fib(n):\n if n < 2:\n return n\n return fib(n-2) + fib(n-1)\n\nforp = pyForp.pyForp()\nforp.start()\nprint fib(2)\nforp.stop()\npp.pprint(forp.dump... | [
0
] |
from flask import Blueprint, request, make_response
from flask_expects_json import expects_json
from server.validation.schemas import guest_calendar_schema
from tools.for_db.work_with_booking_info import add_booking_info_and_get_uuid
from tools.for_db.work_with_links import get_link
from tools.build_response import bui... | normal | {
"blob_id": "75ef5dd2b82cf79819f18045559f9850c74bb55a",
"index": 5565,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@guest_calendar_post.route('/calendars/<link_id>/bookings/', methods=['POST'])\n@expects_json(guest_calendar_schema)\ndef booking(link_id):\n request_body = request.get_json()\n ... | [
0,
1,
2,
3
] |
' a test module '
__author__ = 'Aaron Jiang'
import sys
def test():
args = sys.argv
if len(args) == 1:
print('Hello World')
elif len(args) == 2:
print('Hello, %s!' % args[1])
else:
print('TOO MANY ARGUMENTS!')
if __name__ == '__main__':
test()
class Test():
count =... | normal | {
"blob_id": "ececcf40005054e26e21152bcb5e68a1bce33e88",
"index": 7947,
"step-1": "<mask token>\n\n\nclass Test:\n <mask token>\n print('called ', count)\n <mask token>\n\n\n<mask token>\n\n\nclass Screen:\n\n @property\n def width(self):\n return self._width\n\n @width.setter\n def wi... | [
12,
14,
15,
17,
19
] |
# -*- coding: utf-8 -*-
# Enter your code here. Read input from STDIN. Print output to STDOUT
n= input()
vals= list(map(int,input().split()))
def median(values):
n=len(values)
values = sorted(values)
if n%2==1:
return values[(n+1)//2 - 1]
else:
return int(sum(values[int((n/... | normal | {
"blob_id": "9d6b5baa8462b2996e4518dd39b5bb1efde1fd9d",
"index": 894,
"step-1": "<mask token>\n\n\ndef quartiles(values):\n n = len(values)\n values.sort()\n Q2 = median(values)\n Q1 = median(values[:int(n / 2)])\n if n % 2 == 0:\n Q3 = median(values[int(n / 2):])\n else:\n Q3 = m... | [
1,
2,
3,
4,
5
] |
#@@range_begin(list1) # ←この行は無視してください。本文に引用するためのものです。
#ファイル名 Chapter07/0703person.py
# __metaclass__ = type #← python 2を使っている場合は行頭の「#」を取る
class Person:
def set_name(self, name):
self.name = name
def get_name(self):
return self.name
def greet(self): # あいさつをする
print(f"こんにちは。私は{self... | normal | {
"blob_id": "321dc411b003949a6744216a13c59c70d919a675",
"index": 8402,
"step-1": "class Person:\n <mask token>\n\n def get_name(self):\n return self.name\n\n def greet(self):\n print(f'こんにちは。私は{self.name}です。')\n\n\n<mask token>\n",
"step-2": "class Person:\n\n def set_name(self, name)... | [
3,
4,
5,
6,
7
] |
"""
commands/map.py
description:
Generates a blank configuration file in the current directory
"""
from json import dumps
from .base_command import BaseCommand
class Map(BaseCommand):
def run(self):
from lib.models import Mapping
from lib.models import Migration
migration = Migration.load(self.options['MI... | normal | {
"blob_id": "07783921da2fb4ae9452324f833b08b3f92ba294",
"index": 546,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Map(BaseCommand):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Map(BaseCommand):\n\n def run(self):\n from lib.models import Mapping\n from lib.mod... | [
0,
1,
2,
3,
4
] |
v1 = 3 + 4 * 2
print(v1)
v2 = (2 + 6) * 2
print(v2)
v3 = 2 ** 3 ** 2
print(v3)
v4 = 20 + 80 / 2
print(v4)
| normal | {
"blob_id": "e6694403eecf2c4511c1fce959b5939f5f457bb8",
"index": 9384,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(v1)\n<mask token>\nprint(v2)\n<mask token>\nprint(v3)\n<mask token>\nprint(v4)\n",
"step-3": "v1 = 3 + 4 * 2\nprint(v1)\nv2 = (2 + 6) * 2\nprint(v2)\nv3 = 2 ** 3 ** 2\nprint(v3)\n... | [
0,
1,
2
] |
from django.core.management.base import BaseCommand, CommandError
from tasks.redisqueue import RedisQueue
from django.conf import settings
class Command(BaseCommand):
def handle(self, *args, **options):
rqueue = RedisQueue(settings.REDIS_URL)
rqueue.worker()
| normal | {
"blob_id": "cccf6ec50ae00d8e00a1a53ea06fa8b6d061b72e",
"index": 8258,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Command(BaseCommand):\n <mask token>\n",
"step-3": "<mask token>\n\n\nclass Command(BaseCommand):\n\n def handle(self, *args, **options):\n rqueue = RedisQueue(se... | [
0,
1,
2,
3
] |
from checkio.home.long_repeat import long_repeat
def test_long_repeat():
assert long_repeat("sdsffffse") == 4, "First"
assert long_repeat("ddvvrwwwrggg") == 3, "Second"
def test_fails_1():
assert long_repeat("") == 0, "Empty String"
def test_fails_2():
assert long_repeat("aa") == 2
| normal | {
"blob_id": "b459919e779063247c176e127368c687c903cf0f",
"index": 7869,
"step-1": "<mask token>\n\n\ndef test_fails_1():\n assert long_repeat('') == 0, 'Empty String'\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_fails_1():\n assert long_repeat('') == 0, 'Empty String'\n\n\ndef test_fails_2(... | [
1,
2,
3,
4,
5
] |
from django.conf.urls import patterns, include, url
from django.contrib import admin
from metainfo.views import DomainListView
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'metapull.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^$', DomainListView.as_view()),
url(... | normal | {
"blob_id": "1599f5e49ec645b6d448e74719e240343077aedd",
"index": 5464,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nurlpatterns = patterns('', url('^$', DomainListView.as_view()), url(\n '^admin/', include(admin.site.urls)), url('^domains/', include(\n 'metainfo.urls', namespace='domains')))\n",
... | [
0,
1,
2,
3
] |
# Pose estimation and object detection: OpenCV DNN, ImageAI, YOLO, mpi, caffemodel, tensorflow
# Authors:
# Tutorial by: https://learnopencv.com/deep-learning-based-human-pose-estimation-using-opencv-cpp-python/
# Model file links collection (replace .sh script): Twenkid
# http://posefs1.perception.cs.cmu.edu/OpenPose/... | normal | {
"blob_id": "c80ae9d2eb07fd716a80a5e2d7b5237925fda02c",
"index": 5861,
"step-1": "<mask token>\n\n\ndef yolo():\n root = 'Z:\\\\'\n name = '23367640.png'\n execution_path = os.getcwd()\n yolo_path = 'Z:\\\\yolo.h5'\n localdir = False\n detector = ObjectDetection()\n detector.setModelTypeAsYO... | [
2,
3,
4,
5,
6
] |
import random
import torch
import numpy as np
from torch.autograd import Variable
class SupportSetManager(object):
FIXED_FIRST = 0
RANDOM = 1
def __init__(self, datasets, config, sample_per_class):
self.config = config
(TEXT, LABEL, train, dev, test) = datasets[0]
self.TEXT = TEXT
... | normal | {
"blob_id": "13a2814e8744c6c09906d790185ed44fc2b3f23e",
"index": 3642,
"step-1": "<mask token>\n\n\nclass SupportSetManager(object):\n <mask token>\n <mask token>\n\n def __init__(self, datasets, config, sample_per_class):\n self.config = config\n TEXT, LABEL, train, dev, test = datasets[0... | [
6,
8,
9,
10,
12
] |
from pyathena import connect
from Config import config2
from Config import merchants
def get_mapped_sku(sku):
try:
cursor = connect(aws_access_key_id=config2["aws_access_key_id"],
aws_secret_access_key=config2["aws_secret_access_key"],
s3_staging_dir=confi... | normal | {
"blob_id": "6add599035573842475c7f9155c5dbbea6c96a8a",
"index": 3618,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef get_mapped_sku(sku):\n try:\n cursor = connect(aws_access_key_id=config2['aws_access_key_id'],\n aws_secret_access_key=config2['aws_secret_access_key'],\n ... | [
0,
2,
3,
4,
5
] |
import sys
import os
sys.path.append("C:/Users/Laptop/Documents/Repos/udacity_stats_functions/descriptive")
import normal_distribution_06
#import sampling_distributions_07
def lower_upper_confidence_intervals(avg, SD):
#avg is x bar. The mean value at the "would be" point. ie Bieber Tweeter
#SD is standard err... | normal | {
"blob_id": "d423b0bc6cd9ea9795317750141ad5f5eab01636",
"index": 1886,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef lower_upper_confidence_intervals(avg, SD):\n lower = avg - 2 * SD\n upper = avg + 2 * SD\n return lower, upper\n\n\n<mask token>\n",
"step-3": "<mask token>\nsys.path.a... | [
0,
1,
2,
3,
4
] |
import tkinter as tk
import tkinter.messagebox as tkmb
import psutil
import os
import re
import subprocess
from subprocess import Popen, PIPE, STDOUT, DEVNULL
import filecmp
import re
import time
import threading
import datetime
import re
debian = '/etc/debian_version'
redhat = '/etc/redhat-release'
def PrintaLog(tex... | normal | {
"blob_id": "fde62dd3f5ee3cc0a1568b037ada14835c327046",
"index": 6298,
"step-1": "<mask token>\n\n\ndef PrintaLog(texto):\n t = time.time()\n logtime = time.ctime(t)\n stringprint = '%s %s\\n' % (logtime, texto)\n f = open('/var/log/patriot', 'a')\n f.write(stringprint)\n f.flush()\n f.close... | [
4,
6,
9,
10,
11
] |
import bpy
bl_info = {
"name": "Ratchets Center All Objects",
"author": "Ratchet3789",
"version": (0, 1, 0),
"description": "Centers all selected objects. Built for Game Development.",
"category": "Object",
}
class CenterOriginToZero(bpy.types.Operator):
"""Center all objects script""" # blen... | normal | {
"blob_id": "f7a511beaea869cf32eb905a4f3685077297a5ec",
"index": 1654,
"step-1": "<mask token>\n\n\nclass CenterOriginToZero(bpy.types.Operator):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def execute(self, context):\n for x in bpy.context.selected_objects:\n ... | [
10,
14,
15,
16,
18
] |
from rllab.envs.base import Env
from rllab.spaces import Discrete
from rllab.spaces import Box
from rllab.envs.base import Step
import numpy as np
import sys, pickle, os
sys.path.append(os.path.dirname(os.getcwd()))
from os.path import dirname
sys.path.append(dirname(dirname(dirname(os.getcwd()))))
from simulation impo... | normal | {
"blob_id": "21974274b1e7800b83eb9582ab21714f04230549",
"index": 4299,
"step-1": "<mask token>\n\n\nclass PinEnvDiscrete(Env):\n <mask token>\n\n def __init__(self, simulation, x, y, trajectory, scorer=0,\n max_displacement=False, predict=False, original=False, sample=False):\n self.simulatio... | [
8,
9,
10,
12,
13
] |
#!/usr/bin/env python
"""Diverse wiskundige structuren weergeven in LaTeX in Jupyter Notebook."""
__author__ = "Brian van der Bijl"
__copyright__ = "Copyright 2020, Hogeschool Utrecht"
from IPython.display import display, Math, Markdown
import re
def show_num(x):
return re.compile(r"\.(?!\d)")... | normal | {
"blob_id": "7f7bd2e9ec1932ccfd8aa900956ce85473ee8dbd",
"index": 4668,
"step-1": "<mask token>\n\n\ndef latex_formula(form):\n latex = form.simplify().to_latex(outer=True)\n if latex:\n display(Math(latex))\n display(Markdown('<details><pre>$' + latex + '$</pre></details>'))\n\n\n<mask token>... | [
1,
5,
7,
9,
10
] |
import re
import requests
def download_image(url: str) -> bool:
img_tag_regex = r"""<img.*?src="(.*?)"[^\>]+>"""
response = requests.get(url)
if response.status_code != 200:
return False
text = response.text
image_links = re.findall(img_tag_regex, text)
for link in image_links:
... | normal | {
"blob_id": "268c36f6fb99383ea02b7ee406189ffb467d246c",
"index": 6554,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef download_image(url: str) ->bool:\n img_tag_regex = '<img.*?src=\"(.*?)\"[^\\\\>]+>'\n response = requests.get(url)\n if response.status_code != 200:\n return False... | [
0,
1,
2,
3
] |
__version__ = '0.90.03'
| normal | {
"blob_id": "284e4f79748c17d44518f2ce424db5b1697373dc",
"index": 3156,
"step-1": "<mask token>\n",
"step-2": "__version__ = '0.90.03'\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
# Dependancies
import pandas as pd
# We can use the read_html function in Pandas
# to automatically scrape any tabular data from a page.
# URL of website to scrape
url = 'https://en.wikipedia.org/wiki/List_of_capitals_in_the_United_States'
# Read HTML
tables = pd.read_html(url)
tables
# What we get in return is a ... | normal | {
"blob_id": "f4fca5ce20db0e27da11d76a7a2fd402c33d2e92",
"index": 4731,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntables\n<mask token>\ndf.head()\n<mask token>\ndf.head()\ndf.set_index('State', inplace=True)\ndf.head()\ndf.loc['Alabama']\n<mask token>\nhtml_table\nhtml_table.replace('\\n', '')\ndf.to... | [
0,
1,
2,
3,
4
] |
import sys
sys.path.append("..\\Pole_IA_Systemes_Experts")
from tkinter import *
from Knowledge_base.Facts import Fact
from Knowledge_base.Rules import Rule
from Backward.Explanation_tree import *
def ask_about_fact(fact: Fact):
"""
Asks the user about whether a fact is true or false threw an interface provi... | normal | {
"blob_id": "4dae34b7c90f52314aac5e457addb3700ffcbd28",
"index": 9156,
"step-1": "<mask token>\n\n\ndef ask_about_fact(fact: Fact):\n \"\"\"\n Asks the user about whether a fact is true or false threw an interface provided by tkinter\n Args:\n fact (Fact): the fact we want to know about\n\n Re... | [
1,
2,
3,
4,
5
] |
#MenuTitle: Check for open paths in selected glyphs
"""
Checks for open paths in selected glyphs (or all glyphs if no selection).
Output appears in Macro Window (Option-Command-M).
"""
# FIXME: test with masters and instances -- may not work
Font = Glyphs.font
Doc = Glyphs.currentDocument
selectedGlyphs = [ x.parent f... | normal | {
"blob_id": "bf49893fee79b0c3e34340cf1633c1797ce1bf41",
"index": 2282,
"step-1": "#MenuTitle: Check for open paths in selected glyphs\n\"\"\"\nChecks for open paths in selected glyphs (or all glyphs if no selection).\nOutput appears in Macro Window (Option-Command-M).\n\"\"\"\n# FIXME: test with masters and inst... | [
0
] |
from rlbot.agents.base_agent import BaseAgent, GameTickPacket, SimpleControllerState
#from rlbot.utils.structures.game_data_struct import GameTickPacket
from Decisions.challengeGame import ChallengeGame
from Decisions.info import MyInfo, Car
from Decisions.strat import Strategy
from Drawing.Drawing import DrawingTool
f... | normal | {
"blob_id": "1a0d4e77f09b4ce752631ae36a83ff57f96b89b1",
"index": 600,
"step-1": "<mask token>\n\n\nclass MyBot(BaseAgent):\n <mask token>\n\n def initialize_agent(self):\n self.boost_pad_tracker.initialize_boosts(self.get_field_info())\n self.info = MyInfo(self.team, self.index)\n self... | [
5,
6,
7,
8,
9
] |
#!/usr/bin/env python
##############
#### Your name: Alexis Vincent
##############
import numpy as np
import re
from skimage.color import convert_colorspace
from sklearn.model_selection import GridSearchCV
from sklearn import svm, metrics
from skimage import io, feature, filters, exposu... | normal | {
"blob_id": "58204b4b035aa06015def7529852e882ffdd369a",
"index": 8997,
"step-1": "<mask token>\n\n\nclass ImageClassifier:\n <mask token>\n <mask token>\n <mask token>\n\n def extract_image_features(self, data):\n fd = None\n for pic in data:\n rescaled_picture = exposure.res... | [
5,
7,
9,
10,
12
] |
from tkinter import *
class Menuutje:
def __init__(self, master):
menu = Menu(master)
master.config(menu=menu)
subMenu = Menu(menu)
menu.add_cascade(label="File", menu=subMenu)
subMenu.add_command(label="New Game...", command=self.doNothing)
subMenu.add_command(la... | normal | {
"blob_id": "8fbfa53be826b45b53b530a1766f6a68c61f5be9",
"index": 9377,
"step-1": "from tkinter import *\n\n\nclass Menuutje:\n\n def __init__(self, master):\n menu = Menu(master)\n master.config(menu=menu)\n\n subMenu = Menu(menu)\n menu.add_cascade(label=\"File\", menu=subMenu)\n ... | [
0
] |
import sys
sys.path.append('../')
import constants as cnst
import os
os.environ['PYTHONHASHSEED'] = '2'
import tqdm
from model.stg2_generator import StyledGenerator
import numpy as np
from my_utils.visualize_flame_overlay import OverLayViz
from my_utils.flm_dynamic_fit_overlay import camera_ringnetpp
from my_utils.gene... | normal | {
"blob_id": "d0991d8ea47379a0c1de836b5d215c99166ad049",
"index": 5936,
"step-1": "<mask token>\n\n\ndef ge_gen_in(flm_params, textured_rndr, norm_map, normal_map_cond,\n texture_cond):\n if normal_map_cond and texture_cond:\n return torch.cat((textured_rndr, norm_map), dim=1)\n elif normal_map_co... | [
2,
3,
4,
5,
6
] |
import numpy as np
np.random.seed(1)
class MonteCarloGameDriver():
def __init__(self):
self.default_moves = np.array(['w','a','s','d'])
self.probability_distribution = np.array([.25,.25,.25,.25])
def run_game(self, simulation_size=20):
from game import GameLayout
from copy ... | normal | {
"blob_id": "aeb986360c6990f9375f2552cbdeef595af815b4",
"index": 6432,
"step-1": "<mask token>\n\n\nclass MonteCarloGameDriver:\n\n def __init__(self):\n self.default_moves = np.array(['w', 'a', 's', 'd'])\n self.probability_distribution = np.array([0.25, 0.25, 0.25, 0.25])\n <mask token>\n\n... | [
5,
6,
7,
8,
9
] |
''' Model package should containt all data types for the database engine,
which means that projects like PyCIM can be included within ''' | normal | {
"blob_id": "ce3c1a7210632d0a8475fe886d514eb91d3c75ac",
"index": 7700,
"step-1": "<mask token>\n",
"step-2": "''' Model package should containt all data types for the database engine, \nwhich means that projects like PyCIM can be included within '''",
"step-3": null,
"step-4": null,
"step-5": null,
"st... | [
0,
1
] |
$ pip install "<package_name> >= 1.1"
| normal | {
"blob_id": "8010c0d53af6d428f29ff3ce63bcd6b5b811b051",
"index": 3456,
"step-1": "$ pip install \"<package_name> >= 1.1\"\n\n",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
/usr/share/pyshared/screenlets/plugins/SizeConverter.py | normal | {
"blob_id": "58ddf496245741498177a67b7ce692b97bbd476a",
"index": 9887,
"step-1": "/usr/share/pyshared/screenlets/plugins/SizeConverter.py",
"step-2": null,
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0
]
} | [
0
] |
from DHT_Python import dht22
from oled96 import oled
from PiBlynk import Blynk
# read data using pin 4
instance = dht22.DHT22(pin=4)
token = "---token---"
blynk = Blynk(token)
def cnct_cb():
print ("Connected: ")
blynk.on_connect(cnct_cb)
def _funCb(ACT):
result = instance.read()
if result.is_valid():
strTe... | normal | {
"blob_id": "e95ebb2aa6526e3bf3789da17d144e71cdb49aca",
"index": 2712,
"step-1": "<mask token>\n\n\ndef cnct_cb():\n print('Connected: ')\n\n\n<mask token>\n\n\ndef _funCb(ACT):\n result = instance.read()\n if result.is_valid():\n strTemp = '%.2f' % result.temperature\n strHumi = '%.2f' % ... | [
2,
3,
4,
5,
6
] |
# _*_ coding: utf-8 _*_
# 按层打印二叉树
class TreeNode(object):
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class PrintTree(object):
def printTree(self, root):
if not root:
return
'''
定义next_last为下一层的最后一个,cur_last为当前层最后一个
... | normal | {
"blob_id": "4ddff57790ad191fc29fc092bcc714f0b6273100",
"index": 7755,
"step-1": "<mask token>\n\n\nclass PrintTree(object):\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass PrintTree(object):\n\n def printTree(self, root):\n if not root:\n return\n \"\"\"\n 定义next_la... | [
1,
2,
3,
4,
5
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.10.5 on 2017-07-31 18:38
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('product', '0007_auto_20170731_1812'),
]
operations... | normal | {
"blob_id": "ae82ecadb61fd87afbc83926b9dc9d5f7e8c35a0",
"index": 4194,
"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 = [('product', '... | [
0,
1,
2,
3,
4
] |
"""
@file : 001-rnn+lstm+crf.py
@author: xiaolu
@time : 2019-09-06
"""
import re
import numpy as np
import tensorflow as tf
from sklearn.metrics import classification_report
class Model:
def __init__(self, dim_word, dim_char, dropout, learning_rate,
hidden_size_char, hidden_size_word, num_l... | normal | {
"blob_id": "5d9c8e235385ff53c7510994826ff3a04e4a5888",
"index": 10,
"step-1": "<mask token>\n\n\nclass Model:\n\n def __init__(self, dim_word, dim_char, dropout, learning_rate,\n hidden_size_char, hidden_size_word, num_layers):\n \"\"\"\n :param dim_word: 词的维度\n :param dim_char: 字... | [
5,
8,
10,
11,
13
] |
#!/usr/bin python3
# coding: utf-8
"""
AUTHOR: bovenson
EMAIL: szhkai@qq.com
FILE: 03.py
DATE: 17-9-25 下午7:59
DESC:
"""
from socket import socket
| normal | {
"blob_id": "74d1491280eba1ceb06ccf6f45546cdb41149687",
"index": 5642,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfrom socket import socket\n",
"step-3": "#!/usr/bin python3\n# coding: utf-8\n\n\"\"\"\nAUTHOR: bovenson\nEMAIL: szhkai@qq.com\nFILE: 03.py\nDATE: 17-9-25 下午7:59\nDESC:\n\"\"\"\n\nfrom ... | [
0,
1,
2
] |
# -*- coding: utf-8 -*-
import luigi
from luigi import *
#from luigi import Task
import pandas as pd
from pset.tasks.embeddings.load_embeding import EmbedStudentData
from pset.tasks.data.load_dataset import HashedStudentData
import numpy as npy
import pickle
import os
class NearestStudents(Task):
github_id = Par... | normal | {
"blob_id": "15eed401728e07bfe9299edd12add43ad8b9cb71",
"index": 3802,
"step-1": "<mask token>\n\n\nclass NearestStudents(Task):\n <mask token>\n <mask token>\n <mask token>\n\n def output(self):\n return luigi.LocalTarget('/Users/adcxdpf/Downloads/pset_03/sd.csv')\n\n def requires(self):\n... | [
5,
6,
7,
8,
9
] |
from django import forms
from django.contrib.auth.models import User
from ServicePad.apps.account.models import UserProfile
import hashlib, random, datetime
from ServicePad.apps.registration.models import ActivationKey
MIN_PASSWORD_LENGTH=8
MAX_PASSWORD_LENGTH=30
class UserRegistrationForm(forms.Form):
first_name... | normal | {
"blob_id": "5f680fb21fe1090dfb58f5b9260739b91ae04d99",
"index": 9922,
"step-1": "<mask token>\n\n\nclass UserRegistrationForm(forms.Form):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def save(self):\n new_user = User... | [
6,
8,
9,
10,
11
] |
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-23 19:31
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('mocbackend', '0034_auto_20181122_1903'),
]
operations = [
migrations.AddFi... | normal | {
"blob_id": "36bdd6f7c130914856ddf495c50f928405c345aa",
"index": 6646,
"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 = [('mocbackend'... | [
0,
1,
2,
3,
4
] |
# Copyright 2021 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from pants.backend.scala.goals.tailor import classify_source_files
from pants.backend.scala.target_types import (
ScalaJunitTestsGeneratorTarget,
ScalaSourcesGeneratorTarget,
... | normal | {
"blob_id": "42d2d8717ec2c25a99302e8de3090d600f8e80ff",
"index": 674,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_classify_source_files() ->None:\n scalatest_files = {'foo/bar/BazSpec.scala'}\n junit_files = {'foo/bar/BazTest.scala'}\n lib_files = {'foo/bar/Baz.scala'}\n asser... | [
0,
1,
2,
3
] |
def fun(st,n):
suffix=[0 for i in range(n)]
prefix=[0 for i in range(n)]
count=0
for i,val in enumerate(st):
if(val=='*'):
if(i==0):
prefix[i]=0
count+=1
else:
prefix[i]=prefix[i-1]
count+=1
else:
... | normal | {
"blob_id": "77c7ca3391426d1e56e15a93ef3e6227a45140fc",
"index": 2829,
"step-1": "<mask token>\n",
"step-2": "def fun(st, n):\n suffix = [(0) for i in range(n)]\n prefix = [(0) for i in range(n)]\n count = 0\n for i, val in enumerate(st):\n if val == '*':\n if i == 0:\n ... | [
0,
1,
2,
3,
4
] |
class Node:
def __init__(self,data):
self.data = data
self.next = None
def Add(Head,data):
Temp = Head
while(Temp.next != None):
Temp = Temp.next
Temp.next = Node(data)
# print(Temp.data)
def create(data):
Head = Node(data)
return Head
def printLL(Head):
Temp ... | normal | {
"blob_id": "ff137b51ea5b8c21e335a38a3d307a3302921245",
"index": 9993,
"step-1": "class Node:\n\n def __init__(self, data):\n self.data = data\n self.next = None\n\n\n<mask token>\n\n\ndef Reverse(Head):\n Temp = Head\n TempNext = Head.next\n while TempNext != None:\n NextSaved =... | [
3,
5,
6,
7,
8
] |
#!/usr/bin/env python3
import optparse
from bs4 import BeautifulSoup
import re
import jieba
import pickle
import requests
import asyncio
if __name__ == '__main__':
# 读取10000个关键词
fs = open("./src/keywords.txt", "rb")
keywords = fs.read().decode("utf-8").split(",")
fs.close()
# 找出特征
def find_f... | normal | {
"blob_id": "88590aef975f7e473ef964ee0c4004cff7e24b07",
"index": 1049,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nif __name__ == '__main__':\n fs = open('./src/keywords.txt', 'rb')\n keywords = fs.read().decode('utf-8').split(',')\n fs.close()\n\n def find_features(doc):\n words = ... | [
0,
1,
2,
3
] |
import sqlite3
def connect():
connect = sqlite3.connect("books.db")
cursor = connect.cursor()
cursor.execute("CREATE TABLE IF NOT EXISTS bookstore (id INTEGER PRIMARY KEY,"
"title TEXT,"
"author TEXT,"
"year INTEGER,"
"isbn INTEGER... | normal | {
"blob_id": "d7d23b04f6e73db6a0a8730192398941743f32ce",
"index": 6800,
"step-1": "<mask token>\n\n\ndef view():\n connect = sqlite3.connect('books.db')\n cursor = connect.cursor()\n cursor.execute('SELECT * FROM bookstore')\n books = cursor.fetchall()\n connect.close()\n return books\n\n\n<mask... | [
4,
6,
7,
8,
10
] |
# -*- coding: utf-8 -*-
"""
Created on Tue Jan 23 20:44:38 2018
@author: user
"""
import fitbit
import gather_keys_oauth2 as Oauth2
import pandas as pd
import datetime as dt
from config import CLIENT_ID, CLIENT_SECRET
#Establish connection to Fitbit API
server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET)
server... | normal | {
"blob_id": "9f1cbc655a5d8f14fa45cf977bb2dcee4874b188",
"index": 5809,
"step-1": "<mask token>\n\n\ndef get_heart_rate(auth2_client, date, granularity='1sec'):\n \"\"\"\n Query intraday time series given date\n granularity: 1sec or 1min\n \"\"\"\n heart_rate_raw = auth2_client.intraday_time_series... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python3
import click
@click.command()
@click.option("--name", prompt = "Your name")
def hello(name):
print("hello", name)
if __name__ == '__main__':
hello()
| normal | {
"blob_id": "19c1a50cf19f04a9e0d0163a9383cb900bca1d38",
"index": 9862,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@click.command()\n@click.option('--name', prompt='Your name')\ndef hello(name):\n print('hello', name)\n\n\n<mask token>\n",
"step-3": "<mask token>\n\n\n@click.command()\n@click... | [
0,
1,
2,
3,
4
] |
import os
from tqdm import tqdm
from system.krl import KRL
from system.utils.format import format_data
from system.oie import OIE
# extract one file
def execute_file(input_fp, output_fp):
oie = OIE()
oie.extract_file(input_fp, output_fp)
# extract one sentence
def execute_sentence():
... | normal | {
"blob_id": "bc5e928305d82c92c10106fe1f69f5979d57e3d2",
"index": 5446,
"step-1": "<mask token>\n\n\ndef execute_file(input_fp, output_fp):\n oie = OIE()\n oie.extract_file(input_fp, output_fp)\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\ndef execute_file(input_fp, output_fp):\n oie = OIE()\n ... | [
1,
3,
4,
5,
6
] |
#! /usr/bin/env python
import os
import re
from codecs import open
from setuptools import find_packages, setup
here = os.path.abspath(os.path.dirname(__file__))
def get_changelog():
with open(os.path.join(here, 'CHANGELOG'), encoding='utf-8') as f:
text = f.read()
header_matches = list(re.finditer... | normal | {
"blob_id": "c81889cf4d87933b562aa4618bc5185a8d213107",
"index": 8075,
"step-1": "<mask token>\n\n\ndef get_changelog():\n with open(os.path.join(here, 'CHANGELOG'), encoding='utf-8') as f:\n text = f.read()\n header_matches = list(re.finditer('^=+$', text, re.MULTILINE))\n text = text[:header_ma... | [
1,
2,
3,
4,
5
] |
import torch
import torch.nn.functional as f
import time
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
import numpy as np
dtype = torch.float
device = torch.device("cpu")
# device = torch.device("cuda:0") # Uncomment this to run on GPU
N, D_in, H, D_out = 64, 1000, 100, 10
x = torch.randn(N, D... | normal | {
"blob_id": "0fb424dafaac184882ea56f36265e0b19b5a4c50",
"index": 9758,
"step-1": "<mask token>\n\n\ndef plot_grad_flow(named_parameters):\n \"\"\"Plots the gradients flowing through different layers in the net during training.\n Can be used for checking for possible gradient vanishing / exploding problems.... | [
1,
2,
3,
4,
5
] |
from django.contrib import admin
from django.db import models
from tinymce.widgets import TinyMCE
from .models import UserInfo
# Register your models here.
class UserInfoAdmin(admin.ModelAdmin):
list_display=[
'user_name',
'user_profession',
'user_phone',
'user_email',
... | normal | {
"blob_id": "15134d7e4036c102bc9d2ba4d321fadd0467100f",
"index": 6637,
"step-1": "<mask token>\n\n\nclass UserInfoAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass UserInf... | [
1,
2,
3,
4,
5
] |
from db_upgrader.Repositories.store import Store, StoreException
from db_upgrader.Models.product import *
class ProductStore(Store):
table = 'product'
def add_product(self, product):
try:
c = self.conn.cursor()
c.execute(
'INSERT INTO product (`name`,customerId... | normal | {
"blob_id": "963499e071873083dc942486b9a5b094393cd99e",
"index": 4458,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass ProductStore(Store):\n <mask token>\n\n def add_product(self, product):\n try:\n c = self.conn.cursor()\n c.execute(\n 'INSERT ... | [
0,
2,
3,
4
] |
import numpy as np
import itertools
from scipy.linalg import eig, schur
from eigen_rootfinding.polynomial import MultiCheb, MultiPower
from eigen_rootfinding.utils import memoize
from scipy.stats import ortho_group
def indexarray(matrix_terms, which, var):
"""Compute the array mapping monomials under multiplicatio... | normal | {
"blob_id": "14fb6776ac30802edf43c43acbee64263c6bdd7b",
"index": 2777,
"step-1": "<mask token>\n\n\ndef ms_matrices(E, Q, matrix_terms, dim):\n \"\"\"Compute the Möller-Stetter matrices in the monomial basis from a\n reduced Macaulay matrix\n\n Parameters\n ----------\n E : (m, k) ndarray\n ... | [
5,
6,
8,
10,
12
] |
import unittest
from utils import getParams
from utils.httpUtil import HttpUtil
from utils.logger import Log
logger = Log(logger='cms_getMarket').get_log()
class NavTest(unittest.TestCase):
@classmethod
def setUpClass(cls) ->None:
cls.url = getParams.get_url('cms_getMarket', 'getMarket')
Http... | normal | {
"blob_id": "b328ee0b6c5afaf496297cefe477f933af458a03",
"index": 5654,
"step-1": "<mask token>\n\n\nclass NavTest(unittest.TestCase):\n <mask token>\n\n @classmethod\n def tearDownClass(cls) ->None:\n pass\n\n def test01_getMarket(self):\n resp_c = getParams.get_resp_params('cms_getMark... | [
3,
4,
5,
6
] |
from collections import defaultdict
from mask import Mask
from utils import bits_to_decimal
def get_program(filename):
program = []
mask = None
with open(filename, 'r') as f:
for line in f:
line = line[:-1]
if 'mask' in line:
if mask is not None:
... | normal | {
"blob_id": "56e8cdec854b3b7a2f925e70d7d59a73b76f9952",
"index": 9340,
"step-1": "<mask token>\n\n\ndef get_program(filename):\n program = []\n mask = None\n with open(filename, 'r') as f:\n for line in f:\n line = line[:-1]\n if 'mask' in line:\n if mask is n... | [
1,
3,
4,
5,
6
] |
a, b = input().split()
def test_input_text(expected_result, actual_result):
assert expected_result == actual_result, \
f'expected {expected_result}, got {actual_result}'
test_input_text(a,b)
| normal | {
"blob_id": "63391b31d1746f9b3583df5353ae160a430943a9",
"index": 9027,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_input_text(expected_result, actual_result):\n assert expected_result == actual_result, f'expected {expected_result}, got {actual_result}'\n\n\n<mask token>\n",
"step-3":... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
import sys
#from Constants import *
# start
import CrudMatrixDao
class CrudAccessValue:
def __init__(self):
self.crudAccessValue = {}
self.__run()
def __run(self):
aCrudMatrixDao = CrudMatrixDao.CrudMatrixDao()
# print aCrudMatrixDao.selectCrudAccessValueAction()
... | normal | {
"blob_id": "38e616e35f165d458d774dd0b6837a733b8402d7",
"index": 1555,
"step-1": "# -*- coding: utf-8 -*-\r\nimport sys\r\n#from Constants import *\r\n# start\r\nimport CrudMatrixDao\r\n\r\nclass CrudAccessValue:\r\n\tdef __init__(self):\r\n\t\tself.crudAccessValue = {}\r\n\t\tself.__run()\r\n\t\t\r\n\tdef __ru... | [
0
] |
"""Add uri on identity provider
Revision ID: 52561c782d96
Revises: cdf9f34b764c
Create Date: 2022-03-11 10:16:39.583434
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '52561c782d96'
down_revision = 'cdf9f34b764c'
branch_labels = None
depends_on = None
def up... | normal | {
"blob_id": "c185a88332e39c561649f087f01fd3b704e7010b",
"index": 1959,
"step-1": "<mask token>\n\n\ndef upgrade():\n bind = op.get_bind()\n urls = bind.execute(\n 'SELECT p.id as pid, r.id as rid, r.uri as uri FROM oauth2_identity_provider p JOIN resource r ON p.api_resource_id = r.id'\n )\n ... | [
1,
2,
3,
4,
5
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.