text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: oleg-chubin/let_me_play path: /let_me_play/urls.py
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
import django.contrib.auth.urls
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf import sett... | code_fim | hard | {
"lang": "python",
"repo": "oleg-chubin/let_me_play",
"path": "/let_me_play/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def init():
app.run(debug=True)
if __name__ == '__main__':
import platform
if platform.system().lower() == 'windows':
l = []
for letter in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
if os.path.isdir(f'{letter}:\\'):
l.append(letter)
for letter in l:
try:
dir = f'{le... | code_fim | hard | {
"lang": "python",
"repo": "Tidanium/librarium",
"path": "/server/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tidanium/librarium path: /server/server.py
from flask import Flask, abort, make_response, jsonify
from modules import file_management as fmanage
import asyncio, aiohttp
import os
from modules.utils import settings
app = Flask(settings.Config.getConfigValue('default', 'name'))
# todo actually wo... | code_fim | medium | {
"lang": "python",
"repo": "Tidanium/librarium",
"path": "/server/server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ("2000-01-08", "20:00:00.000") -> "2000-01-08 20:00:00"
dt_str = items[0] + ' ' + items[1][:8]
dt = datetime.strptime(dt_str, "%Y-%m-%d %H:%M:%S")
return (time.mktime(dt.timetuple()), float(items[3]))<|fim_prefix|># repo: checongcong/dst-exploratory-analysis path: /src/p... | code_fim | hard | {
"lang": "python",
"repo": "checongcong/dst-exploratory-analysis",
"path": "/src/parser_iaga.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: checongcong/dst-exploratory-analysis path: /src/parser_iaga.py
# IAGAParser parses the IAGA2002 format into DST data.
# IAGA2002 format: http://wdc.kugi.kyoto-u.ac.jp/mdplt/format/iaga2002.html
import sys
import time
from datetime import datetime
from dst import Dst
<|fim_suffix|> # Ope... | code_fim | medium | {
"lang": "python",
"repo": "checongcong/dst-exploratory-analysis",
"path": "/src/parser_iaga.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(varidx['SigmaP']) # Pedersen conductance
# 4
print(varidx['SigmaH']) # Hall conductance
# 3
print(data[varidx['Theta'],:]) # colatitudes
#[ 0. 180. 179. ... 3. 2. 1.]
print(data[varidx['Psi'],:]) # longitudes
#[ 0. 0. 0. ... 358. 358. 358.]<|fim_prefix|># repo: GaryQ-physics/swmfio p... | code_fim | hard | {
"lang": "python",
"repo": "GaryQ-physics/swmfio",
"path": "/demo_rim_cdf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GaryQ-physics/swmfio path: /demo_rim_cdf.py
import swmfio as swmfio
from os.path import exists
from urllib.request import urlretrieve
urlbase = 'http://mag.gmu.edu/git-data/swmfio/'
tmpdir = '/tmp/'
filename = 'SWPC_SWMF_052811_2.swmf.it061214_071000_000.cdf'
if not exists(tmpdir + filename):
... | code_fim | hard | {
"lang": "python",
"repo": "GaryQ-physics/swmfio",
"path": "/demo_rim_cdf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self, snr_input: Union[int, float, np.ndarray, Sig2NoiseQuery], fill_value=None
) -> None:
"""
Sets S/N for instrument configuration.
- If snr_input is an int or float, a constant S/N is set for all pixels.
- If snr_input is a 2D array, the first row is the wav... | code_fim | hard | {
"lang": "python",
"repo": "tingyuansen/Chem-I-Calc",
"path": "/chemicalc/instruments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> - If snr_input is an int or float, a constant S/N is set for all pixels.
- If snr_input is a 2D array, the first row is the wavelength grid and the second row is the S/N per pixel. The S/N is then interpolated onto the instrument's wavelength grid.
- If snr_input is a 1D array, the... | code_fim | hard | {
"lang": "python",
"repo": "tingyuansen/Chem-I-Calc",
"path": "/chemicalc/instruments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tingyuansen/Chem-I-Calc path: /chemicalc/instruments.py
from typing import Union, Dict
from warnings import warn
import copy
from pathlib import Path
import json
import numpy as np
from scipy.interpolate import interp1d
from chemicalc.utils import generate_wavelength_template
from chemicalc.s2n i... | code_fim | hard | {
"lang": "python",
"repo": "tingyuansen/Chem-I-Calc",
"path": "/chemicalc/instruments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class BlogForm(forms.Form):
title = forms.CharField()
author = forms.CharField()
body = forms.TextField()
@register('blog')
class BlogAdmin(CRUDAdmin):
icon = 'fa fa-book'
form = forms.Layout(BlogForm)<|fim_prefix|># repo: SirZazu/lux path: /tests/admin/__init__.py
import lux
from l... | code_fim | hard | {
"lang": "python",
"repo": "SirZazu/lux",
"path": "/tests/admin/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SirZazu/lux path: /tests/admin/__init__.py
import lux
from lux import forms
from lux.extensions.admin import register, CRUDAdmin
<|fim_suffix|>
class Extension(lux.Extension):
pass
class BlogForm(forms.Form):
title = forms.CharField()
author = forms.CharField()
body = forms.Te... | code_fim | hard | {
"lang": "python",
"repo": "SirZazu/lux",
"path": "/tests/admin/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pestanko/py-is-muni-api path: /muni_is_api/entities.py
import logging
from typing import List, Optional
from defusedxml.lxml import tostring, RestrictedElement
log = logging.getLogger(__name__)
class Resource:
def __init__(self, content: RestrictedElement, base_selector=""):
self.... | code_fim | hard | {
"lang": "python",
"repo": "pestanko/py-is-muni-api",
"path": "/muni_is_api/entities.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class CourseStudents(Resource):
def __init__(self, content: RestrictedElement,
base_selector="/PREDMET_STUDENTI_INFO/"):
super().__init__(content, base_selector=base_selector)
@property
def students(self) -> List[StudentSub]:
return self._collection('STUDENT'... | code_fim | hard | {
"lang": "python",
"repo": "pestanko/py-is-muni-api",
"path": "/muni_is_api/entities.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lustfullyCake/the-tale path: /src/the_tale/the_tale/portal/management/commands/portal_postupdate_operations.py
# coding: utf-8
from django.core.management.base import BaseCommand
from dext.settings import settings
from the_tale.common.utils.permissions import sync_group
from dext.common.utils.... | code_fim | hard | {
"lang": "python",
"repo": "lustfullyCake/the-tale",
"path": "/src/the_tale/the_tale/portal/management/commands/portal_postupdate_operations.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> print()
print('REFRESH ATTRIBUTES')
places_logic.refresh_all_places_attributes()
persons_logic.refresh_all_persons_attributes()
print()
print('REMOVE OLD CDN INFO')
if portal_settings.SETTINGS_CDN_INFO_KEY in settings:
del settings[por... | code_fim | hard | {
"lang": "python",
"repo": "lustfullyCake/the-tale",
"path": "/src/the_tale/the_tale/portal/management/commands/portal_postupdate_operations.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for func, args, kwargs in self.waiting:
func(*args, **kwargs)
def print_n(n):
print n
def test_func():
print "begin"
with Defer() as defer:
for i in range(10):
defer(print_n, i)
print "done"
if __name__ == '__main__':
print test_func.fun... | code_fim | hard | {
"lang": "python",
"repo": "zjjott/curiosity",
"path": "/defer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print "begin"
with Defer() as defer:
for i in range(10):
defer(print_n, i)
print "done"
if __name__ == '__main__':
print test_func.func_code<|fim_prefix|># repo: zjjott/curiosity path: /defer.py
# coding=utf-8
from __future__ import unicode_literals
class Defer(... | code_fim | hard | {
"lang": "python",
"repo": "zjjott/curiosity",
"path": "/defer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zjjott/curiosity path: /defer.py
# coding=utf-8
from __future__ import unicode_literals
class Defer(object):
"""
Implement Go lang defer keywords
like demo
"""
def __init__(self):
<|fim_suffix|> return self
def __exit__(self, *exc_info):
for func, args, ... | code_fim | medium | {
"lang": "python",
"repo": "zjjott/curiosity",
"path": "/defer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Example: curl http://localhost:8090/block/8884FF53AE28F1DD5499F78733FC1A075864FFC428CEEC9A9C8A4ECCA98BB134
@route('/block/<block_hash>', method='GET')
def getBlock(block_hash):
block = node_rpc_helper.getBlockInfo(block_hash)
setHeaders()
# return the contents
if 'contents' in block:
... | code_fim | hard | {
"lang": "python",
"repo": "mikroncoin/mikron_restapi_py",
"path": "/service/restapi_service.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mikroncoin/mikron_restapi_py path: /service/restapi_service.py
import account_helper
import node_rpc_helper
import cache
import os
import json
from bottle import post, request, response, get, route, static_file
from threading import Thread
def setHeaders():
response.content_type = 'applicat... | code_fim | hard | {
"lang": "python",
"repo": "mikroncoin/mikron_restapi_py",
"path": "/service/restapi_service.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pagesize = 50
offset = 0
if int(page) >= 1:
offset = int(page) * pagesize
history = node_rpc_helper.getAccountHistory(account_id, pagesize, offset)
setHeaders()
return history
# Example: curl http://localhost:8090/block/8884FF53AE28F1DD5499F78733FC1A075864FFC428CEEC9A9C8A4... | code_fim | hard | {
"lang": "python",
"repo": "mikroncoin/mikron_restapi_py",
"path": "/service/restapi_service.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Widget:
templates: Jinja2Templates = t
template: str = ""
def __init__(self, **context):
"""
All context will pass to template render if template is not empty.
:param context:
"""
self.context = context
async def render(self, request: Reques... | code_fim | medium | {
"lang": "python",
"repo": "myWorkshop123/fastapi-admin",
"path": "/fastapi_admin/widgets/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: myWorkshop123/fastapi-admin path: /fastapi_admin/widgets/__init__.py
from typing import Any
from starlette.requests import Request
from starlette.templating import Jinja2Templates
from fastapi_admin.template import templates as t
<|fim_suffix|> templates: Jinja2Templates = t
template: s... | code_fim | medium | {
"lang": "python",
"repo": "myWorkshop123/fastapi-admin",
"path": "/fastapi_admin/widgets/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> templates: Jinja2Templates = t
template: str = ""
def __init__(self, **context):
"""
All context will pass to template render if template is not empty.
:param context:
"""
self.context = context
async def render(self, request: Request, value: Any):... | code_fim | medium | {
"lang": "python",
"repo": "myWorkshop123/fastapi-admin",
"path": "/fastapi_admin/widgets/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YKJIN/CAEML path: /caeml/management/conf/__init__.py
__copyright__ = "Copyright 2017 Renumics GmbH (http://www.renumics.com)"
fr<|fim_suffix|>azySettings
settings = LazySettings()<|fim_middle|>om caeml.management.conf.base import L | code_fim | easy | {
"lang": "python",
"repo": "YKJIN/CAEML",
"path": "/caeml/management/conf/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>azySettings
settings = LazySettings()<|fim_prefix|># repo: YKJIN/CAEML path: /caeml/management/conf/__init__.py
__copyright__ = "Copyright 2017 Renum<|fim_middle|>ics GmbH (http://www.renumics.com)"
from caeml.management.conf.base import L | code_fim | medium | {
"lang": "python",
"repo": "YKJIN/CAEML",
"path": "/caeml/management/conf/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # theme
html_theme = theme
shtml_theme_options = {"bodyfont": "Calibri"}
if theme_path is not None:
if isinstance(theme_path, list):
html_theme_path = theme_path # pragma: no cover
else:
html_theme_path = [theme_path]
# static files
html_st... | code_fim | hard | {
"lang": "python",
"repo": "Pandinosaurus/pyquickhelper",
"path": "/src/pyquickhelper/helpgen/default_conf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pandinosaurus/pyquickhelper path: /src/pyquickhelper/helpgen/default_conf.py
phinx_gallery = True
except ImportError: # pragma: no cover
has_sphinx_gallery = False
if has_sphinx_gallery:
try:
import sphinx_gallery.gen_rst
except ValueError as e: # pr... | code_fim | hard | {
"lang": "python",
"repo": "Pandinosaurus/pyquickhelper",
"path": "/src/pyquickhelper/helpgen/default_conf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Pandinosaurus/pyquickhelper path: /src/pyquickhelper/helpgen/default_conf.py
name)
}}
else:
jupyter_sphinx_thebelab_config = {'requestKernel': True}
# settings
exclude_patterns = ["*.py", "**/*.py"]
html_show_sphinx = False
html_show_copyright = False
... | code_fim | hard | {
"lang": "python",
"repo": "Pandinosaurus/pyquickhelper",
"path": "/src/pyquickhelper/helpgen/default_conf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mobile >> firebase >> lambda_train >> model >> lambda_predict >> firebase
firebase >> mobile<|fim_prefix|># repo: danvargg/danvargg path: /docs/projects/auraML/auraML.py
"""Aura Health ML pipeline architecture diagram."""
from diagrams import Diagram, Cluster
from diagrams.aws.compute import Lamb... | code_fim | hard | {
"lang": "python",
"repo": "danvargg/danvargg",
"path": "/docs/projects/auraML/auraML.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danvargg/danvargg path: /docs/projects/auraML/auraML.py
"""Aura Health ML pipeline architecture diagram."""
from diagrams import Diagram, Cluster
from diagrams.aws.compute import Lambda
from diagrams.firebase.base import Firebase
from diagrams.aws.ml import MachineLearning
from diagrams.aws.integ... | code_fim | hard | {
"lang": "python",
"repo": "danvargg/danvargg",
"path": "/docs/projects/auraML/auraML.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def fetch_all(self, table_name):
return self.conn.execute(
'select * from %s;' % table_name).fetchall()
def get_count(self, table_name):
return self.conn.execute(
'select count() from %s;' % table_name).fetchone()[0]
def execute(self, operation):
... | code_fim | medium | {
"lang": "python",
"repo": "mcxiaoke/python-labs",
"path": "/archives/fanfou/basedb.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mcxiaoke/python-labs path: /archives/fanfou/basedb.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: mcxiaoke
# @Date: 2015-08-07 07:36:01
import sqlite3
<|fim_suffix|> def execute(self, operation):
c = self.conn.cursor()
c.execute(operation)
self.conn.comm... | code_fim | hard | {
"lang": "python",
"repo": "mcxiaoke/python-labs",
"path": "/archives/fanfou/basedb.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>lse:
print(b[::-1])
else:
print(b[::-1])<|fim_prefix|># repo: OMEGA-Y/CodingTest-sol path: /solution/2908(상수).py
a,b = input().split()
if a[2] > b[2]:
print(a[:<|fim_middle|>:-1])
elif a[2] == b[2]:
if a[1] > b[1] or (a[1]==b[1] and a[0]>b[0]):
print(a[::-1])
e | code_fim | medium | {
"lang": "python",
"repo": "OMEGA-Y/CodingTest-sol",
"path": "/solution/2908(상수).py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OMEGA-Y/CodingTest-sol path: /solution/2908(상수).py
a,b = input().split()
if a[2] > b[2]:
print(a[::-1])
elif a[2] == b[2]:
if a[1] > b[1] or (a[1]<|fim_suffix|>lse:
print(b[::-1])
else:
print(b[::-1])<|fim_middle|>==b[1] and a[0]>b[0]):
print(a[::-1])
e | code_fim | easy | {
"lang": "python",
"repo": "OMEGA-Y/CodingTest-sol",
"path": "/solution/2908(상수).py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> from urlparse import urljoin # noqa<|fim_prefix|># repo: mgrbyte/pydatomic path: /pydatomic/compat.py
# Python2 compatability handled in exception cases.
try:
from urllib.pars<|fim_middle|>e import urljoin
except ImportError:
| code_fim | easy | {
"lang": "python",
"repo": "mgrbyte/pydatomic",
"path": "/pydatomic/compat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mgrbyte/pydatomic path: /pydatomic/compat.py
# Python2 compatability handled in exception cases.
try:
from urllib.pars<|fim_suffix|> from urlparse import urljoin # noqa<|fim_middle|>e import urljoin
except ImportError:
| code_fim | easy | {
"lang": "python",
"repo": "mgrbyte/pydatomic",
"path": "/pydatomic/compat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Guillaume-Docquier/python-azure-func-tutorial path: /ai-model/format_data.py
import json
import os
from costprediction.predict import INPUT_SIZE, OUTPUT_SIZE
DATA_FOLDER = "./data/"
RAW_DATA_FOLDER = DATA_FOLDER + "raw/"
(_, _, file_names) = next(os.walk(RAW_DATA_FOLDER))
# Extract
resource_c... | code_fim | medium | {
"lang": "python",
"repo": "Guillaume-Docquier/python-azure-func-tutorial",
"path": "/ai-model/format_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(f"{len(resource_costs)} resources to save")
# Load
nb_train_resource_costs = int(len(resource_costs) * 0.8)
with open(DATA_FOLDER + "train.json", 'w') as outfile:
json.dump(resource_costs[:5000], outfile)
with open(DATA_FOLDER + "test.json", 'w') as outfile:
json.dump(resource_costs[5000:7... | code_fim | hard | {
"lang": "python",
"repo": "Guillaume-Docquier/python-azure-func-tutorial",
"path": "/ai-model/format_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Extract
resource_costs = []
processed = 0
nb_files = len(file_names)
for file_name in file_names[:500]:
with open(RAW_DATA_FOLDER + file_name) as json_file:
resources = json.load(json_file)
# Transform
for resource_name in resources:
resource = resources[resource_... | code_fim | medium | {
"lang": "python",
"repo": "Guillaume-Docquier/python-azure-func-tutorial",
"path": "/ai-model/format_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main() -> None:
# collect paths for each layer here
layers = []
##############################
# Base Circle #
##############################
plain_circle: Path = waves_helper.gen_circle(
(CANVAS_SIZE[0] / 2, CANVAS_SIZE[1] / 2),
DIAMETER_RATIO... | code_fim | medium | {
"lang": "python",
"repo": "DuncanDHall/vector-mandalas",
"path": "/waves.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dwg = svgwrite.Drawing(
os.path.join('./drawings/', FILE_Name),
size=CANVAS_SIZE, profile='tiny'
)
dwg.stroke(color=LINE_COLOR, width=1)
for path in layers:
dwg.add(dwg.path(d=bezier.path_to_string(path), fill="none"))
dwg.save()
if __name__ == "__main__":
... | code_fim | hard | {
"lang": "python",
"repo": "DuncanDHall/vector-mandalas",
"path": "/waves.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DuncanDHall/vector-mandalas path: /waves.py
import numpy as np
import svgwrite
import os
from vector_mandalas import bezier, waves_helper
from vector_mandalas.bezier import Path, Point
##############################
# Global Config #
##############################
<|fim_suffix|>
... | code_fim | medium | {
"lang": "python",
"repo": "DuncanDHall/vector-mandalas",
"path": "/waves.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # This constant is required by soc.modules.core module. If its values
# does not match the one defined there, the callback is rejected.
API_VERSION = 1
def __init__(self, core):
"""Initializes a new Callback object for the specified core.
"""
self.core = core
def registerWithSitem... | code_fim | medium | {
"lang": "python",
"repo": "sambitgaan/nupic.son",
"path": "/app/soc/modules/seeder/callback.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sambitgaan/nupic.son path: /app/soc/modules/seeder/callback.py
#
# Copyright 2010 the Melange authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.... | code_fim | hard | {
"lang": "python",
"repo": "sambitgaan/nupic.son",
"path": "/app/soc/modules/seeder/callback.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RobinMarshall55/InnerEye-DeepLearning path: /InnerEye-DataQuality/InnerEyeDataQuality/datasets/tools.py
# ------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License (MIT... | code_fim | hard | {
"lang": "python",
"repo": "RobinMarshall55/InnerEye-DeepLearning",
"path": "/InnerEye-DataQuality/InnerEyeDataQuality/datasets/tools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i, (x, y) in enumerate(dataset):
# (1 x M) * (M x 10) = (1 x 10)
A = x.view(1, -1).mm(W[y]).squeeze(0)
A[y] = -inf
A = flip_rate[i] * F.softmax(A, dim=0)
A[y] += 1 - flip_rate[i]
P.append(A)
P = torch.stack(P, 0).numpy()
return P<|fim_prefix... | code_fim | medium | {
"lang": "python",
"repo": "RobinMarshall55/InnerEye-DeepLearning",
"path": "/InnerEye-DataQuality/InnerEyeDataQuality/datasets/tools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>str.translate(message, translator)
print(secret_code)<|fim_prefix|># repo: buzzcola/codingclub path: /Week 08/rot13.py
translator = str.maketrans(
'abcdefghijklmnopqrstuvwxyz',
'nopqrstuvwxyzabcdefghijklm'
)
message <|fim_middle|>= input('What is the secret message?')
secret_code = | code_fim | easy | {
"lang": "python",
"repo": "buzzcola/codingclub",
"path": "/Week 08/rot13.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: buzzcola/codingclub path: /Week 08/rot13.py
translator = str.maketrans(
'abcdefghijklmnopqrstuvwxyz',
'nopqrstuvwxyzabcdefghijklm'
)
message <|fim_suffix|>str.translate(message, translator)
print(secret_code)<|fim_middle|>= input('What is the secret message?')
secret_code = | code_fim | easy | {
"lang": "python",
"repo": "buzzcola/codingclub",
"path": "/Week 08/rot13.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> objects = AssignmentGroupManager.from_queryset(AssignmentGroupQuerySet)()
parentnode = models.ForeignKey(Assignment, related_name='assignmentgroups', on_delete=models.CASCADE)
name = models.CharField(
max_length=30, blank=True, null=False, default='',
help_text='An optional na... | code_fim | hard | {
"lang": "python",
"repo": "devilry/devilry-django",
"path": "/devilry/apps/core/models/assignment_group.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: devilry/devilry-django path: /devilry/apps/core/models/assignment_group.py
ts, we use the ID.
.. seealso:: https://github.com/devilry/devilry-django/issues/498
"""
return self.get_short_displayname()
def get_unanonymized_long_displayname(self):
candidates = s... | code_fim | hard | {
"lang": "python",
"repo": "devilry/devilry-django",
"path": "/devilry/apps/core/models/assignment_group.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Annotate the queryset with ``annotated_is_waiting_for_feedback``.
Groups waiting for feedback is all groups where
the deadline of the last feedbackset (or :attr:`.Assignment.first_deadline` and only one feedbackset)
has expired, and the feedbackset does not have... | code_fim | hard | {
"lang": "python",
"repo": "devilry/devilry-django",
"path": "/devilry/apps/core/models/assignment_group.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # first page
header_url = urljoin(site_url, reverse('careers:print-preview-header', kwargs={'slug': obj.slug, }))
header_html_source = url_read(header_url)
header = HTML(string=header_html_source, base_url=site_url).render()
# other pages
content_url = urljoin(site_url, reverse('c... | code_fim | medium | {
"lang": "python",
"repo": "unawe/spaceawe",
"path": "/spaceawe/renderers/career.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # other pages
content_url = urljoin(site_url, reverse('careers:print-preview-content', kwargs={'slug': obj.slug, }))
content_html_source = url_read(content_url)
content = HTML(string=content_html_source, base_url=site_url).render()
header.pages += content.pages
header.write_pdf(p... | code_fim | hard | {
"lang": "python",
"repo": "unawe/spaceawe",
"path": "/spaceawe/renderers/career.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: unawe/spaceawe path: /spaceawe/renderers/career.py
from django.core.urlresolvers import reverse
from django.utils.translation import activate
from weasyprint import HTML
from contrib.urlfetch import url_read
from urllib.parse import urljoin
import logging
logger = logging.getLogger('spaceawe')
... | code_fim | hard | {
"lang": "python",
"repo": "unawe/spaceawe",
"path": "/spaceawe/renderers/career.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: guptamadhur/HackerRank path: /Python/Sets/Symmetric Difference.py
# Author: Madhur Gupta
# Github: github.com/guptamadhur
# Project: Hacker Rank Practice Python
<|fim_suffix|>if __name__ == '__main__':
a, b = [set(input().split()) for _ in range(4)][1::2]
print('\n'.join(sorted(a ^ b, ke... | code_fim | medium | {
"lang": "python",
"repo": "guptamadhur/HackerRank",
"path": "/Python/Sets/Symmetric Difference.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
a, b = [set(input().split()) for _ in range(4)][1::2]
print('\n'.join(sorted(a ^ b, key=int)))<|fim_prefix|># repo: guptamadhur/HackerRank path: /Python/Sets/Symmetric Difference.py
# Author: Madhur Gupta
# Github: github.com/guptamadhur
# Project: Hacker Rank Practice ... | code_fim | medium | {
"lang": "python",
"repo": "guptamadhur/HackerRank",
"path": "/Python/Sets/Symmetric Difference.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def main():
r = requests.get("https://kctbh9vrtdwd.statuspage.io/api/v2/status.json")
if r.ok:
message = r.json()
if message:
print(INFLUXDB_LINE.format(
message['status']['description'],
message['status']['indicator'],
S... | code_fim | medium | {
"lang": "python",
"repo": "rdo-infra/ci-config",
"path": "/ci-scripts/infra-setup/roles/rrcockpit/files/telegraf_py3/github_status.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rdo-infra/ci-config path: /ci-scripts/infra-setup/roles/rrcockpit/files/telegraf_py3/github_status.py
#!/usr/bin/env python
import requests
from influxdb_utils import format_ts_from_str
<|fim_suffix|>
def main():
r = requests.get("https://kctbh9vrtdwd.statuspage.io/api/v2/status.json")
... | code_fim | hard | {
"lang": "python",
"repo": "rdo-infra/ci-config",
"path": "/ci-scripts/infra-setup/roles/rrcockpit/files/telegraf_py3/github_status.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: franklingu/leetcode-solutions path: /questions/minimum-cost-to-hire-k-workers/Solution.py
"""
There are N workers. The i-th worker has a quality[i] and a minimum wage expectation wage[i].
Now we want to hire exactly K workers to form a paid group. When hiring a group of K workers, we must pay ... | code_fim | hard | {
"lang": "python",
"repo": "franklingu/leetcode-solutions",
"path": "/questions/minimum-cost-to-hire-k-workers/Solution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>1 <= K <= N <= 10000, where N = quality.length = wage.length
1 <= quality[i] <= 10000
1 <= wage[i] <= 10000
Answers within 10^-5 of the correct answer will be considered correct.
"""
class Solution(object):
def mincostToHireWorkers(self, quality, wage, K):
from fractions import Fraction
... | code_fim | medium | {
"lang": "python",
"repo": "franklingu/leetcode-solutions",
"path": "/questions/minimum-cost-to-hire-k-workers/Solution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ai-erorr404/opencv-practice path: /basics_raspberry/readImg.py
#!/usr/bin/python3
import cv2
<|fim_suffix|>img = cv2.imread("G:/learn-project/tmp/1.jpg", cv2.IMREAD_COLOR)
cv2.imshow("picImage", img)
cv2.waitKey(0)
print("image is closed!")<|fim_middle|>WINDOW_NAME = "picImage"
| code_fim | easy | {
"lang": "python",
"repo": "ai-erorr404/opencv-practice",
"path": "/basics_raspberry/readImg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("image is closed!")<|fim_prefix|># repo: ai-erorr404/opencv-practice path: /basics_raspberry/readImg.py
#!/usr/bin/python3
import cv2
<|fim_middle|>WINDOW_NAME = "picImage"
img = cv2.imread("G:/learn-project/tmp/1.jpg", cv2.IMREAD_COLOR)
cv2.imshow("picImage", img)
cv2.waitKey(0)
| code_fim | medium | {
"lang": "python",
"repo": "ai-erorr404/opencv-practice",
"path": "/basics_raspberry/readImg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> feed_dict_train = self.construct_feed_dict(self.train_mask,True)
feed_dict_val = self.construct_feed_dict(self.val_mask,False)
feed_dict_test = self.construct_feed_dict(self.test_mask,False)
start = time.time()
for i in range(self.epochs):
loss_tr,_,acc... | code_fim | hard | {
"lang": "python",
"repo": "yusonghust/gcn",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def train_and_evaluate(self):
###getembs: if true, return the gcn output before training.###
output,loss,accuracy,opt = self.gcn()
###start training and evaluate gcn model###
config = tf.ConfigProto()
config.gpu_options.allow_growth = True
sess = tf.Inte... | code_fim | hard | {
"lang": "python",
"repo": "yusonghust/gcn",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yusonghust/gcn path: /main.py
# -*- coding: utf-8 -*-
import tensorflow as tf
import random
import numpy as np
import time
from utils import *
from graph import Graph
import scipy.sparse as sp
from layers import GraphConvLayer
from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
imp... | code_fim | hard | {
"lang": "python",
"repo": "yusonghust/gcn",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from django_otp.admin import OTPAdminSite
admin.site.__class__ = OTPAdminSite
urlpatterns = [
path('admin/', admin.site.urls),
path('', Index.as_view(), name='index'),
path('login/', Login.as_view(), name='login'),
path('register/', Register.as_view(), name='register'),
path('apps/... | code_fim | hard | {
"lang": "python",
"repo": "hubaimaster/aws-interface",
"path": "/aws_interface/urls.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hubaimaster/aws-interface path: /aws_interface/urls.py
"""aws_interface URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import v... | code_fim | hard | {
"lang": "python",
"repo": "hubaimaster/aws-interface",
"path": "/aws_interface/urls.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """base class for data models
Usage::
from april import Struct
class User(Struct):
_fields = ['name', 'title']
user = UserModel(name='xxx')
assert user.name == 'xxx'
user2 = UserModel(user)
assert user2.name = 'xxx'
"""
def ... | code_fim | medium | {
"lang": "python",
"repo": "cosven/april",
"path": "/april.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cosven/april path: /april.py
# -*- coding: utf-8 -*-
from six import with_metaclass
class StructMeta(type):
def __new__(cls, name, bases, attrs):
_fields = list()
# get inherited fileds
for base in bases:
inherited_fields = getattr(base, '_fields', [])... | code_fim | hard | {
"lang": "python",
"repo": "cosven/april",
"path": "/april.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for field in self._fields:
setattr(self, field, getattr(obj, field, None))
for k, v in kwargs.items():
if k in self._fields:
setattr(self, k, v)<|fim_prefix|># repo: cosven/april path: /april.py
# -*- coding: utf-8 -*-
from six import with_metacla... | code_fim | hard | {
"lang": "python",
"repo": "cosven/april",
"path": "/april.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RayKr/AISafety path: /EvalBox/Attack/AdvAttack/ead.py
#!/usr/bin/env python
# coding=UTF-8
"""
@Author: Tao Hang
@LastEditors: Tao Hang
@Description:
@Date: 2019-03-29 10:53:46
@LastEditTime: 2019-04-15 09:25:55
"""
import numpy as np
import torch
from torch.autograd import Variable
from EvalBo... | code_fim | hard | {
"lang": "python",
"repo": "RayKr/AISafety",
"path": "/EvalBox/Attack/AdvAttack/ead.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Update best results
for i, (dist, score, img) in enumerate(
zip(
decision_loss.data.cpu().numpy(),
output.data.cpu().numpy(),
new_image.data.cpu().numpy(),
)
... | code_fim | hard | {
"lang": "python",
"repo": "RayKr/AISafety",
"path": "/EvalBox/Attack/AdvAttack/ead.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmkite/photoblocks path: /consensus.py
# consensus.py
# Implements longest-chain consensus algorithm
import requests
<|fim_suffix|>
longest_chain = None
n = len(blockchain.chain)
for node in blockchain.nodes:
response = requests.get('http://{}/chain'.format(node))
l... | code_fim | medium | {
"lang": "python",
"repo": "dmkite/photoblocks",
"path": "/consensus.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
longest_chain = None
n = len(blockchain.chain)
for node in blockchain.nodes:
response = requests.get('http://{}/chain'.format(node))
length = response.json()['length']
chain = response.json()['chain']
if length > n and blockchain.is_valid_chain(chain):
... | code_fim | medium | {
"lang": "python",
"repo": "dmkite/photoblocks",
"path": "/consensus.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in songs:
title, artist, year = i
print(title)
print(artist)
print(year)
print("=" * 20)<|fim_prefix|># repo: BrandonP321/Python-masterclass path: /ListsRangesTuples/tuples.py
# t = "a", "b", "c"
# print(t)
#
# print('a', 'b', 'c')
# print(("a", "b", "c"))
welcome = "W... | code_fim | easy | {
"lang": "python",
"repo": "BrandonP321/Python-masterclass",
"path": "/ListsRangesTuples/tuples.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BrandonP321/Python-masterclass path: /ListsRangesTuples/tuples.py
# t = "a", "b", "c"
# print(t)
#
# print('a', 'b', 'c')
# print(("a", "b", "c"))
welcome = "Welcoma to my Nightmare", "Alice Cooper", 1975
bad = "Bad Company", "Bad Company", 1974
budgie = "Nightflight", "Budgie", 1981
imel... | code_fim | easy | {
"lang": "python",
"repo": "BrandonP321/Python-masterclass",
"path": "/ListsRangesTuples/tuples.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Image writers can be used in a with context.
"""
_include_in_factory = True
@abstractmethod
def __enter__(self):
"""Initialize the image writer."""
raise NotImplementedError
@abstractmethod
def __exit__(self, _exc_type, _exc_val, _exc_tb):
"""Close th... | code_fim | medium | {
"lang": "python",
"repo": "datature/discolight",
"path": "/src/discolight/writers/image/types.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: datature/discolight path: /src/discolight/writers/image/types.py
"""Base types for image writers."""
from abc import ABC, abstractmethod
class ImageWriter(ABC):
<|fim_suffix|> """Write an image with the given name."""
raise NotImplementedError<|fim_middle|> """A class that sa... | code_fim | hard | {
"lang": "python",
"repo": "datature/discolight",
"path": "/src/discolight/writers/image/types.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Return a Params object describing constructor parameters."""
raise NotImplementedError
@abstractmethod
def write_image(self, image_name, image):
"""Write an image with the given name."""
raise NotImplementedError<|fim_prefix|># repo: datature/discolight path: /... | code_fim | hard | {
"lang": "python",
"repo": "datature/discolight",
"path": "/src/discolight/writers/image/types.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brainglobe/brainreg path: /src/brainreg/utils/preprocess.py
import numpy as np
from brainglobe_utils.image.scale import scale_and_convert_to_16_bits
from scipy.ndimage import gaussian_filter
from skimage import morphology
from tqdm import trange
def filter_image(brain, preprocessing_args=None):... | code_fim | hard | {
"lang": "python",
"repo": "brainglobe/brainreg",
"path": "/src/brainreg/utils/preprocess.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def pseudo_flatfield(img_plane, sigma=5):
"""
Pseudo flat field filter implementation using a de-trending by a
heavily gaussian filtered copy of the image.
:param np.array img_plane: The image to filter
:param int sigma: The sigma of the gaussian filter applied to the
image us... | code_fim | hard | {
"lang": "python",
"repo": "brainglobe/brainreg",
"path": "/src/brainreg/utils/preprocess.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zerolfx/aiplay-api path: /account/models.py
from django.contrib.auth.models import AbstractUser
from django.db import models
import random
def _random_avatar():
return "/static/avatar/avatar-" + str(random.randint(1, 2)) + ".jpg"
<|fim_suffix|> avatar = models.CharField(max_length=50, ... | code_fim | medium | {
"lang": "python",
"repo": "zerolfx/aiplay-api",
"path": "/account/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> avatar = models.CharField(max_length=50, default=_random_avatar)
about = models.CharField(max_length=100, blank=True, null=True)
birth_date = models.DateField('Birth Date', blank=True, null=True)
country = models.CharField('Country', max_length=30, blank=True)
city = models.CharField('... | code_fim | medium | {
"lang": "python",
"repo": "zerolfx/aiplay-api",
"path": "/account/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DanielZim/PyOpteryx path: /pyopteryx/factories/loop_action_factories/start_action_factory.py
from pyopteryx.factories.loop_action_factories.abstract_loop_action_factory import AbstractLoopActionFactory
from pyopteryx.utils.builder_utils import add_activity_to_task
class StartLoopActionFactory(A... | code_fim | hard | {
"lang": "python",
"repo": "DanielZim/PyOpteryx",
"path": "/pyopteryx/factories/loop_action_factories/start_action_factory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def add_action(self):
entry_name = self.processor.find(".//entry").get("name")
add_activity_to_task(task_activities=self.task_activities,
activity_name=self.activity_name,
bound_to_entry=entry_name,
... | code_fim | hard | {
"lang": "python",
"repo": "DanielZim/PyOpteryx",
"path": "/pyopteryx/factories/loop_action_factories/start_action_factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class FacetedSearchView(views.FacetedSearchView):
"""View to show search results"""
template = "forum_search/search.html"
def build_form(self, form_kwargs=None):
form = super().build_form(
form_kwargs={
"user": self.request.user,
"lti_conte... | code_fim | medium | {
"lang": "python",
"repo": "openfun/ashley",
"path": "/src/ashley/machina_extensions/forum_search/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openfun/ashley path: /src/ashley/machina_extensions/forum_search/views.py
"""
Forum search views
==================
This module defines views provided by the ``forum_search`` application.
"""
from haystack import views
<|fim_suffix|> template = "forum_search/search.html"
de... | code_fim | medium | {
"lang": "python",
"repo": "openfun/ashley",
"path": "/src/ashley/machina_extensions/forum_search/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> infer_time_list = profile_model(model_path, test_data, ctx)
avg_infer_time = np.average(infer_time_list)
p50_infer_time = np.percentile(infer_time_list, 50)
p90_infer_time = np.percentile(infer_time_list, 90)
p99_infer_time = np.percentile(infer_... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/deeplearning-benchmark",
"path": "/onnx_benchmark/import_benchmarkscript.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: awslabs/deeplearning-benchmark path: /onnx_benchmark/import_benchmarkscript.py
import os
import subprocess
import glob
import time
import numpy as np
def get_model_input(model_dir):
import onnx
from onnx import numpy_helper
model_inputs = []
for test_data_npz in glob.glob(
... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/deeplearning-benchmark",
"path": "/onnx_benchmark/import_benchmarkscript.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ctx = str(argv[1])
for directory in os.listdir("./models"):
model_dir = os.path.join("./models", directory)
if os.path.isdir(model_dir):
model_path = os.path.join(model_dir, "model.onnx")
test_data = get_model_input(model_dir)
infer_time_list = ... | code_fim | hard | {
"lang": "python",
"repo": "awslabs/deeplearning-benchmark",
"path": "/onnx_benchmark/import_benchmarkscript.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dibondar/PyPhotonicReagents path: /libs/dev/spectrometer_ocean_optics.py
########################################################################
#
# This module contains classes for controlling and GUI representation of
# OceanOptics spectrometer
#
##############################################... | code_fim | hard | {
"lang": "python",
"repo": "dibondar/PyPhotonicReagents",
"path": "/libs/dev/spectrometer_ocean_optics.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> sizer.Add (wx.StaticText(self, label="End wavelength (nm)"), flag=wx.LEFT, border=5)
end_wavelength_ctr = wx.SpinCtrl (self, value="1118", min=1, max=1e6)
#end_wavelength_ctr = wx.SpinCtrl (self, value="680", min=1, max=1e6)
end_wavelength_ctr.SetLabel("end_wavelength")
sizer.Add (end_wavelength... | code_fim | hard | {
"lang": "python",
"repo": "dibondar/PyPhotonicReagents",
"path": "/libs/dev/spectrometer_ocean_optics.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_check_if_get_outcomes_succeeds_client_success_returns_true_and_response():
# Arrange
get_outcomes_response = {"outcomes": [unit_test_utils.FAKE_OUTCOME]}
mock_afd_client = unit_test_utils.create_mock_afd_client()
mock_afd_client.get_outcomes = MagicMock(return_value=get_outcomes_... | code_fim | hard | {
"lang": "python",
"repo": "priyap286/aws-cloudformation-resource-providers-frauddetector",
"path": "/common/tests/helpers/test_validation_helpers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: priyap286/aws-cloudformation-resource-providers-frauddetector path: /common/tests/helpers/test_validation_helpers.py
from ...helpers import validation_helpers
from botocore.exceptions import ClientError
from unittest.mock import MagicMock
from .. import unit_test_utils
def test_check_if_get_out... | code_fim | hard | {
"lang": "python",
"repo": "priyap286/aws-cloudformation-resource-providers-frauddetector",
"path": "/common/tests/helpers/test_validation_helpers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class DockerRunner(RunnerBase):
"""
DockerRunner is responsible for running tasks within a Docker Container.
It is similar to the SerialRunner, in that it also runs tasks serially, and quits if a task fails.
"""
def __init__(self, image, remove=True, url=':4000', env=None, docker=None... | code_fim | hard | {
"lang": "python",
"repo": "ghostsquad/swarmci",
"path": "/swarmci/runners.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ghostsquad/swarmci path: /swarmci/runners.py
from docker import Client as DockerClient
import concurrent.futures
from swarmci.util import get_logger
from swarmci.docker import Container
from swarmci.errors import TaskFailedError
logger = get_logger(__name__)
class RunnerBase(object):
def _... | code_fim | hard | {
"lang": "python",
"repo": "ghostsquad/swarmci",
"path": "/swarmci/runners.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif fieldtype == "C":
func = lambda v: v #encoding are handled later
else:
raise Exception("Unexpected bug: Detected field should be always N or C")
fieldtypes.append( (fieldtype,func,fieldlen,decimals) )
return fieldtypes
... | code_fim | hard | {
"lang": "python",
"repo": "karimbahgat/PythonGis",
"path": "/pythongis/vector/saver.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: karimbahgat/PythonGis path: /pythongis/vector/saver.py
# import builtins
import itertools
import math
# import fileformats
import shapefile as pyshp
import pygeoj
# PY3 fix
try:
str = unicode # in py2, make str synonymous with str
zip = itertools.izip
except:
pass
NaN = float("... | code_fim | hard | {
"lang": "python",
"repo": "karimbahgat/PythonGis",
"path": "/pythongis/vector/saver.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.