text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> try:
new_path = safe_join(base, value)
except SuspiciousFileOperation:
raise ValidationError("Relative paths are not allowed.")
valid_path = new_path[len(base) :]
if value != valid_path:
raise ValidationError(f"Invalid file path, should be {valid_path}.")<|fim_pre... | code_fim | medium | {
"lang": "python",
"repo": "njmhendrix/grand-challenge.org",
"path": "/app/grandchallenge/components/validators.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Carla-Ferreira/BiorbdOptim path: /examples/muscle_driven_ocp/static_arm.py
import biorbd
from biorbd_optim import (
OptimalControlProgram,
ObjectiveList,
Objective,
DynamicsTypeList,
DynamicsType,
BoundsList,
QAndQDotBounds,
InitialConditionsList,
ShowResult,
... | code_fim | hard | {
"lang": "python",
"repo": "Carla-Ferreira/BiorbdOptim",
"path": "/examples/muscle_driven_ocp/static_arm.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Initial guess
x_init = InitialConditionsList()
x_init.add([1.57] * biorbd_model.nbQ() + [0] * biorbd_model.nbQdot())
# Define control path constraint
u_bounds = BoundsList()
u_bounds.add(
[
[tau_min] * biorbd_model.nbGeneralizedTorque() + [muscle_min] * biorb... | code_fim | hard | {
"lang": "python",
"repo": "Carla-Ferreira/BiorbdOptim",
"path": "/examples/muscle_driven_ocp/static_arm.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
ocp = prepare_ocp(biorbd_model_path="arm26.bioMod", final_time=2, number_shooting_points=20)
# --- Solve the program --- #
sol = ocp.solve(show_online_optim=True)
# --- Show results --- #
result = ShowResult(ocp, sol)
result.animate()<|fim_prefix|># re... | code_fim | hard | {
"lang": "python",
"repo": "Carla-Ferreira/BiorbdOptim",
"path": "/examples/muscle_driven_ocp/static_arm.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j, row in enumerate(rows):
indices = range(rows[j] - lookback, rows[j], step)
samples[j] = data[indices]
targets[j] = data[rows[j] + delay][1]
yield samples, targets
lookback = 1440
step = 6
delay = 144
batch_size = 128
train_gen = generator(
... | code_fim | hard | {
"lang": "python",
"repo": "slaily/deep-learning-bits",
"path": "/rnn_jena_climate/run_nn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: slaily/deep-learning-bits path: /rnn_jena_climate/run_nn.py
import os
import numpy as np
import matplotlib.pyplot as plt
from keras.models import Sequential
from keras import layers
from keras.optimizers import RMSprop
data_dir = '/Users/iliyanslavov/Downloads/jena_climate'
fname = os.path.jo... | code_fim | hard | {
"lang": "python",
"repo": "slaily/deep-learning-bits",
"path": "/rnn_jena_climate/run_nn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while 1:
if shuffle:
rows = np.random.randint(
min_index + lookback, max_index, size=batch_size
)
else:
if i + batch_size >= max_index:
i = min_index + lookback
rows = np.arange(i, min(i + batch_size, max_... | code_fim | hard | {
"lang": "python",
"repo": "slaily/deep-learning-bits",
"path": "/rnn_jena_climate/run_nn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from pytest import main
if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0])
sys.exit(main())<|fim_prefix|># repo: eduadiez/blockchain path: /tools/bridge/pytest
#! /usr/bin/env python
"""Run pytest with gevent's monkeypatching applied"""
from gevent imp... | code_fim | easy | {
"lang": "python",
"repo": "eduadiez/blockchain",
"path": "/tools/bridge/pytest",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eduadiez/blockchain path: /tools/bridge/pytest
#! /usr/bin/env python
"""Run pytest with gevent's monkeypatching applied"""
<|fim_suffix|>import re
import sys
from pytest import main
if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0])
sys.exit(... | code_fim | medium | {
"lang": "python",
"repo": "eduadiez/blockchain",
"path": "/tools/bridge/pytest",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
sys.argv[0] = re.sub(r"(-script\.pyw?|\.exe)?$", "", sys.argv[0])
sys.exit(main())<|fim_prefix|># repo: eduadiez/blockchain path: /tools/bridge/pytest
#! /usr/bin/env python
"""Run pytest with gevent's monkeypatching applied"""
from gevent import monkey # isort:skip
... | code_fim | easy | {
"lang": "python",
"repo": "eduadiez/blockchain",
"path": "/tools/bridge/pytest",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Shulichenko-git/openprocurement.api path: /src/openprocurement/tender/limited/views/award_document.py
# -*- coding: utf-8 -*-
from openprocurement.api.utils import (
json_view,
)
from openprocurement.tender.belowthreshold.views.award_document import TenderAwardDocumentResource
from openprocur... | code_fim | medium | {
"lang": "python",
"repo": "Shulichenko-git/openprocurement.api",
"path": "/src/openprocurement/tender/limited/views/award_document.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@optendersresource(
name="negotiation.quick:Tender Award Documents",
collection_path="/tenders/{tender_id}/awards/{award_id}/documents",
path="/tenders/{tender_id}/awards/{award_id}/documents/{document_id}",
procurementMethodType="negotiation.quick",
description="Tender award document... | code_fim | hard | {
"lang": "python",
"repo": "Shulichenko-git/openprocurement.api",
"path": "/src/openprocurement/tender/limited/views/award_document.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> - Full path and name of the firewall log file
- notconfigured
maxfilesize:
- 1 - 32767 (Kb)
- notconfigured
store (str):
The store to use. This is either the local firewall policy or the
policy d... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/salt/utils/win_lgpo_netsh.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> profile (str):
The firewall profile to configure. Valid options are:
- domain
- public
- private
inbound (str):
The inbound setting. If ``None`` is passed, the setting will remain
unchanged. Valid values are:
... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/salt/utils/win_lgpo_netsh.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: saltstack/salt path: /salt/utils/win_lgpo_netsh.py
store='lgpo')
# Get all firewall settings for connections on the domain profile
salt.utils.win_lgpo_netsh.get_all_settings(profile='domain')
# Get all firewall settings for connections on the domain profile as
# defined by loca... | code_fim | hard | {
"lang": "python",
"repo": "saltstack/salt",
"path": "/salt/utils/win_lgpo_netsh.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> classes: TypeList[TypeTuple[str, str, TypeAny]] = [
("xgboost.DMatrix", "xgboost.DMatrix", xgb.core.DMatrix),
("xgboost.core.DMatrix", "xgboost.core.DMatrix", xgb.core.DMatrix),
("xgboost.core.Booster", "xgboost.core.Booster", xgb.core.Booster),
(
"xgboost.c... | code_fim | hard | {
"lang": "python",
"repo": "Metrix1010/PySyft",
"path": "/packages/syft/src/syft/lib/xgboost/__init__.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Metrix1010/PySyft path: /packages/syft/src/syft/lib/xgboost/__init__.py
"""Partial-dependency library, runs when user loads xgboost.
__init__ file for sklearn. This defines various modules, classes and methods which we currently support.
We create an AST for all these modules, classes and method... | code_fim | hard | {
"lang": "python",
"repo": "Metrix1010/PySyft",
"path": "/packages/syft/src/syft/lib/xgboost/__init__.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: e-davydenkova/SeleniumWebDriver_Training path: /stickers_search.py
from selenium import webdriver
driver = webdriver.Chrome()
<|fim_suffix|>products_list = driver.find_elements_by_css_selector("div li.product.column.shadow.hover-light")
#stickers_list = driver.find_elements_by_css_selector("div... | code_fim | medium | {
"lang": "python",
"repo": "e-davydenkova/SeleniumWebDriver_Training",
"path": "/stickers_search.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>products_list = driver.find_elements_by_css_selector("div li.product.column.shadow.hover-light")
#stickers_list = driver.find_elements_by_css_selector("div li.product.column.shadow.hover-light .sticker")
for i in range(len(products_list)):
sticker = products_list[i].find_elements_by_class_name("stick... | code_fim | medium | {
"lang": "python",
"repo": "e-davydenkova/SeleniumWebDriver_Training",
"path": "/stickers_search.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PaddlePaddle/Paddle path: /test/dygraph_to_static/test_decorator_transform.py
# Copyright (c) 2021 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a... | code_fim | hard | {
"lang": "python",
"repo": "PaddlePaddle/Paddle",
"path": "/test/dygraph_to_static/test_decorator_transform.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> funcs = [fun1, fun2, fun3, fun4, fun5, fun6, fun7, fun8]
out = []
for idx, fun in enumerate(funcs):
out.append(fun(idx + 1, idx + 1))
return out
@contextmanager
def contextmanager_warning():
yield
@contextmanager_warning()
def fun9():
print('in fun9 want contextmanager ... | code_fim | hard | {
"lang": "python",
"repo": "PaddlePaddle/Paddle",
"path": "/test/dygraph_to_static/test_decorator_transform.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: realms-team/solmanager path: /libs/smartmeshsdk-REL-1.3.0.1/app/RangeTest/RangeTest.py
#!/usr/bin/python
#============================ adjust path =====================================
import sys
import os
if __name__ == "__main__":
here = sys.path[0]
sys.path.insert(0, os.path.join(her... | code_fim | hard | {
"lang": "python",
"repo": "realms-team/solmanager",
"path": "/libs/smartmeshsdk-REL-1.3.0.1/app/RangeTest/RangeTest.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #======================== public ==========================================
def run(self):
while self.goOn:
try:
# create a connector
self.connector = IpMoteConnector.IpMoteConnector()
# connect to the manager
... | code_fim | hard | {
"lang": "python",
"repo": "realms-team/solmanager",
"path": "/libs/smartmeshsdk-REL-1.3.0.1/app/RangeTest/RangeTest.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hirni-Meshram2/pants path: /src/python/pants/backend/python/lint/docformatter/rules.py
# Copyright 2020 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
from dataclasses import dataclass
from typing import Tuple
from pants.backend... | code_fim | hard | {
"lang": "python",
"repo": "Hirni-Meshram2/pants",
"path": "/src/python/pants/backend/python/lint/docformatter/rules.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class DocformatterRequest(PythonFmtRequest, LintRequest):
field_set_type = DocformatterFieldSet
@dataclass(frozen=True)
class SetupRequest:
request: DocformatterRequest
check_only: bool
@dataclass(frozen=True)
class Setup:
process: Process
original_digest: Digest
def generate_ar... | code_fim | hard | {
"lang": "python",
"repo": "Hirni-Meshram2/pants",
"path": "/src/python/pants/backend/python/lint/docformatter/rules.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Builds a square graph with costs for testing."""
if directed:
graph = DirectedGraph()
else:
graph = UndirectedGraph()
graph.new_node()
graph.new_node()
graph.new_node()
graph.new_node()
graph.new_edge(1, 2, 2)
graph.new_edge(1, 4, 10)
graph.new_e... | code_fim | hard | {
"lang": "python",
"repo": "Fynardo/pygraph",
"path": "/tests/utility_functions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Fynardo/pygraph path: /tests/utility_functions.py
"""Provides utility functions for unit testing."""
from ..pygraph import (DirectedGraph, UndirectedGraph,
build_triangle_graph, build_k5_graph, build_k33_graph, build_5_cycle_graph,
merge_graphs)
def bu... | code_fim | hard | {
"lang": "python",
"repo": "Fynardo/pygraph",
"path": "/tests/utility_functions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> merge_graphs(graph, addition_graph)
return graph
def build_non_planar_disconnected_test_graph_with_k5_subgraph():
"""Builds a disconnected test graph that contains K5 as a subgraph, and is thus non-planar."""
graph = build_triangle_graph()
addition_graph = build_k5_graph()
addit... | code_fim | hard | {
"lang": "python",
"repo": "Fynardo/pygraph",
"path": "/tests/utility_functions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ostotem.cern.ch//eos/cms/store/group/phys_pps/reconstruction/2018/alignment_run_April/version8/run_314273.17_re_reco.root")
input_files.append("root://eostotem.cern.ch//eos/cms/store/group/phys_pps/reconstruction/2018/alignment_run_April/version8/run_314273.18_re_reco.root")
input_files.append("root://e... | code_fim | hard | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/CalibPPS/AlignmentGlobal/test/input_files_reference_cff.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-sw/cmssw path: /CalibPPS/AlignmentGlobal/test/input_files_reference_cff.py
les = cms.untracked.vstring()
input_files.append("root://eostotem.cern.ch//eos/cms/store/group/phys_pps/reconstruction/2018/alignment_run_April/version8/run_314273.0_re_reco.root")
input_files.append("root://eostotem... | code_fim | hard | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/CalibPPS/AlignmentGlobal/test/input_files_reference_cff.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-sw/cmssw path: /CalibPPS/AlignmentGlobal/test/input_files_reference_cff.py
d("root://eostotem.cern.ch//eos/cms/store/group/phys_pps/reconstruction/2018/alignment_run_April/version8/run_314273.113_re_reco.root")
input_files.append("root://eostotem.cern.ch//eos/cms/store/group/phys_pps/reconst... | code_fim | hard | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/CalibPPS/AlignmentGlobal/test/input_files_reference_cff.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bethlakshmi/gbe-divio-djangocms-python2.7 path: /gbe/models/style_group.py
from django.db.models import (
CASCADE,
CharField,
IntegerField,
ManyToManyField,
Model,
TextField,
)
from gbe.models import TestURL
<|fim_suffix|> class Meta:
app_label = "gbe"
... | code_fim | hard | {
"lang": "python",
"repo": "bethlakshmi/gbe-divio-djangocms-python2.7",
"path": "/gbe/models/style_group.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
app_label = "gbe"
ordering = ['name', ]<|fim_prefix|># repo: bethlakshmi/gbe-divio-djangocms-python2.7 path: /gbe/models/style_group.py
from django.db.models import (
CASCADE,
CharField,
IntegerField,
ManyToManyField,
Model,
TextField,
)
from gbe.mo... | code_fim | easy | {
"lang": "python",
"repo": "bethlakshmi/gbe-divio-djangocms-python2.7",
"path": "/gbe/models/style_group.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> app_label = "gbe"
ordering = ['name', ]<|fim_prefix|># repo: bethlakshmi/gbe-divio-djangocms-python2.7 path: /gbe/models/style_group.py
from django.db.models import (
CASCADE,
CharField,
IntegerField,
ManyToManyField,
Model,
TextField,
)
from gbe.models import Test... | code_fim | easy | {
"lang": "python",
"repo": "bethlakshmi/gbe-divio-djangocms-python2.7",
"path": "/gbe/models/style_group.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SomHackathon2020/somhackathon2020-pacmantaro path: /PacManTaro/pdf_form.py
from flask import (
Blueprint,
render_template,
redirect,
url_for,
request,
flash,
jsonify,
send_file,
)
from flask_login import login_user, logout_user, login_required, current_user
from we... | code_fim | hard | {
"lang": "python",
"repo": "SomHackathon2020/somhackathon2020-pacmantaro",
"path": "/PacManTaro/pdf_form.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from __init__ import db
pdf_form = Blueprint("pdf_form", __name__)
def create_overlay(
nom_act: str = "nombre de la actividad",
desc: str = "descripción", # max 90 caracteres
data_ini: str = "fecha de inicio",
data_fin: str = "fecha de finalización",
h11: str = "12:00",
h12: st... | code_fim | hard | {
"lang": "python",
"repo": "SomHackathon2020/somhackathon2020-pacmantaro",
"path": "/PacManTaro/pdf_form.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AndrewJLang/Curbside-Recycling path: /Sound Processing/PCA.py
import numpy as np
from glob import glob
from scipy import spatial
import librosa as lb
from sklearn.decomposition import PCA
plasticBottles = "../blue_background_sample_images/PCA_audio/plastic_bottles"
plasticBottles = glob(plasticB... | code_fim | hard | {
"lang": "python",
"repo": "AndrewJLang/Curbside-Recycling",
"path": "/Sound Processing/PCA.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>canPCA = np.array(pcaAnalysis(canFFT))
print(canPCA.shape)
print(f"Bottle transform data: {canPCA}")
ballPCA = np.array(pcaAnalysis(ballFFT))
print(ballPCA.shape)
print(f"Bottle transform data: {ballPCA}")
#This should return a value between -1 and 1 I believe, with 0 being they are the exact same audio... | code_fim | hard | {
"lang": "python",
"repo": "AndrewJLang/Curbside-Recycling",
"path": "/Sound Processing/PCA.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pavasich/invert_imdb_actor_data path: /strip_excess.py
import os, re
# current directory
# place the actor file in the same one
path = os.path.dirname(os.path.abspath(__file__))
FNAME = 'stripped_data.out'
FPATH = os.path.join(path, FNAME)
outf = open(FPATH, 'w')
inf = open('actors.list', 'r... | code_fim | hard | {
"lang": "python",
"repo": "pavasich/invert_imdb_actor_data",
"path": "/strip_excess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # remove excess characters
line = regex.sub('', line)
# check if an actor name is in this line
actor_maybe = get_actor.match(line)
if actor_maybe:
# write the previous actor's movies
for key in db:
outf.write(key + '\n')
# clear the d... | code_fim | hard | {
"lang": "python",
"repo": "pavasich/invert_imdb_actor_data",
"path": "/strip_excess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>db = {}
while True:
line = inf.readline()
# EOF
if not line:
break
# remove excess characters
line = regex.sub('', line)
# check if an actor name is in this line
actor_maybe = get_actor.match(line)
if actor_maybe:
# write the previous actor's movie... | code_fim | hard | {
"lang": "python",
"repo": "pavasich/invert_imdb_actor_data",
"path": "/strip_excess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pauleveritt/kaybee path: /tests/unit/plugins/references/test_references_handlers.py
import pytest
from sphinx.application import Sphinx
from kaybee.plugins.references.container import ReferencesContainer
from kaybee.plugins.references.handlers import (
add_document_reference,
initialize_... | code_fim | hard | {
"lang": "python",
"repo": "pauleveritt/kaybee",
"path": "/tests/unit/plugins/references/test_references_handlers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> references_sphinx_env):
validate_references(references_kb_app, html_builder,
references_sphinx_env)
class TestMissingReference:
def test_import(self):
assert 'missing_reference' == missing_reference.__name__
def test_explicit(self, r... | code_fim | hard | {
"lang": "python",
"repo": "pauleveritt/kaybee",
"path": "/tests/unit/plugins/references/test_references_handlers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ykanggit/web2py-appliances path: /MovieReviews/controllers/default.py
# -*- coding: utf-8 -*-
#########################################################################
## This is a samples controller
## - index is the default action of any application
## - user is required for authentication and... | code_fim | hard | {
"lang": "python",
"repo": "ykanggit/web2py-appliances",
"path": "/MovieReviews/controllers/default.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@auth.requires_login()
def format():
return dict(form4=crud.create(db.format),
format=db(db.format.id>0).select())
def start():
return dict (string="Start",)
def rules():
return dict (string="Rules and Regulations",)
@auth.requires_login()
def movies():
if not request.v... | code_fim | hard | {
"lang": "python",
"repo": "ykanggit/web2py-appliances",
"path": "/MovieReviews/controllers/default.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nocproject/noc path: /sa/profiles/Huawei/MA5600T/get_version.py
# ---------------------------------------------------------------------
# Huawei.MA5600T.get_version
# ---------------------------------------------------------------------
# Copyright (C) 2007-2017 The NOC Project
# See LICENSE for ... | code_fim | hard | {
"lang": "python",
"repo": "nocproject/noc",
"path": "/sa/profiles/Huawei/MA5600T/get_version.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def execute_cli(self):
v = self.cli("display version")
match = self.rx_ver1.search(v)
if match:
platform = match.group("platform")
platform1 = match.group("platform1")
if platform1 and platform1 != platform:
platform = platfor... | code_fim | hard | {
"lang": "python",
"repo": "nocproject/noc",
"path": "/sa/profiles/Huawei/MA5600T/get_version.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> rx_ver1 = re.compile(
r"^\s*(?P<platform>[UM]A\S+)(?P<version>V\d+R\d+\S*)\s*.+\n"
r"(^\s*PRODUCT (?P<platform1>MA\S+)\s*\n)?",
re.MULTILINE,
)
rx_ver2 = re.compile(
r"^\s*VERSION\s*:\s*MA\S+(?P<version>V\d+R\d+\S+)\s*\n"
r".+?"
r"^\s*PRODUCT\s+(... | code_fim | hard | {
"lang": "python",
"repo": "nocproject/noc",
"path": "/sa/profiles/Huawei/MA5600T/get_version.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, hu_lis=[0], norm_lis=[0], smooth_lis=[0], norm=False):
super(Adapt_transform2, self).__init__()
self.norm_lis = nn.Parameter(torch.FloatTensor(norm_lis))
self.hu_lis = nn.Parameter(torch.FloatTensor(hu_lis))
self.smooth_lis = nn.Parameter(torch.FloatT... | code_fim | hard | {
"lang": "python",
"repo": "captaint-tao/NinaProNet",
"path": "/networks/Adapt_transform.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(Adapt_transform3, self).__init__()
self.base_hu = base_hu
self.base_norm = base_norm
self.hu_lis = nn.Parameter(torch.FloatTensor(hu_lis))
self.norm_lis = nn.Parameter(torch.FloatTensor(norm_lis))
self.smooth_lis = nn.Parameter(torch.FloatTensor(smooth... | code_fim | hard | {
"lang": "python",
"repo": "captaint-tao/NinaProNet",
"path": "/networks/Adapt_transform.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: captaint-tao/NinaProNet path: /networks/Adapt_transform.py
from __future__ import print_function
from networks.module import Module
import torch
import torch.nn as nn
from networks.layers import TriResSeparateConv3D
import torch.nn.functional as F
import numpy as np
class Adapt_transform(Module)... | code_fim | hard | {
"lang": "python",
"repo": "captaint-tao/NinaProNet",
"path": "/networks/Adapt_transform.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FernandaPerezV/03Tarea path: /tareap1.py
import numpy as np
import matplotlib.pyplot as plt
'''Este script resuelve el oscilador de
Van der Pool, utilizando el metodo de runge-kutta
de orden 3. Se utilizan dos sets de condiciones
iniciales: 1) dy/ds=0, y=0.1 ;2) dy/ds=0 , y=4.
Finalmente grafica... | code_fim | hard | {
"lang": "python",
"repo": "FernandaPerezV/03Tarea",
"path": "/tareap1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> k1= get_k1(xn, vn, h, f_a_integrar)
k2= get_k2(yn, h, f_a_integrar)
f_eval= f_a_integrar(xn - k1[0] - 2*k2[0] , vn - k1[1] - 2*k2[1])
return h*f_eval[0], h*f_eval[1]
def rk3_step(xn,vn,h,f_a_integrar):
k1=get_k1(xn, vn, h, f_a_integrar)
k2=get_k2(xn, vn, h, f_a_integrar)
k3=g... | code_fim | hard | {
"lang": "python",
"repo": "FernandaPerezV/03Tarea",
"path": "/tareap1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@pytest.mark.parametrize(
'num1, num2, expected',
[(3, 5, 8), (-2, -2, -4), (-1, 5, 4), (3, -5, -2), (0, 5, 5)])
def test_sum(num1, num2, expected):
assert sum(num1, num2) == expected<|fim_prefix|># repo: leliel12/diseno_sci_sfw path: /legacy/unidad2/10_PBT/test_buggy_example.py
def sum(num1,... | code_fim | easy | {
"lang": "python",
"repo": "leliel12/diseno_sci_sfw",
"path": "/legacy/unidad2/10_PBT/test_buggy_example.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: leliel12/diseno_sci_sfw path: /legacy/unidad2/10_PBT/test_buggy_example.py
def sum(num1, num2):
"""Buggy logic"""
results = {
(3, 5): 8, (-2, -2): -4,
(-1, 5): 4, (3, -5): -2, (0, 5): 5}
return results.get((num1, num2))
<|fim_suffix|>
@pytest.mark.parametrize(
'n... | code_fim | easy | {
"lang": "python",
"repo": "leliel12/diseno_sci_sfw",
"path": "/legacy/unidad2/10_PBT/test_buggy_example.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> first_row = []
second_row = []
cmds_rows = []
for k, v in tracking.items():
first_row.append(k)
second_row.append(v)
for cmd in cmds:
row = []
row.append(" ".join(cmd.command))
row.append(cmd.stdout)
row.append(cmd.execution_time)
... | code_fim | hard | {
"lang": "python",
"repo": "uceasy/uceasy",
"path": "/src/uceasy/tracking.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: uceasy/uceasy path: /src/uceasy/tracking.py
r"""Provenance tracking module.
This CSV file stores information about how UCEasy was run,
such as system information and parameters used.
"""
import csv
import sys
import platform
import getpass
from datetime import datetime
from typing import List
... | code_fim | hard | {
"lang": "python",
"repo": "uceasy/uceasy",
"path": "/src/uceasy/tracking.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> app.add_crossref_type('phpref', 'phpref', ref_nodeclass=PhpRef)<|fim_prefix|># repo: bbatsche/Verify path: /docs/_extensions/phpref.py
from docutils.nodes import literal
class PhpRef(literal):
def __init__(self, rawsource='', text='', *children, **attributes):
<|fim_middle|> attributes['c... | code_fim | medium | {
"lang": "python",
"repo": "bbatsche/Verify",
"path": "/docs/_extensions/phpref.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bbatsche/Verify path: /docs/_extensions/phpref.py
from docutils.nodes import literal
<|fim_suffix|> attributes['classes'] = ['code', 'highlight', 'php']
literal.__init__(self, rawsource, text, *children, **attributes)
def setup(app):
app.add_crossref_type('phpref', 'phpref',... | code_fim | medium | {
"lang": "python",
"repo": "bbatsche/Verify",
"path": "/docs/_extensions/phpref.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def setup(app):
app.add_crossref_type('phpref', 'phpref', ref_nodeclass=PhpRef)<|fim_prefix|># repo: bbatsche/Verify path: /docs/_extensions/phpref.py
from docutils.nodes import literal
class PhpRef(literal):
<|fim_middle|> def __init__(self, rawsource='', text='', *children, **attributes):
... | code_fim | hard | {
"lang": "python",
"repo": "bbatsche/Verify",
"path": "/docs/_extensions/phpref.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alldatacenter/alldata path: /ai/modelscope/modelscope/models/nlp/space/model/intent_unified_transformer.py
# Copyright (c) Alibaba, Inc. and its affiliates.
import torch
import torch.nn as nn
import torch.nn.functional as F
from modelscope.utils.nlp.space.criterions import compute_kl_loss
from ... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/ai/modelscope/modelscope/models/nlp/space/model/intent_unified_transformer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> intent_label = torch.cat([inputs['intent_label'], inputs['intent_label']], dim=0) \
if self.with_rdrop or self.with_contrastive else inputs['intent_label']
if self.example:
intent_loss = self.loss_fct(
torch.log(outputs['intent_probs'] + 1e-12).view... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/ai/modelscope/modelscope/models/nlp/space/model/intent_unified_transformer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return outputs
def _collect_metrics(self, inputs, outputs, with_label, data_file):
metrics = {}
batch_size = inputs['src_token'].size(0)
intent_label = torch.cat([inputs['intent_label'], inputs['intent_label']], dim=0) \
if self.with_rdrop or self.with_co... | code_fim | hard | {
"lang": "python",
"repo": "alldatacenter/alldata",
"path": "/ai/modelscope/modelscope/models/nlp/space/model/intent_unified_transformer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if feminino_menor_que_20_anos >= 1:
print('{} mulher(es) tem menos de 20 anos!'.format(feminino_menor_que_20_anos))
else:
print('Mediante aos seu dados fornecidos, não identificamos nenhum genero feminino abaixo dos 20 anos!')
print('ACABOU!!!')<|fim_prefix|># repo: wtomalves/exerciciopython pat... | code_fim | hard | {
"lang": "python",
"repo": "wtomalves/exerciciopython",
"path": "/ex056cadastro.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wtomalves/exerciciopython path: /ex056cadastro.py
nomes = []
idades = []
generos = []
idade_homem_mais_velho = 0
feminino_menor_que_20_anos = 0
for registro in range(1,5):
print('Cadastro número {}'.format(registro))
print('')
nome = input('Nome: ').strip().upper()
idade = int(inp... | code_fim | hard | {
"lang": "python",
"repo": "wtomalves/exerciciopython",
"path": "/ex056cadastro.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if next_node is None:
return
if (('B' in next_node.properties and not pos.to_play == go.BLACK) or
('W' in next_node.properties and not pos.to_play == go.WHITE)):
pos.flip_playerturn(mutate=True)
def replay_sgf(sgf_contents):
'''
Wrapper for sgf files, exposing cont... | code_fim | hard | {
"lang": "python",
"repo": "muyunren/AlphaGOZero-python-tensorflow",
"path": "/support/MuGo-master/sgf_wrapper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: muyunren/AlphaGOZero-python-tensorflow path: /support/MuGo-master/sgf_wrapper.py
'''
Code to extract a series of positions + their next moves from an SGF.
Most of the complexity here is dealing with two features of SGF:
- Stones can be added via "play move" or "add move", the latter being used
... | code_fim | hard | {
"lang": "python",
"repo": "muyunren/AlphaGOZero-python-tensorflow",
"path": "/support/MuGo-master/sgf_wrapper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> computador = randint(1,3)
print('O computador escolheu: {}\n\n'.format(lista[computador]))
if escolha == 1 and computador == 1:
print('Emppate')
elif escolha == 1 and computador == 2:
print('O computador ganhou')
elif escolha == 1 and computador == 3:
print('Voc... | code_fim | hard | {
"lang": "python",
"repo": "brenuvida/cursoemvideo",
"path": "/Aula12/exercicio_45.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brenuvida/cursoemvideo path: /Aula12/exercicio_45.py
from random import randint
print ('\n\n\nVamos jogar JOKENPÔ!!!\n\n\n')
escolha = int(input('Escolha PEDRA, PAPEL ou TESOURA:\n\n[1] PEDRA\n\n[2] PAPEL\n\n[3] TESOURA\n\nFaça a sua escolha: '))
<|fim_suffix|> computador = randint(1,3)
... | code_fim | hard | {
"lang": "python",
"repo": "brenuvida/cursoemvideo",
"path": "/Aula12/exercicio_45.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HyOsori/HungryOsori-PushServer path: /push/migrations/0016_auto_20170309_1307.py
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-03-09 04:07
from __future__ import unicode_literals
<|fim_suffix|>class Migration(migrations.Migration):
dependencies = [
('push', '0015_auto... | code_fim | medium | {
"lang": "python",
"repo": "HyOsori/HungryOsori-PushServer",
"path": "/push/migrations/0016_auto_20170309_1307.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='crawldata',
name='extra_data_1',
),
migrations.RemoveField(
model_name='crawldata',
name='extra_data_2',
),
migrations.RemoveField(
model_name='crawlda... | code_fim | medium | {
"lang": "python",
"repo": "HyOsori/HungryOsori-PushServer",
"path": "/push/migrations/0016_auto_20170309_1307.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Event(models.Model):
creator = models.ForeignKey('user.User', on_delete=models.SET_NULL, related_name="creator", null=True)
event_type = models.ForeignKey('event.EventType', on_delete=models.SET_NULL, related_name="event_type", null=True)
accepted = models.ManyToManyField('user.User', r... | code_fim | medium | {
"lang": "python",
"repo": "Bruin-Entrepreneurs/BMU",
"path": "/apps/event/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bruin-Entrepreneurs/BMU path: /apps/event/models.py
from django.db import models
from django.utils import timezone
class EventType(models.Model):
name = models.CharField(max_length=150, null=False, unique=True, db_index=True)
image_url = models.CharField(max_length=255, default='')
<|f... | code_fim | medium | {
"lang": "python",
"repo": "Bruin-Entrepreneurs/BMU",
"path": "/apps/event/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def makeConnected(self, n: int, connections: List[List[int]]) -> int:<|fim_prefix|># repo: spencercjh/sync-leetcode-today-problem-python3-example path: /number_of_operations_to_make_network_connected.py
class NumberOfOperationsToMakeNetworkConnected:
<|fim_middle|> """
https://leetcode-c... | code_fim | medium | {
"lang": "python",
"repo": "spencercjh/sync-leetcode-today-problem-python3-example",
"path": "/number_of_operations_to_make_network_connected.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spencercjh/sync-leetcode-today-problem-python3-example path: /number_of_operations_to_make_network_connected.py
class NumberOfOperationsToMakeNetworkConnected:
<|fim_suffix|> def makeConnected(self, n: int, connections: List[List[int]]) -> int:<|fim_middle|> """
https://leetcode-cn.com... | code_fim | medium | {
"lang": "python",
"repo": "spencercjh/sync-leetcode-today-problem-python3-example",
"path": "/number_of_operations_to_make_network_connected.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def makeConnected(self, n: int, connections: List[List[int]]) -> int:<|fim_prefix|># repo: spencercjh/sync-leetcode-today-problem-python3-example path: /number_of_operations_to_make_network_connected.py
class NumberOfOperationsToMakeNetworkConnected:
<|fim_middle|> """
https://leetcode-cn.com... | code_fim | medium | {
"lang": "python",
"repo": "spencercjh/sync-leetcode-today-problem-python3-example",
"path": "/number_of_operations_to_make_network_connected.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>requests.post("https://makeschool.slack.com/services/hooks/slackbot?token="+URLTOKENSTRING+"&channel=%23exercise", data="Good morning, @channel! Who's ready to get ripped?")
for i in range(10000):
exercise = selectExerciseAndStartTime("strength")
stretch = selectExerciseAndStartTime("stretch")
... | code_fim | hard | {
"lang": "python",
"repo": "samaratrilling/exercise",
"path": "/slackbotExercise.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samaratrilling/exercise path: /slackbotExercise.py
import random
import time
import requests
import json
import csv
USERTOKENSTRING = ""
URLTOKENSTRING = ""
def extractSlackUsers(token):
# Set token parameter of Slack API call
tokenString = token
params = {"token": tokenString}
... | code_fim | hard | {
"lang": "python",
"repo": "samaratrilling/exercise",
"path": "/slackbotExercise.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trillobite/mayan path: /apps/document_signatures/models.py
from __future__ import unicode_literals
import logging
import uuid
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django_gpg.runtime import gpg
from documents.models import DocumentVersion
fr... | code_fim | medium | {
"lang": "python",
"repo": "trillobite/mayan",
"path": "/apps/document_signatures/models.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class DocumentVersionSignature(models.Model):
"""
Model that describes a document version signature properties
"""
document_version = models.ForeignKey(
DocumentVersion, editable=False, verbose_name=_('Document version')
)
signature_file = models.FileField(
blank=T... | code_fim | medium | {
"lang": "python",
"repo": "trillobite/mayan",
"path": "/apps/document_signatures/models.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>N',
12: 'N'
},
'Spare Power Status': {
1: 'N',
2: 'N',
3: 'N',
4: 'N',
5: 'N',
6: 'N',
7: 'N',
8: 'N',
9: 'N',
10: 'N',
11: 'N',
12: 'N'
},
'Auto Config': {
1: 'Y',
2: 'Y',
3: 'Y',
4: 'Y',
5: 'Y',
... | code_fim | hard | {
"lang": "python",
"repo": "CiscoTestAutomation/genieparser",
"path": "/src/genie/libs/parser/iosxe/tests/ShowControllersPowerInlineModule/cli/equal/golden_output_expected.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CiscoTestAutomation/genieparser path: /src/genie/libs/parser/iosxe/tests/ShowControllersPowerInlineModule/cli/equal/golden_output_expected.py
expected_output= {
'alchemy_instance': {
'0': {
'address': '0',
'type': {
'Pending event flag': {
1: 'N',
2: 'N',
3: 'N',
... | code_fim | hard | {
"lang": "python",
"repo": "CiscoTestAutomation/genieparser",
"path": "/src/genie/libs/parser/iosxe/tests/ShowControllersPowerInlineModule/cli/equal/golden_output_expected.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pulumi/pulumi-google-native path: /sdk/python/pulumi_google_native/certificatemanager/v1/_enums.py
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi SDK Generator. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
from enum import Enum
__all_... | code_fim | medium | {
"lang": "python",
"repo": "pulumi/pulumi-google-native",
"path": "/sdk/python/pulumi_google_native/certificatemanager/v1/_enums.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class CertificateMapEntryMatcher(str, Enum):
"""
A predefined matcher for particular cases, other than SNI selection.
"""
MATCHER_UNSPECIFIED = "MATCHER_UNSPECIFIED"
"""
A matcher has't been recognized.
"""
PRIMARY = "PRIMARY"
"""
A primary certificate that is serv... | code_fim | hard | {
"lang": "python",
"repo": "pulumi/pulumi-google-native",
"path": "/sdk/python/pulumi_google_native/certificatemanager/v1/_enums.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: erikhayton/Portfolio path: /Python/Tools/mileage_converter.py
print("How many kilometers did you cycle today?")
kms = input()
miles = float(<|fim_suffix|>int(f"Your {kms}km ride was {miles}mi ")<|fim_middle|>kms)/1.60934
miles = round(miles, 2)
pr | code_fim | easy | {
"lang": "python",
"repo": "erikhayton/Portfolio",
"path": "/Python/Tools/mileage_converter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>int(f"Your {kms}km ride was {miles}mi ")<|fim_prefix|># repo: erikhayton/Portfolio path: /Python/Tools/mileage_converter.py
print("How many kilometers did you cycl<|fim_middle|>e today?")
kms = input()
miles = float(kms)/1.60934
miles = round(miles, 2)
pr | code_fim | medium | {
"lang": "python",
"repo": "erikhayton/Portfolio",
"path": "/Python/Tools/mileage_converter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Current events:")
[print(event.title) for event in logman._events]
print("Deleting: " + e.title)
logman.remove_event(e)
print()
e_proc.on_failed = delete_event
logman.register_event(e_proc)
logman.listen(args.logfile, follow=args.follow)
fo... | code_fim | hard | {
"lang": "python",
"repo": "arvind-iyer/logan",
"path": "/test/test_logan.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: arvind-iyer/logan path: /test/test_logan.py
import re
import logan
import argparse
def print_result(e: logan.LogEvent):
SUCCESS = "\x1b[42m"
FAIL = "\x1b[1;41m"
BOLD = "\x1b[1m"
END = "\x1b[0m"
if e.success():
print(
"{SUCCESS}Success{END}: {BOLD}{title}{... | code_fim | medium | {
"lang": "python",
"repo": "arvind-iyer/logan",
"path": "/test/test_logan.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(probe_bed, "r") as infile, open(
os.path.join(outdir, "probe.bed"), "w"
) as outfile:
for line in infile:
line = line.strip()
if len(line.split("\t")) >= 3:
if line[:3] == "chr":
print(line, file=outfile)
... | code_fim | medium | {
"lang": "python",
"repo": "papaemmelab/toil_cnacs",
"path": "/toil_cnacs/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: papaemmelab/toil_cnacs path: /toil_cnacs/utils.py
"""toil_cnacs utils."""
from __future__ import print_function
import os
import tarfile
def force_link(src, dst):
"""Force a link between src and dst."""
try:
os.unlink(dst)
os.link(src, dst)
except OSError:
... | code_fim | medium | {
"lang": "python",
"repo": "papaemmelab/toil_cnacs",
"path": "/toil_cnacs/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Compress a `source_dir` in `output_path`."""
with tarfile.open(output_path, "w:gz") as tar:
tar.add(source_dir, arcname=os.path.basename(source_dir))
def make_dir(directory):
if not os.path.exists(directory):
os.makedirs(directory)
def copyfix_bed(probe_bed, outdir):
... | code_fim | medium | {
"lang": "python",
"repo": "papaemmelab/toil_cnacs",
"path": "/toil_cnacs/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jvictor0/TiaraBoom path: /tiara/union_find.py
def Find(uf, k):
v = uf[k]
if v == k:
return v
result = Find(uf, v)
uf[k] = result
return result
<|fim_suffix|> results = {}
for k in uf.keys():
v = Find(uf, k)
if v not in results:
res... | code_fim | easy | {
"lang": "python",
"repo": "jvictor0/TiaraBoom",
"path": "/tiara/union_find.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> results = {}
for k in uf.keys():
v = Find(uf, k)
if v not in results:
results[v] = []
results[v].append(k)
return results<|fim_prefix|># repo: jvictor0/TiaraBoom path: /tiara/union_find.py
def Find(uf, k):
v = uf[k]
if v == k:
return v
... | code_fim | easy | {
"lang": "python",
"repo": "jvictor0/TiaraBoom",
"path": "/tiara/union_find.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alipay/alipay-sdk-python-all path: /alipay/aop/api/domain/AlipayPcreditLoanRepayApplyModel.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
from alipay.aop.api.constant.ParamConstants import *
class AlipayPcreditLoanRepayApplyModel(object):
def __init__(self):
self._ba... | code_fim | hard | {
"lang": "python",
"repo": "alipay/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/AlipayPcreditLoanRepayApplyModel.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Charset:
input_charset = ... # type: Any
header_encoding = ... # type: Any
body_encoding = ... # type: Any
output_charset = ... # type: Any
input_codec = ... # type: Any
output_codec = ... # type: Any
def __init__(self, input_charset=...): ...
def __eq__(self, o... | code_fim | medium | {
"lang": "python",
"repo": "o11c/typeshed",
"path": "/stdlib/3/email/charset.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: o11c/typeshed path: /stdlib/3/email/charset.pyi
# Stubs for email.charset (Python 3.4)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
<|fim_suffix|> def header_encode_lines(self, string, maxlengths): ...
def body_encode(self, string): ...<|fim_middle|>from t... | code_fim | hard | {
"lang": "python",
"repo": "o11c/typeshed",
"path": "/stdlib/3/email/charset.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_charset = ... # type: Any
header_encoding = ... # type: Any
body_encoding = ... # type: Any
output_charset = ... # type: Any
input_codec = ... # type: Any
output_codec = ... # type: Any
def __init__(self, input_charset=...): ...
def __eq__(self, other): ...
... | code_fim | medium | {
"lang": "python",
"repo": "o11c/typeshed",
"path": "/stdlib/3/email/charset.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gkerherve/AvantageToPlot path: /Older Issues/Avantage_To_Plot_10.py
sep='\t')
if plotline == True:
if UseOffsetComp == True: LabellingNumber = 0
if len(tmplist)>2 : plot_line(DEF_lines, df_Au4f[tmplist[0]], MinMaxAu4f, MinAu4f, MaxAu4f, df_Au4f[tmplist[2*LabellingNumber+1]]... | code_fim | hard | {
"lang": "python",
"repo": "gkerherve/AvantageToPlot",
"path": "/Older Issues/Avantage_To_Plot_10.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if I_maxCOMP < max(TmpDef1[tmplist[2*i+1]].ix[ix_Max:ix_Min]):
I_maxCOMP = max(TmpDef1[tmplist[2*i+1]].ix[ix_Max:ix_Min])
LabellingNumber = i
#print("I_max: ", I_maxCOMP, "FileNumber: ", )
# Checking for labelling----------------
if len(tmplist)>2 :... | code_fim | hard | {
"lang": "python",
"repo": "gkerherve/AvantageToPlot",
"path": "/Older Issues/Avantage_To_Plot_10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gkerherve/AvantageToPlot path: /Older Issues/Avantage_To_Plot_10.py
ix[i,3+PlotSettingNumber*4]
MinP2p = Plot_Settings.ix[i,1+PlotSettingNumber*4]
MaxP2p = Plot_Settings.ix[i,2+PlotSettingNumber*4]
elif Plot_Settings.ix[i,0+PlotSettingNumber*4] == 'Si2p' :
MinMax... | code_fim | hard | {
"lang": "python",
"repo": "gkerherve/AvantageToPlot",
"path": "/Older Issues/Avantage_To_Plot_10.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.