text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>ut warranty under the terms of the BSD license
# in the LICENSE file.
__version__ = '0.1'
__requires__ = ['traits']<|fim_prefix|># repo: corranwebster/taupo path: /taupo/__init__.py
# Taupo library code.
#
# Copyright 2014, Corran Webster.
<|fim_middle|># All rights reserved.
#
# This software is provid... | code_fim | easy | {
"lang": "python",
"repo": "corranwebster/taupo",
"path": "/taupo/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> backend : string, (Default="auto")
Which backend to use.
Options are 'auto', 'sklearn', 'h2o4gpu'.
Saves as attribute for actual backend used.
"""
def __init__(
self,
fit_intercept=True, # h2o4gpu
normalize=False,
copy_... | code_fim | hard | {
"lang": "python",
"repo": "pnijhara/h2o4gpu",
"path": "/src/interface_py/h2o4gpu/solvers/linear_regression.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pnijhara/h2o4gpu path: /src/interface_py/h2o4gpu/solvers/linear_regression.py
# - * - encoding : utf - 8 - * -
# pylint: disable=fixme, line-too-long
"""
:copyright: 2017-2018 H2O.ai, Inc.
:license: Apache License Version 2.0 (see LICENSE for details)
"""
# pylint: disable=unused-import
from h2... | code_fim | hard | {
"lang": "python",
"repo": "pnijhara/h2o4gpu",
"path": "/src/interface_py/h2o4gpu/solvers/linear_regression.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hugs-cloud/hugs path: /services/hugs_service/removeobjects.py
def remove_objects(args):
from HUGS.ObjectStore import get_bucket, delete_object
<|fim_suffix|> for key in keys:
delete_object(bucket=bucket, key=key)<|fim_middle|> if "keys" in args:
keys = args["keys"]
... | code_fim | medium | {
"lang": "python",
"repo": "hugs-cloud/hugs",
"path": "/services/hugs_service/removeobjects.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for key in keys:
delete_object(bucket=bucket, key=key)<|fim_prefix|># repo: hugs-cloud/hugs path: /services/hugs_service/removeobjects.py
def remove_objects(args):
from HUGS.ObjectStore import get_bucket, delete_object
<|fim_middle|> if "keys" in args:
keys = args["keys"]
... | code_fim | medium | {
"lang": "python",
"repo": "hugs-cloud/hugs",
"path": "/services/hugs_service/removeobjects.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fundiZX48/pyaiblocker path: /src/replay.py
"""Game replay.
Copyright 2018 Mark Mitterdorfer
Side line application to replay a recorded game session.
"""
import board
import renderer
import pygame
import sys
from pygame.locals import *
import pickle
import argparse
def main():
parser = arg... | code_fim | hard | {
"lang": "python",
"repo": "fundiZX48/pyaiblocker",
"path": "/src/replay.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> winner = game.is_game_over()
if winner:
print("Player", winner, "wins!")
game_over = True
pygame.display.update()
render_update = False
# Handle Pygame events
for event in pygame.event.get():
if e... | code_fim | hard | {
"lang": "python",
"repo": "fundiZX48/pyaiblocker",
"path": "/src/replay.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Handle Pygame events
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
elif event.type == KEYDOWN:
# Move forward with a move
if event.key == K_m:
if... | code_fim | hard | {
"lang": "python",
"repo": "fundiZX48/pyaiblocker",
"path": "/src/replay.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>async def relay(websocket, path):
"""
Count values in the web socket
:param websocket: websocket to communicate on
:param path: Path being used
"""
# register(websocket) sends user_event() to websocket
await register(websocket)
try:
while True:
try:
... | code_fim | hard | {
"lang": "python",
"repo": "artsman/omnis_wsbus",
"path": "/omnis_wsbus/sockets.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: artsman/omnis_wsbus path: /omnis_wsbus/sockets.py
# -*- coding: utf-8 -*-
from asyncio import wait
from json import dumps
from weakref import WeakSet
from websockets import ConnectionClosed
from .app import app
# Bind the web socket tracking to the app
app['websockets'] = WeakSet()
def build... | code_fim | hard | {
"lang": "python",
"repo": "artsman/omnis_wsbus",
"path": "/omnis_wsbus/sockets.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>import textwrap
from ._mudensity.mudensity import calc_mu_density as calculate
from ._mudensity.mudensity import display_mu_density as display
from ._mudensity.mudensity import get_grid as grid
WARNING_MESSAGE = textwrap.dedent(__doc__.split("WARNING::")[-1])<|fim_prefix|># repo: ikevin2810/pymedphys p... | code_fim | hard | {
"lang": "python",
"repo": "ikevin2810/pymedphys",
"path": "/pymedphys/mudensity.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ikevin2810/pymedphys path: /pymedphys/mudensity.py
"""A suite of functions to determine the MU Density for a range of
formats
.. WARNING::
Although this is a useful tool in the toolbox for patient specific
IMRT QA, in and of itself it is not a sufficient replacement for
direct dosimetri... | code_fim | hard | {
"lang": "python",
"repo": "ikevin2810/pymedphys",
"path": "/pymedphys/mudensity.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Furthermore, when the MU Density is calculated off of log files alone
this uses leaf and jaw positions as reported by the Linac which may
not agree with their position in reality due to issues such as a
hardware or calibration fault.
"""
# pylint: disable = unused-import
import textwrap
fro... | code_fim | hard | {
"lang": "python",
"repo": "ikevin2810/pymedphys",
"path": "/pymedphys/mudensity.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: weso/landportal-importers path: /FAOAgriculturalCensuesImporter/es/weso/fao/importer/fao_importer.py
DICATOR", "tnh_topic")
tnh_ind.preferable_tendency = self._parse_preferable_tendency(
self._read_config_value("INDICATOR", "tnh_tendency... | code_fim | hard | {
"lang": "python",
"repo": "weso/landportal-importers",
"path": "/FAOAgriculturalCensuesImporter/es/weso/fao/importer/fao_importer.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _build_indicators_dict(self):
result = {}
number_measure = MeasurementUnit(name = None, convert_to = "units")
area_measure = MeasurementUnit(name = None, convert_to = "sq. km", factor=10)
share_measure = MeasurementUnit(name = None, convert_to = "%")
... | code_fim | hard | {
"lang": "python",
"repo": "weso/landportal-importers",
"path": "/FAOAgriculturalCensuesImporter/es/weso/fao/importer/fao_importer.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xpunch/x-spider path: /xspider/items.py
# -*- coding: utf-8 -*-
# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html
from scrapy import Item, Field
from xspider.itemselastic import WeiboTweetDoc, WeiboUserDoc
class Weib... | code_fim | hard | {
"lang": "python",
"repo": "xpunch/x-spider",
"path": "/xspider/items.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class WeiboUserItem(Item):
_id = Field()
name = Field()
gender = Field()
province = Field()
city = Field()
bio = Field()
birthday = Field()
tweets_count = Field()
follows_count = Field()
followers_count = Field()
sex_orientation = Field()
sentiment = Field(... | code_fim | hard | {
"lang": "python",
"repo": "xpunch/x-spider",
"path": "/xspider/items.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>default_signature_names = [
[CLASSLOAD],
# [CLASSLOAD, BLACKLISTED],
# [CLASSLOAD, NOT, BLACKLISTED],
[CLASSLOAD, NULL_LOADER],
[CLASSLOAD, NULL_LOADER_NAME],
[CLASSLOAD, NULL_LOADER, NOT, NULL_PD],
[CLASSLOAD, NULL_LOADER_NAME, NOT, NULL_PD],
[CLASSLOAD, NOT, NULL_LOADER, ... | code_fim | hard | {
"lang": "python",
"repo": "p27mcgee/buggin",
"path": "/src/python/debuglog/buggin.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> filter_log(src_log, makeLogPath(output_dir, log_ext, *signature_names), lambda line: applyFilters(line, signature_map, *signature_names))
print()
NOT = "not"
CLASSLOAD = "classload"
BLACKLISTED = "blacklisted"
NULL_LOADER = "nullloader"
NULL_LOADER_NAME = "nullname"
PLATFORM_LOADER = "platformloa... | code_fim | hard | {
"lang": "python",
"repo": "p27mcgee/buggin",
"path": "/src/python/debuglog/buggin.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: p27mcgee/buggin path: /src/python/debuglog/buggin.py
#!/usr/bin/env python3
from os import path
SKEWER = "-"
def makeLogPath(dir, log_ext, *signature_names):
filename = ""
for signature_name in signature_names:
if filename:
filename += SKEWER
filename += sign... | code_fim | hard | {
"lang": "python",
"repo": "p27mcgee/buggin",
"path": "/src/python/debuglog/buggin.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: broadinstitute/cromshell path: /tests/integration/test_abort.py
import pytest
from cromshell.utilities.workflow_status_utils import WorkflowStatuses
from tests.integration import utility_test_functions
<|fim_suffix|> @pytest.mark.parametrize(
"wdl, json_file",
[
(... | code_fim | hard | {
"lang": "python",
"repo": "broadinstitute/cromshell",
"path": "/tests/integration/test_abort.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> utility_test_functions.wait_for_workflow_completion(
test_workflow_id=test_workflow_id,
status_to_reach=WorkflowStatuses.ABORTED.value,
)<|fim_prefix|># repo: broadinstitute/cromshell path: /tests/integration/test_abort.py
import pytest
from cromshell.utilities.wo... | code_fim | hard | {
"lang": "python",
"repo": "broadinstitute/cromshell",
"path": "/tests/integration/test_abort.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MeHelmy/princess path: /scripts/phasing_report_update_vcf.py
#!/usr/bin/env python3
"""
bamtools merge should be used before this script. where the vcf file should be merged with both paternal and maternal, respectively.
"""
import argparse
import sys, re
def get_args():
parser = argparse.A... | code_fim | hard | {
"lang": "python",
"repo": "MeHelmy/princess",
"path": "/scripts/phasing_report_update_vcf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def is_not_conflict(block_snp_list, args):
all_snps_in_block = sum(block_snp_list)
if all_snps_in_block >= args.min_snps:
# assuming that the list is formed like that F0|1 F1|0 M0|1 M1|0
tolerance_percentage = args.tolerance * all_snps_in_block/100 # tolerance is 5%
index_... | code_fim | hard | {
"lang": "python",
"repo": "MeHelmy/princess",
"path": "/scripts/phasing_report_update_vcf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryansdowning/portfolio_alerts path: /portfolio_alerts.py
import datetime
import time
import numpy as np
from iexfinance import Stock
from twilio.rest import Client
account_sid = # twilio account sid
auth_token = # twilio auth_token
twilio_number = # my twilio number
client = Client(account_si... | code_fim | hard | {
"lang": "python",
"repo": "ryansdowning/portfolio_alerts",
"path": "/portfolio_alerts.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return np.sum(self.current_prices * np.array(self.amounts))
def check_change(self):
self.update_all_prices()
self.new_total = self.get_total()
change = self.new_total - self.todays_open
percent = change / self.todays_open * 100
print('{}: {}'.format(sel... | code_fim | hard | {
"lang": "python",
"repo": "ryansdowning/portfolio_alerts",
"path": "/portfolio_alerts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hl0071/OnlineStore path: /store/migrations/0010_auto_20201212_2058.py
# Generated by Django 3.1.3 on 2020-12-12 18:58
from django.db import migrations, models
import store.validators
<|fim_suffix|> dependencies = [
('store', '0009_auto_20201212_1226'),
]
operations = [
... | code_fim | medium | {
"lang": "python",
"repo": "hl0071/OnlineStore",
"path": "/store/migrations/0010_auto_20201212_2058.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('store', '0009_auto_20201212_1226'),
]
operations = [
migrations.AlterField(
model_name='watch',
name='name',
field=models.CharField(max_length=20),
),
migrations.AlterField(
model_name='watch',
... | code_fim | medium | {
"lang": "python",
"repo": "hl0071/OnlineStore",
"path": "/store/migrations/0010_auto_20201212_2058.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def system_tombstone(logcat):
content = logcat.split('\n\n')
if len(content) >= 3:
process = detect_string(content[1], r'\s+>>>\s+(.*)\s+<<<')
signal = detect_string(content[1], r'^(signal\s+\d+\s+\(\w+\),\s+code\s+\d+\s+\(\w+\))')
backtrace = detect_trace(content[2:])
... | code_fim | medium | {
"lang": "python",
"repo": "EthanGuo/error-detect-of-log",
"path": "/ed/system_tombstone.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EthanGuo/error-detect-of-log path: /ed/system_tombstone.py
# -*- coding: utf-8 -*-
import re
from utils import detect_string
def detect_trace(contents):
for content in contents:
if "backtrace:" in content:
return re.findall(r'((?:/.+)+(?: \(.+\))*)', content)
<|fim_suf... | code_fim | medium | {
"lang": "python",
"repo": "EthanGuo/error-detect-of-log",
"path": "/ed/system_tombstone.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>result = 1
for i in range(9, 0, -1):
result *= N + i
result %= m
result *= pow(i, -1, m)
result %= m
print(result)<|fim_prefix|># repo: c-yan/yukicoder path: /yc201/741-1.py
N = int(input())
<|fim_middle|>m = 1000000007
| code_fim | easy | {
"lang": "python",
"repo": "c-yan/yukicoder",
"path": "/yc201/741-1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: c-yan/yukicoder path: /yc201/741-1.py
N = int(input())
<|fim_suffix|>result = 1
for i in range(9, 0, -1):
result *= N + i
result %= m
result *= pow(i, -1, m)
result %= m
print(result)<|fim_middle|>m = 1000000007
| code_fim | easy | {
"lang": "python",
"repo": "c-yan/yukicoder",
"path": "/yc201/741-1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yangyi0318/raylab path: /tests/raylab/torch/nn/distributions/utils.py
# pylint:disable=missing-docstring
import torch
def _test_dist_ops(dist, params, batch_shape, event_shape, sample_shape):
# pylint:disable=too-many-arguments
sample, logp = dist.sample(params, sample_shape)
assert... | code_fim | hard | {
"lang": "python",
"repo": "yangyi0318/raylab",
"path": "/tests/raylab/torch/nn/distributions/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sample, logp = dist.deterministic(params)
if not torch.isnan(sample).any():
assert sample.shape == batch_shape + event_shape
assert logp.shape == batch_shape<|fim_prefix|># repo: yangyi0318/raylab path: /tests/raylab/torch/nn/distributions/utils.py
# pylint:disable=missing-docstri... | code_fim | hard | {
"lang": "python",
"repo": "yangyi0318/raylab",
"path": "/tests/raylab/torch/nn/distributions/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_3_model():
headers = ['f1', 'f2', 'f3']
rows = []
####model setting start######
model_name = 'xception' # 'inceptionv4'#'senet154'#
model = pretrainedmodels.__dict__[model_name](num_classes=1000, pretrained='imagenet')
dim_feats = model.last_linear.in_features
nb_clas... | code_fim | hard | {
"lang": "python",
"repo": "liangzuan1983/XueLang",
"path": "/chusai/code/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liangzuan1983/XueLang path: /chusai/code/main.py
########################################################
#### TEAM: VGG19 , MEMBER:Bingyu Xin ####
########################################################
import lightgbm as lgb
import csv
import pandas as pd
import datetime
import ... | code_fim | hard | {
"lang": "python",
"repo": "liangzuan1983/XueLang",
"path": "/chusai/code/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _get_hook_type(vul):
hook_type = HookType.objects.filter(pk=vul['hook_type_id']).first()
if hook_type:
return {'hook_type_name': hook_type.name, 'level_id': vul['level_id']}
def _get_parameters(api_route):
parameters = IastApiParameter.objects.filter(route=api_route).all()
p... | code_fim | hard | {
"lang": "python",
"repo": "Jeromeyoung/DongTai-webapi",
"path": "/iast/views/api_route_search.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jeromeyoung/DongTai-webapi path: /iast/views/api_route_search.py
######################################################################
# @author : bidaya0 (bidaya0@$HOSTNAME)
# @file : api_route_search
# @created : Wednesday Aug 18, 2021 14:31:17 CST
#
# @description :
##########... | code_fim | hard | {
"lang": "python",
"repo": "Jeromeyoung/DongTai-webapi",
"path": "/iast/views/api_route_search.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _get_parameters_type(api_route):
api_route['parameter_type_shortcut'] = api_route['parameter_type'].split(
'.')[-1]
return api_route
def _get_responses(api_route):
responses = IastApiResponse.objects.filter(route=api_route).all()
responses = [model_to_dict(response) for respo... | code_fim | hard | {
"lang": "python",
"repo": "Jeromeyoung/DongTai-webapi",
"path": "/iast/views/api_route_search.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lexibank/pylexibank path: /tests/test_db.py
import pytest
from csvw.metadata import Column
from pylexibank.db import Database, ColSpec, schema
@pytest.fixture
def db(tmp_path):
return Database(tmp_path / 'lexibank.sqlite')
def test_ColSpec():
col = ColSpec(name='c', csvw_type='float'... | code_fim | hard | {
"lang": "python",
"repo": "lexibank/pylexibank",
"path": "/tests/test_db.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_db_multiple_datasets_error(dataset, dataset_factory, db):
import shutil
from clldutils.jsonlib import load, dump
assert not db.fname.exists()
db.load(dataset)
ds_dir = dataset.dir.parent / 'dbtest'
shutil.copytree(str(dataset.dir), str(ds_dir))
# Now modify the CLDF ... | code_fim | hard | {
"lang": "python",
"repo": "lexibank/pylexibank",
"path": "/tests/test_db.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> process(zfile, configfile)<|fim_prefix|># repo: stevecassidy/pyunitgrading path: /scripts/runtests.py
from pyunitgrading import process
import sys
if __name__=='__main__':
<|fim_middle|> if len(sys.argv) != 3:
print("Usage: runtests.py <iLearn Zip file> <config file>")
exit
... | code_fim | medium | {
"lang": "python",
"repo": "stevecassidy/pyunitgrading",
"path": "/scripts/runtests.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stevecassidy/pyunitgrading path: /scripts/runtests.py
from pyunitgrading import process
import sys
<|fim_suffix|> process(zfile, configfile)<|fim_middle|>if __name__=='__main__':
if len(sys.argv) != 3:
print("Usage: runtests.py <iLearn Zip file> <config file>")
exit
... | code_fim | hard | {
"lang": "python",
"repo": "stevecassidy/pyunitgrading",
"path": "/scripts/runtests.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def run(self):
time.sleep(1)
fig, axes = plt.subplots(3, 3)
axes[0, 0].set_title('原始信号')
axes[0, 1].set_title('HP滤波残差')
axes[0, 2].set_title('FFT频谱')
axes[0, 0].set_ylabel('Blue')
axes[1, 0].set_ylabel('Green')
axes[2, 0].set_ylabel('Red... | code_fim | hard | {
"lang": "python",
"repo": "wozu-dichter/MindLink-Explorer",
"path": "/MindLink-Eumpy/heartRate/heartRate_V1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wozu-dichter/MindLink-Explorer path: /MindLink-Eumpy/heartRate/heartRate_V1.py
#!/usr/bin/env python
# coding: utf-8
# In[ ]:
# https://download.csdn.net/download/itnerd/12923042
# https://blog.csdn.net/itnerd/article/details/109078291
import cv2
import traceback
import threading
from queue im... | code_fim | hard | {
"lang": "python",
"repo": "wozu-dichter/MindLink-Explorer",
"path": "/MindLink-Eumpy/heartRate/heartRate_V1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tiagoCuervo/MINE path: /mine/utils.py
import torch
from torch.utils.data import Dataset
<|fim_suffix|> def __len__(self):
return len(self.x)<|fim_middle|>
def logSumExp(x, axis=None):
xMax = torch.max(x, axis)[0]
y = torch.log((torch.exp(x - xMax)).sum(axis)) + xMax
return... | code_fim | hard | {
"lang": "python",
"repo": "tiagoCuervo/MINE",
"path": "/mine/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class RegressionDataset(Dataset):
def __init__(self, xTensor, yTensor):
self.x = xTensor
self.y = yTensor
def __getitem__(self, index):
return self.x[index], self.y[index]
def __len__(self):
return len(self.x)<|fim_prefix|># repo: tiagoCuervo/MINE path: /mine... | code_fim | medium | {
"lang": "python",
"repo": "tiagoCuervo/MINE",
"path": "/mine/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tiagoCuervo/MINE path: /mine/utils.py
import torch
from torch.utils.data import Dataset
def logSumExp(x, axis=None):
xMax = torch.max(x, axis)[0]
y = torch.log((torch.exp(x - xMax)).sum(axis)) + xMax
return y
class RegressionDataset(Dataset):
def __init__(self, xTensor, yTenso... | code_fim | medium | {
"lang": "python",
"repo": "tiagoCuervo/MINE",
"path": "/mine/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: allenai/allennlp-models path: /tests/lm/modules/token_embedders/bidirectional_lm_test.py
from tests import FIXTURES_ROOT
from tests.lm.modules.token_embedders.language_model_test import TestLanguageModelTokenEmbedder
<|fim_suffix|> def setup_method(self):
super().setup_method()
... | code_fim | medium | {
"lang": "python",
"repo": "allenai/allennlp-models",
"path": "/tests/lm/modules/token_embedders/bidirectional_lm_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> super().setup_method()
self.set_up_model(
FIXTURES_ROOT
/ "lm"
/ "language_model"
/ "bidirectional_lm_characters_token_embedder.jsonnet",
FIXTURES_ROOT / "lm" / "conll2003.txt",
)
class TestBidirectionalLanguageModelToke... | code_fim | medium | {
"lang": "python",
"repo": "allenai/allennlp-models",
"path": "/tests/lm/modules/token_embedders/bidirectional_lm_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> u[i * ndof_u:(i + 1) * ndof_u] = ui
sim.set_u(ui)
sim.forward(1, False)
q = sim.get_q()
print('q = ', q)
SimRenderer.replay(sim, record = False, record_path = "./torque_finger_flick_init.gif")
def loss_and_grad(u): # compute loss and gradient through diff redma... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/DiffHand",
"path": "/examples/test_finger_flick_optimize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TrendingTechnology/DiffHand path: /examples/test_finger_flick_optimize.py
'''
optimize an open-loop action sequence for finger to push a box to a target location
'''
from renderer import SimRenderer
import numpy as np
import scipy.optimize
import redmax_py as redmax
if __name__ == '__main__':
... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/DiffHand",
"path": "/examples/test_finger_flick_optimize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> original_data = (2506, 723526)
expected_output = b'\xca\t\x00\x00\x00\x00\x00\x00F\n\x0b\x00\x00\x00\x00\x00'
output = serialize_tuple_of_integers(original_data)
assert output == expected_output
assert struct.unpack("<2Q", output) == original_data<|fim_prefix|># repo: JFF-Bohdan/item_l... | code_fim | medium | {
"lang": "python",
"repo": "JFF-Bohdan/item_lookup",
"path": "/tests/test_lmdb_serializer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JFF-Bohdan/item_lookup path: /tests/test_lmdb_serializer.py
import struct
from shared.lmdb_support import serialize_tuple_of_integers
<|fim_suffix|> assert serialize_tuple_of_integers(data) == expected_output
def test_serialization_is_correct():
original_data = (2506, 723526)
expect... | code_fim | medium | {
"lang": "python",
"repo": "JFF-Bohdan/item_lookup",
"path": "/tests/test_lmdb_serializer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Synerty/peek-storage-service path: /peek_storage/_private/alembic/versions/bab14faf0cd7_add_timescale.py
"""add timescale
Revision ID: bab14faf0cd7
Revises: 12a0ab3826f3
Create Date: 2020-05-17 16:07:17.377521
"""
# revision identifiers, used by Alembic.
revision = 'bab14faf0cd7'
down_revision... | code_fim | easy | {
"lang": "python",
"repo": "Synerty/peek-storage-service",
"path": "/peek_storage/_private/alembic/versions/bab14faf0cd7_add_timescale.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Extend the database with TimescaleDB
op.execute('CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE')
def downgrade():
pass<|fim_prefix|># repo: Synerty/peek-storage-service path: /peek_storage/_private/alembic/versions/bab14faf0cd7_add_timescale.py
"""add timescale
Revision ID: bab14faf... | code_fim | easy | {
"lang": "python",
"repo": "Synerty/peek-storage-service",
"path": "/peek_storage/_private/alembic/versions/bab14faf0cd7_add_timescale.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def parse(self, buff):
buffer_contents = []
while buff:
try:
ack, buff = self._parse_ack(buff)
except BufferParsingError:
# skip to next message
old_buff = buff
_, delim, buff = buff.partition('0262... | code_fim | hard | {
"lang": "python",
"repo": "maxvitek/insteon-hub",
"path": "/insteon/local.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
buff[22]
except IndexError:
raise BufferExhausted()
_msg_flag = buff[:4]
_from = buff[4:10]
_to = buff[10:16]
_flags = buff[16:18]
_cmd1 = buff[18:20]
_cmd2 = buff[20:22]
try:
assert _msg_flag ... | code_fim | hard | {
"lang": "python",
"repo": "maxvitek/insteon-hub",
"path": "/insteon/local.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maxvitek/insteon-hub path: /insteon/local.py
import time
import json
import requests
import threading
# http://cache.insteon.com/developer/2242-222dev-062013-en.pdf
class BufferParsingError(Exception):
pass
class BufferExhausted(Exception):
pass
class SingleGetter(object):
def ... | code_fim | hard | {
"lang": "python",
"repo": "maxvitek/insteon-hub",
"path": "/insteon/local.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Toblerity/fio-buffer path: /tests/test_processor.py
import copy
from shapely.geometry import mapping
from shapely.geometry import shape
import fio_buffer.core
feature = {
'type': 'Feature',
'properties': {'prop1': 1, 'prop2': None},
'geometry': {
'type': 'Polygon',
... | code_fim | hard | {
"lang": "python",
"repo": "Toblerity/fio-buffer",
"path": "/tests/test_processor.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> expected = {
'type': 'Feature',
'properties': feature['properties'],
'geometry': mapping(shape(feature['geometry']).buffer(**args['buf_args']))
}
actual = fio_buffer.core._processor(args)
assert expected.keys() == actual.keys()
assert expected['properties'] ==... | code_fim | hard | {
"lang": "python",
"repo": "Toblerity/fio-buffer",
"path": "/tests/test_processor.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmattey/leetcode_problems path: /30DayChallenge_April/april_12_last_stone_weight.py
class Solution:
def lastStoneWeight(self, stones: List[int]) -> int:
import heapq
stones = [-val for val in stones]
heapq.heapify(stones)
while len(stones)>1:
sto... | code_fim | hard | {
"lang": "python",
"repo": "cmattey/leetcode_problems",
"path": "/30DayChallenge_April/april_12_last_stone_weight.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> stones = [-val for val in stones]
heapq.heapify(stones)
while len(stones)>1:
stone1 = -heapq.heappop(stones)
stone2 = -heapq.heappop(stones)
if stone1==stone2:
continue
else:
heapq.heappush(stones, -... | code_fim | easy | {
"lang": "python",
"repo": "cmattey/leetcode_problems",
"path": "/30DayChallenge_April/april_12_last_stone_weight.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 0 if len(stones)==0 else -stones[0]<|fim_prefix|># repo: cmattey/leetcode_problems path: /30DayChallenge_April/april_12_last_stone_weight.py
class Solution:
def lastStoneWeight(self, stones: List[int]) -> int:
import heapq
stones = [-val for val in stones]
heap... | code_fim | hard | {
"lang": "python",
"repo": "cmattey/leetcode_problems",
"path": "/30DayChallenge_April/april_12_last_stone_weight.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: niki4/leetcode_py3 path: /medium/535_encode_and_decode_tiny_url.py
"""
Note: This is a companion problem to the System Design problem: Design TinyURL.
TinyURL is a URL shortening service where you enter a URL such as
https://leetcode.com/problems/design-tinyurl and it returns a short URL
such as ... | code_fim | hard | {
"lang": "python",
"repo": "niki4/leetcode_py3",
"path": "/medium/535_encode_and_decode_tiny_url.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Decodes a shortened URL to its original URL.
:type shortUrl: str
:rtype: str
"""
cleanedID = shortUrl[len(self.baseUrl)+len(self.prefix):]
long_URL = self.storage[cleanedID]
return long_URL
# Your Codec object will be instantiated and called as... | code_fim | hard | {
"lang": "python",
"repo": "niki4/leetcode_py3",
"path": "/medium/535_encode_and_decode_tiny_url.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(FC, self).__init__()
self.fc1 = nn.Linear(in_size, out_size,bias=False)
self.softmax = nn.Softmax(1)
def forward(self, x):
x = self.fc1(x)
x = self.softmax(x)
return x
def colour_predicate(net, *colour):
d = torch.FloatTensor(colour)
d =... | code_fim | medium | {
"lang": "python",
"repo": "MarcRoigVilamala/DeepProbCEP",
"path": "/examples/NIPS/CoinUrn/nets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarcRoigVilamala/DeepProbCEP path: /examples/NIPS/CoinUrn/nets.py
import torch
import torch.optim as optim
import torch.nn as nn
from torch.autograd import Variable
from network import Network
from examples.NIPS.MNIST.mnist import MNIST_Net, neural_predicate
class FC(nn.Module):
def __init_... | code_fim | hard | {
"lang": "python",
"repo": "MarcRoigVilamala/DeepProbCEP",
"path": "/examples/NIPS/CoinUrn/nets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@bp.route("/new", methods=["POST"])
def create_user():
return json.dumps({"index": "hello"})
@bp.route("/<int:_id>", methods=["PATCH"])
def update_user(_id):
return json.dumps({"index": _id})
@bp.route("/new", methods=["DELETE"])
def delete_user():
return json.dumps({"index": "hello"})<|f... | code_fim | medium | {
"lang": "python",
"repo": "diwakarjaiswal880/sentimental-user-service",
"path": "/src/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@bp.route("/<int:_id>", methods=["GET"])
def show_user(_id):
return json.dumps({"index": _id})
@bp.route("/new", methods=["POST"])
def create_user():
return json.dumps({"index": "hello"})
@bp.route("/<int:_id>", methods=["PATCH"])
def update_user(_id):
return json.dumps({"index": _id})
... | code_fim | medium | {
"lang": "python",
"repo": "diwakarjaiswal880/sentimental-user-service",
"path": "/src/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diwakarjaiswal880/sentimental-user-service path: /src/views.py
from flask import Blueprint
import simplejson as json
bp = Blueprint("user", import_name=__name__, url_prefix="/user")
@bp.route("/health")
def health():
return json.dumps({"health": "alive"})
@bp.route("/all", methods=["GET... | code_fim | medium | {
"lang": "python",
"repo": "diwakarjaiswal880/sentimental-user-service",
"path": "/src/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xiaochengcike/pixel-constrained-cnn-tf path: /utils.py
import numpy as np
import os
from skimage.io import imsave
from matplotlib.pyplot import get_cmap
def softmax(x):
"""Compute softmax values for each sets of scores in x."""
e_x = np.exp(x - np.expand_dims(np.max(x, axis=-1), ... | code_fim | hard | {
"lang": "python",
"repo": "xiaochengcike/pixel-constrained-cnn-tf",
"path": "/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not os.path.exists(samples_dir):
os.makedirs(samples_dir)
for i in range(N):
step = start_iter + i
name = record_list[step]
start_idx = name.rindex('/')
end_idx = name.rindex('.')
name = name[start_idx+1:end_idx]
img_path = samples_dir + '/' + name + '_' + 'p... | code_fim | hard | {
"lang": "python",
"repo": "xiaochengcike/pixel-constrained-cnn-tf",
"path": "/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return np.floor(pixels), pixel_probs
def log_likelihood_plot(samples,log_likelihoods, ncols, cmap = 'jet', samples_dir = None, record_list = None):
"""
Sorts samples by their log likelihoods and creates an image representing the log likelihood of each sample
as a boxwith color and size pr... | code_fim | hard | {
"lang": "python",
"repo": "xiaochengcike/pixel-constrained-cnn-tf",
"path": "/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pingsutw/Recommendation-system path: /run_deepfm.py
from submarine.ml.tensorflow.model import DeepFM
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-conf", help="a JSON configuration file for DeepFM", type=str)
parser.add_argument("... | code_fim | medium | {
"lang": "python",
"repo": "pingsutw/Recommendation-system",
"path": "/run_deepfm.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if task_type == 'train':
model.train()
result = model.evaluate()
print("Model metrics : ", result)<|fim_prefix|># repo: pingsutw/Recommendation-system path: /run_deepfm.py
from submarine.ml.tensorflow.model import DeepFM
import argparse
if __name__ == '__main__':
parser =... | code_fim | medium | {
"lang": "python",
"repo": "pingsutw/Recommendation-system",
"path": "/run_deepfm.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: opentelekomcloud-infra/otc-zuul-jobs path: /roles/upload-logs-base1/library/test_zuul_google_storage_upload.py
# Copyright (C) 2018-2019 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may o... | code_fim | medium | {
"lang": "python",
"repo": "opentelekomcloud-infra/otc-zuul-jobs",
"path": "/roles/upload-logs-base1/library/test_zuul_google_storage_upload.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>FIXTURE_DIR = os.path.join(os.path.dirname(__file__),
'test-fixtures')
class TestCredential(testtools.TestCase):
def test_credential(self):
path = os.path.join(FIXTURE_DIR, 'gcs', 'auth.json')
headers = {}
c = Credentials(path)
c.before_req... | code_fim | medium | {
"lang": "python",
"repo": "opentelekomcloud-infra/otc-zuul-jobs",
"path": "/roles/upload-logs-base1/library/test_zuul_google_storage_upload.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def on(self, color='all'):
"""Turn on the LED light.
Args:
color (str, optional): Color of the LED light. ``r``, ``g`` or ``b``. Defaults to ``all``.
"""
if color in ['all', 'r']:
self.__send('r', 'on')
if color in ['all', 'g']:
... | code_fim | hard | {
"lang": "python",
"repo": "kingkorea/DynamiKontrol",
"path": "/dynamikontrol/BaseLED.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kingkorea/DynamiKontrol path: /dynamikontrol/BaseLED.py
class BaseLED(object):
def __init__(self, module):
self.m = module
self.type = 0x02
self.command = {
'r': 0x00,
'g': 0x01,
'b': 0x02
}
self.mode = {
... | code_fim | hard | {
"lang": "python",
"repo": "kingkorea/DynamiKontrol",
"path": "/dynamikontrol/BaseLED.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for tbl in aux_tbls:
data.add_table(tbl.name, tbl.data_table)
return data
@classmethod
def load_issues(cls, dump_path, project_names=None, verbose=False):
"""
Read in a Mantis SQL dump file and return a dictionary mapping issue
number to a Mant... | code_fim | hard | {
"lang": "python",
"repo": "dglo/svn2git_tools",
"path": "/mantis_converter.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dglo/svn2git_tools path: /mantis_converter.py
for label in self.__gitrepo.get_labels():
tmplist[label.name] = label
self.__labels = tmplist
if label_name in self.__labels:
return self.__labels[label_name]
if label_name not in self.LA... | code_fim | hard | {
"lang": "python",
"repo": "dglo/svn2git_tools",
"path": "/mantis_converter.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dglo/svn2git_tools path: /mantis_converter.py
for this project
self.__project_issue_numbers = \
self.__create_issue_order(verbose=verbose)
if verbose:
if self.__project_names is None:
pstr = "all projects"
else:
pst... | code_fim | hard | {
"lang": "python",
"repo": "dglo/svn2git_tools",
"path": "/mantis_converter.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryanwitt/django-liberace path: /liberace/templates.py
apache_conf = """
# Sample apache config for Fabulous django deployment.
NameVirtualHost *:80
<VirtualHost *:80>
WSGIDaemonProcess %(project_name)s \
processes=2 threads=5 display-name=%(project_name)s
<|fim_suffix|># Preload d... | code_fim | hard | {
"lang": "python",
"repo": "ryanwitt/django-liberace",
"path": "/liberace/templates.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># Activate virtualenv support
activate_this = '%(virtualenv_path)s/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
os.environ['DJANGO_SETTINGS_MODULE'] = '%(django_settings_module)s'
os.environ['PYTHON_EGG_CACHE'] = '%(egg_cache_path)s'
# Preload django environment
settings =... | code_fim | hard | {
"lang": "python",
"repo": "ryanwitt/django-liberace",
"path": "/liberace/templates.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PeterConstable/PyOTCodec path: /PyOTCodec/PyOTCodecTests/test_setup.py
import ot_file
# Several tests will use selawk.ttf, SourceHanSans-Regular.TTC
selawk_path = r"TestData\selawk.ttf"
sourceHansSans_path = r"TestData\SourceHanSans-Regular.TTC"
bungeeColor_path = r"TestData\BungeeColor-Regul... | code_fim | medium | {
"lang": "python",
"repo": "PeterConstable/PyOTCodec",
"path": "/PyOTCodec/PyOTCodecTests/test_setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print()
print(f"{heading}:")
print()
print("{:<55} {:<}".format("Test", "result"))
print("===============================================================")
for k, v in testResults.items():
print(f"{k:<55} {'Pass' if v else '!! FAIL !!'}")
print()
print(f"Number of t... | code_fim | hard | {
"lang": "python",
"repo": "PeterConstable/PyOTCodec",
"path": "/PyOTCodec/PyOTCodecTests/test_setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Conv2D(64, (10,10), activation = 'relu', input_shape = input_shape , kernel_initializer = initialize_weights, kernel_regularizer = tf.keras.regularizers.l2(2e-4)),
MaxPooling2D(),
Conv2D(128, (7,7), activation = 'relu', kernel_initializer = initialize_weights, bias_initializer = in... | code_fim | medium | {
"lang": "python",
"repo": "ayushmankumar7/Siamese-Network-with-One-Shot-Learning",
"path": "/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ayushmankumar7/Siamese-Network-with-One-Shot-Learning path: /model.py
import tensorflow as tf
import numpy as np
from tensorflow.keras.layers import Dense, Conv2D, MaxPooling2D, Input, Flatten, Lambda
from tensorflow.keras.models import Model, Sequential
from utils import initialize_bias, ini... | code_fim | hard | {
"lang": "python",
"repo": "ayushmankumar7/Siamese-Network-with-One-Shot-Learning",
"path": "/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> L1_layer = Lambda(lambda x: tf.keras.backend.abs(x[0] - x[1]))
L1_distance = L1_layer([encoded_1, encoded_2])
prediction = Dense(1, activation = 'sigmoid')(L1_distance)
final_model = Model(inputs = [input1, input2], outputs = prediction)
model.compile( loss = 'binary_crossentropy',
... | code_fim | medium | {
"lang": "python",
"repo": "ayushmankumar7/Siamese-Network-with-One-Shot-Learning",
"path": "/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @cr.Plugin.activemethod
def GetTargets(self):
"""Gets the full set of targets supported by this builder.
Used in automatic target name transformations, and also in offering the
user choices.
"""
return []
@cr.Plugin.activemethod
def IsTarget(self, target_name):
"""Check i... | code_fim | hard | {
"lang": "python",
"repo": "chromium/chromium",
"path": "/tools/cr/cr/actions/builder.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chromium/chromium path: /tools/cr/cr/actions/builder.py
# Copyright 2013 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""A module for the Builder base class."""
import difflib
import cr
class Builder(cr.Action, cr.... | code_fim | hard | {
"lang": "python",
"repo": "chromium/chromium",
"path": "/tools/cr/cr/actions/builder.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: snfactory/extract-star path: /scripts/pySNIFS_special.py
from matplotlib.mlab import linspace, dist
from matplotlib.patches import Circle, Rectangle
from matplotlib.lines import Line2D
from matplotlib.numerix import array
from matplotlib.transforms import blend_xy_sep_transform
from scipy.special... | code_fim | hard | {
"lang": "python",
"repo": "snfactory/extract-star",
"path": "/scripts/pySNIFS_special.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'on button release event'
if self.pressx is None or self.ignore(event): return
if self.pressy is None or self.ignore(event): return
self.canvas.draw()
self.center = [self.pressx, self.pressy]
self.radius = sqrt((event.xdata-self.center[0])**2 + (event.ydata-self.center[1... | code_fim | hard | {
"lang": "python",
"repo": "snfactory/extract-star",
"path": "/scripts/pySNIFS_special.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#-------------------------------------------------------------------------------
# Short Message B
#
# Empty handler reply message
#-------------------------------------------------------------------------------
short_message_B = TestVector()
short_message_B.add_thread(initT)
smB_t1 = Thread()
initT.wai... | code_fim | hard | {
"lang": "python",
"repo": "UofT-HPRC/shoal",
"path": "/GAScore/testbench/xpams_tx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>short_message_B = TestVector()
short_message_B.add_thread(initT)
smB_t1 = Thread()
initT.wait_negedge('ap_clk')
smB_t1.add_delay('100ns')
smB_t1.init_timer()
smB_t1.set_signal('address_offset_high_V', 15)
axis_kernel_in.write(smB_t1, strToInt("{AMHeader,0x0,0x01,0,2,1,1}"))
axis_kernel_in.write(smB_t1, s... | code_fim | hard | {
"lang": "python",
"repo": "UofT-HPRC/shoal",
"path": "/GAScore/testbench/xpams_tx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UofT-HPRC/shoal path: /GAScore/testbench/xpams_tx.py
import os
from sonar.testbench import Testbench, Module, TestVector, Thread
from sonar.interfaces import AXIS
from sonar_strToInt import strToInt
xpams_tx = Testbench.default('xpams_tx')
filepath = os.path.join(os.path.dirname(__file__), 'bu... | code_fim | hard | {
"lang": "python",
"repo": "UofT-HPRC/shoal",
"path": "/GAScore/testbench/xpams_tx.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samisalkosuo/kubeterminal path: /kubeterminal/lexer.py
from prompt_toolkit.lexers import Lexer
from prompt_toolkit.styles.named_colors import NAMED_COLORS
import re
import kubeterminal.globals as globals
class ResourceWindowLexer(Lexer):
def windowColors(self,contentMode, line):
... | code_fim | hard | {
"lang": "python",
"repo": "samisalkosuo/kubeterminal",
"path": "/kubeterminal/lexer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if self.isRunningEqualReady(line) == True:
return [(NAMED_COLORS["Green"],line)]
#default yellow
return [(NAMED_COLORS["Yellow"],line)]
def checkSingleField(self,line,value,desiredValue):
#if value equals desiredValue return Green line
#else r... | code_fim | hard | {
"lang": "python",
"repo": "samisalkosuo/kubeterminal",
"path": "/kubeterminal/lexer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(coords_raw)
coords_raw = [elt.strip() for elt in coords_raw]
#elts_stripped = coords_raw.strip()
coords_pos = [elt.split('\t')]
print(coords_pos)<|fim_prefix|># repo: chrismits/COMP50Project path: /visionsam/scripts/test.py
#!/usr/bin/env python
f = open("/home/turtlebot/catkin_ws/src/visionsam/way... | code_fim | easy | {
"lang": "python",
"repo": "chrismits/COMP50Project",
"path": "/visionsam/scripts/test.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.