text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> docs = [
{'name': 'Sarah', 'address': {'city': 'Edinburgh'}},
{'name': 'Brian', 'address': {'city': 'London'}},
{'name': 'Mike', 'address': {'city': 'Edinburgh'}},
{'name': 'Diane', 'address': {'city': 'Manchester'}},
{'name': 'Peter', 'a... | code_fim | hard | {
"lang": "python",
"repo": "BedquiltDB/bedquilt-core",
"path": "/test/test_distinct.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bachvtuan/Bing-Linux-Wallpaper path: /service.py
import json, helper, os, sys
import urllib2
#import requests
import subprocess
import time
import urllib
import ntpath
home_site = "http://bing.com"
weekly_wallpapers_url = home_site + "/HPImageArchive.aspx?format=js&idx=0&n=8&mkt=en-US"
def get... | code_fim | hard | {
"lang": "python",
"repo": "bachvtuan/Bing-Linux-Wallpaper",
"path": "/service.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Wallpaper doesn't existing
if os.path.isfile(wallpaper_path) is False or is_force is True:
helper.notify("Downloading " + wallpaper['copyright'] )
#Download to tmp folder first to prevent happend corrupt file while download a wallpaper
#urllib.urlretrieve ( download_u... | code_fim | hard | {
"lang": "python",
"repo": "bachvtuan/Bing-Linux-Wallpaper",
"path": "/service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
wallpaper_files = [ f for f in listdir(wallpapers_folder) if isfile(join(wallpapers_folder,f)) and is_valid(f, date_ranges) ]
count_wallpapers = len(wallpaper_files)
if count_wallpapers > 0:
choose_wallper =wallpaper_files[ randrange( count_wallpapers ) ]
if choose_wallper == c... | code_fim | hard | {
"lang": "python",
"repo": "bachvtuan/Bing-Linux-Wallpaper",
"path": "/service.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'JJ_result', # 形容词
'JJR_result', # 比较级词语
'JJS_result', # 最高级
# 'RB_result', # 副词
'RBR_result', # 副词比较级
# 'RBS_result', # 副词比较级
# 'PDT_result', # 前限定词a
'NN_result', # 名词
# 二元的
'RB_JJ', # 副词 + 形容词
'JJR_NN', # 最高级 + 名词
'JJS_NNPS', # 最高级 + 专有名词复数
... | code_fim | hard | {
"lang": "python",
"repo": "wangqi1996/Essay_Scoring",
"path": "/src/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "vocab_size",
'unique_size',
'PRP_result',
# 'MD_result',
'NNP_result',
# 'COMMA_result',
'JJ_result', # 形容词
'JJR_result', # 比较级词语
'JJS_result', # 最高级
# 'RB_result', # 副词
'RBR_result', # 副词比较级
# 'RBS_result', # 副词比较级
# 'PDT_result', # 前限定词a
... | code_fim | hard | {
"lang": "python",
"repo": "wangqi1996/Essay_Scoring",
"path": "/src/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangqi1996/Essay_Scoring path: /src/config.py
# encoding=utf-8
STANFORDCORENLP_PATH = r'../lib/stanford-corenlp-full-2016-10-31'
TRAIN_DADA_PATH = r'../data/train.pickle'
TEST_DATA_PATH = r'../data/test.pickle'
DEV_DATA_PATH = r'../data/dev.pickle'
"""
把常量字段也定义在这里吧
"""
ESSAY_SET_FIELD = 'ess... | code_fim | hard | {
"lang": "python",
"repo": "wangqi1996/Essay_Scoring",
"path": "/src/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NCATS-Gamma/hermes path: /tests/test_hermes.py
"""Test hermes."""
import asyncio
import copy
import os
import pytest
import redis
from aiohttp import web
from hermes.server import app
from hermes.core import run_job, get_job_id, CACHE_DIR
async def plus(request):
"""Plus request handler."""... | code_fim | hard | {
"lang": "python",
"repo": "NCATS-Gamma/hermes",
"path": "/tests/test_hermes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def test_missing(cli):
"""Test fetching missing result."""
response = await cli.get(f'/result/nope')
assert response.status == 404
async def test_lost(cli):
"""Test fetching lost result."""
test_input = {
'message': {
'value': 0
},
'actions':... | code_fim | hard | {
"lang": "python",
"repo": "NCATS-Gamma/hermes",
"path": "/tests/test_hermes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: josehoras/Advanced-Lane-Finding path: /correct_distorsion.py
import numpy as np
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import glob
import pickle
<|fim_suffix|># Collect all example images by name
images = glob.glob("test_images/*.jpg")
print("IM: ",images)
f... | code_fim | hard | {
"lang": "python",
"repo": "josehoras/Advanced-Lane-Finding",
"path": "/correct_distorsion.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Collect all example images by name
images = glob.glob("test_images/*.jpg")
print("IM: ",images)
for img_name in images:
img = mpimg.imread(img_name)
dst = cv2.undistort(img, mtx, dist, None, mtx)
f, (ax1, ax2) = plt.subplots(2, 1, figsize=(8, 8), sharex=True)
ax1.imshow(img)
ax1.set... | code_fim | hard | {
"lang": "python",
"repo": "josehoras/Advanced-Lane-Finding",
"path": "/correct_distorsion.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kleberandrade/mario-tensorflow path: /mario_bot_tensorflow.py
from pynput.keyboard import Key, Controller
import pynput
import time
import random
import cv2
import pyscreenshot as ImageGrab
import numpy
import pyautogui
import mss
keyboard = Controller()
keys = [
Key.up, ... | code_fim | hard | {
"lang": "python",
"repo": "kleberandrade/mario-tensorflow",
"path": "/mario_bot_tensorflow.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dimension = get_screen_dimension()
print('Screen ', dimension)
while True:
last_time = time.time()
image = capture_screen(dimension)
action()
print("fps: {}".format(1 / (time.time() - last_time)))
if __name__ == '__main__':
main()<|fim_prefix|># repo: kleb... | code_fim | hard | {
"lang": "python",
"repo": "kleberandrade/mario-tensorflow",
"path": "/mario_bot_tensorflow.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: krono-safe/corunners-example path: /scripts/gen-kmem.py
#! /usr/bin/env python3
#
# This script generates the json files for the memory placement. It allows to control the placement of two parts:
# * the task;
# * the co_runners;
#
# Usage:
# python3 gen-kmem.py --config {json config file} --... | code_fim | hard | {
"lang": "python",
"repo": "krono-safe/corunners-example",
"path": "/scripts/gen-kmem.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def find_reg_name():
for reg in kmem['kmemory']['regions']:
addr = reg['physical_address']
if addr <= sec['address'] < addr+reg['size']:
return reg['name']
reg_name = sec['region'] if 'region' in sec else find_reg_name()
... | code_fim | hard | {
"lang": "python",
"repo": "krono-safe/corunners-example",
"path": "/scripts/gen-kmem.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for reg in kmem['kmemory']['regions']:
if 'domains' in reg:
del_dom = []
for dom in reg['domains']:
d = set()
for sec in dom['output_sections']:
if sec['name'] in sec_sat2:
... | code_fim | hard | {
"lang": "python",
"repo": "krono-safe/corunners-example",
"path": "/scripts/gen-kmem.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mayuanyang/doggy path: /src/exportToJson.py
from keras.models import load_model
from keras.preprocessing.image import<|fim_suffix|>np
import os, sys
# Load model 1
model1 = load_model('trained/family/model.hdf5')
with open('model.json', 'w') as f:
f.write(model1.to_json())<|fim_middle|> Imag... | code_fim | medium | {
"lang": "python",
"repo": "mayuanyang/doggy",
"path": "/src/exportToJson.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>np
import os, sys
# Load model 1
model1 = load_model('trained/family/model.hdf5')
with open('model.json', 'w') as f:
f.write(model1.to_json())<|fim_prefix|># repo: mayuanyang/doggy path: /src/exportToJson.py
from keras.models import load_model
from keras.preprocessing.image import<|fim_middle|> Imag... | code_fim | medium | {
"lang": "python",
"repo": "mayuanyang/doggy",
"path": "/src/exportToJson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> driver = self.driver
for i in range(0, 3):
ps = driver.find_elements_by_tag_name('p1')
print(ps)
teste01 = JogarOJogo()
teste01.entrarNaPagina()
teste01.coletarNumero()
teste01.clicar()<|fim_prefix|># repo: JhonataAugust0/Python path: /Areas/Automacao/Sele... | code_fim | hard | {
"lang": "python",
"repo": "JhonataAugust0/Python",
"path": "/Areas/Automacao/Selenium/Exercícios/Jogar_o_Jogo/JogarOJogo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.driver = webdriver.Chrome(executable_path="/run/media/jhonata/_home/Programação/Python/Selenium/chromedriver")
def entrarNaPagina(self):
driver = self.driver
driver.get('https://curso-python-selenium.netlify.app/exercicio_02.html#')
time.sleep(2)
def clica... | code_fim | medium | {
"lang": "python",
"repo": "JhonataAugust0/Python",
"path": "/Areas/Automacao/Selenium/Exercícios/Jogar_o_Jogo/JogarOJogo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JhonataAugust0/Python path: /Areas/Automacao/Selenium/Exercícios/Jogar_o_Jogo/JogarOJogo.py
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
class JogarOJogo:
def __init__(self):
self.driver = webdriver.Chrome(executable_path="/run/media/j... | code_fim | hard | {
"lang": "python",
"repo": "JhonataAugust0/Python",
"path": "/Areas/Automacao/Selenium/Exercícios/Jogar_o_Jogo/JogarOJogo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rmusmanno/ofx2xlsmbr path: /ofx2xlsmbr/reader/xml/XMLReaderController.py
from ofx2xlsmbr.reader.IReaderController import IReaderController
from ofx2xlsmbr.model.BankStatement import BankStatement
<|fim_suffix|> data = ''
tree = None
options = {}
if (files):
... | code_fim | hard | {
"lang": "python",
"repo": "rmusmanno/ofx2xlsmbr",
"path": "/ofx2xlsmbr/reader/xml/XMLReaderController.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>import logging
logger = logging.getLogger(__name__)
# XML Reader Controller esta acoplado demais ao OFX Reader Controller, por isso so recebe uma lista
# com um objeto
class XMLReaderController(IReaderController):
def read(self, factory, files=[]) -> List[BankStatement]:
data = ''
tr... | code_fim | medium | {
"lang": "python",
"repo": "rmusmanno/ofx2xlsmbr",
"path": "/ofx2xlsmbr/reader/xml/XMLReaderController.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bsReader = factory.createReaderBankStatement()
return [bsReader.read(factory, tree, options)]
def readFile(self, file):
data = str(file.read())
data = data[data.find('<OFX>'):]
return data<|fim_prefix|># repo: rmusmanno/ofx2xlsmbr path: /ofx2xlsmbr/reader/xml/... | code_fim | hard | {
"lang": "python",
"repo": "rmusmanno/ofx2xlsmbr",
"path": "/ofx2xlsmbr/reader/xml/XMLReaderController.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sandmann83/py2scala path: /py2scala/test/funval.py
'''
In scala, function f as a value is written f _.
`from functools import partial as pf_` lets us use pf_(f) to signal this usage.
'''
from functools import partial as pf_
def adder(x):
''':type x: Int'''
def add(y):
''':typ... | code_fim | medium | {
"lang": "python",
"repo": "sandmann83/py2scala",
"path": "/py2scala/test/funval.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
:type x: Int
:rtype: Int => Int
'''
return lambda y: x * y
def bool_default(x=True):
# TODO: not not x
return not x
DEFAULT = 1
def name_default(x=DEFAULT):
''':type x: Int'''
return x + 1
def circle_area(r, pi=3.14159):
''':type r: Double'''
# TODO:... | code_fim | medium | {
"lang": "python",
"repo": "sandmann83/py2scala",
"path": "/py2scala/test/funval.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def genTerrain(this):
x = 0
z = 0
# ***
x = this.swirlEngine.pos.x
z = this.swirlEngine.pos.y
d = int(this.subWidth*0.5)
for k in range(-d,d):
for j in range(-d,d):
y = floor(this.perlin.getHeight(x+k,z+j))
... | code_fim | hard | {
"lang": "python",
"repo": "Veenion/ursina_tutorials",
"path": "/python_meshCraft_tut_2021/old code/prep_mesh_terrain.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> y = floor(this.perlin.getHeight(x+k,z+j))
# ***
if this.td.get( "x"+str(floor(x+k))+
"y"+str(floor(y))+
"z"+str(floor(z+j)))==None:
this.genBlock(x+k,y,z+j)
... | code_fim | hard | {
"lang": "python",
"repo": "Veenion/ursina_tutorials",
"path": "/python_meshCraft_tut_2021/old code/prep_mesh_terrain.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Veenion/ursina_tutorials path: /python_meshCraft_tut_2021/old code/prep_mesh_terrain.py
from perlin import Perlin
from ursina import *
from random import random
# ***
from swirl import SwirlEngine
class MeshTerrain:
def __init__(this):
this.block = load_model('block.obj')
... | code_fim | hard | {
"lang": "python",
"repo": "Veenion/ursina_tutorials",
"path": "/python_meshCraft_tut_2021/old code/prep_mesh_terrain.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: angelicaurba/ai_ml_siren_sr path: /resize_img.py
from PIL import Image
from os import listdir
from os.path import isfile, join
<|fim_suffix|>for file in only_files:
print(file)
img = Image.open(join(IMAGES_DIR, file))
if img.size[0] % 2 == 0 and img.size[1] % 2 == 0:
print(fi... | code_fim | hard | {
"lang": "python",
"repo": "angelicaurba/ai_ml_siren_sr",
"path": "/resize_img.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for file in only_files:
print(file)
img = Image.open(join(IMAGES_DIR, file))
if img.size[0] % 2 == 0 and img.size[1] % 2 == 0:
print(file)
img = img.resize((int(img.size[0]/2), int(img.size[1]/2)), Image.ANTIALIAS)
img.save(join(IMAGES_DEST_DIR, file))<|fim_prefix|># re... | code_fim | hard | {
"lang": "python",
"repo": "angelicaurba/ai_ml_siren_sr",
"path": "/resize_img.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> del self.__dict__[key]
def __iter__(self):
return iter(self.__dict__)
def __len__(self):
return len(self.__dict__)
@retry(retry_on_exception=retry_if_Index_Exception, stop_max_attempt_number=10)
def _import_pkg(self, package, package_config):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "MD-Studio/MDStudio_structures",
"path": "/mdstudio_structures/cheminfo_pkgmanager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MD-Studio/MDStudio_structures path: /mdstudio_structures/cheminfo_pkgmanager.py
# -*- coding: utf-8 -*-
from __future__ import print_function
"""
file: cheminfo_pkgmanager.py
Manage import of Cinfony supported cheminformatics software packages.
Currently supports the following 9 packages:
*... | code_fim | hard | {
"lang": "python",
"repo": "MD-Studio/MDStudio_structures",
"path": "/mdstudio_structures/cheminfo_pkgmanager.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Import packages by name or path and register in self.
Log relevant import errors
:param package: package name
:type package: :py:str
:param package_config: package specific configuration
:type package_config: :py:dict
"""... | code_fim | hard | {
"lang": "python",
"repo": "MD-Studio/MDStudio_structures",
"path": "/mdstudio_structures/cheminfo_pkgmanager.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sshobham/textclassification path: /train.py
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 05 15:49:12 2020
@author: shobham
"""
import pandas as pd
import spacy
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.svm import LinearSVC
from sklearn.pi... | code_fim | hard | {
"lang": "python",
"repo": "sshobham/textclassification",
"path": "/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__=="__main__":
train_classification_model=train_classification_model()
train_df, test_df, classes_df = train_classification_model.load_data()
train_df[1] = train_df[1].apply(lambda x : train_classification_model.clean_data(x))
test_df[1] = test_df[1].apply(lambda x : train_cl... | code_fim | hard | {
"lang": "python",
"repo": "sshobham/textclassification",
"path": "/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def generate_avg_vector(self, data):
"""Generate Mean Vector using spacy word vectors"""
doc=nlp(data)
data_vector = [token.vector for token in doc]
mean_vector = np.mean(data_vector, axis=0)
return mean_vector
def get_split_dat... | code_fim | hard | {
"lang": "python",
"repo": "sshobham/textclassification",
"path": "/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> image_patches = []
for box in boxes:
patch = extract_image_patch(image, box, image_shape[:2])
if patch is None:
print("WARNING: Failed to extract image patch: %s." % str(box))
patch = np.random.uniform(
0., 255., i... | code_fim | hard | {
"lang": "python",
"repo": "HaojieSHI98/PaddleRobotics",
"path": "/HRI/TFVT_HRI/perception/tracker/re_id.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HaojieSHI98/PaddleRobotics path: /HRI/TFVT_HRI/perception/tracker/re_id.py
# See github: nwojke/deep_sort
import numpy as np
import tensorflow as tf
from perception.tracker.utils import extract_image_patch
def _run_in_batches(f, data_dict, out, batch_size):
data_len = len(out)
num_batc... | code_fim | hard | {
"lang": "python",
"repo": "HaojieSHI98/PaddleRobotics",
"path": "/HRI/TFVT_HRI/perception/tracker/re_id.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matthewgdv/iotools path: /iotools/command/argparser.py
from __future__ import annotations
import argparse
from typing import Any, Callable, TYPE_CHECKING
import tabulate
if TYPE_CHECKING:
from .declarative import CommandHandler
from .argument import Argument
class ArgParser(argparse.... | code_fim | hard | {
"lang": "python",
"repo": "matthewgdv/iotools",
"path": "/iotools/command/argparser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.add_argument("_", nargs="?")
for arg in self.handler.arguments:
self.add_argument(*arg.aliases, default=arg.default, type=self.validate_and_set(arg), choices=arg.choices, required=arg.required, nargs="?" if arg.nullable else None, help=arg.info, dest=arg.name)
def for... | code_fim | hard | {
"lang": "python",
"repo": "matthewgdv/iotools",
"path": "/iotools/command/argparser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> global __plugin_implementation__
__plugin_implementation__ = OctoflatPlugin()
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.plugin.softwareupdate.check_config": __plugin_implementation__.get_update_information
}<|fim_prefix|># repo: josephgeis/OctoPrint-OctoFlat pat... | code_fim | hard | {
"lang": "python",
"repo": "josephgeis/OctoPrint-OctoFlat",
"path": "/octoprint_octoflat/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: josephgeis/OctoPrint-OctoFlat path: /octoprint_octoflat/__init__.py
# coding=utf-8
from __future__ import absolute_import, unicode_literals
# (Don't forget to remove me)
# This is a basic skeleton for your plugin's __init__.py. You probably want to adjust the class name of your plugin
# as well ... | code_fim | medium | {
"lang": "python",
"repo": "josephgeis/OctoPrint-OctoFlat",
"path": "/octoprint_octoflat/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # version check: github repository
type="github_release",
user="juniorRubyist",
repo="OctoPrint-OctoFlat",
current=self._plugin_version,
# update method: pip
pip="https://github.com/juniorRubyi... | code_fim | hard | {
"lang": "python",
"repo": "josephgeis/OctoPrint-OctoFlat",
"path": "/octoprint_octoflat/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ScottAI/doudizhu path: /core/table.py
import logging
import random
from typing import List
from tornado.ioloop import IOLoop
from core.robot import AiPlayer, Player
from handlers.protocol import Protocol as Pt
class Table(object):
WAITING = 0
PLAYING = 1
END = 2
CLOSED = 3
... | code_fim | hard | {
"lang": "python",
"repo": "ScottAI/doudizhu",
"path": "/core/table.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def on_game_over(self, winner):
# if winner.hand_pokers:
# return
coin = self.room.entrance_fee * self.call_score * self.multiple
for p in self.players:
response = [Pt.RSP_GAME_OVER, winner.uid, coin if p != winner else coin * 2 - 100]
for pp... | code_fim | hard | {
"lang": "python",
"repo": "ScottAI/doudizhu",
"path": "/core/table.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_list1():
input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
input_me = Tensor(input_np)
net = Net1([1])
_executor.compile(net, input_me)
def test_list2():
input_np = np.random.randn(2, 3, 4, 5).astype(np.float32)
input_me = Tensor(input_np)
net = Net1([1, 2])
... | code_fim | medium | {
"lang": "python",
"repo": "ythlml/mindspore",
"path": "/tests/ut/python/pipeline/parse/test_list.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ythlml/mindspore path: /tests/ut/python/pipeline/parse/test_list.py
# Copyright 2020 Huawei Technologies Co., Ltd
#
# 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
#
# ht... | code_fim | medium | {
"lang": "python",
"repo": "ythlml/mindspore",
"path": "/tests/ut/python/pipeline/parse/test_list.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>httpd = wsgiref.simple_server.make_server('localhost', args.port, app)
print 'ready to serve on port %d' % args.port
try:
if args.serve_forever:
httpd.serve_forever()
httpd.handle_request()
except KeyboardInterrupt:
print 'caught ctl-c'
sys.exit(0)
# eof<|fim_prefix|># repo: chaselg... | code_fim | hard | {
"lang": "python",
"repo": "chaselgrove/dpf",
"path": "/dpf_data_server",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>parser.add_argument('--config', '-c',
help='the config file')
parser.add_argument('--handler', '-H',
action='append',
dest='handlers',
help='a data handler (may be specified more than once)')
parser.add_argument('--cache',... | code_fim | hard | {
"lang": "python",
"repo": "chaselgrove/dpf",
"path": "/dpf_data_server",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chaselgrove/dpf path: /dpf_data_server
#!/usr/bin/python
# See file COPYING distributed with dpf for copyright and license.
import sys
import os
import argparse
import ConfigParser
import importlib
import wsgiref.simple_server
import dpf.data
description = """Start a data server."""
progname ... | code_fim | hard | {
"lang": "python",
"repo": "chaselgrove/dpf",
"path": "/dpf_data_server",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class I18nField(Field):
def __init__(self, **kwargs):
self.allow_blank = kwargs.pop('allow_blank', False)
self.trim_whitespace = kwargs.pop('trim_whitespace', True)
self.max_length = kwargs.pop('max_length', None)
self.min_length = kwargs.pop('min_length', None)
... | code_fim | hard | {
"lang": "python",
"repo": "raphaelm/django-i18nfield",
"path": "/i18nfield/rest_framework.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: raphaelm/django-i18nfield path: /i18nfield/rest_framework.py
from django.conf import settings
from .fields import I18nCharField, I18nTextField
from .strings import LazyI18nString
try:
from rest_framework.exceptions import ValidationError
from rest_framework.fields import Field
from ... | code_fim | hard | {
"lang": "python",
"repo": "raphaelm/django-i18nfield",
"path": "/i18nfield/rest_framework.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, **kwargs):
self.allow_blank = kwargs.pop('allow_blank', False)
self.trim_whitespace = kwargs.pop('trim_whitespace', True)
self.max_length = kwargs.pop('max_length', None)
self.min_length = kwargs.pop('min_length', None)
super().__init__(**kwar... | code_fim | medium | {
"lang": "python",
"repo": "raphaelm/django-i18nfield",
"path": "/i18nfield/rest_framework.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: oboforty/ricochat path: /server_proto/voiceserver.py
import secrets
import socketserver
ENCODING = 'ascii'
class VoiceServer(socketserver.UDPServer):
allow_reuse_address = True
max_packet_size = 8192
def __init__(self, bundle, server_address):
self.bundle = bundle
... | code_fim | hard | {
"lang": "python",
"repo": "oboforty/ricochat",
"path": "/server_proto/voiceserver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.echo_server:
msg = self.wrap_msg(packet, client['vcid'])
socket.sendto(msg, client_address)
else:
# spread voice data
self.send_channel(client['channel'], client['vcid'], packet)
def wrap_msg(self, msg, vc... | code_fim | hard | {
"lang": "python",
"repo": "oboforty/ricochat",
"path": "/server_proto/voiceserver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gnokem/ML path: /svm3.py
import os, sys;
from sklearn import svm;
import numpy as np, pandas as pd;
import csv, random;
seed=13
np.random.seed(seed);
random.seed(seed);
def isNum(s):
digits=[str(i) for i in range(0,10)]+['.'];
for i in s:
if i not in digits: return False;
if ... | code_fim | hard | {
"lang": "python",
"repo": "gnokem/ML",
"path": "/svm3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>clf_list=[];
errs=[];
num_models=1
for m in range(num_models):
k=random.random();
typ="linear";
clf_list+=[svm.SVR(kernel="linear")];
x,y=sample_and_split(tr_set,60000);
clf_list[-1].fit(x,y);
print m,typ,;
sys.stdout.flush();
p=[];
for i in te_set_x:
p+=[clf_list[-1].predict([i]... | code_fim | hard | {
"lang": "python",
"repo": "gnokem/ML",
"path": "/svm3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> featuretype = models.ForeignKey(FeatureType)
minx = models.CharField(max_length=254)
miny = models.CharField(max_length=254)
maxx = models.CharField(max_length=254)
maxy = models.CharField(max_length=254)
def __str__(self):
return "((" + self.minx + ", ", self.miny + "), (... | code_fim | hard | {
"lang": "python",
"repo": "VForWaTer/django-wfs",
"path": "/wfs/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VForWaTer/django-wfs path: /wfs/models.py
from django.db import models
from django.core.urlresolvers import reverse
from django.contrib.sites.models import Site
from django.contrib.contenttypes.models import ContentType
class Service(models.Model):
name = models.CharField(max_length=254)
... | code_fim | hard | {
"lang": "python",
"repo": "VForWaTer/django-wfs",
"path": "/wfs/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_user(self, user_id):
try:
return ForumUser.objects.get(pk=user_id)
except ForumUser.DoesNotExist:
return None<|fim_prefix|># repo: ankesh100/forum path: /forum/backends.py
# coding: utf-8
from django.contrib.auth.backends import ModelBackend # 继承这个为了使用... | code_fim | hard | {
"lang": "python",
"repo": "ankesh100/forum",
"path": "/forum/backends.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ankesh100/forum path: /forum/backends.py
# coding: utf-8
from django.contrib.auth.backends import ModelBackend # 继承这个为了使用admin的权限控制
from forum.models import ForumUser
<|fim_suffix|>
def authenticate(self, username=None, password=None):
try:
user = ForumUser.objects.get(e... | code_fim | medium | {
"lang": "python",
"repo": "ankesh100/forum",
"path": "/forum/backends.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>metric_bar_joint import ParametricBarJoint
from .wheel import *
from .cardan import *
from .active_cardan import *
from .active_rotator import *
from .active_wheel import *
from .active_wheg import *
__author__ = 'Elte Hupkes'<|fim_prefix|># repo: ElteHupkes/revolve path: /revolve/angle/robogen/body_par... | code_fim | medium | {
"lang": "python",
"repo": "ElteHupkes/revolve",
"path": "/revolve/angle/robogen/body_parts/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ElteHupkes/revolve path: /revolve/angle/robogen/body_parts/__init__.py
from .active_hinge import ActiveHinge
from .core_component import CoreComponent
from .hinge import Hinge
from .li<|fim_suffix|>*
from .active_rotator import *
from .active_wheel import *
from .active_wheg import *
__author__ ... | code_fim | hard | {
"lang": "python",
"repo": "ElteHupkes/revolve",
"path": "/revolve/angle/robogen/body_parts/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>decompiler = EveScriptDecompiler()
decompiled_script = decompiler.decompile(compiled_script)
print(decompiled_script)<|fim_prefix|># repo: charlee/evescript path: /example/decompiler_example.py
import os
import sys
cwd = os.path.dirname(__file__)
try:
from evescript.compiler import EveScriptCompil... | code_fim | medium | {
"lang": "python",
"repo": "charlee/evescript",
"path": "/example/decompiler_example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>compiler = EveScriptCompiler()
compiled_script = compiler.compile(script)
decompiler = EveScriptDecompiler()
decompiled_script = decompiler.decompile(compiled_script)
print(decompiled_script)<|fim_prefix|># repo: charlee/evescript path: /example/decompiler_example.py
import os
import sys
cwd = os.path... | code_fim | medium | {
"lang": "python",
"repo": "charlee/evescript",
"path": "/example/decompiler_example.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: charlee/evescript path: /example/decompiler_example.py
import os
import sys
cwd = os.path.dirname(__file__)
try:
from evescript.compiler import EveScriptCompiler
from evescript.decompiler import EveScriptDecompiler
except ModuleNotFoundError:
sys.path.append(os.path.normpath(os.path... | code_fim | medium | {
"lang": "python",
"repo": "charlee/evescript",
"path": "/example/decompiler_example.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def alias_out_port(from_tuple, to_tuple):
""" Alias out-ports of two units
Args:
from_tuple (tuple<Unit, str>): Unit and port id to alias from.
to_tuple (tuple<Unit, str>): Unit and port id to alias to.
Returns:
None.
"""
from_unit, from_port = from_tuple
to_... | code_fim | hard | {
"lang": "python",
"repo": "wbap/BriCA1",
"path": "/brica1/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def alias_out_port(from_tuple, to_tuple):
""" Alias out-ports of two units
Args:
from_tuple (tuple<Unit, str>): Unit and port id to alias from.
to_tuple (tuple<Unit, str>): Unit and port id to alias to.
Returns:
None.
"""
from_unit, from_port = from_tuple
to_u... | code_fim | hard | {
"lang": "python",
"repo": "wbap/BriCA1",
"path": "/brica1/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wbap/BriCA1 path: /brica1/utils.py
# -*- coding: utf-8 -*-
"""
utils.py
=====
This modules contains utility functions for BriCA.
"""
import time
__all__ = ["current_time", "current_time_millis", "connect", "alias_in_port",
"alias_out_port"]
def current_time():
return time.ti... | code_fim | medium | {
"lang": "python",
"repo": "wbap/BriCA1",
"path": "/brica1/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kpow-jp/zardoz path: /zardoz/zardoz.py
import dice
import discord
from discord.ext import commands
import argparse
import json
import os
from pathlib import Path
import sys
import textwrap
from .logging import setup as setup_logger
from . import __version__, __splash__, __about__, __testing__... | code_fim | hard | {
"lang": "python",
"repo": "kpow-jp/zardoz",
"path": "/zardoz/zardoz.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def main():
parser = argparse.ArgumentParser(
description=f'{__splash__}\n{__about__}',
formatter_class=CustomFormatter
)
parser.add_argument(
'--secret-token',
help='The secret token for the bot, '\
'from the discord developer portal. '\
... | code_fim | hard | {
"lang": "python",
"repo": "kpow-jp/zardoz",
"path": "/zardoz/zardoz.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bazzile/helper path: /my_ellipsoidal_area.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##Ellipsoidal Area=name
##Utils=group
##input=vector polygon
##ellipsoid=string WGS84
##new_field=string Area
##units=selection sq_km;sq_m;sq_miles;sq_ft;sq_nm;sq_degrees
##output=output vector
import proc... | code_fim | hard | {
"lang": "python",
"repo": "bazzile/helper",
"path": "/my_ellipsoidal_area.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # calculated area is in sq. metres (see the "else" case)
# TODO убрать лишние единицы
if units == u'км2':
final_area = polygon_area / 1e6
# elif units == 'sq_ft':
# final_area = area.convertMeasurement(
# polygon_area, QGis.Meters, QG... | code_fim | hard | {
"lang": "python",
"repo": "bazzile/helper",
"path": "/my_ellipsoidal_area.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: blackzilla2126/twine path: /tests/conftest.py
import getpass
import textwrap
import pytest
from twine import settings
@pytest.fixture()
def pypirc(tmpdir):
return tmpdir / ".pypirc"
@pytest.fixture()
def make_settings(pypirc):
"""Return a factory function for settings.Settings with ... | code_fim | medium | {
"lang": "python",
"repo": "blackzilla2126/twine",
"path": "/tests/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture
def entered_password(monkeypatch):
monkeypatch.setattr(getpass, "getpass", lambda prompt: "entered pw")<|fim_prefix|># repo: blackzilla2126/twine path: /tests/conftest.py
import getpass
import textwrap
import pytest
from twine import settings
@pytest.fixture()
def pypirc(tmpdir):
... | code_fim | hard | {
"lang": "python",
"repo": "blackzilla2126/twine",
"path": "/tests/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for directory in directories:
assert host.file(f'{working_dir}/{directory}').is_directory<|fim_prefix|># repo: ccronca/dotfiles path: /base/molecule/default/tests/test_packages.py
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(... | code_fim | hard | {
"lang": "python",
"repo": "ccronca/dotfiles",
"path": "/base/molecule/default/tests/test_packages.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ccronca/dotfiles path: /base/molecule/default/tests/test_packages.py
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
os.environ['MOLECULE_INVENTORY_FILE']).get_hosts('all')
<|fim_suffix|> for f in bin_files:
assert ... | code_fim | hard | {
"lang": "python",
"repo": "ccronca/dotfiles",
"path": "/base/molecule/default/tests/test_packages.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for f in bin_files:
assert host.file(f'/usr/bin/{f}').is_file
def test_base_directories_exists(host):
working_dir = host.run('cd && pwd').stdout
directories = ["projects", "bin"]
for directory in directories:
assert host.file(f'{working_dir}/{directory}').is_directory<|f... | code_fim | medium | {
"lang": "python",
"repo": "ccronca/dotfiles",
"path": "/base/molecule/default/tests/test_packages.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>print Solution().myPow(2, 3)
print Solution().myPow(34.00515, -3)<|fim_prefix|># repo: ChuanleiGuo/AlgorithmsPlayground path: /LeetCodeSolutions/python/50_Pow(x, n).py
class Solution(object):
def myPow(self, x, n):
<|fim_middle|> """
:type x: float
:type n: int
:rtype: ... | code_fim | hard | {
"lang": "python",
"repo": "ChuanleiGuo/AlgorithmsPlayground",
"path": "/LeetCodeSolutions/python/50_Pow(x, n).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChuanleiGuo/AlgorithmsPlayground path: /LeetCodeSolutions/python/50_Pow(x, n).py
class Solution(object):
def myPow(self, x, n):
<|fim_suffix|>print Solution().myPow(2, 3)
print Solution().myPow(34.00515, -3)<|fim_middle|> """
:type x: float
:type n: int
:rtype: ... | code_fim | hard | {
"lang": "python",
"repo": "ChuanleiGuo/AlgorithmsPlayground",
"path": "/LeetCodeSolutions/python/50_Pow(x, n).py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Without this, an error occurs for the unit tests
except SystemExit as inst:
if inst.args[0] is True:
raise
#end
"""
TODO:
1.) verifyOptimum?
2.) baseStar path compression or not?
3.) IPython Notebook
"""<|fim_prefix|># repo: AlexanderSoloviev/mv-matching ... | code_fim | hard | {
"lang": "python",
"repo": "AlexanderSoloviev/mv-matching",
"path": "/test/test_driver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AlexanderSoloviev/mv-matching path: /test/test_driver.py
#!/usr/bin/env python
"""
Driver module for all unit testing.
This module generates the suites for all of the test classes and runs
the entire set of tests in the /test directory.
:filename test_driver.py
"""
# Necessary impo... | code_fim | medium | {
"lang": "python",
"repo": "AlexanderSoloviev/mv-matching",
"path": "/test/test_driver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Run the unit tests from all testing modules and display their name information
try:
matchingSimpleSuite = test_matching_simple.suiteFull()
matchingCompoundSuite = test_matching_compound.suiteFull()
matchingRandomSuite = test_matching_random.suiteCase()
full... | code_fim | medium | {
"lang": "python",
"repo": "AlexanderSoloviev/mv-matching",
"path": "/test/test_driver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> global host
global port
if IP == None:
modules.pfsense.print_logs(host, port)
else:
modules.pfsense.print_logs(host, port, IP)<|fim_prefix|># repo: M507/CellTower path: /Utilities.py
from config import *
# import modules
import modules.pfsense
<|fim_middle|>
def Print_pf... | code_fim | easy | {
"lang": "python",
"repo": "M507/CellTower",
"path": "/Utilities.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: M507/CellTower path: /Utilities.py
from config import *
# import modules
import modules.pfsense
<|fim_suffix|> global host
global port
if IP == None:
modules.pfsense.print_logs(host, port)
else:
modules.pfsense.print_logs(host, port, IP)<|fim_middle|>def Print_pf... | code_fim | easy | {
"lang": "python",
"repo": "M507/CellTower",
"path": "/Utilities.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if salarioc < salarios:
print('\nPARABÉNS, seu financiamento foi provado.\nA casa no valor de R${:.2f} reais,\nserá financiado em {} meses,com parcelas de R${:.2f} reais ' .format(casa, ano*12, salarioc))
else:
print('\nFINANCIAMENTO NEGADO, no momento não foi possível financiar seu imóvel')<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "JonasAraujoP/Python",
"path": "/desafios/desafio36.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JonasAraujoP/Python path: /desafios/desafio36.py
"""DESAFIO 36"""
casa = float(input('Qual o valor do imóvel desejado? R$'))
salario = float(input('Qual o valor do seu salário? R$'))
ano = int(input('Em quantos anos deseja financiar a casa? '))
<|fim_suffix|>if salarioc < salarios:
print('\n... | code_fim | medium | {
"lang": "python",
"repo": "JonasAraujoP/Python",
"path": "/desafios/desafio36.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rmcgibbo/asv path: /asv/plugins/conda.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, unicode_literals, print_function
import os
import tempfile
import subprocess
import six
from .. import environment... | code_fim | hard | {
"lang": "python",
"repo": "rmcgibbo/asv",
"path": "/asv/plugins/conda.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if util.WIN:
if not os.path.isfile(os.path.join(self._path, 'python.exe')):
return False
else:
if not os.path.isfile(os.path.join(self._path, 'bin', 'python')):
return False
try:
self._run_executable('python', ['-... | code_fim | hard | {
"lang": "python",
"repo": "rmcgibbo/asv",
"path": "/asv/plugins/conda.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> build_bz2 = self._cache.build_project_cached(
self, conf, commit_hash)
if build_bz2 is None:
build_bz2 = self.build_project(commit_hash)
self.install(build_bz2)
def _setup(self):
try:
conda = util.which('conda')
except IOErr... | code_fim | hard | {
"lang": "python",
"repo": "rmcgibbo/asv",
"path": "/asv/plugins/conda.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sprockets/sprockets-dynamodb path: /tests/api_tests.py
if index['IndexStatus'] != dynamodb.TABLE_ACTIVE:
return False
return True
class AsyncItemTestCase(AsyncTestCase):
def setUp(self):
self.definition = self.generic_table_definition()
return ... | code_fim | hard | {
"lang": "python",
"repo": "sprockets/sprockets-dynamodb",
"path": "/tests/api_tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> response = yield self.get_item(item['id'])
self.assertEqual(response['Item']['id'], item['id'])
self.assertEqual(response['Item']['update_check'],
item['update_check'])
update_check = str(uuid.uuid4())
response = yield self.client.update_i... | code_fim | hard | {
"lang": "python",
"repo": "sprockets/sprockets-dynamodb",
"path": "/tests/api_tests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sprockets/sprockets-dynamodb path: /tests/api_tests.py
_metrics='SIZE',
return_values='ALL_OLD')
def get_item(self, item_id):
return self.client.get_item(self.definition['TableName'],
{'id': item_id})
def... | code_fim | hard | {
"lang": "python",
"repo": "sprockets/sprockets-dynamodb",
"path": "/tests/api_tests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> os.chdir(workingDirectory)
iteration = 0
goal_samples = 0
root = xml.etree.ElementTree.parse(duplexsavefile).getroot()
pareto = []
variableSize=7
for p in root.findall('./data/node'):
if(goal_samples<500):
iteration += 1
candid = False
... | code_fim | hard | {
"lang": "python",
"repo": "ahmadyan/Duplex",
"path": "/test/yield.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ahmadyan/Duplex path: /test/yield.py
import os
import subprocess
import platform
import xml.etree.ElementTree
import time
global workingDirectory
global duplexCommand
global configfile
global matlabfile
def isWithinTheGoalRegion(objectives):
isOptimalState = True
if (objectives[0] < 4e9... | code_fim | hard | {
"lang": "python",
"repo": "ahmadyan/Duplex",
"path": "/test/yield.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># This function draw a row of blocks based on user value
def draw_block_row(num_blocks):
for i in range(num_blocks):
circle(radius)
penup()
forward(50)
pendown()
# Set row value to 0
speed(5)
#Current row and offset defined
row_value = 0
o = 25
#moving to the sta... | code_fim | hard | {
"lang": "python",
"repo": "lukeyzan/CodeHS-Python",
"path": "/CirclePyramid2.0.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lukeyzan/CodeHS-Python path: /CirclePyramid2.0.py
"""
# This code will ask the user how many blocks they want on the bottom of the pyramid
# and then draw a pyramid of squares, subtracting one block from each row.
"""
'''
# This function moves to next row with x-value based on how many blocks ar... | code_fim | medium | {
"lang": "python",
"repo": "lukeyzan/CodeHS-Python",
"path": "/CirclePyramid2.0.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def trim_spaces_and_tabs_from_lines_in_txt(txt: str) -> str:
""" This function will remove leading spaces and tabs from lines of text.
:param txt: a str containing the text to be cleaned up.
:return: a str containing text with all of the leading spaces removed from each line.
"""
cl... | code_fim | hard | {
"lang": "python",
"repo": "jaredpeterson/pyhandy",
"path": "/pyhandy/txt_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # convert the text string into a buffer so that we can read lines.
txt_buffer = io.StringIO(txt)
# iterate through each line trimming whitespace.
next_line = txt_buffer.readline()
while next_line:
stripped_next_line = next_line.lstrip(' \t') # just want spaces and tabs.
... | code_fim | hard | {
"lang": "python",
"repo": "jaredpeterson/pyhandy",
"path": "/pyhandy/txt_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.