code stringlengths 13 1.2M | order_type stringclasses 1
value | original_example dict | step_ids listlengths 1 5 |
|---|---|---|---|
import numpy as np
from input_parameters.program_constants import ITERATIONS_NUM, TIMESTEPS_NUMB
def init_zero_arrays():
radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB))
dot_radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB))
dotdot_radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB))
d... | normal | {
"blob_id": "e652196f9c74be6f05c6148de152996e449670ea",
"index": 3059,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef init_zero_arrays():\n radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB))\n dot_radius_arr = np.zeros((ITERATIONS_NUM, TIMESTEPS_NUMB))\n dotdot_radius_arr = np.zeros... | [
0,
1,
2,
3
] |
#!usr/bin/python
# -*- coding:UTF-8 -*-
'''
Introduction:
Implementation of Stack
Created on: Oct 28, 2014
@author: ICY
'''
#-------------------------FUNCTION---------------------------#
class Stack(object):
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
... | normal | {
"blob_id": "6fa9dfadc60108e1718c6688f07de877b0ac0afd",
"index": 5885,
"step-1": "<mask token>\n\n\nclass Stack(object):\n\n def __init__(self):\n self.items = []\n\n def is_empty(self):\n return self.items == []\n\n def clear(self):\n self.items = []\n\n def push(self, item):\n ... | [
7,
8,
9,
10,
11
] |
from PenaltyTracker import PenaltyTracker
from DatabaseManager import DatabaseManager
import unittest,os,sys,shutil, filecmp
class TestingPenaltyTracker(unittest.TestCase):
@classmethod
def setUpClass(cls):
cls.testPTDatabase = os.path.join( os.getcwd(), "Tests", "test_penalty.db")
cls.testPena... | normal | {
"blob_id": "607d8bc79caa9d767bdb7e77a5db52295d90236f",
"index": 1759,
"step-1": "<mask token>\n\n\nclass TestingPenaltyTracker(unittest.TestCase):\n <mask token>\n\n @classmethod\n def tearDownClass(cls):\n cls.testPenaltyTracker = None\n cls.controlDatabase = None\n os.remove(os.p... | [
3,
5,
6,
7,
8
] |
import numpy
from PIL import Image, ImageDraw
def start():
# ----------------------------
# Set values
# ----------------------------
image_file = 'sample.png'
# Coordinates, where [0,0] is top left corner
top_left_corner = [100, 100] # [x, y]
bottom_right_corner = [200, 200] # [x, y]
... | normal | {
"blob_id": "84476e1793242bf3bae51263c2db28ff555c25d7",
"index": 1104,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef start():\n image_file = 'sample.png'\n top_left_corner = [100, 100]\n bottom_right_corner = [200, 200]\n img = Image.open(image_file)\n top_left_x = top_left_corner... | [
0,
1,
2,
3,
4
] |
# We will try to implement add noise to audio file and filter it using Mean and Median Filters.
import numpy as np
import scipy
import matplotlib.pyplot as plt
from scipy.io.wavfile import read
from scipy.io.wavfile import write
rate,audio_original = read('Audio_Original.wav')
audio = audio_original[:,0]
write("Audi... | normal | {
"blob_id": "844b8e2d4f05a51282b356c995f2733d6935a5d6",
"index": 5552,
"step-1": "<mask token>\n\n\ndef Plot_Audio(audio):\n s = audio.shape[0]\n time = np.arange(s)\n plt.plot(time, audio)\n plt.show()\n\n\ndef Add_Noise(audio, mu=0, sigma=1):\n \"\"\"\n\tAdding Gaussian Noise\n\t\"\"\"\n gaus... | [
4,
5,
6,
7,
8
] |
from keyboards import *
from DB import cur, conn
from bot_token import bot
from limit_text import limit_text
def send_answer(question_id, answer_owner, receiver_tel_id, short):
answer = cur.execute('''SELECT answer FROM Answers WHERE question_id = (%s) AND tel_id = (%s)''', (question_id, answer_owner)).fetchone()... | normal | {
"blob_id": "464fc2c193769eee86a639f73b933d5413be2b87",
"index": 3396,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef send_answer(question_id, answer_owner, receiver_tel_id, short):\n answer = cur.execute(\n 'SELECT answer FROM Answers WHERE question_id = (%s) AND tel_id = (%s)'\n ... | [
0,
1,
2,
3
] |
#!/usr/bin/env python
# ------------------------------------------------------------------------------------------------------%
# Created by "Thieu Nguyen" at 19:47, 08/04/2020 %
# ... | normal | {
"blob_id": "93b12d1e936331c81522790f3f45faa3383d249e",
"index": 3515,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(best_fit1)\n",
"step-3": "<mask token>\nobjective_func = F1\nproblem_size = 30\ndomain_range = [-15, 15]\nlog = True\nepoch = 100\npop_size = 50\np = 0.8\nmd1 = BaseFPA(objective_... | [
0,
1,
2,
3,
4
] |
from arma_scipy.fit import fit, predict
| normal | {
"blob_id": "0f6512bb734336a67eab2f13949dd960f5ffc1d5",
"index": 7758,
"step-1": "<mask token>\n",
"step-2": "from arma_scipy.fit import fit, predict\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
"""
CP1404 - Practical
Code that produces a random number between 1 and 100 inclusive
Rhys Simpson
"""
# 1.
# smallest number 5; largest number 20
# 2.
# smallest number 3; largest number 9
# no it can only produce 3, 5, 7, 9
# 3.
# smallest number 2.5000000000000000; largest number 5.5000000000000000
import random... | normal | {
"blob_id": "46696ee9576d74c087ae435bfd304c8346530ab2",
"index": 9804,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(random.randint(1, 100))\n",
"step-3": "<mask token>\nimport random\nprint(random.randint(1, 100))\n",
"step-4": "\"\"\"\nCP1404 - Practical\nCode that produces a random number b... | [
0,
1,
2,
3
] |
# -*- coding: utf-8 -*-
"""
Created on Tue May 22 15:01:21 2018
@author: Weiyu_Lee
"""
import numpy as np
import pandas as pd
import pickle
import matplotlib.pyplot as plt
from datetime import datetime, timedelta
import config as conf
def get_stock_time_series(data_df, stock_id):
curr_ID_dat... | normal | {
"blob_id": "6a7e5a78f516cecf083ca3900bdaaf427bedd497",
"index": 756,
"step-1": "<mask token>\n\n\ndef get_stock_time_series(data_df, stock_id):\n curr_ID_data = data_df.loc[stock_id]\n output = np.array(curr_ID_data[0])\n for i in range(1, len(curr_ID_data.index)):\n output = np.vstack((output, ... | [
1,
2,
3,
4,
5
] |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from .variational_legacy import *
| normal | {
"blob_id": "ea07cb640e76ced8be92b55ee14e1d3058e073c9",
"index": 845,
"step-1": "<mask token>\n",
"step-2": "from .variational_legacy import *\n",
"step-3": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\nfrom .variational_legacy import *\n",
"step-4": null,
"step-5": null,
"step-ids": [
0,
... | [
0,
1,
2
] |
# ------------------------------------------------------------------------------------------------------
# Copyright (c) Leo Hanisch. All rights reserved.
# Licensed under the BSD 3-Clause License. See LICENSE.txt in the project root for license information.
# ---------------------------------------------------------... | normal | {
"blob_id": "917a291c7b62dee392d7411c3e039949d74d7af8",
"index": 1375,
"step-1": "<mask token>\n\n\nclass Nest:\n <mask token>\n <mask token>\n <mask token>\n\n def update_pos(self, new_position: Tuple[float, float]) ->None:\n \"\"\"\n If the new position's value is better than the old ... | [
2,
3,
4,
5,
7
] |
"""
This is the common util file
"""
from faker import Faker
from pytest_practical.helper.api_helpers import woo_request_helper
fake = Faker()
def generate_random_email_and_password():
"""
Function to generate random email id and password
"""
email = fake.email()
password_string = fake.password(... | normal | {
"blob_id": "0dab663847fdb4efa419882519616b7a89d0bbe8",
"index": 1716,
"step-1": "<mask token>\n\n\ndef generate_random_email_and_password():\n \"\"\"\n Function to generate random email id and password\n \"\"\"\n email = fake.email()\n password_string = fake.password()\n random_info = {'email'... | [
4,
7,
8,
9,
11
] |
import os
class Idea:
def __init__(self, folder):
self.folder = folder
def name(self):
return "jetbrains-idea"
def cmd(self):
return "intellij-idea-ultimate-edition %s" % self.folder
| normal | {
"blob_id": "90fc6e37e3988a2014c66913db61749509db2d53",
"index": 1036,
"step-1": "<mask token>\n\n\nclass Idea:\n <mask token>\n <mask token>\n\n def cmd(self):\n return 'intellij-idea-ultimate-edition %s' % self.folder\n",
"step-2": "<mask token>\n\n\nclass Idea:\n\n def __init__(self, fold... | [
2,
3,
4,
5,
6
] |
import pandas as pd
import numpy as np
import seaborn as sns
from matplotlib import pyplot as plt, ticker
from analysis.report import lib_plot
from analysis.report.lib_agent import known_agents
from analysis.report.lib_fmt import fmt_thousands
from lib_db import DBClient
def main(db_client: DBClient):
sns.set_th... | normal | {
"blob_id": "51b28650f8ae6cbda3d81695acd27744e9bfebd1",
"index": 2528,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef main(db_client: DBClient):\n sns.set_theme()\n peer_ids = db_client.get_dangling_peer_ids()\n arrivals = db_client.get_inter_arrival_time(peer_ids)\n results_df = pd.D... | [
0,
1,
2,
3,
4
] |
import math
def calcula_distancia_do_projetil(v, O, y0):
g = 9.8
return ((v ** 2) / 2 * g) * (1 + math.sqrt(1 + ( 2 * g * y0 / (v ** 2) * (math.sin(O) ** 2)))) * math.sin(2 * O) | normal | {
"blob_id": "0a459b4aeb2a16c06c1d89dafb656028b235a31e",
"index": 9415,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef calcula_distancia_do_projetil(v, O, y0):\n g = 9.8\n return v ** 2 / 2 * g * (1 + math.sqrt(1 + 2 * g * y0 / v ** 2 * math.\n sin(O) ** 2)) * math.sin(2 * O)\n",
"s... | [
0,
1,
2,
3
] |
from sklearn.svm import SVC
from helper_functions import *
from sklearn.metrics import accuracy_score
from sklearn.model_selection import train_test_split
from sklearn.utils import shuffle
from sklearn.preprocessing import StandardScaler
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import glob
impor... | normal | {
"blob_id": "89db4431a252d024381713eb7ad86346814fcbe4",
"index": 7955,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef process_image(image):\n draw_image = np.copy(image)\n window_list_32 = slide_window(image, y_start_stop=y_start_stop_32,\n xy_window=(32, 32), xy_overlap=xy_overlap_3... | [
0,
1,
2,
3,
4
] |
import unittest
import A1
import part_manager
import security
class test_A1(unittest.TestCase):
# ----------------------------------- set up the mock data for test cases -----------------------------------
def setUp(self):
self.security1 = security.Security("XXX-1234-ABCD-1234", None)
self... | normal | {
"blob_id": "2ba5cb1265090b42b9a4838b792a3e81b209ba1a",
"index": 3822,
"step-1": "<mask token>\n\n\nclass test_A1(unittest.TestCase):\n\n def setUp(self):\n self.security1 = security.Security('XXX-1234-ABCD-1234', None)\n self.security2 = security.Security(None, 'kkklas8882kk23nllfjj88290')\n ... | [
6,
7,
8,
9,
11
] |
tn=int(input())
for ti in range(tn):
#ans = work()
rn,cn = [int(x) for x in input().split()]
evenRow='-'.join(['+']*(cn+1))
oddRow='.'.join(['|']*(cn+1))
artrn = rn*2+1
print(f'Case #{ti+1}:')
for ri in range(artrn):
defaultRow = evenRow if ri%2==0 else oddRow
if ri//2==0:
... | normal | {
"blob_id": "1972e3733918da654cd156a500432a35a239aed4",
"index": 1841,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor ti in range(tn):\n rn, cn = [int(x) for x in input().split()]\n evenRow = '-'.join(['+'] * (cn + 1))\n oddRow = '.'.join(['|'] * (cn + 1))\n artrn = rn * 2 + 1\n print(... | [
0,
1,
2,
3
] |
import pytest
import numpy as np
from GSPA_DMC import SymmetrizeWfn as symm
def test_swap():
cds = np.load('h3o_data/ffinal_h3o.npy')
dws = np.load('h3o_data/ffinal_h3o_dw.npy')
cds = cds[:10]
a = symm.swap_two_atoms(cds, dws, atm_1=1, atm_2=2)
b = symm.swap_group(cds, dws, atm_list_1=[0, 1], atm_... | normal | {
"blob_id": "4ecd756b94b0cbab47a8072e9bccf26e2dd716d0",
"index": 7833,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_swap():\n cds = np.load('h3o_data/ffinal_h3o.npy')\n dws = np.load('h3o_data/ffinal_h3o_dw.npy')\n cds = cds[:10]\n a = symm.swap_two_atoms(cds, dws, atm_1=1, atm... | [
0,
1,
2
] |
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
#
from __future__ import absolute_import, division, print_function, unicode_literals
from collections import defaultdict
import os
import torch
import numpy as np
import pickle
from sklearn.linear_model import Ridge, Lasso
from biplnn.log import getLogger
from biplnn.utils... | normal | {
"blob_id": "9f86ff37d3a72364b5bd83e425d8151136c07dd3",
"index": 6294,
"step-1": "<mask token>\n\n\ndef fit_linear_model(x, y):\n logger.info('Using Lasso')\n lr = Lasso(alpha=0.01)\n lr.fit(x, y)\n return SharedScalerModel(lr)\n\n\nclass SharedScalerModel:\n\n def __init__(self, lm):\n sel... | [
7,
8,
10,
11,
12
] |
from django import forms
from .models import Project
from user.models import User
from assets.models import Assets
class CreateProjectForm(forms.ModelForm):
project_name = forms.CharField(
label='项目名',
widget=forms.TextInput(
attrs={"class": "form-control"}
)
)
project_... | normal | {
"blob_id": "599c5c02397f283eb00f7343e65c5cb977442e38",
"index": 3848,
"step-1": "<mask token>\n\n\nclass CreateProjectForm(forms.ModelForm):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n model = Project\n fields = ['project_name', 'project_desc', 'a... | [
3,
4,
5,
6,
7
] |
#coding=utf-8
import yaml
import os
import os.path
import shutil
import json
import subprocess
import sys
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
import rtool.taskplugin.plugin.MultiProcessRunner as MultiProcessRunner
import rtool.utils as utils
logger = utils.getLogger('CopyRes')
def run():
lo... | normal | {
"blob_id": "364150d6f37329c43bead0d18da90f0f6ce9cd1b",
"index": 4886,
"step-1": "<mask token>\n\n\nclass CopyResAction:\n <mask token>\n default_option = None\n res_root = None\n packing_root = None\n ignore_list = []\n\n def setResRoot(self, root):\n self.res_root = root\n pass\... | [
6,
8,
13,
14,
15
] |
# -*- coding: utf-8 -*-
#imports
from math import sqrt, pi, exp
from csv import reader
from random import seed,randrange
"""
Helper functions
"""
#calculate probability
def probability(x,avg,standev):
exponent = exp(-((x-avg)**2 / (2 * standev**2)))
return (1/(sqrt(2*pi) *standev)) * exponent
#mean
def avg(... | normal | {
"blob_id": "f92a1398a27541557ec5bbf752d44ce40d1df94a",
"index": 4131,
"step-1": "<mask token>\n\n\ndef standev(vals):\n mean = avg(vals)\n var = sum([((x - mean) ** 2) for x in vals]) / float(len(vals) - 1)\n return sqrt(var)\n\n\n<mask token>\n\n\ndef read_csv(file_name):\n data = list()\n with ... | [
9,
11,
12,
18,
19
] |
"""Test Assert module."""
import unittest
from physalia import asserts
from physalia.fixtures.models import create_random_sample
from physalia.models import Measurement
# pylint: disable=missing-docstring
class TestAssert(unittest.TestCase):
TEST_CSV_STORAGE = "./test_asserts_db.csv"
def setUp(self):
... | normal | {
"blob_id": "eda1c1db5371f5171f0e1929e98d09e10fdcef24",
"index": 1677,
"step-1": "<mask token>\n\n\nclass TestAssert(unittest.TestCase):\n <mask token>\n <mask token>\n\n def test_consumption_below(self):\n sample = create_random_sample(10, 1)\n asserts.consumption_below(sample, 11)\n ... | [
4,
5,
6,
7,
8
] |
from django.db import models
from django.utils import timezone
class User(models.Model):
class Meta:
db_table = "User"
app_label = "backlog"
webin_id = models.CharField(
"ENA's submission account id", max_length=15, unique=True, primary_key=True
)
registered = models.BooleanFi... | normal | {
"blob_id": "dff5e75460637cf175b1b65af3320d01dc2e35b6",
"index": 2628,
"step-1": "<mask token>\n\n\nclass Blacklist(models.Model):\n\n\n class Meta:\n db_table = 'Blacklist'\n app_label = 'backlog'\n date_blacklisted = models.DateField(auto_now_add=True)\n pipeline_version = models.Foreign... | [
35,
36,
38,
45,
47
] |
import time
import numpy as np
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL import *
from utils import *
g = 9.8
t_start = 0
def init():
glClearColor(1.0, 1.0, 1.0, 1.0)
glClear(GL_COLOR_BUFFER_BIT)
glColor3f(1.0, 0.0, 0.0)
glPointSize(2)
gluOrtho2D(0.0, 500.0, 0.0, 500.0)
... | normal | {
"blob_id": "d85c0929b22f57367c0e707bac78e56027113417",
"index": 4539,
"step-1": "<mask token>\n\n\ndef init():\n glClearColor(1.0, 1.0, 1.0, 1.0)\n glClear(GL_COLOR_BUFFER_BIT)\n glColor3f(1.0, 0.0, 0.0)\n glPointSize(2)\n gluOrtho2D(0.0, 500.0, 0.0, 500.0)\n\n\n<mask token>\n\n\ndef mouse(btn, s... | [
4,
6,
7,
8,
9
] |
# Example 15-5. Using a BookDict, but not quite as intended
>>> from books import BookDict
>>> pp = BookDict(title='Programming Pearls',
... authors='Jon Bentley',
... isbn='0201657880',
... pagecount=256)
>>> pp
{'title': 'Programming Pearls', 'authors': 'Jon Bentley', 'isbn'... | normal | {
"blob_id": "ab9d8e36518c4d42f1e29fbc5552078a5a338508",
"index": 7010,
"step-1": "# Example 15-5. Using a BookDict, but not quite as intended\n\n>>> from books import BookDict\n>>> pp = BookDict(title='Programming Pearls',\n... authors='Jon Bentley',\n... isbn='0201657880',\n... ... | [
0
] |
from draft import *
# create a train station
platform = Platform('platform 1')
train_station = TrainStation('Linz')
train_station.add_platform(platform)
# create a train
train_1 = ICE('ICE 1')
platform.accept_train(train_1)
train_section_1 = TrainSection('First section')
train_section_2 = TrainSection('Second section')... | normal | {
"blob_id": "5900dc0acde45ac9a31dc9d489aa8dae304d626b",
"index": 1791,
"step-1": "<mask token>\n",
"step-2": "<mask token>\ntrain_station.add_platform(platform)\n<mask token>\nplatform.accept_train(train_1)\n<mask token>\ntrain_1.dock_section(train_section_1)\ntrain_1.dock_section(train_section_2)\ntrain_1.doc... | [
0,
1,
2,
3,
4
] |
import os
from flask import request, jsonify
from flask_api import FlaskAPI
from flask_api.exceptions import NotAcceptable
from dotenv import load_dotenv
load_dotenv(dotenv_path='./.env')
from src.service.jira import jira
from src.service.helper import helper
application = FlaskAPI(__name__)
jiraservice = jira()
help... | normal | {
"blob_id": "72e03e7199044f3ed1d562db622a7b884fa186b0",
"index": 2206,
"step-1": "<mask token>\n\n\n@application.route('/')\ndef hello_world():\n return jsonify({'Hello': 'World'})\n\n\n<mask token>\n",
"step-2": "<mask token>\nload_dotenv(dotenv_path='./.env')\n<mask token>\n\n\n@application.route('/')\nde... | [
1,
3,
4,
5,
6
] |
import random
import pygame
pygame.init()
# 큐브의 크기
cubeSize = 2
# GUI 관련 변수
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 204, 0)
ORANGE = (255, 102, 0)
WHITE = (255, 255, 255)
GREY = (128, 128, 128)
pieceSize = 50
gridSize = pieceSize * cubeSize
screen = pygame.display.se... | normal | {
"blob_id": "1d8e48aab59869831defcccdd8902230b0f3daa7",
"index": 5368,
"step-1": "<mask token>\n\n\nclass Cube:\n <mask token>\n\n def sortPieces(self):\n self.pieces.sort(key=lambda x: x.location[2] * cubeSize * cubeSize +\n x.location[1] * cubeSize + x.location[0])\n <mask token>\n\n... | [
19,
23,
24,
26,
29
] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 18 13:37:10 2018
@author: ninja1mmm
"""
import os
import numpy as np
import pandas as pd
from sklearn import preprocessing
def file_name(file_dir):
root_tmp=[]
dirs_tmp=[]
files_tmp=[]
for root, dirs, files in os.walk(file_dir): ... | normal | {
"blob_id": "96d5cf948a9b0f622889977e8b26993299bceead",
"index": 770,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef file_name(file_dir):\n root_tmp = []\n dirs_tmp = []\n files_tmp = []\n for root, dirs, files in os.walk(file_dir):\n root_tmp.append(root)\n dirs_tmp.app... | [
0,
2,
3,
4,
5
] |
from django.db import models
class Brokerage(models.Model):
BrokerageName = models.CharField(max_length=500)
#To-Do Fix additional settings for ImagesFields/FileFields
#BrokerageLogo = ImageField
ReviewLink = models.CharField(max_length=1000)
ContactLink = models.CharField(max_length=1000)
TotalAgents = models.I... | normal | {
"blob_id": "174f744b641ee20272713fa2fe1991cb2c76830a",
"index": 99,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\nclass Brokerage(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... | [
0,
1,
2,
3,
4
] |
mlt = 1
mlt_sum = 0
num_sum = 0
for i in range(1,101):
mlt = (i ** 2)
mlt_sum += mlt
num_sum += i
print((num_sum ** 2) - mlt_sum)
| normal | {
"blob_id": "6f877dccab8d62e34b105bbd06027cbff936e3aa",
"index": 6885,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(1, 101):\n mlt = i ** 2\n mlt_sum += mlt\n num_sum += i\nprint(num_sum ** 2 - mlt_sum)\n",
"step-3": "mlt = 1\nmlt_sum = 0\nnum_sum = 0\nfor i in range(1, 101):\... | [
0,
1,
2,
3
] |
#juego trivia hecho por mayu xD
print('¡hola! te invito a jugar mi juego trivia, trataremos temas como termux xd y entre otras cosas')
n1 = input('\n por favor dime como te llamas:')
print('\nmucho gusto', n1, ',empecemos')
puntaje = 0
print('me puedes decir con que comando en linux puedo listar la informacion de ... | normal | {
"blob_id": "0c297e6f79682896e98c7a2933a4da6d9af7d7fe",
"index": 9060,
"step-1": "<mask token>\n",
"step-2": "print(\n '¡hola! te invito a jugar mi juego trivia, trataremos temas como termux xd y entre otras cosas'\n )\n<mask token>\nprint('\\nmucho gusto', n1, ',empecemos')\n<mask token>\nprint(\n 'm... | [
0,
1,
2,
3
] |
array=list(map(int,input().split(" ")))
nums=list(set(array))
occ=[]
for num in nums:
count=array.count(num)
occ.append((int(num),int(count)))
ans=[]
print(occ)
occ.sort(key=lambda x: x[1],reverse=True)
print(occ)
for number,count in (occ):
for i in range(count):
ans.append(number)
print (ans) | normal | {
"blob_id": "acbe4afee81cb6b9c0b8404d470c3f7f5685477c",
"index": 1700,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor num in nums:\n count = array.count(num)\n occ.append((int(num), int(count)))\n<mask token>\nprint(occ)\nocc.sort(key=lambda x: x[1], reverse=True)\nprint(occ)\nfor number, count... | [
0,
1,
2,
3
] |
def maior(a,b):
if a > b:
return a
else:
return b
a = int(input("Digite o 1 valor: "))
b = int(input("Digite o 2 valor: "))
print(maior(a,b))
| normal | {
"blob_id": "f4ca7f31000a1f649876b19ef937ece9958dd60f",
"index": 5352,
"step-1": "<mask token>\n",
"step-2": "def maior(a, b):\n if a > b:\n return a\n else:\n return b\n\n\n<mask token>\n",
"step-3": "def maior(a, b):\n if a > b:\n return a\n else:\n return b\n\n\n<ma... | [
0,
1,
2,
3,
4
] |
'''
Inspection of the network with unlabelled data
'''
import numpy as np
import matplotlib.pyplot as plt
from main import IMG_SIZE, MODEL_NAME, model
model.load(MODEL_NAME)
''' COMMENT OUT FOLLOWING AS APPROPRIATE '''
# if you need to create the data:
# test_data = process_test_... | normal | {
"blob_id": "02d7022c7d864354379009577d64109601190998",
"index": 7034,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nmodel.load(MODEL_NAME)\n<mask token>\nfor num, data in enumerate(test_data[:12]):\n img_num = data[1]\n img_data = data[0]\n y = fig.add_subplot(3, 4, num + 1)\n orig = img_da... | [
0,
1,
2,
3,
4
] |
import sys
import os
arcpy_path = [r'D:\software\ArcGIS\python 27\ArcGIS10.2\Lib\site-packages',
r'D:\software\ArcGIS\Desktop 10.2\Desktop10.2\arcpy',
r'D:\software\ArcGIS\Desktop 10.2\Desktop10.2\bin',
r'D:\software\ArcGIS\Desktop 10.2\Desktop10.2\ArcToolbox\Scripts']
sys.pa... | normal | {
"blob_id": "eab2cdd92d3be5760f13e747b05ca902eaf9aca8",
"index": 8287,
"step-1": "<mask token>\n\n\ndef CreateCGCS2000prj(shpPath):\n body = (\n 'GEOGCS[\"CGCS_2000\",DATUM[\"D_2000\",SPHEROID[\"S_2000\",6378137.0,298.2572221010041]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]]'\n ... | [
1,
3,
6,
9,
10
] |
from __future__ import absolute_import, division, print_function
import time
from flytekit.sdk.tasks import python_task, dynamic_task, inputs, outputs
from flytekit.sdk.types import Types
from flytekit.sdk.workflow import workflow_class, Input
from six.moves import range
@inputs(value1=Types.Integer)
@outputs(out=T... | normal | {
"blob_id": "c30b0db220bdacd31ab23aa1227ce88affb79daa",
"index": 2322,
"step-1": "<mask token>\n\n\n@workflow_class\nclass FlyteDJOLoadTestWorkflow(object):\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\n@workflow_class\nclass FlyteDJOLoadTestWorkflow(object):\n tasks_count = Input(Typ... | [
1,
2,
4,
5,
6
] |
__author__ = 'mvoronin'
| normal | {
"blob_id": "e5a7b0cbc82b57578f6dcbf676e8f589c6e9ac1b",
"index": 5663,
"step-1": "<mask token>\n",
"step-2": "__author__ = 'mvoronin'\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
class ConfigError(ValueError):
pass
| normal | {
"blob_id": "76dd4d2b5f68683c77f9502a2298e65c97db7c8d",
"index": 1263,
"step-1": "<mask token>\n",
"step-2": "class ConfigError(ValueError):\n pass\n",
"step-3": null,
"step-4": null,
"step-5": null,
"step-ids": [
0,
1
]
} | [
0,
1
] |
#Multiple Word Palindromes
#Ex 72 extended
word = input("Word: ")
new = []
o = []
r = []
#canceling out the spaces
for i in range(len(word)):
if word[i] in ".,?!" or word[i] == ' ':
pass
else:
new.append(word[i])
#original
for i in range(len(new)):
o.append(new[i])
#reverse
for i in range(... | normal | {
"blob_id": "c6ab82d7f59faeee2a74e90a96c2348b046d0889",
"index": 7382,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(len(word)):\n if word[i] in '.,?!' or word[i] == ' ':\n pass\n else:\n new.append(word[i])\nfor i in range(len(new)):\n o.append(new[i])\nfor i in ra... | [
0,
1,
2,
3
] |
from django.contrib import admin
from search.models import PrimaryCategory,PlaceCategory
class PrimaryCategoryAdmin(admin.ModelAdmin):
list_display = ('primary_name','is_active','description','image',)
actions = None
def has_delete_permission(self,request,obj=None):
return False
... | normal | {
"blob_id": "606abf8501d85c29051df4bf0276ed5b098ee6c5",
"index": 8679,
"step-1": "<mask token>\n\n\nclass PrimaryCategoryAdmin(admin.ModelAdmin):\n <mask token>\n <mask token>\n <mask token>\n\n\nclass PlaceCategoryAdmin(admin.ModelAdmin):\n list_display = ('category_name', 'is_paid', 'description', ... | [
5,
6,
7,
8,
10
] |
from django.urls import path
from . import views
app_name = 'adverts'
urlpatterns = [
path('', views.AdvertListView.as_view(), name="list"),
path('create/', views.AdvertFormView.as_view(), name='adverts-create'),
path('<str:category>/', views.AdvertListView.as_view(), name="adverts-list-categories"),
]
| normal | {
"blob_id": "8c1718f56a73fdd962154abfaedc7c0c3cb0d9ba",
"index": 6626,
"step-1": "<mask token>\n",
"step-2": "<mask token>\napp_name = 'adverts'\nurlpatterns = [path('', views.AdvertListView.as_view(), name='list'), path(\n 'create/', views.AdvertFormView.as_view(), name='adverts-create'), path\n ('<str:... | [
0,
1,
2,
3
] |
# Copyright 2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You
# may not use this file except in compliance with the License. A copy of
# the License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompa... | normal | {
"blob_id": "653c8db6741a586694d91bd9928d8326cce9e41d",
"index": 6373,
"step-1": "<mask token>\n\n\ndef get_application_name(default=_marker, prompt=True):\n global _selected_app\n result = None\n try:\n result = fileoperations.get_config_setting('global', 'application_name'\n )\n e... | [
2,
4,
5,
6,
7
] |
from stats_arrays.distributions import GeneralizedExtremeValueUncertainty as GEVU
from stats_arrays.errors import InvalidParamsError
from ..base import UncertaintyTestCase
import numpy as np
class GeneralizedExtremeValueUncertaintyTestCase(UncertaintyTestCase):
def test_random_variables(self):
params = s... | normal | {
"blob_id": "997c1c86848b59a3986a579d5b1b50313fdfdf44",
"index": 8161,
"step-1": "<mask token>\n\n\nclass GeneralizedExtremeValueUncertaintyTestCase(UncertaintyTestCase):\n\n def test_random_variables(self):\n params = self.make_params_array()\n params['loc'] = 2\n params['scale'] = 5\n ... | [
4,
5,
6,
7,
8
] |
users = {1: "Tom", 2: "Bob", 3: "Bill"}
elements = {"Au": "Oltin", "Fe": "Temir", "H": "Vodorod", "O": "Kislorod"} | normal | {
"blob_id": "a24ab93983546f8ae0fab042c121ac52388e62e8",
"index": 2967,
"step-1": "<mask token>\n",
"step-2": "users = {(1): 'Tom', (2): 'Bob', (3): 'Bill'}\nelements = {'Au': 'Oltin', 'Fe': 'Temir', 'H': 'Vodorod', 'O': 'Kislorod'}\n",
"step-3": "users = {1: \"Tom\", 2: \"Bob\", 3: \"Bill\"}\n\nelements = {\... | [
0,
1,
2
] |
# coding: utf-8
"""
SevOne API Documentation
Supported endpoints by the new RESTful API # noqa: E501
OpenAPI spec version: 2.1.18, Hash: db562e6
Generated by: https://github.com/swagger-api/swagger-codegen.git
"""
import pprint
import re # noqa: F401
import six
from swagger_client.models.d... | normal | {
"blob_id": "25d4fa44cb17048301076391d5d67ae0b0812ac7",
"index": 3988,
"step-1": "<mask token>\n\n\nclass RawDataSettingsV1(object):\n <mask token>\n <mask token>\n <mask token>\n <mask token>\n\n def __init__(self, data_aggregation_setting=None, raw_data_setting=None,\n units_setting=None,... | [
8,
15,
17,
18,
19
] |
'''
Problem 24
A permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lexicographic order. The lexicographic permutations of 0, 1 and 2 are:
012 021 102 120 ... | normal | {
"blob_id": "f2ac9904aaa4c12ef2954b88c37ffd0c97aadf5a",
"index": 9398,
"step-1": "'''\nProblem 24\n\n\nA permutation is an ordered arrangement of objects. For example, 3124 is one possible permutation of the digits 1, 2, 3 and 4. If all of the permutations are listed numerically or alphabetically, we call it lex... | [
0
] |
# coding:utf-8
def application(env,handle_headers):
status="200"
response_headers=[
('Server','')
]
return "" | normal | {
"blob_id": "8c318d7152bfdf2bc472258eb87dfa499b743193",
"index": 797,
"step-1": "<mask token>\n",
"step-2": "def application(env, handle_headers):\n status = '200'\n response_headers = [('Server', '')]\n return ''\n",
"step-3": "# coding:utf-8\n\n\ndef application(env,handle_headers):\n status=\"... | [
0,
1,
2
] |
import unittest
import requests
class TestAudiobookResponse(unittest.TestCase):
def test_audiobook_can_insert(self):
""" test that audiobook can be inserted into db """
data = {
"audiotype": "Audiobook",
"metadata": {
"duration": 37477,
"ti... | normal | {
"blob_id": "e651edcbe68264e3f25180b10dc8e9d5620ecd6b",
"index": 3656,
"step-1": "<mask token>\n\n\nclass TestAudiobookResponse(unittest.TestCase):\n\n def test_audiobook_can_insert(self):\n \"\"\" test that audiobook can be inserted into db \"\"\"\n data = {'audiotype': 'Audiobook', 'metadata':... | [
4,
5,
6,
7,
8
] |
import numpy as np
import cv2
import skimage.color
import skimage.filters
import skimage.io
from sklearn.model_selection import train_test_split
from sklearn import preprocessing
import pickle
from sklearn.base import BaseEstimator, ClassifierMixin
from sklearn.utils import check_random_state
from keras.preprocessing.i... | normal | {
"blob_id": "42ae3804c2d8f6a0d440e2bb6231186a868630b1",
"index": 2772,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint('Train Benign: ' + str(np.count_nonzero(Y_Train == 0)))\nprint('Train Malignant: ' + str(np.count_nonzero(Y_Train == 1)))\nprint('Test Benign: ' + str(np.count_nonzero(Y_Test == 0))... | [
0,
1,
2,
3,
4
] |
from schemasheets.schemasheet_datamodel import SchemaSheet
RECORD = "Record"
FIELD = "Field"
METATYPE = "MetaType"
INFO = "Info"
CV = "CV"
PV = "PV"
SDO_MAPPINGS = "schema.org"
WD_MAPPINGS = "wikidata"
DATATYPE = "Datatype"
CASES = [
(1,
[
{
RECORD: "> class",
INFO: " descript... | normal | {
"blob_id": "25dc0395da1f1ac2ccd990151c3e5b250802b402",
"index": 2749,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_parse_header():\n print()\n for case_id, case in CASES:\n ss = SchemaSheet.from_dictreader(case)\n tc = ss.table_config\n info_cc = tc.columns[INFO... | [
0,
1,
2,
3,
4
] |
from collections import Counter
from copy import deepcopy
from itertools import count
from traceback import print_exc
#https://www.websudoku.com/?level=4
class SudukoBoard:
side=3
sz=side*side
class Cell:
def __init__(self,board,row,col):
self._values= [None] * SudukoBoard.sz
... | normal | {
"blob_id": "44d9e628e31cdb36088b969da2f6e9af1b1d3efe",
"index": 7841,
"step-1": "<mask token>\n\n\nclass SudukoBoard:\n <mask token>\n <mask token>\n\n\n class Cell:\n\n def __init__(self, board, row, col):\n self._values = [None] * SudukoBoard.sz\n self._value = None\n ... | [
6,
8,
9,
10,
11
] |
"""
It's annoying that we have to do it here but for something like Ant, we're not going to be able to
specify it easily inside of the rbf_hyper_parameters file. Because, for something like Ant, we have
2 COM dimensions, and Bipedal we have 1.
So, we're going to do something similar to shaping_functions.
The way it'... | normal | {
"blob_id": "5529813e10e4a30a60c28242be9d1a8822fb58af",
"index": 9685,
"step-1": "<mask token>\n\n\ndef action_scaling(env, action_scaler):\n \"\"\"\n This is actually going to just be \"action scaling\". Because,\n it's all about the ratio, and the ratio doesn't change!\n \"\"\"\n try:\n s... | [
3,
4,
6,
7,
8
] |
from .candles import CandleCallback
from .firestore import FirestoreTradeCallback
from .gcppubsub import GCPPubSubTradeCallback
from .thresh import ThreshCallback
from .trades import (
NonSequentialIntegerTradeCallback,
SequentialIntegerTradeCallback,
TradeCallback,
)
__all__ = [
"FirestoreTradeCallbac... | normal | {
"blob_id": "b6dc29ae5661f84273ff91a124420bc10c7b6f6e",
"index": 3704,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n__all__ = ['FirestoreTradeCallback', 'GCPPubSubTradeCallback',\n 'CandleCallback', 'TradeCallback', 'ThreshCallback',\n 'SequentialIntegerTradeCallback', 'NonSequentialIntegerTradeC... | [
0,
1,
2,
3
] |
# -*- coding: UTF-8 -*-
from flask import Blueprint, jsonify, request, abort, current_app
import json
from config import config_orm_initial
orm = config_orm_initial.initialize_orm()
session = orm['dict_session']
Article_list = orm['dict_Articlelist']
user = orm['dict_user']
app = Blueprint('api_get_comments', __name_... | normal | {
"blob_id": "016c004fd95d901a6d55b6f7460397223a6baa3b",
"index": 1881,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@app.route('/comments/<article_id>', methods=['POST'])\ndef get_comments(article_id):\n comments_range = request.form.get('comments_for_single')\n try:\n temp_list = json... | [
0,
1,
2,
3,
4
] |
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under t... | normal | {
"blob_id": "6339a1a06319a748030b3411c7a8d00f36336e65",
"index": 9778,
"step-1": "<mask token>\n\n\nclass RemovedResourceWarning(OpenStackDeprecationWarning):\n <mask token>\n\n\nclass RemovedFieldWarning(OpenStackDeprecationWarning):\n \"\"\"Indicates that a field has been removed in newer API versions an... | [
11,
12,
13,
14,
15
] |
import unittest
import subprocess
import tempfile
import os
import filecmp
import shutil
import cfg
import utils
class TestFunctionalHumannEndtoEndBiom(unittest.TestCase):
"""
Test humann with end to end functional tests
"""
def test_humann_fastq_biom_output(self):
"""
Test the standa... | normal | {
"blob_id": "27702f72ae147c435617acaab7dd7e5a5a737b13",
"index": 8152,
"step-1": "<mask token>\n\n\nclass TestFunctionalHumannEndtoEndBiom(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def test_humann_gene_families_biom_input(self):\n \"\"\"\n Test the standard hu... | [
2,
4,
5,
6,
7
] |
# Code
import json
import os
import pandas
from pathlib import Path
from asyncio import sleep
# Import default websocket conection instance
from channels.generic.websocket import AsyncJsonWebsocketConsumer
# Global variable ----------
timeout = 0.5
# Get curent working directory
cwd = os.getcwd() # Get... | normal | {
"blob_id": "466ffbd1f25423e4209fa7331d8b824b2dd3cd70",
"index": 4031,
"step-1": "<mask token>\n\n\nclass recomend(AsyncJsonWebsocketConsumer):\n\n async def connect(self):\n await self.accept()\n while True:\n df = pandas.read_csv(dataDir + 'Readings.csv', sep='\\\\t')\n r... | [
6,
7,
8,
10,
13
] |
import os
import sendgrid
class Mail:
def __init__(self, to, subject, msg):
self.to = to
self.subject = subject
self.msg = msg
def send(self):
sg = sendgrid.SendGridClient(os.environ.get('SENDGRID_KEY', ''))
message = sendgrid.Mail()
message.add_to(self.to)
... | normal | {
"blob_id": "bf60e34190f4c453c85baaf2fbbff027fb77b7c8",
"index": 4512,
"step-1": "import os\nimport sendgrid\n\n\nclass Mail:\n def __init__(self, to, subject, msg):\n self.to = to\n self.subject = subject\n self.msg = msg\n\n def send(self):\n sg = sendgrid.SendGridClient(os.en... | [
0
] |
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 23 20:33:08 2018
@author: ashima.garg
"""
import tensorflow as tf
class Layer():
def __init__(self, shape, mean, stddev):
self.weights = tf.Variable(tf.random_normal(shape=shape, mean=mean, stddev=stddev))
self.biases = tf.Variable(tf.zeros(shape=[s... | normal | {
"blob_id": "ed246f2887f19ccf922a4d386918f0f0771fb443",
"index": 5106,
"step-1": "<mask token>\n\n\nclass Convolution_Layer(Layer):\n\n def __init__(self, shape, mean, stddev):\n super(Convolution_Layer, self).__init__(shape, mean, stddev)\n\n def feed_forward(self, input_data, stride):\n con... | [
6,
7,
8,
9,
11
] |
"""
Created on Apr 27, 2017
@author: Franziska Schlösser
"""
from ipet.parsing.Solver import Solver
import re
from ipet import Key
from ipet import misc
class MIPCLSolver(Solver):
solverId = "MIPCL"
recognition_expr = re.compile("Reading data")
primalbound_expr = re.compile("Objective value: (\S*)")
dualbound_ex... | normal | {
"blob_id": "191154c896fe441519ad4f343c6d92d6304fb3db",
"index": 8187,
"step-1": "<mask token>\n\n\nclass MIPCLSolver(Solver):\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 <... | [
3,
4,
5,
6,
7
] |
# -*- coding:utf-8 -*-
# Copyright (C) 2020. Huawei Technologies Co., Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | normal | {
"blob_id": "a491772258a52bdfc93083343d2a2e48a240340d",
"index": 490,
"step-1": "<mask token>\n\n\n@ClassFactory.register(ClassType.METRIC, alias='accuracy')\nclass Accuracy(MetricBase):\n <mask token>\n __metric_name__ = 'accuracy'\n\n def __init__(self, topk=(1, 5)):\n \"\"\"Init Accuracy metri... | [
12,
13,
14,
15,
16
] |
__author__ = 'sushil'
from .utilities import decompose_date
from .DateConverter import _bs_to_ad, _ad_to_bs
def convert_to_ad(bs_date):
date_components = decompose_date(bs_date)
year, month, day = date_components
ad_year, ad_month, ad_day = _bs_to_ad(year, month, day)
formatted_date = "{}-{:02}-{:02}"... | normal | {
"blob_id": "e7295336a168aa2361a9090e79465eab5f564599",
"index": 5076,
"step-1": "<mask token>\n\n\ndef convert_to_bs(ad_date):\n date_components = decompose_date(ad_date)\n year, month, day = date_components\n bs_year, bs_month, bs_day = _ad_to_bs(year, month, day)\n formatted_date = '{}-{:02}-{:02}... | [
1,
2,
3,
4,
5
] |
from .base import * # noqa
from .base import env
# exemple https://github.com/pydanny/cookiecutter-django/blob/master/%7B%7Bcookiecutter.project_slug%7D%7D/config/settings/production.py
# GENERAL
# ------------------------------------------------------------------------------
# https://docs.djangoproject.com/en/dev/r... | normal | {
"blob_id": "836df02495ee581f138050be6b7a7a076ea899eb",
"index": 4966,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nSECRET_KEY = env('DJANGO_SECRET_KEY')\nALLOWED_HOSTS = [x.split(':') for x in env.list('DJANGO_ALLOWED_HOSTS')]\nADMINS = [x.split(':') for x in env.list('DJANGO_ADMINS')]\nDATABASES['def... | [
0,
1,
2,
3
] |
# !/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
# -*- coding:utf-8 -*-
# @Author : Jiazhixiang
import requests
from bs4 import BeautifulSoup
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.65 Safari/535.11"
}
# start_url = "htt... | normal | {
"blob_id": "9833af7f5f740e18cbd4d16f59474b4bacaf070c",
"index": 2026,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nprint(response.status_code)\nprint(response.apparent_encoding)\n<mask token>\nfor music in list_music:\n print(music['name'])\n print('所属专辑:' + music['album']['name'])\n print('歌... | [
0,
1,
2,
3,
4
] |
from vector3 import vec3
class ray:
def __init__(self, *args):
if len(args) == 0:
self.A = vec3(0,0,0)
self.B = vec3(1,0,0)
elif len(args) == 2:
if type(args[0]) != vec3 or type(args[1]) != vec3:
raise ValueError("Expected two vec3s")
else:
self.A = args[0]
self.B = args[1]
else:
rais... | normal | {
"blob_id": "a73e3a07ab0ebb90fa744d3dfc8d9da119f99283",
"index": 2070,
"step-1": "<mask token>\n\n\nclass ray:\n\n def __init__(self, *args):\n if len(args) == 0:\n self.A = vec3(0, 0, 0)\n self.B = vec3(1, 0, 0)\n elif len(args) == 2:\n if type(args[0]) != vec3 ... | [
4,
5,
6,
7,
8
] |
import pytest
import numpy as np
from dwave_qbsolv import QBSolv
from src.quantumrouting.solvers import partitionqubo
from src.quantumrouting.types import CVRPProblem
from src.quantumrouting.wrappers.qubo import wrap_vrp_qubo_problem
@pytest.fixture
def cvrp_problem():
max_num_vehicles = 1
coords = [[-15.6570... | normal | {
"blob_id": "f61e9e8069a0e90506c2f03a0cc4a25a16d71b85",
"index": 3732,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\n@pytest.fixture\ndef cvrp_problem():\n max_num_vehicles = 1\n coords = [[-15.6570138544452, -47.802664728268745], [-15.65879313293694,\n -47.7496622016347], [-15.65144038... | [
0,
1,
2,
3
] |
import pandas as pd
def load_covid():
covid = pd.read_csv("https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv")
target = 'new_cases'
date = 'date'
dataset = covid[(covid['location'] == 'World')].copy()[[target, date]]
dataset[date] = pd.to_datetime(datase... | normal | {
"blob_id": "e19529dce407da0f1e21f6a3696efcefac9ed040",
"index": 8500,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef load_covid():\n covid = pd.read_csv(\n 'https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/owid-covid-data.csv'\n )\n target = 'new_cases'... | [
0,
1,
2,
3
] |
''' The previous code does not correcly compute the stiffening coefficients
This program uses the clustering data to re-compute the stiffening coefficients '''
import glob
import sys
import time
#-----------------------------------------------------------------------------------#
#-----------------------------------... | normal | {
"blob_id": "095d7abfc8297e0bf741a4ebb351a7776055623f",
"index": 326,
"step-1": "''' The previous code does not correcly compute the stiffening coefficients \nThis program uses the clustering data to re-compute the stiffening coefficients '''\n\nimport glob\nimport sys\nimport time\n\n#--------------------------... | [
0
] |
from typing import List, Tuple
test_string = "2 3 0 3 10 11 12 1 1 0 1 99 2 1 1 2"
with open('data/day8_input.txt', 'r') as fp:
my_string = fp.read()
class Node:
def __init__(self):
self.metadata = list()
self.children = list()
def checksum(self):
return sum([x for x in self.met... | normal | {
"blob_id": "3bea4413a41a9eecb5e3184d090b646e17892b5c",
"index": 5277,
"step-1": "<mask token>\n\n\nclass Node:\n\n def __init__(self):\n self.metadata = list()\n self.children = list()\n\n def checksum(self):\n return sum([x for x in self.metadata])\n\n def add_child(self, child):\... | [
8,
9,
10,
11,
12
] |
# -*- coding: utf-8 -*-
# Author : Seungyeon Jo
# e-mail : syjo@seculayer.co.kr
# Powered by Seculayer © 2018 AI-Core Team
from mlps.core.data.cnvrtr.ConvertAbstract import ConvertAbstract
class Substr(ConvertAbstract):
def __init__(self, **kwargs):
super().__init__(**kwargs)
def apply(self,... | normal | {
"blob_id": "f704742b9e023a1c3386fed293032fd8196b875e",
"index": 7344,
"step-1": "<mask token>\n\n\nclass Substr(ConvertAbstract):\n <mask token>\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Substr(ConvertAbstract):\n\n def __init__(self, **kwargs):\n super().__init__... | [
1,
3,
4,
5,
6
] |
"""
*********************************************************************
* Project : POP1 (Practical Exam)
* Program name : q2.py
* Author : varunk01
* Purpose : Attempts to solve the question 2 from the exam paper
* Date created : 28/05/2018
*
* Date Author Ver Comment
* 28/05/2018 varunk... | normal | {
"blob_id": "f7d487ec99e2fa901677ab9aec0760a396722e12",
"index": 8245,
"step-1": "<mask token>\n\n\ndef get_choice(attempt):\n \"\"\"\n return an integer input from the user\n \"\"\"\n try:\n user_text = ''\n if attempt == 1:\n user_text = 'Guess a number between 0 and 99:'\n... | [
2,
3,
4,
5,
6
] |
import Libcplx as lc
# 1.Adición de vectores complejos
def adVector(v, w):
n = len(v)
r = []
for k in range(n):
r += [lc.cplxsum(v[k], w[k])]
return r
# 2.Inverso (aditivo) de un vector complejo
def invVector(v):
n = len(v)
r = []
for k in range(n):
r += [lc.cplxproduct((... | normal | {
"blob_id": "5f242ae801a239dde6a22e4fb68b4ef4b2459be6",
"index": 2599,
"step-1": "<mask token>\n\n\ndef adVector(v, w):\n n = len(v)\n r = []\n for k in range(n):\n r += [lc.cplxsum(v[k], w[k])]\n return r\n\n\n<mask token>\n\n\ndef MultEscalarVector(v, w):\n n = len(w)\n r = []\n for... | [
10,
13,
14,
15,
18
] |
#
# Copyright (C) 2005-2006 Rational Discovery LLC
#
# @@ All Rights Reserved @@
# This file is part of the RDKit.
# The contents are covered by the terms of the BSD license
# which is included in the file license.txt, found at the root
# of the RDKit source tree.
#
import argparse
import re
import os
from rd... | normal | {
"blob_id": "4b63df35b36b35f1b886b8981519921a9e697a42",
"index": 4840,
"step-1": "<mask token>\n\n\ndef GetAtomFeatInfo(factory, mol):\n res = [None] * mol.GetNumAtoms()\n feats = factory.GetFeaturesForMol(mol)\n for feat in feats:\n ids = feat.GetAtomIds()\n feature = '%s-%s' % (feat.GetF... | [
5,
6,
7,
8,
9
] |
import sys
import os
sys.path.insert(0, "main")
import main
workspace = os.path.abspath(sys.argv[1])
main.hammer(workspace)
| normal | {
"blob_id": "4e1f7fddb6bd3413dd6a8ca21520d309af75c811",
"index": 931,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nsys.path.insert(0, 'main')\n<mask token>\nmain.hammer(workspace)\n",
"step-3": "<mask token>\nsys.path.insert(0, 'main')\n<mask token>\nworkspace = os.path.abspath(sys.argv[1])\nmain.ham... | [
0,
1,
2,
3,
4
] |
# -*- coding: utf-8 -*-
import numpy as np
import pickle
import os
import feature_extraction
#import topic
file1 = open('vecdict_all.p', 'r')
file2 = open('classif_all.p','r')
vec = pickle.load(file1)
classifier = pickle.load(file2)
file1.close()
file2.close()
#sentence = "I never miss the lecture of Dan Moldovan... | normal | {
"blob_id": "1d1576825f80c3b65ce1b7f8d1daccbbf8543d7d",
"index": 8294,
"step-1": "# -*- coding: utf-8 -*-\n\nimport numpy as np\nimport pickle\nimport os\nimport feature_extraction\n#import topic\n\n\nfile1 = open('vecdict_all.p', 'r')\nfile2 = open('classif_all.p','r')\n\nvec = pickle.load(file1)\nclassifier = ... | [
0
] |
# -*- coding: utf-8 -*-
'''
File Name: bubustatus/utils.py
Author: JackeyGao
mail: junqi.gao@shuyun.com
Created Time: 一 9/14 12:51:37 2015
'''
from rest_framework.views import exception_handler
def custom_exception_handler(exc, context):
# Call REST framework's default exception handler first,
# to get the st... | normal | {
"blob_id": "4e6e4917aee2385fe118d6e58c359a4c9fc50943",
"index": 8617,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef custom_exception_handler(exc, context):\n response = exception_handler(exc, context)\n if response is not None:\n response.data['status_code'] = response.status_code\... | [
0,
1,
2,
3
] |
import os
import stat
from optparse import OptionParser
from bbpgsql.configuration import get_config_from_filename_and_set_up_logging
from bbpgsql.configuration.general import get_data_dir
from subprocess import check_output
import sys
VERSION = ''
class BadArgumentException(Exception):
def __init__(self, msg):
... | normal | {
"blob_id": "eed79a3895975a0475c0b192bd8a42e80def2e78",
"index": 2502,
"step-1": "<mask token>\n\n\nclass BadArgumentException(Exception):\n\n def __init__(self, msg):\n self.msg = msg\n\n def __str__(self):\n return self.msg\n\n\nclass TooManyArgumentsException(Exception):\n\n def __init_... | [
25,
26,
29,
31,
32
] |
import sys
minus = "-"
plus = "+"
divis = "/"
multi = "*"
power = "^"
unary = "-"
br_op = "("
br_cl = ")"
operations = [power, divis, multi, minus, plus]
digits = ['1','2','3','4','5','6','7','8','9','0','.']
def find_close_pos(the_string):
open_count = 0
close_count = 0
for i in range(len(the_string)):
if the... | normal | {
"blob_id": "c0c8f40e43f1c27f8efa47cfc366c6076b77b9c9",
"index": 9337,
"step-1": "import sys\n\nminus = \"-\"\nplus = \"+\"\ndivis = \"/\"\nmulti = \"*\"\npower = \"^\"\nunary = \"-\"\nbr_op = \"(\"\nbr_cl = \")\"\n\noperations = [power, divis, multi, minus, plus]\ndigits = ['1','2','3','4','5','6','7','8','9',... | [
0
] |
#!/usr/bin/python3
import os, re
import csv, unittest
from langtag import langtag
from sldr.iana import Iana
langtagjson = os.path.join(os.path.dirname(__file__), '..', 'pub', 'langtags.json')
bannedchars = list(range(33, 45)) + [47] + list(range(58, 63)) + [94, 96]
def nonascii(s):
cs = [ord(x) for x in s]
i... | normal | {
"blob_id": "e4f194c3dbc3e1d62866343642e41fa1ecdeab93",
"index": 7380,
"step-1": "<mask token>\n\n\nclass Basic(unittest.TestCase):\n <mask token>\n <mask token>\n <mask token>\n\n def _region_test(self, x):\n if x in self.iana.region:\n return True\n elif x in ('XX', 'XK'):\... | [
11,
13,
17,
18,
19
] |
h = 160
xorg = 0
yoff = 400
xcount = 0
xvel = 2
def setup():
size(800, 800)
colorMode(HSB, 360, 1, 1, 1)
background(140, 0.49, 0.75)
frameRate(30)
noStroke()
def draw():
global h, xorg, yoff, xcount, xvel
if frameCount % 10 == 0:
fill(140, 0.49, 0.75, 0.2)
square(0,0,width)... | normal | {
"blob_id": "2257494dec9fccc4e8bd4acf0aff31a73c252a61",
"index": 616,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef draw():\n global h, xorg, yoff, xcount, xvel\n if frameCount % 10 == 0:\n fill(140, 0.49, 0.75, 0.2)\n square(0, 0, width)\n pushMatrix()\n translate(xorg... | [
0,
1,
2,
3,
4
] |
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
def test_register_new_accont(self):
cos = self.cos
cos.get("https://wizzair.com/pl-pl#/")
cos.find_elements_by_class_name('navigation__button navigation__button--simple').click()
cos.find_elements_by_class_name('content__lin... | normal | {
"blob_id": "6efd22feb4f96de74633276b1ec8550f8d853075",
"index": 2657,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef test_register_new_accont(self):\n cos = self.cos\n cos.get('https://wizzair.com/pl-pl#/')\n cos.find_elements_by_class_name(\n 'navigation__button navigation__butt... | [
0,
1,
2,
3
] |
"""
This module contains the logic to resolve the head-tail orientation of a predicted video time series.
"""
import logging
import numpy as np
import numpy.ma as ma
from wormpose.pose.distance_metrics import angle_distance, skeleton_distance
from wormpose.pose.results_datatypes import (
BaseResults,
Shuffle... | normal | {
"blob_id": "b8fcd8e6dce8d210576bc4166dd258e5fd51278d",
"index": 517,
"step-1": "<mask token>\n\n\nclass _PartitionedResults(BaseResults):\n <mask token>\n\n def mask(self, indices):\n self.theta.mask[indices] = True\n self.skeletons.mask[indices] = True\n self.scores.mask[indices] = T... | [
10,
19,
20,
24,
26
] |
from typing import Union
from django.db.models import Q, Value
from django.db.models.functions import Lower, Replace, Trim
from .normalization import (
normalize_doi,
normalize_funkcja_autora,
normalize_grupa_pracownicza,
normalize_isbn,
normalize_kod_dyscypliny,
normalize_nazwa_dyscypliny,
... | normal | {
"blob_id": "47025a30d79341ff0819fe87638e35960a5fc87d",
"index": 6446,
"step-1": "<mask token>\n\n\ndef matchuj_wydzial(nazwa):\n try:\n return Wydzial.objects.get(nazwa__iexact=nazwa.strip())\n except Wydzial.DoesNotExist:\n pass\n\n\ndef matchuj_tytul(tytul: str, create_if_not_exist=False) ... | [
11,
12,
13,
15,
16
] |
from __future__ import print_function
import re
import sys
from pyspark import SparkContext
# define a regular expression for delimiters
NON_WORDS_DELIMITER = re.compile(r'[^\w\d]+')
def main():
if len(sys.argv) < 2:
print('''Usage: pyspark q2.py <file>
e.g. pyspark q2.py file:///home/cloudera/test... | normal | {
"blob_id": "deff4eb3ae933a99036f39213ceaf2144b682904",
"index": 5025,
"step-1": "<mask token>\n\n\ndef main():\n if len(sys.argv) < 2:\n print(\n 'Usage: pyspark q2.py <file>\\n e.g. pyspark q2.py file:///home/cloudera/test_file'\n )\n exit(-1)\n sc = SparkContext(ap... | [
1,
2,
3,
4,
5
] |
# The Minion Game
# Kevin and Stuart want to play the 'The Minion Game'.
# Your task is to determine the winner of the game and their score.
"""
Game Rules
Both players are given the same string, S.
Both players have to make substrings using the letters of the string S.
Stuart has to make words starting with consonant... | normal | {
"blob_id": "c96ebfe41b778e85e954e2b7d6de4b078e72c81f",
"index": 7203,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor i in range(len(string)):\n if string[i] in vowels:\n Kevin += len(string) - i\n else:\n Stuart += len(string) - i\nif Kevin > Stuart:\n print('Kevin', Kevin)\ne... | [
0,
1,
2,
3
] |
# Developed by : Jays Patel (cyberthreatinfo.ca)
# This script is use to find the python Composer packages vulnerabilities from linux machine and python source project.
import time
import glob2
import random
import os.path
from os import path
import ast
import sys
import commands
import re
import requests
from pkg_res... | normal | {
"blob_id": "c4c24c36fe0afba61f8046055690f0c36df7098c",
"index": 9799,
"step-1": "# Developed by : Jays Patel (cyberthreatinfo.ca)\n# This script is use to find the python Composer packages vulnerabilities from linux machine and python source project.\n\nimport time\nimport glob2\nimport random\nimport os.path\n... | [
0
] |
#!/usr/bin/python3
import sys
import csv
infile = sys.stdin
for line in infile:
line = line.strip()
my_list = line.split(',')
if my_list[0] != "ball":
continue
batsman = my_list[4]
bowler = my_list[6]
if my_list[9] == 'run out' or my_list[9] == '""' or my_list[9] == "retired hurt":
... | normal | {
"blob_id": "cfa7dc295c635bbdf707f1e899c4fbf8ea91df9a",
"index": 1209,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor line in infile:\n line = line.strip()\n my_list = line.split(',')\n if my_list[0] != 'ball':\n continue\n batsman = my_list[4]\n bowler = my_list[6]\n if my_l... | [
0,
1,
2,
3,
4
] |
dict1 = [
{'a':1},
{'a':2},
{'a':3}
]
a = dict1[1]['a']
# print(a)
correlation_dict = {'${class_id}':123}
data = {'token': '${self.token}', 'name': 'api测试','class_id': '${class_id}'}
for k in data:
for key in correlation_dict:
if data[k] in key:
data[k] = correlation_dict[key]
pr... | normal | {
"blob_id": "9c05b39a12ab29db99397e62315efddd8cdf1df4",
"index": 456,
"step-1": "<mask token>\n",
"step-2": "<mask token>\nfor k in data:\n for key in correlation_dict:\n if data[k] in key:\n data[k] = correlation_dict[key]\nprint(data)\n",
"step-3": "dict1 = [{'a': 1}, {'a': 2}, {'a': 3... | [
0,
1,
2,
3
] |
from typing import Any, Sequence, Callable, Union, Optional
import pandas as pd
import numpy as np
from .taglov import TagLoV
def which_lov(series: pd.Series,
patterns: Sequence[Sequence[Any]],
method: Optional[Union[Callable, str]] = None,
**kwargs) -> np.ndarray:
"""Whi... | normal | {
"blob_id": "7b9bf791d52fdc801e24d0c8541d77d91a488e12",
"index": 3361,
"step-1": "<mask token>\n",
"step-2": "<mask token>\n\n\ndef which_lov(series: pd.Series, patterns: Sequence[Sequence[Any]], method:\n Optional[Union[Callable, str]]=None, **kwargs) ->np.ndarray:\n \"\"\"Which list-of-values does ever... | [
0,
1,
2,
3,
4
] |
from django.db import models
from utils.models import BaseModel
# Create your models here.
class ContentCategory(BaseModel):
'''广告内容类别'''
name = models.CharField(verbose_name='名称',max_length=50)
key = models.CharField(verbose_name='类别键名',max_length=50)
class Meta:
db_table = 'tb_content_catego... | normal | {
"blob_id": "fd96bf5595ce6ec1f95d0f7a9d1c4ff582826ac0",
"index": 1439,
"step-1": "<mask token>\n\n\nclass ContentCategory(BaseModel):\n <mask token>\n <mask token>\n <mask token>\n\n\n class Meta:\n db_table = 'tb_content_category'\n verbose_name = '广告内容类别'\n verbose_name_plural ... | [
5,
6,
7,
8,
10
] |
from fbchat import Client
class IBehaviourBase(Client):
BreakFlag = False
def __init__(self,email,password, kwargs):
""""abstract class being parent of every user implemented behaviour;
it handles logging in and tasks on behaviour loader side"""
self.kwargs=kwargs
Client.__init_... | normal | {
"blob_id": "e67f27eec53901f27ba5a7ee7e2a20bbb1e8f7f9",
"index": 2237,
"step-1": "<mask token>\n\n\nclass IBehaviourBase(Client):\n <mask token>\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass IBehaviourBase(Client):\n <mask token>\n\n def __init__(self, email, password, kwa... | [
1,
3,
4,
5,
6
] |
import importlib
class Scrapper:
def get_pos(str_lf, str_rg, text):
left = text.find(str_lf)
right = text.rfind(str_rg)
return left, right
def scrapper(prov):
scrapper = importlib.import_module('scrappers.{}'.format(prov))
return scrapper.scrape()
| normal | {
"blob_id": "67e06b6dddbd3f26295eaff921d1ad4a8b0e5487",
"index": 5580,
"step-1": "<mask token>\n\n\nclass Scrapper:\n <mask token>\n <mask token>\n",
"step-2": "<mask token>\n\n\nclass Scrapper:\n <mask token>\n\n def scrapper(prov):\n scrapper = importlib.import_module('scrappers.{}'.format... | [
1,
2,
3,
4
] |
import cherrypy
import config
try:
from simplejson import json
except ImportError:
import json
import routes
import urllib
import re
def redirect(url, status=None):
"""Raise a redirect to the specified address.
"""
raise cherrypy.HTTPRedirect(url, status)
def require_method(*allowed_methods):
... | normal | {
"blob_id": "dc28d8aa17347f07041ae218bbe4e1b0add27c24",
"index": 5669,
"step-1": "<mask token>\n\n\ndef redirect(url, status=None):\n \"\"\"Raise a redirect to the specified address.\n\n \"\"\"\n raise cherrypy.HTTPRedirect(url, status)\n\n\ndef require_method(*allowed_methods):\n allowed_methods = l... | [
11,
13,
16,
19,
20
] |
import numpy as np
import matplotlib.pyplot as plt
import csv
def save_cp_csvdata(reward, err, filename):
with open(filename, mode='w') as data_file:
data_writer = csv.writer(data_file, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
data_writer.writerow(['epoch', 'reward', 'error'])
... | normal | {
"blob_id": "a91d2f32afdc20516e56036c352cc267c728e886",
"index": 3051,
"step-1": "<mask token>\n\n\ndef save_cp_csvdata(reward, err, filename):\n with open(filename, mode='w') as data_file:\n data_writer = csv.writer(data_file, delimiter=',', quotechar='\"',\n quoting=csv.QUOTE_MINIMAL)\n ... | [
6,
8,
9,
10,
11
] |
"""
MAIN IDEA --> Keep 2 pointers. i points to current 0 element and j searches for first non zero element which comes after i.
As soon as we get a j, we swap i and j. So index i now becomes non zero. Now move i to next index i.e i+1 and now check if i
is zero or non zero. If i is still zero, then again search for 1st... | normal | {
"blob_id": "8855747f58b48bedc362930662e147b1fc4ebd63",
"index": 4182,
"step-1": "<mask token>\n\n\nclass Solution(object):\n <mask token>\n\n\n<mask token>\n",
"step-2": "<mask token>\n\n\nclass Solution(object):\n\n def moveZeroes(self, nums):\n \"\"\"\n :type nums: List[int]\n :rt... | [
1,
2,
3,
4,
5
] |
from jaqsmds.server.repliers.basic import RegularReplier
from jaqsmds.server.repliers.handlers import JsetHandler, JsdHandler, JsiHandler
from queue import Queue, Empty
from threading import Thread
import logging
class FreeReplier(RegularReplier):
def __init__(self):
super(FreeReplier, self).__init__()
... | normal | {
"blob_id": "42ebd42801b7d1563c9f204f296afba5fa3c6d3c",
"index": 1592,
"step-1": "<mask token>\n\n\nclass FreeReplier(RegularReplier):\n <mask token>\n\n def run(self):\n while self._running or self.input.qsize():\n try:\n client, message = self.input.get(timeout=2)\n ... | [
5,
6,
7,
8,
10
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.