text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>admin.site.register(Trains, TrainAdmin)<|fim_prefix|># repo: GowthamKumar1626/TRAIN-BOOKING-SYSTEM-DJANGO path: /trainbooking/trains/admin.py
from django.contrib import admin
from trains.models import Trains
class TrainAdmin(admin.ModelAdmin):
<|fim_middle|> model = Trains
list_display = ["t... | code_fim | medium | {
"lang": "python",
"repo": "GowthamKumar1626/TRAIN-BOOKING-SYSTEM-DJANGO",
"path": "/trainbooking/trains/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GowthamKumar1626/TRAIN-BOOKING-SYSTEM-DJANGO path: /trainbooking/trains/admin.py
from django.contrib import admin
from trains.models import Trains
class TrainAdmin(admin.ModelAdmin):
<|fim_suffix|>admin.site.register(Trains, TrainAdmin)<|fim_middle|> model = Trains
list_display = ["t... | code_fim | medium | {
"lang": "python",
"repo": "GowthamKumar1626/TRAIN-BOOKING-SYSTEM-DJANGO",
"path": "/trainbooking/trains/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jf---/compas_assembly path: /src/compas_assembly/datastructures/courses.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
__all__ = ['assembly_courses']
<|fim_suffix|># ==============================================================... | code_fim | hard | {
"lang": "python",
"repo": "jf---/compas_assembly",
"path": "/src/compas_assembly/datastructures/courses.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> seen = set()
seen.update(base)
vertices -= base
while vertices:
nbrs = set(nbr for key in courses[-1] for nbr in wall.neighbors(key))
course = list(nbrs - seen)
courses.append(course)
seen.update(nbrs)
vertices -... | code_fim | hard | {
"lang": "python",
"repo": "jf---/compas_assembly",
"path": "/src/compas_assembly/datastructures/courses.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># ==============================================================================
# Main
# ==============================================================================
if __name__ == '__main__':
pass<|fim_prefix|># repo: jf---/compas_assembly path: /src/compas_assembly/datastructures/courses.py
fro... | code_fim | hard | {
"lang": "python",
"repo": "jf---/compas_assembly",
"path": "/src/compas_assembly/datastructures/courses.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stanfordnlp/stanza path: /stanza/tests/common/test_data_conversion.py
"""
Basic tests of the data conversion
"""
import pytest
import tempfile
from zipfile import ZipFile
import stanza
from stanza.utils.conll import CoNLL
from stanza.models.common.doc import Document
from stanza.tests import *
... | code_fim | hard | {
"lang": "python",
"repo": "stanfordnlp/stanza",
"path": "/stanza/tests/common/test_data_conversion.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># sample is two sentences long so that the tests check multiple sentences
RUSSIAN_SAMPLE="""
# sent_id = yandex.reviews-f-8xh5zqnmwak3t6p68y4rhwd4e0-1969-9253
# genre = review
# text = Как- то слишком мало цветов получают актёры после спектакля.
1 Как как-то ADV _ Degree=Pos|PronType=Ind 7 advmod _ SpaceA... | code_fim | hard | {
"lang": "python",
"repo": "stanfordnlp/stanza",
"path": "/stanza/tests/common/test_data_conversion.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shashank025/codeeval path: /streamdiff.py
"""Compute the diff of two streams.
Usage:
python3 diff.py <stream_a> <stream_b>
For example, if stream_a has the contents:
a
b
c
d
and stream_b has the contents:
a
a
c
e
f
then, the output will be:
a
-b
+a
c
-d
+e
+f
"""
import argparse
import... | code_fim | hard | {
"lang": "python",
"repo": "shashank025/codeeval",
"path": "/streamdiff.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> >>> ''.join(list(diff(iter('abc'), iter(''))))
'-a-b-c'
>>> ''.join(list(diff(iter(''), iter('abc'))))
'+a+b+c'
>>> ''.join(list(diff(iter('abc'), iter('xyzacbuvw'))))
'+x+y+z a+c b-c+u+v+w'
>>> ''.join(list(diff(iter('abcd'), iter('aace'))))
' a-b+a c-d+e'
>>> ''.join(... | code_fim | hard | {
"lang": "python",
"repo": "shashank025/codeeval",
"path": "/streamdiff.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AdrianGPrado/load-balancer path: /app/project_settings.py
import os
dirname = os.path.dirname(__<|fim_suffix|>name, 'website/static')
TEMPLATE_PATH = os.path.join(dirname, 'website/views')<|fim_middle|>file__)
STATIC_PATH = os.path.join(dir | code_fim | easy | {
"lang": "python",
"repo": "AdrianGPrado/load-balancer",
"path": "/app/project_settings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> os.path.join(dirname, 'website/views')<|fim_prefix|># repo: AdrianGPrado/load-balancer path: /app/project_settings.py
import os
dirname = os.path.dirname(__<|fim_middle|>file__)
STATIC_PATH = os.path.join(dirname, 'website/static')
TEMPLATE_PATH = | code_fim | medium | {
"lang": "python",
"repo": "AdrianGPrado/load-balancer",
"path": "/app/project_settings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NaluCFD/Nalu path: /reg_tests/test_files/mixedTetPipe/pipe_tet_catalyst.py
# script-version: 2.0
# Catalyst state generated using paraview version 5.9.0
#### import the simple module from the paraview
from paraview.simple import *
#### disable automatic camera reset on 'Show'
paraview.simple._Di... | code_fim | hard | {
"lang": "python",
"repo": "NaluCFD/Nalu",
"path": "/reg_tests/test_files/mixedTetPipe/pipe_tet_catalyst.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># create extractor
pNG1 = CreateExtractor('PNG', renderView1, registrationName='PNG1')
# trace defaults for the extractor.
# init the 'PNG' selected for 'Writer'
pNG1.Writer.FileName = 'CatalystTestImage_%.6ts%cm.png'
pNG1.Writer.ImageResolution = [844, 539]
pNG1.Writer.Format = 'PNG'
# -----------------... | code_fim | hard | {
"lang": "python",
"repo": "NaluCFD/Nalu",
"path": "/reg_tests/test_files/mixedTetPipe/pipe_tet_catalyst.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> dm.add_middleware(_middle)
dm.add_dialogue_rule("middleware_test", _handler, intent="middle")
request = create_request("domain", "middle")
response = create_responder(request)
result = await dm.apply_handler(request, response)
assert result.dialogue_state ==... | code_fim | hard | {
"lang": "python",
"repo": "cisco/mindmeld",
"path": "/tests/components/test_dialogue_async.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> async def _first(ctx, responder, handler):
responder.frame["middles"] = responder.frame.get("middles", []) + ["first"]
await handler(ctx, responder)
async def _second(ctx, responder, handler):
responder.frame["middles"] = responder.frame.get("middles", ... | code_fim | hard | {
"lang": "python",
"repo": "cisco/mindmeld",
"path": "/tests/components/test_dialogue_async.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cisco/mindmeld path: /tests/components/test_dialogue_async.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
test_dialogue
----------------------------------
Tests for dialogue module.
These tests apply only when async/await are supported.
"""
# pylint: disable=locally-disabled,redefined-ou... | code_fim | hard | {
"lang": "python",
"repo": "cisco/mindmeld",
"path": "/tests/components/test_dialogue_async.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jaklinger/nesta_toolbox path: /sandbox/jaklinger/superfuzz/superfuzz.py
import math
from functools import reduce
def superfuzz(s1,s2,algs,length_norm=False):
# Calculate the score from each algorithm
scores = [alg(s1,s2) for alg in algs]
# Score = Sqrt(Sum_a(score_a^2) / N_a)
sco... | code_fim | medium | {
"lang": "python",
"repo": "jaklinger/nesta_toolbox",
"path": "/sandbox/jaklinger/superfuzz/superfuzz.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(superfuzz(s1,s2,[fuzz.ratio]))
print(superfuzz(s1,s2,[fuzz.ratio],length_norm=True))
print(superfuzz(s1,s2,[fuzz.ratio,fuzz.token_sort_ratio]))
print(superfuzz(s1,s2,[fuzz.ratio,fuzz.token_sort_ratio],length_norm=True))<|fim_prefix|># repo: jaklinger/nesta_toolbox path: /sandbox/jak... | code_fim | medium | {
"lang": "python",
"repo": "jaklinger/nesta_toolbox",
"path": "/sandbox/jaklinger/superfuzz/superfuzz.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mydjangoprojects/recipe-mpa path: /app/core/views.py
from django.urls import reverse_lazy
from django.views import generic
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from django.contrib.auth import get_user_model
from .forms import CustomUserCreationForm
User = get... | code_fim | hard | {
"lang": "python",
"repo": "mydjangoprojects/recipe-mpa",
"path": "/app/core/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> paginator = Paginator(queryset, self.paginate_by)
page = self.request.GET.get('page')
try:
objects = paginator.page(page)
except PageNotAnInteger:
objects = paginator.page(1)
except TypeError:
objects = paginator.page(1)
... | code_fim | medium | {
"lang": "python",
"repo": "mydjangoprojects/recipe-mpa",
"path": "/app/core/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lucinezhong/controllers_ode_COVID path: /Code/impact evaluation/selection of NPIs.py
import sys
sys.path.append('Project')
from input_library import *
import Input
emergency_date=datetime.datetime.strptime('2020-03-13', '%Y-%m-%d')
start_date=datetime.datetime.strptime('2020-04-01', '%Y-%m-%d')
... | code_fim | hard | {
"lang": "python",
"repo": "lucinezhong/controllers_ode_COVID",
"path": "/Code/impact evaluation/selection of NPIs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return (1-a1 * x[:, 0]-a2 * x[:, 1]-a3 * x[:, 2]-a4 * x[:, 3] ) *(1-b1 * x[:, 4]-b2* x[:, 5]-b3 * x[:, 6]-b4* x[:, 7] )-1
def func_delta(x, a1, a2, a3,a4,b1,b2,b3,b4):
return (1-a1 * x[:, 0]-a2 * x[:, 1]-a3 * x[:, 2]-a4 * x[:, 3] ) *(1-b1 * x[:, 4]-b2* x[:, 5]-b3 * x[:, 6]-b4* x[:, 7] )-1
def fu... | code_fim | hard | {
"lang": "python",
"repo": "lucinezhong/controllers_ode_COVID",
"path": "/Code/impact evaluation/selection of NPIs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> customized_layers = FullyConnectedNetwork(
[input_dim] + sizes + [linucb_inp_dim],
activations,
use_batch_norm=False,
dropout_ratio=0.0,
normalize_output=False,
use_layer_norm=False,
)
policy_network = DeepRepr... | code_fim | medium | {
"lang": "python",
"repo": "facebookresearch/ReAgent",
"path": "/reagent/test/training/cb/test_deep_represent_linucb.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: facebookresearch/ReAgent path: /reagent/test/training/cb/test_deep_represent_linucb.py
"""
How to use:
buck test reagent:training_tests -- TestDeepRepresentLinUCB
"""
import unittest
import torch
from reagent.core.types import CBInput
from reagent.gym.policies.policy import Policy
from reag... | code_fim | hard | {
"lang": "python",
"repo": "facebookresearch/ReAgent",
"path": "/reagent/test/training/cb/test_deep_represent_linucb.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.policy = Policy(scorer=policy_network, sampler=GreedyActionSampler())
self.trainer = DeepRepresentLinUCBTrainer(self.policy, **self.params.asdict())
self.batch = CBInput(
context_arm_features=torch.rand(2, 2, input_dim),
action=torch.tensor([[0], [1]], ... | code_fim | hard | {
"lang": "python",
"repo": "facebookresearch/ReAgent",
"path": "/reagent/test/training/cb/test_deep_represent_linucb.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: umap-project/umap path: /umap/tests/test_licence.py
import pytest
from umap.models import DataLayer, Map
pytestmark = pytest.mark.django_db
<|fim_suffix|> assert map.licence == licence
licence.delete()
assert Map.objects.filter(pk=map.pk).exists()
assert DataLayer.objects.filter... | code_fim | medium | {
"lang": "python",
"repo": "umap-project/umap",
"path": "/umap/tests/test_licence.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert map.licence == licence
licence.delete()
assert Map.objects.filter(pk=map.pk).exists()
assert DataLayer.objects.filter(pk=datalayer.pk).exists()<|fim_prefix|># repo: umap-project/umap path: /umap/tests/test_licence.py
import pytest
from umap.models import DataLayer, Map
<|fim_midd... | code_fim | medium | {
"lang": "python",
"repo": "umap-project/umap",
"path": "/umap/tests/test_licence.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>artnerURL"),
url(r"^getChargeInfo$", views.getChargeInfo, name="GetChargeInfo"),
url(r"^getAccessURL", views.getAccessURL, name="GetAccessURL"),
url(r"^checkIsMember$", views.checkIsMember, name="CheckIsMember"),
url(r"^checkID$", views.checkID, name="CheckID"),
url(r"^joinMember$", vi... | code_fim | hard | {
"lang": "python",
"repo": "linkhub-sdk/popbill.example.django",
"path": "/EasyFinBankExample/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: linkhub-sdk/popbill.example.django path: /EasyFinBankExample/urls.py
# -*- coding: utf-8 -*-
from django.conf.urls import url
from . import views
urlpatterns = [
# Index Page
url(r"^$", views.index, name="index"),
url(r"^registBankAccount$", views.registBankAccount, name="RegistBank... | code_fim | hard | {
"lang": "python",
"repo": "linkhub-sdk/popbill.example.django",
"path": "/EasyFinBankExample/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.on_event("startup")
async def startup():
setup_env()
setup_logging()
redis_url = get_redis_url()
if redis_url:
redis = await aioredis.create_redis_pool(redis_url, encoding="utf8")
FastAPICache.init(RedisBackend(redis), prefix="fastapi-cache")
else:
FastAPIC... | code_fim | hard | {
"lang": "python",
"repo": "tixo/spellbot",
"path": "/src/spellapi/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = {"guilds": guilds, "username": username}
expires_delta = timedelta(minutes=ACCESS_TOKEN_EXPIRE_MINUTES)
access_token = create_access_token(data=data, expires_delta=expires_delta)
token = jsonable_encoder(access_token)
response = JSONResponse(data)
res... | code_fim | hard | {
"lang": "python",
"repo": "tixo/spellbot",
"path": "/src/spellapi/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tixo/spellbot path: /src/spellapi/__init__.py
import json
import logging
from contextlib import asynccontextmanager
from datetime import datetime, timedelta
from os import getenv
from typing import AsyncGenerator, Optional
import aiohttp
import aioredis # type: ignore
import coloredlogs # type... | code_fim | hard | {
"lang": "python",
"repo": "tixo/spellbot",
"path": "/src/spellapi/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#处理被覆盖的标签
for label in ax.get_xticklabels()+ax.get_yticklabels():
label.set_fontsize(12) #{'facecolor':'white','edgecolor':'None','alpha':0.7}
label.set_bbox(dict(facecolor='white',edgecolor='None',alpha=0.7))
label.set_zorder(1)
plt.show()<|fim_prefix|># repo: lizhangjie316/ComputerVision ... | code_fim | medium | {
"lang": "python",
"repo": "lizhangjie316/ComputerVision",
"path": "/01-python/source code/05_matplotlib/05_axis_tick.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#print(ax.get_xticklabels()) #标签对象的列表
#print(ax.get_xticklabels()+ax.get_yticklabels()) #标签对象的列表
#处理被覆盖的标签
for label in ax.get_xticklabels()+ax.get_yticklabels():
label.set_fontsize(12) #{'facecolor':'white','edgecolor':'None','alpha':0.7}
label.set_bbox(dict(facecolor='white',edgecolor='None',... | code_fim | hard | {
"lang": "python",
"repo": "lizhangjie316/ComputerVision",
"path": "/01-python/source code/05_matplotlib/05_axis_tick.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lizhangjie316/ComputerVision path: /01-python/source code/05_matplotlib/05_axis_tick.py
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(-3,3,50)
y=0.1*x
<|fim_suffix|>#处理被覆盖的标签
for label in ax.get_xticklabels()+ax.get_yticklabels():
label.set_fontsize(12) #{'facecolor':'whi... | code_fim | hard | {
"lang": "python",
"repo": "lizhangjie316/ComputerVision",
"path": "/01-python/source code/05_matplotlib/05_axis_tick.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: team-telnyx/telnyx-python path: /tests/conftest.py
from __future__ import absolute_import, division, print_function
import atexit
import os
import sys
import pytest
from tests.request_mock import RequestMock
from tests.telnyx_mock import TelnyxMock
import telnyx
from telnyx.six.moves.urllib.e... | code_fim | hard | {
"lang": "python",
"repo": "team-telnyx/telnyx-python",
"path": "/tests/conftest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
try:
resp = urlopen("http://localhost:%s/" % MOCK_PORT)
info = resp.info()
except HTTPError as e:
info = e.info()
except Exception:
sys.exit(
"Couldn't reach telnyx-mock at `localhost:%s`. Is "
"it running? Please see README for setup instructions." % MOCK_PORT
)
"""
... | code_fim | hard | {
"lang": "python",
"repo": "team-telnyx/telnyx-python",
"path": "/tests/conftest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sushant/intellafeed path: /lib/aggregator.py
'''
Created on Sep 28, 2013
@author: ralekar
'''
import string
import unicodedata, re, json
from news_feed import News_Feed, Search_Api
import params, sys
import nltk
from urllib import urlopen
import mongo_handler
import operator
class Aggregato... | code_fim | hard | {
"lang": "python",
"repo": "Sushant/intellafeed",
"path": "/lib/aggregator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> r= re.sub('[^A-Za-z0-9]+', ' ', data)
return r
def get_feed_object(self, data):
try:
print self.news.get_entities("contentanalysis.analyze", self.clean_text(data))
return json.loads(self.news.get_entities("contentanalysis.analyze", self.clean_text(data)))
... | code_fim | hard | {
"lang": "python",
"repo": "Sushant/intellafeed",
"path": "/lib/aggregator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ff = asdf.AsdfFile(tree)
ff.write_to(tmpfile)
# Test that by default we use memmapped arrays when possible
with asdf.open(tmpfile) as af:
array = af.tree["array"]
# Make sure to access the block so that it gets loaded
array[0]
assert array.block._memmapped ... | code_fim | hard | {
"lang": "python",
"repo": "asdf-format/asdf",
"path": "/asdf/_tests/test_array_blocks.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asdf-format/asdf path: /asdf/_tests/test_array_blocks.py
# This is the case where the new tree can't fit in the available space
tree = _get_update_tree()
ff = asdf.AsdfFile(tree)
ff.write_to(path, pad_blocks=True)
original_size = os.stat(path).st_size
with asdf.open(os.pat... | code_fim | hard | {
"lang": "python",
"repo": "asdf-format/asdf",
"path": "/asdf/_tests/test_array_blocks.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_short_file_find_block_index():
# This tests searching for a block index in a file that looks like
# it might have an index, in the last filesystem block or so, but
# ultimately proves to not have an index.
buff = io.BytesIO()
ff = asdf.AsdfFile({"arr": np.ndarray([1]), "arr2... | code_fim | hard | {
"lang": "python",
"repo": "asdf-format/asdf",
"path": "/asdf/_tests/test_array_blocks.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: meraki-analytics/champyongg path: /classes/generaldata.py
import champyongg.common
class GeneralData(champyongg.common.ChampyonGGObject):
def __init__(self, dictionary):
self.assists = Assists(dictionary.get('assists', {}))
self.ban_rate = BanRate(dictionary.get('banRate', {... | code_fim | hard | {
"lang": "python",
"repo": "meraki-analytics/champyongg",
"path": "/classes/generaldata.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.change = dictionary.get('change', 0)
self.position = dictionary.get('position', 0)
class PlayPercent(champyongg.common.ChampyonGGObject):
def __init__(self, dictionary):
self.change = dictionary.get('change', 0)
self.position = dictionary.get('position', 0)
... | code_fim | hard | {
"lang": "python",
"repo": "meraki-analytics/champyongg",
"path": "/classes/generaldata.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return auction["Confidence"] > self.confidence_threshold and auction["Interest"] > self.min_interest
def find_attractive_auctions(self):
bids = self.api.get_bids()
logging.info("Nr of bids made: {}".format(len(bids)))
auctions = [auction for auction in self.api.get_auc... | code_fim | medium | {
"lang": "python",
"repo": "pdanelson/bondora-auto-investor",
"path": "/loan_classifier/loan_classifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bids = self.api.get_bids()
logging.info("Nr of bids made: {}".format(len(bids)))
auctions = [auction for auction in self.api.get_auctions() if auction["Country"] == "EE"]
available_auctions = [auction for auction in auctions if not self._has_any_prior_bids(auction, bids)]
... | code_fim | medium | {
"lang": "python",
"repo": "pdanelson/bondora-auto-investor",
"path": "/loan_classifier/loan_classifier.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pdanelson/bondora-auto-investor path: /loan_classifier/loan_classifier.py
import logging
import xgboost
import pandas
from .data_transformer import DataTransformer
class LoanClassifier:
def __init__(self, confidence_threshold, min_interest, model_path, api):
self.confidence_thres... | code_fim | hard | {
"lang": "python",
"repo": "pdanelson/bondora-auto-investor",
"path": "/loan_classifier/loan_classifier.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def act(self, *args, **kwargs):
return self.algo.actor_critic.act(*args, **kwargs)
def get_value(self, *args, **kwargs):
return self.algo.actor_critic.get_value(*args, **kwargs)
def insert(self, *args, **kwargs):
return self.storage.insert(*args, **kwargs)<|fim_prefix|># repo: TrendingTechnolog... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/paired",
"path": "/algos/agent.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self
def train(self):
self.algo.actor_critic.train()
def eval(self):
self.algo.actor_critic.eval()
def random(self):
self.algo.actor_critic.random = True
def process_action(self, action):
if hasattr(self.algo.actor_critic, 'process_action'):
return self.algo.actor_critic.proces... | code_fim | medium | {
"lang": "python",
"repo": "TrendingTechnology/paired",
"path": "/algos/agent.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TrendingTechnology/paired path: /algos/agent.py
class ACAgent(object):
def __init__(self, algo, storage):
self.algo = algo
self.storage = storage
def update(self):
info = self.algo.update(self.storage)
self.storage.after_update()
return info
def to(self, device):
self.algo.actor... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/paired",
"path": "/algos/agent.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
_summary = outputs['Summary']
except KeyError: # If output is a dict but summary doesn't exist
_summary = outputs
except TypeError: # if output is a string
_summary = outputs
event_summary = " ".join(['(', description_prefix, ')', _summary])
# event_summary = _sum... | code_fim | hard | {
"lang": "python",
"repo": "Jazun713/sensu-plugin-py-pagerduty",
"path": "/pagerduty/handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jazun713/sensu-plugin-py-pagerduty path: /pagerduty/handler.py
# /usr/bin/env python
# -*- coding: utf-8 -*-
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
from __future__ import print_function
import argparse
import json
import logging
import sys
impo... | code_fim | hard | {
"lang": "python",
"repo": "Jazun713/sensu-plugin-py-pagerduty",
"path": "/pagerduty/handler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ress == "10.99.99.186":
hit_num += 1
print "number of hits were made to 10.99.99.186: "+str(hit_num)<|fim_prefix|># repo: IITDU-BSSE06/ads-demystifying-the-logs-pritomsaha path: /assignment1/reducer.py
#!/usr/bin/python
import sys
hit_num = 0
for line <|fim_middle|>in sys.stdin:
ip_address = line.stri... | code_fim | easy | {
"lang": "python",
"repo": "IITDU-BSSE06/ads-demystifying-the-logs-pritomsaha",
"path": "/assignment1/reducer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>r of hits were made to 10.99.99.186: "+str(hit_num)<|fim_prefix|># repo: IITDU-BSSE06/ads-demystifying-the-logs-pritomsaha path: /assignment1/reducer.py
#!/usr/bin/python
import sys
hit_num = 0
for line <|fim_middle|>in sys.stdin:
ip_address = line.strip()
if ip_address == "10.99.99.186":
hit_num += ... | code_fim | medium | {
"lang": "python",
"repo": "IITDU-BSSE06/ads-demystifying-the-logs-pritomsaha",
"path": "/assignment1/reducer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IITDU-BSSE06/ads-demystifying-the-logs-pritomsaha path: /assignment1/reducer.py
#!/usr/bin/python
import sys
hit_num = 0
for line in sys.stdin:
ip_address = line.strip()
if ip_add<|fim_suffix|>r of hits were made to 10.99.99.186: "+str(hit_num)<|fim_middle|>ress == "10.99.99.186":
hit_num += ... | code_fim | easy | {
"lang": "python",
"repo": "IITDU-BSSE06/ads-demystifying-the-logs-pritomsaha",
"path": "/assignment1/reducer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
INSTALLED_APPS += ('debug_toolbar',)
INTERNAL_IPS = ('127.0.0.1',)
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TEMPLATE_CONTEXT': True,
}<|fim_prefix|># repo: pydanny/roda path: /roda/roda/settings/dev.... | code_fim | hard | {
"lang": "python",
"repo": "pydanny/roda",
"path": "/roda/roda/settings/dev.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TEMPLATE_CONTEXT': True,
}<|fim_prefix|># repo: pydanny/roda path: /roda/roda/settings/dev.py
from base import *
DEBUG = True
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
<|fim_middle|>DATABASES = {
'default': {
'ENGINE': ... | code_fim | hard | {
"lang": "python",
"repo": "pydanny/roda",
"path": "/roda/roda/settings/dev.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pydanny/roda path: /roda/roda/settings/dev.py
from base import *
DEBUG = True
EMAIL_HOST = 'localhost'
EMAIL_PORT = 1025
<|fim_suffix|>DEBUG_TOOLBAR_CONFIG = {
'INTERCEPT_REDIRECTS': False,
'SHOW_TEMPLATE_CONTEXT': True,
}<|fim_middle|>DATABASES = {
'default': {
'ENGINE': '... | code_fim | hard | {
"lang": "python",
"repo": "pydanny/roda",
"path": "/roda/roda/settings/dev.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RoAbreu/AulaJavaScripts path: /PROJETO/backend/appengine/routes/listaDicionarioss/admin/edit.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from config.template_middleware import TemplateResponse
from gaebusiness.business import CommandExecutionException
from ... | code_fim | hard | {
"lang": "python",
"repo": "RoAbreu/AulaJavaScripts",
"path": "/PROJETO/backend/appengine/routes/listaDicionarioss/admin/edit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> lista_dicionarios = facade.get_lista_dicionarios_cmd(lista_dicionarios_id)()
detail_form = facade.lista_dicionarios_detail_form()
context = {'save_path': router.to_path(save, lista_dicionarios_id), 'lista_dicionarios': detail_form.fill_with_model(lista_dicionarios)}
return TemplateResponse... | code_fim | medium | {
"lang": "python",
"repo": "RoAbreu/AulaJavaScripts",
"path": "/PROJETO/backend/appengine/routes/listaDicionarioss/admin/edit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JoseCordobaEAN/ProgramacionEAN20191 path: /Semana_8/listas 2.py
pizza_carnes = ['jamon', 'salchicha', 'salami']
pizza_pollo = ['pollo', 'tocineta', 'champiñones']
pizza_especial = pizza_carnes + pizza_pollo
print(pizza_especial)
pizza_mega_carnes = pizza_carnes * 3
print(pizza_mega_carnes)
pi... | code_fim | hard | {
"lang": "python",
"repo": "JoseCordobaEAN/ProgramacionEAN20191",
"path": "/Semana_8/listas 2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ciruela = pizza_pollo.pop()
print(pizza_pollo)
pizza_pollo.remove('queso')
print(pizza_pollo)
pizza_ultra_mega_carnes.remove('jamon')
print(pizza_ultra_mega_carnes)
pos_pollo = pizza_pollo.index('pollo')
print(pos_pollo)
pos_pollo = pizza_pollo.index('queso')
print(pos_pollo)<|fim_prefix|># repo: Jose... | code_fim | hard | {
"lang": "python",
"repo": "JoseCordobaEAN/ProgramacionEAN20191",
"path": "/Semana_8/listas 2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pizza_mega_carnes = pizza_carnes * 3
print(pizza_mega_carnes)
pizza_ultra_mega_carnes = pizza_carnes * 20
print(pizza_ultra_mega_carnes)
pizza_especial_extra_pollo = pizza_pollo * 2 + pizza_carnes
print(pizza_especial_extra_pollo)
print('la pizza especial tiene mani?', 'mani' in pizza_especial)
pizza_... | code_fim | medium | {
"lang": "python",
"repo": "JoseCordobaEAN/ProgramacionEAN20191",
"path": "/Semana_8/listas 2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>),
('Tipo_personal', models.CharField(max_length=30)),
('Nro_item', models.IntegerField()),
('Responsable', models.BooleanField(default=False)),
('Cargo', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='responsablesInformac... | code_fim | hard | {
"lang": "python",
"repo": "lizethlizi/proyecto_backend_POA",
"path": "/backend_poa_admin/apps/responsablesInformacion/migrations/0003_auto_20180731_2106.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nombre_unidad', models.CharField(max_length=50)),
],
options={
'verbose_name_plural': 'Unidad',
},
),
migrat... | code_fim | hard | {
"lang": "python",
"repo": "lizethlizi/proyecto_backend_POA",
"path": "/backend_poa_admin/apps/responsablesInformacion/migrations/0003_auto_20180731_2106.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lizethlizi/proyecto_backend_POA path: /backend_poa_admin/apps/responsablesInformacion/migrations/0003_auto_20180731_2106.py
# Generated by Django 2.0.7 on 2018-07-31 21:06
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
init... | code_fim | hard | {
"lang": "python",
"repo": "lizethlizi/proyecto_backend_POA",
"path": "/backend_poa_admin/apps/responsablesInformacion/migrations/0003_auto_20180731_2106.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ben-Duke/SENG302_Group_Project path: /Extras/generate 10k users.py
import json
import string
#response = requests.get('https://randomuser.me/api/?results=3?nat=fr')
#response.encoding = 'utf-8'
def is_user_safe(user):
alphabetical_chars = set(list(string.ascii_letters))
digits = set(li... | code_fim | hard | {
"lang": "python",
"repo": "Ben-Duke/SENG302_Group_Project",
"path": "/Extras/generate 10k users.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def filter_user_data(user):
fields_to_filter = ['first_name', 'last_name']
for field in fields_to_filter:
user[field] = replace_apostrophes(user[field])
def replace_apostrophes(input):
return input.replace("'", "\\'") # escape apostrophes
def main():
generate_sql()
if __nam... | code_fim | hard | {
"lang": "python",
"repo": "Ben-Duke/SENG302_Group_Project",
"path": "/Extras/generate 10k users.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Wanger-SJTU/leetcode-solutions path: /python/485.MaxConsecutiveOnes.py
def findMaxConsecutiveOnes(self, nums: List[int]) -> i<|fim_suffix|>s, tmp)
else:
tmp =0
return res<|fim_middle|>nt:
res, tmp = 0, 0
for item in nums:
if item !=0:
tmp+=1
... | code_fim | medium | {
"lang": "python",
"repo": "Wanger-SJTU/leetcode-solutions",
"path": "/python/485.MaxConsecutiveOnes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>s, tmp)
else:
tmp =0
return res<|fim_prefix|># repo: Wanger-SJTU/leetcode-solutions path: /python/485.MaxConsecutiveOnes.py
def findMaxConsecutiveOnes(self, nums: List[int]) -> i<|fim_middle|>nt:
res, tmp = 0, 0
for item in nums:
if item !=0:
tmp+=1
... | code_fim | medium | {
"lang": "python",
"repo": "Wanger-SJTU/leetcode-solutions",
"path": "/python/485.MaxConsecutiveOnes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adhocmaster/MLSQL path: /parser/lexer.py
import ply.lex as lex
from ply.lex import TOKEN
import dill
from tokens.manipulations import *
from tokens.sql import *
from tokens.definitions import *
from tokens.data_types import *
keywords = list(set().union(
modelTokens,
tra... | code_fim | hard | {
"lang": "python",
"repo": "adhocmaster/MLSQL",
"path": "/parser/lexer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def t_VALIDATION_SPLIT(t):
r'VALIDATION[_ \t\n]+SPLIT'
t.type = 'VALIDATION_SPLIT'
t.value = 'VALIDATION_SPLIT'
# print("found t_VALIDATION_SPLIT")
return t
def t_FORMULA_OPERATOR(t):
r'~'
t.type = 'FORMULA_OPERATOR'
t.value = 'FORMULA_OPERATOR'
# print("found t_FORMUL... | code_fim | hard | {
"lang": "python",
"repo": "adhocmaster/MLSQL",
"path": "/parser/lexer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Check for anti symmetries in the elementary winding pattern
if (
Nperslot % 2 == 0
and norm(
wind_mat2[0 : Nperslot // 2, :] + wind_mat2[Nperslot // 2 : Nperslot, :]
)
== 0
):
is_aper_a = True
Nperw = Nperw * 2
else:
is_... | code_fim | hard | {
"lang": "python",
"repo": "Lunreth/pyleecan",
"path": "/pyleecan/Methods/Machine/Winding/comp_periodicity.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Looking for the periodicity of each phase
for q in range(0, qs):
k = 1
is_per = False
while k <= Zs and not is_per:
# We shift the array arround the slot and check if it's the same
if array_equal(wind_mat2[:, q], roll(wind_mat2[:, q], shift=k)):
... | code_fim | hard | {
"lang": "python",
"repo": "Lunreth/pyleecan",
"path": "/pyleecan/Methods/Machine/Winding/comp_periodicity.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lunreth/pyleecan path: /pyleecan/Methods/Machine/Winding/comp_periodicity.py
from numpy import array_equal, roll, squeeze, sum as np_sum, lcm
from numpy.linalg import norm
def comp_periodicity(self, wind_mat=None):
"""Computes the winding matrix (anti-)periodicity
Parameters
------... | code_fim | hard | {
"lang": "python",
"repo": "Lunreth/pyleecan",
"path": "/pyleecan/Methods/Machine/Winding/comp_periodicity.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saadmk11/readthedocs.org path: /readthedocs/api/mixins.py
import functools
import structlog
from django.shortcuts import get_object_or_404
from django.utils.functional import cached_property
from readthedocs.core.unresolver import unresolve
from readthedocs.core.utils import get_cache_tag
from ... | code_fim | hard | {
"lang": "python",
"repo": "saadmk11/readthedocs.org",
"path": "/readthedocs/api/mixins.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Note that these methods are cached (``lru_cache`` and ``cached_property``)
to avoid hitting the database multiple times on the same request.
"""
@cached_property
def unresolved_url(self):
url = self.request.GET.get("url")
if not url:
return None
ret... | code_fim | hard | {
"lang": "python",
"repo": "saadmk11/readthedocs.org",
"path": "/readthedocs/api/mixins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.external:
return
if self.unresolved_url:
project_slug = self.unresolved_url.project.slug
else:
project_slug = self.request.GET.get("project")
return get_object_or_404(Project, slug=project_slug)
@functools.lru_cache(maxsize=... | code_fim | hard | {
"lang": "python",
"repo": "saadmk11/readthedocs.org",
"path": "/readthedocs/api/mixins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert r.json() == {'authenticated': True, 'user': 'user'}
def test_digest(self):
with self.cassette('digest'):
r = self.session.request(
'GET', 'http://httpbin.org/digest-auth/auth/user/passwd',
auth=GuessAuth('user', 'passwd'))
as... | code_fim | hard | {
"lang": "python",
"repo": "mikelambert/requests-toolbelt",
"path": "/tests/test_auth.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with self.cassette('none'):
url = 'http://httpbin.org/get?a=1'
r = self.session.request('GET', url,
auth=GuessAuth('user', 'passwd'))
j = r.json()
assert j['args'] == {'a': '1'}
assert j['url'] == url... | code_fim | hard | {
"lang": "python",
"repo": "mikelambert/requests-toolbelt",
"path": "/tests/test_auth.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mikelambert/requests-toolbelt path: /tests/test_auth.py
# -*- coding: utf-8 -*-
import requests
import unittest
from requests_toolbelt.auth.guess import GuessAuth
from . import get_betamax
class TestGuessAuth(unittest.TestCase):
def setUp(self):
self.session = requests.Session()
... | code_fim | hard | {
"lang": "python",
"repo": "mikelambert/requests-toolbelt",
"path": "/tests/test_auth.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Capnode/Algoloop path: /Algorithm.Python/Alphas/ShareClassMeanReversionAlpha.py
# QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
# Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
... | code_fim | hard | {
"lang": "python",
"repo": "Capnode/Algoloop",
"path": "/Algorithm.Python/Alphas/ShareClassMeanReversionAlpha.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ## Calculate position value and update the SMA indicator and Rolling Window
self.position_value = (self.alpha * data[self.long_symbol].Close) - (self.beta * data[self.short_symbol].Close)
self.sma.Update(data[self.long_symbol].EndTime, self.position_value)
self.position_win... | code_fim | hard | {
"lang": "python",
"repo": "Capnode/Algoloop",
"path": "/Algorithm.Python/Alphas/ShareClassMeanReversionAlpha.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DalavanCloud/botoflow path: /test/unit/decisions/test_decisions.py
from botoflow.decisions import decisions
def test_cancel_workflow_execution():
decision = decisions.CancelWorkflowExecution(details="Blah").decision
assert decision['decisionType'] == 'CancelWorkflowExecution'
assert... | code_fim | hard | {
"lang": "python",
"repo": "DalavanCloud/botoflow",
"path": "/test/unit/decisions/test_decisions.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_schedule_activity_tasl():
decision = decisions.ScheduleActivityTask(
activity_id="activity_id", activity_type_name="name", activity_type_version="1.0",
task_list="task_list", control="control", heartbeat_timeout="3",
schedule_to_close_timeout="4",
schedule_to_... | code_fim | hard | {
"lang": "python",
"repo": "DalavanCloud/botoflow",
"path": "/test/unit/decisions/test_decisions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ftconan/python3 path: /effective_python/built-in_module/collection_demo.py
"""
@author: magician
@file: collection_demo.py
@date: 2020/8/11
"""
import bisect
import random
from collections import deque, OrderedDict, defaultdict
from heapq import heappush, heappop, nsmallest
if __name__ == '_... | code_fim | hard | {
"lang": "python",
"repo": "ftconan/python3",
"path": "/effective_python/built-in_module/collection_demo.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for value1, value2 in zip(a.values(), b.values()):
print(value1, value2)
# defaultdict
stats = defaultdict(int)
stats['my_counter'] += 1
# heap
a = []
heappush(a, 5)
heappush(a, 3)
heappush(a, 7)
heappush(a, 4)
# print(heappop(a), heappop(a), heappop(a... | code_fim | medium | {
"lang": "python",
"repo": "ftconan/python3",
"path": "/effective_python/built-in_module/collection_demo.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def show_text_test_case_succeeded(test_condition) -> None:
"""Prints to console success statuses for received text test case."""
test_cases_success_outputs = {
'input_search_field': 'Input search field found. OK.',
'suggest_table': 'Table with suggestions for searching found. OK.'... | code_fim | hard | {
"lang": "python",
"repo": "dussiks/tenzor",
"path": "/test_cases/test_base/print_services.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def show_image_test_case_succeeded(test_condition) -> None:
"""Prints to console success statuses for received image test case."""
image_test_cases_success_outputs = {
'image_block': 'Yandex image block "Картинки" found. OK.',
'new_tab_url': 'New tab url opened as expected. OK.',
... | code_fim | hard | {
"lang": "python",
"repo": "dussiks/tenzor",
"path": "/test_cases/test_base/print_services.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dussiks/tenzor path: /test_cases/test_base/print_services.py
from datetime import datetime
def show_set_up_info(test_driver=None) -> None:
"""Prints additional info to console about test driver set up."""
print(f'Started at: {datetime.now()}')
print(f'{test_driver} driver environme... | code_fim | hard | {
"lang": "python",
"repo": "dussiks/tenzor",
"path": "/test_cases/test_base/print_services.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
parser = argparse.ArgumentParser(
description='Report approximate number of messages in given queue.')
parser.add_argument('-q', '--queue', help='queue to check')
args = parser.parse_args()
if not args.queue:
print(parser.format_usage())
s... | code_fim | hard | {
"lang": "python",
"repo": "humaton/fabric8-analytics-scaler",
"path": "/sqs_status.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: humaton/fabric8-analytics-scaler path: /sqs_status.py
#!/usr/bin/env python3
import argparse
import os
import sys
import boto3
conn_args = {
'aws_access_key_id': os.getenv('AWS_SQS_ACCESS_KEY_ID'),
'aws_secret_access_key': os.getenv('AWS_SQS_SECRET_ACCESS_KEY'),
'region_name': 'us-... | code_fim | hard | {
"lang": "python",
"repo": "humaton/fabric8-analytics-scaler",
"path": "/sqs_status.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def train_model(model, train_dataset, valid_dataset, model_dir, args):
if not os.path.exists(model_dir):
os.makedirs(model_dir)
tensorboard_logdir = os.path.join(model_dir, 'logs')
saved_model_dir = os.path.join(model_dir, 'export', '{epoch}')
model.fit(
train_dataset,
... | code_fim | hard | {
"lang": "python",
"repo": "lievcin/ner_tagger",
"path": "/run_ner.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def choose_model(args):
if args.model == 'bilstm-crf':
assert args.vocab_size is not None, "vocab_size must be set when using bilstm-crf model!"
assert args.embedding_size is not None, "embedding_size must be set when using bilstm-crf model!"
model = BiLSTMCRF(
voca... | code_fim | hard | {
"lang": "python",
"repo": "lievcin/ner_tagger",
"path": "/run_ner.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lievcin/ner_tagger path: /run_ner.py
import argparse
import logging
import os
import tensorflow as tf
from models.bilstm_crf.model import BiLSTMCRF
from datasets.dataset import TokenMapper, LabelMapper, DatasetBuilder
def add_arguments():
parser = argparse.ArgumentParser()
parser.add_arg... | code_fim | hard | {
"lang": "python",
"repo": "lievcin/ner_tagger",
"path": "/run_ner.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hr49-thesis/sim path: /run_pylint.py
#!/usr/bin/env python
# ref: https://gist.github.com/gregorynicholas/3152237
'''
Module that runs pylint on all python scripts found in a directory tree.
'''
import os
import sys
def check(module):
<|fim_suffix|> print("linting *.py files beneath \n {0}"... | code_fim | hard | {
"lang": "python",
"repo": "hr49-thesis/sim",
"path": "/run_pylint.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def check(module):
'''
apply pylint to the file specified if it is a *.py file
'''
if module[-3:] == ".py":
print("CHECKING ", module)
pout = os.popen('pylint %s'% module, 'r')
if pout:
for line in pout:
if not "*" in line:
... | code_fim | medium | {
"lang": "python",
"repo": "hr49-thesis/sim",
"path": "/run_pylint.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
try:
# print(sys.argv)
BASE_DIRECTORY = sys.argv[1]
except IndexError:
BASE_DIRECTORY = os.getcwd()
print("linting *.py files beneath \n {0}".format(BASE_DIRECTORY))
print("=" * 80)
for root, dirs, files in os.walk(BASE_DIRECTORY):
... | code_fim | hard | {
"lang": "python",
"repo": "hr49-thesis/sim",
"path": "/run_pylint.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sshyran/hyperledger-indy-plenum path: /plenum/test/client/test_client_can_send.py
import pytest
from plenum.test.delayers import reset_delays_and_process_delayeds, lsDelay, \
reset_delays_and_process_delayeds_for_client
from plenum.test.exceptions import TestException
from plenum.test.helper... | code_fim | hard | {
"lang": "python",
"repo": "sshyran/hyperledger-indy-plenum",
"path": "/plenum/test/client/test_client_can_send.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_client_can_not_send_requests_not_started(poolTxnClientData, tdirWithPoolTxns):
client, _ = new_client(poolTxnClientData, tdirWithPoolTxns)
assert not client.can_send_read_requests()
def test_client_can_send_write_requests_no_catchup(looper,
... | code_fim | hard | {
"lang": "python",
"repo": "sshyran/hyperledger-indy-plenum",
"path": "/plenum/test/client/test_client_can_send.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.