text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>
@pytest.mark.parametrize("is_controller,expected_routes", [
(False, {
'awx.main.tasks.cluster_node_heartbeat': {'queue': 'east-1', 'routing_key': 'east-1'},
'awx.main.tasks.purge_old_stdout_files': {'queue': 'east-1', 'routing_key': 'east-1'}
}),
(True... | code_fim | hard | {
"lang": "python",
"repo": "mirskiy/awx",
"path": "/awx/main/tests/unit/utils/test_ha.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mirskiy/awx path: /awx/main/tests/unit/utils/test_ha.py
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Ansible Tower by Red Hat
# All Rights Reserved.
# python
import pytest
import mock
# AWX
from awx.main.utils.ha import (
_add_remove_celery_worker_queues,
update_celery_worker_routes,
)... | code_fim | hard | {
"lang": "python",
"repo": "mirskiy/awx",
"path": "/awx/main/tests/unit/utils/test_ha.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @pytest.mark.parametrize("is_controller,expected_routes", [
(False, {
'awx.main.tasks.cluster_node_heartbeat': {'queue': 'east-1', 'routing_key': 'east-1'},
'awx.main.tasks.purge_old_stdout_files': {'queue': 'east-1', 'routing_key': 'east-1'}
}),
(True,... | code_fim | hard | {
"lang": "python",
"repo": "mirskiy/awx",
"path": "/awx/main/tests/unit/utils/test_ha.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/pyseqan path: /python/seqan/test/test_build_index.py
#
# Copyright John Reid 2013, 2014
#
"""
Test building an index.
"""
<|fim_suffix|> _num_bases, sequences, _ids = seqan.readFastaDNA5(fasta_file('dm01r.fasta'))
index = seqan.IndexStringDNA5SetESA(sequences)
seqan.trave... | code_fim | hard | {
"lang": "python",
"repo": "pombredanne/pyseqan",
"path": "/python/seqan/test/test_build_index.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_build_index():
_num_bases, sequences, _ids = seqan.readFastaDNA5(fasta_file('dm01r.fasta'))
index = seqan.IndexStringDNA5SetESA(sequences)
seqan.traverse.topdownhistorytraversal(index.topdownhistory(), visitvertex)
seqan.traverse.topdowncopytraversal(index.topdown(), visitvertex)<... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/pyseqan",
"path": "/python/seqan/test/test_build_index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def visitvertex(it):
if len(it.representative) >= 3:
return False
logging.info('%-2s : %5d', it.representative, it.numOccurrences)
return True
def test_build_index():
_num_bases, sequences, _ids = seqan.readFastaDNA5(fasta_file('dm01r.fasta'))
index = seqan.IndexStringDNA5Se... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/pyseqan",
"path": "/python/seqan/test/test_build_index.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Which host to use
host = InteractiveHost()
#host = PBSHost(env='/scratch/prism/memosa/env.sh', cpus_per_node=8, walltime='2:00')
# select a parameter sweep method
# These control the parameters sent to the test program
# Currently the choices include Smolyak, and PSweep
# Fo... | code_fim | medium | {
"lang": "python",
"repo": "FermiQ/puq",
"path": "/examples/montecarlo/mc_normal.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # If we create a TestProgram object, we can add a description
# and the plots will use it.
prog = TestProgram('./mc_prog.py', desc='Monte Carlo - Normal')
# Create a Sweep object
return Sweep(uq, host, prog)<|fim_prefix|># repo: FermiQ/puq path: /examples/montecarlo/mc_normal.py
#!/u... | code_fim | hard | {
"lang": "python",
"repo": "FermiQ/puq",
"path": "/examples/montecarlo/mc_normal.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FermiQ/puq path: /examples/montecarlo/mc_normal.py
#!/usr/bin/env python
"""
Monte Carlo basic example
Usage: mc.py
"""
from puq import *
def run():
# Declare our parameters here
v0 = Parameter('v', 'velocity', mean=1.0, dev=0.1)
<|fim_suffix|> # If we create a TestProgram object, w... | code_fim | hard | {
"lang": "python",
"repo": "FermiQ/puq",
"path": "/examples/montecarlo/mc_normal.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: boussier/django_rest_api path: /users/urls.py
# users/urls.py
from django.urls impo<|fim_suffix|> path('', UserListView.as_view()),
]<|fim_middle|>rt include, path
from .views import (
UserListView
)
urlpatterns = [
| code_fim | medium | {
"lang": "python",
"repo": "boussier/django_rest_api",
"path": "/users/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> UserListView
)
urlpatterns = [
path('', UserListView.as_view()),
]<|fim_prefix|># repo: boussier/django_rest_api path: /users/urls.py
# users/urls.py
from django.urls impo<|fim_middle|>rt include, path
from .views import (
| code_fim | easy | {
"lang": "python",
"repo": "boussier/django_rest_api",
"path": "/users/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> path('', UserListView.as_view()),
]<|fim_prefix|># repo: boussier/django_rest_api path: /users/urls.py
# users/urls.py
from django.urls impo<|fim_middle|>rt include, path
from .views import (
UserListView
)
urlpatterns = [
| code_fim | medium | {
"lang": "python",
"repo": "boussier/django_rest_api",
"path": "/users/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JT501/drf-access-policy path: /test_project/testapp/serializers.py
from rest_framework import serializers
from test_project.testapp.models import UserAccount
<|fim_suffix|> class Meta:
model = UserAccount
fields = ["username", "first_name", "last_name"]<|fim_middle|>
class Use... | code_fim | easy | {
"lang": "python",
"repo": "JT501/drf-access-policy",
"path": "/test_project/testapp/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
model = UserAccount
fields = ["username", "first_name", "last_name"]<|fim_prefix|># repo: JT501/drf-access-policy path: /test_project/testapp/serializers.py
from rest_framework import serializers
from test_project.testapp.models import UserAccount
<|fim_middle|>class Use... | code_fim | easy | {
"lang": "python",
"repo": "JT501/drf-access-policy",
"path": "/test_project/testapp/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = UserAccount
fields = ["username", "first_name", "last_name"]<|fim_prefix|># repo: JT501/drf-access-policy path: /test_project/testapp/serializers.py
from rest_framework import serializers
from test_project.testapp.models import UserAccount
class UserAccountSerializer(serializers... | code_fim | easy | {
"lang": "python",
"repo": "JT501/drf-access-policy",
"path": "/test_project/testapp/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # clean your room
if clean_files:
shutil.rmtree(temp_scr)
return properties
def calculate(molobj, confid=-1, show_progress=True, return_copy=True, **kwargs):
"""
INCOMPLETE
"""
# TODO Get coordinates
atoms, coordinates, charge = chembridge.get_axyzc(molobj, co... | code_fim | hard | {
"lang": "python",
"repo": "rochoa85/ppqm",
"path": "/ppqm/xtb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rochoa85/ppqm path: /ppqm/xtb.py
fid=-1, atomfmt=str)
if show_progress:
pbar = tqdm(total=n_conformers, desc="XTB", **constants.TQDM_OPTIONS)
# For conformers
for conformer in molobj.GetConformers():
coordinates = conformer.GetPositions()
coordinates = np.arr... | code_fim | hard | {
"lang": "python",
"repo": "rochoa85/ppqm",
"path": "/ppqm/xtb.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rochoa85/ppqm path: /ppqm/xtb.py
l termination of xtb"
idx = linesio.get_rev_index(lines, error_pattern, stoppattern="#")
if idx is not None:
_logger.critical(error_pattern)
idx = linesio.get_rev_index(lines, "ERROR")
if idx is None:
_logger.critical... | code_fim | hard | {
"lang": "python",
"repo": "rochoa85/ppqm",
"path": "/ppqm/xtb.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: seek-oss/aec path: /src/aec/util/ec2.py
from __future__ import annotations
from typing import Sequence
import boto3
import aec.util.tags as util_tags
from aec.util.config import Config
from aec.util.ec2_types import DescribeArgs
def describe_running_instances_names(config: Config) -> dict[st... | code_fim | hard | {
"lang": "python",
"repo": "seek-oss/aec",
"path": "/src/aec/util/ec2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> next_token = response.get("NextToken", None)
if next_token:
kwargs["NextToken"] = next_token
else:
break
return instances<|fim_prefix|># repo: seek-oss/aec path: /src/aec/util/ec2.py
from __future__ import annotations
from typing import Sequence
impo... | code_fim | hard | {
"lang": "python",
"repo": "seek-oss/aec",
"path": "/src/aec/util/ec2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = self.raw_result.split('_')
num_rows = int(data[0])
num_cols = int(data[1])
raw_mat = data[2]
raw_mat = raw_mat.replace(';', ',')
raw_mat = raw_mat.replace('\n', '')
raw_mat = raw_mat.replace('[', '')
raw_mat = raw_mat.replace(']', '')... | code_fim | hard | {
"lang": "python",
"repo": "roncho12/frontapp",
"path": "/frontalization_API/Frontalizer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser.add_argument('-preproc', action='store_true', dest='preprocess', default=False,
help='If this argument is used, the images will be\n' +
'preprocessed: the face will be detected and\n' +
'the image ... | code_fim | hard | {
"lang": "python",
"repo": "roncho12/frontapp",
"path": "/frontalization_API/Frontalizer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: roncho12/frontapp path: /frontalization_API/Frontalizer.py
from ctypes import *
import numpy as np
import os
import glob
import platform
from FaceCrop import FaceCrop
from commonFun import check_version
class Frontalizer(object):
def __init__(self, cascade_path=None, dlib_path=None, ignore... | code_fim | hard | {
"lang": "python",
"repo": "roncho12/frontapp",
"path": "/frontalization_API/Frontalizer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allenbross-wf/Arelle-1 path: /testParser2.py
'''
Use this module to start Arelle in windowing interactive UI mode
<|fim_suffix|>from arelle.XPathParser import main
main()<|fim_middle|>See COPYRIGHT.md for copyright information.
'''
| code_fim | easy | {
"lang": "python",
"repo": "allenbross-wf/Arelle-1",
"path": "/testParser2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from arelle.XPathParser import main
main()<|fim_prefix|># repo: allenbross-wf/Arelle-1 path: /testParser2.py
'''
Use this module to start Arelle in windowing interactive UI mode
<|fim_middle|>See COPYRIGHT.md for copyright information.
'''
| code_fim | easy | {
"lang": "python",
"repo": "allenbross-wf/Arelle-1",
"path": "/testParser2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: myxxxsquared/project-1 path: /test.py
import cv2
import postprocessing
import numpy as np
p = postprocessing.Postprocessor()
maps = np.load('maps.npy')
print(maps.shape)
ctns = p.process(maps)
<|fim_suffix|>x = np.zeros(shape=(maps.shape[0], maps.shape[1]), dtype=np.uint8)
cv2.drawContours(x, ct... | code_fim | medium | {
"lang": "python",
"repo": "myxxxsquared/project-1",
"path": "/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>x = np.zeros(shape=(maps.shape[0], maps.shape[1]), dtype=np.uint8)
cv2.drawContours(x, ctns, -1, (255, 255, 255))
cv2.imwrite('o2.png', x)<|fim_prefix|># repo: myxxxsquared/project-1 path: /test.py
import cv2
import postprocessing
import numpy as np
p = postprocessing.Postprocessor()
maps = np.load('map... | code_fim | medium | {
"lang": "python",
"repo": "myxxxsquared/project-1",
"path": "/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('zhutie',
sa.Column('zhutieid', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('zhutietitle', sa.String(length=200), nullable=False),
sa.Column('zhutievalue', sa.String(length=50... | code_fim | medium | {
"lang": "python",
"repo": "nix18/FlaskForum",
"path": "/migrations/versions/29033ccaea2f_.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nix18/FlaskForum path: /migrations/versions/29033ccaea2f_.py
"""empty message
Revision ID: 29033ccaea2f
Revises: 34b6e3c4c3e2
Create Date: 2019-12-01 13:18:19.957425
"""
from alembic import op
import sqlalchemy as sa
<|fim_suffix|>
def upgrade():
# ### commands auto generated by Alembic -... | code_fim | medium | {
"lang": "python",
"repo": "nix18/FlaskForum",
"path": "/migrations/versions/29033ccaea2f_.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Exabyte-io/express path: /tests/unit/properties/non_scalar/two_dimensional_plot/test_dos.py
from tests.unit import UnitTestBase
from tests.fixtures.data import DOS_RAW_DATA
from express.properties.non_scalar.two_dimensional_plot.density_of_states import DensityOfStates
DOS = {
"legend": [
... | code_fim | medium | {
"lang": "python",
"repo": "Exabyte-io/express",
"path": "/tests/unit/properties/non_scalar/two_dimensional_plot/test_dos.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_dos(self):
parser = self.get_mocked_parser("dos", DOS_RAW_DATA)
property_ = DensityOfStates("density_of_states", parser)
self.assertDeepAlmostEqual(property_.serialize_and_validate(), DOS)<|fim_prefix|># repo: Exabyte-io/express path: /tests/unit/properties/non_scalar... | code_fim | hard | {
"lang": "python",
"repo": "Exabyte-io/express",
"path": "/tests/unit/properties/non_scalar/two_dimensional_plot/test_dos.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>frase = 'Curso em video Python'
print(len(frase))<|fim_prefix|># repo: FelipeSilveiraL/EstudoPython path: /meuCursoEmVideo/mundo1/aula09A.py
frase = 'Curso em video Python'
print(frase.count('o'))
print('oi')
<|fim_middle|>print("""Nessa aula, vamos aprender operações com String no Python.
As principa... | code_fim | hard | {
"lang": "python",
"repo": "FelipeSilveiraL/EstudoPython",
"path": "/meuCursoEmVideo/mundo1/aula09A.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>frase = 'Curso em video Python'
print(frase.upper().count('O'))
frase = 'Curso em video Python'
print(len(frase))<|fim_prefix|># repo: FelipeSilveiraL/EstudoPython path: /meuCursoEmVideo/mundo1/aula09A.py
frase = 'Curso em video Python'
print(frase.count('o'))
<|fim_middle|>print('oi')
print("""Nessa ... | code_fim | hard | {
"lang": "python",
"repo": "FelipeSilveiraL/EstudoPython",
"path": "/meuCursoEmVideo/mundo1/aula09A.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FelipeSilveiraL/EstudoPython path: /meuCursoEmVideo/mundo1/aula09A.py
frase = 'Curso em video Python'
print(frase.count('o'))
print('oi')
<|fim_suffix|>frase = 'Curso em video Python'
print(frase.upper().count('O'))
frase = 'Curso em video Python'
print(len(frase))<|fim_middle|>print("""Nessa ... | code_fim | hard | {
"lang": "python",
"repo": "FelipeSilveiraL/EstudoPython",
"path": "/meuCursoEmVideo/mundo1/aula09A.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tyleragreen/python-interfaces path: /tests/test_multiple_inheritance.py
from interface import interface
class Iterable:
def do_loop(self):
pass
class VehicleList:
def another_method(self):
return 'vehicles are cool'
class PublicTransportVehicle:
def __init__(self... | code_fim | hard | {
"lang": "python",
"repo": "tyleragreen/python-interfaces",
"path": "/tests/test_multiple_inheritance.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_isinstance_respects_inheritance():
bl = BusList()
assert isinstance(bl, BusList)
assert isinstance(bl, VehicleList)
assert isinstance(bl, PublicTransportVehicle)
assert not isinstance(bl, Iterable)<|fim_prefix|># repo: tyleragreen/python-interfaces path: /tests/test_multiple... | code_fim | hard | {
"lang": "python",
"repo": "tyleragreen/python-interfaces",
"path": "/tests/test_multiple_inheritance.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: frankhood/django-moderation-model-mixin path: /tests/test_app/tests/test_managers.py
from django.test import TestCase
from moderation_model_mixin import settings
from moderation_model_mixin.managers import AcceptedModerableEntryManager
from moderation_model_mixin.querysets import ModerableQueryS... | code_fim | hard | {
"lang": "python",
"repo": "frankhood/django-moderation-model-mixin",
"path": "/tests/test_app/tests/test_managers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertNotIn(example2, ExampleModel.not_rejected_objects.all())
self.assertNotIn(example2, ExampleModel.accepted_objects.all())
self.assertNotIn(example2, ExampleModel.published_objects.all())
self.assertNotIn(example2, ExampleModel.not_moderated_objects.all())<|fim_pre... | code_fim | hard | {
"lang": "python",
"repo": "frankhood/django-moderation-model-mixin",
"path": "/tests/test_app/tests/test_managers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> all_data = hadut.collect_output(output_dir)
return pts.parse_mr_output(all_data, vtype=int)
def check(measured_res, expected_res):
res = pts.compare_counts(measured_res, expected_res)
if res:
return "ERROR: %s" % res
else:
return "OK."
def main(argv):
logger = l... | code_fim | medium | {
"lang": "python",
"repo": "crs4/pydoop",
"path": "/examples/input_format/check_results.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_res(output_dir):
all_data = hadut.collect_output(output_dir)
return pts.parse_mr_output(all_data, vtype=int)
def check(measured_res, expected_res):
res = pts.compare_counts(measured_res, expected_res)
if res:
return "ERROR: %s" % res
else:
return "OK."
def m... | code_fim | medium | {
"lang": "python",
"repo": "crs4/pydoop",
"path": "/examples/input_format/check_results.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crs4/pydoop path: /examples/input_format/check_results.py
# BEGIN_COPYRIGHT
#
# Copyright 2009-2022 CRS4.
#
# 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://w... | code_fim | medium | {
"lang": "python",
"repo": "crs4/pydoop",
"path": "/examples/input_format/check_results.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> url(r'^page(\d*)/$',views.pageinfo),
url(r'pagecanshu/$',views.pagecanshu)
]<|fim_prefix|># repo: LuyilunGitHub/test001 path: /Bookmange3/Book/urls.py
from django.conf.urls import url
from Book import views
urlpatterns = [
<|fim_middle|> url(r'^boolist/$',views.booklist),
#静态页面显示图片
... | code_fim | hard | {
"lang": "python",
"repo": "LuyilunGitHub/test001",
"path": "/Bookmange3/Book/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LuyilunGitHub/test001 path: /Bookmange3/Book/urls.py
from django.conf.urls import url
from Book import views
urlpatterns = [
url(r'^boolist/$',views.booklist),
<|fim_suffix|> #上传图片
url(r'^upImg/$',views.upImg),
url(r'^shangchuanImg/$',views.shangchuanImg),
url(r'^upload_ava... | code_fim | easy | {
"lang": "python",
"repo": "LuyilunGitHub/test001",
"path": "/Bookmange3/Book/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryneches/ulakes path: /matt_writes_a_code.py
import numpy
import vcf
import distance
import csv
block_size = 10000
size_cut = 2e7
vcf_reader = vcf.Reader(open('SNPs_only.kivu.vcf.gz', 'rb'))
<|fim_suffix|>
#plot(sorted(contig_lengths.values()))
#axhline(size_cut,color='black')
#semilogy()
b... | code_fim | medium | {
"lang": "python",
"repo": "ryneches/ulakes",
"path": "/matt_writes_a_code.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#plot(sorted(contig_lengths.values()))
#axhline(size_cut,color='black')
#semilogy()
bigcontigs = []
mysamples_df = {}
mysamples_dxy = {}
for name in vcf_reader.samples :
mycontigs = {}
for contig in vcf_reader.contigs :
if contig_lengths[contig] > size_cut :
if not bigconti... | code_fim | medium | {
"lang": "python",
"repo": "ryneches/ulakes",
"path": "/matt_writes_a_code.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matteorr/rel_3d_pose path: /gui/scripts/prepareDepthGUIHuman36Data.py
'''
Written for the cocoa_depth Amazon Mechanical Turk GUI.
Intended to extract the needed keypoint annotations from the Human3.6
dataset.
'''
#######################################################################
# GENERAL ... | code_fim | hard | {
"lang": "python",
"repo": "matteorr/rel_3d_pose",
"path": "/gui/scripts/prepareDepthGUIHuman36Data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if VERBOSE:
print "HITId: [%d] -> human subjects: [%s]" % (
amt_hit_id, str(_amt_hit_people_list))
else:
if amt_hit_id == 1 or amt_hit_id == (NUMBER_HIT_ASSIGNMENTS *
(l / NUMBER_SUBJECTS_IN_HIT)):
... | code_fim | hard | {
"lang": "python",
"repo": "matteorr/rel_3d_pose",
"path": "/gui/scripts/prepareDepthGUIHuman36Data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>amt_hit_id = 0
for ii in range(0, NUMBER_HIT_ASSIGNMENTS):
random.shuffle(DATASET_SUBJ_ID_LIST)
for jj in range(0, l, NUMBER_SUBJECTS_IN_HIT):
amt_hit_id = amt_hit_id + 1
_amt_hit_people_list = DATASET_SUBJ_ID_LIST[jj:jj +
NUMBER... | code_fim | hard | {
"lang": "python",
"repo": "matteorr/rel_3d_pose",
"path": "/gui/scripts/prepareDepthGUIHuman36Data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> bot.remove_cog('ChannelNotifier')<|fim_prefix|># repo: MaeBee/discord-bot path: /extensions/channel_notifier/__init__.py
from .channel_notifier import ChannelNotifier
def setup(bot):
<|fim_middle|> cog = ChannelNotifier(bot)
bot.add_cog(cog)
def teardown(bot):
| code_fim | medium | {
"lang": "python",
"repo": "MaeBee/discord-bot",
"path": "/extensions/channel_notifier/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MaeBee/discord-bot path: /extensions/channel_notifier/__init__.py
from .channel_notifier import ChannelNotifier
def setup(bot):
<|fim_suffix|>def teardown(bot):
bot.remove_cog('ChannelNotifier')<|fim_middle|> cog = ChannelNotifier(bot)
bot.add_cog(cog)
| code_fim | easy | {
"lang": "python",
"repo": "MaeBee/discord-bot",
"path": "/extensions/channel_notifier/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amadea-system/StalkMarketBot path: /src/cogs/stalkMarket.py
ame__)
day_segment_names = ["Sunday Buy Price", "N/A", "Monday Morning", "Monday Afternoon", "Tuesday Morning",
"Tuesday Afternoon", "Wednesday Morning", "Wednesday Afternoon", "Thursday Morning",
... | code_fim | hard | {
"lang": "python",
"repo": "amadea-system/StalkMarketBot",
"path": "/src/cogs/stalkMarket.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amadea-system/StalkMarketBot path: /src/cogs/stalkMarket.py
oolPage, StringReactPage
if TYPE_CHECKING:
from bot import GGBot
log = logging.getLogger(__name__)
day_segment_names = ["Sunday Buy Price", "N/A", "Monday Morning", "Monday Afternoon", "Tuesday Morning",
"Tue... | code_fim | hard | {
"lang": "python",
"repo": "amadea-system/StalkMarketBot",
"path": "/src/cogs/stalkMarket.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@eCommands.command(name="list", aliases=["list_prices"],
brief="Lists the current weeks recorded prices.",
examples=[""])
async def list_prices(self, ctx: commands.Context, user: Optional[discord.Member] = None):
if user is None:
... | code_fim | hard | {
"lang": "python",
"repo": "amadea-system/StalkMarketBot",
"path": "/src/cogs/stalkMarket.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = ArgumentParser(parents=[parent_parser])
parser.add_argument('-j', '--workers', default=8, type=int, metavar='N',
help='number of data loading workers (default: 4)')
parser.add_argument('-b', '--batch-size', default=512, type=int,
... | code_fim | hard | {
"lang": "python",
"repo": "limberc/HyperNetworks",
"path": "/hypernet/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def run_cli():
parent_parser = ArgumentParser(add_help=False)
# ------------
# args
# ------------
parent_parser = pl.Trainer.add_argparse_args(parent_parser)
parent_parser.add_argument('--data-path', metavar='DIR', type=str, default='./data',
help='p... | code_fim | hard | {
"lang": "python",
"repo": "limberc/HyperNetworks",
"path": "/hypernet/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: limberc/HyperNetworks path: /hypernet/main.py
from argparse import ArgumentParser, Namespace
import pytorch_lightning as pl
import torch
import torch.nn.parallel
import torch.optim as optim
from pytorch_lightning.core import LightningModule
from pytorch_lightning.loggers.neptune import NeptuneLo... | code_fim | hard | {
"lang": "python",
"repo": "limberc/HyperNetworks",
"path": "/hypernet/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rrebase/django_microsoft_auth path: /tests/test_context_processors.py
from unittest.mock import Mock, patch
from django.test import RequestFactory, TestCase, override_settings
from microsoft_auth.conf import LOGIN_TYPE_O365, LOGIN_TYPE_XBL
from microsoft_auth.context_processors import micr... | code_fim | medium | {
"lang": "python",
"repo": "rrebase/django_microsoft_auth",
"path": "/tests/test_context_processors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @override_settings(MICROSOFT_AUTH_LOGIN_TYPE=LOGIN_TYPE_O365)
@patch("microsoft_auth.context_processors.MicrosoftClient")
def test_microsoft_login_type_text_o365(self, mock_client):
request = self.factory.get("/")
context = microsoft(request)
self.assertEqual("... | code_fim | hard | {
"lang": "python",
"repo": "rrebase/django_microsoft_auth",
"path": "/tests/test_context_processors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: weder942/first_step_with_django path: /polls/admin/__init__.py
from django.contrib import admin
from .AdminCh<|fim_suffix|>n
admin.site.register(Question, QuestionAdmin)<|fim_middle|>oice import ChoiceInline
from .AdminQuestion import QuestionAdmin
from ..models import Questio | code_fim | medium | {
"lang": "python",
"repo": "weder942/first_step_with_django",
"path": "/polls/admin/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>port QuestionAdmin
from ..models import Question
admin.site.register(Question, QuestionAdmin)<|fim_prefix|># repo: weder942/first_step_with_django path: /polls/admin/__init__.py
from django.contrib import admin
from .AdminCh<|fim_middle|>oice import ChoiceInline
from .AdminQuestion im | code_fim | easy | {
"lang": "python",
"repo": "weder942/first_step_with_django",
"path": "/polls/admin/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # multi-process grid search for best C
results = []
for c in p.c_grid:
result = process_pool.apply_async(learn.svm_cross_val_ROC, (data, state, p.K, s, t, False, c))
results.append((c,result))
# wait for results
for i, (c, result) in... | code_fim | hard | {
"lang": "python",
"repo": "rronen/SFselect",
"path": "/SFselect_train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # set simulation range
if(first is None): first = p.first_sim
if(last is None): last = p.last_sim
reg = regimes.get_regimes()
for i, regime_dict in enumerate(reg):
train_mix[i,"data"], train_mix[i,"states"] = data_and_states_for_dict(p.case_type, p.cont_type, regime_dic... | code_fim | hard | {
"lang": "python",
"repo": "rronen/SFselect",
"path": "/SFselect_train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rronen/SFselect path: /SFselect_train.py
se_SVC
# learns (s,t)-specific models, but computes their power across all (s,t) pairs.
# The diagonal of the resulting power matrix (each model applied to its respective
# scenario) is what results from specific_SVC().
# Note, In Ronen e... | code_fim | hard | {
"lang": "python",
"repo": "rronen/SFselect",
"path": "/SFselect_train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
方法功能:创建单链表
输入参数:nums: list[int], 按索引顺序,依次为“个位”、“十位”、“百位”……
"""
head = LNode()
cur = head
for num in nums:
tmp = LNode()
tmp.val = num
cur.next = tmp
cur = tmp
return head
def printLinkedList(head):
""" 打印单链表 """
cur = head.next
... | code_fim | hard | {
"lang": "python",
"repo": "YorkFish/git_study",
"path": "/ProgrammerAlgorithmInterview/Chapter01/01_03_plus_two_linked_lists_02.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ 打印单链表 """
cur = head.next
print("head->", end='')
while cur is not None:
print(cur.val, end="->")
cur = cur.next
print("None")
return None
if __name__ == "__main__":
print("linked list 1:", end=' ')
head1 = constructLinkedList([3, 4, 5, 6, 7, 8])
pr... | code_fim | hard | {
"lang": "python",
"repo": "YorkFish/git_study",
"path": "/ProgrammerAlgorithmInterview/Chapter01/01_03_plus_two_linked_lists_02.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YorkFish/git_study path: /ProgrammerAlgorithmInterview/Chapter01/01_03_plus_two_linked_lists_02.py
#!/usr/bin/env python3
#coding:utf-8
class LNode(object):
def __init__(self, x=None):
self.val = x
self.next = None
def plusTwoLinkedLists(h1, h2):
"""
方法功能:对两个带头结点的单链表所... | code_fim | hard | {
"lang": "python",
"repo": "YorkFish/git_study",
"path": "/ProgrammerAlgorithmInterview/Chapter01/01_03_plus_two_linked_lists_02.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elliottsj/botbot-web path: /botbot/apps/plugins/tests.py
# -*- coding: utf-8 -*-
import datetime
from django.utils.timezone import utc
from django.test import TestCase
from . import utils
class UtilsTestCase(TestCase):
def test_nano_timestamp(self):
<|fim_suffix|> def test_short_nano_t... | code_fim | hard | {
"lang": "python",
"repo": "elliottsj/botbot-web",
"path": "/botbot/apps/plugins/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_nano_timestamp(self):
timestamp = '2014-01-27T16:35:53.123456789Z'
py_date = utils.convert_nano_timestamp(timestamp)
self.assertEqual(py_date,
datetime.datetime(2014, 1, 27, 16, 35,
53, 123456, tzinfo... | code_fim | hard | {
"lang": "python",
"repo": "elliottsj/botbot-web",
"path": "/botbot/apps/plugins/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.ready = True
self.mutex = threading.Lock()
self.not_empty = threading.Condition(self.mutex)
self.not_full = threading.Condition(self.mutex)
self.maxsize = 0
stat_logger.info('init queue')
def is_ready(self):
return s... | code_fim | hard | {
"lang": "python",
"repo": "chengtcc/FATE-Cloud",
"path": "/fate-manager/hyperion/operations/job_queue.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chengtcc/FATE-Cloud path: /fate-manager/hyperion/operations/job_queue.py
#
# Copyright 2020 The FATE Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the ... | code_fim | hard | {
"lang": "python",
"repo": "chengtcc/FATE-Cloud",
"path": "/fate-manager/hyperion/operations/job_queue.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> sql = "SELECT RELEASE_LOCK('%s')" % (lock_name)
stat_logger.info('unlock mysql, lockname {}'.format(lock_name))
cursor = db.execute_sql(sql)
ret = cursor.fetchone()
if ret[0] == 0:
raise Exception('mysql lock {} is not released'.format(lock_name))
... | code_fim | hard | {
"lang": "python",
"repo": "chengtcc/FATE-Cloud",
"path": "/fate-manager/hyperion/operations/job_queue.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> instance = WpConnection(db_host=None, db_name='wp_default', credentials=WpCredentials.from_username_and_password(None, 'password'))
self.assertIsInstance(instance, WpConnection)
self.assertIsNone(instance.db_host)
self.assertIsNone(instance.credentials)
if __name__ == '__... | code_fim | medium | {
"lang": "python",
"repo": "ravensorb/py-wordpress-database",
"path": "/tests/classes/test_connection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_database_properties_db_host_none(self):
"""
Assert that from_aws_secrets_manager() returns a class instance.
"""
instance = WpConnection(db_host=None, db_name='wp_default', credentials=WpCredentials.from_username_and_password('root', 'password'))
self... | code_fim | hard | {
"lang": "python",
"repo": "ravensorb/py-wordpress-database",
"path": "/tests/classes/test_connection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ravensorb/py-wordpress-database path: /tests/classes/test_connection.py
""" Tests for the WpConnection class. """
import unittest
from wpdatabase2.classes import WpCredentials
from wpdatabase2.classes import WpConnection
class ConnectionTestCase(unittest.TestCase):
<|fim_suffix|> instan... | code_fim | hard | {
"lang": "python",
"repo": "ravensorb/py-wordpress-database",
"path": "/tests/classes/test_connection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> config_references = [expand_path(config_ref) for config_ref in get_all_elems_from_json(config, 'config_path')]
requirements |= {req for config in config_references for req in get_config_requirements(config)}
return requirements
def install_from_config(config: [str, Path, dict]):
require... | code_fim | hard | {
"lang": "python",
"repo": "vintagexav/DeepPavlov",
"path": "/deeppavlov/utils/pip_wrapper/pip_wrapper.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vintagexav/DeepPavlov path: /deeppavlov/utils/pip_wrapper/pip_wrapper.py
# Copyright 2017 Neural Networks and Deep Learning lab, MIPT
#
# 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 t... | code_fim | hard | {
"lang": "python",
"repo": "vintagexav/DeepPavlov",
"path": "/deeppavlov/utils/pip_wrapper/pip_wrapper.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if any(_tf_re.match(package) for package in packages) \
and b'tensorflow-gpu' in subprocess.check_output([sys.executable, '-m', 'pip', 'freeze'],
env=os.environ.copy()):
log.warning('found tensorflow-gpu installed, so upg... | code_fim | hard | {
"lang": "python",
"repo": "vintagexav/DeepPavlov",
"path": "/deeppavlov/utils/pip_wrapper/pip_wrapper.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> total_points = 0
for k1 in self.question_points.keys():
print("Question %s: %d points" % (k1, self.question_points[k1]))
total_points += self.question_points[k1]
for k2 in [k for k in self.subquestion_points.keys() if k[0] == k1]:
print("... | code_fim | hard | {
"lang": "python",
"repo": "gsteele13/notebook-grading-rubric",
"path": "/parse_grading.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gsteele13/notebook-grading-rubric path: /parse_grading.py
# +
import nbformat
import re
class assignment_rubric:
def __init__(self, file):
self.rubric_items = []
self.question_points = {}
self.subquestion_points = {}
self.get_rubric_items(file)
self.ge... | code_fim | hard | {
"lang": "python",
"repo": "gsteele13/notebook-grading-rubric",
"path": "/parse_grading.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize("request_method, parm", [
("POST", "mycroft.views.jobs.post_job"),
("GET", "mycroft.views.jobs.list_all_jobs")])
def test_jobs(request_method, parm):
dr = dummy_request()
dr.method = request_method
expected_return_code = 200
with patch('mycroft.models.aws_c... | code_fim | hard | {
"lang": "python",
"repo": "Yelp/mycroft",
"path": "/mycroft/tests/views/test_jobs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Yelp/mycroft path: /mycroft/tests/views/test_jobs.py
# -*- coding: utf-8 -*-
from mock import patch
import pytest
from mycroft.models.abstract_records import PrimaryKeyError
from mycroft.views.jobs import jobs
from mycroft.views.jobs import jobs_filtered
from mycroft.views.jobs import jobs_updat... | code_fim | hard | {
"lang": "python",
"repo": "Yelp/mycroft",
"path": "/mycroft/tests/views/test_jobs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dr = dummy_request()
dr.matchdict["log_name"] = "dummy_log_name"
dr.matchdict["log_schema_version"] = log_version
expected_return_code = 200
with patch('mycroft.models.aws_connections.TableConnection.get_connection'):
with patch(parm) as list_action:
list_action.ret... | code_fim | hard | {
"lang": "python",
"repo": "Yelp/mycroft",
"path": "/mycroft/tests/views/test_jobs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xtblock/chromium path: /weblayer/shell/android/shell_apk/DEPS
noparent = True
include_rules = [
"+weblayer/public/java",
# We want to depend on as little of //base <|fim_suffix|> # different from the implementation. Only simple utility classes are allowed.
"+base/android/java/src/org/chro... | code_fim | medium | {
"lang": "python",
"repo": "xtblock/chromium",
"path": "/weblayer/shell/android/shell_apk/DEPS",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>g/chromium/base/IntentUtils.java",
"+base/android/java/src/org/chromium/base/compat/ApiHelperForR.java",
]<|fim_prefix|># repo: xtblock/chromium path: /weblayer/shell/android/shell_apk/DEPS
noparent = True
include_rules = [
"+weblayer/public/java",
# We want to depend on as little of //base <|fim_... | code_fim | hard | {
"lang": "python",
"repo": "xtblock/chromium",
"path": "/weblayer/shell/android/shell_apk/DEPS",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YanXuVanderbilt/ugscnn path: /meshcnn/mesh_utils.py
import numpy as np
import pyigl as igl
import scipy.sparse as sparse
def unique_rows(data, digits=None):
"""
Returns indices of unique rows. It will return the
first occurrence of a row that is duplicated:
[[1,2], [3,4], [1,2]]... | code_fim | hard | {
"lang": "python",
"repo": "YanXuVanderbilt/ugscnn",
"path": "/meshcnn/mesh_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(m, igl.eigen.MatrixXd):
return np.array(m, dtype='float64', order='C')
elif isinstance(m, igl.eigen.MatrixXi):
return np.array(m, dtype='int32', order='C')
elif isinstance(m, igl.eigen.MatrixXb):
return np.array(m, dtype='bool', order='C')
elif isinsta... | code_fim | hard | {
"lang": "python",
"repo": "YanXuVanderbilt/ugscnn",
"path": "/meshcnn/mesh_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zachsis/strelka path: /server/scanners/scan_json.py
import json
from server import objects
class ScanJson(objects.StrelkaScanner):
"""Collects keys from JSON files."""
def scan(self, file_object, options):
self.metadata.setdefault("keys", [])
try:
self._get... | code_fim | hard | {
"lang": "python",
"repo": "zachsis/strelka",
"path": "/server/scanners/scan_json.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
variable: Variable to recursively parse.
"""
if isinstance(variable, dict):
for (key, value) in variable.items():
if key not in self.metadata["keys"]:
self.metadata["keys"].append(key)
self._get_keys(... | code_fim | hard | {
"lang": "python",
"repo": "zachsis/strelka",
"path": "/server/scanners/scan_json.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def _get_keys(self, variable):
"""Recursively parses JSON.
Args:
variable: Variable to recursively parse.
"""
if isinstance(variable, dict):
for (key, value) in variable.items():
if key not in self.metadata["key... | code_fim | hard | {
"lang": "python",
"repo": "zachsis/strelka",
"path": "/server/scanners/scan_json.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: K3D-tools/K3D-jupyter path: /k3d/test/test_colormap.py
import numpy as np
import unittest
from ..colormaps.basic_color_maps import Rainbow, Binary
from ..helpers import map_colors
class TestPythonColorMapping(unittest.TestCase):
# Rainbow: for 0 - blue, for 1 - red
def test_zeros(self... | code_fim | hard | {
"lang": "python",
"repo": "K3D-tools/K3D-jupyter",
"path": "/k3d/test/test_colormap.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # given
attribute = np.zeros(5)
# when
colors = map_colors(attribute, Rainbow)
# then
self.assertTrue((colors == np.ones(5, dtype=np.int32) * 0xff).all())
def test_ones(self):
# given
attribute = np.ones(5)
# when
# color... | code_fim | medium | {
"lang": "python",
"repo": "K3D-tools/K3D-jupyter",
"path": "/k3d/test/test_colormap.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ARMmbed/yotta_osx_installer path: /workspace/lib/python2.7/site-packages/pyOCD/board/board.py
"""
mbed CMSIS-DAP debugger
Copyright (c) 2006-2013 ARM Limited
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You ... | code_fim | hard | {
"lang": "python",
"repo": "ARMmbed/yotta_osx_installer",
"path": "/workspace/lib/python2.7/site-packages/pyOCD/board/board.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(interface, str) == False:
self.interface = interface
else:
self.interface = INTERFACE[interface].chooseInterface(INTERFACE[interface])
self.transport = TRANSPORT[transport](self.interface)
self.target = TARGET[target](self.transport)
... | code_fim | hard | {
"lang": "python",
"repo": "ARMmbed/yotta_osx_installer",
"path": "/workspace/lib/python2.7/site-packages/pyOCD/board/board.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyro-team/bkt-toolbox path: /bkt/dotnet.py
# -*- coding: utf-8 -*-
'''
Load System or Office specific .Net functions
Created on 23.11.2014
@author: cschmitt
'''
from __future__ import absolute_import, print_function
import clr
from functools import wraps
cache = {}
def memoize(func):
@wr... | code_fim | hard | {
"lang": "python",
"repo": "pyro-team/bkt-toolbox",
"path": "/bkt/dotnet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@memoize
def import_outlook():
clr.AddReference('Microsoft.Office.Interop.Outlook')
import Microsoft.Office.Interop.Outlook as outlook
return outlook
@memoize
def import_visio():
clr.AddReference('Microsoft.Office.Interop.Visio')
import Microsoft.Office.Interop.Visio as visio
retu... | code_fim | hard | {
"lang": "python",
"repo": "pyro-team/bkt-toolbox",
"path": "/bkt/dotnet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ricffb/while-lang path: /whilelang/jit.py
from .parse import PProgram, parse_while
from .models import Program, Assign, Add, Seq, Sub, While, AssignSub
from llvmlite import ir #type: ignore
from ctypes import CFUNCTYPE, c_int64
import llvmlite.binding as llvm #type: ignore
from typing import Di... | code_fim | hard | {
"lang": "python",
"repo": "ricffb/while-lang",
"path": "/whilelang/jit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> engine=defaultengine):
mod_ir = emit_ir(prog[1], dict(prog[0]))
mod = optimize_ir(mod_ir, opt_level=3)
# engine = create_execution_engine()
cmp = compile_module(mod, engine)
# Look up the function pointer (a Python int)
func_ptr = engine.get_function_address("whi... | code_fim | hard | {
"lang": "python",
"repo": "ricffb/while-lang",
"path": "/whilelang/jit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if os.path.split(remote)[1] == '':
remote = remote + '/' + os.path.split(local)[1]
FtpLibrary.cwd(current_dir)
local = os.path.normpath(local)
remote = os.path.normpath(remote)
FtpLibrary.upload_file(local, remote)
class SFtpHandler(object):
"""sf... | code_fim | hard | {
"lang": "python",
"repo": "wangliyao518/FilesOperationLibrary",
"path": "/src/FilesOperationLibrary/handle_ftp.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangliyao518/FilesOperationLibrary path: /src/FilesOperationLibrary/handle_ftp.py
# -*- coding: utf-8 -*-
"""
:created on: 6-09-2017
:copyright:
:author: leo
:contact:
"""
import logging
import os
import re
import shutil
import pysftp
import FtpLibrary
class FtpHandler(object):
"""ftp dow... | code_fim | hard | {
"lang": "python",
"repo": "wangliyao518/FilesOperationLibrary",
"path": "/src/FilesOperationLibrary/handle_ftp.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> statfiles = list("%s/%s" % (sftp_curr_dir, filename) for filename in self.sftp.listdir(sftp_curr_dir) if re.search(filefilter, filename))
sorted_statfiles = list(sorted([filename for filename in statfiles], key=self.mtime))
try:
target_file = sorted_stat... | code_fim | hard | {
"lang": "python",
"repo": "wangliyao518/FilesOperationLibrary",
"path": "/src/FilesOperationLibrary/handle_ftp.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.