text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """The Web server (running the Web site) thinks that there has been too
long an interval of time between 1) the establishment of an IP
connection (socket) between the client and the server and
2) the receipt of any data on that socket, so the server has dropped
the connection. The sock... | code_fim | hard | {
"lang": "python",
"repo": "rick-xu/sanic",
"path": "/sanic/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rick-xu/sanic path: /sanic/exceptions.py
from typing import Optional, Union
from sanic.helpers import STATUS_CODES
class SanicException(Exception):
def __init__(
self,
message: Optional[Union[str, bytes]] = None,
status_code: Optional[int] = None,
quiet: Opt... | code_fim | hard | {
"lang": "python",
"repo": "rick-xu/sanic",
"path": "/sanic/exceptions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if os.getenv("USE_OMP"):
cmake_args += ["-DUSE_OMP:STR=" + os.getenv("USE_OMP")]
if os.getenv("USE_MPI"):
cmake_args += ["-DUSE_MPI:STR=" + os.getenv("USE_MPI")]
env = os.environ.copy()
env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format(
... | code_fim | hard | {
"lang": "python",
"repo": "qulacs/qulacs",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qulacs/qulacs path: /setup.py
import os
import platform
import re
import subprocess
import sys
from setuptools import Extension, find_packages, setup
from setuptools.command.build_ext import build_ext
class CMakeExtension(Extension):
def __init__(self, name, sourcedir=""):
Extensio... | code_fim | hard | {
"lang": "python",
"repo": "qulacs/qulacs",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fostroll/cors_api_proxy path: /cors_api_proxy/proxy.py
# -*- coding: utf-8 -*-
from flask import Flask, request, Response, stream_with_context
from requests import request as make_request
from requests.exceptions import ConnectionError as ConnError, \
MissingSchem... | code_fim | hard | {
"lang": "python",
"repo": "fostroll/cors_api_proxy",
"path": "/cors_api_proxy/proxy.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = reqid = None
if watch_reqs and request.method != OPTIONS:
res, reqid, _ = find_req(request)
if not res:
try:
req = make_request(request.method,
url,
params=request.args,
... | code_fim | hard | {
"lang": "python",
"repo": "fostroll/cors_api_proxy",
"path": "/cors_api_proxy/proxy.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ionrock/taskin path: /tests/test_tasks.py
from mock import Mock
from taskin import MapTask, IfTask, DispatchTask, ThreadPool
def add(x):
return x + 1
class TestMapTask(object):
def setup(self):
self.args = range(3)
self.pool = Mock()
self.task = MapTask(add, s... | code_fim | hard | {
"lang": "python",
"repo": "ionrock/taskin",
"path": "/tests/test_tasks.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.task = DispatchTask(dispatcher)
def test_dispatch_to_key(self):
assert self.task('a') == 'a'
assert self.task('b') == 'b'
assert self.task('c') == 'c'
def test_dispatch_fail_to_dispatch(self):
try:
self.task('x')
except:
... | code_fim | hard | {
"lang": "python",
"repo": "ionrock/taskin",
"path": "/tests/test_tasks.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> meta = yt_link.split('?')
if '&' in meta[-1]:
meta = [string for string in meta[-1].split('&') if splitThis in string]
youtube_id = meta[-1].split(splitThis)[-1]
return youtube_id
# gets the subtitles / captions from the video that's already generated
def getCaptions(vid_id):
try:
captions = You... | code_fim | hard | {
"lang": "python",
"repo": "spbRusty/YouTube-data-scraper",
"path": "/Web-Youtube.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spbRusty/YouTube-data-scraper path: /Web-Youtube.py
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
from webdriver_manager.chrome import ChromeDriverManager
from bs4 import BeautifulSoup
from pathlib import Path
... | code_fim | hard | {
"lang": "python",
"repo": "spbRusty/YouTube-data-scraper",
"path": "/Web-Youtube.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def getLinkID(yt_link, splitThis):
meta = yt_link.split('?')
if '&' in meta[-1]:
meta = [string for string in meta[-1].split('&') if splitThis in string]
youtube_id = meta[-1].split(splitThis)[-1]
return youtube_id
# gets the subtitles / captions from the video that's already generated
def getCapt... | code_fim | hard | {
"lang": "python",
"repo": "spbRusty/YouTube-data-scraper",
"path": "/Web-Youtube.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sazlin/data-structures path: /linked_list.py
class node(object):
def __init__(self, val, next):
self.val = val
self.next = next
class l_list(object):
def __init__(self):
self.num_nodes = 0
self.head = None
def insert(self, val):
if self.head ... | code_fim | hard | {
"lang": "python",
"repo": "sazlin/data-structures",
"path": "/linked_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.head is None:
return
elif self.head.val == node.val and self.head.next == node.next:
self.head = self.head.next
return
previous_node = self.head
current_node = self.head.next
while current_node is not None:
if ... | code_fim | hard | {
"lang": "python",
"repo": "sazlin/data-structures",
"path": "/linked_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>exValidator(message='Incorrect phone number.', regex='^[\\+]?[(]?[0-9]{3}[)]?[-\\s\\.]?[0-9]{3}[-\\s\\.]?[0-9]{4,6}$')], verbose_name='Факс')),
('company', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='employees', to='directory.company')),
('o... | code_fim | hard | {
"lang": "python",
"repo": "Iki-oops/lyubimoffka_task",
"path": "/directory/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Iki-oops/lyubimoffka_task path: /directory/migrations/0001_initial.py
# Generated by Django 3.2.7 on 2021-09-05 13:09
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
... | code_fim | hard | {
"lang": "python",
"repo": "Iki-oops/lyubimoffka_task",
"path": "/directory/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Spirent/openperf path: /tests/aat/spec/tvlp_spec.py
vlp_result)
with description('delayed,'):
with it('succeeded'):
next_day = datetime.datetime.today() + datetime.timedelta(days=2)
result = self.tvlp_api.start_tvlp_configuratio... | code_fim | hard | {
"lang": "python",
"repo": "Spirent/openperf",
"path": "/tests/aat/spec/tvlp_spec.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Spirent/openperf path: /tests/aat/spec/tvlp_spec.py
for gen in configurations:
expect(gen).to(be_valid_tvlp_configuration)
with description('get,'):
with description('by existing id,'):
with before.each:
t ... | code_fim | hard | {
"lang": "python",
"repo": "Spirent/openperf",
"path": "/tests/aat/spec/tvlp_spec.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with description('non-existent id,'):
with it('returns 404'):
expect(lambda: self.tvlp_api.start_tvlp_configuration('foo')).to(raise_api_exception(404))
with description('invalid id,'):
with it('returns 400'):
... | code_fim | hard | {
"lang": "python",
"repo": "Spirent/openperf",
"path": "/tests/aat/spec/tvlp_spec.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>rsers
from . import plotting
from . import sario
from . import timeseries
from . import utils<|fim_prefix|># repo: mfkiwl/insar path: /insar/__init__.py
from . import dem
from . import eof
from . imp<|fim_middle|>ort geojson
from . import log
from . import pa | code_fim | easy | {
"lang": "python",
"repo": "mfkiwl/insar",
"path": "/insar/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mfkiwl/insar path: /insar/__init__.py
from . import dem
from . import eof
from . import geojson
from . import log
from . import pa<|fim_suffix|>io
from . import timeseries
from . import utils<|fim_middle|>rsers
from . import plotting
from . import sar | code_fim | easy | {
"lang": "python",
"repo": "mfkiwl/insar",
"path": "/insar/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mfkiwl/insar path: /insar/__init__.py
from . import dem
from . import eof
from . imp<|fim_suffix|>rsers
from . import plotting
from . import sario
from . import timeseries
from . import utils<|fim_middle|>ort geojson
from . import log
from . import pa | code_fim | easy | {
"lang": "python",
"repo": "mfkiwl/insar",
"path": "/insar/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def bce_dice_loss(y_true, y_pred):
return keras.losses.binary_crossentropy(y_true, y_pred) + dice_loss(y_true, y_pred)
def bce_dice_focal_loss(y_true, y_pred):
return keras.losses.binary_crossentropy(y_true, y_pred) + dice_loss(y_true, y_pred)+focal_loss(y_true, y_pred)
def bce_tversky_los... | code_fim | hard | {
"lang": "python",
"repo": "spunk166/gastric-cancer-detect",
"path": "/models/losses.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spunk166/gastric-cancer-detect path: /models/losses.py
import tensorflow.keras.backend as K
import tensorflow as tf
from tensorflow import keras
from cldice_loss import soft_clDice_loss,soft_dice_cldice_loss
def getLoss(name='bce_dice_focal'):
if name=='bce_dice_focal':
return... | code_fim | hard | {
"lang": "python",
"repo": "spunk166/gastric-cancer-detect",
"path": "/models/losses.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> w = K.sum(y_true)
w = 1/(w**2+0.000001)
# Compute gen dice coef:
numerator = y_true*y_pred
numerator = w*K.sum(numerator)
numerator = K.sum(numerator)
denominator = y_true+y_pred
denominator = w*K.sum(denominator)
denominator = K.sum(denominator)
gen_dice_c... | code_fim | hard | {
"lang": "python",
"repo": "spunk166/gastric-cancer-detect",
"path": "/models/losses.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lintianqianjin/reappearance-of-some-classical-CNNs path: /step5/VGGPreprocessForUsers.py
import numpy as np
def VGGPreprocessingBatch(batch_originImgMatrix):
<|fim_suffix|>
#********** Begin **********#
#********** End **********#<|fim_middle|> '''
你需要对batch中的每一个img的数据作如下预处理:
... | code_fim | hard | {
"lang": "python",
"repo": "Lintianqianjin/reappearance-of-some-classical-CNNs",
"path": "/step5/VGGPreprocessForUsers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param batch_originImgMatrix: 一个数组或者是一个numpy.ndarray,shape是(batchSize,imgSize,imgSize,3)
:return: 返回处理正确后的数据,shape不变,返回类型为numpy.ndarray
'''
#********** Begin **********#
#********** End **********#<|fim_prefix|># repo: Lintianqianjin/reappearance-of-some-classical-CNNs path: /step... | code_fim | medium | {
"lang": "python",
"repo": "Lintianqianjin/reappearance-of-some-classical-CNNs",
"path": "/step5/VGGPreprocessForUsers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
#********** Begin **********#
#********** End **********#<|fim_prefix|># repo: Lintianqianjin/reappearance-of-some-classical-CNNs path: /step5/VGGPreprocessForUsers.py
import numpy as np
def VGGPreprocessingBatch(batch_originImgMatrix):
'''
你需要对batch中的每一个img的数据作如下预处理:
各个像素点上rgb三个通... | code_fim | medium | {
"lang": "python",
"repo": "Lintianqianjin/reappearance-of-some-classical-CNNs",
"path": "/step5/VGGPreprocessForUsers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sebastian-meier/LoCobSS-text-similarity path: /app.py
import logging
logging.basicConfig()
logging.root.setLevel(logging.ERROR)
from flask import Flask, request
from flask_restful import Api, Resource, reqparse
from flasgger import Swagger
import os
from dotenv import load_dotenv
load_dotenv()
... | code_fim | hard | {
"lang": "python",
"repo": "sebastian-meier/LoCobSS-text-similarity",
"path": "/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> module_url = "https://tfhub.dev/google/universal-sentence-encoder/4"
model = hub.load(module_url)
model_output = model([request.json['text']])
return_json = {
"vectors": np.array(model_output).tolist()
}
if 'includeSimilar' in request.json and (request.json['includeSimilar'] == True or ... | code_fim | hard | {
"lang": "python",
"repo": "sebastian-meier/LoCobSS-text-similarity",
"path": "/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''calc gdc out'''
if out_vf is not None:
gdc_w = out_main[0]
gdc_h = max(out_main[1], out_main[0] * out_vf[1] / out_vf[0])
gdc_h = min(gdc_h, out_vf[1] * YUV_MAX_SCALE)
gdc_w = min(gdc_w, out_vf[0] * YUV_MAX_SCALE)
gdc_out = [gdc_w, gdc_h]
if gdc_w ... | code_fim | hard | {
"lang": "python",
"repo": "intel/intel-ipu3-pipecfg",
"path": "/pipe_config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: intel/intel-ipu3-pipecfg path: /pipe_config.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
'''
IF: Input Feeder (former Decompressor)
BDS: bayer downscaling
GDC: Geometric Distortion Correction block
DVS: Digital video stabilization
SF: scale factor
'''
import sys
import math
LOG_DBG = 0
FILTER_... | code_fim | hard | {
"lang": "python",
"repo": "intel/intel-ipu3-pipecfg",
"path": "/pipe_config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def calc_gdc_out(ipu_in, out_main, out_vf):
'''calc gdc out'''
if out_vf is not None:
gdc_w = out_main[0]
gdc_h = max(out_main[1], out_main[0] * out_vf[1] / out_vf[0])
gdc_h = min(gdc_h, out_vf[1] * YUV_MAX_SCALE)
gdc_w = min(gdc_w, out_vf[0] * YUV_MAX_SCALE)
... | code_fim | hard | {
"lang": "python",
"repo": "intel/intel-ipu3-pipecfg",
"path": "/pipe_config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: upendra-k14/indic_tagger path: /polyglot-tokenizer/polyglot_tokenizer/armenian_tokenizer.py
#!/usr/bin/env python
# -*- coding=utf-8 -*-
from __future__ import (division, unicode_literals)
import io
import os
import re
from .roman_tokenizer import RomanTokenizer
<|fim_suffix|> super(Ar... | code_fim | hard | {
"lang": "python",
"repo": "upendra-k14/indic_tagger",
"path": "/polyglot-tokenizer/polyglot_tokenizer/armenian_tokenizer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(ArmenianTokenizer, self).__init__(
lang='en', split_sen=split_sen, smt=smt, fit=False)
self.armenian_alpha = ''.join(
[unichr(x) for x in range(0x0530, 0x0590) if unichr(x).isalpha()])
self.alpha += self.armenian_alpha
self.alpha_lower += ''.jo... | code_fim | hard | {
"lang": "python",
"repo": "upendra-k14/indic_tagger",
"path": "/polyglot-tokenizer/polyglot_tokenizer/armenian_tokenizer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: frapa/tbcnn path: /progress.py
import os
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
summary_writer = None
def start_tensorboard():
<|fim_suffix|> summary_writer = tf.summary.FileWriter(logDir, graph)
def create_metrics_summary(metrics):
summaries = []
for dataset i... | code_fim | hard | {
"lang": "python",
"repo": "frapa/tbcnn",
"path": "/progress.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def add_summary(summ_data, epoch):
summary_writer.add_summary(summ_data, epoch)
summary_writer.flush()<|fim_prefix|># repo: frapa/tbcnn path: /progress.py
import os
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
summary_writer = None
def start_tensorboard():
print('Use `python3... | code_fim | hard | {
"lang": "python",
"repo": "frapa/tbcnn",
"path": "/progress.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#Code starts here
regressor = LinearRegression()
regressor.fit(X_test,y_test)
score = cross_val_score(regressor,X_train,y_train,cv=10)
mean_score = np.mean(score)
print(mean_score)
# --------------
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
fro... | code_fim | hard | {
"lang": "python",
"repo": "Abhijit-21/ga-learner-dsmp-repo",
"path": "/ML-Moving-to-Melbourne---Housing-Again/code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Abhijit-21/ga-learner-dsmp-repo path: /ML-Moving-to-Melbourne---Housing-Again/code.py
# --------------
import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
# path- variable storing file path
df = pd.read_csv(path)
print(df.head(5))
# split the data... | code_fim | hard | {
"lang": "python",
"repo": "Abhijit-21/ga-learner-dsmp-repo",
"path": "/ML-Moving-to-Melbourne---Housing-Again/code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# --------------
from sklearn.preprocessing import PolynomialFeatures
from sklearn.pipeline import make_pipeline
from sklearn.linear_model import LinearRegression
#Code starts here
poly = PolynomialFeatures(2)
model = LinearRegression()
model = make_pipeline(poly,model)
model.fit(X_train,y_tra... | code_fim | hard | {
"lang": "python",
"repo": "Abhijit-21/ga-learner-dsmp-repo",
"path": "/ML-Moving-to-Melbourne---Housing-Again/code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: neoyk/raspberry path: /syncweb.py
#! /usr/bin/python
# upload metadata first, then reset website list
import sys, subprocess, shlex, MySQLdb, os, urllib, urllib2, logging, logging.handlers
from collections import defaultdict
from webcrawl import connect_detection
dirname, filename = os.path.spli... | code_fim | hard | {
"lang": "python",
"repo": "neoyk/raspberry",
"path": "/syncweb.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ap.php'
req = urllib2.Request(url)
response = urllib2.urlopen(req)
output = response.read()
for line in output.split('\n'):
#print line
if line.startswith('system '):
try:
subprocess.Popen(shlex.split(line[7:]), stdout=subprocess.PIPE,stderr = subprocess.PIPE )
except:
... | code_fim | hard | {
"lang": "python",
"repo": "neoyk/raspberry",
"path": "/syncweb.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yingshaoxo/ML path: /15.PaddleGAN/PaddleGAN/ppgan/datasets/photopen_dataset.py
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserve.
#
# 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 c... | code_fim | hard | {
"lang": "python",
"repo": "yingshaoxo/ML",
"path": "/15.PaddleGAN/PaddleGAN/ppgan/datasets/photopen_dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if is_image:
resized = img.resize((resize_w, resize_h), Image.BICUBIC)
else:
resized = img.resize((resize_w, resize_h), Image.NEAREST)
croped = resized.crop((pos[0], pos[1], pos[2], pos[3]))
fliped = ImageOps.mirror(croped) if flip else croped
fliped = np.array(fliped) ... | code_fim | hard | {
"lang": "python",
"repo": "yingshaoxo/ML",
"path": "/15.PaddleGAN/PaddleGAN/ppgan/datasets/photopen_dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # if some labels of the segmentation are missing, we
# return a very large xcenter, which will move them all
# the way to the right (they don't show up in the final
# segmentation anyway)
if o is None: return 999999
return mean((o[1].start,o[1].stop))
xs... | code_fim | hard | {
"lang": "python",
"repo": "cisocrgroup/ocrd_cis",
"path": "/ocrd_cis/ocropy/ocrolib/morph.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def pyargsort(seq,cmp=None,key=lambda x:x):
"""Like numpy's argsort, but using the builtin Python sorting
function. Takes an optional cmp."""
return sorted(list(range(len(seq))),key=lambda x:key(seq.__getitem__(x)),cmp=None)
@checks(SEGMENTATION)
def renumber_by_xcenter(seg):
"""Given a ... | code_fim | hard | {
"lang": "python",
"repo": "cisocrgroup/ocrd_cis",
"path": "/ocrd_cis/ocropy/ocrolib/morph.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cisocrgroup/ocrd_cis path: /ocrd_cis/ocropy/ocrolib/morph.py
let it raise the same exception as before
# return measurements.label(image,**kw)
@checks(SEGMENTATION)
def find_objects(image, **kw):
"""Redefine the scipy.ndimage.measurements.find_objects function to
work with a wider r... | code_fim | hard | {
"lang": "python",
"repo": "cisocrgroup/ocrd_cis",
"path": "/ocrd_cis/ocropy/ocrolib/morph.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>,
'0100000000000022': { # capsrv
'caps:a': 'nn::capsrv::sf::IAlbumAccessorService',
'caps:c': 'nn::capsrv::sf::IAlbumControlService',
},
'0100000000000023': { # am
'appletAE': 'nn::am::service::IAllSystemAppletProxiesService',
'appletOE': 'nn::am::service::IApplicationProxyService',
'idle:s... | code_fim | hard | {
"lang": "python",
"repo": "reswitched/SwIPC",
"path": "/auto/smapping.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: reswitched/SwIPC path: /auto/smapping.py
smapping = {
# builtins
'0100000000000000': {
'fsp-srv': 'nn::fssrv::sf::IFileSystemProxy',
'fsp-ldr': 'nn::fssrv::sf::IFileSystemProxyForLoader',
'fsp-pr': 'nn::fssrv::sf::IProgramRegistry',
},
'0100000000000001': ... | code_fim | hard | {
"lang": "python",
"repo": "reswitched/SwIPC",
"path": "/auto/smapping.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alan-turing-institute/daedalus path: /daedalus/VphSpenserPipeline/RunPipeline.py
#!/usr/bin/env python3
import pandas as pd
import datetime
import daedalus.utils as utils
from pathlib import Path
import os
from vivarium import InteractiveContext
from vivarium_population_spenser.population.spenser... | code_fim | hard | {
"lang": "python",
"repo": "alan-turing-institute/daedalus",
"path": "/daedalus/VphSpenserPipeline/RunPipeline.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> output_data_filename = 'ssm_' + config.location + '_MSOA11_ppp_2011_simulation_year_'+str(year)+'.csv'
pop.to_csv(os.path.join(year_output_dir, output_data_filename))
print ()
print ('In year: ',config.time.start.year + year)
# print some summary stats on the simul... | code_fim | hard | {
"lang": "python",
"repo": "alan-turing-institute/daedalus",
"path": "/daedalus/VphSpenserPipeline/RunPipeline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@pytest.fixture()
def answers():
return [
[
[
{
"coding": [
{
"system": "http://loinc.org",
"code": "15074-8",
"display": "Glucose [Moles... | code_fim | hard | {
"lang": "python",
"repo": "arkhn/FHIR2Dataset",
"path": "/tests/tools/fhirpath_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.fixture()
def answers():
return [
[
[
{
"coding": [
{
"system": "http://loinc.org",
"code": "15074-8",
"display": "Glucose [Moles/... | code_fim | hard | {
"lang": "python",
"repo": "arkhn/FHIR2Dataset",
"path": "/tests/tools/fhirpath_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arkhn/FHIR2Dataset path: /tests/tools/fhirpath_test.py
from dataclasses import asdict
import pytest
from dacite import from_dict
from fhir2dataset.data_class import Element, Elements
from fhir2dataset.tools.fhirpath import multiple_search_dict
@pytest.fixture()
def resources():
resources ... | code_fim | hard | {
"lang": "python",
"repo": "arkhn/FHIR2Dataset",
"path": "/tests/tools/fhirpath_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if isinstance(type_, np.dtype):
val = type_.char
elif type_ in (
int,
np.int,
np.int_,
np.int8,
np.int16,
np.int32,
np.int64,
Int,
float,
np.float,
... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/descarteslabs-python",
"path": "/descarteslabs/workflows/types/array/dtype.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Should not be worked with directly.
"""
def __init__(self, type_):
if isinstance(type_, np.dtype):
val = type_.char
elif type_ in (
int,
np.int,
np.int_,
np.int8,
np.int16,
np.int32,
... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/descarteslabs-python",
"path": "/descarteslabs/workflows/types/array/dtype.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stjordanis/descarteslabs-python path: /descarteslabs/workflows/types/array/dtype.py
import numpy as np
from descarteslabs.common.graft import client
from ...cereal import serializable
from ..core import Proxytype, ProxyTypeError
from ..primitives import Int, Float, Bool
@serializable()
class D... | code_fim | hard | {
"lang": "python",
"repo": "stjordanis/descarteslabs-python",
"path": "/descarteslabs/workflows/types/array/dtype.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> argv = [qemu_location, tmp_fname]
if "bitflip" in nrule:
argv = [argv[0]]+["-bitflip"]+argv[1:]
p = subprocess.Popen(argv, stdin=pipe, stdout=pipe, stderr=pipe)
# very very partial support to network rules
# TODO if we add other "interesting rules", hand... | code_fim | hard | {
"lang": "python",
"repo": "swkim101/patcherex",
"path": "/tests/disabled_test_patch_master.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: swkim101/patcherex path: /tests/disabled_test_patch_master.py
#!/usr/bin/env python
import os
import nose
import struct
import subprocess
import logging
import multiprocessing
import sys
import patcherex.utils as utils
import patcherex
import shellphish_qemu
from patcherex.patch_master import P... | code_fim | hard | {
"lang": "python",
"repo": "swkim101/patcherex",
"path": "/tests/disabled_test_patch_master.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> <video id="{{ scene_name_lowercase }}" class="manim-video" controls src="{{ media_file_name }}"></video>
{% else %}
.. image:: {{ media_file_name }}
:align: center
:name: {{ scene_name_lowercase }}
{% endif %}
{% if not hide_code %}
.. raw:: html
<h5 class="example-header">{{ scene_name ... | code_fim | hard | {
"lang": "python",
"repo": "manim-kindergarten/manim",
"path": "/docs/source/manim_example_ext.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> setup.app = app
setup.config = app.config
setup.confdir = app.confdir
app.add_directive("manim-example", ManimExampleDirective)
metadata = {"parallel_read_safe": False, "parallel_write_safe": True}
return metadata
TEMPLATE = r"""
{% if not hide_code %}
.. raw:: html
<div ... | code_fim | hard | {
"lang": "python",
"repo": "manim-kindergarten/manim",
"path": "/docs/source/manim_example_ext.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: manim-kindergarten/manim path: /docs/source/manim_example_ext.py
from docutils import nodes
from docutils.parsers.rst import directives, Directive
import jinja2
import os
class skip_manim_node(nodes.Admonition, nodes.Element):
pass
def visit(self, node, name=""):
self.visit_admonitio... | code_fim | hard | {
"lang": "python",
"repo": "manim-kindergarten/manim",
"path": "/docs/source/manim_example_ext.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_postflight_page_status(self):
"""Check that a connection is made to the postflight"""
response = self.client.get('/postflight/')
self.assertEqual(response.status_code, 200)
# Create your tests here.<|fim_prefix|># repo: tjhobbs1/python-final path: /dashboard/tests.py... | code_fim | hard | {
"lang": "python",
"repo": "tjhobbs1/python-final",
"path": "/dashboard/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tjhobbs1/python-final path: /dashboard/tests.py
from django.test import TestCase
class TestCase(TestCase):
def test_dashboard_page_status(self):
<|fim_suffix|> """Check that a connection is made to the postflight"""
response = self.client.get('/postflight/')
self.asse... | code_fim | hard | {
"lang": "python",
"repo": "tjhobbs1/python-final",
"path": "/dashboard/tests.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Check that a connection is made to the postflight"""
response = self.client.get('/postflight/')
self.assertEqual(response.status_code, 200)
# Create your tests here.<|fim_prefix|># repo: tjhobbs1/python-final path: /dashboard/tests.py
from django.test import TestCase
class T... | code_fim | hard | {
"lang": "python",
"repo": "tjhobbs1/python-final",
"path": "/dashboard/tests.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PiochU19/image-loader path: /image_loader/image/utils.py
from io import BytesIO
from django.core.files.uploadedfile import InMemoryUploadedFile
from PIL import Image as PillowImage
from django.core import signing
from django.utils import timezone
from datetime import timedelta
from django.urls im... | code_fim | medium | {
"lang": "python",
"repo": "PiochU19/image-loader",
"path": "/image_loader/image/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def create_link(seconds, image_name, size):
"""
Function returns temporary link to the image
"""
token = signing.dumps([str(timezone.now() + timedelta(seconds=int(seconds))), image_name, size])
return settings.SERVER_PATH + reverse("image:dynamic-image", kwargs={"token": token})<|fim_p... | code_fim | hard | {
"lang": "python",
"repo": "PiochU19/image-loader",
"path": "/image_loader/image/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GenilsonMaranguape3/python-sdk path: /examples/visual_recognition_v4.py
import json
import os
from ibm_watson import VisualRecognitionV4
from ibm_watson.visual_recognition_v4 import FileWithMetadata, TrainingDataObject, Location, AnalyzeEnums
from ibm_cloud_sdk_core.authenticators import IAMAuthe... | code_fim | hard | {
"lang": "python",
"repo": "GenilsonMaranguape3/python-sdk",
"path": "/examples/visual_recognition_v4.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># analyze
dog_path = os.path.join(os.path.dirname(__file__), '../resources/dog.jpg')
giraffe_path = os.path.join(os.path.dirname(__file__), '../resources/my-giraffe.jpeg')
with open(dog_path, 'rb') as dog_file, open(giraffe_path, 'rb') as giraffe_files:
analyze_images = service.analyze(
collec... | code_fim | medium | {
"lang": "python",
"repo": "GenilsonMaranguape3/python-sdk",
"path": "/examples/visual_recognition_v4.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># add image training data
training_data = service.add_image_training_data(
collection_id,
image_id,
objects=[
TrainingDataObject(object='giraffe training data',
location=Location(64, 270, 755, 784))
]).get_result()
# train collection
train_result = servi... | code_fim | hard | {
"lang": "python",
"repo": "GenilsonMaranguape3/python-sdk",
"path": "/examples/visual_recognition_v4.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pulumi/pulumi-kong path: /sdk/python/pulumi_kong/consumer_oauth2.py
uris: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
tags: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None):
"""
Input properties used for looking up and filtering Consumer... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-kong",
"path": "/sdk/python/pulumi_kong/consumer_oauth2.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @consumer_id.setter
def consumer_id(self, value: Optional[pulumi.Input[str]]):
pulumi.set(self, "consumer_id", value)
@property
@pulumi.getter(name="hashSecret")
def hash_secret(self) -> Optional[pulumi.Input[bool]]:
"""
A boolean flag that indicates whether th... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-kong",
"path": "/sdk/python/pulumi_kong/consumer_oauth2.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param str resource_name: The name of the resource.
:param ConsumerOauth2Args args: The arguments to use to populate this resource's properties.
:param pulumi.ResourceOptions opts: Options for the resource.
"""
...
def __init__(__self__, resource_name: str, *arg... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-kong",
"path": "/sdk/python/pulumi_kong/consumer_oauth2.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>running = True
while running:
print:("the model has " + str(count_predictions) + "predictions. Which one do you want to see. " )
requested_index = input("====>")
if requested_index is "quit":
running = False
requested_index = int(requested_index)
if type(requested_i... | code_fim | medium | {
"lang": "python",
"repo": "chickenLags/gestures",
"path": "/HandMovementTracking/tester.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chickenLags/gestures path: /HandMovementTracking/tester.py
import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
import Common
common = Common()
(x_train, y_train), (x_test, y_test) = common.load_dataset()
x_train = tf.keras.utils.normalize(x_train, axis=1)
x_test = tf.kera... | code_fim | medium | {
"lang": "python",
"repo": "chickenLags/gestures",
"path": "/HandMovementTracking/tester.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if requested_index is "quit":
running = False
requested_index = int(requested_index)
if type(requested_index) is not int:
print("Please enter a number without other characters.")
elif requested_index >= count_predictions:
print("Please enter an index below... | code_fim | hard | {
"lang": "python",
"repo": "chickenLags/gestures",
"path": "/HandMovementTracking/tester.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> d = {'Book, Section': 'Book chapter',
'Book, Whole': 'Book',
'Conference Proceedings': 'Conference Object',
'Dissertation/Thesis, Unpublished': 'Doctoral Thesis',
'Generic': 'other',
'Monograph': 'Book',
... | code_fim | hard | {
"lang": "python",
"repo": "evelthon/RefWorks-to-DSpace",
"path": "/convert.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evelthon/RefWorks-to-DSpace path: /convert.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv as csv
from collections import OrderedDict
class SpreadSheet:
def __init__(self):
self.di = OrderedDict()
self.csvRow = None
return None
def exportCSV(self):
... | code_fim | hard | {
"lang": "python",
"repo": "evelthon/RefWorks-to-DSpace",
"path": "/convert.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def rename_type(self):
d = {'Book, Section': 'Book chapter',
'Book, Whole': 'Book',
'Conference Proceedings': 'Conference Object',
'Dissertation/Thesis, Unpublished': 'Doctoral Thesis',
'Generic': 'other',
'Monogra... | code_fim | hard | {
"lang": "python",
"repo": "evelthon/RefWorks-to-DSpace",
"path": "/convert.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brianlorenz/COSMOS_IMACS_Redshifts path: /PlotCodes/Plot_R23.py
#Creates an R23 diagram - see Kewley and Ellison (2008)
import numpy as np
import matplotlib.pyplot as plt
from astropy.io import ascii
import sys, os, string
import pandas as pd
from astropy.io import fits
import collections
#Fold... | code_fim | hard | {
"lang": "python",
"repo": "brianlorenz/COSMOS_IMACS_Redshifts",
"path": "/PlotCodes/Plot_R23.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#More plot properties
lw=0.5
mark='o'
ms=3
#Make the figures
fig,axarr = plt.subplots(1,3,figsize=(24,7),sharex=True,sharey=True)
#Plot the data with error bars
c = 0
for ax in axarr:
if c==0:
col = 'good'
color = 'blue'
elif c==1:
col = 'low'
color = 'orange'
... | code_fim | hard | {
"lang": "python",
"repo": "brianlorenz/COSMOS_IMACS_Redshifts",
"path": "/PlotCodes/Plot_R23.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ric2b/Vivaldi-browser path: /chromium/third_party/blink/web_tests/external/wpt/webdriver/tests/support/image.py
import math
import struct
from base64 import decodebytes
<|fim_suffix|> assert_png(screenshot)
image = decodebytes(screenshot.encode())
width, height = struct.unpack(">LL", ... | code_fim | medium | {
"lang": "python",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/blink/web_tests/external/wpt/webdriver/tests/support/image.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_png(screenshot)
image = decodebytes(screenshot.encode())
width, height = struct.unpack(">LL", image[16:24])
return int(width), int(height)<|fim_prefix|># repo: ric2b/Vivaldi-browser path: /chromium/third_party/blink/web_tests/external/wpt/webdriver/tests/support/image.py
import mat... | code_fim | easy | {
"lang": "python",
"repo": "ric2b/Vivaldi-browser",
"path": "/chromium/third_party/blink/web_tests/external/wpt/webdriver/tests/support/image.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return b58encode(addr)
def encode_point(pubkey, compressed=False):
order = generator_secp256k1.order()
p = pubkey.pubkey.point
x_str = ecdsa.util.number_to_string(p.x(), order)
y_str = ecdsa.util.number_to_string(p.y(), order)
if compressed:
return chr(2 + (p.y() & 1... | code_fim | hard | {
"lang": "python",
"repo": "black-wolfie/blockchain-with-python-3",
"path": "/blockchains-cryptos/BTC_P2PKH_sigvef.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: black-wolfie/blockchain-with-python-3 path: /blockchains-cryptos/BTC_P2PKH_sigvef.py
# -*- coding: utf-8 -*-
# Verifying BTC messages for Python 3!
# original Python 2 file:
# https://github.com/stequald/bitcoin-sign-message/blob/master/signmessage.py
# usages:
"""
import BTC_P2PKH_sigvef as bv
... | code_fim | hard | {
"lang": "python",
"repo": "black-wolfie/blockchain-with-python-3",
"path": "/blockchains-cryptos/BTC_P2PKH_sigvef.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> obj_list = [('Table', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Table', [10, 25, 20, 35], 1), ('Table', [25, 25, 35, 35], 1),
('NotTable', [10, 22, 35, 23], 1)]
expected_list = [('Table', [10, 10, 35, 20], 1), ('NotTable', [10, 22, 35, 23], 1), ('Table... | code_fim | hard | {
"lang": "python",
"repo": "hadarohana/myCosmos",
"path": "/cosmos/tests/postprocess/test_group.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> actual_list = group_cls(obj_list, 'Table')
unittest.TestCase().assertCountEqual(expected_list, actual_list)
def test_merge_two_leave_one():
obj_list = [('Table', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Table', [10, 25, 20, 35], 1), ('Table', [25, 25, 35, 35], 1... | code_fim | hard | {
"lang": "python",
"repo": "hadarohana/myCosmos",
"path": "/cosmos/tests/postprocess/test_group.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hadarohana/myCosmos path: /cosmos/tests/postprocess/test_group.py
"""
Testing for group_cls
"""
import ipdb
from postprocess.postprocess import group_cls
import unittest
def test_basic_merge():
obj_list = [('Table', [10, 10, 20, 20], 1), ('Table', [25, 10, 35, 20], 1),
('Tab... | code_fim | hard | {
"lang": "python",
"repo": "hadarohana/myCosmos",
"path": "/cosmos/tests/postprocess/test_group.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|>list2x3 = list2 * 3
print("list2 * 3: ", list2x3)
hasThree = "Three" in list2
print("'Three' in list2? ", hasThree)<|fim_prefix|># repo: Dev-Learn/LearnPython path: /syntax/list/listOperatorsExample.py
list1 = [1, 2, 3]
list2 = ["One", "Two"]
print("list1: ", list1)
print("list2: ", list2)
print("\n... | code_fim | easy | {
"lang": "python",
"repo": "Dev-Learn/LearnPython",
"path": "/syntax/list/listOperatorsExample.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dev-Learn/LearnPython path: /syntax/list/listOperatorsExample.py
list1 = [1, 2, 3]
list2 = ["One", "Two"]
print("list1: ", list1)
print("list2: ", list2)
print("\n")
list12 = list1 + list2
<|fim_suffix|>list2x3 = list2 * 3
print("list2 * 3: ", list2x3)
hasThree = "Three" in list2
print("'T... | code_fim | easy | {
"lang": "python",
"repo": "Dev-Learn/LearnPython",
"path": "/syntax/list/listOperatorsExample.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("list2 * 3: ", list2x3)
hasThree = "Three" in list2
print("'Three' in list2? ", hasThree)<|fim_prefix|># repo: Dev-Learn/LearnPython path: /syntax/list/listOperatorsExample.py
list1 = [1, 2, 3]
list2 = ["One", "Two"]
print("list1: ", list1)
print("list2: ", list2)
print("\n")
<|fim_middle|>lis... | code_fim | medium | {
"lang": "python",
"repo": "Dev-Learn/LearnPython",
"path": "/syntax/list/listOperatorsExample.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return pos and pos == "VBD"
def is_adj(pos):
return pos and pos.startswith("JJ")
def is_pronoun(pos):
return pos and pos.startswith("PRP")
def is_adv(pos):
return pos and pos.startswith("RB")
def is_num(pos):
return pos and pos == "CD"
def merge_neighbor_identical_tag(word_pos_tag... | code_fim | hard | {
"lang": "python",
"repo": "gajanlee/SLN-Summarization",
"path": "/src/sln_summ/sln_construction.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gajanlee/SLN-Summarization path: /src/sln_summ/sln_construction.py
self_reasoning(set(link_clue_words.keys())),
CONDITION_LINK_NAME: {
SEQUENTIAL_LINK_NAME: CONDITION_LINK_NAME,
CONDITION_LINK_NAME: CONDITION_LINK_NAME,
SIMILAR_LINK_NAME: CONDITION_LINK_NAME,
},
... | code_fim | hard | {
"lang": "python",
"repo": "gajanlee/SLN-Summarization",
"path": "/src/sln_summ/sln_construction.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not from_node and not to_node and links:
from_node = PLACEHOLDER_NODE_NAME
if to_node or (i >= len(word_pos_tags) - 1 and from_node and links):
to_node = to_node if to_node else PLACEHOLDER_NODE_NAME
for link in links:
for app... | code_fim | hard | {
"lang": "python",
"repo": "gajanlee/SLN-Summarization",
"path": "/src/sln_summ/sln_construction.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_filters():
filters = []
for can_id in get_can_ids():
filters.append({"can_id": can_id, "can_mask": CAN_MASK, "extended": False})
return filters
def get_can_ids():
can_ids = []
can_ids.extend(ECU_ADDRESSES)
can_ids.extend(TARGET_ADDRESSES)
return can_ids<|fim_p... | code_fim | hard | {
"lang": "python",
"repo": "lbenthins/ecu-simulator",
"path": "/loggers/logger_can.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lbenthins/ecu-simulator path: /loggers/logger_can.py
import can
from loggers import logger_utils
from addresses import ECU_ADDRESSES, TARGET_ADDRESSES
LOG_TYPE = "can"
BUS_TYPE = "socketcan_native"
CAN_MASK = 0x7FF
def start():
<|fim_suffix|> return can.interface.Bus(channel=logger_utils.... | code_fim | hard | {
"lang": "python",
"repo": "lbenthins/ecu-simulator",
"path": "/loggers/logger_can.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wangwang55/blue-marlin path: /Model/predictor_dl_model/predictor_dl_model/trainer/tfrecord_reader.py
import tensorflow as tf
from feeder import VarFeeder
import os
import argparse
import pandas as pd
import numpy
import logging
import yaml
import datetime
import math
import numpy as np
... | code_fim | hard | {
"lang": "python",
"repo": "wangwang55/blue-marlin",
"path": "/Model/predictor_dl_model/predictor_dl_model/trainer/tfrecord_reader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dow =[(a,b) for a,b in zip(tf_stat['dow_sin'],tf_stat['dow_cos'])]
with tf.Session() as sess:
x = sess.run(next_el)
l1 = x[19][0]
l2 = x[20][0]
m = [[v] for v in l1]
[m[i].append(l2[i]) for i in range(0, len(l1))]
page_indx = list(x[18])... | code_fim | hard | {
"lang": "python",
"repo": "wangwang55/blue-marlin",
"path": "/Model/predictor_dl_model/predictor_dl_model/trainer/tfrecord_reader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(cfg['tf_statistics_path'], 'rb') as f:
tf_stat = pickle.load(f)
names = []
tfrecord_location = cfg['tfrecords_local_path']
for file in os.listdir(tfrecord_location):
if file.startswith("part"):
names.append(file)
file_paths = [os.path.... | code_fim | hard | {
"lang": "python",
"repo": "wangwang55/blue-marlin",
"path": "/Model/predictor_dl_model/predictor_dl_model/trainer/tfrecord_reader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: likelyzhao/lightweightcnn path: /image-classification/test_score.py
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF license... | code_fim | hard | {
"lang": "python",
"repo": "likelyzhao/lightweightcnn",
"path": "/image-classification/test_score.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
(speed,r) = score_with_thresh(threshold = args.thrshold , load_epoch = args.load_epoch,image_shape = args.image_shape,model=args.pretrained_model, data_val=args.test_rec,rgb_mean='123.68,116.779,103.939', **kwargs)
print('Tested %s, acc = %f, speed = %f img/sec' % (args.pretrained_model, r, s... | code_fim | hard | {
"lang": "python",
"repo": "likelyzhao/lightweightcnn",
"path": "/image-classification/test_score.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.