text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: impossiblynew/davar path: /tests/test_model.py
from davar import model as m
import pytest
@pytest.fixture(scope="module")
def cached_WikidataItem_Q42():
"""
Contains a cached copy of m.WikidataItem("Q42")
"""
return m.WikidataItem("Q42")
@pytest.fixture(scope="module")
def cac... | code_fim | hard | {
"lang": "python",
"repo": "impossiblynew/davar",
"path": "/tests/test_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert (
str(m.Edge(cached_WikidataItem_Q42, example_statement))
== "(Q42 (P31 Q42 Q5))"
)
def test_describe(self, example_statement, cached_WikidataItem_Q42):
assert (
m.Edge(cached_WikidataItem_Q42, example_statement).describe("en")
... | code_fim | hard | {
"lang": "python",
"repo": "impossiblynew/davar",
"path": "/tests/test_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mySpider = spyder.SpiderSession(dataext=dataext, logo=True, log=False)
### create class averages
apDisplay.printMsg("Averaging particles into classes")
for i in range(numclasses):
classnum = i+1
mySpider.toSpiderQuiet(
"AS R",
spyder.fileFilter(alignedstack)+"@******",
rundir+("/classdoc_... | code_fim | hard | {
"lang": "python",
"repo": "vosslab/ctfeval",
"path": "/appionlib/apSpider/classification.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> ### delete existing files
sys.stderr.write("delete existing files")
for dext in (".hed", ".img", dataext):
apFile.removeFile(classavg+dext)
apFile.removeFile(classvar+dext)
print ""
mySpider = spyder.SpiderSession(dataext=dataext, logo=True, log=False)
### create class averages
apDisplay.print... | code_fim | hard | {
"lang": "python",
"repo": "vosslab/ctfeval",
"path": "/appionlib/apSpider/classification.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vosslab/ctfeval path: /appionlib/apSpider/classification.py
## python
import os
import sys
import time
import random
## PIL
## spider
from appionlib import spyder
from appionlib import apEMAN
from appionlib import apImage
from appionlib import apParam
from appionlib import apDisplay
from appionl... | code_fim | hard | {
"lang": "python",
"repo": "vosslab/ctfeval",
"path": "/appionlib/apSpider/classification.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: suny-downstate-medical-center/netpyne path: /doc/source/code/tut8_batch.py
from netpyne import specs
from netpyne.batch import Batch
def batchTauWeight():
# Create variable of type ordered dictionary (NetPyNE's customized version)
params = specs.ODict()
<|fim_suffix|> # S... | code_fim | hard | {
"lang": "python",
"repo": "suny-downstate-medical-center/netpyne",
"path": "/doc/source/code/tut8_batch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # create Batch object with parameters to modify, and specifying files to use
b = Batch(params=params, cfgFile='tut8_cfg.py', netParamsFile='tut8_netParams.py',)
# Set output folder, grid method (all param combinations), and run configuration
b.batchLabel = 'tauWeight'
... | code_fim | hard | {
"lang": "python",
"repo": "suny-downstate-medical-center/netpyne",
"path": "/doc/source/code/tut8_batch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Run batch simulations
b.run()
# Main code
if __name__ == '__main__':
batchTauWeight()<|fim_prefix|># repo: suny-downstate-medical-center/netpyne path: /doc/source/code/tut8_batch.py
from netpyne import specs
from netpyne.batch import Batch
def batchTauWeight():
# Creat... | code_fim | hard | {
"lang": "python",
"repo": "suny-downstate-medical-center/netpyne",
"path": "/doc/source/code/tut8_batch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _training_report_dict(self):
return {"rec_loss": self.METERINTERFACE["rec_loss"].summary()["mean"]}
def _train_loop(
self, train_loader=None, epoch=0, mode=ModelMode.TRAIN, *args, **kwargs
):
self._model.train()
train_loader_: tqdm = tqdm_(train_loader)
... | code_fim | hard | {
"lang": "python",
"repo": "jizongFox/deep-clustering-toolbox",
"path": "/playground/auto_encoder/mnist.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jizongFox/deep-clustering-toolbox path: /playground/auto_encoder/mnist.py
from typing import List
import torch
from torch import nn
from torch.nn import functional as F
from torch.utils.data import DataLoader
from torchvision import transforms
from torchvision.datasets import MNIST
from deepclu... | code_fim | hard | {
"lang": "python",
"repo": "jizongFox/deep-clustering-toolbox",
"path": "/playground/auto_encoder/mnist.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ITemplateHelpers
def get_helpers(self):
function_names = (
'map_ckan_to_csl_field',
)
return _get_module_functions(helpers, function_names)
# IClick
def get_commands(self):
return get_commands()
def _get_module_functions(module, function_na... | code_fim | hard | {
"lang": "python",
"repo": "depositar/ckanext-citation",
"path": "/ckanext/citation/plugin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: depositar/ckanext-citation path: /ckanext/citation/plugin.py
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
from ckan.lib.plugins import DefaultTranslation
from ckanext.citation import helpers
from ckanext.citation.cli import get_commands
<|fim_suffix|> toolkit.add... | code_fim | hard | {
"lang": "python",
"repo": "depositar/ckanext-citation",
"path": "/ckanext/citation/plugin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bacc44/onlysnarf path: /src/OnlySnarf/lib/actions/message.py
message (and post) class"""
def __init__(self):
"""
OnlyFans message and post object
A post is just a message on a profile with different options made available.
"""
# universal message v... | code_fim | hard | {
"lang": "python",
"repo": "bacc44/onlysnarf",
"path": "/src/OnlySnarf/lib/actions/message.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> amount = 0
if re.search(r'I sent you a \$[0-9]*\.00 tip ♥', text):
amount = re.match(r'I sent you a \$([0-9]*)\.00 tip ♥', text).group(1)
Settings.maybe_print("successfully found tip")
Settings.dev_print("amount: {}".format(amount))
return Tr... | code_fim | hard | {
"lang": "python",
"repo": "bacc44/onlysnarf",
"path": "/src/OnlySnarf/lib/actions/message.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bacc44/onlysnarf path: /src/OnlySnarf/lib/actions/message.py
class Message():
"""OnlyFans message (and post) class"""
def __init__(self):
"""
OnlyFans message and post object
A post is just a message on a profile with different options made available.
"... | code_fim | hard | {
"lang": "python",
"repo": "bacc44/onlysnarf",
"path": "/src/OnlySnarf/lib/actions/message.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert 'PonnistallHoppeslottTrommesett' == unfscker('oepHlpslainttnotePmseormoTtlst')
if __name__ == '__main__':
print(unfscker('tMlsioaplnKlflgiruKanliaebeLlkslikkpnerikTasatamkDpsdakeraBeIdaegptnuaKtmteorpuTaTtbtsesOHXxonibmksekaaoaKtrssegnveinRedlkkkroeekVtkekymmlooLnanoKtlstoepHrpeutdynfSnel... | code_fim | medium | {
"lang": "python",
"repo": "matslindh/codingchallenges",
"path": "/knowit2019/05.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert 'lstoTtormmsetePtnointslaHlpoep' == unfscker_long_trios('oepHlpslainttnotePmseormoTtlst')
def test_unfscker():
assert 'PonnistallHoppeslottTrommesett' == unfscker('oepHlpslainttnotePmseormoTtlst')
if __name__ == '__main__':
print(unfscker('tMlsioaplnKlflgiruKanliaebeLlkslikkpnerikTa... | code_fim | hard | {
"lang": "python",
"repo": "matslindh/codingchallenges",
"path": "/knowit2019/05.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: matslindh/codingchallenges path: /knowit2019/05.py
def unfscker(s):
return unfscker_halfsies(
unfscker_pairsies(
unfscker_long_trios(s)
)
)
def unfscker_halfsies(s):
return s[len(s)//2:] + s[:len(s)//2]
def unfscker_pairsies(s):
r = ''
<|fim_suffix... | code_fim | hard | {
"lang": "python",
"repo": "matslindh/codingchallenges",
"path": "/knowit2019/05.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crockeo/semantixist path: /lib/core.py
from typing import Any
from typing import List
from typing import Optional
import uuid
class Token:
"""
Superclass for each token that can appear in a sentence.
"""
def __str__(self):
return self.serialize()
def __repr__(self)... | code_fim | hard | {
"lang": "python",
"repo": "crockeo/semantixist",
"path": "/lib/core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def serialize(self) -> str:
return ' '.join([token.serialize() for token in self.tokens])
class Function(Token):
"""
Basic implemenetation of a lambda function
"""
def __init__(self, variable: Variable, statement: Statement):
self.variable = variable
self.sta... | code_fim | hard | {
"lang": "python",
"repo": "crockeo/semantixist",
"path": "/lib/core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: videowala/python-unsplash path: /unsplash/search.py
from unsplash.client import Client
from unsplash.models import Photo as PhotoModel, Collection as CollectionModel, User as UserModel
class Search(Client):
"""Unsplash Search operations."""
def __init__(self, **kwargs):
super(S... | code_fim | hard | {
"lang": "python",
"repo": "videowala/python-unsplash",
"path": "/unsplash/search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param query [string]: Search terms.
:param page [integer]: Page number to retrieve. (Optional; default: 1)
:param per_page [integer]: Number of items per page. (Optional; default: 10)
:return: [dict]: {u'total': 0, u'total_pages': 0, u'results': [Collection]}
"""
... | code_fim | hard | {
"lang": "python",
"repo": "videowala/python-unsplash",
"path": "/unsplash/search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rustytwilight/sandypi path: /dev_tools/update_frontend_version_hash.py
import subprocess
def get_commit_shash():
result = subprocess.check_output(['git', 'log', '--pretty=format:"%h"', "-n", "1"])
return result.decode(encoding="UTF-8").replace('"', '')
# This script save the curre... | code_fim | medium | {
"lang": "python",
"repo": "rustytwilight/sandypi",
"path": "/dev_tools/update_frontend_version_hash.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>lines = [
"/* THIS FILE IS GENERATED WITH THE FOLLOWING UTIL: */\n",
"/* dev_tools/update_frontend_version.py*/\n",
"/* Have a look there if you need to put additional variables */\n\n",
"REACT_APP_VERSION = {}".format(get_commit_shash())] # start the server
with open(file_... | code_fim | hard | {
"lang": "python",
"repo": "rustytwilight/sandypi",
"path": "/dev_tools/update_frontend_version_hash.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_sources(input_dir):
with open(os.path.join(input_dir, SOURCES_ID_FILE)) as f:
return json.load(f)
def get_destinations(input_dir):
with open(os.path.join(input_dir, DESTS_ID_FILE)) as f:
return json.load(f)<|fim_prefix|># repo: crs4/health-gateway path: /docker/environm... | code_fim | medium | {
"lang": "python",
"repo": "crs4/health-gateway",
"path": "/docker/environments/dispatcher_performance/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crs4/health-gateway path: /docker/environments/dispatcher_performance/common.py
import json
import subprocess
import os
PROFILE_FILE = 'profile.json'
SOURCES_ID_FILE = 'sources_id.json'
DESTS_ID_FILE = 'dests_id.json'
FRONTEND_FIXTURES_FILE = 'frontend_fixtures.json'
FLOW_REQUEST_DATA_FILE = 'f... | code_fim | medium | {
"lang": "python",
"repo": "crs4/health-gateway",
"path": "/docker/environments/dispatcher_performance/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_destinations(input_dir):
with open(os.path.join(input_dir, DESTS_ID_FILE)) as f:
return json.load(f)<|fim_prefix|># repo: crs4/health-gateway path: /docker/environments/dispatcher_performance/common.py
import json
import subprocess
import os
PROFILE_FILE = 'profile.json'
SOURCES_ID... | code_fim | hard | {
"lang": "python",
"repo": "crs4/health-gateway",
"path": "/docker/environments/dispatcher_performance/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JC6/coursera-py4e-assignments path: /chapter_03/assignment_3_1.py
hrs = input("Enter Hours:")
h = float(h<|fim_suffix|>t(rate)
if h < 40:
print(h * r)
else:
print(40 * r + (h - 40) * r * 1.5)<|fim_middle|>rs)
rate = input("Enter Rate:")
r = floa | code_fim | easy | {
"lang": "python",
"repo": "JC6/coursera-py4e-assignments",
"path": "/chapter_03/assignment_3_1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:
print(40 * r + (h - 40) * r * 1.5)<|fim_prefix|># repo: JC6/coursera-py4e-assignments path: /chapter_03/assignment_3_1.py
hrs = input("Enter Hours:")
h = float(h<|fim_middle|>rs)
rate = input("Enter Rate:")
r = float(rate)
if h < 40:
print(h * r)
else | code_fim | medium | {
"lang": "python",
"repo": "JC6/coursera-py4e-assignments",
"path": "/chapter_03/assignment_3_1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return '%s' % (self.product_name)
class Rental(models.Model):
customer = models.ForeignKey(amod.User)
rental_item = models.ForeignKey(Catalog_Item)
date_out = models.DateField(auto_now=False, auto_now_add=False, null=True)
expected_return = models.DateFie... | code_fim | hard | {
"lang": "python",
"repo": "brayden2544/Mystuff-final",
"path": "/static_files/manage/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brayden2544/Mystuff-final path: /static_files/manage/models.py
from django.db import models
from account.models import User
from django.conf import settings
from django.utils import timezone
from account import models as amod
class Store(models.Model):
active = models.BooleanField(defau... | code_fim | hard | {
"lang": "python",
"repo": "brayden2544/Mystuff-final",
"path": "/static_files/manage/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class BalanceSheetAccounts(models.Model):
account_name = models.CharField(max_length=200, blank=True, null=True)
class Inventory(BalanceSheetAccounts):
balance = models.DecimalField(max_digits=20, decimal_places=2, blank=True, null=True)
class Cash(BalanceSheetAccounts):
balan... | code_fim | hard | {
"lang": "python",
"repo": "brayden2544/Mystuff-final",
"path": "/static_files/manage/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>plt.pie(values, labels=labels, colors=colors, explode = explode, startangle=90, autopct='%.1f%%' )
plt.title("EUROPE", pad=10)
# generate the chart
plt.show()<|fim_prefix|># repo: jieunn01/Baek_J_DataViz_GrB_Fall2020 path: /data/continent_europe.py
import matplotlib.pyplot as plt
values = [457, 280, 28... | code_fim | easy | {
"lang": "python",
"repo": "jieunn01/Baek_J_DataViz_GrB_Fall2020",
"path": "/data/continent_europe.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jieunn01/Baek_J_DataViz_GrB_Fall2020 path: /data/continent_europe.py
import matplotlib.pyplot as plt
values = [457, 280, 285, 433, 360, 434]
labels = ["Norway", "Austria", "Switzerland", "Sweden", "Germany", "Finland"]
colors = ['#992B89','#A54C99', "#BA65AE", "#D388C8", "#EAACE1", "#FCCDF5"]
<... | code_fim | easy | {
"lang": "python",
"repo": "jieunn01/Baek_J_DataViz_GrB_Fall2020",
"path": "/data/continent_europe.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: espnet/espnet path: /espnet2/asr/postencoder/length_adaptor_postencoder.py
#!/usr/bin/env python3
# 2021, University of Stuttgart; Pavel Denisov
# Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""Length adaptor PostEncoder."""
from typing import Optional, Tuple
import torch
from ... | code_fim | hard | {
"lang": "python",
"repo": "espnet/espnet",
"path": "/espnet2/asr/postencoder/length_adaptor_postencoder.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def forward(
self, input: torch.Tensor, input_lengths: torch.Tensor
) -> Tuple[torch.Tensor, torch.Tensor]:
"""Forward."""
if input.size(1) < self.length_adaptor_ratio:
raise TooShortUttError(
f"has {input.size(1)} frames and is too short for sub... | code_fim | hard | {
"lang": "python",
"repo": "espnet/espnet",
"path": "/espnet2/asr/postencoder/length_adaptor_postencoder.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def create_instance(config, logger = default_logger):
producer = None
try:
producer_type = config["MQ_TYPE"]
producer_class = CocoProducerManager.CONSUMER_CLASS[producer_type]
sub_config = config[producer_type]
producer... | code_fim | medium | {
"lang": "python",
"repo": "likexx/cocotask",
"path": "/cocotask/producer_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
CONSUMER_CLASS = {
"RMQ": CocoRMQProducer,
"KAFKA": CocoKafkaProducer,
"REDIS": CocoRedisProducer
}
@staticmethod
def create_instance(config, logger = default_logger):
producer = None
try:
producer_type = config["MQ_TYPE"]
... | code_fim | medium | {
"lang": "python",
"repo": "likexx/cocotask",
"path": "/cocotask/producer_manager.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: likexx/cocotask path: /cocotask/producer_manager.py
from .rabbitmq.rmq_producer import CocoRMQProducer
from .kafka.kafka_producer import CocoKafkaProducer
from .redis.redis_producer import CocoRedisProducer
import logging
default_logger = logging.getLogger(__name__)
class CocoProducerManager(obj... | code_fim | hard | {
"lang": "python",
"repo": "likexx/cocotask",
"path": "/cocotask/producer_manager.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grimm-co/angr path: /angr/engines/failure.py
from .engine import SimEngine
import logging
l = logging.getLogger("angr.engines.failure")
class SimEngineFailure(SimEngine): #pylint:disable=abstract-method
def __init__(self, project):
super(SimEngineFailure, self).__init__()
... | code_fim | hard | {
"lang": "python",
"repo": "grimm-co/angr",
"path": "/angr/engines/failure.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __setstate__(self, state):
super(SimEngineFailure, self).__setstate__(state)
self.project = state['project']
def __getstate__(self):
s = super(SimEngineFailure, self).__getstate__()
s['project'] = self.project
return s
from ..errors import AngrExitErro... | code_fim | hard | {
"lang": "python",
"repo": "grimm-co/angr",
"path": "/angr/engines/failure.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CMWENLIU/fast_tensor path: /exp/google_image_download.py
from google_images_download import google_images_download #importing the library
<|fim_suffix|>arguments = {"keywords":"otc drug,baloons,Beaches","limit":20,"print_urls":True} #creating list of arguments
paths = response.download(ar... | code_fim | medium | {
"lang": "python",
"repo": "CMWENLIU/fast_tensor",
"path": "/exp/google_image_download.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>arguments = {"keywords":"otc drug,baloons,Beaches","limit":20,"print_urls":True} #creating list of arguments
paths = response.download(arguments) #passing the arguments to the function
print(paths) #printing absolute paths of the downloaded images<|fim_prefix|># repo: CMWENLIU/fast_tensor path: /... | code_fim | medium | {
"lang": "python",
"repo": "CMWENLIU/fast_tensor",
"path": "/exp/google_image_download.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># print("%.10f %.10f %.10f"%pos(-math.pi/6, 85.0/180*math.pi, 6))
# print("%.10f %.10f %.10f"%pos(math.pi/2, 85.0/180*math.pi, 6))
C = (-2, 2, 0.5)
N = (0.6, 1, -0.6)
plane = -2
dis = (plane - C[2]) / N[2]
print("dis=%.3f\n"%dis)
C = np.array(C, dtype=np.float)
N = np.array(N, dtype=np.float)
O = C + dis ... | code_fim | medium | {
"lang": "python",
"repo": "lazycal/Progressive-Photon-Mapping",
"path": "/scenes/scene.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lazycal/Progressive-Photon-Mapping path: /scenes/scene.py
import numpy as np
import math
def pos(theta, phi, r, O = np.zeros(shape=(1,3),dtype=np.float)):
<|fim_suffix|># print("%.10f %.10f %.10f"%pos(-math.pi/6, 85.0/180*math.pi, 6))
# print("%.10f %.10f %.10f"%pos(math.pi/2, 85.0/180*math.pi, 6... | code_fim | medium | {
"lang": "python",
"repo": "lazycal/Progressive-Photon-Mapping",
"path": "/scenes/scene.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class WBrowser(GingaPlugin.GlobalPlugin):
def __init__(self, fv):
# superclass defines some variables for us, like logger
super(WBrowser, self).__init__(fv)
self.browser = None
def build_gui(self, container):
if not has_webkit:
self.browser = QtGui.QL... | code_fim | hard | {
"lang": "python",
"repo": "migueldvb/ginga",
"path": "/ginga/qtw/plugins/WBrowser.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.entry = QtGui.QLineEdit()
cw.layout().addWidget(self.entry, stretch=0)
self.entry.returnPressed.connect(self.browse_cb)
btns = QtHelp.HBox()
layout = btns.layout()
layout.setSpacing(3)
btn = QtGui.QPushButton("Close")
btn.clicked.conne... | code_fim | hard | {
"lang": "python",
"repo": "migueldvb/ginga",
"path": "/ginga/qtw/plugins/WBrowser.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: migueldvb/ginga path: /ginga/qtw/plugins/WBrowser.py
#
# WBrowser.py -- Web Browser plugin for fits viewer
#
# This is open-source software licensed under a BSD license.
# Please see the file LICENSE.txt for details.
#
import sys, os
from ginga import GingaPlugin
from ginga.qtw.QtHelp import QtG... | code_fim | hard | {
"lang": "python",
"repo": "migueldvb/ginga",
"path": "/ginga/qtw/plugins/WBrowser.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __rand__(self, other):
# This method should never be called if the left hand operand is a MultipleTableCoordinate
if not isinstance(other, BaseTableCoordinate) or isinstance(other, MultipleTableCoordinate):
return NotImplemented
return type(self)(*([other] + se... | code_fim | hard | {
"lang": "python",
"repo": "mwest007/ndcube",
"path": "/ndcube/extra_coords/table_coord.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mwest007/ndcube path: /ndcube/extra_coords/table_coord.py
ractmethod
def is_scalar(self):
"""
Return a boolean if this coordinate is a scalar.
This is used by `.MultipleTableCoordinate` and `.ExtraCoords` to know
if the dimension has been "dropped".
""... | code_fim | hard | {
"lang": "python",
"repo": "mwest007/ndcube",
"path": "/ndcube/extra_coords/table_coord.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mwest007/ndcube path: /ndcube/extra_coords/table_coord.py
s import SkyCoord
from astropy.modeling import models
from astropy.modeling.models import tabular_model
from astropy.time import Time
from astropy.wcs.wcsapi.wrappers.sliced_wcs import combine_slices, sanitize_slices
__all__ = ['TimeTable... | code_fim | hard | {
"lang": "python",
"repo": "mwest007/ndcube",
"path": "/ndcube/extra_coords/table_coord.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhengnengjin/mindspore path: /tests/st/ops/custom_ops_tbe/conv2d.py
# Copyright 2020 Huawei Technologies Co., Ltd
#
# 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
#
# ht... | code_fim | hard | {
"lang": "python",
"repo": "zhengnengjin/mindspore",
"path": "/tests/st/ops/custom_ops_tbe/conv2d.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
-------
tvm compute
"""
shape_w = []
for i in weights.op.attrs['ori_shape']:
shape_w.append(i.value)
format_w = weights.op.attrs['ori_format']
if format_w == "NCHW":
weight_h = shape_w[2]
weight_w = shape_w[3]
elif format_w == "NHWC":
... | code_fim | hard | {
"lang": "python",
"repo": "zhengnengjin/mindspore",
"path": "/tests/st/ops/custom_ops_tbe/conv2d.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stjordanis/autogluon path: /core/tests/unittests/utils/decorators/test_presets.py
import unittest
from autogluon.core.utils.decorators import apply_presets
class TestPresets(unittest.TestCase):
def test_presets(self):
presets_dict = dict(preset_1=dict(a=2, b=3))
@apply_pre... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/autogluon",
"path": "/core/tests/unittests/utils/decorators/test_presets.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # assert preset alias works
out = get_presets(presets="preset_1_alias")
assert out["presets"] == "preset_1_alias"
assert out["a"] == 2
assert out["b"] == 3
assert len(out) == 3
# assert ValueError raised if alias points to invalid preset
sel... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/autogluon",
"path": "/core/tests/unittests/utils/decorators/test_presets.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: comeweber/coremltools path: /coremltools/converters/mil/mil/ops/tests/test_const.py
# Copyright (c) 2020, Apple Inc. All rights reserved.
#
# Use of this source code is governed by a BSD-3-clause license that can be
# found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Cl... | code_fim | hard | {
"lang": "python",
"repo": "comeweber/coremltools",
"path": "/coremltools/converters/mil/mil/ops/tests/test_const.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> expected_output_types = (4, 2, types.fp32)
expected_outputs = t + constant.astype(np.float32)
run_compare_builder(
build,
input_placeholders,
input_values,
expected_output_types,
expected_outputs,
compute_unit... | code_fim | hard | {
"lang": "python",
"repo": "comeweber/coremltools",
"path": "/coremltools/converters/mil/mil/ops/tests/test_const.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> result.stdout.fnmatch_lines("collected 1 item")
result.assert_outcomes(passed=1)
def test_auto_collect_tests_disabled(auto_collect_test_dir, testdir):
result = testdir.runpytest()
result.stdout.fnmatch_lines("collected 0 items")<|fim_prefix|># repo: uriyyo/pytest-bdd path: /tests/featu... | code_fim | hard | {
"lang": "python",
"repo": "uriyyo/pytest-bdd",
"path": "/tests/feature/test_auto_collect.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = testdir.runpytest()
result.stdout.fnmatch_lines("collected 0 items")<|fim_prefix|># repo: uriyyo/pytest-bdd path: /tests/feature/test_auto_collect.py
"""Auto collect tests."""
import pytest
import textwrap
@pytest.fixture
def auto_collect_test_dir(testdir):
dirname = "test_auto_c... | code_fim | hard | {
"lang": "python",
"repo": "uriyyo/pytest-bdd",
"path": "/tests/feature/test_auto_collect.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uriyyo/pytest-bdd path: /tests/feature/test_auto_collect.py
"""Auto collect tests."""
import pytest
import textwrap
@pytest.fixture
def auto_collect_test_dir(testdir):
dirname = "test_auto_collect"
tests = testdir.mkpydir(dirname)
tests.join("foo.feature").write(
textwrap.... | code_fim | medium | {
"lang": "python",
"repo": "uriyyo/pytest-bdd",
"path": "/tests/feature/test_auto_collect.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: craigstar/bigData path: /preprocess.py
import logging
import ml
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
# # 1. Extract reviews and ratings from original json file
# # Within this step, you will get 'train_data.json', 'validate_data.json', 'rev... | code_fim | medium | {
"lang": "python",
"repo": "craigstar/bigData",
"path": "/preprocess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># 3. Train review sentenses to vectors
ml.d2v_train(test=False, combine=True)<|fim_prefix|># repo: craigstar/bigData path: /preprocess.py
import logging
import ml
logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO)
# # 1. Extract reviews and ratings from original... | code_fim | medium | {
"lang": "python",
"repo": "craigstar/bigData",
"path": "/preprocess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fb = device.add_framebuffer(width, height, fmt, 0,
dumb, dumb.pitch, 0, 0)
for plane in device.planes:
if plane.crtc == connector.encoder.crtc:
p... | code_fim | hard | {
"lang": "python",
"repo": "thierryreding/python-drm",
"path": "/src/drm/tools/kms-modetest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for node in drm.devices():
if isinstance(node, drm.CardDevice):
device = node.open()
device.set_capability(drm.ClientCapability.UNIVERSAL_PLANES, True)
device.get_resources()
if device.connectors:
for connector in device.connect... | code_fim | hard | {
"lang": "python",
"repo": "thierryreding/python-drm",
"path": "/src/drm/tools/kms-modetest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thierryreding/python-drm path: /src/drm/tools/kms-modetest.py
#!/usr/bin/python3
import cairo, drm, time
class Pattern:
def draw(self, cr, width, height):
pass
class SMPTE(Pattern):
def draw(self, cr, width, height):
class Column:
def __init__(self, width, c... | code_fim | hard | {
"lang": "python",
"repo": "thierryreding/python-drm",
"path": "/src/drm/tools/kms-modetest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lafriedman/data-automation-project path: /transform-data/ACS_1yr_B17024_t_overview.py
#make overview table - percent of children and youth living below the poverty level
#create vars for Google Drive ids
googleDriveIDForImport = 'insert_here'
googleDriveIDForExport = 'insert_here'
<|fim_suffix|... | code_fim | hard | {
"lang": "python",
"repo": "lafriedman/data-automation-project",
"path": "/transform-data/ACS_1yr_B17024_t_overview.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#reorder columns
child_poverty_overview_cols = ['Austin', 'Travis County', 'Austin-Round Rock MSA', 'Texas', 'US']
child_poverty_overview = child_poverty_overview[child_poverty_overview_cols]
#convert df to csv
child_poverty_overview.to_csv('Youth_OverviewData_' + str(latest_data_year) + '.csv', sep='\t'... | code_fim | hard | {
"lang": "python",
"repo": "lafriedman/data-automation-project",
"path": "/transform-data/ACS_1yr_B17024_t_overview.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def update_trades():
try:
et = stock_utils.get_recently_trade_date()
st = ConfigUtils.get_stock("START_DATE")
# 登陆系统 ####
lg = bs.login()
# 显示登陆返回信息
print('login respond error_code:' + lg.error_code + ', error_msg:' + lg.error_msg)
pd_names = pd... | code_fim | hard | {
"lang": "python",
"repo": "learnerzhang/trade",
"path": "/api_modules/server/pipeline/syncup_data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: learnerzhang/trade path: /api_modules/server/pipeline/syncup_data.py
# -*- encoding: UTF-8 -*-
from api_modules.server.utils import stock_utils
from api_modules.server.utils.config import ConfigUtils
from multiprocessing import Pool
import baostock as bs
import pandas as pd
import logging
import ... | code_fim | hard | {
"lang": "python",
"repo": "learnerzhang/trade",
"path": "/api_modules/server/pipeline/syncup_data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.route("/", methods = ['GET'])
def hello():
return "Hello BERT predicting Scores! Try posting a string to this url"
@app.route("/", methods = ['POST'])
def predict():
# MODEL PARAMS
max_seq_length = 128
channel = grpc.insecure_channel("bert-scores:8500")
stub = prediction_service_pb2_grpc... | code_fim | medium | {
"lang": "python",
"repo": "saurabhnlp/bert",
"path": "/run_app.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Parse Description
tokenizer = tokenization.FullTokenizer(
vocab_file="asset/vocab.txt", do_lower_case=True)
processor = classifiers.CompetencyProcessor()
label_list = processor.get_labels()
content = request.get_json()
request_id = str(random.randint(1, 9223372036854775807))
inputExamp... | code_fim | medium | {
"lang": "python",
"repo": "saurabhnlp/bert",
"path": "/run_app.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saurabhnlp/bert path: /run_app.py
import grpc
import tensorflow as tf
import run_classifier as classifiers
import tokenization
from tensorflow_serving.apis import predict_pb2
from tensorflow_serving.apis import prediction_service_pb2_grpc
from tensorflow.core.framework import tensor_pb2
from t... | code_fim | medium | {
"lang": "python",
"repo": "saurabhnlp/bert",
"path": "/run_app.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@main.command("check")
@click.pass_obj
def check(client: Client):
"""Check the library for consistency and completeness."""
pass
@main.command("metadata")
@click.option(
"-m",
"--modify",
is_flag=True,
help="Modify metadata in editor and update files with changes.",
)
@click.opti... | code_fim | hard | {
"lang": "python",
"repo": "cassava/mpd-remote",
"path": "/mpd_remote/__main__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cassava/mpd-remote path: /mpd_remote/__main__.py
from typing import Union, Set
import logging
import sys
import os
from pathlib import Path
import click
from .backend import Client
from .remotes import DenonRC1223
from .organize import EditableDatabase
@click.group()
@click.pass_context
@clic... | code_fim | hard | {
"lang": "python",
"repo": "cassava/mpd-remote",
"path": "/mpd_remote/__main__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: test-mass-forker-org-1/quilla path: /src/quilla/plugins/blob_storage.py
from typing import (
Optional,
cast,
)
from argparse import (
ArgumentParser,
Namespace
)
from datetime import datetime
from azure.storage.blob import ContainerClient
from .base_storage import BaseStorage
... | code_fim | hard | {
"lang": "python",
"repo": "test-mass-forker-org-1/quilla",
"path": "/src/quilla/plugins/blob_storage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return blob.url
def store_treatment_image(self, run_id: str, baseline_id: str, treatment: bytes) -> str:
blob = self.container_client.get_blob_client(f'runs/{run_id}/{baseline_id}_treatment.png')
blob.upload_blob(treatment)
return blob.url
def make_baseline_uri(s... | code_fim | hard | {
"lang": "python",
"repo": "test-mass-forker-org-1/quilla",
"path": "/src/quilla/plugins/blob_storage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def make_baseline_uri(self, run_id: str, baseline_id: str) -> str:
baseline_data = self.find_image_by_baseline(baseline_id)
blob = self.container_client.get_blob_client(f'runs/{run_id}/{baseline_id}.png')
blob.upload_blob(baseline_data)
return blob.url
def cleanu... | code_fim | hard | {
"lang": "python",
"repo": "test-mass-forker-org-1/quilla",
"path": "/src/quilla/plugins/blob_storage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def load_pickle(path, check=True):
if check:
assert path.exists(), print(f"{str(path)} not found!")
with open(path, 'rb') as fp:
return pkl.load(fp)
def save_pickle(path, data, check=True):
if check:
assert path.parent.exists(), print(f"{str(path.parent)} not found!"... | code_fim | hard | {
"lang": "python",
"repo": "ds4dm/nectar",
"path": "/nectar/utils/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
@abstractmethod
def make_two_sip_model(self, use_xi_bar=False):
pass
@abstractmethod
def make_second_stage_model(self, sol, xi):
pass
@abstractmethod
def solve_two_sip(self, gap=0.02, time_limit=600, threads=2):
pass
@abstractmethod
... | code_fim | hard | {
"lang": "python",
"repo": "ds4dm/nectar",
"path": "/nectar/utils/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ds4dm/nectar path: /nectar/utils/__init__.py
import hashlib
import pickle as pkl
from abc import ABC, abstractmethod
def create_config_hash(config):
"""Create a hash based on configuration values
Creating a unique hash based on the values of the configuration
helps us define a scop... | code_fim | medium | {
"lang": "python",
"repo": "ds4dm/nectar",
"path": "/nectar/utils/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # double check it's indeed a single mutant
mutpos_codon_list = [int(i) // 3 for i in mutpos_to_base]
mutpos_codon_list = mutpos_codon_list
assert (
len(set(mutpos_codon_list)) == 1
), "mutation from mut_str found not in the same c... | code_fim | hard | {
"lang": "python",
"repo": "ddingding/coevolution_mechanism",
"path": "/src/mutTools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ddingding/coevolution_mechanism path: /src/mutTools.py
# mutTools
# set of functions to use for manipulating biological sequences, fasta files, mutation strings, ...
import numpy as np
import operator
import matplotlib.pyplot as plt
from itertools import groupby
from collections import defaultdi... | code_fim | hard | {
"lang": "python",
"repo": "ddingding/coevolution_mechanism",
"path": "/src/mutTools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class_din, df_config, dout="./", template="pare", max_samples_read=100000000
):
# get a dictionary of pairs of files that belong to the same sample
fs = [f for f in listdir(class_din) if f.endswith("class.tsv")]
dic_id_to_fs = {}
for f in fs:
primer, at_mut, _ = f.split("_")
... | code_fim | hard | {
"lang": "python",
"repo": "ddingding/coevolution_mechanism",
"path": "/src/mutTools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # BadArgumentエラー
elif isinstance(error, commands.BadArgument):
# どのコマンドの引数が悪かったのかチェック
# まだ未実装
#if ctx.command.qualified_name == 'ping':
#await ctx.send('入力したコマンドの引数が無効です')
return
# MissingPermiss... | code_fim | hard | {
"lang": "python",
"repo": "haru-works/discord-bot-test",
"path": "/cogs/command_error_handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: haru-works/discord-bot-test path: /cogs/command_error_handler.py
import discord
from discord.ext import commands
import traceback
import sys
# コマンドエラーハンドラークラス
class CommandErrorHandler(commands.Cog):
# コンストラクタ
def __init__(self, bot):
self.bot = bot
# コマンドエラーイベント検知 ... | code_fim | hard | {
"lang": "python",
"repo": "haru-works/discord-bot-test",
"path": "/cogs/command_error_handler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # DisabledCommandエラー
if isinstance(error, commands.DisabledCommand):
await ctx.send(f'{ctx.command} のコマンドは無効です')
# NoPrivateMessageエラー
elif isinstance(error, commands.NoPrivateMessage):
try:
await ctx.author.send(f'{ctx.c... | code_fim | hard | {
"lang": "python",
"repo": "haru-works/discord-bot-test",
"path": "/cogs/command_error_handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kixus/hytest path: /hytest
#!/usr/bin/env python
# A little wrapper over HyTest
<|fim_suffix|>if __name__ == '__main__':
res = main(*sys.argv)
if is_integer(res):
sys.exit(res)<|fim_middle|>import sys
from hy.core.language import is_integer
from hytest import main, load_tests
| code_fim | medium | {
"lang": "python",
"repo": "kixus/hytest",
"path": "/hytest",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
res = main(*sys.argv)
if is_integer(res):
sys.exit(res)<|fim_prefix|># repo: kixus/hytest path: /hytest
#!/usr/bin/env python
# A little wrapper over HyTest
<|fim_middle|>import sys
from hy.core.language import is_integer
from hytest import main, load_tests
| code_fim | medium | {
"lang": "python",
"repo": "kixus/hytest",
"path": "/hytest",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nanoonyx/sleepecg path: /sleepecg/test/test_heartbeat_detection.py
# Authors: Florian Hofer
#
# License: BSD (3-clause)
"""Tests for heartbeat detection C extension."""
import sys
import numpy as np
import pytest
pytestmark = pytest.mark.c_extension
def test_squared_moving_integration_args(... | code_fim | hard | {
"lang": "python",
"repo": "nanoonyx/sleepecg",
"path": "/sleepecg/test/test_heartbeat_detection.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert sys.getrefcount(filtered_ecg) == filtered_ecg_refcount
assert sys.getrefcount(integrated_ecg) == integrated_ecg_refcount
@pytest.mark.parametrize(
['filtered_ecg', 'integrated_ecg', 'fs'],
[
(np.zeros((5, 5)), np.arange(5), 10),
(np.array(5), np.arange(5), 10),
... | code_fim | hard | {
"lang": "python",
"repo": "nanoonyx/sleepecg",
"path": "/sleepecg/test/test_heartbeat_detection.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def stop(self):
if hasattr(self, 'shutdown'):
self.shutdown()
else:
self.server_close()
print("Server stopped")
if __name__ == '__main__':
fs = FileServer()
fs.start()
while True:
time.sleep(10)
# fs.stop()<|fim_prefix|># repo: mg... | code_fim | hard | {
"lang": "python",
"repo": "mgladki/remoteswinglibrary",
"path": "/src/test/robotframework/acceptance/webstart/FileServer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mgladki/remoteswinglibrary path: /src/test/robotframework/acceptance/webstart/FileServer.py
from __future__ import print_function
import sys
IS_PYTHON3 = sys.version_info[0] >= 3
if IS_PYTHON3:
from http.server import SimpleHTTPRequestHandler
from socketserver import TCPServer, ThreadingM... | code_fim | hard | {
"lang": "python",
"repo": "mgladki/remoteswinglibrary",
"path": "/src/test/robotframework/acceptance/webstart/FileServer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: afcarl/QuestionAnsweringGCN path: /example_extender/remove_gold_from_all_except_best_mention.py
import numpy as np
class RemoveGoldFromAllExceptBestMention:
inner = None
def __init__(self, inner):
self.inner = inner
def extend(self, example):
example = self.inner.... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/QuestionAnsweringGCN",
"path": "/example_extender/remove_gold_from_all_except_best_mention.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for i,gold_answer in enumerate(example.gold_answers):
entity_indexes = gold_answer.entity_indexes
for index in entity_indexes:
nearby_mentions = example.graph.get_nearby_centroids(index)
for j, mention in enumerate(example.mentions):
... | code_fim | hard | {
"lang": "python",
"repo": "afcarl/QuestionAnsweringGCN",
"path": "/example_extender/remove_gold_from_all_except_best_mention.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: realabbas/convert-youtube-mp3 path: /index.py
import youtube_dl
class you2mp3:
def __init__(self):
self.ydl = youtube_dl.YoutubeDL(self.getOptions())
<|fim_suffix|> def getOptions(self):
return {
'format': 'bestaudio/best',
'postprocessors': [{
... | code_fim | medium | {
"lang": "python",
"repo": "realabbas/convert-youtube-mp3",
"path": "/index.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.ydl.download([url])
downloader = you2mp3()
url = input("Enter Youtube URL: ")
downloader.startDownload(url)<|fim_prefix|># repo: realabbas/convert-youtube-mp3 path: /index.py
import youtube_dl
class you2mp3:
def __init__(self):
self.ydl = youtube_dl.YoutubeDL(self.getOptions()... | code_fim | hard | {
"lang": "python",
"repo": "realabbas/convert-youtube-mp3",
"path": "/index.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> """this is not ok"""
instance = MyClass()
for i in range(10):
if 5 <= i: # [misplaced-comparison-constant]
pass
if 1 == i: # [misplaced-comparison-constant]
pass
if 3 < dummy_return(): # [misplaced-comparison-constant]
pass
... | code_fim | medium | {
"lang": "python",
"repo": "ahmadreza-smdi/ms-shop",
"path": "/.venv/lib/python3.7/site-packages/pylint/test/functional/misplaced_comparison_constant.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 2
def bad_comparisons():
"""this is not ok"""
instance = MyClass()
for i in range(10):
if 5 <= i: # [misplaced-comparison-constant]
pass
if 1 == i: # [misplaced-comparison-constant]
pass
if 3 < dummy_return(): # [misplaced-comparis... | code_fim | medium | {
"lang": "python",
"repo": "ahmadreza-smdi/ms-shop",
"path": "/.venv/lib/python3.7/site-packages/pylint/test/functional/misplaced_comparison_constant.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ahmadreza-smdi/ms-shop path: /.venv/lib/python3.7/site-packages/pylint/test/functional/misplaced_comparison_constant.py
"""Check that the constants are on the right side of the comparisons"""
# pylint: disable=singleton-comparison, missing-docstring, too-few-public-methods, useless-object-inheri... | code_fim | medium | {
"lang": "python",
"repo": "ahmadreza-smdi/ms-shop",
"path": "/.venv/lib/python3.7/site-packages/pylint/test/functional/misplaced_comparison_constant.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sys = massspringdamper.ThreeMass()
sys.plot_linearized_bode()
sys.plot_linearized_pz_map()
sys.x0[2] = 1
sys.plot_trajectory()
sys.animate_simulation()<|fim_prefix|># repo: SherbyRobotics/pyro path: /examples/demos_by_system/mass_spring_damper/three_mass_dynamic.py
# -*- coding: utf-8 -*-
"""
Created... | code_fim | medium | {
"lang": "python",
"repo": "SherbyRobotics/pyro",
"path": "/examples/demos_by_system/mass_spring_damper/three_mass_dynamic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.