text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> for line in obj['file']:
data = line.decode('utf-8').strip().split("\t")
info = {}
identification = int(data[0])
info['balance_contributions']=int(round(float(data[1]), 0))
info['total_quota']=int(round(float(data[2]), 0))
info['contributions']=int(round(float(data[3]), 0))
info['ut... | code_fim | hard | {
"lang": "python",
"repo": "Fonmon/Fondo-API",
"path": "/fondo_api/services/user.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Fonmon/Fondo-API path: /fondo_api/services/user.py
import binascii
import os
import logging
from django.contrib.auth.models import User
from django.db import IntegrityError,transaction
from django.core.paginator import Paginator
from django.conf import settings
from rest_framework.authtoken.model... | code_fim | hard | {
"lang": "python",
"repo": "Fonmon/Fondo-API",
"path": "/fondo_api/services/user.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
if id is not None:
user_finance = UserFinance.objects.get(user_id=id)
else:
user_finance = UserFinance.objects.get(user__identification=identification)
except UserFinance.DoesNotExist:
return (False, 404)
if (user_finance.contributions != obj['contributions']
or user_finance... | code_fim | hard | {
"lang": "python",
"repo": "Fonmon/Fondo-API",
"path": "/fondo_api/services/user.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gezav88/repo-to-fork path: /chemasarmiento.py
print("Fibonacci")
bef = 0
aft = 1
counter = 0
print(bef)
print(aft)
while counter < 13:
next = bef + aft
bef = aft
aft = next
print(aft)
counter = counter + 1
<|fim_suffix|> if x < 1:
return False
sum = 0
for i in range(1,x):
... | code_fim | hard | {
"lang": "python",
"repo": "gezav88/repo-to-fork",
"path": "/chemasarmiento.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if x < 1:
return False
sum = 0
for i in range(1,x):
if x%i==0:
sum += i
return sum == x
counter = 0
test = 1
while counter < 4:
if isPerfect(test):
print(test)
counter = counter + 1
test += 1<|fim_prefix|># repo: gezav88/repo-to-fork path: /chemasarmiento.py
print("Fibo... | code_fim | hard | {
"lang": "python",
"repo": "gezav88/repo-to-fork",
"path": "/chemasarmiento.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Detrous/darksky path: /tests/utils.py
def snake_case_key(key: str) -> str:
assert isinstance(key, str)
new_k<|fim_suffix|>_key += "_{char}".format(char=char.lower())
elif char == "-":
new_key += "__"
else:
new_key += char
return new_key<|fim_mid... | code_fim | medium | {
"lang": "python",
"repo": "Detrous/darksky",
"path": "/tests/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_key += "__"
else:
new_key += char
return new_key<|fim_prefix|># repo: Detrous/darksky path: /tests/utils.py
def snake_case_key(key: str) -> str:
assert isinstance(key, str)
new_k<|fim_middle|>ey = key[0]
for char in key[1:]:
if char.isupper():
... | code_fim | medium | {
"lang": "python",
"repo": "Detrous/darksky",
"path": "/tests/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>except ValueError:
sys.path.insert(0, ROOT_PATH)
from setupextras.extras import *<|fim_prefix|># repo: grimen/python-setupextras path: /setupextras/__init__.py
# =========================================
# IMPORTS / EXPORTS
# --------------------------------------
import sys
from os import ... | code_fim | easy | {
"lang": "python",
"repo": "grimen/python-setupextras",
"path": "/setupextras/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grimen/python-setupextras path: /setupextras/__init__.py
# =========================================
# IMPORTS / EXPORTS
# --------------------------------------
<|fim_suffix|>try:
try:
sys.path.remove(CURRENT_PATH)
except:
pass
sys.path.index(ROOT_PATH)
exce... | code_fim | medium | {
"lang": "python",
"repo": "grimen/python-setupextras",
"path": "/setupextras/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sunlightlabs/regulations-scraper path: /regscrape/sec_cftc/commands/sec_cftc_import.py
import json, re, urlparse
from dateutil.parser import parse as parse_date
import datetime
import settings
from regs_models import *
from regs_common.util import *
from mongoengine.errors import NotUniqueError
... | code_fim | hard | {
"lang": "python",
"repo": "sunlightlabs/regulations-scraper",
"path": "/regscrape/sec_cftc/commands/sec_cftc_import.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> current.details = dkt.details
current.source = dkt.source
current.agency = dkt.agency
if current.scraped != 'yes':
current.scraped = dkt.scraped
current.save()
for... | code_fim | hard | {
"lang": "python",
"repo": "sunlightlabs/regulations-scraper",
"path": "/regscrape/sec_cftc/commands/sec_cftc_import.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> printer_socket = socket.socket()
printer_socket.settimeout(TIMEOUT_SECONDS)
printer_socket.connect((printer_adress['ip'], printer_adress['port']))
printer_socket.send(message_data.encode())
data = printer_socket.recv(BUFFER_SIZE)
printer_socket.close()
return data.decod... | code_fim | medium | {
"lang": "python",
"repo": "aoirint/flashforge-finder-api",
"path": "/api/socket_handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aoirint/flashforge-finder-api path: /api/socket_handler.py
import socket
BUFFER_SIZE = 1024
TIMEOUT_SECONDS = 5
import time
<|fim_suffix|> printer_socket = socket.socket()
printer_socket.settimeout(TIMEOUT_SECONDS)
printer_socket.connect((printer_adress['ip'], printer_adres... | code_fim | medium | {
"lang": "python",
"repo": "aoirint/flashforge-finder-api",
"path": "/api/socket_handler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_optimize(self):
model_paths = ['gpt2', 'distilgpt2']
device = 'cpu'
enable_optimize = {'external_memory': 1024, 'return_proba': True}
disable_optimize = {'external_memory': 0, 'return_proba': True}
epoch = 10
for model_path in model_paths:
... | code_fim | hard | {
"lang": "python",
"repo": "makcedward/nlpaug",
"path": "/test/profiling/sentence/test_context_word_embs_sentence_profiling.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: makcedward/nlpaug path: /test/profiling/sentence/test_context_word_embs_sentence_profiling.py
import unittest
import os
import time
from dotenv import load_dotenv
import nlpaug.augmenter.sentence as nas
class TestContextualWordEmbsAugProfiling(unittest.TestCase):
@classmethod
def setUp... | code_fim | hard | {
"lang": "python",
"repo": "makcedward/nlpaug",
"path": "/test/profiling/sentence/test_context_word_embs_sentence_profiling.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Model:{}, Optimized: {}({}), No Optimized: {}({})'.format(
model_path, optimized_total_duration, optimized_average_duration,
no_optimized_total_duration, no_optimized_average_duration
))
self.assertGreater(no_optimized_total_durat... | code_fim | hard | {
"lang": "python",
"repo": "makcedward/nlpaug",
"path": "/test/profiling/sentence/test_context_word_embs_sentence_profiling.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'http_connect_raw'
op|'('
nl|'\n'
string|"'127.0.0.1'"
op|','
number|'8080'
op|','
string|"'GET'"
op|','
string|"'/'"
op|','
nl|'\n'
name|'headers'
op|'='
op|'{'
string|"'x-one'"
op|':'
string|"'1'"
op|','
string|"'x-two'"
op|':'
number|'2'
op|','
string|"'x-three'"
op|':'
number|'3.0'
op|','
nl|'\n'
stri... | code_fim | hard | {
"lang": "python",
"repo": "yasutaka-kamei/swift-token",
"path": "/test/unit/common/test_bufferedhttp.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yasutaka-kamei/swift-token path: /test/unit/common/test_bufferedhttp.py
begin_unit
comment|'# -*- coding: utf-8 -*-'
nl|'\n'
comment|'# Copyright (c) 2010-2012 OpenStack Foundation'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# Licensed under the Apache License, Version 2.0 (the "License");'
nl|'\n'
co... | code_fim | hard | {
"lang": "python",
"repo": "yasutaka-kamei/swift-token",
"path": "/test/unit/common/test_bufferedhttp.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DanDresser/zorrom path: /zorrom/util.py
def hexdump(src, length=16):
FILTER = ''.join([(len(repr(chr(x))) == 3) and chr(x) or '.'
for x in range(256)])
lines = []
for c in range(0, len(src), length):
chars = src[c:c + length]
hex = ' '.join(["%02x... | code_fim | hard | {
"lang": "python",
"repo": "DanDresser/zorrom",
"path": "/zorrom/util.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def tostr(buff):
if type(buff) is str:
return buff
elif type(buff) is bytearray or type(buff) is bytes:
return ''.join([chr(b) for b in buff])
else:
assert 0, type(buff)
'''
Convert a bytearray ROM file into a row/col bit dict w/ image convention
'''
def rom_bytes2t... | code_fim | hard | {
"lang": "python",
"repo": "DanDresser/zorrom",
"path": "/zorrom/util.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def rom_bytes2txtdict(mr, romb):
if len(romb) != mr.size():
raise ValueError()
ret = {}
txtw, txth = mr.txtwh()
for col in range(txtw):
for row in range(txth):
offset, maskb = mr.cr2ow(col, row)
byte = romb[offset]
bit = int(bool(byte & ... | code_fim | hard | {
"lang": "python",
"repo": "DanDresser/zorrom",
"path": "/zorrom/util.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: medunigraz/outpost.django.campusonline path: /src/outpost/django/campusonline/migrations/0013_course_group_term.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.11 on 2018-03-15 15:50
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations
... | code_fim | hard | {
"lang": "python",
"repo": "medunigraz/outpost.django.campusonline",
"path": "/src/outpost/django/campusonline/migrations/0013_course_group_term.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>CT
format('%s-%s-%s', termin_nr, lv_grp_nr, pers_nr) AS id,
termin_nr::integer AS termroom_id,
lv_grp_nr::integer AS coursegroup_id,
pers_nr::integer AS person_id,
lv_beginn AS start,
lv_ende AS end,
raum_nr::integer AS ro... | code_fim | hard | {
"lang": "python",
"repo": "medunigraz/outpost.django.campusonline",
"path": "/src/outpost/django/campusonline/migrations/0013_course_group_term.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> :link https://api-v2-docs.dome9.com/#cloudaccounts_updateorganziationalid
:param aws_cloud_account_id: The Dome9 Guid ID of the AWS cloud account
:type aws_cloud_account_id: str
:param body: The Guid ID of the Organizational Unit to attach to. Use 'null' to attach to the root Organizatio... | code_fim | hard | {
"lang": "python",
"repo": "dome9/dome9-sdk-python",
"path": "/dome9_type_annotations/aws_cloud_account.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
pass
@classmethod
def update_credentials(cls, body: CloudAccountCredentialsViewModel) -> Dict:
"""Update credentials for an AWS cloud account in Dome9. At least one of the following properties must be provided: "cloudAccountId", "externalAccountNumber"
:link https://api-v2-docs.dome9.co... | code_fim | hard | {
"lang": "python",
"repo": "dome9/dome9-sdk-python",
"path": "/dome9_type_annotations/aws_cloud_account.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dome9/dome9-sdk-python path: /dome9_type_annotations/aws_cloud_account.py
from typing import Dict, List, Union
from resources.aws_cloud_account import AwsCloudAccount as BaseAwsCloudAccount, CloudAccountCredentialsViewModel, CloudAccountUpdateOrganizationalUnitId, \
CloudAccountRegionConfigurat... | code_fim | hard | {
"lang": "python",
"repo": "dome9/dome9-sdk-python",
"path": "/dome9_type_annotations/aws_cloud_account.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: QDylan/Learning- path: /Leetcode/632. 最小区间.py
# -*- coding: utf-8 -*-
"""
@Time : 2020/8/1 10:00
@Author : QDY
@FileName: 632. 最小区间.py
@Software: PyCharm
"""
"""
你有k个升序排列的整数数组。找到一个最小区间,使得k个列表中的每个列表至少有一个数包含在其中。
我们定义如果b-a < d-c或者在b-a == d-c时a < c,则区间 [a,b] 比 [c,d] 小。
示例 1:
... | code_fim | medium | {
"lang": "python",
"repo": "QDylan/Learning-",
"path": "/Leetcode/632. 最小区间.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> k, heap = len(nums), []
for i in range(k): # 构建小根堆 时间复杂度O(nklogk),空间复杂度O(k)
heapq.heappush(heap, (nums[i][0], i, 0))
max_val = max(heap)[0] # 记录 小根堆中 最大的值
res = [heap[0][0], max_val]
while heap[0][2] < len(nums[heap[0][1]]) - 1:
val, id1,... | code_fim | medium | {
"lang": "python",
"repo": "QDylan/Learning-",
"path": "/Leetcode/632. 最小区间.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def smallestRange(self, nums):
k, heap = len(nums), []
for i in range(k): # 构建小根堆 时间复杂度O(nklogk),空间复杂度O(k)
heapq.heappush(heap, (nums[i][0], i, 0))
max_val = max(heap)[0] # 记录 小根堆中 最大的值
res = [heap[0][0], max_val]
while heap[0][2] < len(nums[heap... | code_fim | medium | {
"lang": "python",
"repo": "QDylan/Learning-",
"path": "/Leetcode/632. 最小区间.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NobuoTsukamoto/models path: /official/nlp/modeling/networks/fnet.py
# Copyright 2022 The TensorFlow Authors. 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 L... | code_fim | hard | {
"lang": "python",
"repo": "NobuoTsukamoto/models",
"path": "/official/nlp/modeling/networks/fnet.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dense_inputs = inputs.get('dense_inputs', None)
dense_mask = inputs.get('dense_mask', None)
dense_type_ids = inputs.get('dense_type_ids', None)
else:
raise ValueError('Unexpected inputs type (%s) to %s.' %
(type(inputs), self.__class__))
if word_embe... | code_fim | hard | {
"lang": "python",
"repo": "NobuoTsukamoto/models",
"path": "/official/nlp/modeling/networks/fnet.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ls().keys() if k not in _EXCLUDE and not k.startswith("_")]<|fim_prefix|># repo: zhenlongsong/Group-CAM path: /utils/__init__.py
from .imagenet import *
from .misc import *
from .target_la<|fim_middle|>yer import TargetLayer
from .cluster import group_sum
_EXCLUDE = {"torch", "torchvision"}
__all__ = [k... | code_fim | medium | {
"lang": "python",
"repo": "zhenlongsong/Group-CAM",
"path": "/utils/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhenlongsong/Group-CAM path: /utils/__init__.py
from .imagenet import *
from .misc import *
from .target_la<|fim_suffix|>ls().keys() if k not in _EXCLUDE and not k.startswith("_")]<|fim_middle|>yer import TargetLayer
from .cluster import group_sum
_EXCLUDE = {"torch", "torchvision"}
__all__ = [k... | code_fim | medium | {
"lang": "python",
"repo": "zhenlongsong/Group-CAM",
"path": "/utils/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tabatsky/imctools path: /imctools/load_multichannel_ome.py
# read in and display ImagePlus object(s)
from ij.io import OpenDialog
from ij import IJ
import os
import sys
<|fim_suffix|>def view_image5d_ome(img, ome_meta):
"""
:param img:
:param ome_meta:
:return:
"""
nchan... | code_fim | medium | {
"lang": "python",
"repo": "tabatsky/imctools",
"path": "/imctools/load_multichannel_ome.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
op = OpenDialog('Choose multichannel TIFF')
file = os.path.join(op.getDirectory(), op.getFileName())
load_and_view(file_name=file)<|fim_prefix|># repo: tabatsky/imctools path: /imctools/load_multichannel_ome.py
# read in and display ImagePlus object(s)
from ij.io import OpenDialog
from ij import IJ
imp... | code_fim | medium | {
"lang": "python",
"repo": "tabatsky/imctools",
"path": "/imctools/load_multichannel_ome.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: psymar/vizh path: /vizh/compiler.py
from vizh.ir import *
import vizh.util
import tempfile
import distutils.ccompiler
import os.path
import sys
import os
libv_decls = []
try:
# This is generated when the package is built
# and contains declarations for libv
import vizh.libv_decls
... | code_fim | hard | {
"lang": "python",
"repo": "psymar/vizh",
"path": "/vizh/compiler.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def compile_functions_to_c(self, functions, externs=[]):
"""Compiles the given IR functions to C.
Any functions which are called by these functions and
are not present (i.e. they'll be linked against later)
must have their signatures passed as externs.
... | code_fim | hard | {
"lang": "python",
"repo": "psymar/vizh",
"path": "/vizh/compiler.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: astsu-dev/pizza-store-backend path: /pizza_store/db/crud/category/crud.py
from typing import Optional
from pizza_store.db.models.category import Category
from sqlalchemy import delete, select
from sqlalchemy.ext.asyncio import AsyncSession
class CategoryCRUD:
"""Has methods for getting, ad... | code_fim | hard | {
"lang": "python",
"repo": "astsu-dev/pizza-store-backend",
"path": "/pizza_store/db/crud/category/crud.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
async def delete_category(cls, session: AsyncSession, id: int) -> None:
"""Deletes category by id.
NOTE: Does not commit.
Example:
>>> crud = CategoryCRUD()
>>> await crud.delete_category(session, id=1)
>>> await session.co... | code_fim | hard | {
"lang": "python",
"repo": "astsu-dev/pizza-store-backend",
"path": "/pizza_store/db/crud/category/crud.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
session (AsyncSession): sqlalchemy session
Returns:
list[Category]: list of categories.
"""
stmt = select(Category)
result = await session.execute(stmt)
return result.scalars().all()
@classmethod
def add_category(cls,... | code_fim | hard | {
"lang": "python",
"repo": "astsu-dev/pizza-store-backend",
"path": "/pizza_store/db/crud/category/crud.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def implement_genetic_algorithm():
done = False
answer = None
population = generate_swarm(10)
while not done:
new_population = []
for i in range(0, len(population)):
random_motif_dad = get_random_from_population(population)
random_motif_mom = get_ran... | code_fim | medium | {
"lang": "python",
"repo": "stackedq/Motif-discovery",
"path": "/pso.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stackedq/Motif-discovery path: /pso.py
import common
import random
import math
import time
all_created_motifs = []
enough_time = 60
def mutate(motif):
return common.generate_adjecent_motif(motif)
def reproduce(mom, dad):
random_index = random.randint(0, common.input_motif_length - 1)... | code_fim | hard | {
"lang": "python",
"repo": "stackedq/Motif-discovery",
"path": "/pso.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for motif in population:
if common.is_motif_valid(motif) == True:
done = True
answer = motif
break
if answer is not None:
return answer
else:
return False
st = common.start_time()
answer = implement_genetic_algo... | code_fim | hard | {
"lang": "python",
"repo": "stackedq/Motif-discovery",
"path": "/pso.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: anakli/this path: /logs/remove-redis-runlogs.py
#!/usr/bin/env python
<|fim_suffix|>r = redis.Redis(host=os.environ['REDIS_HOSTADDR'], port=6379)
#runlog_keys = r.delete("*")
for key in r.scan_iter('*'):
r.delete(key)<|fim_middle|>import redis
import os
import sys
| code_fim | easy | {
"lang": "python",
"repo": "anakli/this",
"path": "/logs/remove-redis-runlogs.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>for key in r.scan_iter('*'):
r.delete(key)<|fim_prefix|># repo: anakli/this path: /logs/remove-redis-runlogs.py
#!/usr/bin/env python
<|fim_middle|>import redis
import os
import sys
r = redis.Redis(host=os.environ['REDIS_HOSTADDR'], port=6379)
#runlog_keys = r.delete("*")
| code_fim | medium | {
"lang": "python",
"repo": "anakli/this",
"path": "/logs/remove-redis-runlogs.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> out.update({'saturation':for_out_a})
out.update({'switching_time':for_out_b})
return out
def invert(data_dict, keys = 'all'):
"""
Invert data. If keys set to 'all', all keys will be inverted except 'time'.
args:
keys (str or array-like): Which keys to invert... | code_fim | hard | {
"lang": "python",
"repo": "eparsonnet93/ekpmeasure",
"path": "/src/ekpy/analysis/FE_switching/_data_funcs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for p1, p2 in zip(p1_ida, p2_ida):
worker.append((p1 - p2)/R)
return {'time':data_dict['time'], 'dp':worker.build()}
def smooth(data_dict, key='dp', N=3, Wn=0.05):
"""
Apply butterworth filter (scipy.signal.butter) to specified key of data.
args:
data_dic... | code_fim | hard | {
"lang": "python",
"repo": "eparsonnet93/ekpmeasure",
"path": "/src/ekpy/analysis/FE_switching/_data_funcs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eparsonnet93/ekpmeasure path: /src/ekpy/analysis/FE_switching/_data_funcs.py
import pandas as pd
import numpy as np
from scipy.integrate import cumtrapz
import warnings
from scipy import signal
from ..data_funcs import _fod_dimensionality_fixer
from ..data_funcs import iterable_data_array
from .... | code_fim | hard | {
"lang": "python",
"repo": "eparsonnet93/ekpmeasure",
"path": "/src/ekpy/analysis/FE_switching/_data_funcs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> created_at = DateTime()
message = Foo()
self.assertEqual(message.get('created_at'), Timestamp())
self.assertEqual(message.created_at, datetime(1970, 1, 1, 0, 0))
message.created_at = datetime(2017, 2, 1, 15, 50, 1)
self.assertEqual(message.get('creat... | code_fim | medium | {
"lang": "python",
"repo": "sgalkina/venom",
"path": "/tests/common/test_converters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sgalkina/venom path: /tests/common/test_converters.py
# TODO Test DateTime and Date converters
from datetime import datetime
from unittest import TestCase
from venom import Message
from venom.common import Timestamp
from venom.common.fields import DateTime
from venom.converter import Converter
f... | code_fim | hard | {
"lang": "python",
"repo": "sgalkina/venom",
"path": "/tests/common/test_converters.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return int(value)
class Foo(Message):
int_id = ConverterField(StringConverter())
message = Foo()
self.assertEqual(message.get('int_id'), 0)
self.assertEqual(message.int_id, '0')
message.int_id = '42'
self.assertEqual(message.ge... | code_fim | hard | {
"lang": "python",
"repo": "sgalkina/venom",
"path": "/tests/common/test_converters.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ferranSanchezLlado/ModularChess path: /src/ModularChess/utils/MovementsGraph.py
import dataclasses
from typing import List, TYPE_CHECKING, Optional, cast
if TYPE_CHECKING:
from ModularChess.movements.Movement import Movement
@dataclasses.dataclass
class MovementsNode:
parent: Optional[... | code_fim | hard | {
"lang": "python",
"repo": "ferranSanchezLlado/ModularChess",
"path": "/src/ModularChess/utils/MovementsGraph.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self
def __next__(self) -> MovementsNode:
if self.current is None:
raise StopIteration
if self.direction_right:
if len(self.current) == 0:
raise StopIteration
self.current = self.current.children[0]
else:
... | code_fim | hard | {
"lang": "python",
"repo": "ferranSanchezLlado/ModularChess",
"path": "/src/ModularChess/utils/MovementsGraph.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def find_children_move(self, move: "Movement") -> Optional["MovementsNode"]:
for node in self.children:
if node.move == move:
return node
return None
@dataclasses.dataclass
class MovementsGraph:
root: Optional[MovementsNode] = None
current: Optiona... | code_fim | hard | {
"lang": "python",
"repo": "ferranSanchezLlado/ModularChess",
"path": "/src/ModularChess/utils/MovementsGraph.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: milvus-io/milvus path: /tests/python_client/testcases/test_collection.py
s['properties']
assert description == res
class TestReleaseAdvanced(TestcaseBase):
@pytest.mark.tags(CaseLabel.L0)
def test_release_collection_during_searching(self):
"""
target: test releas... | code_fim | hard | {
"lang": "python",
"repo": "milvus-io/milvus",
"path": "/tests/python_client/testcases/test_collection.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: milvus-io/milvus path: /tests/python_client/testcases/test_collection.py
ue #24634")
def test_create_collection_with_invalid_default_value_string(self, default_value):
"""
target: test create collection with maximum fields
method: create collection with maximum field n... | code_fim | hard | {
"lang": "python",
"repo": "milvus-io/milvus",
"path": "/tests/python_client/testcases/test_collection.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @pytest.mark.tags(CaseLabel.L0)
@pytest.mark.parametrize('binary_index', gen_binary_index())
@pytest.mark.parametrize('metric_type', ct.binary_metrics)
def test_load_partition_after_index_binary(self, binary_index, metric_type):
"""
target: test load binary_collection, afte... | code_fim | hard | {
"lang": "python",
"repo": "milvus-io/milvus",
"path": "/tests/python_client/testcases/test_collection.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fusion-jena/JenTab path: /services/Solver/preprocessing/type_prediciton/config.py
# These are the common special chars occured w<|fim_suffix|>, ' ']
# get_type_lst will sample at most x entries from a given query
MAX_SAMPLE_SIZE = 500<|fim_middle|>ith numbers
Num_Special_Chars = [',', '-', '+' | code_fim | easy | {
"lang": "python",
"repo": "fusion-jena/JenTab",
"path": "/services/Solver/preprocessing/type_prediciton/config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ntries from a given query
MAX_SAMPLE_SIZE = 500<|fim_prefix|># repo: fusion-jena/JenTab path: /services/Solver/preprocessing/type_prediciton/config.py
# These are the common special chars occured with numbers
Num_Special_Chars = [',', '-', '+'<|fim_middle|>, ' ']
# get_type_lst will sample at most x e | code_fim | easy | {
"lang": "python",
"repo": "fusion-jena/JenTab",
"path": "/services/Solver/preprocessing/type_prediciton/config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: schmitzmelissa/unity-ml-penguins path: /ml-agents/mlagents/trainers/brain.py
from mlagents_envs.communicator_objects.agent_info_pb2 import AgentInfoProto
from mlagents_envs.communicator_objects.brain_parameters_pb2 import BrainParametersProto
from typing import List, NamedTuple
class CameraReso... | code_fim | hard | {
"lang": "python",
"repo": "schmitzmelissa/unity-ml-penguins",
"path": "/ml-agents/mlagents/trainers/brain.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> brain_params = BrainParameters(
brain_name=brain_param_proto.brain_name,
vector_observation_space_size=total_vector_obs,
camera_resolutions=resolutions,
vector_action_space_size=list(brain_param_proto.vector_action_size),
vector_action_de... | code_fim | hard | {
"lang": "python",
"repo": "schmitzmelissa/unity-ml-penguins",
"path": "/ml-agents/mlagents/trainers/brain.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Linear solver
linear_solver = IncompressibleSolver(eqns)
# Time stepper
stepper = SemiImplicitQuasiNewton(eqns, io, transported_fields,
transport_methods,
linear_solver=linear_solver)
# ------------------------------------------------... | code_fim | hard | {
"lang": "python",
"repo": "firedrakeproject/gusto",
"path": "/examples/incompressible/skamarock_klemp_incompressible.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: firedrakeproject/gusto path: /examples/incompressible/skamarock_klemp_incompressible.py
"""
The gravity wave test case of Skamarock and Klemp (1994), solved using the
incompressible Boussinesq equations.
Buoyancy is transported using SUPG.
"""
from gusto import *
from firedrake import (as_vecto... | code_fim | hard | {
"lang": "python",
"repo": "firedrakeproject/gusto",
"path": "/examples/incompressible/skamarock_klemp_incompressible.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Equation
parameters = CompressibleParameters()
eqns = IncompressibleBoussinesqEquations(domain, parameters)
# I/O
output = OutputParameters(
dirname='skamarock_klemp_incompressible',
dumpfreq=dumpfreq,
dumplist=['u'],
)
# list of diagnostic fields, each defined in a class in diagnostics.py
... | code_fim | hard | {
"lang": "python",
"repo": "firedrakeproject/gusto",
"path": "/examples/incompressible/skamarock_klemp_incompressible.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>nfo = (2, 0, 14)
SERVER_NAME = 'TWS'
SERVER_INFO = '%s/%s' % (SERVER_NAME, version)<|fim_prefix|># repo: bufferx/twork path: /twork/__init__.py
__import__('pkg_resources').declare_namesp<|fim_middle|>ace(__name__)
version = "2.0.14"
version_i | code_fim | easy | {
"lang": "python",
"repo": "bufferx/twork",
"path": "/twork/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bufferx/twork path: /twork/__init__.py
__import__('pkg_resources').declare_namesp<|fim_suffix|>ER_INFO = '%s/%s' % (SERVER_NAME, version)<|fim_middle|>ace(__name__)
version = "2.0.14"
version_info = (2, 0, 14)
SERVER_NAME = 'TWS'
SERV | code_fim | medium | {
"lang": "python",
"repo": "bufferx/twork",
"path": "/twork/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_preds(model:nn.Module, dl:DataLoader, pbar:Optional[PBar]=None, cb_handler:Optional[CallbackHandler]=None,
activ:nn.Module=None, loss_func:OptLossFunc=None, n_batch:Optional[int]=None) -> List[Tensor]:
"Tuple of predictions and targets, and optional losses (if `loss_f... | code_fim | hard | {
"lang": "python",
"repo": "cahya-wirawan/FastAI-Course",
"path": "/flower/lesson1-flower-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> "Return prect class, label and probabilities for `img`."
ds = self.data.valid_ds
ds.set_item(img)
res = self.pred_batch()[0]
ds.clear_item()
pred_max = res.argmax()
return self.data.classes[pred_max],pred_max,res
def create_cnn_2(arch:Callable, n_cl... | code_fim | hard | {
"lang": "python",
"repo": "cahya-wirawan/FastAI-Course",
"path": "/flower/lesson1-flower-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cahya-wirawan/FastAI-Course path: /flower/lesson1-flower-1.py
from fastai import *
from fastai.vision import *
from fastai.callbacks.hooks import num_features_model
from torch.autograd import Variable
import dill
import pickle
from torchvision import datasets, models, transforms
from PIL import I... | code_fim | hard | {
"lang": "python",
"repo": "cahya-wirawan/FastAI-Course",
"path": "/flower/lesson1-flower-1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: apache/airflow path: /tests/providers/amazon/aws/transfers/test_salesforce_to_s3.py
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. ... | code_fim | hard | {
"lang": "python",
"repo": "apache/airflow",
"path": "/tests/providers/amazon/aws/transfers/test_salesforce_to_s3.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert f"s3://{S3_BUCKET}/{S3_KEY}" == operator.execute({})
mock_make_query.assert_called_once_with(
query=QUERY, include_deleted=INCLUDE_DELETED, query_params=QUERY_PARAMS
)
mock_write_object_to_file.assert_called_once_with(
query_results=SALESFOR... | code_fim | hard | {
"lang": "python",
"repo": "apache/airflow",
"path": "/tests/providers/amazon/aws/transfers/test_salesforce_to_s3.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lawlietsoul/ML_Course_Code_Report path: /Faber_Code/02-Repeat_Table3/prop.py
#---- prop.py
# Parse properties, or unit conversion utilities specified to QM9 dataset.
#----
#---- function parse_prop
# Parse standardized QM9 database molecule properties.
# The file with the input... | code_fim | hard | {
"lang": "python",
"repo": "lawlietsoul/ML_Course_Code_Report",
"path": "/Faber_Code/02-Repeat_Table3/prop.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>3885)
for Indi, i in enumerate(QM9_Prop_File):
temp_strlst = i.split()
QM9_Index[Indi] = int(temp_strlst[0].replace("qm9:",""))
for Indj in range(13):
QM9_Prop[int(temp_strlst[0][4:])-1][Indj] = float(temp_strlst[Indj+2])
return (QM9_Prop, QM9_Index)<|fim_prefix... | code_fim | hard | {
"lang": "python",
"repo": "lawlietsoul/ML_Course_Code_Report",
"path": "/Faber_Code/02-Repeat_Table3/prop.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: snowflakedb/snowflake-kafka-connector path: /test/test_suit/test_snowpipe_streaming_schema_mapping_dlq.py
from test_suit.test_utils import RetryableError, NonRetryableError
import json
import datetime
# Test if incorrect data with a schematized column gets send to DLQ
# It sends a String to a co... | code_fim | hard | {
"lang": "python",
"repo": "snowflakedb/snowflake-kafka-connector",
"path": "/test/test_suit/test_snowpipe_streaming_schema_mapping_dlq.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.gold = {
'PERFORMANCE_STRING': 'Excellent',
'RATING_INT': 100
}
def getConfigFileName(self):
return self.fileName + ".json"
def send(self):
# Send incorrect data and send correct data, in serialized fashion
key = []
val... | code_fim | hard | {
"lang": "python",
"repo": "snowflakedb/snowflake-kafka-connector",
"path": "/test/test_suit/test_snowpipe_streaming_schema_mapping_dlq.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Put the legend text only once
label = None
if first_band_1 and band_type % 2 == 0:
first_band_1 = False
label = all_data.get("legend_text", None)
elif first_band_2 and band_type % 2 == 1:
first_band_2 = False... | code_fim | hard | {
"lang": "python",
"repo": "aiidateam/aiida-wannier90-workflows",
"path": "/src/aiida_wannier90_workflows/utils/workflows/plot/bands.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aiidateam/aiida-wannier90-workflows path: /src/aiida_wannier90_workflows/utils/workflows/plot/bands.py
ermi', zorder=-1)\n"
replacement += "pl.legend()\n\n"
replacement += "for path in paths:"
dft_mpl_code = dft_mpl_code.replace(b"for path in paths:", replacement.encode())... | code_fim | hard | {
"lang": "python",
"repo": "aiidateam/aiida-wannier90-workflows",
"path": "/src/aiida_wannier90_workflows/utils/workflows/plot/bands.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>logging.getLogger("pyrogram").setLevel(logging.WARNING)
@app.on_message(pyrogram.filters.command(["search"]))
async def ytsearch(_, message: Message):
try:
if len(message.command) < 2:
await message.reply_text("/search needs an argument!")
return
query = messa... | code_fim | medium | {
"lang": "python",
"repo": "INFINITY00800/infinitymusicbot",
"path": "/infinityMusicBot/modules/ytsearch.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: INFINITY00800/infinitymusicbot path: /infinityMusicBot/modules/ytsearch.py
# the logging things
import logging
from pyrogram import Client as app
from pyrogram.types import Message
from youtube_search import YoutubeSearch
logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(nam... | code_fim | medium | {
"lang": "python",
"repo": "INFINITY00800/infinitymusicbot",
"path": "/infinityMusicBot/modules/ytsearch.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># URL for requesting token
tok_url = 'http://localhost:8088/apps/access_token/'
r = requests.post(tok_url, headers=headers, data=payload)
r = json.loads(r.text)
token = r['token']
print('-------------------------------------------------------------------')
print(r)<|fim_prefix|># repo: xod442/paw path... | code_fim | easy | {
"lang": "python",
"repo": "xod442/paw",
"path": "/tok.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r = json.loads(r.text)
token = r['token']
print('-------------------------------------------------------------------')
print(r)<|fim_prefix|># repo: xod442/paw path: /tok.py
import requests
import json
app_id = 'wendys'
app_secret = 'test'
headers = {"Content-Type":"application/json"}
payload = {"app_... | code_fim | medium | {
"lang": "python",
"repo": "xod442/paw",
"path": "/tok.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xod442/paw path: /tok.py
import requests
import json
app_id = 'wendys'
app_secret = 'test'
headers = {"Content-Type":"application/json"}
payload = {"app_id":app_id,"app_secret":app_secret}
# Convert to json
payload=json.dumps(payload)
# URL for requesting token
tok_url = 'http://localhost:808... | code_fim | easy | {
"lang": "python",
"repo": "xod442/paw",
"path": "/tok.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gregdavill/litex path: /litex/compat/soc_add_spi_flash.py
####################################################################################################
# DISCLAIMER: Provides retro-compatibility layer for add_spi_flash with previous LiteX core.
# Will soon no longer work... | code_fim | hard | {
"lang": "python",
"repo": "gregdavill/litex",
"path": "/litex/compat/soc_add_spi_flash.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Core.
soc.check_if_exists(name)
spiflash = SpiFlash(
pads = soc.platform.request(name if mode == "1x" else name + mode),
dummy = dummy_cycles,
div = ceil(soc.clk_freq/clk_freq),
with_bitbang = True,
endianness = soc.cpu.endian... | code_fim | hard | {
"lang": "python",
"repo": "gregdavill/litex",
"path": "/litex/compat/soc_add_spi_flash.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tungstenfabric/tf-controller path: /src/config/utils/slo_rules.py
#!/usr/bin/python
#
#Copyright (c) 2017 Juniper Networks, Inc. All rights reserved.
#
from __future__ import print_function
from future import standard_library
standard_library.install_aliases()
from builtins import str
from built... | code_fim | hard | {
"lang": "python",
"repo": "tungstenfabric/tf-controller",
"path": "/src/config/utils/slo_rules.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
pol = self._vnc_lib.network_policy_read(fq_name = None, fq_name_str=self._args.policy_fq_name)
except NoIdError:
print("Network policy %s does NOT exist" %(self._args.policy_fq_name))
return
#create empty SLO rule list
slo_rule_list ... | code_fim | hard | {
"lang": "python",
"repo": "tungstenfabric/tf-controller",
"path": "/src/config/utils/slo_rules.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: slimshreydy/advent-of-code path: /submissions/day23.py
from advent import AdventProblem
from tqdm import tqdm
from collections import deque
def preprocess(lines):
return [int(x) for x in lines[0]]
def decrement_cup(n, wrap_to):
if n == 1:
return wrap_to
else:
retur... | code_fim | hard | {
"lang": "python",
"repo": "slimshreydy/advent-of-code",
"path": "/submissions/day23.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for _ in tqdm(range(10000000)):
sidelined = order.pop_slice(curr_node.next, 3)
dest_val = curr_node.val
while dest_val in sidelined or dest_val == curr_node.val:
dest_val = decrement_cup(dest_val, wrap_to=1000000)
dest_node = order.find(dest_val)
cir... | code_fim | hard | {
"lang": "python",
"repo": "slimshreydy/advent-of-code",
"path": "/submissions/day23.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gtshepard/pycomplete path: /pycomplete/test_autocomplete.py
import pytest as py
import topktrie as topk
import autocomplete as ac
# test trie
class TestTopK:
def test_get_index(self):
trie = topk.TopkTrie(file_path=None)
# characters are always converted lower case
... | code_fim | hard | {
"lang": "python",
"repo": "gtshepard/pycomplete",
"path": "/pycomplete/test_autocomplete.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> autocomplete = ac.AutoComplete()
print("animal")
autocomplete.record_word("animal")
autocomplete.record_word("animal")
autocomplete.record_word("animal")
# animal should inserted into trie with frequency of 4,
# becuase animal is in the preloaded wo... | code_fim | hard | {
"lang": "python",
"repo": "gtshepard/pycomplete",
"path": "/pycomplete/test_autocomplete.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrFlamboyyandt/analyse_hackathon path: /hackathon/sorting.py
def bubble_sort(items):
'''
Return array of items, sorted in ascending order by the bubble sort method
Args:
items (array)
Returns:
array (ascending order)
Example:
>> bubble_sort([54,2... | code_fim | hard | {
"lang": "python",
"repo": "MrFlamboyyandt/analyse_hackathon",
"path": "/hackathon/sorting.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return items
def quick_sort(items):
'''
Return array of items, sorted in ascending order by the quick sort method
Args:
items (array)
Returns:
array (ascending order)
Example:
>> quick_sort([54,26,93,17,77,31,44,55,20,52])
[17, 20, 26, 3... | code_fim | hard | {
"lang": "python",
"repo": "MrFlamboyyandt/analyse_hackathon",
"path": "/hackathon/sorting.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while j < len(right):
items[k]=right[j]
j=j+1
k=k+1
return items
def quick_sort(items):
'''
Return array of items, sorted in ascending order by the quick sort method
Args:
items (array)
Returns:
array (asce... | code_fim | hard | {
"lang": "python",
"repo": "MrFlamboyyandt/analyse_hackathon",
"path": "/hackathon/sorting.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def as_input(s):
"use in test, use given string as input file"
import io
global read, input
f = io.StringIO(s.strip())
input = f.readline
read = f.read
USE_NUMBA = False
if (USE_NUMBA and sys.argv[-1] == 'ONLINE_JUDGE') or sys.argv[-1] == '-c':
print("compiling")
from nu... | code_fim | hard | {
"lang": "python",
"repo": "nishio/atcoder",
"path": "/dp/g_old.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> >>> as_input(T3)
>>> main()
3
"""
import doctest
doctest.testmod()
def as_input(s):
"use in test, use given string as input file"
import io
global read, input
f = io.StringIO(s.strip())
input = f.readline
read = f.read
USE_NUMBA = False
if (USE_NUMBA and... | code_fim | hard | {
"lang": "python",
"repo": "nishio/atcoder",
"path": "/dp/g_old.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nishio/atcoder path: /dp/g_old.py
#!/usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
def debug(*x):
print(*x)
def solve0(... | code_fim | hard | {
"lang": "python",
"repo": "nishio/atcoder",
"path": "/dp/g_old.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Exception for overlapped folder name
try:
os.mkdir(face_path)
print('Face directory is created :: ', face_path)
except FileExistsError:
print('Folder name exception :: already registered face')
# Path adequacy check
assert os.path.exists(face_path)
# Set ... | code_fim | hard | {
"lang": "python",
"repo": "noviicee/CoinShift-Imaging-Box",
"path": "/Helmet Detection/face_register.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: noviicee/CoinShift-Imaging-Box path: /Helmet Detection/face_register.py
import face_recognition
from PIL import Image, ImageDraw
import argparse
import os
import cv2
import camera
import face_recog
import numpy as np
import DBmanager
import random
# Define args property
parser = argparse.Argument... | code_fim | hard | {
"lang": "python",
"repo": "noviicee/CoinShift-Imaging-Box",
"path": "/Helmet Detection/face_register.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>app = core.App()
CiCdkStack(app, "ci-cdk")
app.synth()<|fim_prefix|># repo: arjunne/CIMapping path: /app.py
#!/usr/bin/env python3
<|fim_middle|>from aws_cdk import core
from ci_cdk.ci_cdk_stack import CiCdkStack
| code_fim | medium | {
"lang": "python",
"repo": "arjunne/CIMapping",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
app = core.App()
CiCdkStack(app, "ci-cdk")
app.synth()<|fim_prefix|># repo: arjunne/CIMapping path: /app.py
#!/usr/bin/env python3
<|fim_middle|>from aws_cdk import core
from ci_cdk.ci_cdk_stack import CiCdkStack
| code_fim | medium | {
"lang": "python",
"repo": "arjunne/CIMapping",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.