text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> def metric_increment(bias, received, codeword):
# Binary codewords
assert all(z in [0,1] for z in received.flatten())
d = hamming_distance(received, codeword)
return d * np.log2(p) + (n - d) * np.log2(1 - p) \
+ (1 - bias) * n
return metric_incremen... | code_fim | hard | {
"lang": "python",
"repo": "eliasrg/SURF2017",
"path": "/code/separate/coding/convolutional/stack.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eliasrg/SURF2017 path: /code/separate/coding/convolutional/stack.py
# Copyright (c) 2017 Elias Riedel Gårding
# Licensed under the MIT License
from .node import Node
from utilities import hamming_distance, memoized
from distributions import gaussian
import numpy as np
import scipy.stats as stat... | code_fim | hard | {
"lang": "python",
"repo": "eliasrg/SURF2017",
"path": "/code/separate/coding/convolutional/stack.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def confirm(self, id_, data=None, **options):
url = self._get_url(id_, "confirm")
return self._post(url, data, **options)<|fim_prefix|># repo: Nicerova7/culqi-python path: /culqi/resources/order.py
from ..utils.urls import URL
from .base import Resource
from ..schemas import order
__... | code_fim | easy | {
"lang": "python",
"repo": "Nicerova7/culqi-python",
"path": "/culqi/resources/order.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nicerova7/culqi-python path: /culqi/resources/order.py
from ..utils.urls import URL
from .base import Resource
from ..schemas import order
__all__ = ["Order"]
class Order(Resource):
schema = order.SCHEMA
endpoint = URL.ORDER
<|fim_suffix|> url = self._get_url(id_, "confirm")
... | code_fim | easy | {
"lang": "python",
"repo": "Nicerova7/culqi-python",
"path": "/culqi/resources/order.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZSAIm/TakeTheCourse_GDUT path: /captcha/inference.py
import tensorflow as tf
# INPUT_NODE = 140 * 60
BATCH_SIZE = 100
NUM_CHANNELS = 1
# NUM_LABELS = 24*4
OUTPUT_NODE = 24*4
CONV1_DEEP = 32
CONV1_SIZE = 5
CONV2_DEEP = 64
CONV2_SIZE = 5
CONV3_DEEP = 128
CONV3_SIZE = 5
CONV4_DEEP = 256
CONV4_... | code_fim | hard | {
"lang": "python",
"repo": "ZSAIm/TakeTheCourse_GDUT",
"path": "/captcha/inference.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fc1_biases = tf.get_variable('bias', [FC_SIZE], initializer=tf.constant_initializer(0.1))
fc1 = tf.nn.relu(tf.matmul(reshaped, fc1_weights) + fc1_biases)
if train:
fc1 = tf.nn.dropout(fc1, 0.50)
with tf.variable_scope('layer8-fc2'):
fc2_weights = tf.get_v... | code_fim | hard | {
"lang": "python",
"repo": "ZSAIm/TakeTheCourse_GDUT",
"path": "/captcha/inference.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with tf.variable_scope('layer5-conv3'):
conv3_weights = tf.get_variable('weight', [CONV3_SIZE, CONV3_SIZE, CONV2_DEEP, CONV3_DEEP])
conv3_biases = tf.get_variable('bias', [CONV3_DEEP], initializer=tf.constant_initializer(0.0))
# conv3 = tf.nn.conv2d(pool2, conv3_weights, strid... | code_fim | hard | {
"lang": "python",
"repo": "ZSAIm/TakeTheCourse_GDUT",
"path": "/captcha/inference.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ystem("python manage.py create_cars 3")<|fim_prefix|># repo: tsaklidis/car-service-monitor path: /some_data.py
import os
os.system("echo '[info] Lazy data dump started...'")
os.system("p<|fim_middle|>ython manage.py create_owners 7")
os.s | code_fim | easy | {
"lang": "python",
"repo": "tsaklidis/car-service-monitor",
"path": "/some_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tsaklidis/car-service-monitor path: /some_data.py
import os
os.system("echo '[info] Laz<|fim_suffix|>ystem("python manage.py create_cars 3")<|fim_middle|>y data dump started...'")
os.system("python manage.py create_owners 7")
os.s | code_fim | medium | {
"lang": "python",
"repo": "tsaklidis/car-service-monitor",
"path": "/some_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PROBOYX/javes3.0 path: /userbot/modules/javes 3.0.py
from math import ceil
from userbot import tebot as tgbot
from userbot import bot as borg
import requests
from userbot import CMD_HELP, BOTLOG, BOTLOG_CHATID,client
from telethon import Button, custom, events, functions
@tgbot.on(events.In... | code_fim | hard | {
"lang": "python",
"repo": "PROBOYX/javes3.0",
"path": "/userbot/modules/javes 3.0.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>k', 'back'),Button.inline('❌ Close menu', b'close')],] )
await event.answer([resultm])
return
if not event.query.user_id == me.id:
resultm = builder.article(title="me not your bot",description="Mind Your Business",text="Hey U Must Use https://github.com/Sh1vam/javes... | code_fim | hard | {
"lang": "python",
"repo": "PROBOYX/javes3.0",
"path": "/userbot/modules/javes 3.0.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # No token for auth endpoint
response = client.get("/auth")
assert response.text == 'Forbidden'
assert response.status_code == 403
# Without prefix
response = client.get("/auth",
headers=dict(Authorization=jwt.encode(dict(username="user"), secret_key, alg... | code_fim | hard | {
"lang": "python",
"repo": "mauritsvdvijgh/starlette-jwt",
"path": "/tests/test_middleware.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Without prefix
response = client.get("/auth",
headers=dict(Authorization=jwt.encode(dict(username="user"), secret_key, algorithm='HS256').decode()))
assert response.text == 'Could not separate Authorization scheme and token'
assert response.status_code == 400
... | code_fim | hard | {
"lang": "python",
"repo": "mauritsvdvijgh/starlette-jwt",
"path": "/tests/test_middleware.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mauritsvdvijgh/starlette-jwt path: /tests/test_middleware.py
from starlette.applications import Starlette
from starlette_jwt import JWTAuthenticationBackend, JWTUser
from starlette.responses import JSONResponse
from starlette.testclient import TestClient
from starlette.middleware.authentication i... | code_fim | hard | {
"lang": "python",
"repo": "mauritsvdvijgh/starlette-jwt",
"path": "/tests/test_middleware.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
definition = """
Name Type P20_length std.deviation P10_length std.deviation Interdomain std.deviation
Metacaspase I 147 2.3 97.6 30 28.6 4.7
Metacaspase II 144.5 0.5 81.6 2.9 161 32
Metacaspase III 147 1.2 95.5 4 0 0
MLP 152 20.5 0 0 0 0
"""<|fim_prefix|># repo: caspa... | code_fim | easy | {
"lang": "python",
"repo": "caspase-like-homolog-identifier/c14_witcher",
"path": "/definition.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: caspase-like-homolog-identifier/c14_witcher path: /definition.py
class CaspaseLikeDefinition(object):
<|fim_suffix|>
if __name__ == "__main__":
definition = """
Name Type P20_length std.deviation P10_length std.deviation Interdomain std.deviation
Metacaspase I 147 2.3 97.6 30 28.6... | code_fim | easy | {
"lang": "python",
"repo": "caspase-like-homolog-identifier/c14_witcher",
"path": "/definition.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
definition = """
Name Type P20_length std.deviation P10_length std.deviation Interdomain std.deviation
Metacaspase I 147 2.3 97.6 30 28.6 4.7
Metacaspase II 144.5 0.5 81.6 2.9 161 32
Metacaspase III 147 1.2 95.5 4 0 0
MLP 152 20.5 0 0 0 0
"""<|fim_prefix|># repo: c... | code_fim | easy | {
"lang": "python",
"repo": "caspase-like-homolog-identifier/c14_witcher",
"path": "/definition.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dom8509/libcumffa path: /test/performance/PerformanceDataLogger.py
# cubffa (CUda Binary Finite Field Arithmetic library) provides
# functions for large binary galois field arithmetic on GPUs.
# Besides CUDA it is also possible to extend cubffa to any other
# underlying framework.
# Copyright (C)... | code_fim | hard | {
"lang": "python",
"repo": "dom8509/libcumffa",
"path": "/test/performance/PerformanceDataLogger.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.__con.row_factory = lambda cursor, row: row[0]
self.__con.text_factory = str
cur = self.__con.cursor()
header = ["Function", "Metric", "Bits", "Invocations", "Min", "Max", "Avg"]
table = PrettyTable(header)
functions = cur.execute("select FUNC_NAME from RES_METRIC_TEST GROUP BY FUNC_... | code_fim | hard | {
"lang": "python",
"repo": "dom8509/libcumffa",
"path": "/test/performance/PerformanceDataLogger.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mdolab/pygeo path: /pygeo/parameterization/DVGeoESP.py
maxproc=None,
suppress_stdout=False,
exclude_edge_projections=False,
ulimits=None,
vlimits=None,
name=None,
):
if not ocsmImported:
raise ImportError("OCSM and pyOCSM must be ... | code_fim | hard | {
"lang": "python",
"repo": "mdolab/pygeo",
"path": "/pygeo/parameterization/DVGeoESP.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for faceIndex in range(1, nFaces + 1):
with stdout_redirected(self.suppress_stdout):
# get the projected points on the ESP surface in UV coordinates
uvtemp = self.espModel.GetUV(bodyIndex, ocsm.FACE, faceIndex, 1, truexyz.... | code_fim | hard | {
"lang": "python",
"repo": "mdolab/pygeo",
"path": "/pygeo/parameterization/DVGeoESP.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _updateModel(self):
"""
Sets design parameters in ESP to the correct value then rebuilds the model.
"""
# for each design variable in the dictionary:
# loop through rows and cols setting design paramter values
for dvName in self.DVs:
dv =... | code_fim | hard | {
"lang": "python",
"repo": "mdolab/pygeo",
"path": "/pygeo/parameterization/DVGeoESP.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: borismarin/org.geppetto.python path: /tests/test_json_to_py.py
from geppetto.model import GeppettoModel
from mock import Mock
at0 = {'name': 'anontype1'}
at1 = {'name': 'anontype2'}
var0 = {'name': 'var1_type1_lib_1'}
var1 = {'name': 'var2_type1_lib1', 'anonymousTypes': [at0, at1]}
lib0_type0 = ... | code_fim | hard | {
"lang": "python",
"repo": "borismarin/org.geppetto.python",
"path": "/tests/test_json_to_py.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_referencing():
for obj in refs_types.values():
assert round_ref(obj) == obj
for ref in refs_types:
assert round_ref2(ref) == ref<|fim_prefix|># repo: borismarin/org.geppetto.python path: /tests/test_json_to_py.py
from geppetto.model import GeppettoModel
from mock import ... | code_fim | hard | {
"lang": "python",
"repo": "borismarin/org.geppetto.python",
"path": "/tests/test_json_to_py.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rectory-school/rectory-apps-legacy path: /academics/managers.py
import logging
from django.db import models
import academics.models
logger = logging.getLogger(__name__)
class AcademicYearManager(models.Manager):
<|fim_suffix|> def get_queryset(self):
return super(EnrollmentManager,... | code_fim | hard | {
"lang": "python",
"repo": "rectory-school/rectory-apps-legacy",
"path": "/academics/managers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class EnrollmentManager(models.Manager):
def get_queryset(self):
return super(EnrollmentManager, self).get_queryset().select_related('student', 'academic_year')<|fim_prefix|># repo: rectory-school/rectory-apps-legacy path: /academics/managers.py
import logging
from django.db import models
i... | code_fim | medium | {
"lang": "python",
"repo": "rectory-school/rectory-apps-legacy",
"path": "/academics/managers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@when('{attacker} attacks {defender}')
def step_impl(context, attacker, defender):
a = getattr(context, attacker)
d = getattr(context, defender)
attack(a, d)
@then('defense of {name} goes down to 40')
def step_impl(context, name):
p = getattr(context, name)
assert p.defense == 4... | code_fim | hard | {
"lang": "python",
"repo": "euribates/bdd-intro",
"path": "/features/steps/pokemons.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: euribates/bdd-intro path: /features/steps/pokemons.py
import pytest
from behave import *
from models import Pokemon, attack
@given('pokemon {name} with {attack:d} attack')
def step_impl(context, name, attack):
setattr(context, name, Pokemon(name, attack=attack))
@given('pokemon {name} with... | code_fim | medium | {
"lang": "python",
"repo": "euribates/bdd-intro",
"path": "/features/steps/pokemons.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ptype = (p.ip_object.io_bits & 0x7fff0000) >> 16
if ptype != 0: ## don't bother with port sets
continue
## If the port that's in-transit has messages already enqueued,
## go through each of those messages and look for more ports!
if p.ip_messages.data.p... | code_fim | hard | {
"lang": "python",
"repo": "jayhe/objc4_debug",
"path": "/objc4-756.2/编译素材/xnu-4903.241.1/tools/lldbmacros/ipc.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jayhe/objc4_debug path: /objc4-756.2/编译素材/xnu-4903.241.1/tools/lldbmacros/ipc.py
}".format(ie_port_callstack[0])
count = 1
while count < 16 and ie_port_callstack[count]:
out_str += ": <10x".format(ie_port_callstack[count])
count = count + 1
if ie_po... | code_fim | hard | {
"lang": "python",
"repo": "jayhe/objc4_debug",
"path": "/objc4-756.2/编译素材/xnu-4903.241.1/tools/lldbmacros/ipc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jayhe/objc4_debug path: /objc4-756.2/编译素材/xnu-4903.241.1/tools/lldbmacros/ipc.py
f the location of the descriptor count to get this correct
body = Cast(addressof(Cast(addressof(kmsgh), 'char *')[sizeof(kmsgh)]), 'mach_msg_body_t *')
#dsc_count = body.msgh_descriptor_count
dsc_count = ... | code_fim | hard | {
"lang": "python",
"repo": "jayhe/objc4_debug",
"path": "/objc4-756.2/编译素材/xnu-4903.241.1/tools/lldbmacros/ipc.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danziy0904/codes_repository path: /2019_dcase_task1_hy_BC/utils/features.py
import os
import sys
sys.path.insert(1, os.path.join(sys.path[0], 'utils'))
import numpy as np
import pandas as pd
import argparse
import h5py
import librosa
from scipy import signal
import time
import csv
# from torch i... | code_fim | hard | {
"lang": "python",
"repo": "danziy0904/codes_repository",
"path": "/2019_dcase_task1_hy_BC/utils/features.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> audio_names = [audio_names[idx] for idx in audio_indexes]
if data_type == 'development':
scene_labels = [scene_labels[idx] for idx in audio_indexes]
identifiers = [identifiers[idx] for idx in audio_indexes]
source_labels = [source_labels[idx] for idx in... | code_fim | hard | {
"lang": "python",
"repo": "danziy0904/codes_repository",
"path": "/2019_dcase_task1_hy_BC/utils/features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>A = {-2, 10, 40, 20}
B = {-2, 10}
print(B.issubset(A))<|fim_prefix|># repo: PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch path: /29. Operations on sets/set.py
"""
unique | order | changing specific el. | new elements
LISTS N Y Y Y
TU... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch",
"path": "/29. Operations on sets/set.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch path: /29. Operations on sets/set.py
"""
unique | order | changing specific el. | new elements
LISTS N Y Y Y
TUPLES N Y N N
DICT ... | code_fim | medium | {
"lang": "python",
"repo": "PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch",
"path": "/29. Operations on sets/set.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> run_test(question)
a=input("TYPE 'yes' to see correct ANSWERS ")
b=a.lower()
if b=="yes":
print('\n------CORRECT ANSWERS-------')
print("\nQ1.b) Guido van Rossum\nQ2.b) type'type'\nQ3.c) abcd\nQ4.a) 48\nQ5.d) Method\n")
print('THANKS FOR ATTENDING ... | code_fim | hard | {
"lang": "python",
"repo": "a-dera/awesome-python-projects",
"path": "/QUIZ APP/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: a-dera/awesome-python-projects path: /QUIZ APP/app.py
from Question import Question
print('----------------------------')
print(' QUIZ ')
print('----------------------------')
print('INSTRUCTIONS\n(1) Quiz consists of 5 questions.\n(2) Each question will have 4 options (... | code_fim | hard | {
"lang": "python",
"repo": "a-dera/awesome-python-projects",
"path": "/QUIZ APP/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def test_create(self):
obj0 = await testmodels.EnumFields.create(service=testmodels.Service.system_administration)
self.assertIsInstance(obj0.currency, testmodels.Currency)
obj = await testmodels.EnumFields.get(id=obj0.id)
self.assertIsInstance(obj.currency, testm... | code_fim | hard | {
"lang": "python",
"repo": "tortoise/tortoise-orm",
"path": "/tests/fields/test_enum.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def test_values(self):
obj0 = await testmodels.EnumFields.create(
service=testmodels.Service.system_administration, currency=testmodels.Currency.EUR
)
values = await testmodels.EnumFields.get(id=obj0.id).values("currency")
self.assertEqual(values["curr... | code_fim | hard | {
"lang": "python",
"repo": "tortoise/tortoise-orm",
"path": "/tests/fields/test_enum.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tortoise/tortoise-orm path: /tests/fields/test_enum.py
from enum import IntEnum
from tests import testmodels
from tortoise.contrib import test
from tortoise.exceptions import ConfigurationError, IntegrityError
from tortoise.fields import CharEnumField, IntEnumField
class BadIntEnum1(IntEnum):
... | code_fim | hard | {
"lang": "python",
"repo": "tortoise/tortoise-orm",
"path": "/tests/fields/test_enum.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: salotz/jubeo path: /src/jubeo/main.py
import sys
from pathlib import Path
import pkgutil
import shutil
import os
import os.path as osp
import dataclasses as dc
from typing import (
Tuple,
Optional,
)
import toml
from hyperlink import URL
from git import Repo
JUBEO_PROJ_DIR = ".jubeo"
J... | code_fim | hard | {
"lang": "python",
"repo": "salotz/jubeo",
"path": "/src/jubeo/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> source,
target,
config,
force=True,
):
"""Update the taskset for this project.
Parameters
----------
source : Path
The task-set repository to copy from.
target : Path
The target task-set to update.
"""
source = Path(source)
... | code_fim | hard | {
"lang": "python",
"repo": "salotz/jubeo",
"path": "/src/jubeo/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # pack the extracted features into a pandas dataframe
feature_df_raw = defaultdict(list)
keys = [set(fd.keys()) for fd in feature_dicts]
all_feats = set()
for keyset in keys:
all_feats |= keyset
for feature_dict in feature_dicts:
for ... | code_fim | hard | {
"lang": "python",
"repo": "shuaidop/Cornell-Conversational-Analysis-Toolkit",
"path": "/convokit/politenessStrategies.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shuaidop/Cornell-Conversational-Analysis-Toolkit path: /convokit/politenessStrategies.py
"""Politeness Strategies features
See Section 4 of http://www.cs.cornell.edu/~cristian/Conversations_gone_awry.html
"""
import numpy as np
import pandas as pd
from collections import defaultdict
from .poli... | code_fim | hard | {
"lang": "python",
"repo": "shuaidop/Cornell-Conversational-Analysis-Toolkit",
"path": "/convokit/politenessStrategies.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # use the bundled politeness API to extract politeness features for each
# preprocessed comment
if self.verbose: print("Extracting politeness strategies...")
feature_dicts = [get_politeness_strategy_features(doc) for doc in processed_comments]
# pack the extracted ... | code_fim | hard | {
"lang": "python",
"repo": "shuaidop/Cornell-Conversational-Analysis-Toolkit",
"path": "/convokit/politenessStrategies.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def UserAttendance(activity, contacts, attended):
"""Records user attendance for an activity.
Args:
activity: models.Activity to register attendance for.
contacts: Comma separated list of emails.
attended: String 'True' or 'False' indicating attendance.
Returns:
Dictionary of {ema... | code_fim | hard | {
"lang": "python",
"repo": "silpol/cloudcourse",
"path": "/core/ajax_impl.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: silpol/cloudcourse path: /core/ajax_impl.py
#!/usr/bin/python2.4
# Copyright 2009 Google Inc. All Rights Reserved.
#
# 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": "silpol/cloudcourse",
"path": "/core/ajax_impl.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 0x1d00ffff/0xbtc-discord-price-bot path: /uniswap/token.py
from dataclasses import dataclass
from .types import AddressLike
@dataclass
class BaseToken:
"""Base for tokens of all kinds"""
symbol: str
"""Symbol such as ETH, DAI, etc."""
address: AddressLike
"""Address of the... | code_fim | hard | {
"lang": "python",
"repo": "0x1d00ffff/0xbtc-discord-price-bot",
"path": "/uniswap/token.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Represents an ERC20 token"""
name: str
"""Name of the token, as specified in the contract."""
decimals: int
"""Decimals used to denominate the token."""
def __repr__(self) -> str:
return f"Token({self.symbol}, {self.address!r}, {self.decimals})"<|fim_prefix|># repo: 0... | code_fim | hard | {
"lang": "python",
"repo": "0x1d00ffff/0xbtc-discord-price-bot",
"path": "/uniswap/token.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MikeWooster/jsonmarshal path: /jsonmarshal/__init__.py
from jsonmarshal.fields import json_field
f<|fim_suffix|>jsonmarshal.unmarshal import unmarshal
__all__ = ["json_field", "unmarshal", "marshal"]<|fim_middle|>rom jsonmarshal.marshal import marshal
from | code_fim | easy | {
"lang": "python",
"repo": "MikeWooster/jsonmarshal",
"path": "/jsonmarshal/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>l__ = ["json_field", "unmarshal", "marshal"]<|fim_prefix|># repo: MikeWooster/jsonmarshal path: /jsonmarshal/__init__.py
from jsonmarshal.fields import json_field
from jsonmarshal.marshal import marshal
from <|fim_middle|>jsonmarshal.unmarshal import unmarshal
__al | code_fim | easy | {
"lang": "python",
"repo": "MikeWooster/jsonmarshal",
"path": "/jsonmarshal/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dmitriy1978/SeconDOKnew path: /fixture/regHelperBillInfo.py
from model.names import info_bill
from model.elements import wait
import time
class base(object):
def __init__(self, driver):
self.driver = driver
class regHelperBillInfo(base):
inform_xpath = "//input[@id='reg_card']... | code_fim | hard | {
"lang": "python",
"repo": "Dmitriy1978/SeconDOKnew",
"path": "/fixture/regHelperBillInfo.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> inform_xpath = "//input[@id='reg_card']"
submit_add_xpath = "//div[@class='btn btn_green ng-binding']"
xpath_add = "//span[@data-name='reg_card' and contains(text(), '1234 5678 1234 5678')]"
submit_reg_xpath = "//div[@class='btn btn_green btn_reg_complet ng-binding']"
def bill_informa... | code_fim | medium | {
"lang": "python",
"repo": "Dmitriy1978/SeconDOKnew",
"path": "/fixture/regHelperBillInfo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .evaluator import *
from .space import *
from .utils import load_benchmark, download_benchmark<|fim_prefix|># repo: squirrelsc/nni path: /nni/nas/benchmark/__init__.py
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
<|fim_middle|>import warnings
try:
import peewee
excep... | code_fim | medium | {
"lang": "python",
"repo": "squirrelsc/nni",
"path": "/nni/nas/benchmark/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: squirrelsc/nni path: /nni/nas/benchmark/__init__.py
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.
<|fim_suffix|>from .evaluator import *
from .space import *
from .utils import load_benchmark, download_benchmark<|fim_middle|>import warnings
try:
import peewee
excep... | code_fim | medium | {
"lang": "python",
"repo": "squirrelsc/nni",
"path": "/nni/nas/benchmark/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_all(capsys):
create_files()
args = get_args('--all')
assert args.all
assert not args.certs
assert not args.database
assert not args.keys
assert not args.logs
assert args.root == ROOT_DIR
assert not args.quiet
assert args.yes
# execute command
ar... | code_fim | hard | {
"lang": "python",
"repo": "MSLNZ/msl-network",
"path": "/tests/test_cli_delete.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MSLNZ/msl-network path: /tests/test_cli_delete.py
import os
import shutil
import tempfile
from msl.network import cli
N = 10
ROOT_DIR = os.path.join(tempfile.gettempdir(), 'msl-io-testing')
def get_args(*args):
parser = cli.configure_parser()
command = ['delete', '--root', ROOT_DIR, '... | code_fim | hard | {
"lang": "python",
"repo": "MSLNZ/msl-network",
"path": "/tests/test_cli_delete.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> out, _ = capsys.readouterr()
assert f'{N} log file(s) will be deleted' in out
# the .log files are gone, but all other files remain
assert os.path.isfile(os.path.join(ROOT_DIR, 'manager.sqlite3'))
for i in range(N):
assert os.path.isfile(os.path.join(ROOT_DIR, 'certs', f'{i}.c... | code_fim | hard | {
"lang": "python",
"repo": "MSLNZ/msl-network",
"path": "/tests/test_cli_delete.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def getResponse(neighbors):
classVotes = {}
for x in range(len(neighbors)):
response = neighbors[x][-1]
if response in classVotes:
classVotes[response] += 1
else:
classVotes[response] = 1
sortedVotes = sorted(classVotes.iteritems(), key=operator.... | code_fim | hard | {
"lang": "python",
"repo": "arewm/TOP-python",
"path": "/Converted_Test_Cases/test_case_2_converted.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arewm/TOP-python path: /Converted_Test_Cases/test_case_2_converted.py
"""""
Converted Test Case 2 for TOP
KNN: K nearest Neighbours
Finding the K nearest neighbors for a point
Original Test Case picked from
source: https://machinelearningmastery.com/tutorial-to-implement-k-nearest-neighbors-in... | code_fim | hard | {
"lang": "python",
"repo": "arewm/TOP-python",
"path": "/Converted_Test_Cases/test_case_2_converted.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>while cont <= qt:
t3 = t1 + t2
t1 = t2
t2 = t3
print(t3, end=" • ")
cont += 1
print("FIM")<|fim_prefix|># repo: pedrohenriquebraga/Curso-Python path: /Mundo 2/Exercícios/ex_063.py
# Sequência de Fibonacci
<|fim_middle|>qt = int(input("Quantos termos você quer mostrar? "))
t1 =... | code_fim | medium | {
"lang": "python",
"repo": "pedrohenriquebraga/Curso-Python",
"path": "/Mundo 2/Exercícios/ex_063.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pedrohenriquebraga/Curso-Python path: /Mundo 2/Exercícios/ex_063.py
# Sequência de Fibonacci
qt = int(input("Quantos termos você quer mostrar? "))
t1 = 0
t2 = 1
cont = 3
<|fim_suffix|>while cont <= qt:
t3 = t1 + t2
t1 = t2
t2 = t3
print(t3, end=" • ")
cont += 1
print(... | code_fim | easy | {
"lang": "python",
"repo": "pedrohenriquebraga/Curso-Python",
"path": "/Mundo 2/Exercícios/ex_063.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(f"{t1} • {t2}", end=" • ")
while cont <= qt:
t3 = t1 + t2
t1 = t2
t2 = t3
print(t3, end=" • ")
cont += 1
print("FIM")<|fim_prefix|># repo: pedrohenriquebraga/Curso-Python path: /Mundo 2/Exercícios/ex_063.py
# Sequência de Fibonacci
qt = int(input("Quantos termos você que... | code_fim | easy | {
"lang": "python",
"repo": "pedrohenriquebraga/Curso-Python",
"path": "/Mundo 2/Exercícios/ex_063.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Forrest-Z/autobot path: /core/python/behaviors/PENALTY_BEHAVIOR.py
g):
super(BallBearing, self).__init__()
self.ball = ball
self.bearing = bearing
def ready(self):
return abs(self.ball.bearing - self.bearing) < 0.1
def BB(ball, bearing = 0.28):
"""Ball close enough"""
retur... | code_fim | hard | {
"lang": "python",
"repo": "Forrest-Z/autobot",
"path": "/core/python/behaviors/PENALTY_BEHAVIOR.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Forrest-Z/autobot path: /core/python/behaviors/PENALTY_BEHAVIOR.py
cts found"""
return ObjectSeen(*objects)
def NO(*objects):
"""Not true that all objects found"""
return NegationEvent(ObjectSeen(*objects))
class ObjectOrSeen(Event):
"""Event that fires when all the objects passed to th... | code_fim | hard | {
"lang": "python",
"repo": "Forrest-Z/autobot",
"path": "/core/python/behaviors/PENALTY_BEHAVIOR.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(GoToBall, self).__init__()
self.ball = ball
self.dist = dist
self.k_t = (0.7, 0.01, 0.1)
self.k_d = (0.001, 0.0001, 0.0001)
self.theta_integral = 0.0
self.theta_prev = 0.0
self.dist_integral = 0.0
self.dist_prev = 0.0
self.time_last = time.clock()
self.tim... | code_fim | hard | {
"lang": "python",
"repo": "Forrest-Z/autobot",
"path": "/core/python/behaviors/PENALTY_BEHAVIOR.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if (
"use_legacy_format"
in inspect.getfullargspec(tf.keras.layers.serialize).args
):
return tf.keras.layers.serialize(layer, use_legacy_format=use_legacy_format)
else:
return tf.keras.layers.serialize(layer)
def deserialize_layer(config, use_legacy_format=False):
if (
... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/model-optimization",
"path": "/tensorflow_model_optimization/python/core/quantization/keras/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: onnx/onnx path: /onnx/reference/ops/op_unsqueeze.py
# Copyright (c) ONNX Project Contributors
# SPDX-License-Identifier: Apache-2.0
# pylint: disable=E0203,W0221
import numpy as np
from onnx.reference.op_run import OpRun
class Unsqueeze_1(OpRun):
def _run(self, data, axes=None): # type:... | code_fim | hard | {
"lang": "python",
"repo": "onnx/onnx",
"path": "/onnx/reference/ops/op_unsqueeze.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if axes is not None:
if hasattr(axes, "__iter__") and len(axes.shape) > 0:
try:
sq = np.expand_dims(data, axis=tuple(axes))
except TypeError:
# numpy 1.18 supports axes as a tuple
if len(axes) =... | code_fim | hard | {
"lang": "python",
"repo": "onnx/onnx",
"path": "/onnx/reference/ops/op_unsqueeze.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Unsqueeze_11(Unsqueeze_1):
pass
class Unsqueeze_13(OpRun):
def _run(self, data, axes=None): # type: ignore
if axes is not None:
if hasattr(axes, "__iter__") and len(axes.shape) > 0:
try:
sq = np.expand_dims(data, axis=tuple(axes))
... | code_fim | hard | {
"lang": "python",
"repo": "onnx/onnx",
"path": "/onnx/reference/ops/op_unsqueeze.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(retrieve_rotations)
print(torch.abs(retrieve_rotations[0][0]-retrieve_rotations[1][0]).sum())
return retrieve_rotations
if __name__ == '__main__':
device = torch.device('cuda', 0)
smpl = SMPL(args.smpl_model, joint_type = 'lsp', obj_saveable = True).to(device)
#i... | code_fim | hard | {
"lang": "python",
"repo": "DianaTaukin/DSD-SATN",
"path": "/src/utils/SMPL.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DianaTaukin/DSD-SATN path: /src/utils/SMPL.py
#encoding=utf-8
import torch
import sys
import os
sys.path.append(os.path.abspath(__file__).replace(os.path.basename(__file__),'').replace('utils/',''))
from config import args
import json
import sys
import numpy as np
from utils.util import *
import ... | code_fim | hard | {
"lang": "python",
"repo": "DianaTaukin/DSD-SATN",
"path": "/src/utils/SMPL.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if get_org_joints:
return verts, self.J_transformed, Rs
if get_skin:
return verts, joints, Rs
else:
return joints
def reverse_derive_rotation(self, beta, param, rotated_kp3d_org = None):
def make_A(R, t):
R_homo = F.pad(... | code_fim | hard | {
"lang": "python",
"repo": "DianaTaukin/DSD-SATN",
"path": "/src/utils/SMPL.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elmoutaouakkil/TUT-live-age-estimator path: /DetectionThread.py
#!/usr/bin/env python
import cv2
import threading
import time
import numpy as np
import dlib
import GrabUnit
class DetectionThread(threading.Thread):
def __init__(self, parent, params):
threading.Thread.__init__(self)... | code_fim | hard | {
"lang": "python",
"repo": "elmoutaouakkil/TUT-live-age-estimator",
"path": "/DetectionThread.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for box in boxes:
box = [int(b / self.scaling) for b in box]
bboxes.append(box)
timestamps.append(unit.getTimeStamp())
self.parent.setDetections(bboxes, timestamps)<|fim_... | code_fim | hard | {
"lang": "python",
"repo": "elmoutaouakkil/TUT-live-age-estimator",
"path": "/DetectionThread.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: i3anaan/DrawALine path: /src/cls.py
import json
def check_settings(args, classifier):
override = {}
for param in classifier().get_params():
if param in vars(args) and vars(args)[param] is not None:
override[param] = vars(args)[param]
if override:
print("Ov... | code_fim | hard | {
"lang": "python",
"repo": "i3anaan/DrawALine",
"path": "/src/cls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def models_from_settings(settings, classifier):
models = []
for setting in settings:
models.append(classifier(**setting))
return models<|fim_prefix|># repo: i3anaan/DrawALine path: /src/cls.py
import json
def check_settings(args, classifier):
override = {}
for param in class... | code_fim | hard | {
"lang": "python",
"repo": "i3anaan/DrawALine",
"path": "/src/cls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> response = make_request(self.client, query)
self.assertEqual(expected, response)
def test_retrieve_multiple_vendors_filter_by_name(self):
self.create_multiple_vendors()
query = 'query {vendors(name_Icontains: "ndor1") {edges{node{name}}}}'
expected = {
... | code_fim | hard | {
"lang": "python",
"repo": "teamtaverna/core",
"path": "/app/api/tests/test_vendor_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> expected = {
'vendors': [
{
'name': self.first_vendor['name']
}
]
}
response = make_request(self.client, query)
self.assertEqual(expected, response)
def test_update_vendor_object(self):
... | code_fim | hard | {
"lang": "python",
"repo": "teamtaverna/core",
"path": "/app/api/tests/test_vendor_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: teamtaverna/core path: /app/api/tests/test_vendor_api.py
from django.test import Client, TestCase
from .utils import create_admin_account, make_request
class VendorApiTest(TestCase):
"""Test for Vendor API."""
def setUp(self):
self.client = Client()
create_admin_accoun... | code_fim | hard | {
"lang": "python",
"repo": "teamtaverna/core",
"path": "/app/api/tests/test_vendor_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.info('Connecting to block explorer.')
return sys.modules['lib.blockchain.{}'.format(config.BLOCKCHAIN_SERVICE_NAME)].check()
def searchrawtransactions(proxy, address):
return sys.modules['lib.blockchain.{}'.format(config.BLOCKCHAIN_SERVICE_NAME)].searchrawtransactions(proxy, address)<|... | code_fim | medium | {
"lang": "python",
"repo": "evanwagner1/counterpartyd",
"path": "/lib/blockchain/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evanwagner1/counterpartyd path: /lib/blockchain/__init__.py
'''
Proxy API to make queries to popular blockchains explorer
'''
import sys
import logging
logger = logging.getLogger(__name__)
from lib import config
from lib.blockchain import insight, jmcorgan, sochain, blockr
<|fim_suffix|> log... | code_fim | medium | {
"lang": "python",
"repo": "evanwagner1/counterpartyd",
"path": "/lib/blockchain/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GreatFruitOmsk/pyqtdeploy path: /pyqtdeploy/gui/pyqt_page.py
# Copyright (c) 2016, Riverbank Computing Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redist... | code_fim | hard | {
"lang": "python",
"repo": "GreatFruitOmsk/pyqtdeploy",
"path": "/pyqtdeploy/gui/pyqt_page.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if imports is None:
imports = QGroupBox(title)
grid = QGridLayout()
b = ModuleButton(module_name)
b.explicitly_required_changed.connect(self._module_toggled)
self._buttons[module_name] = b
grid.addWidget(b, row, ... | code_fim | hard | {
"lang": "python",
"repo": "GreatFruitOmsk/pyqtdeploy",
"path": "/pyqtdeploy/gui/pyqt_page.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
('safebrowsing', 'v4'),
('script', 'v1'),
('searchconsole', 'v1'),
('secretmanager', 'v1'),
('securitycenter', 'v1'),
('serviceconsumermanagement', 'v1'),
('servicemanagement', 'v1'),
('servicenetworking', 'v1'),
('serviceusage', 'v1'),
('sheets', 'v4'),
('siteVerification', 'v1'),
('slides',... | code_fim | hard | {
"lang": "python",
"repo": "omarryhan/aiogoogle",
"path": "/tests/ALL_APIS.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: omarryhan/aiogoogle path: /tests/ALL_APIS.py
### This file is autogenerated ###
ALL_APIS = [('abusiveexperiencereport', 'v1'),
('acceleratedmobilepageurl', 'v1'),
('accessapproval', 'v1'),
('accesscontextmanager', 'v1'),
('adexperiencereport', 'v1'),
('admob', 'v1'),
('analytics', 'v3'),
(... | code_fim | hard | {
"lang": "python",
"repo": "omarryhan/aiogoogle",
"path": "/tests/ALL_APIS.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> S = Session()
S.reader, S.writer = yield from asyncio.open_connection('127.0.0.1', 8888, loop=loop)
h = ProtocolHandler(S, config)
yield from h.start()
yield from h.outgoing_queue.put(test_packet)
yield from h.stop()
# Start ... | code_fim | hard | {
"lang": "python",
"repo": "gitter-badger/hbmqtt",
"path": "/tests/mqtt/test_protocol.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Schedule client
loop.call_soon(asyncio.async, client())
# Wait for server to complete client request
loop.run_until_complete(asyncio.wait([event.wait()]))
server.close()
self.logger.info(ret_packet)
self.assertEquals(ret_packet.fixed_header.packet... | code_fim | hard | {
"lang": "python",
"repo": "gitter-badger/hbmqtt",
"path": "/tests/mqtt/test_protocol.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gitter-badger/hbmqtt path: /tests/mqtt/test_protocol.py
# Copyright (c) 2015 Nicolas JOUANIN
#
# See the file license.txt for copying permission.
import unittest
import asyncio
from hbmqtt.mqtt.connect import ConnectPacket, ConnectVariableHeader, ConnectPayload
from hbmqtt.mqtt.protocol import P... | code_fim | hard | {
"lang": "python",
"repo": "gitter-badger/hbmqtt",
"path": "/tests/mqtt/test_protocol.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Vignesh-cell-hub/aadolf path: /purchaseitem/views.py
from django.shortcuts import render,redirect
from django.http import HttpResponse,JsonResponse
from customer.models import Customer
from itemform.models import Item
from .models import Invoice,Invoice_transaction
from django.core import seriali... | code_fim | hard | {
"lang": "python",
"repo": "Vignesh-cell-hub/aadolf",
"path": "/purchaseitem/views.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> user = Invoice(invoice_date = invoice_date,invoice = invoice, order_no = order_no, customer_name = customer_name, due_date=due_date,billingStreet=billingStreet,billingCity=billingCity,billingState=billingState,billingZipcode=billingZipcode,
shippingStreet=shippingStreet,ship... | code_fim | hard | {
"lang": "python",
"repo": "Vignesh-cell-hub/aadolf",
"path": "/purchaseitem/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("id :",id)
current_user_data = Customer.objects.get(id=id)
# current_user_data = current_user_datas[0]
gst_treatment = current_user_data.gst_treatment
billing_address = current_user_data.billing_address
billing_city = current_user_data.billing_city
billing_state = c... | code_fim | hard | {
"lang": "python",
"repo": "Vignesh-cell-hub/aadolf",
"path": "/purchaseitem/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: svn2github/calendarserver-raw path: /twext/branches/users/sagen/recordtypes/twext/enterprise/dal/record.py
che License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICE... | code_fim | hard | {
"lang": "python",
"repo": "svn2github/calendarserver-raw",
"path": "/twext/branches/users/sagen/recordtypes/twext/enterprise/dal/record.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def delete(self):
"""
Delete this row from the database.
@return: a L{Deferred} which fires with C{None} when the underlying row
has been deleted, or fails with L{NoSuchRecord} if the underlying
row was already deleted.
"""
return Delet... | code_fim | hard | {
"lang": "python",
"repo": "svn2github/calendarserver-raw",
"path": "/twext/branches/users/sagen/recordtypes/twext/enterprise/dal/record.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Blazzerrr/Quiz path: /restapi/quiz/views.py
# from django.shortcuts import render
from datetime import datetime
from rest_framework.response import Response
from rest_framework.views import APIView
from .models import Answer, Quiz, Question
from .serializers import QuizSerializer, QuestionSeriali... | code_fim | hard | {
"lang": "python",
"repo": "Blazzerrr/Quiz",
"path": "/restapi/quiz/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class UserView(APIView):
def get(self, request):
user_id = request.data.get('user_id')
quiz_id = request.data.get('quiz_id')
# If user don't send one of the required data
if (user_id is None) or (quiz_id is None):
return Response({"error": "undefined valu... | code_fim | hard | {
"lang": "python",
"repo": "Blazzerrr/Quiz",
"path": "/restapi/quiz/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class UserView(APIView):
def get(self, request):
user_id = request.data.get('user_id')
quiz_id = request.data.get('quiz_id')
# If user don't send one of the required data
if (user_id is None) or (quiz_id is None):
return Response({"error": "undefined value... | code_fim | hard | {
"lang": "python",
"repo": "Blazzerrr/Quiz",
"path": "/restapi/quiz/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gottaegbert/penter path: /the-python-standard-library-by-example/zipfile/zipfile_printdir.py
#!/usr/bin/env python
"""Print the table of contents of a ZIP archive
"""
#end_pymotw_header
<|fim_suffix|>with zipfile.ZipFile('example.zip', 'r') as zf:
print zf.printdir()<|fim_middle|>import zipf... | code_fim | easy | {
"lang": "python",
"repo": "gottaegbert/penter",
"path": "/the-python-standard-library-by-example/zipfile/zipfile_printdir.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>with zipfile.ZipFile('example.zip', 'r') as zf:
print zf.printdir()<|fim_prefix|># repo: gottaegbert/penter path: /the-python-standard-library-by-example/zipfile/zipfile_printdir.py
#!/usr/bin/env python
"""Print the table of contents of a ZIP archive
"""
#end_pymotw_header
<|fim_middle|>import zipf... | code_fim | easy | {
"lang": "python",
"repo": "gottaegbert/penter",
"path": "/the-python-standard-library-by-example/zipfile/zipfile_printdir.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: django-compressor/django-compressor path: /compressor/exceptions.py
class CompressorError(Exception):
"""
A general error of the compressor
"""
pass
class UncompressableFileError(Exception):
"""
This exception is raised when a file cannot be compressed
"""
pass... | code_fim | medium | {
"lang": "python",
"repo": "django-compressor/django-compressor",
"path": "/compressor/exceptions.py",
"mode": "psm",
"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.