text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Liam-Deacon/phaseshifts path: /phaseshifts/lib/hartfock.py
bs(alfa) >= 0.001:
if (alfa > 0.):
fx = 1.0
fc = 1.0
else:
fx = 1.5 * abs(alfa)
fc = 0.0
# note: we don't deal with spin-polarization in local exchange
# picture, s... | code_fim | hard | {
"lang": "python",
"repo": "Liam-Deacon/phaseshifts",
"path": "/phaseshifts/lib/hartfock.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Liam-Deacon/phaseshifts path: /phaseshifts/lib/hartfock.py
occ[i] * coeff
coeffj = occ[j] * coeff
ri = ratio * coeffi
rj = ratio * coeffj
rc = coeff * occ[i] * occ[j]
xnum2 = xnum * xnum
xout... | code_fim | hard | {
"lang": "python",
"repo": "Liam-Deacon/phaseshifts",
"path": "/phaseshifts/lib/hartfock.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.row - HEIGHT_BUFFER
def copy(self):
return copy.deepcopy(self)<|fim_prefix|># repo: joeyism/cloud-storage-tui path: /cloudstoragetui/cursor_state.py
import copy
from cloudstoragetui.constants import HEIGHT_BUFFER
class CursorState:
_MIN_ROW = 4
_MAX_COLUMNS = 2
... | code_fim | medium | {
"lang": "python",
"repo": "joeyism/cloud-storage-tui",
"path": "/cloudstoragetui/cursor_state.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joeyism/cloud-storage-tui path: /cloudstoragetui/cursor_state.py
import copy
from cloudstoragetui.constants import HEIGHT_BUFFER
class CursorState:
_MIN_ROW = 4
_MAX_COLUMNS = 2
def __init__(self):
self.column = 0
self.depth = 0
self.row = self._MIN_ROW
... | code_fim | medium | {
"lang": "python",
"repo": "joeyism/cloud-storage-tui",
"path": "/cloudstoragetui/cursor_state.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return torch.matmul(out_grads.T, out_grads) # f_out x f_out
@staticmethod
def gram_A(module, in_data1, in_data2):
return torch.matmul(in_data1, in_data2.T) # n x n
@staticmethod
def gram_B(module, out_grads1, out_grads2):
return torch.matmul(out_grads1, out_grad... | code_fim | hard | {
"lang": "python",
"repo": "LaplaceKorea/asdfghjkl",
"path": "/asdfghjkl/operations/linear.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return torch.matmul(in_data1, in_data2.T) # n x n
@staticmethod
def gram_B(module, out_grads1, out_grads2):
return torch.matmul(out_grads1, out_grads2.T) # n x n<|fim_prefix|># repo: LaplaceKorea/asdfghjkl path: /asdfghjkl/operations/linear.py
import torch
from torch import nn
... | code_fim | medium | {
"lang": "python",
"repo": "LaplaceKorea/asdfghjkl",
"path": "/asdfghjkl/operations/linear.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LaplaceKorea/asdfghjkl path: /asdfghjkl/operations/linear.py
import torch
from torch import nn
from .operation import Operation
class Linear(Operation):
"""
module.weight: f_out x f_in
module.bias: f_out x 1
Argument shapes
in_data: n x f_in
out_grads: n x f_out
""... | code_fim | hard | {
"lang": "python",
"repo": "LaplaceKorea/asdfghjkl",
"path": "/asdfghjkl/operations/linear.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:rtype: int
"""
return self.s[-1][1]
def popMax(self):
"""
:rtype: int
"""
m = self.s[-1][1]
t = []
while self.s[-1][0] != m: t.append(self.pop())
e = self.pop()
for x in reversed(t): self.push(x)
... | code_fim | hard | {
"lang": "python",
"repo": "phucle2411/LeetCode",
"path": "/Python/max-stack.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: phucle2411/LeetCode path: /Python/max-stack.py
# https://leetcode.com/problems/max-stack/
class MaxStack:
def __init__(self):
"""
initialize your data structure here.
"""
self.s = []
def push(self, x):
"""
:type x: int
:rtype: vo... | code_fim | hard | {
"lang": "python",
"repo": "phucle2411/LeetCode",
"path": "/Python/max-stack.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if network.getStartIp():
print(' ' * 2 + '- Start IP: {0}'.format(network.getStartIp()))
if network.getGateway():
print(' ' * 2 + '- Gateway: {0}'.format(network.getGateway()))
if __name__ == '__main__':
GetNetworkListCli().run()<|fim_prefix|>... | code_fim | hard | {
"lang": "python",
"repo": "ilumb/tortuga",
"path": "/src/installer/bin/get-network-list",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
outputAttrGroup = _('Output formatting options')
self.addOptionGroup(outputAttrGroup, None)
self.addOptionToGroup(
outputAttrGroup, '--json',
action='store_true', default=False,
help=_('JSON formatted output')
)
self.addOption... | code_fim | hard | {
"lang": "python",
"repo": "ilumb/tortuga",
"path": "/src/installer/bin/get-network-list",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ilumb/tortuga path: /src/installer/bin/get-network-list
#!/usr/bin/env python
# Copyright 2008-2018 Univa Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#... | code_fim | hard | {
"lang": "python",
"repo": "ilumb/tortuga",
"path": "/src/installer/bin/get-network-list",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qtile/qtile path: /libqtile/layout/ratiotile.py
# -*- coding:utf-8 -*-
# Copyright (c) 2011 Florian Mounier
# Copyright (c) 2012-2013, 2015 Tycho Andersen
# Copyright (c) 2013 Björn Lindström
# Copyright (c) 2013 Tao Sauvage
# Copyright (c) 2014 ramnes
# Copyright (c) 2014 Sean Vig
# Copyright (c... | code_fim | hard | {
"lang": "python",
"repo": "qtile/qtile",
"path": "/libqtile/layout/ratiotile.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Tries to tile all windows in the width/height ratio passed in"""
defaults = [
("border_focus", "#0000ff", "Border colour(s) for the focused window."),
("border_normal", "#000000", "Border colour(s) for un-focused windows."),
("border_width", 1, "Border width."),
... | code_fim | hard | {
"lang": "python",
"repo": "qtile/qtile",
"path": "/libqtile/layout/ratiotile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.layout_info = method(screen.width, screen.height, screen.x, screen.y)
self.dirty = False
try:
idx = self.clients.index(win)
except ValueError:
win.hide()
return
x, y, w, h = self.layout_info[idx]
if win.has_f... | code_fim | hard | {
"lang": "python",
"repo": "qtile/qtile",
"path": "/libqtile/layout/ratiotile.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xryuseix/Heavy-Tire path: /WebAPI/inferModel/learningModel.py
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report
from sklearn.metrics import confusion_matrix
from sklearn.metr... | code_fim | hard | {
"lang": "python",
"repo": "xryuseix/Heavy-Tire",
"path": "/WebAPI/inferModel/learningModel.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> svc = LinearSVC(max_iter=3000)
svc.fit(trainX, trainY)
return svc
# グリッドサーチ
def gridSearch(trainX, trainY, model_name, param):
gscv = GridSearchCV(model_name, param, cv=4, verbose=3)
gscv.fit(trainX, trainY)
return gscv
# グリッドサーチ
def svc(trainX, trainY):
svc = SVC(verbose=1... | code_fim | medium | {
"lang": "python",
"repo": "xryuseix/Heavy-Tire",
"path": "/WebAPI/inferModel/learningModel.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> verbose_name = _("Picture")
verbose_name_plural = _("Pictures")
def __str__(self):
return self.image.name if self.image else u'(no image)'<|fim_prefix|># repo: onepercentclub/bluebottle path: /bluebottle/contentplugins/models.py
"""
ContentItem models for custom django-fluent... | code_fim | hard | {
"lang": "python",
"repo": "onepercentclub/bluebottle",
"path": "/bluebottle/contentplugins/models.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> validators=[
FileMimetypeValidator(
allowed_mimetypes=settings.IMAGE_ALLOWED_MIME_TYPES,
),
validate_file_infection
]
)
align = models.CharField(_("Align"), max_length=50,
choices=PictureAlignment.choi... | code_fim | hard | {
"lang": "python",
"repo": "onepercentclub/bluebottle",
"path": "/bluebottle/contentplugins/models.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: onepercentclub/bluebottle path: /bluebottle/contentplugins/models.py
"""
ContentItem models for custom django-fluent-contents plugins.
"""
from builtins import object
from future.utils import python_2_unicode_compatible
from django.conf import settings
from django.db import models
from django.u... | code_fim | hard | {
"lang": "python",
"repo": "onepercentclub/bluebottle",
"path": "/bluebottle/contentplugins/models.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
config = dict()
if args.dataset == 'wikipedia':
config['img_input_dim'] = 2048
config['txt_input_dim'] = 2048
config['n_clusters'] = 10
config['img_hiddens'] = [1024, 256, 128]
config['txt_hiddens'] = [1024, 256, 128]
confi... | code_fim | hard | {
"lang": "python",
"repo": "jiangyangby/DM2C",
"path": "/code/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jiangyangby/DM2C path: /code/train.py
from __future__ import print_function, absolute_import, division
import os
import time
import argparse
import scipy.io as sio
import torch
from sklearn.cluster import KMeans
from model import MultimodalGAN
from utils import calculate_metrics, check_dir_exi... | code_fim | hard | {
"lang": "python",
"repo": "jiangyangby/DM2C",
"path": "/code/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>parser.add_argument('--update_p_freq', type=int, default=10)
parser.add_argument('--update_d_freq', type=int, default=5)
parser.add_argument('--tol', type=int, default=1e-3)
parser.add_argument('--save_freq', type=int, default=25)
parser.add_argument('--log_freq', type=int, default=5)
parser.add_argument(... | code_fim | hard | {
"lang": "python",
"repo": "jiangyangby/DM2C",
"path": "/code/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mindspore-ai/mindinsight path: /tests/st/func/datavisual/image/test_single_image_restful_api.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 c... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/mindinsight",
"path": "/tests/st/func/datavisual/image/test_single_image_restful_api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test getting single image without step."""
params = dict(train_id="./summary0", tag="tag_name_0/image")
url = get_url(BASE_URL, params)
response = client.get(url)
assert response.status_code == 400
response = response.get_json()
assert response[... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/mindinsight",
"path": "/tests/st/func/datavisual/image/test_single_image_restful_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test getting single image without tag."""
params = dict(train_id="./summary0", step=1)
url = get_url(BASE_URL, params)
response = client.get(url)
assert response.status_code == 400
response = response.get_json()
assert response['error_code'] == ... | code_fim | hard | {
"lang": "python",
"repo": "mindspore-ai/mindinsight",
"path": "/tests/st/func/datavisual/image/test_single_image_restful_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.get_body_params().get('slaveSpec')
def set_slaveSpec(self,slaveSpec):
self.add_body_params('slaveSpec', slaveSpec)
def get_region(self):
return self.get_body_params().get('region')
def set_region(self,region):
self.add_body_params('region', region)
def get_masterNum(... | code_fim | medium | {
"lang": "python",
"repo": "aliyun/aliyun-openapi-python-sdk",
"path": "/aliyun-python-sdk-foas/aliyunsdkfoas/request/v20181111/CreateCellClusterOrderRequest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aliyun/aliyun-openapi-python-sdk path: /aliyun-python-sdk-foas/aliyunsdkfoas/request/v20181111/CreateCellClusterOrderRequest.py
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional i... | code_fim | hard | {
"lang": "python",
"repo": "aliyun/aliyun-openapi-python-sdk",
"path": "/aliyun-python-sdk-foas/aliyunsdkfoas/request/v20181111/CreateCellClusterOrderRequest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> homepage, prefixes = element
if "github.com" in homepage: # skip github links for now
return homepage, prefixes, False, None
if "purl.obolibrary.org" in homepage: # this is never acceptable
return homepage, prefixes, True, "no PURLs allowed"
failed = False
msg = ""
... | code_fim | hard | {
"lang": "python",
"repo": "biopragmatics/bioregistry",
"path": "/src/bioregistry/health/check_homepages.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: biopragmatics/bioregistry path: /src/bioregistry/health/check_homepages.py
# -*- coding: utf-8 -*-
"""A script to check which homepages in entries in the Bioregistry actually can be accessed."""
import sys
from collections import defaultdict
from datetime import datetime
from typing import Opti... | code_fim | hard | {
"lang": "python",
"repo": "biopragmatics/bioregistry",
"path": "/src/bioregistry/health/check_homepages.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> failed = sum(failed for _, _, failed, _ in rv)
click.secho(
f"{failed}/{len(rv)} ({failed / len(rv):.2%}) homepages failed to load", fg="red", bold=True
)
df = pd.DataFrame(
columns=["prefix", "homepage", "message"],
data=[
(prefix, homepage, msg)
... | code_fim | hard | {
"lang": "python",
"repo": "biopragmatics/bioregistry",
"path": "/src/bioregistry/health/check_homepages.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_version(self) -> None:
assert_success(
["version"],
f"git-machete version {__version__}\n"
)<|fim_prefix|># repo: VirtusLab/git-machete path: /tests/test_version.py
from git_machete import __version__
from .mockers import assert_success
<|fim_middl... | code_fim | easy | {
"lang": "python",
"repo": "VirtusLab/git-machete",
"path": "/tests/test_version.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VirtusLab/git-machete path: /tests/test_version.py
from git_machete import __version__
<|fim_suffix|> assert_success(
["version"],
f"git-machete version {__version__}\n"
)<|fim_middle|>from .mockers import assert_success
class TestVersion:
def test_... | code_fim | medium | {
"lang": "python",
"repo": "VirtusLab/git-machete",
"path": "/tests/test_version.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_version(self) -> None:
assert_success(
["version"],
f"git-machete version {__version__}\n"
)<|fim_prefix|># repo: VirtusLab/git-machete path: /tests/test_version.py
from git_machete import __version__
from .mockers import assert_success
<|fim_middl... | code_fim | easy | {
"lang": "python",
"repo": "VirtusLab/git-machete",
"path": "/tests/test_version.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def log_statistics(bot_func):
@functools.wraps(bot_func)
def wrapper(bot, update, *args, **kwargs):
message = update.message.text
user_id = str(update.message.from_user.id)
chat_id = update.message.chat_id
msg = "{} triggered, user_id: {}, chat_id {}"
logger... | code_fim | hard | {
"lang": "python",
"repo": "MrLokans/bank_telegram_bot",
"path": "/bot/decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def log_statistics(bot_func):
@functools.wraps(bot_func)
def wrapper(bot, update, *args, **kwargs):
message = update.message.text
user_id = str(update.message.from_user.id)
chat_id = update.message.chat_id
msg = "{} triggered, user_id: {}, chat_id {}"
logge... | code_fim | hard | {
"lang": "python",
"repo": "MrLokans/bank_telegram_bot",
"path": "/bot/decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrLokans/bank_telegram_bot path: /bot/decorators.py
"""
Useful decorators
"""
import functools
import telegram
from bot.exceptions import BotLoggedError
from bot.settings import logging
logger = logging.getLogger('telegrambot')
<|fim_suffix|> try:
bot_func(bot, update, *a... | code_fim | medium | {
"lang": "python",
"repo": "MrLokans/bank_telegram_bot",
"path": "/bot/decorators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
world = World(map_topic=map_tc)
turtle1 = Turtle(name)
msg = LaserScan()
msg.angle_min = angle_min
msg.angle_max = angle_max
msg.angle_increment = angle_increment
msg.range_max = range_max
msg.range_min = range_min
msg.time_increment = 0.001
msg.range_min = range_min
msg.header.frame_id = frame_id
star... | code_fim | hard | {
"lang": "python",
"repo": "qingchunlizhi/turtlebot2-for-clearning-robot",
"path": "/turtlesim_examples/scripts/fake_laser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qingchunlizhi/turtlebot2-for-clearning-robot path: /turtlesim_examples/scripts/fake_laser.py
#!/usr/bin/env python
import rospy
from utils import Turtle
from utils import World
from math import cos, sin
from sensor_msgs.msg import LaserScan
from time import time
rospy.init_node('laser_node')
... | code_fim | hard | {
"lang": "python",
"repo": "qingchunlizhi/turtlebot2-for-clearning-robot",
"path": "/turtlesim_examples/scripts/fake_laser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
args = parse_args()
args.func(args)
if __name__ == '__main__':
main()<|fim_prefix|># repo: kingsamchen/anvil path: /anvil.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 0xCCCCCCCC
import argparse
import job_init
VER = '0.8.0'
def show_anvil_version(_):
<|fim_middle|> ... | code_fim | hard | {
"lang": "python",
"repo": "kingsamchen/anvil",
"path": "/anvil.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kingsamchen/anvil path: /anvil.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 0xCCCCCCCC
import argparse
import job_init
VER = '0.8.0'
def show_anvil_version(_):
<|fim_suffix|> # command version
ver_parser = cmd_parser.add_parser('version', help='show version and exit')
ver_p... | code_fim | hard | {
"lang": "python",
"repo": "kingsamchen/anvil",
"path": "/anvil.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def parse_args():
parser = argparse.ArgumentParser()
cmd_parser = parser.add_subparsers(title='commands', dest='command')
cmd_parser.required = True
# command init
init_parser = cmd_parser.add_parser('init', help='bootstrap a new project')
init_parser.set_defaults(func=job_init.r... | code_fim | medium | {
"lang": "python",
"repo": "kingsamchen/anvil",
"path": "/anvil.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SpencerHastings/DiscordBot2.0 path: /bot.py
import asyncio
import os
from discord.ext import commands
from cogs import add_cogs
from config.token import botToken
from config.settings import prefix
if os.name == 'nt':
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
... | code_fim | medium | {
"lang": "python",
"repo": "SpencerHastings/DiscordBot2.0",
"path": "/bot.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|># random stuff below
# async def background_task():
# await bot.wait_until_ready()
# await asyncio.sleep(5)
# while not bot.is_closed():
# try:
# logging.info("Background Task")
# await asyncio.sleep(5)
# except Exception as e:
# logging.err... | code_fim | medium | {
"lang": "python",
"repo": "SpencerHastings/DiscordBot2.0",
"path": "/bot.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
my_singleton = MySingleton()<|fim_prefix|># repo: youaresherlock/PythonPractice path: /Foundation/singleton/mysingleton1.py
#!usr/bin/python
# -*- coding:utf8 -*-
"""
方式一:
其实,Python 的模块就是天然的单例模式,因为模块在第一次导入时
,会生成 .pyc 文件,当第二次导入时,就会直接加载 .pyc 文件,
而不会再次执行模块代码。因此,我们只需把相关的函数和数据定义在一个模块中,
就可以获得一个单... | code_fim | easy | {
"lang": "python",
"repo": "youaresherlock/PythonPractice",
"path": "/Foundation/singleton/mysingleton1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
my_singleton = MySingleton()<|fim_prefix|># repo: youaresherlock/PythonPractice path: /Foundation/singleton/mysingleton1.py
#!usr/bin/python
# -*- coding:utf8 -*-
"""
方式一:
其实,Python 的模块就是天然的单例模式,因为模块在第一次导入时
,会生成 .pyc 文件,当第二次导入时,就会直接加载 .pyc 文件,
而不会再次执行模块代码。因此,我们只需把相关的函数和数据定义在一个模块中,
就可以获得一个单例对象了
"""
cla... | code_fim | easy | {
"lang": "python",
"repo": "youaresherlock/PythonPractice",
"path": "/Foundation/singleton/mysingleton1.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: youaresherlock/PythonPractice path: /Foundation/singleton/mysingleton1.py
#!usr/bin/python
# -*- coding:utf8 -*-
"""
方式一:
其实,Python 的模块就是天然的单例模式,因为模块在第一次导入时
,会生成 .pyc 文件,当第二次导入时,就会直接加载 .pyc 文件,
而不会再次执行模块代码。因此,我们只需把相关的函数和数据定义在一个模块中,
就可以获得一个单例对象了
"""
<|fim_suffix|> def foo(self):
pass
... | code_fim | easy | {
"lang": "python",
"repo": "youaresherlock/PythonPractice",
"path": "/Foundation/singleton/mysingleton1.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TrendingTechnology/util path: /src/python/zensols/persist/composite.py
"""Stash implementations.
"""
__author__ = 'Paul Landes'
import logging
from typing import Any, Set, Tuple
from functools import reduce
import collections
import shutil
from pathlib import Path
from . import PersistableError... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/util",
"path": "/src/python/zensols/persist/composite.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if logger.isEnabledFor(logging.DEBUG):
logger.debug(f'dump {name}({self.attribute_name}) ' +
f'-> {inst.__class__}')
org_attr_val = getattr(inst, self.attribute_name)
context, composite = self._to_composite(org_attr_val)
try:
... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/util",
"path": "/src/python/zensols/persist/composite.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.brain.addSummaryScalar( input = 'Cost' )
self.brain.addSummaryHistogram( input = 'Target' )
self.brain.addWriter(name = 'Writer' , dir = '../' )
self.brain.addSummary( name = 'Summary' )
self.brain.initialize()
# TRAIN NETWORK
def train( self, prev_sta... | code_fim | hard | {
"lang": "python",
"repo": "raphaelsc19/Deep-RL-and-IL",
"path": "/learning/players_reinforcement/player_dql_bayesian_2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: raphaelsc19/Deep-RL-and-IL path: /learning/players_reinforcement/player_dql_bayesian_2.py
from players_reinforcement.player import player
from auxiliar.aux_plot import *
import random
from collections import deque
import sys
sys.path.append('..')
import tensorblock as tb
import numpy as np
# ... | code_fim | hard | {
"lang": "python",
"repo": "raphaelsc19/Deep-RL-and-IL",
"path": "/learning/players_reinforcement/player_dql_bayesian_2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.brain.addOperation( function = tb.ops.sum_mul,
input = ['Output', 'Actions'],
name = 'Readout' )
self.brain.addOperation( function = tb.ops.mean_squared_error,
input = ['Targe... | code_fim | hard | {
"lang": "python",
"repo": "raphaelsc19/Deep-RL-and-IL",
"path": "/learning/players_reinforcement/player_dql_bayesian_2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>.DetailView.as_view()),
url(r'^visit/(?P<category_id>\d+)/',views.VisitView.as_view()),
]<|fim_prefix|># repo: Hyman-Yuan/meiduo_project path: /meiduo_mall/meiduo_mall/apps/goods/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
# /list/115/1/
url(r'^list/(?P<categ... | code_fim | medium | {
"lang": "python",
"repo": "Hyman-Yuan/meiduo_project",
"path": "/meiduo_mall/meiduo_mall/apps/goods/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hyman-Yuan/meiduo_project path: /meiduo_mall/meiduo_mall/apps/goods/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
# /list/115/1/
ur<|fim_suffix|>.DetailView.as_view()),
url(r'^visit/(?P<category_id>\d+)/',views.VisitView.as_view()),
]<|fim_middle|>l(r'^... | code_fim | medium | {
"lang": "python",
"repo": "Hyman-Yuan/meiduo_project",
"path": "/meiduo_mall/meiduo_mall/apps/goods/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uelordi01/inference path: /v0.5/classification_and_detection/python/backend_dldt.py
"""
pytoch/caffe2 backend via onnx
https://pytorch.org/docs/stable/onnx.html
"""
# pylint: disable=unused-argument,missing-docstring,useless-super-delegation
from threading import Lock
import os
# needed to get ... | code_fim | hard | {
"lang": "python",
"repo": "uelordi01/inference",
"path": "/v0.5/classification_and_detection/python/backend_dldt.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # data = res[0][0][0]
# for number, proposal in enumerate(data):
# if proposal[2] > 0:
# detection_classes.append(np.int(proposal[1]))
# detection_num = detection_num + 1
# detection_threshold.append(proposal[2])
# ... | code_fim | hard | {
"lang": "python",
"repo": "uelordi01/inference",
"path": "/v0.5/classification_and_detection/python/backend_dldt.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: theromis/mlpiper path: /mlcomp/parallelm/components/connected_component_info.py
class ConnectedComponentInfo(object):
"""
Information about a connected component, which is needed in order to run the component, and provide information to
child components.
"""
def __init__(self... | code_fim | medium | {
"lang": "python",
"repo": "theromis/mlpiper",
"path": "/mlcomp/parallelm/components/connected_component_info.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
s = "Info:\n"
s += "params: {}\n".format(self.params)
s += "parents_obj: {}\n".format(self.parents_objs)
s += "output_obj: {}\n".format(self.output_objs)
return s<|fim_prefix|># repo: theromis/mlpiper path: /mlcomp/parallelm/componen... | code_fim | medium | {
"lang": "python",
"repo": "theromis/mlpiper",
"path": "/mlcomp/parallelm/components/connected_component_info.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isabella232/auth-6 path: /auth/blueprint.py
import os
from flask import Blueprint, request, url_for, session
from flask import redirect
from flask_jsonpify import jsonpify
from .controllers import authenticate, authorize, update, oauth_callback, setup_oauth_apps, resolve_username, get_profile_b... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/auth-6",
"path": "/auth/blueprint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> username = request.values.get('username')
return jsonpify(get_profile_by_username_controller(username))
# Register routes
blueprint.add_url_rule(
'check', 'check', check_, methods=['GET'])
blueprint.add_url_rule(
'update', 'update', update_, methods=['POST'])
... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/auth-6",
"path": "/auth/blueprint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> token = request.headers.get('auth-token') or request.values.get('jwt')
next_url = request.args.get('next', 'http://example.com')
return jsonpify(authenticate_controller(token, next_url, callback_url(), private_key))
def update_():
token = request.headers.get('auth-toke... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/auth-6",
"path": "/auth/blueprint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>' : 'python',
'issues_data' : issues_data,
},
}<|fim_prefix|># repo: marcinguy/checkmate path: /checkmate/contrib/plugins/python/pep8/setup.py
from .analyzer import Pep8Analyzer
from .issues_data import issues_data
analyzers = {
'pep8' :
{
'title' : <|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "marcinguy/checkmate",
"path": "/checkmate/contrib/plugins/python/pep8/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'Pep-8',
'class' : Pep8Analyzer,
'language' : 'python',
'issues_data' : issues_data,
},
}<|fim_prefix|># repo: marcinguy/checkmate path: /checkmate/contrib/plugins/python/pep8/setup.py
from .analyzer import Pep8Analyzer
from .issues_data import issues<|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "marcinguy/checkmate",
"path": "/checkmate/contrib/plugins/python/pep8/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marcinguy/checkmate path: /checkmate/contrib/plugins/python/pep8/setup.py
from .analyzer import Pep8Analyzer
from .issues_data import issues_data
analyzers = {
'pep8' :
{
'title' : <|fim_suffix|>' : 'python',
'issues_data' : issues_data,
},
}<|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "marcinguy/checkmate",
"path": "/checkmate/contrib/plugins/python/pep8/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ltoddy/leetcode path: /algorithms/reveal-cards-in-increasing-order.py
class Solution:
def deckRevealedIncreasing(self, deck):
"""
:type deck: List[int]
:rtype: L<|fim_suffix|>dge[index + 1:]
index += 1
if len(judge):
index %= len... | code_fim | hard | {
"lang": "python",
"repo": "ltoddy/leetcode",
"path": "/algorithms/reveal-cards-in-increasing-order.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>dge[index + 1:]
index += 1
if len(judge):
index %= len(judge)
return res<|fim_prefix|># repo: ltoddy/leetcode path: /algorithms/reveal-cards-in-increasing-order.py
class Solution:
def deckRevealedIncreasing(self, deck):
"""
:type deck: L... | code_fim | hard | {
"lang": "python",
"repo": "ltoddy/leetcode",
"path": "/algorithms/reveal-cards-in-increasing-order.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kethan1/Data-Structures path: /Linked_List/linked_list_data_structure.py
'''
---------------------------------------------
LinkedList - My version of the class List
Author: Kethan Vegunta
---------------------------------------------
Description:
This is my version of the python list. It is a dou... | code_fim | hard | {
"lang": "python",
"repo": "kethan1/Data-Structures",
"path": "/Linked_List/linked_list_data_structure.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not isinstance(data, Node):
return Node(data)
return data
def __toData(self, data):
if isinstance(data, Node):
return data.data
return data
'''
LinkedList supports item assignments: linkedlist_var[0] = 99
This updates the item's ... | code_fim | hard | {
"lang": "python",
"repo": "kethan1/Data-Structures",
"path": "/Linked_List/linked_list_data_structure.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if pos > self.GetLength() or pos < 0 or self.GetLength() == 0:
raise IndexError("delete index out of range")
elif pos == 0:
self.deleteAtBeginning()
elif pos == self.GetLength():
self.deleteAtEnd()
else:
self.current = self.he... | code_fim | hard | {
"lang": "python",
"repo": "kethan1/Data-Structures",
"path": "/Linked_List/linked_list_data_structure.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with pytest.raises(ValueError):
role_str = join_role('role', ['a', '*'])
class TestRoles:
def test_init(self):
roles = Roles(ROLES_STR)
assert ROLE_1_STR in roles
assert ROLE_2_STR in roles
assert ROLE_3_STR in roles
assert 'fail' not in roles
... | code_fim | hard | {
"lang": "python",
"repo": "W-DEJONG/id-roles",
"path": "/tests/test_roles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: W-DEJONG/id-roles path: /tests/test_roles.py
import pytest
from id_roles.roles import Roles, split_role, join_role
ROLE_1_STR = 'role_1:sub-role_1'
ROLE_2_STR = 'role_2'
ROLE_3_STR = 'role_3'
ROLES_STR = 'role_1:sub-role_1[v1,v2] role_2[*] role_3'
@pytest.fixture()
def roles_obj():
return... | code_fim | hard | {
"lang": "python",
"repo": "W-DEJONG/id-roles",
"path": "/tests/test_roles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iamshb/python_samples path: /crawling/urllib_parse_urljoin.py
from urllib.parse import urljoin
<|fim_suffix|>print(urljoin(baseUrl, 'b.html'))
print(urljoin(baseUrl, '../index.html'))
print(urljoin(baseUrl, '../img/image.jpg'))<|fim_middle|>baseUrl = 'http://test.com/html/a.html'
| code_fim | easy | {
"lang": "python",
"repo": "iamshb/python_samples",
"path": "/crawling/urllib_parse_urljoin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(urljoin(baseUrl, 'b.html'))
print(urljoin(baseUrl, '../index.html'))
print(urljoin(baseUrl, '../img/image.jpg'))<|fim_prefix|># repo: iamshb/python_samples path: /crawling/urllib_parse_urljoin.py
from urllib.parse import urljoin
<|fim_middle|>baseUrl = 'http://test.com/html/a.html'
| code_fim | easy | {
"lang": "python",
"repo": "iamshb/python_samples",
"path": "/crawling/urllib_parse_urljoin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IgorQueiroz32/Data_Glacier path: /final_project/deploy_streamlit/deploy.py
import pickle
import numpy as np
import streamlit as st
from sklearn.preprocessing import robust_scale
# loading the trained model
pickle_in = open('model/model_classification.pkl', 'rb')
classifier = pickle.load(p... | code_fim | hard | {
"lang": "python",
"repo": "IgorQueiroz32/Data_Glacier",
"path": "/final_project/deploy_streamlit/deploy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # defining Concom_Macrolides_And_Similar_Types
Concom_Macrolides_And_Similar_Types = st.checkbox('Concom_Macrolides_And_Similar_Types')
if Concom_Macrolides_And_Similar_Types:
Concom_Macrolides_And_Similar_Types = 1
else:
Concom_Macrolides_And_Similar_Types = 0
... | code_fim | hard | {
"lang": "python",
"repo": "IgorQueiroz32/Data_Glacier",
"path": "/final_project/deploy_streamlit/deploy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Yuhan-Wg/massive-data-mining path: /python/test/recommender.py
import unittest
class TestRecommenderSystem(unittest.TestCase):
def test_consistency_neighborhood_based_with_random_data(self):
from datming.recommender import ItemBasedCF, UserBasedCF
from pyspark import SparkCo... | code_fim | hard | {
"lang": "python",
"repo": "Yuhan-Wg/massive-data-mining",
"path": "/python/test/recommender.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> result4 = (
ItemBasedCF(k=2, n_user_block=10, n_cross_block=10, n_item_block=10, maximum_num_partitions=10,
threshold=0.01, n_bands=100, signature_length=200, seed=0)
.fit_predict(train_data, test_data)
)
self.assertLessEqual(
... | code_fim | hard | {
"lang": "python",
"repo": "Yuhan-Wg/massive-data-mining",
"path": "/python/test/recommender.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: atulmkamble/100DaysOfCode path: /Day 8 - Caesar Cipher/caesar_cipher.py
"""
This program encodes/decodes text given to it as an input.
It takes three arguments as an input:
1. Action: Encode/Decode
1. Text to be encoded/decoded
2. Shift value (The value by which the alphabets will be shifted)
"""... | code_fim | hard | {
"lang": "python",
"repo": "atulmkamble/100DaysOfCode",
"path": "/Day 8 - Caesar Cipher/caesar_cipher.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Exit the program if user does not want to continue
if response == 'no':
go_again = False
print('Thank you for using this program.')
# Time Tracking End
toc1 = perf_counter()
toc2 = process_time()
# Print execution time
print('\nExecution Time Details:')
print(f'Total execution ... | code_fim | hard | {
"lang": "python",
"repo": "atulmkamble/100DaysOfCode",
"path": "/Day 8 - Caesar Cipher/caesar_cipher.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @use_profile('postgres')
def test_postgres_simple_seed(self):
# first make sure nobody "fixed" the file by accident
seed_path = os.path.join(self.config.data_paths[0], 'seed_bom.csv')
# 'data-bom/seed_bom.csv'
with open(seed_path, encoding='utf-8') as fp:
... | code_fim | hard | {
"lang": "python",
"repo": "better/dbt",
"path": "/test/integration/005_simple_seed_test/test_simple_seed.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: better/dbt path: /test/integration/005_simple_seed_test/test_simple_seed.py
import os
from test.integration.base import DBTIntegrationTest, use_profile
class TestSimpleSeed(DBTIntegrationTest):
def setUp(self):
DBTIntegrationTest.setUp(self)
self.run_sql_file("seed.sql")
... | code_fim | hard | {
"lang": "python",
"repo": "better/dbt",
"path": "/test/integration/005_simple_seed_test/test_simple_seed.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @use_profile('postgres')
def test_postgres_simple_seed_with_schema(self):
schema_name = self.custom_schema_name()
results = self.run_dbt(["seed"])
self.assertEqual(len(results), 1)
self.assertTablesEqual("seed_actual","seed_expected", table_a_schema=schema_name)
... | code_fim | hard | {
"lang": "python",
"repo": "better/dbt",
"path": "/test/integration/005_simple_seed_test/test_simple_seed.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bloomdt-uw/pyAFQ path: /AFQ/tests/test_api.py
files recognized by pyBIDS"
+ " in the pipeline: missingPipe"):
api.AFQ(bids_path, dmriprep="missingPipe")
@pytest.mark.nightly_custom
def test_AFQ_custom_tract():
"""
Test whether AFQ can use tractography from
custom... | code_fim | hard | {
"lang": "python",
"repo": "bloomdt-uw/pyAFQ",
"path": "/AFQ/tests/test_api.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Requires large download
@pytest.mark.nightly
def test_AFQ_FA():
"""
Test if API can run registeration with FA
"""
_, bids_path, _ = get_temp_hardi()
myafq = api.AFQ(
bids_path=bids_path,
dmriprep='vistasoft',
reg_template='dti_fa_template',
reg_subjec... | code_fim | hard | {
"lang": "python",
"repo": "bloomdt-uw/pyAFQ",
"path": "/AFQ/tests/test_api.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bloomdt-uw/pyAFQ path: /AFQ/tests/test_api.py
data = np.ones((10, 10, 10, 6))
bvecs = np.vstack([np.eye(3), np.eye(3)])
bvecs[0] = 0
bvals = np.ones(6) * 1000.
bvals[0] = 0
if session is None:
data_dir = subject
else:
data_dir = op.join(subject, session)
... | code_fim | hard | {
"lang": "python",
"repo": "bloomdt-uw/pyAFQ",
"path": "/AFQ/tests/test_api.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def ll_shrink_final(ll_builder):
final_size = ll_builder.current_pos
ll_assert(final_size <= ll_builder.total_size,
"final_size > ll_builder.total_size?")
buf = rgc.ll_shrink_array(ll_builder.current_buf, final_size)
ll_builder.current_buf = buf
ll_builder.current_end = f... | code_fim | hard | {
"lang": "python",
"repo": "mesalock-linux/mesapy",
"path": "/rpython/rtyper/lltypesystem/rbuilder.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mesalock-linux/mesapy path: /rpython/rtyper/lltypesystem/rbuilder.py
gBuilderRepr
from rpython.tool.sourcetools import func_with_new_name
from rpython.rtyper.annlowlevel import llstr, llunicode
# ------------------------------------------------------------
# Basic idea:
#
# - A StringBuilder h... | code_fim | hard | {
"lang": "python",
"repo": "mesalock-linux/mesapy",
"path": "/rpython/rtyper/lltypesystem/rbuilder.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mesalock-linux/mesapy path: /rpython/rtyper/lltypesystem/rbuilder.py
r_repr,
string_repr, unichar_repr, unicode_repr)
from rpython.rtyper.rbuilder import AbstractStringBuilderRepr
from rpython.tool.sourcetools import func_with_new_name
from rpython.rtyper.annlowlevel import llstr, llunicode
... | code_fim | hard | {
"lang": "python",
"repo": "mesalock-linux/mesapy",
"path": "/rpython/rtyper/lltypesystem/rbuilder.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_private_key_set():
"""Test private key is set"""
loop = asyncio.get_event_loop()
with aioresponses() as m:
m.post('https://api.idex.market/returnNextNonce', payload=nonce_res, status=200)
m.post('https://api.idex.market/cancel', payload=json_res, status=200)
... | code_fim | medium | {
"lang": "python",
"repo": "driscollco/python-idex",
"path": "/asynctests/test_private_key_exception.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop = asyncio.get_event_loop()
with aioresponses() as m:
m.post('https://api.idex.market/returnNextNonce', payload=nonce_res, status=200)
m.post('https://api.idex.market/cancel', payload=json_res, status=200)
async def _run_test():
client = await AsyncClient.c... | code_fim | hard | {
"lang": "python",
"repo": "driscollco/python-idex",
"path": "/asynctests/test_private_key_exception.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: driscollco/python-idex path: /asynctests/test_private_key_exception.py
#!/usr/bin/env python
# coding=utf-8
import asyncio
import pytest
from aioresponses import aioresponses
from idex.asyncio import AsyncClient
from idex.exceptions import IdexException, IdexPrivateKeyNotFoundException
json_res... | code_fim | hard | {
"lang": "python",
"repo": "driscollco/python-idex",
"path": "/asynctests/test_private_key_exception.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lakshyarawal/pythonPractice path: /Binary Search Tree/top_view.py
"""Traversing and printing all nodes from a Top View in a Binary Tree """
from collections import deque
from sortedcollections import SortedDict
class Node:
def __init__(self, val):
self.key = val
self.left = ... | code_fim | medium | {
"lang": "python",
"repo": "lakshyarawal/pythonPractice",
"path": "/Binary Search Tree/top_view.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> q1 = deque()
if root_n is not None:
q1.append([root_n, 0])
while len(q1) > 0:
curr_size = len(q1)
i = 0
while i < curr_size:
cur_node, j = q1.popleft()
if j not in sum_map.keys():
sum_map[j] = [cur_node.key]
if... | code_fim | medium | {
"lang": "python",
"repo": "lakshyarawal/pythonPractice",
"path": "/Binary Search Tree/top_view.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dimagi/commcare-hq path: /corehq/apps/reports/formdetails/readable.py
import re
from copy import deepcopy
from pydoc import html
from django.http import Http404
from django.utils.safestring import mark_safe
from django.utils.translation import gettext_lazy as _
from couchdbkit import ResourceNo... | code_fim | hard | {
"lang": "python",
"repo": "dimagi/commcare-hq",
"path": "/corehq/apps/reports/formdetails/readable.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def absolute_path_from_context(path, path_context):
assert path_context.endswith('/')
if path.startswith('/'):
return path
else:
return path_context + path
def _html_interpolate_output_refs(itext_value, context):
if hasattr(itext_value, 'with_refs'):
underline_te... | code_fim | hard | {
"lang": "python",
"repo": "dimagi/commcare-hq",
"path": "/corehq/apps/reports/formdetails/readable.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hellc/elasticsearch-fias path: /fiases/house_upd.py
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from tqdm import trange, tqdm
from xml.dom import pulldom
from lxml import etree
from xml.dom.pulldom import parse
from elasticsearch.helpers import parallel_bulk
# Local modules:
from fiases.fias_... | code_fim | hard | {
"lang": "python",
"repo": "hellc/elasticsearch-fias",
"path": "/fiases/house_upd.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> else:
for ok, info in parallel_bulk(fiases.fias_data.ES, updateIndex(),
raise_on_error=False,
raise_on_exception=False):
# ADDR_CNT = ADDR_CNT + 1
if (not ok):
print(ok, info)
... | code_fim | hard | {
"lang": "python",
"repo": "hellc/elasticsearch-fias",
"path": "/fiases/house_upd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ADDR_CNT = 0
if IS_DEBUG:
for ok, info in tqdm(parallel_bulk(fiases.fias_data.ES, updateIndex(),
raise_on_error=False,
raise_on_exception=False),
unit=' house',
... | code_fim | hard | {
"lang": "python",
"repo": "hellc/elasticsearch-fias",
"path": "/fiases/house_upd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cessor/substitute path: /test/test_verify_calls_with_keyword_arguments.py
from nose.tools import *
from substitute import *
from substitute.complaint import *
expect_that = assert_true
# arg = Argument
# kwarg = Keyword Argument
# kwargs by names & values
def test_expect_received_kwarg... | code_fim | hard | {
"lang": "python",
"repo": "cessor/substitute",
"path": "/test/test_verify_calls_with_keyword_arguments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Substitute - Verify (kwargs): Method was called without any kwargs (type)'''
component = Substitute()
component.method('Joseph')
expect_that(component.method.received_any(name=str))
@raises(MissingKeywordArgumentComplaint)
def test_expect_received_wrong_kwarg_type_fails_2():
... | code_fim | hard | {
"lang": "python",
"repo": "cessor/substitute",
"path": "/test/test_verify_calls_with_keyword_arguments.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.