text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: kimbring2/MOBA_RL path: /dota2/run.py
NIGHT, control_mode=modes[1]),
HeroPick(team_id=TEAM_DIRE, hero_id=NPC_DOTA_HERO_SNIPER, control_mode=HERO_CONTROL_MODE_IDLE),
HeroPick(team_id=TEAM_DIRE, hero_id=NPC_DOTA_HERO_SNIPER, control_mode=HERO_CONTROL_MODE_IDLE),
HeroPick(tea... | code_fim | hard | {
"lang": "python",
"repo": "kimbring2/MOBA_RL",
"path": "/dota2/run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kimbring2/MOBA_RL path: /dota2/run.py
que_omniknight_7",
'''
omniknight_ability_route = [
'omniknight_purification', 'omniknight_repel', 'omniknight_purification', 'omniknight_degen_aura',
'omniknight_repel', 'omniknight_guardian_angel', 'omniknight_purification', 'omniknight_dege... | code_fim | hard | {
"lang": "python",
"repo": "kimbring2/MOBA_RL",
"path": "/dota2/run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if hero_unit2 != None:
gold2 = hero_unit2.unreliable_gold + hero_unit2.reliable_gold
mana2 = hero_unit2.mana
location2 = hero_unit2.location
action_pb_item_and_ability1 = None
action_pb_item_and_ability2 = None
if int(dota_time) % 140 == 0 and dota_time >= 0:
if t... | code_fim | hard | {
"lang": "python",
"repo": "kimbring2/MOBA_RL",
"path": "/dota2/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret, frame = cap.read()
x = cv.cvtColor(frame,cv.COLOR_BGR2GRAY)
h,b = np.histogram(x, bins=256, range=(0,256))
# ajustamos la escala del histograma para que se vea bien en la imagen
kk = np.array([2*b[1:], 480-h*(480/10000)]).T.astype(int)
cv.polylines(x, [kk], isCl... | code_fim | medium | {
"lang": "python",
"repo": "anyelgarcia/umucv",
"path": "/code/histogram.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anyelgarcia/umucv path: /code/histogram.py
#!/usr/bin/env python
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt
cap = cv.VideoCapture(0)
<|fim_suffix|> # ajustamos la escala del histograma para que se vea bien en la imagen
kk = np.array([2*b[1:], 480-h*(480/10000)])... | code_fim | medium | {
"lang": "python",
"repo": "anyelgarcia/umucv",
"path": "/code/histogram.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wuzhenjiexd/steam-friends-status path: /steamquery/steam.py
#!/usr/bin/python
""" SteamQuery class. This screen scrapes the Steam Community website for in-game and
online players.
This part of Steam Friends Status is given under the WTFPL license
"""
import urllib2, socket, re
f... | code_fim | hard | {
"lang": "python",
"repo": "wuzhenjiexd/steam-friends-status",
"path": "/steamquery/steam.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for (element, attr, link, pos) in i.iterlinks():
s = cre.search(link)
if s:
f['server'] = s.group(1)
if 'server' not in f:
f['server'] = 'No server'
if game:
g = re.sub('\s-\sJoin', '', ... | code_fim | hard | {
"lang": "python",
"repo": "wuzhenjiexd/steam-friends-status",
"path": "/steamquery/steam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Try to guess whether the user gave us a:
* Steam Community ID URL (which has a custom URL appended to it)
* Steam Community Profile ID URL (with a bunch of numbers following)
* Their custom URL name
"""
if re.match(r'http://.*steamcommunity... | code_fim | hard | {
"lang": "python",
"repo": "wuzhenjiexd/steam-friends-status",
"path": "/steamquery/steam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(f'Extracting the archive in {directory_to_extract_to}...', end=' ')
with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:
zip_ref.extractall(directory_to_extract_to)
print('Done!')<|fim_prefix|># repo: nikolasjdawson/mapping-career-causeways path: /supplementary_online_data/ONET_ESCO_crosswal... | code_fim | hard | {
"lang": "python",
"repo": "nikolasjdawson/mapping-career-causeways",
"path": "/supplementary_online_data/ONET_ESCO_crosswalk/download_outputs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nikolasjdawson/mapping-career-causeways path: /supplementary_online_data/ONET_ESCO_crosswalk/download_outputs.py
import urllib.request
import os
import zipfile
fpath = ''
path_to_zip_file = fpath + 'outputs.zip'
directory_to_extract_to = 'outputs/'
if os.path.exists(directory_to_extract_to)==Fal... | code_fim | hard | {
"lang": "python",
"repo": "nikolasjdawson/mapping-career-causeways",
"path": "/supplementary_online_data/ONET_ESCO_crosswalk/download_outputs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> \b
Temporary env:
$ hatch shell -t
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /tmp/tmpzg73untp/Ihqd/bin/python3
Also creating executable in /tmp/tmpzg73untp/Ihqd/bin/python
Installing setuptools, pip, wheel...done.
$ whi... | code_fim | hard | {
"lang": "python",
"repo": "DalavanCloud/hatch",
"path": "/hatch/commands/shell.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if temp_env:
if pyname:
try:
settings = load_settings()
except FileNotFoundError:
echo_failure('Unable to locate config file. Try `hatch config --restore`.')
sys.exit(1)
pypath = settings.get('pypaths', {}).ge... | code_fim | hard | {
"lang": "python",
"repo": "DalavanCloud/hatch",
"path": "/hatch/commands/shell.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DalavanCloud/hatch path: /hatch/commands/shell.py
import os
import subprocess
import sys
from tempfile import TemporaryDirectory
import click
from hatch.commands.utils import (
UNKNOWN_OPTIONS, echo_failure, echo_info, echo_success, echo_waiting
)
from hatch.config import get_venv_dir
from ... | code_fim | hard | {
"lang": "python",
"repo": "DalavanCloud/hatch",
"path": "/hatch/commands/shell.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def transform(self, j_object):
return HyperLogLogPlus(j_object)
class HyperLogLogPlus(GeoWaveObject):
def cardinality(self):
return self._java_ref.cardinality()<|fim_prefix|># repo: kaydoh/geowave path: /python/src/main/python/pygw/statistics/field/hyper_log_log_statistic.py
#
#... | code_fim | hard | {
"lang": "python",
"repo": "kaydoh/geowave",
"path": "/python/src/main/python/pygw/statistics/field/hyper_log_log_statistic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kaydoh/geowave path: /python/src/main/python/pygw/statistics/field/hyper_log_log_statistic.py
#
# Copyright (c) 2013-2022 Contributors to the Eclipse Foundation
#
# See the NOTICE file distributed with this work for additional information regarding copyright
# ownership. All rights reserved. Thi... | code_fim | medium | {
"lang": "python",
"repo": "kaydoh/geowave",
"path": "/python/src/main/python/pygw/statistics/field/hyper_log_log_statistic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RiseofRice/password-Creator path: /genpasswds.py
import random
import string
specials = '!"§$%&/()=?-_.:,;#+*~'
passstring = string.digits + string.ascii_lowercase + \
string.ascii_uppercase + specials
<|fim_suffix|> password = ""
password = "".join(random.choice(passstring) for j i... | code_fim | easy | {
"lang": "python",
"repo": "RiseofRice/password-Creator",
"path": "/genpasswds.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print(password)
return password<|fim_prefix|># repo: RiseofRice/password-Creator path: /genpasswds.py
import random
import string
specials = '!"§$%&/()=?-_.:,;#+*~'
passstring = string.digits + string.ascii_lowercase + \
string.ascii_uppercase + specials
<|fim_middle|>
def generate_passw... | code_fim | medium | {
"lang": "python",
"repo": "RiseofRice/password-Creator",
"path": "/genpasswds.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def drain(self):
try:
while True:
self.wakeup_sock.recv(2 ** 16)
except BlockingIOError:
pass
def close(self):
self.wakeup_sock.close()
self.write_sock.close()<|fim_prefix|># repo: njsmith/trio path: /trio/_core/_wakeup_sock... | code_fim | hard | {
"lang": "python",
"repo": "njsmith/trio",
"path": "/trio/_core/_wakeup_socketpair.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: njsmith/trio path: /trio/_core/_wakeup_socketpair.py
import socket
from .. import _core
class WakeupSocketpair:
def __init__(self):
self.wakeup_sock, self.write_sock = socket.socketpair()
self.wakeup_sock.setblocking(False)
self.write_sock.setblocking(False)
... | code_fim | medium | {
"lang": "python",
"repo": "njsmith/trio",
"path": "/trio/_core/_wakeup_socketpair.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_chunk_tag_size_8():
result = chunk(LIST, 8)
expected = [[1, 2, 3, 4, 5, 6, 7]]
assert result == expected<|fim_prefix|># repo: nhsuk/wagtail-nhsuk-frontend path: /tests/test_chunk_tag.py
from wagtailnhsukfrontend.templatetags.nhsukfrontend_tags import chunk
LIST = [1, 2, 3, 4, 5, 6... | code_fim | medium | {
"lang": "python",
"repo": "nhsuk/wagtail-nhsuk-frontend",
"path": "/tests/test_chunk_tag.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nhsuk/wagtail-nhsuk-frontend path: /tests/test_chunk_tag.py
from wagtailnhsukfrontend.templatetags.nhsukfrontend_tags import chunk
<|fim_suffix|> result = chunk(LIST, 2)
expected = [[1, 2], [3, 4], [5, 6], [7]]
assert result == expected
def test_chunk_tag_size_8():
result = chu... | code_fim | medium | {
"lang": "python",
"repo": "nhsuk/wagtail-nhsuk-frontend",
"path": "/tests/test_chunk_tag.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> contents = ''.join(sorted(
'lib/%s=%s\n' % (name, subprocess.check_output(
cmd + ['-print-file-name=' + name]).rstrip())
for name in args.soname))
if os.path.exists(args.output):
with open(args.output, 'rb') as f:
if f.read() == contents:
return... | code_fim | hard | {
"lang": "python",
"repo": "mdxy2010/fuchsia",
"path": "/build/gn/toolchain_manifest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mdxy2010/fuchsia path: /build/gn/toolchain_manifest.py
#!/usr/bin/env python
# Copyright 2017 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# TODO(TO-471): Remove this script when the toolchain prov... | code_fim | hard | {
"lang": "python",
"repo": "mdxy2010/fuchsia",
"path": "/build/gn/toolchain_manifest.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if os.path.exists(args.output):
with open(args.output, 'rb') as f:
if f.read() == contents:
return
if not os.path.isdir(os.path.dirname(args.output)):
os.makedirs(os.path.dirname(args.output))
with open(args.output, 'wb') as f:
f.write(contents)
if __name... | code_fim | hard | {
"lang": "python",
"repo": "mdxy2010/fuchsia",
"path": "/build/gn/toolchain_manifest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CHEN-Zhaohui/geoist path: /geoist/pfm/polyprism.py
res += kernel*density
res *= G*SI2MGAL
return res
def gxx(xp, yp, zp, prisms):
r"""
xx component of the gravity gradient tensor of a polygonal prism.
.. note:: The coordinate system of the input parameters is to be
... | code_fim | hard | {
"lang": "python",
"repo": "CHEN-Zhaohui/geoist",
"path": "/geoist/pfm/polyprism.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
if xp.shape != yp.shape != zp.shape:
raise ValueError("Input arrays xp, yp, and zp must have same shape!")
dummy = 1e-10
x, y = prism.x, prism.y
z1, z2 = prism.z1, prism.z2
nverts = prism.nverts
# Calculate the effect of the prism
Z1 = z1 - zp
Z2 = z2 - zp
... | code_fim | hard | {
"lang": "python",
"repo": "CHEN-Zhaohui/geoist",
"path": "/geoist/pfm/polyprism.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def gzz(xp, yp, zp, prisms):
r"""
zz component of the gravity gradient tensor of a polygonal prism.
.. note:: The coordinate system of the input parameters is to be
x -> North, y -> East and z -> Down.
.. note:: All input values in SI units and output in Eotvos!
Parameters:
... | code_fim | hard | {
"lang": "python",
"repo": "CHEN-Zhaohui/geoist",
"path": "/geoist/pfm/polyprism.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xdze2/arbresdegrenoble path: /geojson_to_sqlite.py
import json
import sqlite3
json_filename = 'data/ARBRES_TERRITOIRE_VDG_EPSG4326.json'
db_filename = 'data/arbres.db'
data = json.load(open( json_filename ))
db = sqlite3.connect(db_filename)
# -- create the table --
cursor = db.cursor()
cu... | code_fim | hard | {
"lang": "python",
"repo": "xdze2/arbresdegrenoble",
"path": "/geojson_to_sqlite.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>db.commit()
# -- Populate the table --
arbres = []
for k, arbre in enumerate( data['features'] ):
infolist = []
infolist.append( arbre['properties']['CODE_PARENT_DESC'] )
infolist.append( arbre['properties']['CODE_PARENT'] )
infolist.append( arbre['properties']['GENRE_BOTA'] )
infoli... | code_fim | hard | {
"lang": "python",
"repo": "xdze2/arbresdegrenoble",
"path": "/geojson_to_sqlite.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Sets the authenticated_at of this Session.
:param authenticated_at: The authenticated_at of this Session. # noqa: E501
:type: datetime
"""
if self.local_vars_configuration.client_side_validation and authenticated_at is None: # noqa: E501
raise Val... | code_fim | hard | {
"lang": "python",
"repo": "ms42Q/sdk",
"path": "/clients/kratos/python/ory_kratos_client/models/session.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ms42Q/sdk path: /clients/kratos/python/ory_kratos_client/models/session.py
# coding: utf-8
"""
Ory Kratos
Welcome to the ORY Kratos HTTP API documentation! # noqa: E501
The version of the OpenAPI document: v0.5.4-alpha.1
Generated by: https://openapi-generator.tech
"""
impor... | code_fim | hard | {
"lang": "python",
"repo": "ms42Q/sdk",
"path": "/clients/kratos/python/ory_kratos_client/models/session.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Sets the id of this Session.
:param id: The id of this Session. # noqa: E501
:type: str
"""
if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501
raise ValueError("Invalid value for `id`, must not be `None`") # noqa... | code_fim | hard | {
"lang": "python",
"repo": "ms42Q/sdk",
"path": "/clients/kratos/python/ory_kratos_client/models/session.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Junhojuno/reinforcement-learning-kr path: /1-grid-world/4-sarsa/sarsa_agent_juno.py
import numpy as np
import random
from collections import defaultdict
from environment import Env
class SARSAagent:
def __init__(self, actions):
self.actions = actions
self.learning_rate = 0.0... | code_fim | hard | {
"lang": "python",
"repo": "Junhojuno/reinforcement-learning-kr",
"path": "/1-grid-world/4-sarsa/sarsa_agent_juno.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> agent.learn(str(state), action, reward, str(next_state), next_action)
state = next_state
action = next_action
env.print_value_all(agent.q_table)
if done:
break<|fim_prefix|># repo: Junhojuno/reinforcement-learning-kr path: /1-... | code_fim | hard | {
"lang": "python",
"repo": "Junhojuno/reinforcement-learning-kr",
"path": "/1-grid-world/4-sarsa/sarsa_agent_juno.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhuangzi926/KnowledgeDistillation-pytorch path: /tests/minist.py
import os
import sys
import torch
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
sys.path.append("..")
import nets
# GPU setting
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
... | code_fim | hard | {
"lang": "python",
"repo": "zhuangzi926/KnowledgeDistillation-pytorch",
"path": "/tests/minist.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>dataloader_train = torch.utils.data.DataLoader(dataset_train, **kwargs)
dataloader_test = torch.utils.data.DataLoader(dataset_test, **kwargs)
# Model setting
model = nets.maxout.MaxoutConvMNIST().to(device)
# Optim setting
optimizer = optim.Adam(model.parameters(), lr=5e-3)
# LR scheduler
scheduler = t... | code_fim | hard | {
"lang": "python",
"repo": "zhuangzi926/KnowledgeDistillation-pytorch",
"path": "/tests/minist.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for statement in self.double_statements:
# 列出所有double型临时寄存器
if statement.find('%') != -1:
idx = statement.find('%')
if statement[idx + 1: idx + 2].isalnum():
self.double_vars.append('%' + statement[idx + 1: idx + 2])
... | code_fim | hard | {
"lang": "python",
"repo": "FloatErrorAnalysis/LLVM",
"path": "/Extractor/util/DoubleValExtractor.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FloatErrorAnalysis/LLVM path: /Extractor/util/DoubleValExtractor.py
# 一个专门用于提取ll文件double类型变量和相关函数以及double类型的函数的工具类
''' 全局标识符(函数,全局变量)以“@”字符开头。
本地标识符(注册名称,类型)以'%'字符开头 '''
class DoubleValExtractor:
source_file_path = ''
ll_file_content_list = []
vm_module = []
double_vars =... | code_fim | hard | {
"lang": "python",
"repo": "FloatErrorAnalysis/LLVM",
"path": "/Extractor/util/DoubleValExtractor.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akhilgakhar/deap_analysis path: /peripheral_fe_construction.py
# EMG and peripheral data feature extraction and construction.
# Affect recognition via EEG
import numpy as np
import signalpreprocess as sp
import peripheral_features as pf
import cPickle
# Load the entire 32 patients accesible b... | code_fim | hard | {
"lang": "python",
"repo": "akhilgakhar/deap_analysis",
"path": "/peripheral_fe_construction.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>## Need to do this for all 32 and first 22 seperately to make sure we are doing things properly.
###################################################################################
############################ Full 32 Participants #################################
########################################... | code_fim | medium | {
"lang": "python",
"repo": "akhilgakhar/deap_analysis",
"path": "/peripheral_fe_construction.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>participants = range(1,33)
videos = range(0,40)
# Our data for the ml
X = [] # make full dumb
y = [] # put all ratings, so we can subset laters
# construct feature vectors
for person in participants:
for vid in videos:
channels_data = (((raw_data_dict[person])['data'])[vid])[32:]
ratings = ((raw_da... | code_fim | hard | {
"lang": "python",
"repo": "akhilgakhar/deap_analysis",
"path": "/peripheral_fe_construction.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
q = np.eye(5)
q[0][0] = 0.0001
q[1][1] = 0.0001
q[2][2] = 0.0004
q[3][3] = 0.0025
q[4][4] = 0.0025
print(q)<|fim_prefix|># repo: nerv8761/kf path: /2.py
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 7 13:28:46 2019
@author: ams_user
"""
<|fim_middle|>import numpy as np
import ma... | code_fim | easy | {
"lang": "python",
"repo": "nerv8761/kf",
"path": "/2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nerv8761/kf path: /2.py
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 7 13:28:46 2019
@author: ams_user
"""
<|fim_suffix|>
q = np.eye(5)
q[0][0] = 0.0001
q[1][1] = 0.0001
q[2][2] = 0.0004
q[3][3] = 0.0025
q[4][4] = 0.0025
print(q)<|fim_middle|>import numpy as np
import ma... | code_fim | easy | {
"lang": "python",
"repo": "nerv8761/kf",
"path": "/2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kamaal44/molior path: /molior/model/project.py
from sqlalchemy import Column, String, Integer, Boolean
from sqlalchemy.orm import relationship
from .database import Base
<|fim_suffix|> id = Column(Integer, primary_key=True)
is_mirror = Column(Boolean, default=False)
is_basemirror = ... | code_fim | easy | {
"lang": "python",
"repo": "kamaal44/molior",
"path": "/molior/model/project.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> id = Column(Integer, primary_key=True)
is_mirror = Column(Boolean, default=False)
is_basemirror = Column(Boolean, default=False)
name = Column(String, unique=True, index=True, nullable=False)
projectversions = relationship("ProjectVersion", back_populates="project")
description = C... | code_fim | easy | {
"lang": "python",
"repo": "kamaal44/molior",
"path": "/molior/model/project.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucadealfaro/cis-crowd path: /models/tables.py
# coding: utf8
from datetime import datetime
import datetime as dates # Ah, what a mess these python names
from gluon.validators import IS_FLOAT_IN_RANGE
DATE_FORMAT = '%Y-%m-%d %H:%M %Z'
datetime_validator = IS_LOCALIZED_DATETIME(timezone=pytz.time... | code_fim | hard | {
"lang": "python",
"repo": "lucadealfaro/cis-crowd",
"path": "/models/tables.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>db.comment.id.readable = False
db.comment.binding.writable = False
db.comment.vote.requires=IS_FLOAT_IN_RANGE(-2, 2)
db.comment.user.writable = False
db.comment.user_id.readable = db.comment.user_id.writable = False
db.comment.created_on.writable = False
db.comment.updated_on.writable = False
db.comment.c... | code_fim | hard | {
"lang": "python",
"repo": "lucadealfaro/cis-crowd",
"path": "/models/tables.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>db.define_table('comment',
Field('binding', db.binding, required=True),
Field('vote', 'double'),
Field('comment', 'text'),
Field('user', default=current.user_email),
Field('user_id', default=current.user_id),
Field('created_on', 'datetime', default=datetime.utcnow()),
Field('up... | code_fim | hard | {
"lang": "python",
"repo": "lucadealfaro/cis-crowd",
"path": "/models/tables.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tharnatoz/PokeKaio path: /filters/pokemon/mon_advanced.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from filters.baseFilter import BaseFilter
from filters import helper
class Mon_Advanced(BaseFilter):
def __init__(self, filterConfig):
super(Mon_Advanced, self).__init__(filterCo... | code_fim | hard | {
"lang": "python",
"repo": "tharnatoz/PokeKaio",
"path": "/filters/pokemon/mon_advanced.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def testConfig(self):
for monFilter in self.filterConfig['mons']:
# first check if the mon id is set
helper.hasOwnProperty(monFilter, 'monId', self.filterType)
# tmp filter name for improved error finding
tmpFilterName = self.filte... | code_fim | hard | {
"lang": "python",
"repo": "tharnatoz/PokeKaio",
"path": "/filters/pokemon/mon_advanced.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: priyansh19/pytype path: /pytype/tests/test_generic.py
Var("K")
V = TypeVar("V")
class A(Dict[K, V]): pass
class B(A[str, int]): pass
""")
ty = self.Infer("""
import a
def foo():
return a.B()
def bar():
x = foo()
... | code_fim | hard | {
"lang": "python",
"repo": "priyansh19/pytype",
"path": "/pytype/tests/test_generic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: priyansh19/pytype path: /pytype/tests/test_generic.py
x = a.B()
x.extend(["str"])
return x[0]
""", pythonpath=[d.path])
self.assertTypesMatchPytd(ty, """
a = ... # type: module
def foo() -> a.A[nothing]
def bar() -> int
def baz(... | code_fim | hard | {
"lang": "python",
"repo": "priyansh19/pytype",
"path": "/pytype/tests/test_generic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def testTypeParameterEmpty(self):
with file_utils.Tempdir() as d:
d.create_file("a.pyi", """
from typing import Generic, List, TypeVar
T = TypeVar("T")
class A(Generic[T]):
def f(self) -> List[T]
""")
ty = self.Infer("""
import a
de... | code_fim | hard | {
"lang": "python",
"repo": "priyansh19/pytype",
"path": "/pytype/tests/test_generic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cosminbasca/asyncrpc path: /asyncrpc/util.py
#
# author: Cosmin Basca
#
# Copyright 2010 University of Zurich
#
# 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
#
# ... | code_fim | hard | {
"lang": "python",
"repo": "cosminbasca/asyncrpc",
"path": "/asyncrpc/util.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(address, __types_list):
size = len(address)
if size == 1:
return format_address(address[0])
elif size >= 2 and isinstance(address[1], __types_all):
return map(format_address, address)
return format_address(address)
__templates_dir = o... | code_fim | hard | {
"lang": "python",
"repo": "cosminbasca/asyncrpc",
"path": "/asyncrpc/util.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>__templates_dir = os.path.join(os.path.dirname(__file__), 'templates')
__static_dir = os.path.join(os.path.dirname(__file__), 'static')
def get_templates_dir():
global __templates_dir
return __templates_dir
def get_static_dir():
global __static_dir
return __static_dir<|fim_prefix|># re... | code_fim | hard | {
"lang": "python",
"repo": "cosminbasca/asyncrpc",
"path": "/asyncrpc/util.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> the result of applying the bitwise inclusive OR operation to _xByte_ and _yByte_.
1. Set _i_ to _i_ + 1.
1. Append _resultByte_ to the end of _result_.
1. Return _result_.<|fim_prefix|># repo: kaist-plrg/jstar path: /tests/compile/basic/recent/ByteListBitwiseOp.spec
... | code_fim | hard | {
"lang": "python",
"repo": "kaist-plrg/jstar",
"path": "/tests/compile/basic/recent/ByteListBitwiseOp.spec",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>_yByte_.
1. Else if _op_ is `^`, let _resultByte_ be the result of applying the bitwise exclusive OR (XOR) operation to _xByte_ and _yByte_.
1. Else, _op_ is `|`. Let _resultByte_ be the result of applying the bitwise inclusive OR operation to _xByte_ and _yByte_.
1. Se... | code_fim | hard | {
"lang": "python",
"repo": "kaist-plrg/jstar",
"path": "/tests/compile/basic/recent/ByteListBitwiseOp.spec",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kaist-plrg/jstar path: /tests/compile/basic/recent/ByteListBitwiseOp.spec
1. Assert: _op_ is `&`, `^`, or `|`.
1. Assert: _xBytes_ and _yBytes_ have the same number of elements.
1. Let _result_ be a new empty List.
1. Let _i_ be 0.
1. For each ele... | code_fim | hard | {
"lang": "python",
"repo": "kaist-plrg/jstar",
"path": "/tests/compile/basic/recent/ByteListBitwiseOp.spec",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> X = np.stack([conf_r,conf_c]).T
nn = NearestNeighbors(n_neighbors=1).fit(cen)
dis,idx = nn.kneighbors(n_neighbors =1,X = X)
m_changed = masks.copy()
#set 0 across all masks at conflicted pixels
m_changed[conf_r,conf_c,:] = 0
#only at final mask inde... | code_fim | hard | {
"lang": "python",
"repo": "nolanlab/CellVisionSegmenter",
"path": "/src/cvmask.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nolanlab/CellVisionSegmenter path: /src/cvmask.py
# cvmask.py
# ---------------------------
# Wrapper class for masks. See class doc for details.
import numpy as np
from scipy.linalg import lstsq
from scipy.spatial import distance
from operator import itemgetter
from skimage.measure import find... | code_fim | hard | {
"lang": "python",
"repo": "nolanlab/CellVisionSegmenter",
"path": "/src/cvmask.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def remove_overlaps_nearest_neighbors(self):
Y, X, N = self.masks.shape
collisions = []
for y in range(Y):
for x in range(X):
pixel_masks = np.where(self.masks[y, x, :])[0]
if len(pixel_masks) == 2:
c... | code_fim | hard | {
"lang": "python",
"repo": "nolanlab/CellVisionSegmenter",
"path": "/src/cvmask.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Tests(TestCase):
"""Tests for our lone template tag"""
def test_unsubscribe_instructions(self):
"""Make sure unsubscribe_instructions renders and contains the
unsubscribe URL."""
w = watch(save=True)
template = Template('{% load unsubscribe_instructions %}'
... | code_fim | medium | {
"lang": "python",
"repo": "mozilla/django-tidings",
"path": "/tests/test_templatetags.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mozilla/django-tidings path: /tests/test_templatetags.py
from django.test import TestCase
from django.template import Context, Template
from .base import watch
<|fim_suffix|> """Tests for our lone template tag"""
def test_unsubscribe_instructions(self):
"""Make sure unsubscribe... | code_fim | medium | {
"lang": "python",
"repo": "mozilla/django-tidings",
"path": "/tests/test_templatetags.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> bundle_fqids = set()
notifications = []
def update(source: SourceRef,
prefix: str,
partition_bundle_fqids: Iterable[SourcedBundleFQID]):
bundle_fqids.update(partition_bundle_fqids)
notifications.append(self.azul_client.... | code_fim | hard | {
"lang": "python",
"repo": "DataBiosphere/azul",
"path": "/test/integration_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DataBiosphere/azul path: /test/integration_test.py
will use
# catalogs from first run. Don't commit changes to these two lines.
index = True
delete = True
if index:
self._reset_indexer()
catalogs: list[Catalog] = []
for catalog in conf... | code_fim | hard | {
"lang": "python",
"repo": "DataBiosphere/azul",
"path": "/test/integration_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DataBiosphere/azul path: /test/integration_test.py
assert False, catalog
def _project_type(self, catalog: CatalogName) -> EntityType:
if config.is_hca_enabled(catalog):
return 'projects'
elif config.is_anvil_enabled(catalog):
return 'datas... | code_fim | hard | {
"lang": "python",
"repo": "DataBiosphere/azul",
"path": "/test/integration_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: blurrcat/leet path: /leet/problems/65_valid_number.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Validate if a given string is numeric.
Some examples:
"0" => true
" 0.1 " => true
"abc" => false
"1 a" => false
"2e10" => true
Note: It is intended for the problem statement to be ambiguous.
Y... | code_fim | hard | {
"lang": "python",
"repo": "blurrcat/leet",
"path": "/leet/problems/65_valid_number.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class FSM(object):
absorb_states = {
'integer',
'float',
'float_point',
'sci',
}
def __init__(self):
self.state = 'initial'
def parse(self, stream):
if not stream:
return False
for token in stream.strip():
... | code_fim | hard | {
"lang": "python",
"repo": "blurrcat/leet",
"path": "/leet/problems/65_valid_number.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rakshith-2905/cat-dog-classification path: /train.py
# -*- coding: utf-8 -*-
""" This program trains a simple two layer classifier for the task of classifying
elements of the data set.
The program requires the data tree to be of the following format.
|dataset/
|train/
|class-A/
... | code_fim | hard | {
"lang": "python",
"repo": "Rakshith-2905/cat-dog-classification",
"path": "/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> valid_datagen = ImageDataGenerator(rescale = 1./255)
training_set = train_datagen.flow_from_directory('dataset/training_set',
target_size = (64, 64),
batch_size = 32,
... | code_fim | hard | {
"lang": "python",
"repo": "Rakshith-2905/cat-dog-classification",
"path": "/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lving/outlier_detection path: /example/poisson_demo.py
# create test data
from scipy import stats
x = stats.poisson.rvs(1, 0, 100)
noise = [16, 17, 18, 19, 10]
<|fim_suffix|>detector = OutlierDetector(algo_name='poisson', param_dict={'cdf_thres': 0.9})
detector.fit(x)
print detector.predict(x[-... | code_fim | medium | {
"lang": "python",
"repo": "Lving/outlier_detection",
"path": "/example/poisson_demo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>detector = OutlierDetector(algo_name='poisson', param_dict={'cdf_thres': 0.9})
detector.fit(x)
print detector.predict(x[-5:])
print detector.score(x[-5:])
print detector.predict(noise)
print detector.score(noise)<|fim_prefix|># repo: Lving/outlier_detection path: /example/poisson_demo.py
# create test da... | code_fim | medium | {
"lang": "python",
"repo": "Lving/outlier_detection",
"path": "/example/poisson_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> frequencies, energies = self.costcalculator.calculate_frequencies_energy(microphone_samples_one_second)
current_error = self.costcalculator.get_energy_frequency(frequencies,energies,frequency_to_correct)
if current_error>self.previous_error:
if self.direction == Di... | code_fim | hard | {
"lang": "python",
"repo": "WanneWisseGit/SoundFiltering",
"path": "/online_modeling.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WanneWisseGit/SoundFiltering path: /online_modeling.py
#TODO create a errorplot class
import pyaudio
import numpy as np
import matplotlib.pyplot as plt
import time
import queue
import keyboard
import enum
from scipy.io.wavfile import write
import os
#class used to set the direction of shift or a... | code_fim | hard | {
"lang": "python",
"repo": "WanneWisseGit/SoundFiltering",
"path": "/online_modeling.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.on_disconnect = on_disconnect
client.username_pw_set(SECRET_KEY)
client.connect("mqtt.beebotte.com", 1883, 60)
print("Starting the loop..")
client.loop_forever(timeout=1.0)
if __nam... | code_fim | hard | {
"lang": "python",
"repo": "dhavalhparikh/fun-hobby-projects",
"path": "/beebotte_scripts/beebotte_mqtt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(msg.topic+" "+str(msg.payload))
def main():
client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.on_disconnect = on_disconnect
client.username_pw_set(SECRET_KEY)
client.connect("mqtt.beebotte.com", 1883, 60)
print("Starting the ... | code_fim | hard | {
"lang": "python",
"repo": "dhavalhparikh/fun-hobby-projects",
"path": "/beebotte_scripts/beebotte_mqtt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dhavalhparikh/fun-hobby-projects path: /beebotte_scripts/beebotte_mqtt.py
import paho.mqtt.client as mqtt
import time
from pyfirmata import Arduino, util
SECRET_KEY = ''
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, flags, rc):
... | code_fim | hard | {
"lang": "python",
"repo": "dhavalhparikh/fun-hobby-projects",
"path": "/beebotte_scripts/beebotte_mqtt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jecker7/chess-concepts path: /features/performance_eval/add_analysis.py
import json
import chess
import chess.engine
def load_puzzles(json_path):
with open(json_path) as fp:
data = json.load(fp)
return data
class PuzzleProcessor:
def __init__(self, engine_depth):
... | code_fim | hard | {
"lang": "python",
"repo": "jecker7/chess-concepts",
"path": "/features/performance_eval/add_analysis.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> args = parser.parse_args()
puzzles = load_puzzles(args.puzzle_path)
p = PuzzleProcessor(engine_depth=args.engine_depth)
with tqdm(total=len(puzzles)) as progress_bar:
for analysis, puzzle in zip(p.process_puzzles(puzzles), puzzles):
puzzle["analysis"] = analysis
... | code_fim | hard | {
"lang": "python",
"repo": "jecker7/chess-concepts",
"path": "/features/performance_eval/add_analysis.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(obj, DiskList):
return obj.serialize()
#return json.JSONEncoder(obj.serialize())
# Let the base class default method raise the TypeError
return json.JSONEncoder.default(self, obj)<|fim_prefix|># repo: elpollodiablo/python-disktypes path: /... | code_fim | medium | {
"lang": "python",
"repo": "elpollodiablo/python-disktypes",
"path": "/disktypes/encoder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elpollodiablo/python-disktypes path: /disktypes/encoder.py
import json
from .disklist import DiskList
class JSONDiskTypesEncoder(json.JSONEncoder):
<|fim_suffix|> if isinstance(obj, DiskList):
return obj.serialize()
#return json.JSONEncoder(obj.serialize())
... | code_fim | easy | {
"lang": "python",
"repo": "elpollodiablo/python-disktypes",
"path": "/disktypes/encoder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Syler1984/seismo-ml-phase-picker path: /utils/progress_bar.py
# Class for progress bar.
class ProgressBar:
def __init__(self):
self.progress_maxes = {}
self.progress = {}
self.progress_char = '#'
self.current_progress_char = '#'
self.empty_char = '-... | code_fim | hard | {
"lang": "python",
"repo": "Syler1984/seismo-ml-phase-picker",
"path": "/utils/progress_bar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def pop_postfix_arg(self, name):
"""
Pop postfix argument by its keyword (name)
:param name: str - keyword
:return: argument value or None
"""
return self._postfix_kwargs.pop(name, None)
# Progress bar tests
if __name__ == '__main__':
from time im... | code_fim | hard | {
"lang": "python",
"repo": "Syler1984/seismo-ml-phase-picker",
"path": "/utils/progress_bar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Pop postfix argument by its keyword (name)
:param name: str - keyword
:return: argument value or None
"""
return self._postfix_kwargs.pop(name, None)
# Progress bar tests
if __name__ == '__main__':
from time import sleep, time
# Prefix, postf... | code_fim | hard | {
"lang": "python",
"repo": "Syler1984/seismo-ml-phase-picker",
"path": "/utils/progress_bar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shakusi2009/dwarf path: /tests/image/test_api.py
#!/usr/bin/env python
#
# Copyright (c) 2015 Hewlett-Packard Development Company, L.P.
#
# 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... | code_fim | hard | {
"lang": "python",
"repo": "shakusi2009/dwarf",
"path": "/tests/image/test_api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual(json.loads(resp.body), IMAGE_CREATE_RESP)
with open('/tmp/dwarf/images/%s' % UUID, 'r') as fh:
self.assertEqual(fh.read(), IMAGE_DATA)
# TBD: check the content of the database
def test_image_create_chunked(self):
headers = utils.to_headers(... | code_fim | hard | {
"lang": "python",
"repo": "shakusi2009/dwarf",
"path": "/tests/image/test_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> headers = utils.to_headers(IMAGE_CREATE_REQ)
resp = self.app.post('/v1/images', IMAGE_DATA, headers, status=200)
self.assertEqual(json.loads(resp.body), IMAGE_CREATE_RESP)
with open('/tmp/dwarf/images/%s' % UUID, 'r') as fh:
self.assertEqual(fh.read(), IMAGE_DA... | code_fim | hard | {
"lang": "python",
"repo": "shakusi2009/dwarf",
"path": "/tests/image/test_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_14(self):
"""
Test Case 14:
Test type of :py:data:`xobox.APPINFO`
Test is passed if type of :py:data:`xobox.APPINFO` is a tuple
"""
self.assertIsInstance(xobox.APPINFO, tuple)
def test_15(self):
"""
Test Case 15:
... | code_fim | hard | {
"lang": "python",
"repo": "stormrose-va/xobox",
"path": "/tests/test_xobox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stormrose-va/xobox path: /tests/test_xobox.py
# -*- coding: utf-8 -*-
"""
tests.test_xobox
~~~~~~~~~~~~~~~~
:copyright: Copyright 2017 by the Stormrose Project team, see AUTHORS.
:license: MIT License, see LICENSE for details.
"""
from unittest import TestCase, skipUnless
impor... | code_fim | hard | {
"lang": "python",
"repo": "stormrose-va/xobox",
"path": "/tests/test_xobox.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_04(self):
"""
Test Case 04:
Test type of second member of :py:data:`xobox.VERSION`
Test is passed if detected type is :py:class:`int` and value is not negative
"""
self.assertIsInstance(xobox.VERSION[1], int)
self.assertGreaterE... | code_fim | hard | {
"lang": "python",
"repo": "stormrose-va/xobox",
"path": "/tests/test_xobox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #### 设置 Response HTTP 头部
response = client.get_object(
Bucket='examplebucket-1250000000',
Key='picture.jpg',
ResponseContentType='text/html; charset=utf-8'
)
print(response['Content-Type'])
fp = response['Body'].get_raw_stream()
print(fp.read(2))
##... | code_fim | hard | {
"lang": "python",
"repo": "tencentyun/cos-snippets",
"path": "/Python/examples/get_object.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #### 指定下载范围
response = client.get_object(
Bucket='examplebucket-1250000000',
Key='picture.jpg',
Range='bytes=0-10'
)
fp = response['Body'].get_raw_stream()
print(fp.read())
#.cssg-snippet-body-end
#.cssg-methods-pragma
# 下载对象
get_object()
# 下载对象
get... | code_fim | hard | {
"lang": "python",
"repo": "tencentyun/cos-snippets",
"path": "/Python/examples/get_object.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tencentyun/cos-snippets path: /Python/examples/get_object.py
# -*- coding=utf-8
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
from qcloud_cos import CosServiceError
from qcloud_cos import CosClientError
secret_id = 'COS_SECRETID' # 替换为用户的secret_id
secret_key = 'COS_SEC... | code_fim | hard | {
"lang": "python",
"repo": "tencentyun/cos-snippets",
"path": "/Python/examples/get_object.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
QDockWidget </
border: None;
background: Transparent;
/>
QScrollBar </
border: None;
border-radius: 0px;
background-color: {ffBackground};
/>
QScrollBar:horizontal </
height: 12px;
margin: 0px 12px 0px 12px;
/>
QScrollBar:vertical </
width: 12px;
margin: 12px 0px 1... | code_fim | hard | {
"lang": "python",
"repo": "datalyze-solutions/FancyQt",
"path": "/fancyqt/firefox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>QScrollBar::add-line:horizontal
</
border-image: url(:/icons/black/arrow-right.svg);
subcontrol-position: right;
/>
QScrollBar::sub-line:horizontal
</
border-image: url(:/icons/black/arrow-left.svg);
subcontrol-position: left;
/>
QScrollBar::add-line:vertical
</
border-image: url(:/i... | code_fim | hard | {
"lang": "python",
"repo": "datalyze-solutions/FancyQt",
"path": "/fancyqt/firefox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: datalyze-solutions/FancyQt path: /fancyqt/firefox.py
import sip
try:
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
except ValueError, e:
print e
import fancyqt.firefox_rc
values = {
"ffWhite": "#fffdfc",
"ffBackground": "#d6d2d0",
"ffBackgroundAlternative": "#c7c3c0... | code_fim | hard | {
"lang": "python",
"repo": "datalyze-solutions/FancyQt",
"path": "/fancyqt/firefox.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mveyette/PyHammer path: /classifier/NNClassifier.py
from . import Classifier
from .reader import read_all_spectra
import numpy as np
import tensorflow as tf
class NNClassifier(Classifier):
def __init__(self, load_model_dir=None):
"""
Simple feed forward neurnal network mode... | code_fim | hard | {
"lang": "python",
"repo": "mveyette/PyHammer",
"path": "/classifier/NNClassifier.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __train_input_fn(self):
"""Returns a random batch of training data"""
## To ensure unbiased training, grab random labels to define batch
labels = np.random.choice(np.unique(self.labels_train), self.batch_size)
## Then grab a random spectrum from each label
s... | code_fim | hard | {
"lang": "python",
"repo": "mveyette/PyHammer",
"path": "/classifier/NNClassifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if user_input.isdigit():
print("All Numbers")
elif user_input.islower():
print("All lowercase")
elif user_input.endswith("yes"):
print("Ends in yes")
else:
print("None of the conditions have been met")
"""===================== Module 3 ==========================="""
"""
=========... | code_fim | hard | {
"lang": "python",
"repo": "Descent098/PYTH-101",
"path": "/Solutions.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.