text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: dadhichmohit/notes path: /scripts/xpath.py
#!/usr/bin/env python2.7
#encoding: utf-8
#author : ThammeGowda N
#Licence : Apache 2.0
import libxml2
import argparse
import sys
def xpath_eval(xml_f, xp_qry):
<|fim_suffix|>def main(argv):
parser = argparse.ArgumentParser(description='Xpath Eval... | code_fim | hard | {
"lang": "python",
"repo": "dadhichmohit/notes",
"path": "/scripts/xpath.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dtantsur/miniscript path: /miniscript/_types.py
import typing
class Error(Exception):
"""Base class for all errors."""
class ExecutionFailed(Error):
"""Execution of a task failed."""
class InvalidScript(Error):
"""The script definition is invalid."""
class InvalidTask(Error):
... | code_fim | medium | {
"lang": "python",
"repo": "dtantsur/miniscript",
"path": "/miniscript/_types.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class FinishScript(BaseException):
"""Finish the script successfully."""
def __init__(self, result: typing.Any):
self.result = result
class Aborted(ExecutionFailed):
"""Abort the script."""<|fim_prefix|># repo: dtantsur/miniscript path: /miniscript/_types.py
import typing
class ... | code_fim | hard | {
"lang": "python",
"repo": "dtantsur/miniscript",
"path": "/miniscript/_types.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: henryfjordan/django_beginnings path: /django_beginnings/blog/views.py
from django.shortcuts import render
from django.views.generic import ListView, DetailView, CreateView
from django.core.urlresolvers import reverse_lazy
from django.http import HttpResponse
# Create your views here.
from .model... | code_fim | medium | {
"lang": "python",
"repo": "henryfjordan/django_beginnings",
"path": "/django_beginnings/blog/views.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> context = super(BlogDetail, self).get_context_data(**kwargs)
context['form'] = CommentForm()
return context
def post(self, request, *args, **kwargs):
self.form = CommentForm(request.POST)
if self.form.is_valid():
comment = self.form.save(commit=Fal... | code_fim | medium | {
"lang": "python",
"repo": "henryfjordan/django_beginnings",
"path": "/django_beginnings/blog/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.form = CommentForm(request.POST)
if self.form.is_valid():
comment = self.form.save(commit=False)
#print(dir(self.object))
comment.author = User.objects.get(username = self.request.user.username)
comment.blogpost = self.get_object()
... | code_fim | hard | {
"lang": "python",
"repo": "henryfjordan/django_beginnings",
"path": "/django_beginnings/blog/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> np.random.seed(0)
x = np.float32(pptk.rand(100, 3))
n = x.NBHDS(k=3)
y = np.vstack(pptk.MEAN(x[n], axis=0).evaluate())
self.assertTrue(y.shape == (100, 3))
if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: cassfalg/pptk path: /tests/test_expr.py... | code_fim | medium | {
"lang": "python",
"repo": "cassfalg/pptk",
"path": "/tests/test_expr.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cassfalg/pptk path: /tests/test_expr.py
import unittest
import pptk
import numpy as np
class TestCentroids(unittest.TestCase):
def test_centroids(self):
<|fim_suffix|>
if __name__ == '__main__':
unittest.main()<|fim_middle|> np.random.seed(0)
x = np.float32(pptk.rand(100,... | code_fim | medium | {
"lang": "python",
"repo": "cassfalg/pptk",
"path": "/tests/test_expr.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
unittest.main()<|fim_prefix|># repo: cassfalg/pptk path: /tests/test_expr.py
import unittest
import pptk
import numpy as np
<|fim_middle|>class TestCentroids(unittest.TestCase):
def test_centroids(self):
np.random.seed(0)
x = np.float32(pptk.rand(100, ... | code_fim | hard | {
"lang": "python",
"repo": "cassfalg/pptk",
"path": "/tests/test_expr.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEqual( len(data), readfiles.line_count() )
def test_longest_word(self):
'''
Test to check the longest work
'''
with open('test.txt', 'r') as handle:
data = handle.read()
long_word = ''
for word in data.spl... | code_fim | hard | {
"lang": "python",
"repo": "carolwanjohi/lorem-read-files",
"path": "/test_readfiles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if word == 'Lorem':
counter += 1
self.assertEqual(counter, readfiles.word_count('Lorem'))
def test_number_of_lines(self):
'''
Test to count the number of lines in the text file
'''
with open('test.txt','r') as handle:... | code_fim | hard | {
"lang": "python",
"repo": "carolwanjohi/lorem-read-files",
"path": "/test_readfiles.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: carolwanjohi/lorem-read-files path: /test_readfiles.py
import unittest
import readfiles
class TestReadFiles(unittest.TestCase):
'''
Class to test the functions on the readfiles module
Args:
unittest.TestCase class from the unittest module to create unittest
'''
# ... | code_fim | hard | {
"lang": "python",
"repo": "carolwanjohi/lorem-read-files",
"path": "/test_readfiles.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(MasterCorePayload, self).__init__(*args, **kwargs)<|fim_prefix|># repo: saisandeep/python-project-template path: /twophasecommit/payload_machines/core_machines/master_core_machine.py
from twophasecommit.models.master_states import MasterStates
class MasterCorePayload(BaseMachine):
<|fim_m... | code_fim | hard | {
"lang": "python",
"repo": "saisandeep/python-project-template",
"path": "/twophasecommit/payload_machines/core_machines/master_core_machine.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(*args, **kwargs):
super(MasterCorePayload, self).__init__(*args, **kwargs)<|fim_prefix|># repo: saisandeep/python-project-template path: /twophasecommit/payload_machines/core_machines/master_core_machine.py
from twophasecommit.models.master_states import MasterStates
class Mast... | code_fim | hard | {
"lang": "python",
"repo": "saisandeep/python-project-template",
"path": "/twophasecommit/payload_machines/core_machines/master_core_machine.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saisandeep/python-project-template path: /twophasecommit/payload_machines/core_machines/master_core_machine.py
from twophasecommit.models.master_states import MasterStates
class MasterCorePayload(BaseMachine):
<|fim_suffix|> super(MasterCorePayload, self).__init__(*args, **kwargs)<|fim_m... | code_fim | hard | {
"lang": "python",
"repo": "saisandeep/python-project-template",
"path": "/twophasecommit/payload_machines/core_machines/master_core_machine.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> users = []
for user in USERS:
users.append(User(
username=user[0],
birthday=user[1],
))
User.objects.bulk_create(users)<|fim_prefix|># repo: andrew-terpolovsky/milo-django-task path: /apps/accounts/management/commands/db.py
... | code_fim | hard | {
"lang": "python",
"repo": "andrew-terpolovsky/milo-django-task",
"path": "/apps/accounts/management/commands/db.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andrew-terpolovsky/milo-django-task path: /apps/accounts/management/commands/db.py
import datetime
from django.core.management.base import BaseCommand
<|fim_suffix|>
class Command(BaseCommand):
def handle(self, *args, **options):
users = []
for user in USERS:
use... | code_fim | hard | {
"lang": "python",
"repo": "andrew-terpolovsky/milo-django-task",
"path": "/apps/accounts/management/commands/db.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TACC/vis-workloads path: /pv_scripts/moreland.py
e_Shield.exo.300.154', '/work/01336/carson/intelTACC/data/Whipple300/Whipple_Shield.exo.300.155', '/work/01336/carson/intelTACC/data/Whipple300/Whipple_Shield.exo.300.156', '/work/01336/carson/intelTACC/data/Whipple300/Whipple_Shield.exo.300.157', ... | code_fim | hard | {
"lang": "python",
"repo": "TACC/vis-workloads",
"path": "/pv_scripts/moreland.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TACC/vis-workloads path: /pv_scripts/moreland.py
143', '/work/01336/carson/intelTACC/data/Whipple300/Whipple_Shield.exo.300.144', '/work/01336/carson/intelTACC/data/Whipple300/Whipple_Shield.exo.300.145', '/work/01336/carson/intelTACC/data/Whipple300/Whipple_Shield.exo.300.146', '/work/01336/cars... | code_fim | hard | {
"lang": "python",
"repo": "TACC/vis-workloads",
"path": "/pv_scripts/moreland.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # toggle the 3D widget visibility.
active_objects.source.SMProxy.InvokeEvent('UserEvent', 'HideWidget')
#RenderView1.CameraClippingRange = [0.11770729481791534, 0.23555732428522624]
Clip1.Scalars = ['POINTS', 'VOLFRC2']
Clip1.ClipType = "Scalar"
Clip1.Value = 0.5
DataRepresen... | code_fim | hard | {
"lang": "python",
"repo": "TACC/vis-workloads",
"path": "/pv_scripts/moreland.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('\n******************************************************')
print('1、请求url:\n%s %s\n' % (self.method, self.res.request.url))
print('2、api描述:\n%s\n' % (self.func.__doc__ or self.func.__name__).strip())
print('3、请求headers:\n%s\n' % format_json(dict(self.res.request.head... | code_fim | hard | {
"lang": "python",
"repo": "hzs618/walnuts",
"path": "/src/walnuts/api_decorator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hzs618/walnuts path: /src/walnuts/api_decorator.py
import inspect
import json
from collections import OrderedDict, defaultdict
from functools import wraps
from types import FunctionType
from urllib.parse import urljoin, urlencode
from requests import Session, Response
from .config_manager impor... | code_fim | hard | {
"lang": "python",
"repo": "hzs618/walnuts",
"path": "/src/walnuts/api_decorator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('sum_v1', '0014_auto_20180615_1428'),
]
operations = [
migrations.AlterField(
model_name='file_upload',
name='word_count',
field=models.TextField(blank=True, default='200'),
),
]<|fim_prefix|># repo: time-crunch... | code_fim | easy | {
"lang": "python",
"repo": "time-crunched/nlp-toolbox",
"path": "/gui/sum_v1/migrations/0015_auto_20180615_1431.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='file_upload',
name='word_count',
field=models.TextField(blank=True, default='200'),
),
]<|fim_prefix|># repo: time-crunched/nlp-toolbox path: /gui/sum_v1/migrations/0015_auto_20180615_1431.py
# G... | code_fim | medium | {
"lang": "python",
"repo": "time-crunched/nlp-toolbox",
"path": "/gui/sum_v1/migrations/0015_auto_20180615_1431.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: time-crunched/nlp-toolbox path: /gui/sum_v1/migrations/0015_auto_20180615_1431.py
# Generated by Django 2.0.5 on 2018-06-15 12:31
from django.db import migrations, models
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='file_upload',
name='word... | code_fim | medium | {
"lang": "python",
"repo": "time-crunched/nlp-toolbox",
"path": "/gui/sum_v1/migrations/0015_auto_20180615_1431.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChroniclesStudio/money-and-honour path: /src/formAI_mission_templates_mb.py
# Formations AI for Mount & Blade by Motomataru
# rel. 01/03/11
# This function attaches AI_triggers only to mission "lead_charge"
# For other missions, add to end of triggers list like so: " ] + AI_triggers "
# M... | code_fim | hard | {
"lang": "python",
"repo": "ChroniclesStudio/money-and-honour",
"path": "/src/formAI_mission_templates_mb.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (0, AI_Delay_For_Spawn, ti_once, [], [
(set_fixed_point_multiplier, 100),
(call_script, "script_battlegroup_get_position", Team0_Starting_Point, 0, grc_everyone),
(call_script, "script_battlegroup_get_position", Team1_Starting_Point, 1, grc_everyone),
(call_script, "script_battlegroup_get_pos... | code_fim | hard | {
"lang": "python",
"repo": "ChroniclesStudio/money-and-honour",
"path": "/src/formAI_mission_templates_mb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (set_fixed_point_multiplier, 100),
(call_script, "script_store_battlegroup_data"),
(try_begin), #reassess ranged position when fighting starts
(ge, "$battle_phase", BP_Fight),
(eq, "$clock_reset", 0),
(call_script, "script_field_tactics", 1),
(assign, "$ranged_clock", 0),
(assi... | code_fim | hard | {
"lang": "python",
"repo": "ChroniclesStudio/money-and-honour",
"path": "/src/formAI_mission_templates_mb.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EajksEajks/time-series-pipeline path: /utils/sample_against_redundancy.py
import numpy as np
import pandas as pd
# Functions for sampling data in a way that reduces label redundancy
# From Marcos Lopez de Prado's "Advances in Financial Machine Learning" Chapter 4
# The same chapter also showcase... | code_fim | hard | {
"lang": "python",
"repo": "EajksEajks/time-series-pipeline",
"path": "/utils/sample_against_redundancy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
"""
Standard uniqueness vs Sequential uniqueness demo from the book
"""
t1 = pd.Series(
[2, 3, 5, 6, 9], index=[0, 2, 4, 5, 7]
) # t1,t0: The timestamps of the labels and of the features
barIx = range(t1.max() + 1)
print(t1)
print(barIx)
... | code_fim | hard | {
"lang": "python",
"repo": "EajksEajks/time-series-pipeline",
"path": "/utils/sample_against_redundancy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return condor.fig10(conn)
@display
def condor_websub_post_vs_get(conn):
return condor.fig11(conn)
@display
def condor_websub_duration_post_vs_get(conn):
return condor.fig12(conn)
@display
def condor_websub_over_batch_ratio(conn):
return condor.fig13(conn)
##
# OpenStack
#
@display
def openstack_c... | code_fim | hard | {
"lang": "python",
"repo": "canfar/cadcstats",
"path": "/svc_plots/plots.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: canfar/cadcstats path: /svc_plots/plots.py
from . import advancedsearch, apache, condor, openstack, tomcat_odin, tomcat_old
from bokeh.plotting import output_notebook, show
from elasticsearch import Elasticsearch
import requests
es = 'http://users:cadcusers@206.12.59.36:9200'
class Init():
def... | code_fim | hard | {
"lang": "python",
"repo": "canfar/cadcstats",
"path": "/svc_plots/plots.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wchorolque/py-postgresql path: /postgresql/exceptions.py
exceptions.
It provides a convenient way to look up the exception object mapped to by the
given error code::
$ python -m postgresql.exceptions XX000
postgresql.exceptions.InternalError [XX000]
If the exact error code is not found, it wi... | code_fim | hard | {
"lang": "python",
"repo": "wchorolque/py-postgresql",
"path": "/postgresql/exceptions.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> code = '42611'
class CursorDefinitionError(DefinitionError):
code = '42P11'
class DatabaseDefinitionError(DefinitionError):
code = '42P12'
class FunctionDefinitionError(DefinitionError):
code = '42P13'
class PreparedStatementDefinitionError(DefinitionError):
code = '42P14'
class SchemaDefinitionError... | code_fim | hard | {
"lang": "python",
"repo": "wchorolque/py-postgresql",
"path": "/postgresql/exceptions.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> code = '42622'
class ReservedNameError(SEARVError):
code = '42939'
class ForeignKeyCreationError(SEARVError):
code = '42830'
class InsufficientPrivilegeError(SEARVError):
code = '42501'
class GroupingError(SEARVError):
code = '42803'
class RecursionError(SEARVError):
code = '42P19'
class WindowEr... | code_fim | hard | {
"lang": "python",
"repo": "wchorolque/py-postgresql",
"path": "/postgresql/exceptions.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def testDoublesidedMaxwellPDF(self):
# Use only positive values since we will use the one sided maxwell
# as a test.
x = np.arange(1, 5, dtype=np.float64)
loc = 1.
scale = 1.
# Test the pdf value by using its relationship to the 1-sided Maxwell.
dsmaxwell = doublesided_maxwe... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/probability",
"path": "/tensorflow_probability/python/distributions/doublesided_maxwell_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def testParamShapes(self):
sample_shape = [10, 3, 4]
self._testParamShapes(sample_shape, sample_shape)
self._testParamShapes(tf.constant(sample_shape), sample_shape)
self._testParamStaticShapes(sample_shape, sample_shape)
def testDoublesidedMaxwellPDF(self):
# Use only positive va... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/probability",
"path": "/tensorflow_probability/python/distributions/doublesided_maxwell_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tensorflow/probability path: /tensorflow_probability/python/distributions/doublesided_maxwell_test.py
# Copyright 2018 The TensorFlow Probability Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You m... | code_fim | hard | {
"lang": "python",
"repo": "tensorflow/probability",
"path": "/tensorflow_probability/python/distributions/doublesided_maxwell_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>for suffix in mods_load_order:
mod = mod_prefix + suffix
if mod in reload_mods:
reload(sys.modules[mod])
try:
# Python 3
from .ml.xcc import Xcc
from .ml.commands import *
except (ValueError):
# Python 2
from ml.xcc import Xcc
from ml.commands import *<|fim_prefix|># repo: paxtonhare/MarkLogic-... | code_fim | medium | {
"lang": "python",
"repo": "paxtonhare/MarkLogic-Sublime",
"path": "/MarkLogic.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paxtonhare/MarkLogic-Sublime path: /MarkLogic.py
import sublime
import sys
import os
import locale
if int(sublime.version()) > 3000:
st_version = 3
else:
st_version = 2
reload_mods = []
for mod in sys.modules:
if (mod[0:10] == 'MarkLogic.' or mod[0:3] == 'ml.' or mod == 'ml') and sys.modules... | code_fim | medium | {
"lang": "python",
"repo": "paxtonhare/MarkLogic-Sublime",
"path": "/MarkLogic.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pymor/pymor-deal.II path: /test/test_demo.py
def test_demo_results(ndarrays_regression):
<|fim_suffix|> result, _, _, _ = run(plot_error=False)
compare = ["errors", "basis_sizes", "rel_errors"]
ndarrays_regression.check({k: v for k, v in result.items() if k in compare})<|fim_middle|> ... | code_fim | easy | {
"lang": "python",
"repo": "pymor/pymor-deal.II",
"path": "/test/test_demo.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> compare = ["errors", "basis_sizes", "rel_errors"]
ndarrays_regression.check({k: v for k, v in result.items() if k in compare})<|fim_prefix|># repo: pymor/pymor-deal.II path: /test/test_demo.py
def test_demo_results(ndarrays_regression):
<|fim_middle|> from pymor_dealii.pymor.demo import run
... | code_fim | medium | {
"lang": "python",
"repo": "pymor/pymor-deal.II",
"path": "/test/test_demo.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> result, _, _, _ = run(plot_error=False)
compare = ["errors", "basis_sizes", "rel_errors"]
ndarrays_regression.check({k: v for k, v in result.items() if k in compare})<|fim_prefix|># repo: pymor/pymor-deal.II path: /test/test_demo.py
def test_demo_results(ndarrays_regression):
<|fim_middle|> ... | code_fim | easy | {
"lang": "python",
"repo": "pymor/pymor-deal.II",
"path": "/test/test_demo.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: karaasJP/ViZDoom path: /examples/python/test.py
import numpy as np
<|fim_suffix|>print(arr2.shape)
print(arr2)<|fim_middle|>arr = np.zeros((1,3), dtype = int)
arr2 = np.append(arr, arr, axis=0)
arr2 = np.append(arr2, arr, axis = 0)
arr2 = np.append(arr2, arr, axis = 0)
| code_fim | medium | {
"lang": "python",
"repo": "karaasJP/ViZDoom",
"path": "/examples/python/test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(arr2.shape)
print(arr2)<|fim_prefix|># repo: karaasJP/ViZDoom path: /examples/python/test.py
import numpy as np
<|fim_middle|>arr = np.zeros((1,3), dtype = int)
arr2 = np.append(arr, arr, axis=0)
arr2 = np.append(arr2, arr, axis = 0)
arr2 = np.append(arr2, arr, axis = 0)
| code_fim | medium | {
"lang": "python",
"repo": "karaasJP/ViZDoom",
"path": "/examples/python/test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test data stream."""
times = [0, 1]
records = [dict(k="1"), dict(k="2")]
ds = MultiDataStream(times, records)
list(ds)
assert len([r for r in ds]) == 2
assert len(ds) == 2<|fim_prefix|># repo: haje01/swak path: /tests/test_event.py
"""This module implements data test."""
f... | code_fim | easy | {
"lang": "python",
"repo": "haje01/swak",
"path": "/tests/test_event.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: haje01/swak path: /tests/test_event.py
"""This module implements data test."""
from swak.data import MultiDataStream
def test_data_basic():
<|fim_suffix|> ds = MultiDataStream(times, records)
list(ds)
assert len([r for r in ds]) == 2
assert len(ds) == 2<|fim_middle|> """Test d... | code_fim | medium | {
"lang": "python",
"repo": "haje01/swak",
"path": "/tests/test_event.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fhightower-tc/old-tcex-utility path: /democritus/__init__.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
<|fim_suffix|>from .elements import Elements
from .molecules import Molecules<|fim_middle|>__author__ = """Floyd Hightower"""
__version__ = '0.1.0'
| code_fim | easy | {
"lang": "python",
"repo": "fhightower-tc/old-tcex-utility",
"path": "/democritus/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .elements import Elements
from .molecules import Molecules<|fim_prefix|># repo: fhightower-tc/old-tcex-utility path: /democritus/__init__.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
<|fim_middle|>__author__ = """Floyd Hightower"""
__version__ = '0.1.0'
| code_fim | easy | {
"lang": "python",
"repo": "fhightower-tc/old-tcex-utility",
"path": "/democritus/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.info("Running PCA analysis")
feat_cols = [ 'embedding'+str(i) for i in range(x.shape[1]) ]
df_embed = pd.DataFrame(x,columns=feat_cols)
df_embed['y'] = y
pca = PCA(n_components=2)
pca_result = pca.fit_transform(x)
df_embed['pca-one'] = pca_re... | code_fim | hard | {
"lang": "python",
"repo": "Evaaaaaaa/CloudWine",
"path": "/train/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Evaaaaaaa/CloudWine path: /train/utils.py
import logging
import os
import pickle
import pandas as pd
import numpy as np
from sklearn.decomposition import PCA
from sklearn.metrics.pairwise import cosine_similarity
import matplotlib.pyplot as plt
import seaborn as sns
# Logging
logger = logging... | code_fim | hard | {
"lang": "python",
"repo": "Evaaaaaaa/CloudWine",
"path": "/train/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self):
self.top_labels = ['Cabernet Sauvignon-Napa Valley','Nebbiolo-Barolo',
'Pinot Noir-Willamette Valley','Pinot Noir-Russian River Valley',
'Champagne Blend-Champagne','Pinot Noir-Sonoma Coast','Malbec-Mendoza',
'Chardonnay-Russian River Val... | code_fim | hard | {
"lang": "python",
"repo": "Evaaaaaaa/CloudWine",
"path": "/train/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ray-project/maze-raylit path: /rllib/models/utils.py
from ray.rllib.utils.framework import try_import_tf, try_import_torch
def get_filter_config(shape):
"""Returns a default Conv2D filter config (list) for a given image shape.
Args:
shape (Tuple[int]): The input (image) shape, ... | code_fim | hard | {
"lang": "python",
"repo": "ray-project/maze-raylit",
"path": "/rllib/models/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Returns a framework specific initializer, given a name string.
Args:
name (str): One of "xavier_uniform" (default), "xavier_normal".
framework (str): One of "tf" or "torch".
Returns:
A framework-specific initializer function, e.g.
tf.keras.initializers.... | code_fim | hard | {
"lang": "python",
"repo": "ray-project/maze-raylit",
"path": "/rllib/models/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rchateauneu/rdflib-sqlalchemy path: /test/test_sqlalchemy_postgresql.py
import logging
import os
import unittest
from nose import SkipTest
try:
import psycopg2 # noqa
except ImportError:
raise SkipTest("psycopg2 not installed, skipping PgSQL tests")
from . import context_case
from . im... | code_fim | medium | {
"lang": "python",
"repo": "rchateauneu/rdflib-sqlalchemy",
"path": "/test/test_sqlalchemy_postgresql.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(SQLAPgSQLGraphTestCase, self).setUp(
uri=self.uri,
storename=self.storename,
)
def tearDown(self):
super(SQLAPgSQLGraphTestCase, self).tearDown(uri=self.uri)
class SQLAPgSQLContextTestCase(context_case.ContextTestCase):
storetest = True
... | code_fim | hard | {
"lang": "python",
"repo": "rchateauneu/rdflib-sqlalchemy",
"path": "/test/test_sqlalchemy_postgresql.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_valid_scales(self):
img = Image(test_array)
with self.assertRaises(ValueError):
img.scale(-2)
def test_double_res(self):
img = Image(test_array)
img.scale(2)
self.assertEquals(test_array.shape[0] * 2, img.y_res)
self.assertEqual... | code_fim | hard | {
"lang": "python",
"repo": "thorsteinson/board-vector-proto",
"path": "/lib/test_image.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thorsteinson/board-vector-proto path: /lib/test_image.py
import unittest
from .image import Image
import numpy as np
from pathlib import Path
from copy import copy
test_array = np.zeros((10, 10, 3), dtype="uint8")
class TestInit(unittest.TestCase):
def test_from_array(self):
img = ... | code_fim | hard | {
"lang": "python",
"repo": "thorsteinson/board-vector-proto",
"path": "/lib/test_image.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEquals(init_x, img.x_res)
self.assertEquals(init_y, img.y_res)
class TestDrawLine(unittest.TestCase):
def test_types(self):
img = Image(test_array)
bad_types = [(("a", "b"), ("a", "b")), ((None, None), ([1, 2.3], {}))]
for p0, p1 in bad_types:
... | code_fim | hard | {
"lang": "python",
"repo": "thorsteinson/board-vector-proto",
"path": "/lib/test_image.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def findSolution(initialState, goalState):
"""
Function implementing the bfs algorithm
"""
initialState = convertToRow(initialState)
goalState = convertToRow(goalState)
closedNode = set()
nodeList = Queue()
allNode = Queue()
count = 0
root = Node(initialState, None,... | code_fim | hard | {
"lang": "python",
"repo": "Arjung27/8puzzle",
"path": "/8puzzle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return count
def findSolution(initialState, goalState):
"""
Function implementing the bfs algorithm
"""
initialState = convertToRow(initialState)
goalState = convertToRow(goalState)
closedNode = set()
nodeList = Queue()
allNode = Queue()
count = 0
root = Node(i... | code_fim | hard | {
"lang": "python",
"repo": "Arjung27/8puzzle",
"path": "/8puzzle.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Arjung27/8puzzle path: /8puzzle.py
import numpy as np
import sys
from queue import Queue
from queue import LifoQueue
class Node:
def __init__(self, key, parent, index):
self.key = key
self.position = key.find('0')
self.parent = parent
self.index = index
def ... | code_fim | hard | {
"lang": "python",
"repo": "Arjung27/8puzzle",
"path": "/8puzzle.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_invalid_json():
"""Test Invalid response Exception"""
with pytest.raises(ExxRequestException):
with requests_mock.mock() as m:
m.get('https://api.exx.com/data/v1/markets', text='<head></html>')
client.get_markets()
def test_api_exception():
"""Test A... | code_fim | medium | {
"lang": "python",
"repo": "afcarl/python-exx",
"path": "/tests/test_api_request.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afcarl/python-exx path: /tests/test_api_request.py
# coding=utf-8
from exx.client import Client
from exx.exceptions import ExxAPIException, ExxRequestException
import pytest
import requests_mock
client = Client('api_key', 'api_secret')
<|fim_suffix|>def test_api_exception():
"""Test API r... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/python-exx",
"path": "/tests/test_api_request.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_api_exception():
"""Test API response Exception"""
with pytest.raises(ExxAPIException):
with requests_mock.mock() as m:
json_obj = {'error': '币种错误'}
m.get('https://api.exx.com/data/v1/tickers', json=json_obj, status_code=200)
client.get_ticker... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/python-exx",
"path": "/tests/test_api_request.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # For convenience get the endpoint statement dict
s_dict = stmt_nd[tr.id][src][tcid][reader][rv][rid]
# Initialize the value to a set, and count duplicates
if stmt_hash not in s_dict.keys():
s_dict[stmt_hash] = set()
num_unique_evidence += 1
... | code_fim | hard | {
"lang": "python",
"repo": "budakn/INDRA",
"path": "/indra/db/util.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: budakn/INDRA path: /indra/db/util.py
ata, cols)
return
@_clockit
def insert_pa_agents_directly(db, stmts, verbose=False):
"""Insert agents for preasembled statements.
Unlike raw statements, preassembled statements are indexed by a hash,
allowing for bulk import without a lookup... | code_fim | hard | {
"lang": "python",
"repo": "budakn/INDRA",
"path": "/indra/db/util.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Alterations are made to the Statement objects "in-place", so this function
itself returns None.
"""
rid_set = {rid for rid, _, _ in rid_stmt_trios if rid is not None}
logger.info("Getting text refs for %d readings." % len(rid_set))
if rid_set:
rid_tr_pairs = db.select_all([... | code_fim | hard | {
"lang": "python",
"repo": "budakn/INDRA",
"path": "/indra/db/util.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: meocong/clothing-co-parsing path: /train.py
from segmentation_models import Unet, FPN
from segmentation_models.utils import set_trainable
from keras.utils import Sequence
import numpy as np
from online_augment import augment
import glob
import cv2
from sklearn.model_selection import train_test_sp... | code_fim | hard | {
"lang": "python",
"repo": "meocong/clothing-co-parsing",
"path": "/train.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
X_train, X_val, Y_train, Y_val = train_test_split(X, y, test_size = 0.1, random_state=42)
n_train = len(X_train)
n_val = len(X_val)
batch_size = 2
my_training_batch_generator = DataGenerator(X_train, Y_train, batch_size)
my_validation_batch_generator = DataGenerator(X_val, Y_val, batch_size)
print(n_tra... | code_fim | hard | {
"lang": "python",
"repo": "meocong/clothing-co-parsing",
"path": "/train.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>model = Unet(backbone_name='vgg16', encoder_weights='imagenet', freeze_encoder=True, classes=59, decoder_block_type='transpose')
model.compile('Adam', 'binary_crossentropy', ['binary_accuracy'])
mask_images = glob.glob("./mask/*.jpg")
X = [x.replace("mask","photos") for x in mask_images]
y = [x for x in ... | code_fim | hard | {
"lang": "python",
"repo": "meocong/clothing-co-parsing",
"path": "/train.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class TemplateRead(TemplateBase):
id: int
updated_at: datetime
created_at: datetime
class TemplateReadAll(TemplateBase):
items: List[TemplateItem] = []
class TemplateItems(TemplateRead):
items: List[TemplateItem] = []
class Config:
orm_mode = True
### TEMPLATES END ... | code_fim | hard | {
"lang": "python",
"repo": "SelfhostedPro/Yacht",
"path": "/backend/api/db/schemas/templates.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> id: int
### Export/Import ###
class Import_Export(BaseModel):
templates: List[TemplateItems] = []
variables: List[ReadTemplateVariables] = []
TemplateItems.update_forward_refs()<|fim_prefix|># repo: SelfhostedPro/Yacht path: /backend/api/db/schemas/templates.py
from __future__ import an... | code_fim | hard | {
"lang": "python",
"repo": "SelfhostedPro/Yacht",
"path": "/backend/api/db/schemas/templates.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SelfhostedPro/Yacht path: /backend/api/db/schemas/templates.py
from __future__ import annotations
from typing import List, Optional, Union
from datetime import datetime
from pydantic import BaseModel
class TemplateItem(BaseModel):
id: int
type: int
title: str
name: str
platf... | code_fim | hard | {
"lang": "python",
"repo": "SelfhostedPro/Yacht",
"path": "/backend/api/db/schemas/templates.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pavansaidiwakar/Vehicular-Traffic-Modelling-using-HMM path: /coordinate2.py
from hmm import Model
from hmm import train
from PIL import Image
x=[190,190,190,190,190,540,540,540,540,540,854,854,854,854,854,1189,1189,1189,1189,1189]
y=[573,573,573,573,573,466,466,466,466,466,380,380,380,380,380,26... | code_fim | hard | {
"lang": "python",
"repo": "pavansaidiwakar/Vehicular-Traffic-Modelling-using-HMM",
"path": "/coordinate2.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #SEG1
for i in range(0,5):
P = pix[x[i],y[i]]
B = sum(P)
pixsum[j]=pixsum[j]+B
M=[0,0,0,0]
#print B
#print P #Get the RGBA Value of the a pixel of an image
if B in range(180,215):
M[0]=M[0]+1
elif B in range(215,270):
M[1]=M[1]+1
elif P[0]>200:
M[2]=M[2]+1
else:
M[3]=M[3]... | code_fim | hard | {
"lang": "python",
"repo": "pavansaidiwakar/Vehicular-Traffic-Modelling-using-HMM",
"path": "/coordinate2.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openmc-data-storage/openmc_data_downloader path: /src/openmc_data_downloader/terminal_cmd.py
#!/usr/bin/python
"""
A nuclear data downloading package that facilitates the reproduction of cross
section collections. Use the command line tool or Python API to download the h5
cross sections for just... | code_fim | hard | {
"lang": "python",
"repo": "openmc-data-storage/openmc_data_downloader",
"path": "/src/openmc_data_downloader/terminal_cmd.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser.add_argument(
"-e",
"--elements",
nargs="*",
default=[],
help="The element or elements to download, name of element e.g. 'Al' or keyword 'all' or 'stable'",
)
parser.add_argument(
"-p",
"--particles",
nargs="*",
def... | code_fim | hard | {
"lang": "python",
"repo": "openmc-data-storage/openmc_data_downloader",
"path": "/src/openmc_data_downloader/terminal_cmd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mats = openmc.Materials([mat])
if args.materials_xml:
for material_xml in args.materials_xml:
mats_from_xml = openmc.Materials.from_xml(material_xml)
mats = mats + mats_from_xml
mats.download_cross_section_data(
libraries=args.libraries,
destin... | code_fim | hard | {
"lang": "python",
"repo": "openmc-data-storage/openmc_data_downloader",
"path": "/src/openmc_data_downloader/terminal_cmd.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_analysis(img, PIX_SIZE, PATH_LENGTH, config_file=''):
'''wrapper for pysilcam processing
Args:
img (unit8) : image to be processed (equivalent to the background-corrected image obtained from the
SilCam)
PIX_SIZE (float) : pixel si... | code_fim | hard | {
"lang": "python",
"repo": "SINTEF/PySilCam",
"path": "/pysilcam/tests/synthesizer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SINTEF/PySilCam path: /pysilcam/tests/synthesizer.py
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import pandas as pd
import os
from skimage.draw import circle
from skimage import util
import pysilcam.postprocess as scpp
import pysilcam.p... | code_fim | hard | {
"lang": "python",
"repo": "SINTEF/PySilCam",
"path": "/pysilcam/tests/synthesizer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''synthesize an image and measure droplets
Args:
diams (array) : size bins of the number distribution
bin_limits_um (array) : limits of the size bins where dias are the mid-points
nd (array) : number of parti... | code_fim | hard | {
"lang": "python",
"repo": "SINTEF/PySilCam",
"path": "/pysilcam/tests/synthesizer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i, rec in enumerate(SeqIO.parse(sys.argv[1], 'fasta')):
sys.stdout.write('a label=' + str(i) + '\n')
sys.stdout.write('s\t' + sys.argv[2] + '.' + rec.id + '\t' +
'0\t' + str(len(rec)) + '\t+\t' +
str(len(rec)) + str(rec.seq) + '\n')<|fim_prefix|># repo... | code_fim | easy | {
"lang": "python",
"repo": "brendane/miscellaneous_bioinfo_scripts",
"path": "/fasta2maf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brendane/miscellaneous_bioinfo_scripts path: /fasta2maf.py
#!/usr/bin/env python3
import os.path as osp
import sys
<|fim_suffix|>for i, rec in enumerate(SeqIO.parse(sys.argv[1], 'fasta')):
sys.stdout.write('a label=' + str(i) + '\n')
sys.stdout.write('s\t' + sys.argv[2] + '.' + rec.id +... | code_fim | easy | {
"lang": "python",
"repo": "brendane/miscellaneous_bioinfo_scripts",
"path": "/fasta2maf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> addressComponentList = [streetAddress, addressLocality, addressRegion, postalCode, addressCountry]
addressText = ' '.join(addressComponentList)
# print(address)
details = self.soup.find(class_='company-details-industry')
labels = details.find_all('dt')
val... | code_fim | hard | {
"lang": "python",
"repo": "jlucas-esri/UgandaCompaniesWebScraper",
"path": "/source/companyParser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # print(address)
details = self.soup.find(class_='company-details-industry')
labels = details.find_all('dt')
values = details.find_all('dd')
labelTextList = []
valueTextList = []
for label in labels:
parsedText = label.get_text()
... | code_fim | hard | {
"lang": "python",
"repo": "jlucas-esri/UgandaCompaniesWebScraper",
"path": "/source/companyParser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jlucas-esri/UgandaCompaniesWebScraper path: /source/companyParser.py
from bs4 import BeautifulSoup
import pprint
import re
class CompanyParser:
def __init__(self, htmlText, link):
self.htmlText = htmlText
self.link = link
self.id = re.split(r'\-', self.link)[-1]
... | code_fim | hard | {
"lang": "python",
"repo": "jlucas-esri/UgandaCompaniesWebScraper",
"path": "/source/companyParser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pfmoore/shadwell path: /src/shadwell/finder.py
import enum
import sys
from typing import Callable, List, Optional, Set, Tuple
from packaging.requirements import Requirement
from packaging.tags import Tag, sys_tags
from packaging.version import Version
from .candidate import Candidate
SortKey =... | code_fim | hard | {
"lang": "python",
"repo": "pfmoore/shadwell",
"path": "/src/shadwell/finder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Finder:
sources: List[Callable[[str], List[Candidate]]]
compatibility_tags: List[Tag]
allow_prerelease: bool
python_version: Version
wheel_policy: Callable[[str], WheelPolicy]
allow_yanked: bool
def __init__(
self,
sources: List[Callable[[str], List[Candi... | code_fim | hard | {
"lang": "python",
"repo": "pfmoore/shadwell",
"path": "/src/shadwell/finder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Handle the simple case first.
if self.python_version not in candidate.requires_python:
return None
# Wheel handling. We need to know the policy.
wheel = self.wheel_policy(candidate.name)
wheel_first = 0
if candidate.is_wheel:
if w... | code_fim | hard | {
"lang": "python",
"repo": "pfmoore/shadwell",
"path": "/src/shadwell/finder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnaviTechnology/anavi-examples path: /peripherals/OLED-SSD1306/OLED-SSD1306.py
#!/usr/bin/env python3
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
from luma.core.error import DeviceNotFoundError
impo... | code_fim | hard | {
"lang": "python",
"repo": "AnaviTechnology/anavi-examples",
"path": "/peripherals/OLED-SSD1306/OLED-SSD1306.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
signal.signal(signal.SIGINT, signal_handler)
serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=0)
while True:
with canvas(device) as draw:
draw.rectangle(device.bounding_box, outline="white", fill="black")
font = ImageFont.truetype(dra... | code_fim | hard | {
"lang": "python",
"repo": "AnaviTechnology/anavi-examples",
"path": "/peripherals/OLED-SSD1306/OLED-SSD1306.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
"""
# test data
x, y = [3, 1, 2], [1, 2, 3, 4]
# test
result_using_smaller_list = \
self.inner_median_obj.get_inner_median_using_smaller_list(x, y)
self.assertEqual(result_using_smaller_list, 2.0)
result_using_builtin =... | code_fim | hard | {
"lang": "python",
"repo": "manojkumar-github/DataStructures-DynamicProgramming-in-Python-JAVA-Cplusplus",
"path": "/leet/miscelleneous/setintersection/TestSolution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: manojkumar-github/DataStructures-DynamicProgramming-in-Python-JAVA-Cplusplus path: /leet/miscelleneous/setintersection/TestSolution.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""
Created on Sun 17:00:00 Sep 15 2019
@author : manoj
Test cases for the Solution Module
"""
import unittest
import... | code_fim | hard | {
"lang": "python",
"repo": "manojkumar-github/DataStructures-DynamicProgramming-in-Python-JAVA-Cplusplus",
"path": "/leet/miscelleneous/setintersection/TestSolution.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Returns:
"""
# test data
x, y = list(), list()
expected_value_error_msg = "There were no common elements in x, y"
# test
with self.assertRaises(Exception) as context1:
result_using_smaller_list = \
self.inner... | code_fim | hard | {
"lang": "python",
"repo": "manojkumar-github/DataStructures-DynamicProgramming-in-Python-JAVA-Cplusplus",
"path": "/leet/miscelleneous/setintersection/TestSolution.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rosepog/scraper path: /Scraper/app/views.py
"""
Definition of views.
"""
from django.shortcuts import render
from django.http import HttpRequest, HttpResponseRedirect,HttpResponse
from django.core.urlresolvers import reverse
from django.template import RequestContext
from datetime import datetim... | code_fim | hard | {
"lang": "python",
"repo": "rosepog/scraper",
"path": "/Scraper/app/views.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #print(link)
rpage = requests.get(link)
rpage2 = rpage.text
rpage3 = json.dumps(rpage2)
splitconti = re.findall(r'titoloh1(.*?)Ultime aziende inserite', rpage3)
for itemconti in splitconti:
splitcont3 = re.findall(r'box_aziende_inteno(.*?)</a>', itemconti)
for item3... | code_fim | hard | {
"lang": "python",
"repo": "rosepog/scraper",
"path": "/Scraper/app/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> b = b + 1
print str(a * b * calcTrip(a, b))<|fim_prefix|># repo: jhoward/code_shop path: /site_problems/euler/9.py
def calcTrip(a, b):
c = (a**2 + b**2)**0.5
return c
<|fim_middle|>
if __name__ == "__main__":
a = 1
b = 1
while True:
c = calcTr... | code_fim | hard | {
"lang": "python",
"repo": "jhoward/code_shop",
"path": "/site_problems/euler/9.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jhoward/code_shop path: /site_problems/euler/9.py
def calcTrip(a, b):
c = (a**2 + b**2)**0.5
return c
<|fim_suffix|> if ans > 1000:
a += 1
b = a - 1
b = b + 1
print str(a * b * calcTrip(a, b))<|fim_middle|>if __name__ == "__... | code_fim | hard | {
"lang": "python",
"repo": "jhoward/code_shop",
"path": "/site_problems/euler/9.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: roni-kemp/python_programming_curricula path: /CS2/1275_turtle_recursion/c_curve_turtle_fractal_NOT_DONE/c_curve_00.py
import turtle
#Don't update the screen until the very end. This will greatly speed things up.
#https://stackoverflow.com/questions/16119991/how-to-speed-up-pythons-turtle-functio... | code_fim | hard | {
"lang": "python",
"repo": "roni-kemp/python_programming_curricula",
"path": "/CS2/1275_turtle_recursion/c_curve_turtle_fractal_NOT_DONE/c_curve_00.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.