text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: josephmjoy/robotics path: /python_robotutils/tests/test_robotcomm.py
ODO: track down and fix all the TODOs
# pylint: disable=fixme
TransportStats = collections.namedtuple('TransportStats',
'sends recvs forcedrops randomdrops')
# Mock transport tracing
... | code_fim | hard | {
"lang": "python",
"repo": "josephmjoy/robotics",
"path": "/python_robotutils/tests/test_robotcomm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Need to close before any test failure assertions, otherwise
# scheduler thread will never exit
transport.close()
# Actual failure rate must match expected to within 0.1
self.assertAlmostEqual(recvcount.value()/msgcount, 1-failurerate, 1)
print("transport_... | code_fim | hard | {
"lang": "python",
"repo": "josephmjoy/robotics",
"path": "/python_robotutils/tests/test_robotcomm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def delete_cart_item(db_session: Session, user_id: int, item_id: int) -> None:
db_session.query(Cart).filter_by(user_id=user_id, item_id=item_id).delete()
db_session.commit()
def empty_cart(db_session: Session, user_id: int) -> int:
unique_items_count = (
db_session.query(Cart)
... | code_fim | hard | {
"lang": "python",
"repo": "Haider8/oscarine-api",
"path": "/app/crud/cart.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_cart_items_detailed(db_session: Session, user_id: int) -> ViewCartResponse:
cart_info: List[Tuple[Cart, Item]] = (
db_session.query(Cart, Item).filter(Cart.user_id == user_id).join(Item).all()
)
total_items: int = 0
total_cost: float = 0
unique_items: int = len(cart_in... | code_fim | hard | {
"lang": "python",
"repo": "Haider8/oscarine-api",
"path": "/app/crud/cart.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Haider8/oscarine-api path: /app/crud/cart.py
from typing import List, Tuple
from fastapi import status
from fastapi.exceptions import HTTPException
from sqlalchemy.orm import Session
from app.db_models.cart import Cart
from app.db_models.item import Item
from app.models.cart import (
CartIt... | code_fim | hard | {
"lang": "python",
"repo": "Haider8/oscarine-api",
"path": "/app/crud/cart.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> manifest_strict=False<|fim_prefix|># repo: tralahtek/django-user-accounts path: /user_accounts/storage.py
from whitenoise.storage import CompressedManifestStaticFilesStorage
<|fim_middle|>class WhiteNoiseStaticFilesStorage(CompressedManifestStaticFilesStorage):
| code_fim | medium | {
"lang": "python",
"repo": "tralahtek/django-user-accounts",
"path": "/user_accounts/storage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tralahtek/django-user-accounts path: /user_accounts/storage.py
from whitenoise.storage import CompressedManifestStaticFilesStorage
<|fim_suffix|> manifest_strict=False<|fim_middle|>class WhiteNoiseStaticFilesStorage(CompressedManifestStaticFilesStorage):
| code_fim | medium | {
"lang": "python",
"repo": "tralahtek/django-user-accounts",
"path": "/user_accounts/storage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BII-wushuang/Lie-Group-Motion-Prediction path: /src/SMPL/config.py
import numpy as np
# Map joints Name to SMPL joints idx
JOINT_MAP = {
'MidHip': 0,
'LHip': 1, 'LKnee': 4, 'LAnkle': 7, 'LFoot': 10,
'RHip': 2, 'RKnee': 5, 'RAnkle': 8, 'RFoot': 11,
'LShoulder': 16, 'LElbow': 18, 'LWrist': 20, 'LH... | code_fim | hard | {
"lang": "python",
"repo": "BII-wushuang/Lie-Group-Motion-Prediction",
"path": "/src/SMPL/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># NTU Dataset Indices
NTU_JOINT_MAP = {
'MidHip': 0, 'spine2': 1, 'Neck': 20, 'Head': 2,
'LHip': 16, 'LKnee': 17, 'LAnkle': 18, 'LFoot': 19,
'RHip': 12, 'RKnee': 13, 'RAnkle': 14, 'RFoot': 15,
'LShoulder': 8, 'LElbow': 9, 'LWrist': 10, 'LHand': 11,
'RShoulder': 4, 'RElbow': 5, 'RWrist': 6, 'RHand': 7,
}
n... | code_fim | hard | {
"lang": "python",
"repo": "BII-wushuang/Lie-Group-Motion-Prediction",
"path": "/src/SMPL/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Dance Dataset Indices
WU_JOINT_MAP = {
'MidHip': 0, 'Chest': 1, 'Head':2,
'LHip': 16, 'LKnee': 17, 'LAnkle': 18, 'LFoot': 19, 'LFootTIP': 20,
'RHip': 7, 'RKnee': 8, 'RAnkle': 9, 'RFoot': 10, 'RFootTIP': 11,
'RShoulder': 3, 'RElbow': 4, 'RWrist': 5, 'RHand': 6,
'LShoulder': 12, 'LElbow': 13, 'LWrist': 14... | code_fim | hard | {
"lang": "python",
"repo": "BII-wushuang/Lie-Group-Motion-Prediction",
"path": "/src/SMPL/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: polygon-io/client-python path: /polygon/rest/summaries.py
from polygon.rest.models.summaries import SummaryResult
from .base import BaseClient
from typing import Optional, Any, Dict, List, Union
from urllib3 import HTTPResponse
from .models.request import RequestOptionBuilder
<|fim_suffix|> ... | code_fim | medium | {
"lang": "python",
"repo": "polygon-io/client-python",
"path": "/polygon/rest/summaries.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> url = f"/v1/summaries"
return self._get(
path=url,
params=self._get_params(self.get_summaries, locals()),
result_key="results",
deserializer=SummaryResult.from_dict,
raw=raw,
options=options,
)<|fim_prefix|># r... | code_fim | hard | {
"lang": "python",
"repo": "polygon-io/client-python",
"path": "/polygon/rest/summaries.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.varying:
if self.max_length is not None:
return 'VARBIT(%d)' % (self.max_length,)
return 'VARBIT'
elif self.max_length is not None:
return 'BIT(%d)' % (self.max_length,)
return 'BIT'
def to_python(self, value):
... | code_fim | hard | {
"lang": "python",
"repo": "isotoma/django-postgres",
"path": "/django_postgres/bitstrings.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(BitStringField, self).__init__(*args, **kwargs)
def db_type(self, connection):
if self.varying:
if self.max_length is not None:
return 'VARBIT(%d)' % (self.max_length,)
return 'VARBIT'
elif self.max_length is not None:
... | code_fim | hard | {
"lang": "python",
"repo": "isotoma/django-postgres",
"path": "/django_postgres/bitstrings.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isotoma/django-postgres path: /django_postgres/bitstrings.py
from contextlib import closing
from bitstring import Bits
from django.db import models
from django.db.backends.postgresql_psycopg2.base import DatabaseWrapper as PGDatabaseWrapper
from django.db.backends.signals import connection_creat... | code_fim | hard | {
"lang": "python",
"repo": "isotoma/django-postgres",
"path": "/django_postgres/bitstrings.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> if k == 0:
while nums[l] != 0:
l += 1
l += 1
else:
k -= 1 # otherwise pick it and decrement k
# update ans as max window size till now
ans = ... | code_fim | hard | {
"lang": "python",
"repo": "teddcp2/Tensorflow-Deep-Learning-notes",
"path": "/demo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: teddcp2/Tensorflow-Deep-Learning-notes path: /demo.py
class Solution:
def longestOnes(self, nums: List[int], k: int) -> int:
n, ans, l = len(nums), 0, 0
for r in range(n):
<|fim_suffix|> if k == 0:
while nums[l] != 0:
... | code_fim | hard | {
"lang": "python",
"repo": "teddcp2/Tensorflow-Deep-Learning-notes",
"path": "/demo.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def getPutableList(self):
"""
石のおけるすべての座標のリストを取得する\n
戻り値:\n
[[int, int], [int, int], ...]\n
入力:\n
x,y: int型 座標
"""
putableList = list()
for j in range(0, self.__mStoneRowAmount):
for i in range(0, self.__mStone... | code_fim | hard | {
"lang": "python",
"repo": "fstabin/fsPyReversi",
"path": "/reversi_status.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fstabin/fsPyReversi path: /reversi_status.py
from enum import IntEnum
import copy
class TeamType(IntEnum):
BLACK = 1
WHITE = -1
NOTEAM = 0
def __neg__(self):
if self == TeamType.BLACK:
return TeamType.WHITE
if self == TeamType.WHITE:
retur... | code_fim | hard | {
"lang": "python",
"repo": "fstabin/fsPyReversi",
"path": "/reversi_status.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #石を何個反転させるか判定し
#石を強制的に変更する
noChange = True
reverseList = [0,0,0,0,0,0,0,0]#反転させる石の数
for i in range(0,8):
bx = x
by = y
while True:
bx = bx + offsX[i]
by = by + offsY[i]
stone = self.... | code_fim | hard | {
"lang": "python",
"repo": "fstabin/fsPyReversi",
"path": "/reversi_status.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kw):
print('%s %s():' % (text, func.__name__))
return func(*args, **kw)
return wrapper
return decorator
@log('execute')
@PinpointCommonPlugin(__name__)
def func_in_decorator(x):
re... | code_fim | medium | {
"lang": "python",
"repo": "eeliu/pinpoint-c-agent",
"path": "/testapps/PY/test_decorator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eeliu/pinpoint-c-agent path: /testapps/PY/test_decorator.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import functools
from pinpoint.common import PinpointCommonPlugin
<|fim_suffix|> print('%s %s():' % (text, func.__name__))
return func(*args, **kw)
return wr... | code_fim | medium | {
"lang": "python",
"repo": "eeliu/pinpoint-c-agent",
"path": "/testapps/PY/test_decorator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@log('execute')
@PinpointCommonPlugin(__name__)
def func_in_decorator(x):
return x * x<|fim_prefix|># repo: eeliu/pinpoint-c-agent path: /testapps/PY/test_decorator.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import functools
from pinpoint.common import PinpointCommonPlugin
def log(text):
<|f... | code_fim | hard | {
"lang": "python",
"repo": "eeliu/pinpoint-c-agent",
"path": "/testapps/PY/test_decorator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scratchmex/karmabot path: /tests/test_core.py
from karmabot.commands.welcome import welcome_user
from karmabot.settings import KARMABOT_ID, SLACK_CLIENT
from karmabot.slack import GENERAL_CHANNEL, parse_next_msg
<|fim_suffix|>def test_slack_rtm_read(mock_slack_rtm_read_msg):
event = SLACK_CL... | code_fim | hard | {
"lang": "python",
"repo": "scratchmex/karmabot",
"path": "/tests/test_core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_slack_rtm_read(mock_slack_rtm_read_msg):
event = SLACK_CLIENT.rtm_read()
assert event[0]["type"] == "message"
assert event[0]["user"] == "ABC123"
assert event[0]["text"] == "Hi everybody"<|fim_prefix|># repo: scratchmex/karmabot path: /tests/test_core.py
from karmabot.commands.we... | code_fim | hard | {
"lang": "python",
"repo": "scratchmex/karmabot",
"path": "/tests/test_core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: deepakrana47/RED-machine-translation path: /util/Utility.py
import numpy as np, re, pickle
from random import shuffle
def init_weight(size1, size2=0, mean = 0, sigma = .1):
if size2 == 0:
return np.random.normal(mean, sigma, (size1, 1))
return np.random.normal(mean, sigma, (size1... | code_fim | hard | {
"lang": "python",
"repo": "deepakrana47/RED-machine-translation",
"path": "/util/Utility.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(pool_size):
for j in range(pool_size):
l11=int(vec1[i]); l12=int(vec1[i + 1])
l21=int(vec2[j]); l22=int(vec2[j + 1])
pooled = in_matrix[l11:l12, l21:l22]
output_matrix[i,j] = pool_fun(pooled)
return output_matrix
def similarit... | code_fim | hard | {
"lang": "python",
"repo": "deepakrana47/RED-machine-translation",
"path": "/util/Utility.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_results(score, y_test):
tp = 0.0; fp = 0.0; fn = 0.0; tn = 0.0; f1=0.0
for i in range(len(y_test)):
# fd.write("\ndesire score : " + str(y_test[i]) + " obtained : " + str(score[i]) + " sentences : " + sents[i] + '\n')
if y_test[i] == 1:
if score[i] == 1... | code_fim | hard | {
"lang": "python",
"repo": "deepakrana47/RED-machine-translation",
"path": "/util/Utility.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>"""
(2) Conduct the hypothesis testing to check if the distribution of daily return is normal. [15 points]
"""
utils.hyp_test_pic1(symbol, from_t, to_t)
utils.hyp_test_pic2(symbol, from_t, to_t)
result = utils.hyp_test_data(symbol, from_t, to_t)
print(result)<|fim_prefix|># repo: BinYuOnCa/Algo-ETL path... | code_fim | hard | {
"lang": "python",
"repo": "BinYuOnCa/Algo-ETL",
"path": "/Final_Project/zhangsongbin/assginment2/assignment2_3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BinYuOnCa/Algo-ETL path: /Final_Project/zhangsongbin/assginment2/assignment2_3.py
"""3.Use the same data in Question 2.
(1) Calculate daily return (return = log(today close/previous close)) [5 points]
(2) Conduct the hypothesis testing to check if the distribution of daily return is normal. [15 ... | code_fim | hard | {
"lang": "python",
"repo": "BinYuOnCa/Algo-ETL",
"path": "/Final_Project/zhangsongbin/assginment2/assignment2_3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Vith-MCB/Phyton---Curso-em-Video path: /Cursoemvideo/Exercícios UFV/Lista 5/exer07 - Media multiplos de 3.py
mult = 0
mult3 = 0
quant = int(input('Quantos numero você quer cit<|fim_suffix|> % 3 == 0:
mult += 1
mult3 += num
if num < 0:
break
media = mult3 / mult
print('... | code_fim | medium | {
"lang": "python",
"repo": "Vith-MCB/Phyton---Curso-em-Video",
"path": "/Cursoemvideo/Exercícios UFV/Lista 5/exer07 - Media multiplos de 3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> break
media = mult3 / mult
print('Media: {}'.format(media))<|fim_prefix|># repo: Vith-MCB/Phyton---Curso-em-Video path: /Cursoemvideo/Exercícios UFV/Lista 5/exer07 - Media multiplos de 3.py
mult = 0
mult3 = 0
quant = int(input('Quantos numero você quer cit<|fim_middle|>ar: '))
for i in range(0, q... | code_fim | medium | {
"lang": "python",
"repo": "Vith-MCB/Phyton---Curso-em-Video",
"path": "/Cursoemvideo/Exercícios UFV/Lista 5/exer07 - Media multiplos de 3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>{:.2f}'.format(clf.__class__.__name__, accuracy))<|fim_prefix|># repo: luoyaneng/machine_learning_beginner path: /pyparis-2018-sklearn/solutions/01_5_solutions.py
from sklearn.metrics import balanced_accuracy_score
accuracy = balanced_accuracy_score(y_breast_<|fim_middle|>test, y_pred)
print('Accuracy s... | code_fim | easy | {
"lang": "python",
"repo": "luoyaneng/machine_learning_beginner",
"path": "/pyparis-2018-sklearn/solutions/01_5_solutions.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luoyaneng/machine_learning_beginner path: /pyparis-2018-sklearn/solutions/01_5_solutions.py
from sklearn.metrics import balanced_accuracy_sc<|fim_suffix|>{:.2f}'.format(clf.__class__.__name__, accuracy))<|fim_middle|>ore
accuracy = balanced_accuracy_score(y_breast_test, y_pred)
print('Accuracy s... | code_fim | medium | {
"lang": "python",
"repo": "luoyaneng/machine_learning_beginner",
"path": "/pyparis-2018-sklearn/solutions/01_5_solutions.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class FactoidNode(Node):
"""
Will either set a context variable wth the factoid or print it
"""
def __init__(self, type, varname=None):
self.varname = varname
self.factoid = Factoid.objects.get_random(type).body
def render(self, context):
if self.varname is No... | code_fim | medium | {
"lang": "python",
"repo": "jjdelc/django-factoid",
"path": "/factoid/templatetags/factoids.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> varname = bits.pop()
else:
varname = None
return FactoidNode(type, varname)
class FactoidNode(Node):
"""
Will either set a context variable wth the factoid or print it
"""
def __init__(self, type, varname=None):
self.varname = varname
self.factoid... | code_fim | hard | {
"lang": "python",
"repo": "jjdelc/django-factoid",
"path": "/factoid/templatetags/factoids.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jjdelc/django-factoid path: /factoid/templatetags/factoids.py
# -*- coding: utf-8 -*-
from django.template import Library, Node, TemplateSyntaxError
from factoid.models import Factoid
register = Library()
@register.tag('get_factoid')
def do_get_factoid(parser, token):
"""
Gets a rando... | code_fim | hard | {
"lang": "python",
"repo": "jjdelc/django-factoid",
"path": "/factoid/templatetags/factoids.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> locations = properties.List(
"list of locations of each electrode in a dipole receiver",
RxLocationArray("location of electrode", shape=("*", "*")),
min_length=1,
max_length=2,
)
def __init__(
self, locations_m=None, locations_n=None, times=None, locati... | code_fim | hard | {
"lang": "python",
"repo": "xiaolongw1223/simpeg",
"path": "/SimPEG/electromagnetics/static/spectral_induced_polarization/receivers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaolongw1223/simpeg path: /SimPEG/electromagnetics/static/spectral_induced_polarization/receivers.py
import numpy as np
import properties
from ....utils.code_utils import deprecate_property
from ....utils import sdiag
from ....survey import BaseTimeRx, RxLocationArray
import warnings
class Ba... | code_fim | hard | {
"lang": "python",
"repo": "xiaolongw1223/simpeg",
"path": "/SimPEG/electromagnetics/static/spectral_induced_polarization/receivers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: undertakingyou/remainder-and-adjacent path: /python/phase1.py
import datetime
TZ = datetime.timezone(-datetime.timedelta(hours=0))
def remainder_and_adjacent():
now = datetime.datetime.now(tz=TZ).replace(second=0, microsecond=0)
next_hour = False
if now.minute > 30:
next_h... | code_fim | hard | {
"lang": "python",
"repo": "undertakingyou/remainder-and-adjacent",
"path": "/python/phase1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for item in (first, second):
difference = item - now
response.append(
{
'value': int(difference.seconds/60),
'units': 'mins',
'start': now.isoformat(),
'end': item.isoformat()
}
)
retur... | code_fim | hard | {
"lang": "python",
"repo": "undertakingyou/remainder-and-adjacent",
"path": "/python/phase1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zanachka/exporters path: /tests/test_filters.py
# -*- coding: utf-8 -*-
import random
import unittest
from exporters.filters.base_filter import BaseFilter
from exporters.filters.dupe_filter import DupeFilter
from exporters.filters.key_value_filter import KeyValueFilter
from exporters.filters.key_... | code_fim | hard | {
"lang": "python",
"repo": "zanachka/exporters",
"path": "/tests/test_filters.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> batch = filter.filter_batch(batch)
batch = list(batch)
self.assertEqual(3, len(batch))
self.assertEquals(set(keys),
set([item['custom_key'] for item in batch]))
self.assertEquals(set(['item1', 'item3', 'item5']),
s... | code_fim | hard | {
"lang": "python",
"repo": "zanachka/exporters",
"path": "/tests/test_filters.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.hash = hash
self.height = height
self.index = index
self.status = status
self.tx = tx
def get_hash(self) -> str:
return self.hash
def get_height(self) -> int:
return self.height
def get_index(self) -> int:
return self.inde... | code_fim | hard | {
"lang": "python",
"repo": "katena-chain/sdk-py",
"path": "/katena_chain_sdk_py/entity/api/tx_result.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: katena-chain/sdk-py path: /katena_chain_sdk_py/entity/api/tx_result.py
"""
Copyright (c) 2019, TransChain.
This source code is licensed under the Apache 2.0 license found in the
LICENSE file in the root directory of this source tree.
"""
from marshmallow import fields
from typing import List
fr... | code_fim | hard | {
"lang": "python",
"repo": "katena-chain/sdk-py",
"path": "/katena_chain_sdk_py/entity/api/tx_result.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sdpython/botadi path: /src/botadi/mokadi/mokadi_helper.py
# -*- coding: utf-8 -*-
"""
@file
@brief Small functions.
"""
import datetime
def convert_into_days(date, lang="fr", format="%Y-%m-%dT%H:%M:%S"):
"""
Convert a date into the number of days from today.
@param date ... | code_fim | hard | {
"lang": "python",
"repo": "sdpython/botadi",
"path": "/src/botadi/mokadi/mokadi_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @param text text to convert
@return number
"""
if not text:
raise ValueError("Text to convert cannot be empty.")
if not isinstance(text, str):
raise ValueError("Text to convert cannot be a string.")
try:
return int(text)
excep... | code_fim | hard | {
"lang": "python",
"repo": "sdpython/botadi",
"path": "/src/botadi/mokadi/mokadi_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hans-kun/Django-Ecommerce path: /Ecommerce/ecom/views.py
from django.shortcuts import render
# Create your views here.
def store(request):
context = {}
return render(request, 'ecom/store.html', context)
<|fim_suffix|>def checkout(request):
context = {}
return render(request,... | code_fim | medium | {
"lang": "python",
"repo": "Hans-kun/Django-Ecommerce",
"path": "/Ecommerce/ecom/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def cart(request):
context = {}
return render(request, 'ecom/cart.html', context)
def checkout(request):
context = {}
return render(request, 'ecom/checkout.html', context)<|fim_prefix|># repo: Hans-kun/Django-Ecommerce path: /Ecommerce/ecom/views.py
from django.shortcuts import rende... | code_fim | medium | {
"lang": "python",
"repo": "Hans-kun/Django-Ecommerce",
"path": "/Ecommerce/ecom/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> context = {}
return render(request, 'ecom/cart.html', context)
def checkout(request):
context = {}
return render(request, 'ecom/checkout.html', context)<|fim_prefix|># repo: Hans-kun/Django-Ecommerce path: /Ecommerce/ecom/views.py
from django.shortcuts import render
# Create your vi... | code_fim | easy | {
"lang": "python",
"repo": "Hans-kun/Django-Ecommerce",
"path": "/Ecommerce/ecom/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: home-assistant/core path: /homeassistant/components/esphome/bluetooth/descriptor.py
"""BleakGATTDescriptorESPHome."""
from __future__ import annotations
from aioesphomeapi.model import BluetoothGATTDescriptor
from bleak.backends.descriptor import BleakGATTDescriptor
class BleakGATTDescriptorES... | code_fim | medium | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/homeassistant/components/esphome/bluetooth/descriptor.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(
self,
obj: BluetoothGATTDescriptor,
characteristic_uuid: str,
characteristic_handle: int,
) -> None:
"""Init a BleakGATTDescriptorESPHome."""
super().__init__(obj)
self.__characteristic_uuid: str = characteristic_uuid
se... | code_fim | medium | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/homeassistant/components/esphome/bluetooth/descriptor.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Melon-Tropics/meson path: /mesonbuild/interpreter/compiler.py
hadtxt = mlog.green('YES')
else:
hadtxt = mlog.red('NO')
mlog.log('Checking for type', mlog.bold(typename, True), msg, hadtxt, cached)
return had
@FeatureNew('compiler.compute_int', '0.40.0')
... | code_fim | hard | {
"lang": "python",
"repo": "Melon-Tropics/meson",
"path": "/mesonbuild/interpreter/compiler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(args) != 2:
raise InterpreterException('has_header_symbol method takes exactly two arguments.')
check_stringlist(args)
hname, symbol = args
prefix = kwargs.get('prefix', '')
if not isinstance(prefix, str):
raise InterpreterException('P... | code_fim | hard | {
"lang": "python",
"repo": "Melon-Tropics/meson",
"path": "/mesonbuild/interpreter/compiler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> args = mesonlib.stringlistify(args)
if len(args) != 1:
raise InterpreterException('has_argument takes exactly one argument.')
return self.has_multi_arguments_method(args, kwargs)
@permittedKwargs({})
def has_multi_arguments_method(self, args: T.Sequence[str], k... | code_fim | hard | {
"lang": "python",
"repo": "Melon-Tropics/meson",
"path": "/mesonbuild/interpreter/compiler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> require_update, data_json_data = compare_resource_require_update(expected_path, row)
if require_update:
row['comparison_results'] = {
'action': 'update',
'ckan_id': ckan_id,
'new_data': data_jso... | code_fim | hard | {
"lang": "python",
"repo": "datopian/ckan-ng-harvest",
"path": "/harvester_ng/datajson/flows.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: datopian/ckan-ng-harvest path: /harvester_ng/datajson/flows.py
import glob
import json
import logging
import os
import pytz
from datapackage import Package, Resource
from dateutil.parser import parse
from harvesters.datajson.harvester import DataJSONDataset
from harvester_ng import helpers
from ... | code_fim | hard | {
"lang": "python",
"repo": "datopian/ckan-ng-harvest",
"path": "/harvester_ng/datajson/flows.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 7lsu/eoffcn-ts-decode path: /__main__.py
import re
import os
import sys
import json
import glob
import requests as req
import execjs
import threading
import queue
import time
class myThread (threading.Thread):
def __init__(self, threadID, q):
threading.Thread.__init__(self)
... | code_fim | hard | {
"lang": "python",
"repo": "7lsu/eoffcn-ts-decode",
"path": "/__main__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def download_and_decode(path, mda):
path = path.replace('>', '')
path = path.replace(' ', '_')
mkdir('.' + path)
print(path)
if os.path.exists('.' + path + '/output.mp4') == False:
if mda != '':
video_url = 'https://gcik47gyt746q6nqdze.exp.bcevod.com/' + mda + '/'... | code_fim | hard | {
"lang": "python",
"repo": "7lsu/eoffcn-ts-decode",
"path": "/__main__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dieb/algorithms.py path: /algorithms/sorting/insertion.py
# -*- coding: utf-8 -*-
from six.moves import range
__all__ = ('insertion_sort', 'INSERTION_METHODS')
def insertion_sort(array, method='forloop'):
""" Sorts `array` similarly as we sort a deck of cards. Start with an empty
lef... | code_fim | hard | {
"lang": "python",
"repo": "dieb/algorithms.py",
"path": "/algorithms/sorting/insertion.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Looks at items from left to right, starting from the second position.
For every `item`:
For every `prev_item` to the left of `item`:
If larger than item, copy it one place forward
If smaller than item, stop
Insert item before last larger item copied to ... | code_fim | hard | {
"lang": "python",
"repo": "dieb/algorithms.py",
"path": "/algorithms/sorting/insertion.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tribruin/AdventOfCode path: /2021/Day12/main.py
#!/Users/rblount/.pyenv/versions/AdOfCode/bin/python
import sys
import os
from AOC import AOC
testing = True
def parse_input(data_input: list):
result = dict()
caves = [x.split("-") for x in data_input]
for cave in caves:
if... | code_fim | hard | {
"lang": "python",
"repo": "Tribruin/AdventOfCode",
"path": "/2021/Day12/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def part1(caves):
all_paths = find_paths(caves, "start", last_cave="")
print(all_paths)
def part2(data_input):
pass
def main():
# Get the path name and strip to the last 1 or 2 characters
codePath = os.path.dirname(sys.argv[0])
codeDate = int(codePath.split("/")[-1][3:])
c... | code_fim | hard | {
"lang": "python",
"repo": "Tribruin/AdventOfCode",
"path": "/2021/Day12/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: blockchyp/blockchyp-python path: /tests/integration/media_upload_test.py
# Copyright 2019-2023 BlockChyp, Inc. All rights reserved. Use of this code is
# governed by a license that can be found in the LICENSE file.
#
# This file was generated automatically by the BlockChyp SDK Generator. Changes
... | code_fim | medium | {
"lang": "python",
"repo": "blockchyp/blockchyp-python",
"path": "/tests/integration/media_upload_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> terminal = _get_test_config().get("defaultTerminalName")
client = _get_test_client("")
request = {
"fileName": "aviato.png",
"fileSize": 18843,
"uploadId": str(uuid.uuid4()),
}
file_name = pkg_resources.resource_filename("tests", "resources/aviato.png")
... | code_fim | medium | {
"lang": "python",
"repo": "blockchyp/blockchyp-python",
"path": "/tests/integration/media_upload_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert response.get("success") is True
assert response.get("id")
assert response.get("originalFile") == "aviato.png"
assert response.get("fileUrl")
assert response.get("thumbnailUrl")<|fim_prefix|># repo: blockchyp/blockchyp-python path: /tests/integration/media_upload_test.py
# Copyr... | code_fim | hard | {
"lang": "python",
"repo": "blockchyp/blockchyp-python",
"path": "/tests/integration/media_upload_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_kwargs = pygerduty.v2.Collection.process_kwargs(kwargs)
assert new_kwargs == {
"name": "default-email",
"description": "default email service",
"escalation_policy": {
"id": "PIJ90N7",
"type": "escalation_policy"
},
"service_key":... | code_fim | hard | {
"lang": "python",
"repo": "cugini-dbx/pygerduty",
"path": "/tests/collection_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cugini-dbx/pygerduty path: /tests/collection_test.py
from __future__ import absolute_import
import pygerduty.v2
###################
# Version 2 Tests #
###################
def test_id_to_obj():
kwargs = {
"escalation_policy_id": "PIJ90N7",
}
new_key = pygerduty.v2.Collecti... | code_fim | hard | {
"lang": "python",
"repo": "cugini-dbx/pygerduty",
"path": "/tests/collection_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gemmanguen/stabilizer_code path: /stabilizer_code.py
import numpy as np
import itertools
from pyquil import Program
from pyquil.gates import MEASURE
# all references are to chapter 4 of Gottesman's thesis, chapter 4
# https://arxiv.org/pdf/quant-ph/9705052.pdf
tuple2pauli = {(0,0):'I', (0,1): '... | code_fim | hard | {
"lang": "python",
"repo": "gemmanguen/stabilizer_code",
"path": "/stabilizer_code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # for op1, op2 in I, X, Y, Z, return 0 if they commute, else return 1
assert op1 in ['I','X','Y','Z']
assert op2 in ['I','X','Y','Z']
if op1 == 'I' or op2 == 'I' or op1 == op2:
return 0
else:
return 1
def commutator_n_qubits(op1, op2):
assert len(op1) == len(op2)
... | code_fim | hard | {
"lang": "python",
"repo": "gemmanguen/stabilizer_code",
"path": "/stabilizer_code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@staticmethod
def add_entitlement_override_for_subscription(id, params, env=None, headers=None):
return request.send('post', request.uri_path("subscriptions",id,"entitlement_overrides"), params, env, headers)
@staticmethod
def list_entitlement_override_for_subscription(id, params... | code_fim | medium | {
"lang": "python",
"repo": "chargebee/chargebee-python",
"path": "/chargebee/models/entitlement_override.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chargebee/chargebee-python path: /chargebee/models/entitlement_override.py
import json
from chargebee.model import Model
from chargebee import request
from chargebee import APIError
class EntitlementOverride(Model):
fields = ["id", "entity_id", "entity_type", "feature_id", "feature_name", "... | code_fim | hard | {
"lang": "python",
"repo": "chargebee/chargebee-python",
"path": "/chargebee/models/entitlement_override.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def list_entitlement_override_for_subscription(id, params=None, env=None, headers=None):
return request.send('get', request.uri_path("subscriptions",id,"entitlement_overrides"), params, env, headers)<|fim_prefix|># repo: chargebee/chargebee-python path: /chargebee/models/ent... | code_fim | hard | {
"lang": "python",
"repo": "chargebee/chargebee-python",
"path": "/chargebee/models/entitlement_override.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if node.species_id not in sample_map:
raise Exception("sample map"+repr(sample_map)+"doesn't cover all species in blueprint - missing: " + repr(node.species_id))
module_id = sample_map[node.species_id]
module = S.instance.module_population[module_id]
... | code_fim | hard | {
"lang": "python",
"repo": "John1911603424/CoDeepNEAT-1",
"path": "/src2/Genotype/CDN/Genomes/BlueprintGenome.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: John1911603424/CoDeepNEAT-1 path: /src2/Genotype/CDN/Genomes/BlueprintGenome.py
from __future__ import annotations
import copy
import random
from typing import List, Dict, TYPE_CHECKING, Optional, Set, Tuple
from torch import nn
import src2.Genotype.CDN.Nodes.BlueprintNode as BlueprintNode
fro... | code_fim | hard | {
"lang": "python",
"repo": "John1911603424/CoDeepNEAT-1",
"path": "/src2/Genotype/CDN/Genomes/BlueprintGenome.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def eval(self, gt, pred):
pass
def eval_batch(self, gt, pred, real=True):
assert gt.shape[0] == pred.shape[0]
batch_size = gt.shape[0]
result = np.zeros([batch_size], np.float32)
for i in range(batch_size):
result[i] = self.eval(gt... | code_fim | hard | {
"lang": "python",
"repo": "dzynin/FixMyPose",
"path": "/langeval/eval.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dzynin/FixMyPose path: /langeval/eval.py
import json
import random
import time
import string
import os
import os.path as osp
from json import encoder
import numpy as np
def language_level(preds, metric=None):
"""
:param preds: pred in MSCOCO type, [{'caption':'a sentence', 'image_id': t... | code_fim | hard | {
"lang": "python",
"repo": "dzynin/FixMyPose",
"path": "/langeval/eval.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emmamartins/shopcart-pytonik path: /app/model/Medias.py
from pytonik.Model import Model
from pytonik.Session import Session
from pytonik.Functions.path import path
class Medias(Model, path):
def __getattr__(self, item):
return item
def __call__(self, *args, **kwargs):
r... | code_fim | hard | {
"lang": "python",
"repo": "emmamartins/shopcart-pytonik",
"path": "/app/model/Medias.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> query = self.table('medias').where('medias_id', '=', id).insert(data)
return query
def insertGetId(self, data):
query = self.table('medias').insertGetId(data)
return query<|fim_prefix|># repo: emmamartins/shopcart-pytonik path: /app/model/Medias.py
from pytonik.Mo... | code_fim | hard | {
"lang": "python",
"repo": "emmamartins/shopcart-pytonik",
"path": "/app/model/Medias.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def by_id(self, id):
query = self.table('medias').where('medias_id', '=', id).insert(data)
return query
def insertGetId(self, data):
query = self.table('medias').insertGetId(data)
return query<|fim_prefix|># repo: emmamartins/shopcart-pytonik path: /app/model/... | code_fim | medium | {
"lang": "python",
"repo": "emmamartins/shopcart-pytonik",
"path": "/app/model/Medias.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chyavan-mc/My-Solutions-to-Leetcode-problems-using-Python-3 path: /Sort Colors.py
class Solution:
def sortColors(self, nums):
<|fim_suffix|> for i in range(red):
nums[i]=0
for i in range(red,white+red):
nums[i]=1
for i in range(white+red,blue+red... | code_fim | hard | {
"lang": "python",
"repo": "chyavan-mc/My-Solutions-to-Leetcode-problems-using-Python-3",
"path": "/Sort Colors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i in range(red):
nums[i]=0
for i in range(red,white+red):
nums[i]=1
for i in range(white+red,blue+red+white):
nums[i]=2<|fim_prefix|># repo: chyavan-mc/My-Solutions-to-Leetcode-problems-using-Python-3 path: /Sort Colors.py
class Solution:
... | code_fim | hard | {
"lang": "python",
"repo": "chyavan-mc/My-Solutions-to-Leetcode-problems-using-Python-3",
"path": "/Sort Colors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hypha/zoopla path: /zoopla/MDI-Data/mdi-xls-to-pkl.py
import pandas as pd
# Written by Apollon
# This converts excel MDI files to pickled dataframes
# And saves them in current working directory
<|fim_suffix|>dep_df = pd.ExcelFile("./Deprivation_Index_2016.xlsx")
dep_full = dep_df.parse("All po... | code_fim | medium | {
"lang": "python",
"repo": "hypha/zoopla",
"path": "/zoopla/MDI-Data/mdi-xls-to-pkl.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>dep_df = pd.ExcelFile("./Deprivation_Index_2016.xlsx")
dep_full = dep_df.parse("All postcodes")
dep_full.to_pickle('../edinburgh-deprivation-data.pkl')<|fim_prefix|># repo: hypha/zoopla path: /zoopla/MDI-Data/mdi-xls-to-pkl.py
import pandas as pd
# Written by Apollon
# This converts excel MDI files to p... | code_fim | medium | {
"lang": "python",
"repo": "hypha/zoopla",
"path": "/zoopla/MDI-Data/mdi-xls-to-pkl.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chelsealizardo/coding-challenges path: /codingChallenge9/shapefiles.py
import arcpy
# set workspace and allow for overwrite
arcpy.env.workspace = r"C:\data\codingChallenge9"
arcpy.env.overwriteOutput = True
# Set variable to our input file and the fields that will be used
shp_in = r"... | code_fim | hard | {
"lang": "python",
"repo": "chelsealizardo/coding-challenges",
"path": "/codingChallenge9/shapefiles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Create a new file to determine how many photos are present, which can be found in the the
# attribute table in the shp layer
presence = arcpy.AddFieldDelimiters(shp_in, "photo") + " = 'y'"
arcpy.Select_analysis(shp_in, "photo_presence.shp", presence)
print("New File has been Created Successfully!"... | code_fim | hard | {
"lang": "python",
"repo": "chelsealizardo/coding-challenges",
"path": "/codingChallenge9/shapefiles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Now count how many sites have photos
count = 0
sites = list()
presence = arcpy.AddFieldDelimiters(shp_in, "photo") + " = 'y'"
with arcpy.SearchCursor("photo_presence.shp", presence, fields) as cursor:
for row in cursor:
if row[1] not in sites:
count += 1
sites... | code_fim | hard | {
"lang": "python",
"repo": "chelsealizardo/coding-challenges",
"path": "/codingChallenge9/shapefiles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self, customer_tid=None, next_action=None,
):
query = {}
if customer_tid:
query["customer_tid"] = customer_tid
if next_action:
query["next_action"] = self._next_action(next_action)
yield from get_all(self._session, self._model, self._base... | code_fim | hard | {
"lang": "python",
"repo": "weynandk/jumpscaleX_libs",
"path": "/JumpscaleLibs/clients/explorer/reservations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: weynandk/jumpscaleX_libs path: /JumpscaleLibs/clients/explorer/reservations.py
from Jumpscale import j
from .pagination import get_page, get_all
class Reservations:
def __init__(self, session, url):
self._session = session
self._base_url = url + "/reservations"
self.... | code_fim | hard | {
"lang": "python",
"repo": "weynandk/jumpscaleX_libs",
"path": "/JumpscaleLibs/clients/explorer/reservations.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def sign_provision(self, reservation_id, tid, signature):
url = self._base_url + f"/{reservation_id}/sign/provision"
data = j.data.serializers.json.dumps({"signature": signature, "tid": tid, "epoch": j.data.time.epoch,})
self._session.post(url, data=data)
return True
... | code_fim | hard | {
"lang": "python",
"repo": "weynandk/jumpscaleX_libs",
"path": "/JumpscaleLibs/clients/explorer/reservations.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: djphan/Prog-Problems path: /Advent-Code/2017/day9-stringgarbageprocessor/garbageprocessor.py
def stringCounter(inputFilePath):
returnNum = 0
depth = 0
inputFile = open(inputFilePath, 'r')
for line in inputFile:
cancelFlag = False
garbageFlag = False
for i... | code_fim | hard | {
"lang": "python",
"repo": "djphan/Prog-Problems",
"path": "/Advent-Code/2017/day9-stringgarbageprocessor/garbageprocessor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> inputFile = open(inputFilePath, 'r')
for line in inputFile:
cancelFlag = False
garbageFlag = False
for i in line:
# Ignore < > ! { }
if cancelFlag:
cancelFlag = False
continue
if i == '!':
... | code_fim | hard | {
"lang": "python",
"repo": "djphan/Prog-Problems",
"path": "/Advent-Code/2017/day9-stringgarbageprocessor/garbageprocessor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shadom/ichnaea path: /alembic/versions/4255b858a37e_remove_user_score_tables.py
"""remove user/score tables
Revision ID: 4255b858a37e
Revises: 27400b0c8b42
Create Date: 2016-04-12 10:56:36.512919
"""
import logging
<|fim_suffix|> log.info('Drop user table.')
stmt = 'DROP TABLE user'
... | code_fim | hard | {
"lang": "python",
"repo": "shadom/ichnaea",
"path": "/alembic/versions/4255b858a37e_remove_user_score_tables.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def downgrade():
log.info('Recreate user table.')
stmt = '''\
CREATE TABLE `user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`nickname` varchar(128) DEFAULT NULL,
`email` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `user_nickname_unique` (`nickname`)
) ENGINE=InnoDB D... | code_fim | medium | {
"lang": "python",
"repo": "shadom/ichnaea",
"path": "/alembic/versions/4255b858a37e_remove_user_score_tables.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akai10tsuki/mkvbatchmultiplex path: /MKVBatchMultiplex/ui/Ui_PreferencesDialog.py
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'PreferencesDialog.ui'
##
## Created by: Qt User Interface Compil... | code_fim | hard | {
"lang": "python",
"repo": "akai10tsuki/mkvbatchmultiplex",
"path": "/MKVBatchMultiplex/ui/Ui_PreferencesDialog.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> PreferencesDialog.setWindowTitle(QCoreApplication.translate("PreferencesDialog", u"Preferences", None))
self.grpBox.setTitle("")
self.lblInterfaceLanguage.setText(QCoreApplication.translate("PreferencesDialog", u"Interface Language:", None))
self.chkBoxRestoreWindowSize.... | code_fim | hard | {
"lang": "python",
"repo": "akai10tsuki/mkvbatchmultiplex",
"path": "/MKVBatchMultiplex/ui/Ui_PreferencesDialog.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@bot.command()
@commands.cooldown(1, 3, commands.BucketType.guild)
async def jferrell(ctx): #this command promotes my boy justin's long time animation youtube channel!
ytchannel = 'https://www.youtube.com/channel/UCKQyUCFvmilciKu-ZjJAfRw'
await ctx.send(ytchannel)
@bot.command()
@command... | code_fim | hard | {
"lang": "python",
"repo": "TRJoseph/YoderBot",
"path": "/YoderBot.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TRJoseph/YoderBot path: /YoderBot.py
import discord
import os
from dotenv import load_dotenv
from discord.ext import commands
import platform
import discord_components
import random
import youtube_dl
load_dotenv()
TOKEN = os.getenv('DISCORD_TOKEN')
GUILD = os.getenv('DISCORD_GUILD')
... | code_fim | hard | {
"lang": "python",
"repo": "TRJoseph/YoderBot",
"path": "/YoderBot.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def getStateToPublish(self):
"""Implement me to return state to copy as part of the publish phase.
"""
raise NotImplementedError("%s.getStateToPublishFor" % self.__class__)
def getStateToCacheAndObserveFor(self, perspective, observer):
"""Get all necessary metadata... | code_fim | hard | {
"lang": "python",
"repo": "kuri65536/python-for-android",
"path": "/python-modules/twisted/twisted/spread/publish.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def activated(self):
"""Implement this method if you want to be notified when your
publishable subclass is activated.
"""
def callWhenActivated(self, callback):
"""Externally register for notification when this publishable has received all relevant data.
... | code_fim | hard | {
"lang": "python",
"repo": "kuri65536/python-for-android",
"path": "/python-modules/twisted/twisted/spread/publish.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.