text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> five = [B, B, O, O, O, O, B, B,
B, B, O, O, O, O, B, B,
O, O, O, O, O, O, O, O,
O, O, O, B, B, O, O, O,
O, O, O, B, B, O, O, O,
O, O, O, O, O, O, O, O,
B, B, O, O, O, O, B, B,
B, B, O, O... | code_fim | hard | {
"lang": "python",
"repo": "rmit-s3740446-Ryan-Cassidy/PIoT-Assignment-1",
"path": "/electronicDie.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return entity specific state attributes.
Implemented by platform classes. Convention for attribute names
is lowercase snake_case.
"""
attributes: dict[str, Any] = {}
rooms: dict[str, Any] = {}
for room in self._rooms:
# convert room n... | code_fim | hard | {
"lang": "python",
"repo": "Sanderhuisman/home-assistant-config",
"path": "/data/homeassistant/custom_components/deebot/vacuum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sanderhuisman/home-assistant-config path: /data/homeassistant/custom_components/deebot/vacuum.py
"""Support for Deebot Vaccums."""
import logging
from typing import Any, Mapping, Optional
import voluptuous as vol
from deebot_client.commands import (
Charge,
Clean,
FanSpeedLevel,
... | code_fim | hard | {
"lang": "python",
"repo": "Sanderhuisman/home-assistant-config",
"path": "/data/homeassistant/custom_components/deebot/vacuum.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> platform.async_register_entity_service(
SERVICE_REFRESH,
SERVICE_REFRESH_SCHEMA,
"_service_refresh",
)
class DeebotVacuum(DeebotEntity, StateVacuumEntity): # type: ignore
"""Deebot Vacuum."""
def __init__(self, vacuum_bot: VacuumBot):
"""Initialize the D... | code_fim | hard | {
"lang": "python",
"repo": "Sanderhuisman/home-assistant-config",
"path": "/data/homeassistant/custom_components/deebot/vacuum.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> z_i = np.dot(X_i, theta) + theta_0 #z_i: 20x1
pred_i = sigmoid(z_i) #pred_i: 20x1
J += LRcost(y_i, pred_i) #Compute logistic regression cost for current batch
#Compute gradients:
gradJ = LRgradient_batch(X_i, y_i, pred_i)
gradJ_0 = np.sum(pred_i-y_i)
... | code_fim | hard | {
"lang": "python",
"repo": "zehrashah/logistic-regression-nlp",
"path": "/Cmput651-Assign1b-logreg.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zehrashah/logistic-regression-nlp path: /Cmput651-Assign1b-logreg.py
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 13 10:18:35 2019
@author: zehra
"""
import numpy as np
import pickle
import matplotlib.pyplot as plt
from scipy.special import expit
X_train, y_train, X_val, y_val, X_test, y_tes... | code_fim | hard | {
"lang": "python",
"repo": "zehrashah/logistic-regression-nlp",
"path": "/Cmput651-Assign1b-logreg.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Predict on validation set:
z_val = np.dot(X_val, theta) + theta_0 #z_val: 5,000 x 1
pred_val = sigmoid(z_val) #pred_val: 5,000 x 1
val_cost_history[epoch] = LRcost(y_val, pred_val)
theta_history[epoch,] = np.squeeze(theta)
theta_0_history[epoch] = theta_0
pred_val_class = np.z... | code_fim | hard | {
"lang": "python",
"repo": "zehrashah/logistic-regression-nlp",
"path": "/Cmput651-Assign1b-logreg.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|># test for pd_fetch_tourspot_visitor()
item = pdapi.pd_fetch_foreign_visitor(112, 2012, 7)
print(item)<|fim_prefix|># repo: bitacademy-howl/analysis_public_dataV3 path: /__app__/test_apitest.py
import collect_from_webapi.api_public_data as pdapi
from collect_from_webapi import pd_fetch_tourspot_visitor
... | code_fim | hard | {
"lang": "python",
"repo": "bitacademy-howl/analysis_public_dataV3",
"path": "/__app__/test_apitest.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bitacademy-howl/analysis_public_dataV3 path: /__app__/test_apitest.py
import collect_from_webapi.api_public_data as pdapi
from collect_from_webapi import pd_fetch_tourspot_visitor
<|fim_suffix|># test for pd_fetch_tourspot_visitor()
item = pdapi.pd_fetch_foreign_visitor(112, 2012, 7)
print(item... | code_fim | hard | {
"lang": "python",
"repo": "bitacademy-howl/analysis_public_dataV3",
"path": "/__app__/test_apitest.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>st = [0 for i in range(0, max_size)]
openst = [0 for i in range(0, max_size)]
closedst = [0 for i in range(0, max_size)]
constructST(s, 0, n-1, st, 0)
# print(st)
# print(openst)
# print(closedst)
for _ in range(int(input())):
l, r = map(int, input().split())
print(2*query(s, 0, n-1, l-1, r-1... | code_fim | medium | {
"lang": "python",
"repo": "Yathartha22/JustCode",
"path": "/competitive/Codeforces/Codeforces SerjaAnd Brackets.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if l > end or r < start:
return 0, 0, 0
elif start >= l and end <= r:
return st[i], openst[i], closedst[i]
else:
mid = (start + end)//2
a, b, c = query(s, start, mid, l, r, st, 2*i+1)
d, e, f = query(s, mid+1, end, l, r, st, 2*i+2)
tmp = min(b, f)
T = a+d +tmp
O = b+e - tmp
... | code_fim | medium | {
"lang": "python",
"repo": "Yathartha22/JustCode",
"path": "/competitive/Codeforces/Codeforces SerjaAnd Brackets.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Yathartha22/JustCode path: /competitive/Codeforces/Codeforces SerjaAnd Brackets.py
from math import ceil, log2, sqrt
def constructST(s, start, end, st, i):
if start == end:
st[i] = 0
openst[i] = 1 if s[start] == '(' else 0
closedst[i] = 1 if s[start] == ')' else 0
return st[i], o... | code_fim | medium | {
"lang": "python",
"repo": "Yathartha22/JustCode",
"path": "/competitive/Codeforces/Codeforces SerjaAnd Brackets.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SURGroup/UQpy path: /src/UQpy/utilities/kernels/grassmannian_kernels/ProjectionKernel.py
from typing import Union, Tuple
import numpy as np
from UQpy.utilities.kernels.baseclass.GrassmannianKernel import GrassmannianKernel
<|fim_suffix|> :param xi_j: Tuple of orthonormal matrices repre... | code_fim | hard | {
"lang": "python",
"repo": "SURGroup/UQpy",
"path": "/src/UQpy/utilities/kernels/grassmannian_kernels/ProjectionKernel.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:param kernel_parameter: Number of independent p-planes of each Grassmann point.
"""
super().__init__(kernel_parameter)
def element_wise_operation(self, xi_j: Tuple) -> float:
"""
Compute the Projection kernel entry for a tuple of points on the Gras... | code_fim | medium | {
"lang": "python",
"repo": "SURGroup/UQpy",
"path": "/src/UQpy/utilities/kernels/grassmannian_kernels/ProjectionKernel.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rayyanos/SAK_PRODUCTION path: /pos_ownuser_session/models/model.py
from odoo import api, tools, fields, models, _
import base64
from odoo import modules
class InheritUser(models.Model):
_inherit = 'pos.config'
related_pos_user = fields.One2many('pos.session.users', 'pos_config', string... | code_fim | medium | {
"lang": "python",
"repo": "rayyanos/SAK_PRODUCTION",
"path": "/pos_ownuser_session/models/model.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class InheritUser(models.Model):
_inherit = 'res.users'
pos_sessions = fields.Many2many('pos.config', string='Point of Sale Accessible')
@api.multi
def write(self, vals):
if 'pos_sessions' in vals:
if vals['pos_sessions'][0][2]:
self.env["pos.sessio... | code_fim | hard | {
"lang": "python",
"repo": "rayyanos/SAK_PRODUCTION",
"path": "/pos_ownuser_session/models/model.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''转化格式'''
try:
body_str = to_str(body_str)
except:
return False
body_dict = {}
# print(body_str)
for each in body_str.split("&"):
body_dict[str(each.split("=")[0])] = str(each.split("=")[1])
print(body_dict)
with open("demo.json","w") as demo:
... | code_fim | medium | {
"lang": "python",
"repo": "dangfuli/all_pro",
"path": "/all_until_script/to_json.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dangfuli/all_pro path: /all_until_script/to_json.py
#coding=utf-8
import urllib.parse
import json
'''转化从charles复制下来的字串,转为json格式'''
def to_str(body_str):
'''检查需要转化的str是否符合标准'''
if not body_str == '':
par = body_str.split("&")
# print(par)
_temp = []
try:
... | code_fim | medium | {
"lang": "python",
"repo": "dangfuli/all_pro",
"path": "/all_until_script/to_json.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> sess.run(tf.global_variables_initializer())
sess.run(fine_depthmap_predictions)
# compute cost function
fine_cost = nf.get_cost_function(depthmaps_predicted = fine_depthmap_predictions,
depthmaps_groundtruth = depthmaps_groundtruth)
# calculate and run optimizer
opt... | code_fim | hard | {
"lang": "python",
"repo": "oscarbergqvist/depthpredictions",
"path": "/code/depth_prediction_2_elin.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oscarbergqvist/depthpredictions path: /code/depth_prediction_2_elin.py
'''
"MAIN" module
All operations are added to the defaultgraph.
Network functions are found in module network_functions_2
Display graph in tensorboard by opening a new terminal and write "tensorboard --logdir=tensorbaord/deb... | code_fim | hard | {
"lang": "python",
"repo": "oscarbergqvist/depthpredictions",
"path": "/code/depth_prediction_2_elin.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afcarl/cyNastran path: /pyNastran/bdf/dev_vectorized/cards/elements/bar/pbar.py
from numpy import array, zeros, arange, concatenate, searchsorted, where, unique
from pyNastran.bdf.fieldWriter import print_card_8
from pyNastran.bdf.bdfInterface.assign_type import (integer, integer_or_blank,
d... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/cyNastran",
"path": "/pyNastran/bdf/dev_vectorized/cards/elements/bar/pbar.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unique_pids = unique(self.property_id)
if len(unique_pids) != len(self.property_id):
raise RuntimeError('There are duplicate PCOMP IDs...')
self._cards = []
self._comments = []
#==========================================================... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/cyNastran",
"path": "/pyNastran/bdf/dev_vectorized/cards/elements/bar/pbar.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# command to run
# python setup.py pytoexe<|fim_prefix|># repo: sarthak1598/PentestingWithPython-ToolBox path: /ConvertPython-to-exe.py
# code below
#taking filename as pyscript.py
from distutils.core import setup
<|fim_middle|>import py2exe
setup(console=['pyscript.py'])
| code_fim | easy | {
"lang": "python",
"repo": "sarthak1598/PentestingWithPython-ToolBox",
"path": "/ConvertPython-to-exe.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sarthak1598/PentestingWithPython-ToolBox path: /ConvertPython-to-exe.py
# code below
#taking filename as pyscript.py
<|fim_suffix|>
import py2exe
setup(console=['pyscript.py'])
# command to run
# python setup.py pytoexe<|fim_middle|>from distutils.core import setup
| code_fim | easy | {
"lang": "python",
"repo": "sarthak1598/PentestingWithPython-ToolBox",
"path": "/ConvertPython-to-exe.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# command to run
# python setup.py pytoexe<|fim_prefix|># repo: sarthak1598/PentestingWithPython-ToolBox path: /ConvertPython-to-exe.py
# code below
#taking filename as pyscript.py
<|fim_middle|>from distutils.core import setup
import py2exe
setup(console=['pyscript.py'])
| code_fim | medium | {
"lang": "python",
"repo": "sarthak1598/PentestingWithPython-ToolBox",
"path": "/ConvertPython-to-exe.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dpk14/RootDetective path: /src/controller/root_controller.py
import src.engine.functions.root_analyzer.main as main
from src.engine.functions.function import Function
<|fim_suffix|> image_folder_path = args[0]
output_path = args[1]
self.data_display.clear()
data = ... | code_fim | medium | {
"lang": "python",
"repo": "dpk14/RootDetective",
"path": "/src/controller/root_controller.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> image_folder_path = args[0]
output_path = args[1]
self.data_display.clear()
data = main.generate_data(image_folder_path, self.data_display.data_tracker)
error_message = self.data_display.display_data(data)
return ""<|fim_prefix|># repo: dpk14/RootDetective ... | code_fim | medium | {
"lang": "python",
"repo": "dpk14/RootDetective",
"path": "/src/controller/root_controller.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: harmankaler2000/ShopAlert path: /bot/bot.py
from telegram.ext import Updater, Filters, MessageHandler, PicklePersistence
import telegram
import logging
logging.basicConfig(format='%(asctime)s %(message)s\n',
level=logging.INFO,filename='log.json')
logger = logging.getLogger... | code_fim | hard | {
"lang": "python",
"repo": "harmankaler2000/ShopAlert",
"path": "/bot/bot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # my_persistence = PicklePersistence(filename="users") #incomment if you need persistence
# updater = Updater("",persistence=my_persistence,use_context=True)
updater = Updater("",use_context=True)
dp = updater.dispatcher
jobs = updater.job_queue
dp.add_error_handle... | code_fim | medium | {
"lang": "python",
"repo": "harmankaler2000/ShopAlert",
"path": "/bot/bot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> _CORPORAL.__init__(self)
self.name = "CORPORALS"
self.specie = 'adjectives'
self.basic = "corporal"
self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/adjectives/_corporals.py
from xai.brain.wordbase.adjectives._corporal import _CORPORAL
#calss header
class _CORPO... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/adjectives/_corporals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/adjectives/_corporals.py
from xai.brain.wordbase.adjectives._corporal import _CORPORAL
<|fim_suffix|> def __init__(self,):
_CORPORAL.__init__(self)
self.name = "CORPORALS"
self.specie = 'adjectives'
self.basic = "corporal"
self.jsondata = {}<|f... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/adjectives/_corporals.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(30):
if os.path.exists(str_dir_name+"/"+str(i)+"/command.sh"):
continue
seed += 1
command[1] = str(seed)
print(command)
os.mkdir(str_dir_name+"/"+str(i))
with open(str_dir_name+"/"+str(i)+"/command.sh", "w") as infile:
... | code_fim | hard | {
"lang": "python",
"repo": "emilydolson/MODES-toolbox-paper",
"path": "/code/setup_experiments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emilydolson/MODES-toolbox-paper path: /code/setup_experiments.py
import os
#defaults = {"N":20, "K":3, "POP_SIZE":200, "MUT_RATE":.05, "TOURNAMENT_SIZE":2, "SELECTION":0, "CHANGE_RATE":100000, "MAX_GENS": 5000, "FILTER_LENGTH":50}
defaults = {"N":20, "K":3, "POP_SIZE":200, "MUT_RATE":.05, "TOUR... | code_fim | medium | {
"lang": "python",
"repo": "emilydolson/MODES-toolbox-paper",
"path": "/code/setup_experiments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> = 0
for i in range(8):
if C[i]>0:
cmin += 1
if cmin==0:
cmin = 1
cmax = C[8]
else:
cmax = cmin+C[8]
print(cmin,cmax)<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p03695/s563438464.py
C = {i:0 for i in range(9)}
N = int(input())
A = list(map(int,input().split()))... | code_fim | hard | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p03695/s563438464.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aasthaengg/IBMdataset path: /Python_codes/p03695/s563438464.py
C = {i:0 for i in range(9)}
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
a = A[i]
if a<400:
C[0] +<|fim_suffix|> = 0
for i in range(8):
if C[i]>0:
cmin += 1
if cmin==0:
cmin = ... | code_fim | hard | {
"lang": "python",
"repo": "Aasthaengg/IBMdataset",
"path": "/Python_codes/p03695/s563438464.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>help_rating = """
help on rating:
[usage] :rating (number)
[intro] list a certain number of words from your library with a certain rate.
[eg] :rating 0 9
this function is very complex, browser the website.
more on http://mardict.appspot.com/help/#rating
"""<|fim_prefix|># repo: botasky-lau/mardict path... | code_fim | hard | {
"lang": "python",
"repo": "botasky-lau/mardict",
"path": "/utils/helper.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>help_add = """
help on add:
[usage] :add (word)
[intro] add the new word to your library(storing your unfamiliar word)
[eg] :add hello
more on http://mardict.appspot.com/help/#add
"""
help_del = """
help on del:
[usage] :del word
[intro] delete the word from your library
[eg] :del hello
more on http://... | code_fim | hard | {
"lang": "python",
"repo": "botasky-lau/mardict",
"path": "/utils/helper.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # data = pd.read_parquet("wfm_single_q_Internal_daily_history.parquet")
# data = pd.read_parquet("WFM_200q_Internal_daily_history.parquet")
# data.rename(columns={ 'queueid': 'seriesid', 'date': 'ts', 'callvolume': 'v',}, inplace=True)
data = pd.read_parquet("History_series_0028C91B.0... | code_fim | hard | {
"lang": "python",
"repo": "cl19951225/syntheticdatagen",
"path": "/data_generators/time_vae/processing/preprocessors.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
X_vals = X.values
self.min_vals = np.expand_dims( X_vals[ :, : self.scaling_len ].min(axis=1), axis = 1)
self.max_vals = np.expand_dims( X_vals[ :, : self.scaling_len ].max(axis=1), axis = 1)
self.ranges = self.max_vals - self.min_vals
self.ranges = np.where(s... | code_fim | hard | {
"lang": "python",
"repo": "cl19951225/syntheticdatagen",
"path": "/data_generators/time_vae/processing/preprocessors.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cl19951225/syntheticdatagen path: /data_generators/time_vae/processing/preprocessors.py
self, id_columns, time_column, value_columns ):
super().__init__()
if not isinstance(id_columns, list):
self.id_columns = [id_columns]
else:
self.id_columns = id... | code_fim | hard | {
"lang": "python",
"repo": "cl19951225/syntheticdatagen",
"path": "/data_generators/time_vae/processing/preprocessors.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexander-yu/adventofcode path: /problems_2019/25.py
import utils
from problems_2019 import intcode
def run(commands=None):
memory = utils.get_input()[0]
initial_inputs = intcode.commands_to_input(commands or [])
program = intcode.Program(memory, initial_inputs=initial_inputs, outp... | code_fim | hard | {
"lang": "python",
"repo": "alexander-yu/adventofcode",
"path": "/problems_2019/25.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@utils.part
def part_1():
commands = [
'south',
'take food ration',
'west',
'north',
'north',
'east',
'take astrolabe',
'west',
'south',
'south',
'east',
'north',
'east',
'south',
't... | code_fim | hard | {
"lang": "python",
"repo": "alexander-yu/adventofcode",
"path": "/problems_2019/25.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.board = board
self.pucman = pucman
self.ghasts = ghasts
self.clock = pygame.time.Clock()
self.MODE = MODE
def start(self):
# draw background & begin session
self.board.draw()
session = True
# while playing
while ses... | code_fim | hard | {
"lang": "python",
"repo": "mster/pucman",
"path": "/src/session.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mster/pucman path: /src/session.py
# import core modules and community packages
import sys, math, random
import pygame
# import configuration settings
from src.config import *
from src.board.levels import LEVEL_1
# import game elements
from src.pucman import Pucman
from src.ghast import Ghast
f... | code_fim | hard | {
"lang": "python",
"repo": "mster/pucman",
"path": "/src/session.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def start(self):
# draw background & begin session
self.board.draw()
session = True
# while playing
while session:
# manage game time, 5 ticks per second
self.clock.tick(TICK_RATE[self.MODE])
# pygame.time.delay(50)
... | code_fim | hard | {
"lang": "python",
"repo": "mster/pucman",
"path": "/src/session.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>respuesta_5 = input('\n tu respuesta: ')
while respuesta_5 not in ('a', 'b', 'c', 'd', 'e'):
respuesta_5 = input("debes volver a ingresar tu respuesta:")
if respuesta_5 == "d":
puntaje += 10
print("Muy bien", n1, "!")
else:
puntaje -= 5
print("Incorrecto", n1, "!")
print('\ngracias p... | code_fim | hard | {
"lang": "python",
"repo": "taladropercutor/holauquetal",
"path": "/trivia.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: taladropercutor/holauquetal path: /trivia.py
#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 p... | code_fim | hard | {
"lang": "python",
"repo": "taladropercutor/holauquetal",
"path": "/trivia.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>print('\nsiguiente pregunta')
print('\ncon que comando puedo dar permisos e almacenaminto a termux?')
print('a) pwd')
print('b) ls -a')
print('c) lstree')
print('d) temux setup-storage')
print('e) rm -rf')
respuesta_5 = input('\n tu respuesta: ')
while respuesta_5 not in ('a', 'b', 'c', 'd', 'e'... | code_fim | hard | {
"lang": "python",
"repo": "taladropercutor/holauquetal",
"path": "/trivia.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tianyi-wu/LearningHistoryDatabase path: /mysite/analyze/urls.py
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required
from django.views.generic import TemplateView
<|fim_suffix|>#from lecture import views
urlpatterns = patterns('',
url(r'^... | code_fim | easy | {
"lang": "python",
"repo": "tianyi-wu/LearningHistoryDatabase",
"path": "/mysite/analyze/urls.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#from lecture import views
urlpatterns = patterns('',
url(r'^$', 'analyze.views.analyze', name='analyze'),
)<|fim_prefix|># repo: tianyi-wu/LearningHistoryDatabase path: /mysite/analyze/urls.py
from django.conf.urls import patterns, include, url
from django.contrib.auth.decorators import login_required
... | code_fim | easy | {
"lang": "python",
"repo": "tianyi-wu/LearningHistoryDatabase",
"path": "/mysite/analyze/urls.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: youssefelallam/youtube_downloader path: /GUI.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_M... | code_fim | hard | {
"lang": "python",
"repo": "youssefelallam/youtube_downloader",
"path": "/GUI.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GabrielCaggiano/GabrielCaggiano.github.io path: /python/exception_handling.py
#!/usr/local/bin/python
i = 0
while i == 0:
try:
print("Let's divide some numbers!")
a1 = input("Enter numerator: ")
b1 = input("Enter denominator: ")
a = int(a1)
b = int(b1... | code_fim | medium | {
"lang": "python",
"repo": "GabrielCaggiano/GabrielCaggiano.github.io",
"path": "/python/exception_handling.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(a1 + " divied by " + b1 + " equals: " + str(a/b))
i += 1
except ZeroDivisionError:
print("Cannot divide by 0")
except ValueError:
print("Invalid input, not a number")<|fim_prefix|># repo: GabrielCaggiano/GabrielCaggiano.github.io path: /python/exception_... | code_fim | medium | {
"lang": "python",
"repo": "GabrielCaggiano/GabrielCaggiano.github.io",
"path": "/python/exception_handling.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kolyanovna/MyMinor2015 path: /DZ2/DZ1M.py
__author__ = 'NikolaiEgorov'
def Lad(a1, a2, b1, b2):
<|fim_suffix|>1 = int(input())
b2 = int(input())
print(Lad(a1,a2,b1,b2))<|fim_middle|>if (a1 == b1) | (a2 == b2):
return 'YES'
else:
return 'NO'
a1 = int(input())
a2 = int(input... | code_fim | medium | {
"lang": "python",
"repo": "kolyanovna/MyMinor2015",
"path": "/DZ2/DZ1M.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
return 'NO'
a1 = int(input())
a2 = int(input())
b1 = int(input())
b2 = int(input())
print(Lad(a1,a2,b1,b2))<|fim_prefix|># repo: kolyanovna/MyMinor2015 path: /DZ2/DZ1M.py
__author__ = 'NikolaiEgorov'
def Lad(a1, a2, b1, b2):
<|fim_middle|>if (a1 == b1) | (a2 == b2):
return 'YES'
... | code_fim | easy | {
"lang": "python",
"repo": "kolyanovna/MyMinor2015",
"path": "/DZ2/DZ1M.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ProQwest/Recommendation-system-with-users-influence path: /Recommender system and UI design/src/yelp_ui_pyqt4.py
#!/usr/bin/python
from PyQt4 import QtCore, QtGui
import sys
import json
import re
from Interface_Recommended_Results import obtain_list
try:
_fromUtf8 = QtCore.QString.fromUtf8
... | code_fim | hard | {
"lang": "python",
"repo": "ProQwest/Recommendation-system-with-users-influence",
"path": "/Recommender system and UI design/src/yelp_ui_pyqt4.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def findRest(self):
file1=open("rest_pitt.json")
rest_list=[]
for line in file1.readlines():
rest_list.append(json.loads(line))
filter_stars=self.stars_box.currentIndex()+1
filter_category=unicode(self.category_box.currentText())
filter_name=... | code_fim | hard | {
"lang": "python",
"repo": "ProQwest/Recommendation-system-with-users-influence",
"path": "/Recommender system and UI design/src/yelp_ui_pyqt4.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def train(self, g_model, d_model, gan_model, real, input_cond, latent_dim, n_epochs, n_batch, save):
bat_per_epo = int(real.shape[0] / n_batch) #check
half_batch = int(n_batch / 2)
g_loss = np.zeros(n_epochs)
d_loss_real = np.zeros(n_epochs)
d_loss_fake = np.zer... | code_fim | hard | {
"lang": "python",
"repo": "kanfarrs/Subsurface-Imaging-Using-GANs",
"path": "/Code/cGAN.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kanfarrs/Subsurface-Imaging-Using-GANs path: /Code/cGAN.py
# -*- coding: utf-8 -*-
"""
Created on Mon Nov 11 18:50:46 2019
@author: kanfar
"""
import numpy as np
import timeit
import matplotlib.pyplot as plt
from numpy import expand_dims, zeros, ones
from numpy.random import randn, randint
from... | code_fim | hard | {
"lang": "python",
"repo": "kanfarrs/Subsurface-Imaging-Using-GANs",
"path": "/Code/cGAN.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def generate_latent(self, latent_size, n_samples):
#generate points in teh latent space
total_latent = randn(latent_size*n_samples)
input_z = total_latent.reshape(n_samples, latent_size)
return input_z
def generate_fake_samples(self, generator, defocused, latent_di... | code_fim | hard | {
"lang": "python",
"repo": "kanfarrs/Subsurface-Imaging-Using-GANs",
"path": "/Code/cGAN.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: firewang/python_practice_2018 path: /15.PyQt_learning/qt_test1.py
# -*- encoding: utf-8 -*-
# @Version : 1.0
# @Time : 2018/8/29 9:59
# @Author : wanghuodong
# @note : 生成一个简单窗口
import sys
from PyQt5.QtWidgets import QApplication, QWidget
<|fim_suffix|> '''所有的PyQt5应用必须创建一个应用(Appl... | code_fim | medium | {
"lang": "python",
"repo": "firewang/python_practice_2018",
"path": "/15.PyQt_learning/qt_test1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Qwidget组件是PyQt5中所有用户界面类的基础类。我们给QWidget提供了默认的构造方法。默认构造方法没有父类。没有父类的widget组件将被作为窗口使用'''
w = QWidget()
'''resize()方法调整了widget组件的大小。它现在是250px宽,150px高。'''
w.resize(500, 150)
'''move()方法移动widget组件到一个位置,这个位置是屏幕上x=300,y=300的坐标。'''
w.move(300, 300)
'''setWindowTitle()设置了我们窗口的标题。这个标题显示... | code_fim | medium | {
"lang": "python",
"repo": "firewang/python_practice_2018",
"path": "/15.PyQt_learning/qt_test1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>websocket_urlpatterns = [
path('ws/notifications', NotificationsConsumer),
]<|fim_prefix|># repo: abdellatifLabr/MyStore path: /notifications/routing.py
from django.urls import path
<|fim_middle|>from .consumers import NotificationsConsumer
| code_fim | easy | {
"lang": "python",
"repo": "abdellatifLabr/MyStore",
"path": "/notifications/routing.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abdellatifLabr/MyStore path: /notifications/routing.py
from django.urls import path
<|fim_suffix|>websocket_urlpatterns = [
path('ws/notifications', NotificationsConsumer),
]<|fim_middle|>from .consumers import NotificationsConsumer
| code_fim | easy | {
"lang": "python",
"repo": "abdellatifLabr/MyStore",
"path": "/notifications/routing.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DataKind-DC/capital-nature-ingest path: /events/sierra_club_md.py
from datetime import datetime
import logging
import os
import re
from bs4 import BeautifulSoup
import requests
from .utils.log import get_logger
logger = get_logger(os.path.basename(__file__))
EVENTBRITE_TOKEN = os.environ['EVE... | code_fim | hard | {
"lang": "python",
"repo": "DataKind-DC/capital-nature-ingest",
"path": "/events/sierra_club_md.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> cost = soup.find("span", {"class": "list-card__label"}).text
cost = cost.lower()
cost = cost.replace("free", "0")
cost = re.sub(r'[^\d]+', '', cost)
if cost == "":
cost = "0"
return cost
def main():
events_array = []
r = get(14506382808, 'o')
soup = BeautifulS... | code_fim | hard | {
"lang": "python",
"repo": "DataKind-DC/capital-nature-ingest",
"path": "/events/sierra_club_md.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return r
def get_live_events(soup):
live_events = soup.find("article", {"id": "live_events"})
try:
event_divs = live_events.find_all("div", {"class": "list-card-v2"})
except AttributeError:
return []
return event_divs
def get_cost_events(soup):
cost = soup... | code_fim | hard | {
"lang": "python",
"repo": "DataKind-DC/capital-nature-ingest",
"path": "/events/sierra_club_md.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> result.append(0)
diff = (index - previous_zero_index) // 2
result[index - diff: index] = reversed(result[previous_zero_index + 1: previous_zero_index + 1 + diff])
previous_zero_index = index
count = 0
continue
result.append(... | code_fim | hard | {
"lang": "python",
"repo": "MaksimSoldatov/Algorithms",
"path": "/Algorithms/Introduction to algorithms/Sprint1/Task1.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MaksimSoldatov/Algorithms path: /Algorithms/Introduction to algorithms/Sprint1/Task1.py
array_length = int(input())
source = [int(x) for x in input().split()]
def find_neighbors():
previous_zero_index = -1
count = 0
result = []
for index, value in enumerate(source):
count... | code_fim | hard | {
"lang": "python",
"repo": "MaksimSoldatov/Algorithms",
"path": "/Algorithms/Introduction to algorithms/Sprint1/Task1.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ttruongatl/ml-lstm path: /mllstm/ml_lstm.py
from __future__ import absolute_import, division, print_function, unicode_literals
import tensorflow as tf
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import os
import pandas as pd
print('tensorflow version: {}'.format(... | code_fim | hard | {
"lang": "python",
"repo": "ttruongatl/ml-lstm",
"path": "/mllstm/ml_lstm.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>TRAIN_SPLIT = 300000
BATCH_SIZE = 256
BUFFER_SIZE = 10000
tf.random.set_seed(13)
train_df = pd.read_csv('data/st-cloud.csv')
train_df = train_df.sort_values(by=['timestamp'])
train_df = train_df.loc[(train_df['event'] == 'cut') | (train_df['event'] == 'sort') | (train_df['event'] == 'idle')]
x_train_uni... | code_fim | hard | {
"lang": "python",
"repo": "ttruongatl/ml-lstm",
"path": "/mllstm/ml_lstm.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>train_univariate = tf.data.Dataset.from_tensor_slices((x_train_uni, y_train_uni))
# train_univariate = train_univariate.cache().shuffle(BUFFER_SIZE).batch(BATCH_SIZE).repeat()
#
# val_univariate = tf.data.Dataset.from_tensor_slices((x_val_uni, y_val_uni))
# val_univariate = val_univariate.batch(BATCH_SIZE... | code_fim | hard | {
"lang": "python",
"repo": "ttruongatl/ml-lstm",
"path": "/mllstm/ml_lstm.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Metadata(Descriptive):
name = "metadata"
attrs = ()
class Title(Descriptive):
name = "title"
attrs = ()<|fim_prefix|># repo: roddux/svjesus path: /svjesus/elements/Descriptive.py
from svjesus.ffz import genContent
from svjesus.elements.Base import Element
<|fim_middle|>class Descriptive(Eleme... | code_fim | medium | {
"lang": "python",
"repo": "roddux/svjesus",
"path": "/svjesus/elements/Descriptive.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: roddux/svjesus path: /svjesus/elements/Descriptive.py
from svjesus.ffz import genContent
from svjesus.elements.Base import Element
class Descriptive(Element):
def __init__(self):
self.allowedChildren = () # TODO: Check what's allowed
# Descriptive elements
class Desc(Descriptive):
name = "d... | code_fim | easy | {
"lang": "python",
"repo": "roddux/svjesus",
"path": "/svjesus/elements/Descriptive.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Title(Descriptive):
name = "title"
attrs = ()<|fim_prefix|># repo: roddux/svjesus path: /svjesus/elements/Descriptive.py
from svjesus.ffz import genContent
from svjesus.elements.Base import Element
class Descriptive(Element):
<|fim_middle|> def __init__(self):
self.allowedChildren = () # TODO:... | code_fim | hard | {
"lang": "python",
"repo": "roddux/svjesus",
"path": "/svjesus/elements/Descriptive.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AlexKohanim/ICPC path: /bookingaroom.py
r, n = map(int, input().split())
if r == n:
print("too late")
else:
l = list<|fim_suffix|> l.remove(int(input()))
print(l[0])<|fim_middle|>(range(1, r+1))
for _ in range(n):
| code_fim | easy | {
"lang": "python",
"repo": "AlexKohanim/ICPC",
"path": "/bookingaroom.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> l.remove(int(input()))
print(l[0])<|fim_prefix|># repo: AlexKohanim/ICPC path: /bookingaroom.py
r, n = map(int, input().split())
if r == n<|fim_middle|>:
print("too late")
else:
l = list(range(1, r+1))
for _ in range(n):
| code_fim | medium | {
"lang": "python",
"repo": "AlexKohanim/ICPC",
"path": "/bookingaroom.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AlexKohanim/ICPC path: /bookingaroom.py
r, n = map(int, input().split())
if r == n<|fim_suffix|>(range(1, r+1))
for _ in range(n):
l.remove(int(input()))
print(l[0])<|fim_middle|>:
print("too late")
else:
l = list | code_fim | easy | {
"lang": "python",
"repo": "AlexKohanim/ICPC",
"path": "/bookingaroom.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pandinosaurus/nnabla path: /python/test/function/test_mod2.py
# Copyright 2023 Sony Group Corporation.
#
# 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://ww... | code_fim | hard | {
"lang": "python",
"repo": "Pandinosaurus/nnabla",
"path": "/python/test/function/test_mod2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def ref_mod2(x0, x1, fmod):
if x0.dtype == np.float32 or fmod == True:
return np.fmod(x0, x1)
else:
return np.mod(x0, x1)
@pytest.mark.parametrize("ctx, func_name", ctxs)
@pytest.mark.parametrize("x0_shape, x1_shape", [
((2, 3, 4), (2, 3, 4)),
((2, 3, 4), (1, 1, 1)),
... | code_fim | medium | {
"lang": "python",
"repo": "Pandinosaurus/nnabla",
"path": "/python/test/function/test_mod2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TiaanVenter/pythonlearningprograms path: /cargame_wrong_solution.py
car_state = False
u_input = input(f'>')
<|fim_suffix|>if u_input == 'start':
car_state = True
print('Car has started!')
elif u_input == 'stop':
car_state == False
print('Car has stopped!')
else:
pri... | code_fim | easy | {
"lang": "python",
"repo": "TiaanVenter/pythonlearningprograms",
"path": "/cargame_wrong_solution.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>if u_input == 'start':
car_state = True
print('Car has started!')
elif u_input == 'stop':
car_state == False
print('Car has stopped!')
else:
print('''I don''t understand that...''')<|fim_prefix|># repo: TiaanVenter/pythonlearningprograms path: /cargame_wrong_solution.py
car_sta... | code_fim | easy | {
"lang": "python",
"repo": "TiaanVenter/pythonlearningprograms",
"path": "/cargame_wrong_solution.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> batch_pred_vector = None
if self.use_keqa_vector:
batch_pred_vector = self.model.get_anticipated_entity_vector(batch_head, batch_question, batch_question_len, self.d_entity_neighours)
log_action_prob = torch.zeros(self.batch_size).cuda(self.gpu_id)
for ... | code_fim | hard | {
"lang": "python",
"repo": "iDylanCui/ARN",
"path": "/Code/RL_A3C/test_woker.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> r_space = r_space.view(self.batch_size, -1)
e_space = e_space.view(self.batch_size, -1)
log_action_dist = log_action_dist.view(self.batch_size, -1)
beam_action_space_size = log_action_dist.size()[1]
k = min(self.beam_size, beam_action_space_size)
n... | code_fim | hard | {
"lang": "python",
"repo": "iDylanCui/ARN",
"path": "/Code/RL_A3C/test_woker.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iDylanCui/ARN path: /Code/RL_A3C/test_woker.py
import torch
import torch.nn as nn
from tqdm import tqdm
import torch.nn.functional as F
import torch.multiprocessing as mp
from policy_network import Policy_Network
from util import safe_log
from util import index2word, rearrange_vector_list, get_nu... | code_fim | hard | {
"lang": "python",
"repo": "iDylanCui/ARN",
"path": "/Code/RL_A3C/test_woker.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return str(self.q1)
def test_stack():
s = Stack()
s.push(1)
s.push(2)
s.push(3)
s.push(4)
assert str(s) == 'head > 4 > 3 > 2 > 1 > '
assert s.pop() == 4
assert s.pop() == 3
assert s.pop() == 2
assert s.pop() == 1
if __name__ == '__main__':
test_stack... | code_fim | medium | {
"lang": "python",
"repo": "KomorebiL/OJ",
"path": "/stack_from_queue.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __repr__(self):
return str(self.q1)
def test_stack():
s = Stack()
s.push(1)
s.push(2)
s.push(3)
s.push(4)
assert str(s) == 'head > 4 > 3 > 2 > 1 > '
assert s.pop() == 4
assert s.pop() == 3
assert s.pop() == 2
assert s.pop() == 1
if __name__ == '_... | code_fim | hard | {
"lang": "python",
"repo": "KomorebiL/OJ",
"path": "/stack_from_queue.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KomorebiL/OJ path: /stack_from_queue.py
from queue import Queue
class Stack:
def __init__(self):
self.q1 = Queue()
self.q2 = Queue()
def empty(self):
return self.q1.empty()
def push(self, element):
if self.empty():
self.q1.enqueue(elemen... | code_fim | medium | {
"lang": "python",
"repo": "KomorebiL/OJ",
"path": "/stack_from_queue.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: utah-geological-survey/UBM path: /UBM/getdata.py
is 102003
http://files.ntsg.umt.edu/data/NTSG_Products/MOD16/MOD16_global_evapotranspiration_description.pdf
https://modis-land.gsfc.nasa.gov/MODLAND_grid.html
https://lpdaac.usgs.gov/dataset_discovery/modis/modis_products_table/mod16a... | code_fim | hard | {
"lang": "python",
"repo": "utah-geological-survey/UBM",
"path": "/UBM/getdata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: utah-geological-survey/UBM path: /UBM/getdata.py
se_url = "http://files.ntsg.umt.edu/data/NTSG_Products/MOD16/MOD16A2_MONTHLY.MERRA_GMAO_1kmALB/"
dir_path = "Y{:}/M{:}/".format(yr, m)
url = base_url + dir_path
soup = BeautifulSoup(urllib2.urlopen(u... | code_fim | hard | {
"lang": "python",
"repo": "utah-geological-survey/UBM",
"path": "/UBM/getdata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for yr in yrs:
for m in mons:
ftp_addr = "sidads.colorado.edu"
ftp = ftplib.FTP(ftp_addr)
ftp.login()
dir_path = "pub/DATASETS/NOAA/G02158/masked/" + yr + "/" + m + "/"
ftp.cwd(dir_path)
files = ftp.nlst()
fo... | code_fim | hard | {
"lang": "python",
"repo": "utah-geological-survey/UBM",
"path": "/UBM/getdata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: int0thewind/Canon-Composer path: /src/note.py
from random import shuffle, choice
from typing import Dict, List, Tuple
note_to_midi: Dict[int, int] = {
1: 0,
2: 2,
3: 4,
4: 5,
5: 7,
6: 9,
7: 11,
}
midi_to_note: Dict[int, int] = {
0: 1,
2: 2,
4: 3,
5: 4... | code_fim | hard | {
"lang": "python",
"repo": "int0thewind/Canon-Composer",
"path": "/src/note.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._get_interval(5)
def get_seventh(self):
return self._get_interval(6)
def inv(self):
return Note(6 - self.num)
def get_next_possible_notes(self, /, leap=True):
ret = [Note(self.num - 1), Note(self.num + 1)]
if leap:
ret += [Note... | code_fim | hard | {
"lang": "python",
"repo": "int0thewind/Canon-Composer",
"path": "/src/note.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __eq__(self, other):
return self._distance(other) == 0
def __lt__(self, other):
return self._distance(other) < 0
def __le__(self, other):
return self._distance(other) <= 0
def __gt__(self, other):
return self._distance(other) > 0
def __ge__(self,... | code_fim | hard | {
"lang": "python",
"repo": "int0thewind/Canon-Composer",
"path": "/src/note.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Called when the user specifies an intent for this skill """
print("on_intent requestId=" + intent_request['requestId'] +
", sessionId=" + session['sessionId'])
intent = intent_request['intent']
intent_name = intent_request['intent']['name']
# Dispatch to your s... | code_fim | hard | {
"lang": "python",
"repo": "sdebrosse/alexa_la_bos",
"path": "/index.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Initial session attributes are "+str(session['attributes']));
host = "http://bos.lacounty.gov/Board-Meeting/Board-Agendas";
url = host;
page = parse(url)
nodes = page.xpath("//div[a[text()='View Agenda']]");
latest_agenda_node = nodes[0];
headline = latest_agenda_no... | code_fim | hard | {
"lang": "python",
"repo": "sdebrosse/alexa_la_bos",
"path": "/index.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sdebrosse/alexa_la_bos path: /index.py
# -*- coding: utf-8 -*-
import requests
import json
import boto3
from lxml.html import parse
CardTitlePrefix = "Greeting"
def build_speechlet_response(title, output, reprompt_text, should_end_session):
"""
Build a speechlet JSON representation of t... | code_fim | hard | {
"lang": "python",
"repo": "sdebrosse/alexa_la_bos",
"path": "/index.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> subMenu = Menu(menu)
menu.add_cascade(label="File", menu=subMenu)
subMenu.add_command(label="New Game...", command=self.newGame)
subMenu.add_separator()
subMenu.add_command(label="Exit", command=self.exitGame)
def exitGame(self):
exit()
def newGa... | code_fim | medium | {
"lang": "python",
"repo": "paulusdevries/rock-paper-scissors",
"path": "/menu.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paulusdevries/rock-paper-scissors path: /menu.py
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(lab... | code_fim | medium | {
"lang": "python",
"repo": "paulusdevries/rock-paper-scissors",
"path": "/menu.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 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.newGame)
subMenu.add_separator()
subMenu.add_command... | code_fim | hard | {
"lang": "python",
"repo": "paulusdevries/rock-paper-scissors",
"path": "/menu.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.