text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>fig1, (ax1) = plt.subplots(1, 1, sharex=True, sharey=False, figsize=(17,12), dpi=166)
ax1.set_yscale('log')
ax1.set_xscale('log')
ax1.plot(freqs, T[:,0], color='black', label='1st Layer Spectra')
ax1.plot(freqs, T[:,1], color='red', label='2nd Layer Spectra')
ax1.plot(freqs, T[:,2], color='blue', label='3... | code_fim | hard | {
"lang": "python",
"repo": "mcooper52590/RadioAstronomy",
"path": "/Homework3/HW3-Problem3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> import StaticFiles
from .access_control import LoginHandler, LogoutHandler<|fim_prefix|># repo: blueshed/duckdown path: /duckdown/handlers/__init__.py
""" handlers """
from .editor_handler import EditorHandler
from .site_hand<|fim_middle|>ler import SiteHandler
from .dir_handler import DirHandler
from .... | code_fim | medium | {
"lang": "python",
"repo": "blueshed/duckdown",
"path": "/duckdown/handlers/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.initialize_dynamic_settings()
def initialize_dynamic_settings(self):
"""Initializes the configurations that increase during the game"""
self.hero_speed_factor = 1.5
self.bullet_speed_factor = 1
self.covid_horizontal_speed_factor = -10
self.alien_po... | code_fim | hard | {
"lang": "python",
"repo": "carlinhoshk/python",
"path": "/pygame/hero_combat/hero_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carlinhoshk/python path: /pygame/hero_combat/hero_settings.py
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 28 2020
@author: Cassio (chmendonca)
Description: This class was created as a container to the game characteristics
and configurations
"""
from random import randint
class Settings():
... | code_fim | hard | {
"lang": "python",
"repo": "carlinhoshk/python",
"path": "/pygame/hero_combat/hero_settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Initializes the configurations that increase during the game"""
self.hero_speed_factor = 1.5
self.bullet_speed_factor = 1
self.covid_horizontal_speed_factor = -10
self.alien_points = 50
#The pandemy direction equals 1 means to the bottom; -1 means to the ... | code_fim | hard | {
"lang": "python",
"repo": "carlinhoshk/python",
"path": "/pygame/hero_combat/hero_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zefciu/django-bob path: /bob/templatetags/bob.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import json
import datetime
from django import template
from django.util... | code_fim | hard | {
"lang": "python",
"repo": "zefciu/django-bob",
"path": "/bob/templatetags/bob.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@register.inclusion_tag('bob/form_as_fieldsets.html')
def form_as_fieldsets(form_instance, *args, **kwargs):
if not getattr(form_instance.Meta, 'fieldset', None):
raise Exception(
"{}.Meta.fieldset attribute is UNDEFINED or EMPTY".format(
repr(form_instance)
... | code_fim | hard | {
"lang": "python",
"repo": "zefciu/django-bob",
"path": "/bob/templatetags/bob.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
'items': items,
'selected': selected,
}
@register.inclusion_tag('bob/sidebar_menu_subitems.html')
def sidebar_menu_subitems(item, selected):
"""
Show subitems of a menu in a sidebar.
"""
return {
'item': item,
'selected': selected,
}
... | code_fim | hard | {
"lang": "python",
"repo": "zefciu/django-bob",
"path": "/bob/templatetags/bob.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>]+utils.laplace(1/epsilon))
myHist = plt.hist(noises, 10000, normed=True)
plt.show()<|fim_prefix|># repo: mishravikas/DPsim path: /laplace_plot.py
import utils
from pylab import *
from random import shuffle
import matplotlib.pyplot<|fim_middle|> as plt
zero_list = [0]*3000
one_list = [1]*1000
counts = z... | code_fim | medium | {
"lang": "python",
"repo": "mishravikas/DPsim",
"path": "/laplace_plot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mishravikas/DPsim path: /laplace_plot.py
import utils
from pylab import *
from random import shuffle
import matplotlib.pyplot as plt
zero_list = [0]*3000
one_list = [1]*1000
counts = zero_list + one_list
shuffl<|fim_suffix|>]+utils.laplace(1/epsilon))
myHist = plt.hist(noises, 10000, normed=True... | code_fim | medium | {
"lang": "python",
"repo": "mishravikas/DPsim",
"path": "/laplace_plot.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>e(counts)
noises = []
epsilon = 0.3
for i in range(4000):
noises.append(counts[i]+utils.laplace(1/epsilon))
myHist = plt.hist(noises, 10000, normed=True)
plt.show()<|fim_prefix|># repo: mishravikas/DPsim path: /laplace_plot.py
import utils
from pylab import *
from random import shuffle
import matplo... | code_fim | medium | {
"lang": "python",
"repo": "mishravikas/DPsim",
"path": "/laplace_plot.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>Menu.add_item(
"main",
MenuItem(
"Logout",
reverse("logout"),
weight=1000,
check=lambda request: request.user.is_authenticated,
),
)<|fim_prefix|># repo: mt-krainski/speakers-dashboard path: /utils/menus.py
from django.urls import reverse
from menu import Menu,... | code_fim | medium | {
"lang": "python",
"repo": "mt-krainski/speakers-dashboard",
"path": "/utils/menus.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mt-krainski/speakers-dashboard path: /utils/menus.py
from django.urls import reverse
from menu import Menu, MenuItem
Menu.add_item(
"main",
MenuItem(
"Add presentation",
reverse("presentation-manager:presentation-add"),
weight=1000,
check=lambda request: r... | code_fim | hard | {
"lang": "python",
"repo": "mt-krainski/speakers-dashboard",
"path": "/utils/menus.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.errorhandler(404)
def not_found(error):
return make_response(jsonify({'error': 'Not found'}), 404)
if __name__ == '__main__':
app.run(debug=True)<|fim_prefix|># repo: keithleung95/python-flask-REST-API path: /app.py
#!flask/bin/python3.7
from flask import Flask, jsonify, abort, make_respons... | code_fim | medium | {
"lang": "python",
"repo": "keithleung95/python-flask-REST-API",
"path": "/app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route('/device/<int:device_id>', methods=['GET'])
def get_device(device_id):
device = [device for device in devices if device['id'] == device_id]
if len(device) == 0:
abort(404)
return jsonify({'device': device[0]})
@app.errorhandler(404)
def not_found(error):
return make_res... | code_fim | medium | {
"lang": "python",
"repo": "keithleung95/python-flask-REST-API",
"path": "/app.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keithleung95/python-flask-REST-API path: /app.py
#!flask/bin/python3.7
from flask import Flask, jsonify, abort, make_response
app = Flask(__name__)
<|fim_suffix|>@app.route('/device/<int:device_id>', methods=['GET'])
def get_device(device_id):
device = [device for device in devices if devic... | code_fim | hard | {
"lang": "python",
"repo": "keithleung95/python-flask-REST-API",
"path": "/app.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: biancini/Rorschach-Test-Platform path: /utils/libsna.py
from networkx import Graph
from networkx import degree_centrality, closeness_centrality, eigenvector_centrality, betweenness_centrality
from networkx import find_cliques
import logging
import conf
import datetime
import numpy as np
import n... | code_fim | hard | {
"lang": "python",
"repo": "biancini/Rorschach-Test-Platform",
"path": "/utils/libsna.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.measures['density'] = num_edges / tot_edges * 100
self.nodesmeasures['density'] = None
self.edgesmeasures['density'] = w
def calculate_geodesic(self, backend=False):
logging.info("Calculating geodesic.")
path = self.floyd_warshall... | code_fim | hard | {
"lang": "python",
"repo": "biancini/Rorschach-Test-Platform",
"path": "/utils/libsna.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def plot_data(sim):
fig = plt.figure(figsize=(6.0,5))
#fig = plt.figure(figsize=(7.36,5))
ax_whole_domain = plt.subplot2grid((4,100),(0,0),rowspan=4,colspan=50,aspect='equal',adjustable='box-forced')
colormap=np.linspace(np.nanmin(sim.U),np.nanmax(sim.U),300)
#ax_whole_domain.contour (... | code_fim | hard | {
"lang": "python",
"repo": "srharris91/PostProcessing_Scripts",
"path": "/DA_Paraview_csv/Read_Plot_instant.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: srharris91/PostProcessing_Scripts path: /DA_Paraview_csv/Read_Plot_instant.py
import sys
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as patches
from scipy.interpolate import griddata
import h5py
plt.style.use('seaborn-paper')
class sim_avg:
def __init__(self,... | code_fim | hard | {
"lang": "python",
"repo": "srharris91/PostProcessing_Scripts",
"path": "/DA_Paraview_csv/Read_Plot_instant.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #xbmc.executebuiltin('Shutdown()')
system('sudo shutdown -h now');
if __name__ == '__main__':
while system('pidof pigpiod') != 0:
time.sleep(1)
time.sleep(1) # wait for pigpio to get a socket-connection...
pi = pigpio.pi()
timer = TimerDialogCallback(pi, 10, 10, "Shutting Down", my_func)
while ... | code_fim | medium | {
"lang": "python",
"repo": "bkcsoft/service.xbmc.shutdowntimer",
"path": "/service.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#Print the contents of the message to the console
print 'This is our produced rotation matrix'
joints = [message.position[4], message.position[5], message.position[2], message.position[3], message.position[6], message.position[7], message.position[8]]
ours = llib.gst(joints)
print... | code_fim | hard | {
"lang": "python",
"repo": "RoSp201/baxter-dominoes",
"path": "/motion_planning/python_lab_scripts/lab3/forward_kinematics.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RoSp201/baxter-dominoes path: /motion_planning/python_lab_scripts/lab3/forward_kinematics.py
#!/usr/bin/env python
#The line above tells Linux that this file is a Python script,
#and that the OS should use the Python interpreter in /usr/bin/env
#to run it. Don't forget to use "chmod +x [filename]... | code_fim | hard | {
"lang": "python",
"repo": "RoSp201/baxter-dominoes",
"path": "/motion_planning/python_lab_scripts/lab3/forward_kinematics.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> problem = 'CartPole-v0'
param = {'e_anneal_steps': 10000,
'learning_rate': 0.01,
'n_epoch': 1,
'gamma': 0.99}
sys_vars = rl.run_dqn.run_session(problem, param)
assert(sys_vars['RENDER'] == False)
# ensure it runs, a... | code_fim | hard | {
"lang": "python",
"repo": "corba777/openai_gym",
"path": "/test/test_rl.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> max_size = 0
rs = len(grid)
cs = len(grid[0])
for i in range(rs):
for j in range(cs):
if grid[i][j] == 0:
max_size = max(max_size, _wbs(i, j, rs, cs, grid))
return max_size
"""
Dp Solution
"""
# def find_largest_water_body_2(matrix):
# max_si... | code_fim | medium | {
"lang": "python",
"repo": "sandeepyadav10011995/Data-Structures",
"path": "/IT Bodhi/Recursion/5. Largest Water Body Size in 2D matrix of 0-1. 0 indicates Water and 1 indicates Land. Water bodies are connected as up, down, left and right ways..py",
"mode": "spm",
"license": "unknown",
"source": "the-stack... |
<|fim_prefix|># repo: sandeepyadav10011995/Data-Structures path: /IT Bodhi/Recursion/5. Largest Water Body Size in 2D matrix of 0-1. 0 indicates Water and 1 indicates Land. Water bodies are connected as up, down, left and right ways..py
"""
You can call the function find_largest_water_body by passing in a 2D matrix of... | code_fim | medium | {
"lang": "python",
"repo": "sandeepyadav10011995/Data-Structures",
"path": "/IT Bodhi/Recursion/5. Largest Water Body Size in 2D matrix of 0-1. 0 indicates Water and 1 indicates Land. Water bodies are connected as up, down, left and right ways..py",
"mode": "psm",
"license": "unknown",
"source": "the-stack... |
<|fim_suffix|>if __name__ == '__main__':
logging.basicConfig(level=logging.INFO)
root_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
data_path = os.path.join(root_path, 'data', 'SO_GH')
so_user_question_file = os.path.join(data_path, 'user_question.csv.gz')
so_... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/crossact",
"path": "/crossact/data/data_utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vishalbelsare/crossact path: /crossact/data/data_utils.py
import os
import logging
import pandas as pd
from sklearn.feature_extraction.text import TfidfVectorizer
from collections import defaultdict
from time import time
class DataLoader:
"""
Utility class for loading various types of ... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/crossact",
"path": "/crossact/data/data_utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
path_file (str): Data location path
Returns:
pd.DataFrame: Label dataframe
"""
if '.csv' not in path_file:
raise FileNotFoundError('Only CSV format is supported currently')
t0 = time()
df = pd.DataFrame()
... | code_fim | hard | {
"lang": "python",
"repo": "vishalbelsare/crossact",
"path": "/crossact/data/data_utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mtn/icpc-cuddly-happiness path: /Casper's practice stuff/goodcoalition.py
from functools import reduce
numTestCases = int(input())
def go():
global opt,p,s
numParties = int(input())
parties = []
for i in range(numParties):
si, pi = [int(x) for x in input().split(' ')]
... | code_fim | medium | {
"lang": "python",
"repo": "mtn/icpc-cuddly-happiness",
"path": "/Casper's practice stuff/goodcoalition.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(numParties):
for S in range(50):
ssi = max(S-s[i], 0)
if S <= s[i] and i > 0:
opt[i][S] = max(opt[i-1][S],opt[i-1][0]*p[i],p[i] )
elif i > 0: # S > s[i]
opt[0][S] = max(opt[i-1][S],opt[i-1][S-s[i]]*p[i])
else: ... | code_fim | medium | {
"lang": "python",
"repo": "mtn/icpc-cuddly-happiness",
"path": "/Casper's practice stuff/goodcoalition.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> else: # i = 0 and any S
opt[i][S] = 0 if s[0] < S else p[0]
print(opt[-1][50])
for i in range(numTestCases):
go()<|fim_prefix|># repo: mtn/icpc-cuddly-happiness path: /Casper's practice stuff/goodcoalition.py
from functools import reduce
numTestCases = int(input()... | code_fim | hard | {
"lang": "python",
"repo": "mtn/icpc-cuddly-happiness",
"path": "/Casper's practice stuff/goodcoalition.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hiroshiyu/Aspose_Cloud_SDK_For_Python path: /src/aspose/cloud/cells/Extractor.py
from aspose.cloud.common.product import Product
from aspose.cloud.common.utils import Utils
from aspose.cloud.common.asposeapp import AsposeApp
class CellsExtractor(object):
file_name = ""
def __init__(sel... | code_fim | hard | {
"lang": "python",
"repo": "hiroshiyu/Aspose_Cloud_SDK_For_Python",
"path": "/src/aspose/cloud/cells/Extractor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/cells/" + self.file_name + "/worksheets/" + worksheet_name + "/charts/" + str(chart_index) + "?format=" + image_format
signed_uri = U... | code_fim | hard | {
"lang": "python",
"repo": "hiroshiyu/Aspose_Cloud_SDK_For_Python",
"path": "/src/aspose/cloud/cells/Extractor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(tumor_col, str):
tumor_col = np.where(drug_response_data.columns == tumor_col)[0][0]
if isinstance(drug_col, str):
drug_col = np.where(drug_response_data.columns == drug_col)[0][0]
drug_response_data = drug_response_data.copy()
drug_response_data = drug_resp... | code_fim | hard | {
"lang": "python",
"repo": "ECP-CANDLE/Benchmarks",
"path": "/common/P1_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def generate_gene_set_data(
data,
genes,
gene_name_type="entrez",
gene_set_category="c6.all",
metric="mean",
standardize=False,
data_dir="../../Data/examples/Gene_Sets/MSigDB.v7.0/",
):
"""
This function generates genomic data summarized at the gene set level.
Par... | code_fim | hard | {
"lang": "python",
"repo": "ECP-CANDLE/Benchmarks",
"path": "/common/P1_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ECP-CANDLE/Benchmarks path: /common/P1_utils.py
eneralizable_gene: positive integer indicating the number of generalizable genes to be selected.
multi_drug_mode: boolean, indicating whether the function runs as an auxiliary function of COXEN
gene selection for multiple drugs. Default ... | code_fim | hard | {
"lang": "python",
"repo": "ECP-CANDLE/Benchmarks",
"path": "/common/P1_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tedisfree/python path: /download-file-via-http/download-file-via-http.py
import os
import requests
import re
def main():
print('start download test')
with requests.get('http://tedisfree.github.io/abcdef', stream=True) as r:
if r.status_code!=200:
print('failed to down... | code_fim | hard | {
"lang": "python",
"repo": "tedisfree/python",
"path": "/download-file-via-http/download-file-via-http.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> filename = filename.replace('"', '')
print('dest name = '+filename)
with open(filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024*1024):
if chunk:
f.write(chunk)
print('download complete. file name='+filename)
if... | code_fim | hard | {
"lang": "python",
"repo": "tedisfree/python",
"path": "/download-file-via-http/download-file-via-http.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> X_train = X_train.astype("float32")
X_test = X_test.astype("float32")
X_train /= 255
X_test /= 255
model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=10)
score = model.evaluate(X_test, Y_test, batch_size=batch_size)
print 'Test score:', scor... | code_fim | hard | {
"lang": "python",
"repo": "seba-1511/gsoc15-demo",
"path": "/cifar100_cnn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def add_HetrServicer_to_server(servicer, server):
rpc_method_handlers = {
'BuildTransformer': grpc.unary_unary_rpc_method_handler(
servicer.BuildTransformer,
request_deserializer=ngraph_dot_op__graph_dot_hetr__grpc_dot_hetr__pb2.BuildRequest.FromString,
response_seri... | code_fim | hard | {
"lang": "python",
"repo": "psdurley/ngraph",
"path": "/ngraph/op_graph/hetr_grpc/hetr_pb2_grpc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Guillaume-Docquier/Thingy path: /authentication/models.py
from django.contrib.auth.models import AbstractBaseUser
from django.contrib.auth.models import BaseUserManager
from django.db import models
#from review.views import ReviewViewSet
#import Review
from django.db.models import Avg
class Ac... | code_fim | hard | {
"lang": "python",
"repo": "Guillaume-Docquier/Thingy",
"path": "/authentication/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def create_superuser(self, email, password, **kwargs):
account = self.create_user(email, password, **kwargs)
account.is_admin = True
account.save()
return account
class Account(AbstractBaseUser):
username = models.CharField(max_length=40, unique=True)
email =... | code_fim | hard | {
"lang": "python",
"repo": "Guillaume-Docquier/Thingy",
"path": "/authentication/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tuyixiang/Python-Tools path: /mp/reduce.py
"""Reduce 操作"""
# TO BE UPDATED
from functools import partial
from typing import Any, Callable, Generator, Iterable, Iterator
from more_itertools import chunked, first, take
from multiprocess import Process, Queue, cpu_count
from pb import ProgressBar... | code_fim | hard | {
"lang": "python",
"repo": "Tuyixiang/Python-Tools",
"path": "/mp/reduce.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 可能需要计算 size
if size is not None and size == -1:
try:
size = len(data)
except TypeError:
data = list(data)
size = len(data)
iterator = iter(data)
# 分层计算,每一层达到上限后计算下一层
output = [take(batch_size, iterator)]
def reduce_layer(index... | code_fim | hard | {
"lang": "python",
"repo": "Tuyixiang/Python-Tools",
"path": "/mp/reduce.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(len(output)):
if i + 1 >= len(output):
chunk = output[i]
while len(chunk) > max(chunk_size, 2 * jobs):
new_chunk_size = min(chunk_size, len(chunk) // jobs + 1)
new_chunk = map(
_reduce_chunk,
... | code_fim | hard | {
"lang": "python",
"repo": "Tuyixiang/Python-Tools",
"path": "/mp/reduce.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bletzacker/alyra path: /challenge/1/menu.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pip install console-menu
from consolemenu import *
from consolemenu.items import *
from converter import *
def cm_hexadecimal2decimal():
Screen().println(str(hexadecimal2decimal(Screen().input('Ent... | code_fim | medium | {
"lang": "python",
"repo": "bletzacker/alyra",
"path": "/challenge/1/menu.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def cm_target2difficulty():
Screen().println(str(target2difficulty(int(Screen().input('Enter a target in decimal : ').input_string))))
Screen().input('Press [Enter] to continue')
def cm_decode_transaction():
decode_transaction(Screen().input('Enter a raw bitcoin hexadecimal transaction : ').i... | code_fim | hard | {
"lang": "python",
"repo": "bletzacker/alyra",
"path": "/challenge/1/menu.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #compute codon usage
computed_codon_usage = {}
computed_codon_usage_unw = {}
computed_codon_usage_groupw = {}
absolute_usage = {}
relative_usage = {}
relative_usage_unw = {}
relative_usage_groupw = {}
for gi in gis:
computed_codon_usage[gi] = defaultdict(int)
computed_codon_usage_unw[gi] = d... | code_fim | hard | {
"lang": "python",
"repo": "FDA/Identifying-Gene-Variants-of-Viral-Interactors",
"path": "/rc_enrichment/calc_codon_usage.py",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FDA/Identifying-Gene-Variants-of-Viral-Interactors path: /rc_enrichment/calc_codon_usage.py
# Copyright (C) 2017 William M. Jacobs
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Fou... | code_fim | hard | {
"lang": "python",
"repo": "FDA/Identifying-Gene-Variants-of-Viral-Interactors",
"path": "/rc_enrichment/calc_codon_usage.py",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> #read fasta files
seqs = {}
if isinstance(fasta, str):
gene = "".join(os.path.basename(fasta).split(".")[:-1])
seqs[gene] = read_fasta(fasta)
elif isinstance(fasta, (list, tuple)):
for path in fasta:
gene = "".join(os.path.basename(path).split(".")[:-1])
seqs[gene] = read_fasta(path)
if v... | code_fim | hard | {
"lang": "python",
"repo": "FDA/Identifying-Gene-Variants-of-Viral-Interactors",
"path": "/rc_enrichment/calc_codon_usage.py",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Adds the given number of callbacks/errbacks/both to a deferred while it is
paused, and unpauses it, trigerring the processing of the value through the
callbacks.
"""
d = defer.Deferred()
def f(result):
return result
d.callback(1)
d.pause()
for i in xrang... | code_fim | hard | {
"lang": "python",
"repo": "svpcom/twisted-cdeferred",
"path": "/doc/core/benchmarks/defer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: svpcom/twisted-cdeferred path: /doc/core/benchmarks/defer.py
# Copyright (c) 2007 Twisted Matrix Laboratories.
# See LICENSE for details.
"""
See how fast deferreds are.
This is mainly useful to compare cdefer.Deferred to defer.Deferred
"""
from twisted.internet import defer
from timer import... | code_fim | hard | {
"lang": "python",
"repo": "svpcom/twisted-cdeferred",
"path": "/doc/core/benchmarks/defer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> > 0.15 and light < 0.7):
# print ('Partial light available')
# else:
# print ('Not sufficient light')
#
time.sleep(10)
#<|fim_prefix|># repo: aadithyasujit/Project_Plant path: /codes/lighty.py
import RPi.GPIO as GPIO
import subprocess
while True:
GPIO.cleanup()
subprocess.Pop... | code_fim | medium | {
"lang": "python",
"repo": "aadithyasujit/Project_Plant",
"path": "/codes/lighty.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aadithyasujit/Project_Plant path: /codes/lighty.py
import RPi.GPIO as GPIO
import subprocess
while True:
GPIO.cleanup()
subprocess.Popen("simpletest.py", shell=True)
# senso<|fim_suffix|>Light Source={0:0.1f}%'.format(light*100))
# if (light == 0 or light < 0.15):
# print... | code_fim | medium | {
"lang": "python",
"repo": "aadithyasujit/Project_Plant",
"path": "/codes/lighty.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangmn93/ms-th-2018 path: /classifier.py
from __future__ import print_function
from __future__ import division
from __future__ import print_function
from __future__ import absolute_import
import tensorflow as tf
import models_mnist
def weight_variable(shape):
initial = tf.truncated_normal(s... | code_fim | hard | {
"lang": "python",
"repo": "wangmn93/ms-th-2018",
"path": "/classifier.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32), name='accuracy')
# Training algorithm
c_var = tf.trainable_variables('classifier')
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy, var_... | code_fim | hard | {
"lang": "python",
"repo": "wangmn93/ms-th-2018",
"path": "/classifier.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jaewookahn/adaptive_vibe_testing path: /scripts/clustering/clustering.py
#!/usr/bin/python
def get_clustering():
f = open('clusterings.txt')
cl = {}
cli = {}
<|fim_suffix|> key = "%s:%s" % (topicid, clusterid)
cl[key] = docs
for doc in docs:
if not cli.has_key(doc):
cli[doc] = ... | code_fim | medium | {
"lang": "python",
"repo": "jaewookahn/adaptive_vibe_testing",
"path": "/scripts/clustering/clustering.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> key = "%s:%s" % (topicid, clusterid)
cl[key] = docs
for doc in docs:
if not cli.has_key(doc):
cli[doc] = key
else:
print "error"
return (cl, cli)<|fim_prefix|># repo: jaewookahn/adaptive_vibe_testing path: /scripts/clustering/clustering.py
#!/usr/bin/python
def get_clustering():
... | code_fim | medium | {
"lang": "python",
"repo": "jaewookahn/adaptive_vibe_testing",
"path": "/scripts/clustering/clustering.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cainingning/leetcode path: /tree_117.py
# Definition for binary tree with next pointer.
# class TreeLinkNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# self.next = None
class Solution:
<|fim_suffix|> while len(tmp)... | code_fim | hard | {
"lang": "python",
"repo": "cainingning/leetcode",
"path": "/tree_117.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # @param root, a tree link node
# @return nothing
def connect(self, root):
if root is None or (root.left is None and root.right is None):
return
tmp = [root]
while len(tmp) > 0:
num = len(tmp)
for i in range(num):
nod... | code_fim | hard | {
"lang": "python",
"repo": "cainingning/leetcode",
"path": "/tree_117.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if root is None or (root.left is None and root.right is None):
return
tmp = [root]
while len(tmp) > 0:
num = len(tmp)
for i in range(num):
node = tmp.pop(0)
if i < num - 1:
node.next = tmp[0]
... | code_fim | hard | {
"lang": "python",
"repo": "cainingning/leetcode",
"path": "/tree_117.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sinotradition/meridian path: /meridian/acupoints/yingxiang21.py
#!/usr/bin/python
#coding=utf-8
<|fim_suffix|>if __name__ == '__main__':
pass<|fim_middle|>'''
@author: sheng
@license:
'''
SPELL=u'yíngxiāng'
CN=u'迎香'
NAME=u'yingxiang21'
CHANNEL='largeintestine'
CHANNEL_FULLNAME='LargeInte... | code_fim | medium | {
"lang": "python",
"repo": "sinotradition/meridian",
"path": "/meridian/acupoints/yingxiang21.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>SPELL=u'yíngxiāng'
CN=u'迎香'
NAME=u'yingxiang21'
CHANNEL='largeintestine'
CHANNEL_FULLNAME='LargeIntestineChannelofHand-Yangming'
SEQ='LI20'
if __name__ == '__main__':
pass<|fim_prefix|># repo: sinotradition/meridian path: /meridian/acupoints/yingxiang21.py
#!/usr/bin/python
#coding=utf-8
<|fim_mid... | code_fim | easy | {
"lang": "python",
"repo": "sinotradition/meridian",
"path": "/meridian/acupoints/yingxiang21.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
pass<|fim_prefix|># repo: sinotradition/meridian path: /meridian/acupoints/yingxiang21.py
#!/usr/bin/python
#coding=utf-8
<|fim_middle|>'''
@author: sheng
@license:
'''
SPELL=u'yíngxiāng'
CN=u'迎香'
NAME=u'yingxiang21'
CHANNEL='largeintestine'
CHANNEL_FULLNAME='LargeInt... | code_fim | medium | {
"lang": "python",
"repo": "sinotradition/meridian",
"path": "/meridian/acupoints/yingxiang21.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lamby/hba1c.chris-lamb.co.uk path: /hba1c/reports/utils.py
from reportlab.lib import utils
from reportlab.pdfgen import canvas
from reportlab.lib.units import cm
from reportlab.lib.pagesizes import landscape, A4
from django.contrib.staticfiles.storage import staticfiles_storage
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "lamby/hba1c.chris-lamb.co.uk",
"path": "/hba1c/reports/utils.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>def drawImage(canvas, filename, x, y, width, height=None):
path = staticfiles_storage.path('images/f_reports_pdf/%s' % filename)
if height is None:
iw, ih = utils.ImageReader(path).getSize()
aspect = ih / float(iw)
height = width * aspect
canvas.drawImage(
pat... | code_fim | hard | {
"lang": "python",
"repo": "lamby/hba1c.chris-lamb.co.uk",
"path": "/hba1c/reports/utils.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DavidSchimmel/AutoRoboEngine path: /Evolution.py
#Simone and David
import numpy as np
import random
import matplotlib.pyplot as plt
from Config import Config
import json
DEBUG = False
if DEBUG:
def simulate_episode(population): #stupid function that only return the sum of all the el... | code_fim | hard | {
"lang": "python",
"repo": "DavidSchimmel/AutoRoboEngine",
"path": "/Evolution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Log functions
if verbose: print('Generation ',generation_counter,' Best: ',self.population[0],' with value: ', self.fit[0])
self.h_fmax.append(self.fit[0])
self.h_favg.append(sum(self.fit)/len(self.fit))
self.h_div.append(self.diversity())
... | code_fim | hard | {
"lang": "python",
"repo": "DavidSchimmel/AutoRoboEngine",
"path": "/Evolution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def evolution(self, verbose=True, mantain_best=True, exp=0, fp=None):
self.initialization()
for generation_counter in range(self.num_gen):
self.evaluation(generation_counter)
self.population = self.selection_reproduction(mode='rank_proportional', n_best=self... | code_fim | hard | {
"lang": "python",
"repo": "DavidSchimmel/AutoRoboEngine",
"path": "/Evolution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: piyush4for/python_automation_beginner path: /excel_reading/write.py
import openpyxl,os
wb = openpyxl.Workbook()
<|fim_suffix|>sheet2= wb.create_sheet()
print(wb.sheetnames)<|fim_middle|>print(wb.sheetnames)
sheet = wb['Sheet']
sheet['A1'] = 32
sheet['A2'] = 'hello'
wb.save('example2.xlsx')
| code_fim | medium | {
"lang": "python",
"repo": "piyush4for/python_automation_beginner",
"path": "/excel_reading/write.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>sheet2= wb.create_sheet()
print(wb.sheetnames)<|fim_prefix|># repo: piyush4for/python_automation_beginner path: /excel_reading/write.py
import openpyxl,os
wb = openpyxl.Workbook()
print(wb.sheetnames)
sheet = wb['Sheet']
<|fim_middle|>sheet['A1'] = 32
sheet['A2'] = 'hello'
wb.save('example2.xlsx')
| code_fim | medium | {
"lang": "python",
"repo": "piyush4for/python_automation_beginner",
"path": "/excel_reading/write.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cyrilbois/book-python path: /control-flow/solution/for_dict_to_dict.py
INPUT = {
4: ['Masters', 'Doctorate', 'Prof-school'],
6: ['HS-grad'],
3: ['Bachelor']
}
wynik = {}
for key, value in INPUT.items():
for education in value:
wynik[education] = str(key)
<|fim_suffix|>p... | code_fim | medium | {
"lang": "python",
"repo": "cyrilbois/book-python",
"path": "/control-flow/solution/for_dict_to_dict.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>## Alternatywnie:
#
# wynik = {education: str(key)
# for key, value in EDUCATION_GROUPS.items()
# for education in value
# }
print(wynik)
# OUTPUT = {
# 'Masters': '4',
# 'Doctorate': '4',
# 'Prof-school': '4',
# 'HS-grad': '6',
# 'Bachelor': '3',
# }<|fim_prefix|># repo:... | code_fim | medium | {
"lang": "python",
"repo": "cyrilbois/book-python",
"path": "/control-flow/solution/for_dict_to_dict.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
A = 0
"""
if __name__ == "__main__":
R,V,tid,dropout,E,A = oppgave3()
fig1 = plt.figure("Oppgave 3", figsize=(9,9))
ax1 = fig1.add_subplot(1,1,1)
#ax1.scatter(R[:,0], R[:,1], color = 'blue')
ax1.set_xlabel("X Pos[m]"), ax1.set_ylabel("Y Pos[m]... | code_fim | hard | {
"lang": "python",
"repo": "ealtheseal1/Fys1120",
"path": "/oppg3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not np.linalg.norm(R[i,:]) > r_D:
A = (e/m_p)*(E + np.cross(V[i],B))
else:
A = 0
"""
if __name__ == "__main__":
R,V,tid,dropout,E,A = oppgave3()
fig1 = plt.figure("Oppgave 3", figsize=(9,9))
ax1 = fig1.add_subp... | code_fim | hard | {
"lang": "python",
"repo": "ealtheseal1/Fys1120",
"path": "/oppg3.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ealtheseal1/Fys1120 path: /oppg3.py
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 24 21:59:06 2016
@author: Eirik
"""
import numpy as np
import matplotlib.pyplot as plt
import pylab as p
import mpl_toolkits.mplot3d.axes3d as p3
e = 1.6e-19
m_p = 1.672621637e-27 #Reference Pearson... | code_fim | hard | {
"lang": "python",
"repo": "ealtheseal1/Fys1120",
"path": "/oppg3.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> hash_object=hashlib.md5(l)
print '%s\t%s' % (hash_object.hexdigest(), score)<|fim_prefix|># repo: Feynman27/PythonSandbox path: /MasteringPythonForDataScience/overall_senti_mapper.py
#!/usr/bin/python
'''
Calculate the overall sentiment score for a review.
'''
import sys
import hashlib
def sen... | code_fim | hard | {
"lang": "python",
"repo": "Feynman27/PythonSandbox",
"path": "/MasteringPythonForDataScience/overall_senti_mapper.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Feynman27/PythonSandbox path: /MasteringPythonForDataScience/overall_senti_mapper.py
#!/usr/bin/python
'''
Calculate the overall sentiment score for a review.
'''
import sys
import hashlib
def sentiment_score(text,pos_list,neg_list):
pos_score=0
neg_score=0
for w in text.split(' ')... | code_fim | medium | {
"lang": "python",
"repo": "Feynman27/PythonSandbox",
"path": "/MasteringPythonForDataScience/overall_senti_mapper.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luqasz/netboot-manager path: /tests/views/root.py
import pytest
from ipxeboot import main
from webtest import TestApp as WebTestApp
class Test_Root_IPXE_Agent:
def setup(self):
app = main()
self.testapp = WebTestApp(app)
<|fim_suffix|> resp = self.testapp.get('/', s... | code_fim | hard | {
"lang": "python",
"repo": "luqasz/netboot-manager",
"path": "/tests/views/root.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> app = main()
self.testapp = WebTestApp(app)
@pytest.mark.parametrize("agent", (
'Mozilla/5.0',
'iPXE',
'ipxe/version',
))
def test_not_ipxe_script_response(self, agent):
resp = self.testapp.get('/', status=200, headers={'User-Agent': agent})
... | code_fim | hard | {
"lang": "python",
"repo": "luqasz/netboot-manager",
"path": "/tests/views/root.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Test_Root_Non_IPXE_Agent:
def setup(self):
app = main()
self.testapp = WebTestApp(app)
@pytest.mark.parametrize("agent", (
'Mozilla/5.0',
'iPXE',
'ipxe/version',
))
def test_not_ipxe_script_response(self, agent):
resp = self.testapp.g... | code_fim | hard | {
"lang": "python",
"repo": "luqasz/netboot-manager",
"path": "/tests/views/root.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 4seeders/account-generator path: /test/user_test.py
import os
import sys
# 부모디렉토리 참조를 위한 설정추가
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from user import User
user = User('test123','홍길동')
# 초기패스워드 조회
print(user.get_passowrd())
<|fim_suffix|>
# 이름 출력
if user... | code_fim | hard | {
"lang": "python",
"repo": "4seeders/account-generator",
"path": "/test/user_test.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# 이름 출력
if user.get_first_name() == '길동':
print('pass => get first name : ', user.get_first_name())
else:
raise ValueError()<|fim_prefix|># repo: 4seeders/account-generator path: /test/user_test.py
import os
import sys
# 부모디렉토리 참조를 위한 설정추가
sys.path.append(os.path.dirname(os.path.dirname(os.path... | code_fim | hard | {
"lang": "python",
"repo": "4seeders/account-generator",
"path": "/test/user_test.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kbaseapps/kb_SPAdes path: /kb_SPAdes.spec
/*
A KBase module: kb_SPAdes
A wrapper for the SPAdes assembler with hybrid features supported.
http://bioinf.spbau.ru/spades
Always runs in careful mode.
Runs 3 threads / CPU.
Maximum memory use is set to available memory - 1G.
Autodetection is used for... | code_fim | hard | {
"lang": "python",
"repo": "kbaseapps/kb_SPAdes",
"path": "/kb_SPAdes.spec",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> - orientation ("fr", "rf", "ff")
- type ("paired-end", "mate-pairs", "hq-mate-pairs", "single", "pacbio", "nanopore", "sanger", "trusted-contigs", "untrusted-contigs")
- interlaced reads (comma-separated list of files with interlaced reads)
- left reads (com... | code_fim | hard | {
"lang": "python",
"repo": "kbaseapps/kb_SPAdes",
"path": "/kb_SPAdes.spec",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> typedef structure {
obj_ref long_reads_ref;
string long_reads_type;
} LongReadsParams;
/*------To run HybridSPAdes you need at least one library of the following types:------
1) Illumina paired-end/high-quality mate-pairs/unpaired reads
2) IonTorrent paired-end/high-q... | code_fim | hard | {
"lang": "python",
"repo": "kbaseapps/kb_SPAdes",
"path": "/kb_SPAdes.spec",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: plandes/zenbuild path: /bin/buildinfo.py
#!/usr/bin/env python
"""Command line program to access build information.
"""
__author__ = 'Paul Landes'
from typing import List, Dict, Union, Iterable, Tuple
from dataclasses import dataclass, field
import logging
import re
import sys
import json
impo... | code_fim | hard | {
"lang": "python",
"repo": "plandes/zenbuild",
"path": "/bin/buildinfo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return a set key attributes as a dict where keys are ``attribs``.
:see: :meth:`get_attribs`
"""
attrs = self.get_attribs(attribs)
attrs = tuple(map(lambda a: (a[0][1:], a[1]), attrs))
return dict(attrs)
def _format_key(self, k: str) -> str:
... | code_fim | hard | {
"lang": "python",
"repo": "plandes/zenbuild",
"path": "/bin/buildinfo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: harshidkoladara/Online-Police-Complain-System path: /complain.py
from tkinter import *
from mainconnection import *
def complen():
root = Tk()
root.geometry("650x500")
root.title("Complain")
f1 = Frame(root)
f1.grid(row=0, column=0)
f2 = Frame(root)
f2.grid(row=1,... | code_fim | medium | {
"lang": "python",
"repo": "harshidkoladara/Online-Police-Complain-System",
"path": "/complain.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> l1 = Label(f2, text="Department Address", width=30, pady=10)
l1.grid(row=0, column=0)
e1 = Entry(f2, width=40)
e1.grid(row=0, column=1)
con = sql_connection()
what = sql_table(con)
if (what == 1):
con = sql_connection()
cursorObj = con.cursor()
cursorO... | code_fim | medium | {
"lang": "python",
"repo": "harshidkoladara/Online-Police-Complain-System",
"path": "/complain.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZaytsevIlia/first_quarter path: /lesson6/task6/show_sales.py
from sys import argv
from itertools import islice
with open('bakery.csv') as f:
if len(argv)<|fim_suffix|> 3:
for line in islice(f, int(argv[1]) - 1, int(argv[2])):
print(line.strip())<|fim_middle|> == 1:
... | code_fim | medium | {
"lang": "python",
"repo": "ZaytsevIlia/first_quarter",
"path": "/lesson6/task6/show_sales.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> 3:
for line in islice(f, int(argv[1]) - 1, int(argv[2])):
print(line.strip())<|fim_prefix|># repo: ZaytsevIlia/first_quarter path: /lesson6/task6/show_sales.py
from sys import argv
from itertools import islice
with open('bakery.csv') as f:
if len(argv)<|fim_middle|> == 1:
... | code_fim | medium | {
"lang": "python",
"repo": "ZaytsevIlia/first_quarter",
"path": "/lesson6/task6/show_sales.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # initialize an empty board
board = ""
# a standard tic-tac-toe board has 5 rows so
for i in range(5):
# switch between printing vertical and horizontal bars
if i%2 == 0:
board += "| " * 4
else:
board += " --- " * 3
bo... | code_fim | easy | {
"lang": "python",
"repo": "Mutwish/KamiLimu_Python_Assignment-",
"path": "/homework_1.2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Mutwish/KamiLimu_Python_Assignment- path: /homework_1.2.py
# Tracy Otieno
# homework_1.2.py
# May 4, 2017
<|fim_suffix|> # initialize an empty board
board = ""
# a standard tic-tac-toe board has 5 rows so
for i in range(5):
# switch between printing vertical and horizo... | code_fim | easy | {
"lang": "python",
"repo": "Mutwish/KamiLimu_Python_Assignment-",
"path": "/homework_1.2.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> # a standard tic-tac-toe board has 5 rows so
for i in range(5):
# switch between printing vertical and horizontal bars
if i%2 == 0:
board += "| " * 4
else:
board += " --- " * 3
board += "\n"
print(board)
draw()<|fim_prefi... | code_fim | medium | {
"lang": "python",
"repo": "Mutwish/KamiLimu_Python_Assignment-",
"path": "/homework_1.2.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leilalu/algorithm path: /剑指offer/第一遍/linkedlist/05.从尾到头打印链表.py
"""
题目描述
输入一个链表,按链表从尾到头的顺序返回一个ArrayList。
"""
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution1:
def printListFromTailToHead(self, listNode):
"""
暴力法... | code_fim | hard | {
"lang": "python",
"repo": "leilalu/algorithm",
"path": "/剑指offer/第一遍/linkedlist/05.从尾到头打印链表.py",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>
:param listNode:
:return:
"""
if listNode:
self.printListFromTailToHead_1(listNode.next)
self.res.append(listNode.val)
return self.res
def printListFromTailToHead_2(self, listNode):
"""
递归的第二种写法,内部函数
:para... | code_fim | hard | {
"lang": "python",
"repo": "leilalu/algorithm",
"path": "/剑指offer/第一遍/linkedlist/05.从尾到头打印链表.py",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rm-hull/zaup path: /zaup/zeroseg.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2017-18 Richard Hull and contributors
# See LICENSE.md for details.
"""
Display a TOTP code based on some stored secrets
"""
import time
import RPi.GPIO as GPIO
from luma.core.serial import spi
f... | code_fim | hard | {
"lang": "python",
"repo": "rm-hull/zaup",
"path": "/zaup/zeroseg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def message(self, next=None):
n = self.current % len(self.secrets)
token = get_token(self.secrets[n])
self.seg.device.clear()
scroll_message(self.seg.device, self.secrets[n].name)
self.seg.text = " %06d" % token
if next:
self.loop.call_soon... | code_fim | hard | {
"lang": "python",
"repo": "rm-hull/zaup",
"path": "/zaup/zeroseg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.