text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: robieta/pytorch_historic_benchmarks path: /prepare_v2.py
import os
from v2 import init_pytorch
<|fim_suffix|> init_pytorch.run()
if __name__ == "__main__":
main()<|fim_middle|>def main():
if os.getenv("CONDA_PREFIX") is not None:
raise ValueError("This script should not be... | code_fim | medium | {
"lang": "python",
"repo": "robieta/pytorch_historic_benchmarks",
"path": "/prepare_v2.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
main()<|fim_prefix|># repo: robieta/pytorch_historic_benchmarks path: /prepare_v2.py
import os
from v2 import init_pytorch
<|fim_middle|>
def main():
if os.getenv("CONDA_PREFIX") is not None:
raise ValueError("This script should not be run in a conda env.")
... | code_fim | medium | {
"lang": "python",
"repo": "robieta/pytorch_historic_benchmarks",
"path": "/prepare_v2.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matham/cpl_media path: /cpl_media/remote/client.py
"""Remote player
================
This class plays video from the network. E.g. a
:class:`cpl_media.remote.server.RemoteData` can be configured
to broadcast video from a FFmpeg camera. This client plays the video from
the server.
"""
from threa... | code_fim | hard | {
"lang": "python",
"repo": "matham/cpl_media",
"path": "/cpl_media/remote/client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._frame_count += 1
self.frames_played += 1
plane_buffers, pix_fmt, size, linesize, metadata = value
sws = SWScale(*size, pix_fmt, ofmt=pix_fmt)
img = Image(
plane_buffers=plane_... | code_fim | hard | {
"lang": "python",
"repo": "matham/cpl_media",
"path": "/cpl_media/remote/client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_nighties.py
#calss header
class _NIGHTIES():
<|fim_suffix|>
self.basic = ['nightie']<|fim_middle|> def __init__(self,):
self.name = "NIGHTIES"
self.definitions = nightie
self.parents = []
self.childen = []
self.properties = []
s... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/otherforms/_nighties.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
self.basic = ['nightie']<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/otherforms/_nighties.py
#calss header
class _NIGHTIES():
def __init__(self,):
self.name = "NIGHTIES"
self.definitions = nightie
<|fim_middle|> self.parents = []
self.childen = []
self.properties = []
s... | code_fim | medium | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/otherforms/_nighties.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: javascriptlove/sentry path: /src/sentry/integrations/bitbucket/descriptor.py
from __future__ import absolute_import
from sentry.api.base import Endpoint
from sentry.utils.http import absolute_uri
from .client import BITBUCKET_KEY
from sentry.integrations.bitbucket.integration import scopes
cl... | code_fim | hard | {
"lang": "python",
"repo": "javascriptlove/sentry",
"path": "/src/sentry/integrations/bitbucket/descriptor.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get(self, request):
return self.respond(
{
'key': BITBUCKET_KEY,
'name': 'Sentry for Bitbucket',
'description': 'A Sentry integration',
'vendor': {
'name': 'Sentry.io',
'url'... | code_fim | hard | {
"lang": "python",
"repo": "javascriptlove/sentry",
"path": "/src/sentry/integrations/bitbucket/descriptor.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># collect a list of json objects while jumping through hoops to pass
# the serializer a queryset, which it expects instead of instance data
data = []
data.extend(json.loads(j.serialize(Title.objects.filter(pk=TITLE_ID))))
data.extend(json.loads(j.serialize(Batch.objects.filter(name=BATCH_NAME))))
data.ext... | code_fim | hard | {
"lang": "python",
"repo": "LibraryOfCongress/chronam",
"path": "/core/fixtures/uuml_thys_sample.py",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LibraryOfCongress/chronam path: /core/fixtures/uuml_thys_sample.py
#!/usr/bin/env python
"""
this is a script that dumps an issue from batch batch_uuml_thys_ver01
including all its page and ocr models as a json fixture for testing purposes
"""
import json
<|fim_suffix|># create the django json... | code_fim | hard | {
"lang": "python",
"repo": "LibraryOfCongress/chronam",
"path": "/core/fixtures/uuml_thys_sample.py",
"mode": "psm",
"license": "LicenseRef-scancode-public-domain-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>b = Batch.objects.get(name=BATCH_NAME)
i = b.issues.all()[0]
# create the django json serializer
j = serializers.get_serializer("json")()
# collect a list of json objects while jumping through hoops to pass
# the serializer a queryset, which it expects instead of instance data
data = []
data.extend(json... | code_fim | medium | {
"lang": "python",
"repo": "LibraryOfCongress/chronam",
"path": "/core/fixtures/uuml_thys_sample.py",
"mode": "spm",
"license": "LicenseRef-scancode-public-domain-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: venmathig/stackoverflow path: /examples/corelib/threads/queuedcustomtype/main.py
from Qt import QtWidgets
<|fim_suffix|>if __name__ == "__main__":
import sys
sys.path.append('../../../examples')
print(sys.path)
app = QtWidgets.QApplication(sys.argv)
w = Window()
w.show(... | code_fim | easy | {
"lang": "python",
"repo": "venmathig/stackoverflow",
"path": "/examples/corelib/threads/queuedcustomtype/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
import sys
sys.path.append('../../../examples')
print(sys.path)
app = QtWidgets.QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())<|fim_prefix|># repo: venmathig/stackoverflow path: /examples/corelib/threads/queuedcustomtype/main.py
... | code_fim | easy | {
"lang": "python",
"repo": "venmathig/stackoverflow",
"path": "/examples/corelib/threads/queuedcustomtype/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imperva/conf-snapper path: /src/conf_snapper.py
#Function creates or updates (remove->create) symbolic link for given snapshot.
def createSymbolicLink(snapshot, snapshotPath):
logger = logging.getLogger();
if(snapshotPath == None):
logger.error("Path is None, do ... | code_fim | hard | {
"lang": "python",
"repo": "imperva/conf-snapper",
"path": "/src/conf_snapper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Take snapshots on startup
self.checkSnapsotOnStartUp(snapshotConf);
switcher = {
TimeUnit.sec: self.startSecJob,
TimeUnit.min: self.startMinJob,
TimeUnit.hour: self.startHourJob,
... | code_fim | hard | {
"lang": "python",
"repo": "imperva/conf-snapper",
"path": "/src/conf_snapper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger = logging.getLogger();
logger.debug("Checking if snapshot should be taken.")
for stopper in global_stopper_list:
if os.path.exists(stopper) == True:
logger.debug("File %s exists!", stopper)
state.status = StateStatus.suspended;
state.writ... | code_fim | hard | {
"lang": "python",
"repo": "imperva/conf-snapper",
"path": "/src/conf_snapper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tocknicsu/nctuoj_contest path: /backend/req.py
import json
import datetime
import tornado.template
import tornado.gen
import tornado.web
import tornado.websocket
import datetime
from urllib.parse import quote
from utils.log import log
import momoko
import config
import types
from utils.form impor... | code_fim | hard | {
"lang": "python",
"repo": "Tocknicsu/nctuoj_contest",
"path": "/backend/req.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(data, dict):
for x in data:
try:
data[x] = encode(data[x])
except:
pass
elif isinstance(data, list):
for x in data:
try:
... | code_fim | hard | {
"lang": "python",
"repo": "Tocknicsu/nctuoj_contest",
"path": "/backend/req.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> token = self.get_args(['token'])['token']
if token:
err, res = yield from Service.User.get_user_by_token({'token': token})
if err:
self.account = {}
else:
self.account = res
else:
self.account = {}
... | code_fim | hard | {
"lang": "python",
"repo": "Tocknicsu/nctuoj_contest",
"path": "/backend/req.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def forward(self, x):
self.__ishape = x.shape
self.__a = x.reshape(self.__w.shape[1], -1)
return np.dot(self.__w, self.__a) + self.__b
def backprop(self, d):
m = d.shape[1]
self.__dw = np.dot(d, self.__a.T) / m
self.__db = np.sum(d, axis=1, keepdims=True) / m
return np.dot... | code_fim | hard | {
"lang": "python",
"repo": "honk2333/Deeplearning-Notes",
"path": "/blog-record/record-4/cnn-py/dense.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: honk2333/Deeplearning-Notes path: /blog-record/record-4/cnn-py/dense.py
import numpy as np
from layer import Layer
class DenseLayer(Layer):
'''
dense layer
Parameters
---
in_count: int
input node count
out_count: int
output node count
'''
def __init__(self, in_count... | code_fim | hard | {
"lang": "python",
"repo": "honk2333/Deeplearning-Notes",
"path": "/blog-record/record-4/cnn-py/dense.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def loop(self):
if self.timer.millis() > 100:
self.timer.reset()
self.steps += 1
print self.steps, self.encoder.val
if self.steps > 25:
self.motor.write(DOWN, 75)
self.stop()
if __name__ == "__main__":
sketch = EncoderRea... | code_fim | hard | {
"lang": "python",
"repo": "pravinas/et-maslab-2016",
"path": "/sandbox/belt_sandbox.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pravinas/et-maslab-2016 path: /sandbox/belt_sandbox.py
from tamproxy import Sketch, SyncedSketch, Timer
from tamproxy.devices import Encoder, Motor
<|fim_suffix|>if __name__ == "__main__":
sketch = EncoderRead(1, -0.00001, 100)
sketch.run()<|fim_middle|>UP = False
DOWN = True
# Prints a... | code_fim | hard | {
"lang": "python",
"repo": "pravinas/et-maslab-2016",
"path": "/sandbox/belt_sandbox.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PARINetwork/pari path: /face/migrations/0009_face_original_image.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migratio... | code_fim | medium | {
"lang": "python",
"repo": "PARINetwork/pari",
"path": "/face/migrations/0009_face_original_image.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
('face', '0008_increase_parants_occupation_length_to_100'),
]
operations = [
migrations.AddField(
model_name='face',
name='original_image',
field=models.ForeignKey(related_name='origi... | code_fim | medium | {
"lang": "python",
"repo": "PARINetwork/pari",
"path": "/face/migrations/0009_face_original_image.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _get_cached_filepath(prefix, url):
"""Return the filepath where a cached response would live for the given inputs."""
filename = '{prefix}_{hash_string}.cache'.format(
prefix=prefix,
hash_string=_hash_value(url),
)
logger.debug('Cached filepath: ' + os.path.join(CACHE_... | code_fim | hard | {
"lang": "python",
"repo": "khattakdev/prism-frontend",
"path": "/api-flask/app/caching.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: khattakdev/prism-frontend path: /api-flask/app/caching.py
"""Methods to cache remote files."""
import hashlib
import logging
import os
import requests
from timer import timed
logger = logging.getLogger(__name__)
CACHE_DIRECTORY = '/cache/'
@timed
def cache_file(url, prefix):
<|fim_suffix|>
... | code_fim | hard | {
"lang": "python",
"repo": "khattakdev/prism-frontend",
"path": "/api-flask/app/caching.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def _hash_value(value):
"""Hash value to help identify what cached file to use."""
return hashlib.md5(value.encode('utf-8')).hexdigest()[:9]<|fim_prefix|># repo: khattakdev/prism-frontend path: /api-flask/app/caching.py
"""Methods to cache remote files."""
import hashlib
import logging
import os... | code_fim | hard | {
"lang": "python",
"repo": "khattakdev/prism-frontend",
"path": "/api-flask/app/caching.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>CooldownBypassTypes',
),
},
'HarvestObjects.dat': {
'ObjectType': CustomizedField(
enum='HARVEST_OBJECT_TYPES',
),
},
'MapFragmentMods.dat': {
'MapFragmentFamilies': CustomizedField(
enum='MAP_FRAGMENT_FAMILIES',
),
},
... | code_fim | hard | {
"lang": "python",
"repo": "brather1ng/PyPoE",
"path": "/PyPoE/poe/file/specification/generation/custom_attributes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>,
'Scarabs.dat': {
'ScarabType': CustomizedField(
enum='SCARAB_TYPES',
),
},
'ShopPaymentPackage.dat': {
'ShopPackagePlatform': CustomizedField(
enum='SHOP_PACKAGE_PLATFORM',
),
},
'SupporterPackSets.dat': {
'ShopPackagePl... | code_fim | hard | {
"lang": "python",
"repo": "brather1ng/PyPoE",
"path": "/PyPoE/poe/file/specification/generation/custom_attributes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brather1ng/PyPoE path: /PyPoE/poe/file/specification/generation/custom_attributes.py
class CustomizedField:
def __init__(self,
enum: str = None):
self.enum = enum
custom_attributes = {
'BaseItemTypes.dat': {
'ModDomain': CustomizedField(
enu... | code_fim | hard | {
"lang": "python",
"repo": "brather1ng/PyPoE",
"path": "/PyPoE/poe/file/specification/generation/custom_attributes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: demfabris/calculo_func path: /bin/pagamento.py
from bin.coletar import coletar_dias
from bin.scan_escala import *
from bin.detect import falta
<|fim_suffix|> t1 =['Janeiro', 'Março', 'Maio', 'Julho', 'Agosto', 'Outubro', 'Dezembro']
t2 =['Fevereiro']
t0 = ['Abril', 'Junho', 'Setembro... | code_fim | medium | {
"lang": "python",
"repo": "demfabris/calculo_func",
"path": "/bin/pagamento.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> t1 =['Janeiro', 'Março', 'Maio', 'Julho', 'Agosto', 'Outubro', 'Dezembro']
t2 =['Fevereiro']
t0 = ['Abril', 'Junho', 'Setembro', 'Novembro']
t_hold = 0
if mes in t1:
t_hold = 15
elif mes in t2:
t_hold = 13
elif mes in t0:
t_hold = 14
if scan_escala(S... | code_fim | medium | {
"lang": "python",
"repo": "demfabris/calculo_func",
"path": "/bin/pagamento.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>e('Select count(*) from Pages where html is NOT NULL')
print(curr.fetchone()[0])
curr.close()<|fim_prefix|># repo: go4pooja/WebCrawler path: /pagerank/check.py
import sqlite3
conn = sqlite3.connect('PageRan<|fim_middle|>kdb.sqlite')
curr = conn.cursor()
curr.execut | code_fim | easy | {
"lang": "python",
"repo": "go4pooja/WebCrawler",
"path": "/pagerank/check.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: go4pooja/WebCrawler path: /pagerank/check.py
import sqlite3
conn = sqlite3.connect('PageRan<|fim_suffix|>e('Select count(*) from Pages where html is NOT NULL')
print(curr.fetchone()[0])
curr.close()<|fim_middle|>kdb.sqlite')
curr = conn.cursor()
curr.execut | code_fim | easy | {
"lang": "python",
"repo": "go4pooja/WebCrawler",
"path": "/pagerank/check.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> NULL')
print(curr.fetchone()[0])
curr.close()<|fim_prefix|># repo: go4pooja/WebCrawler path: /pagerank/check.py
import sqlite3
conn = sqlite3.connect('PageRan<|fim_middle|>kdb.sqlite')
curr = conn.cursor()
curr.execute('Select count(*) from Pages where html is NOT | code_fim | medium | {
"lang": "python",
"repo": "go4pooja/WebCrawler",
"path": "/pagerank/check.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # check for illegal variable references
for vname in self.__extractVars(rhs):
try:
eval(vname, env)
except:
print 'error:%s: invalid reference: "%s"' % (rhs_line_no, vname)
sys.exit(1)
# evaluate the RHS expre... | code_fim | hard | {
"lang": "python",
"repo": "bondhugula/pluto",
"path": "/orio-0.1.0/src/main/tspec/eval.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bondhugula/pluto path: /orio-0.1.0/src/main/tspec/eval.py
#
# The evaluator for the TSpec (Tuning Specifier) language
#
import StringIO, sys, tokenize
#--------------------------------------------------------------------------------
class TSpecEvaluator:
'''The evaluator for the TSpec lan... | code_fim | hard | {
"lang": "python",
"repo": "bondhugula/pluto",
"path": "/orio-0.1.0/src/main/tspec/eval.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> # get keyword, line number, and identifier name
keyw = stmt[0]
line_no = stmt[1]
(id_name, id_line_no) = stmt[2]
# check for any predefined name
if id_name in name_space:
print 'error:%s: name "%s" already defined' % ... | code_fim | hard | {
"lang": "python",
"repo": "bondhugula/pluto",
"path": "/orio-0.1.0/src/main/tspec/eval.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: home-assistant/supervisor path: /supervisor/__main__.py
"""Main file for Supervisor."""
import asyncio
from concurrent.futures import ThreadPoolExecutor
import logging
from pathlib import Path
import sys
from supervisor import bootstrap
_LOGGER: logging.Logger = logging.getLogger(__name__)
CON... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/supervisor",
"path": "/supervisor/__main__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> loop.call_soon_threadsafe(loop.create_task, coresys.core.start())
loop.call_soon_threadsafe(bootstrap.reg_signal, loop, coresys)
try:
_LOGGER.info("Running Supervisor")
loop.run_forever()
finally:
loop.close()
_LOGGER.info("Closing Supervisor")
sys.exit(co... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/supervisor",
"path": "/supervisor/__main__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TahiriNadia/hawc path: /tests/hawc/apps/common/test_svg.py
import base64
import xml.etree.ElementTree as ET
from io import BytesIO
from pathlib import Path
from shutil import which
import pytest
from hawc.apps.common.svg import SVGConverter
DATA_PATH = Path(__file__).parent.absolute() / "data"... | code_fim | hard | {
"lang": "python",
"repo": "TahiriNadia/hawc",
"path": "/tests/hawc/apps/common/test_svg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # we have styles added and the text is non-empty
styles = tree.find(".{http://www.w3.org/2000/svg}defs/{http://www.w3.org/2000/svg}style")
assert styles.attrib["type"] == "text/css"
assert styles is not None and len(styles.text) > 0
# and we still have our rect
... | code_fim | medium | {
"lang": "python",
"repo": "TahiriNadia/hawc",
"path": "/tests/hawc/apps/common/test_svg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # svg can be parsed
tree = ET.fromstring(resp)
# we have defs added
defs = tree.find(".{http://www.w3.org/2000/svg}defs")
assert defs is not None
# we have styles added and the text is non-empty
styles = tree.find(".{http://www.w3.org/2000/svg}defs... | code_fim | medium | {
"lang": "python",
"repo": "TahiriNadia/hawc",
"path": "/tests/hawc/apps/common/test_svg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tracon/tracontent path: /content/models.py
vaan käytä sivunkopiointitoimintoa.',
on_delete=models.CASCADE,
)
public_from = dict(
null=True,
blank=True,
verbose_name='Julkaisuaika',
help_text='Sivu on tästä hetkestä alkaen myös sisäänkirjautumattom... | code_fim | hard | {
"lang": "python",
"repo": "tracon/tracontent",
"path": "/content/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def categories_html(self):
return ', '.join(
'<a href="{href}">{title}</a>'.format(
href=category.get_absolute_url(),
title=category.title,
) for category in self.categories.all()
)
def get_absolute_url(self):
... | code_fim | hard | {
"lang": "python",
"repo": "tracon/tracontent",
"path": "/content/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tracon/tracontent path: /content/models.py
',
)
body = dict(
blank=True,
verbose_name='Leipäteksti',
)
page_template = dict(
max_length=127,
verbose_name='Sivupohja',
help_text='Sivut näytetään käyttäen tätä sivupohjaa. Tämännimisen sivupo... | code_fim | hard | {
"lang": "python",
"repo": "tracon/tracontent",
"path": "/content/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for chunk in l:
for line in chunk:
print(line, file=file)
print(file=file)
with open("recog_list.txt", "w") as f:
print_recog_list(recog_list, f)
with open("text.txt", "w") as f:
print(text, file=f)<|fim_prefix|># repo: seajo/wordminer path: /audio_separator.py
... | code_fim | hard | {
"lang": "python",
"repo": "seajo/wordminer",
"path": "/audio_separator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: seajo/wordminer path: /audio_separator.py
from pydub import AudioSegment
from pydub import silence
import requests
import json
import sys
def export_sample(audio_segment, filename=None):
if filename:
audio_segment.export(
f"{filename}.wav", format="wav", parameters=["-c:... | code_fim | medium | {
"lang": "python",
"repo": "seajo/wordminer",
"path": "/audio_separator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def styles_replacement(self, matchobj):
opening_tag = matchobj.group(1)
content = matchobj.group(2)
if not content.strip():
content = ''
else:
content = minify_css(content)
if content.endswith('\n'):
content = ''.join(... | code_fim | hard | {
"lang": "python",
"repo": "samuelmaudo/yepes",
"path": "/yepes/utils/minifier/backends/html.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return EMPTY_LINES_RE.sub(r'\n', code)
def process_leading_spaces(self, code):
return LEADING_SPACES_RE.sub('', code)
def process_newlines(self, code):
return NEWLINES_RE.sub(r'\n', code)
def process_pres(self, code):
return PRES_RE.sub(
self.... | code_fim | hard | {
"lang": "python",
"repo": "samuelmaudo/yepes",
"path": "/yepes/utils/minifier/backends/html.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samuelmaudo/yepes path: /yepes/utils/minifier/backends/html.py
# -*- coding:utf-8 -*-
from __future__ import unicode_literals
import re
from yepes.utils.minifier import minify_css, minify_js
__all__ = ('HtmlMinifier', 'minify')
PLACEHOLDER = '~({{[{0}]}})~'
COMMENTS_RE = re.compile(r'<!--.... | code_fim | hard | {
"lang": "python",
"repo": "samuelmaudo/yepes",
"path": "/yepes/utils/minifier/backends/html.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cohesity/management-sdk-python path: /cohesity_management_sdk/controllers/scheduler_controller.py
# -*- coding: utf-8 -*-
# Copyright 2023 Cohesity Inc.
import logging
from cohesity_management_sdk.api_helper import APIHelper
from cohesity_management_sdk.configuration import Configuration
from co... | code_fim | hard | {
"lang": "python",
"repo": "cohesity/management-sdk-python",
"path": "/cohesity_management_sdk/controllers/scheduler_controller.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
void: Response from the API. No Content
Raises:
APIException: When an error occurs while fetching the data from
the remote API. This exception includes the HTTP Response
code, an error message, and the HTTP body that was rec... | code_fim | hard | {
"lang": "python",
"repo": "cohesity/management-sdk-python",
"path": "/cohesity_management_sdk/controllers/scheduler_controller.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> doc = cls.col().find_one({"_id": id})
if doc is None:
raise DoesNotExist(f"No {cls.__name__} with id {id} exists")
return cls(**doc)
@classmethod
def from_context(cls, context):
doc_id = context.user_data.get(cls.Meta.name, None)
if not doc_id:
... | code_fim | hard | {
"lang": "python",
"repo": "ha-D/maleto",
"path": "/maleto/core/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ha-D/maleto path: /maleto/core/model.py
import logging
from collections import defaultdict
from datetime import datetime
from threading import RLock
from maleto.core import sentry
from maleto.core.utils import omit
from pymongo import MongoClient
logger = logging.getLogger(__name__)
from pymon... | code_fim | hard | {
"lang": "python",
"repo": "ha-D/maleto",
"path": "/maleto/core/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> docs = cls.find(**kwargs)
if len(docs) == 0:
return None
if len(docs) > 1:
raise ModelException("More than one item found")
return docs[0]
@classmethod
def find_by_id(cls, id):
doc = cls.col().find_one({"_id": id})
if doc is ... | code_fim | hard | {
"lang": "python",
"repo": "ha-D/maleto",
"path": "/maleto/core/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@click.command()
def build_input_db():
"""
Build a new, timestamped input database from Excel files.
"""
build_input_database()
cli.add_command(build_input_db)
cli()<|fim_prefix|># repo: MattSegal/AuTuMN path: /autumn/__main__.py
"""
Runs module utility scripts
You can access these scri... | code_fim | medium | {
"lang": "python",
"repo": "MattSegal/AuTuMN",
"path": "/autumn/__main__.py",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MattSegal/AuTuMN path: /autumn/__main__.py
"""
Runs module utility scripts
You can access these script from your CLI by running:
python -m autumn --help
"""
import click
from .db.input_data import build_input_database
@click.group()
def cli():
<|fim_suffix|>@click.command()
def build_inp... | code_fim | easy | {
"lang": "python",
"repo": "MattSegal/AuTuMN",
"path": "/autumn/__main__.py",
"mode": "psm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .db.input_data import build_input_database
@click.group()
def cli():
"""
AuTuMN utility command line
"""
pass
@click.command()
def build_input_db():
"""
Build a new, timestamped input database from Excel files.
"""
build_input_database()
cli.add_command(build_inp... | code_fim | easy | {
"lang": "python",
"repo": "MattSegal/AuTuMN",
"path": "/autumn/__main__.py",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pangeamt/nectm path: /src/TMDbApi/TMMap/deprecated/TMMapMongoDb.py
#
# Copyright (c) 2020 Pangeanic SL.
#
# This file is part of NEC TM
# (see https://github.com/shasha79/nectm).
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTI... | code_fim | medium | {
"lang": "python",
"repo": "Pangeamt/nectm",
"path": "/src/TMDbApi/TMMap/deprecated/TMMapMongoDb.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
result = bulk.execute()
except BulkWriteError as bwe:
result = bwe.details
logging.error(bwe.details)
return result
def get(self, source_id, source_lang, target_lang):
src_index = TMUtils.lang2es_index(source_lang)
tgt_index = TMUtils.lang2es_index(target_lang... | code_fim | hard | {
"lang": "python",
"repo": "Pangeamt/nectm",
"path": "/src/TMDbApi/TMMap/deprecated/TMMapMongoDb.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='Register',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('actual_name', models.CharField(max_length=20)),
('student_id', models.CharField(max_length=20)... | code_fim | hard | {
"lang": "python",
"repo": "michwh/onehome-server",
"path": "/users/migrations/0002_register.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: michwh/onehome-server path: /users/migrations/0002_register.py
# Generated by Django 2.1.2 on 2019-02-04 07:51
from django.db import migrations, models
<|fim_suffix|>
dependencies = [
('users', '0001_initial'),
]
operations = [
migrations.CreateModel(
n... | code_fim | hard | {
"lang": "python",
"repo": "michwh/onehome-server",
"path": "/users/migrations/0002_register.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> import gbvision
import numpy as np
data = gbvision.CameraData(0, 0, 0)
data.rotate_yaw(np.pi)
sin, cos = np.sin(np.pi), np.cos(np.pi)
self.assertTrue(all(data.rotation_matrix.flatten() == np.array(np.array([[cos, 0, sin],
... | code_fim | hard | {
"lang": "python",
"repo": "GreenBlitz/GBVision",
"path": "/test/tests/test_camera_data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GreenBlitz/GBVision path: /test/tests/test_camera_data.py
import unittest
class TestCameraData(unittest.TestCase):
def test_mutable(self):
import gbvision
data = gbvision.CameraData(0, 0, 0)
data.move_x(5)
self.assertEqual(data.offset[0], 5)
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "GreenBlitz/GBVision",
"path": "/test/tests/test_camera_data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if attempt == 1:
return send(to, text, img, 2)
raise Exception('Telegram send message')
def delete(to, message, attempt=1):
try:
bot.delete_message(to, message)
except:
print('! ERROR TELEGRAM DEL ! №{}'.format(attempt))
if attempt == 1:
return delete(to, message, 2)
raise Excepti... | code_fim | hard | {
"lang": "python",
"repo": "kosyachniy/dev",
"path": "/bots/tg/bot/lib/tg_bot_control.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise Exception('Telegram send message')
def delete(to, message, attempt=1):
try:
bot.delete_message(to, message)
except:
print('! ERROR TELEGRAM DEL ! №{}'.format(attempt))
if attempt == 1:
return delete(to, message, 2)
raise Exception('Telegram del message')
def edit(to, message, tex... | code_fim | medium | {
"lang": "python",
"repo": "kosyachniy/dev",
"path": "/bots/tg/bot/lib/tg_bot_control.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kosyachniy/dev path: /bots/tg/bot/lib/tg_bot_control.py
import json
import telebot
with open('keys.json', 'r') as file:
token = json.loads(file.read())['tg']['token']
bot = telebot.TeleBot(token)
<|fim_suffix|> try:
bot.delete_message(to, message)
except:
print('! ERROR TELEGRAM DEL !... | code_fim | hard | {
"lang": "python",
"repo": "kosyachniy/dev",
"path": "/bots/tg/bot/lib/tg_bot_control.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._total_limit = value
@property
def total_save_amount(self):
return self._total_save_amount
@total_save_amount.setter
def total_save_amount(self, value):
self._total_save_amount = value
def parse_response_content(self, response_content):
response =... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/response/AlipayInsAutoUserPointQueryResponse.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alipay/alipay-sdk-python-all path: /alipay/aop/api/response/AlipayInsAutoUserPointQueryResponse.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.response.AlipayResponse import AlipayResponse
class AlipayInsAutoUserPointQueryResponse(AlipayResponse):
def __i... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/response/AlipayInsAutoUserPointQueryResponse.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: securityauditing/moneywagon path: /moneywagon/wallet.py
from __future__ import print_function
from concurrent import futures
from moneywagon import get_address_balance, get_current_price
def fetch_wallet_balances(wallets, fiat, **modes):
"""
Wallets must be list of two item lists. First... | code_fim | hard | {
"lang": "python",
"repo": "securityauditing/moneywagon",
"path": "/moneywagon/wallet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> done, not_done = futures.wait(future_to_key, return_when=futures.FIRST_EXCEPTION)
if len(not_done) > 0:
raise not_done.pop().exception()
for future in done:
key = future_to_key[future]
if len(key) > 5: # this will break i... | code_fim | hard | {
"lang": "python",
"repo": "securityauditing/moneywagon",
"path": "/moneywagon/wallet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/verbs/_pitting.py
from xai.brain.wordbase.verbs._pit import _PIT
#calss header
class _PITTING(_PIT, ):
<|fim_suffix|> _PIT.__init__(self)
self.name = "PITTING"
self.specie = 'verbs'
self.basic = "pit"
self.jsondata = {}<|fim_middle|> def __init__... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/verbs/_pitting.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self,):
_PIT.__init__(self)
self.name = "PITTING"
self.specie = 'verbs'
self.basic = "pit"
self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/verbs/_pitting.py
from xai.brain.wordbase.verbs._pit import _PIT
<|fim_middle|>#calss header
class _PITTING... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/verbs/_pitting.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rpwagner/tiled-display path: /flapp/simplejson.py
t sre_constants.error:
raise
p.append(subpattern)
self.actions.append(token)
p = sre_parse.SubPattern(s, [(BRANCH, (None, p))])
self.scanner = sre_compile.compile(p)
def iterscan(self,... | code_fim | hard | {
"lang": "python",
"repo": "rpwagner/tiled-display",
"path": "/flapp/simplejson.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rpwagner/tiled-display path: /flapp/simplejson.py
ce(o, str):
_encoding = self.encoding
if (_encoding is not None
and not (_encoding == 'utf-8' and _need_utf8)):
o = o.decode(_encoding)
return encode_basestri... | code_fim | hard | {
"lang": "python",
"repo": "rpwagner/tiled-display",
"path": "/flapp/simplejson.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Performs the following translations in decoding:
+---------------+-------------------+
| JSON | Python |
+===============+===================+
| object | dict |
+---------------+-------------------+
| array | list ... | code_fim | hard | {
"lang": "python",
"repo": "rpwagner/tiled-display",
"path": "/flapp/simplejson.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sobolevn/django-swagger-tester path: /tests/test_response_validation/unit/static_schema/test_load_schema.py
import pytest
import yaml
from django.conf import settings as django_settings
from django.core.exceptions import ImproperlyConfigured
from django_swagger_tester.static_schema.loader import... | code_fim | hard | {
"lang": "python",
"repo": "sobolevn/django-swagger-tester",
"path": "/tests/test_response_validation/unit/static_schema/test_load_schema.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_no_matching_routes(monkeypatch) -> None:
"""
Asserts that the right exception is raised when an endpoint is not documented in the schema.
"""
monkeypatch.setattr(django_settings, 'SWAGGER_TESTER', {'PATH': yml_path})
monkeypatch.setattr('django_swagger_tester.static_schema.lo... | code_fim | hard | {
"lang": "python",
"repo": "sobolevn/django-swagger-tester",
"path": "/tests/test_response_validation/unit/static_schema/test_load_schema.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: georgeuwagbale/georgeCSC102 path: /BankX.py
class XBank:
loggedinCounter = 0
def __init__(self, theatmpin, theaccountbalance, thename):
self.atmpin = theatmpin
self.accountbalance = theaccountbalance
self.name = thename
XBank.loggedinCounter = XBank.logged... | code_fim | hard | {
"lang": "python",
"repo": "georgeuwagbale/georgeCSC102",
"path": "/BankX.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pasw = input()
if (pasw == password[0]):
customer = XBank(password[0], accountB[0], name[0])
else:
print("sorry your password does not match")<|fim_prefix|># repo: georgeuwagbale/georgeCSC102 path: /BankX.py
class XBank:
loggedinCounter = 0
def __init__(self, theatmpin, theaccountbalanc... | code_fim | hard | {
"lang": "python",
"repo": "georgeuwagbale/georgeCSC102",
"path": "/BankX.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: radiasoft/rsfbpic path: /rsfbpic/rswake/lbn_plot.py
# -*- coding: utf-8 -*-
"""
Plotting curves from 2017 PRAB article by Lebedev, Burov and Nagaitsev
:copyright: Copyright (c) 2019 Radiasoft LLC. All Rights Reserved.
:license: http://www.apache.org/licenses/LICENSE-2.0.html
"""
# SciPy imports... | code_fim | hard | {
"lang": "python",
"repo": "radiasoft/rsfbpic",
"path": "/rsfbpic/rswake/lbn_plot.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Specify the plot range, xi_min <= xi <= xi_max
# xi=ct-z is the distance from the front of the bubble (positive)
xi_min = 0.
xi_max = 2.*xi_b
num_points = 200
xi_array = np.linspace(xi_min, xi_max, num=num_points)
rb_array = np.zeros(num_points)
for iloop in range(0, num_... | code_fim | hard | {
"lang": "python",
"repo": "radiasoft/rsfbpic",
"path": "/rsfbpic/rswake/lbn_plot.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
app_settings = {
"debug": False,
"aiohttp_settings": {},
"databases": [],
"conflict_retry_attempts": 3,
"host": "127.0.0.1",
"port": 8080,
"static": {},
"jsapps": {},
"default_static_filenames": ['index.html', 'index.htm'],
"utilities": [],
"store_json": True,
... | code_fim | medium | {
"lang": "python",
"repo": "tareqalam/guillotina",
"path": "/guillotina/__init__.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tareqalam/guillotina path: /guillotina/__init__.py
# -*- encoding: utf-8 -*-
# load the patch before anything else.
from guillotina import glogging
from guillotina import patch # noqa
from guillotina.i18n import MessageFactory
# create logging
logger = glogging.getLogger('guillotina')
<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "tareqalam/guillotina",
"path": "/guillotina/__init__.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """The login must return a token"""
token = self.download.get_token()
self.assertIsInstance(token, str)
def test_token_format(self):
"""The token needs be with a Bearer prefix"""
bearer_token =self.download.get_authorization()
bearer = bearer_token.spli... | code_fim | hard | {
"lang": "python",
"repo": "embrace-inpe/swds-api-downloader",
"path": "/src/tests/test_api_download.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: embrace-inpe/swds-api-downloader path: /src/tests/test_api_download.py
import os
import shutil
from unittest import TestCase
import settings
from src.api import APIDownload
class APIDownloadTest(TestCase):
def setUp(self):
search = settings.SEARCH
path_to_save = './tmp-test... | code_fim | hard | {
"lang": "python",
"repo": "embrace-inpe/swds-api-downloader",
"path": "/src/tests/test_api_download.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(episode_rewards) > 1:
acc_steps.append(total_num_steps)
acc_scores.append(np.mean(episode_rewards))
if (args.eval_interval is not None
and len(episode_rewards) > 1
and j % args.eval_interval == 0):
eval_envs = make_vec_envs(args.env_name, args.seed + args.... | code_fim | hard | {
"lang": "python",
"repo": "alexis-jacq/Learning_from_a_Learner",
"path": "/lfl/mujoco/observer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexis-jacq/Learning_from_a_Learner path: /lfl/mujoco/observer.py
"""Observer's training.
The observer is trained via Proximal Policy Optimization (PPO).
This code is an adaptation of the PPO implementation taken from
https://github.com/ikostrikov/pytorch-a2c-ppo-acktr-gail.
"""
import collecti... | code_fim | hard | {
"lang": "python",
"repo": "alexis-jacq/Learning_from_a_Learner",
"path": "/lfl/mujoco/observer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class ConvBnReLU2d(torch.nn.Sequential):
def __init__(self, conv, bn, relu):
assert type(conv) == Conv2d and type(bn) == torch.nn.BatchNorm2d and \
type(relu) == ReLU, 'Incorrect types for input modules{}{}{}' \
.format(type(conv), type(bn), type(relu))
super(Co... | code_fim | hard | {
"lang": "python",
"repo": "tjiagoM/quantised-bayesian-nets",
"path": "/src/models/stochastic/bbb/conv.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fused_conv.weight, fused_conv.bias, fused_conv.std= \
fuse_conv_bn_weights(fused_conv.weight, fused_conv.bias, fused_conv.std,
bn.running_mean, bn.running_var, bn.eps, bn.weight, bn.bias)
return fused_conv
def fuse_conv_bn(conv, bn):
assert(conv.training ... | code_fim | hard | {
"lang": "python",
"repo": "tjiagoM/quantised-bayesian-nets",
"path": "/src/models/stochastic/bbb/conv.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tjiagoM/quantised-bayesian-nets path: /src/models/stochastic/bbb/conv.py
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn import ReLU
from torch.autograd import Variable
from src.models.stochastic.bbb.utils_bbb import kl_divergence, softplusinv
import copy
class... | code_fim | hard | {
"lang": "python",
"repo": "tjiagoM/quantised-bayesian-nets",
"path": "/src/models/stochastic/bbb/conv.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.gitProto
def getUsrName(self):
return self.usrName
def getUsrRole(self):
return self.internalUser
def getAnchorDir(self):
return self.anchor
def getLFSEnabledRepos(self):
return self.info['LFSEnabledRepos']
def getSRPkgRepos(self... | code_fim | hard | {
"lang": "python",
"repo": "FlexSNR/reltools",
"path": "/setupTool.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FlexSNR/reltools path: /setupTool.py
import os
import json
gSetup = None
SNAP_ROUTE_SRC = '/snaproute/src/'
EXTERNAL_SRC = '/external/src/'
GENERATED_SRC = '/generated/src/'
class setupGenie(object):
def __init__(self, setupInfo, anchorDir , gitUsrName, role, gitProto='http'):
self.... | code_fim | hard | {
"lang": "python",
"repo": "FlexSNR/reltools",
"path": "/setupTool.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
The base address suited for a url parameter.
"""
return urllib.parse.quote(self.base)
@property
def discovery_address_tuple(self):
"""
A tuple of the discovery address and the port set for fHDHR.
"""
return (self.discovery_addr... | code_fim | hard | {
"lang": "python",
"repo": "gamichaelh/fHDHR",
"path": "/fHDHR/api/__init__.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gamichaelh/fHDHR path: /fHDHR/api/__init__.py
import urllib.parse
import threading
class Fillin_Client():
"""
Until fHDHR_web is loaded, use requests for internal API calls.
"""
def __init__(self, settings, web):
self.config = settings
self.web = web
def __... | code_fim | hard | {
"lang": "python",
"repo": "gamichaelh/fHDHR",
"path": "/fHDHR/api/__init__.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kryndex/cretonne path: /lib/cretonne/meta/isa/intel/encodings.py
"""
Intel Encodings.
"""
from __future__ import absolute_import
from base import instructions as base
from .defs import I32
from . import recipes as r
I32.enc(base.iadd.i32, *r.rr(0x01))
I32.enc(base.isub.i32, *r.rr(0x29))
I32.enc... | code_fim | hard | {
"lang": "python",
"repo": "Kryndex/cretonne",
"path": "/lib/cretonne/meta/isa/intel/encodings.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>I32.enc(base.load.i32.i32, *r.ld(0x8b))
I32.enc(base.load.i32.i32, *r.ldDisp8(0x8b))
I32.enc(base.load.i32.i32, *r.ldDisp32(0x8b))
I32.enc(base.uload16.i32.i32, *r.ld(0x0f, 0xb7))
I32.enc(base.uload16.i32.i32, *r.ldDisp8(0x0f, 0xb7))
I32.enc(base.uload16.i32.i32, *r.ldDisp32(0x0f, 0xb7))
I32.enc(base.sl... | code_fim | hard | {
"lang": "python",
"repo": "Kryndex/cretonne",
"path": "/lib/cretonne/meta/isa/intel/encodings.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> subject=models.CharField(max_length=40)
body=models.TextField()
attachement=models.FileField(upload_to="newsletter")
newsletter = models.CharField(max_length=20,default='newsletter')<|fim_prefix|># repo: SamyMe/django-markdown-newsletter path: /build/django-markdown-newsletter/build/lib.linux-i686-2.... | code_fim | medium | {
"lang": "python",
"repo": "SamyMe/django-markdown-newsletter",
"path": "/build/django-markdown-newsletter/build/lib.linux-i686-2.7/django-markdown-newsletter/models.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.