text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: esterjara/experiment-notebook path: /enb/sets.py
indices=None, target_columns=None, fill=True, overwrite=None, chunk_size=None):
target_indices = target_indices if target_indices is not None \
else enb.atable.get_all_input_files(ext=self.dataset_files_extension,
... | code_fim | hard | {
"lang": "python",
"repo": "esterjara/experiment-notebook",
"path": "/enb/sets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_default_target_indices(self):
return enb.atable.get_all_input_files(
base_dataset_dir=self.original_base_dir, ext=self.dataset_files_extension)
def original_to_versioned_path(self, original_path):
"""Get the path of the versioned file corresponding to original_... | code_fim | hard | {
"lang": "python",
"repo": "esterjara/experiment-notebook",
"path": "/enb/sets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@ray.remote
@config.propagates_options
def ray_version_one_path(version_fun, input_path, output_path, overwrite, original_info_df, check_generated_files,
options):
"""Run the versioning of one path.
"""
return version_one_path_local(version_fun=version_fun, input_path... | code_fim | hard | {
"lang": "python",
"repo": "esterjara/experiment-notebook",
"path": "/enb/sets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_en_parameters():
clf = ElasticNetRegressor(alpha=0.75, l1_ratio=0.5, random_seed=2)
expected_parameters = {
"alpha": 0.75,
"l1_ratio": 0.5,
"max_iter": 1000,
"normalize": False,
}
assert clf.parameters == expected_parameters
def test_problem_types... | code_fim | medium | {
"lang": "python",
"repo": "ObinnaObeleagu/evalml",
"path": "/evalml/tests/component_tests/test_en_regressor.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ObinnaObeleagu/evalml path: /evalml/tests/component_tests/test_en_regressor.py
import numpy as np
from sklearn.linear_model import ElasticNet as SKElasticNetRegressor
from evalml.model_family import ModelFamily
from evalml.pipelines.components.estimators.regressors import (
ElasticNetRegress... | code_fim | medium | {
"lang": "python",
"repo": "ObinnaObeleagu/evalml",
"path": "/evalml/tests/component_tests/test_en_regressor.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justinmeister/spaceinvaders-spyral path: /libraries/spyral/image.py
ew.draw_image(image, (x, y))
return new
def render_nine_slice(image, size):
"""
Creates a new image by dividing the given image into a 3x3 grid, and stretching
the sides and center while leaving the corners the s... | code_fim | hard | {
"lang": "python",
"repo": "justinmeister/spaceinvaders-spyral",
"path": "/libraries/spyral/image.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justinmeister/spaceinvaders-spyral path: /libraries/spyral/image.py
import copy
def _new_spyral_surface(size):
"""
Internal method for creating a new Spyral-compliant Pygame surface.
"""
return pygame.Surface((int(size[0]),
int(size[1])),
... | code_fim | hard | {
"lang": "python",
"repo": "justinmeister/spaceinvaders-spyral",
"path": "/libraries/spyral/image.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param color: a three-tuple of RGB values ranging from 0-255. Example:
(255, 128, 0) is orange.
:type color: a three-tuple of ints.
:param position: The starting position of the ellipse (top-left corner).
If position is a Rect, then si... | code_fim | hard | {
"lang": "python",
"repo": "justinmeister/spaceinvaders-spyral",
"path": "/libraries/spyral/image.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = TextClassifier(10, glove_path)
model.summary()
input_data = np.random.randint(20, size=(4, 500))
self.assert_forward_backward(model, input_data)
model.set_evaluate_status()
# Forward twice will get the same output
output1 = model.forward(inpu... | code_fim | hard | {
"lang": "python",
"repo": "intel-analytics/analytics-zoo",
"path": "/pyzoo/test/zoo/models/textclassification/test_textclassifier.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_forward_backward(self):
model = TextClassifier(10, glove_path)
model.summary()
input_data = np.random.randint(20, size=(4, 500))
self.assert_forward_backward(model, input_data)
model.set_evaluate_status()
# Forward twice will get the same outpu... | code_fim | hard | {
"lang": "python",
"repo": "intel-analytics/analytics-zoo",
"path": "/pyzoo/test/zoo/models/textclassification/test_textclassifier.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: intel-analytics/analytics-zoo path: /pyzoo/test/zoo/models/textclassification/test_textclassifier.py
#
# Copyright 2018 Analytics Zoo Authors.
#
# 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 | medium | {
"lang": "python",
"repo": "intel-analytics/analytics-zoo",
"path": "/pyzoo/test/zoo/models/textclassification/test_textclassifier.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mpw96/geocaching path: /GC67EXW/tryall.py
import os
import subprocess
import sys
def find_coordinates():
for north in range(1000):
for east in range(1000):
with open('gc67exw.txt.asc') as infile, open('cache.txt.asc', 'w') as outfile:
for line in infile:
line = li... | code_fim | hard | {
"lang": "python",
"repo": "mpw96/geocaching",
"path": "/GC67EXW/tryall.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 1
if __name__ == '__main__':
sys.exit(find_coordinates())<|fim_prefix|># repo: mpw96/geocaching path: /GC67EXW/tryall.py
import os
import subprocess
import sys
def find_coordinates():
for north in range(1000):
for east in range(1000):
with open('gc67exw.txt.asc') as infi... | code_fim | hard | {
"lang": "python",
"repo": "mpw96/geocaching",
"path": "/GC67EXW/tryall.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sauerseb/Week-Six-Assignment path: /world.py
# Evan Sauers
# CIS-125-82A
# Collaborated with Marisa Gross, Rebekah Orth, and Dr.Neumann
# world.py
# Populate Function, world & height & weight parameters, returns a value
def populate(world,h,w):
pass
# Display Function, world & height & weig... | code_fim | hard | {
"lang": "python",
"repo": "sauerseb/Week-Six-Assignment",
"path": "/world.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> display(world,height,width)
generation(world,height,width)
x = input("Enter the Q key to quit.")<|fim_prefix|># repo: sauerseb/Week-Six-Assignment path: /world.py
# Evan Sauers
# CIS-125-82A
# Collaborated with Marisa Gross, Rebekah Orth, and Dr.Neumann
# world.py
# Pop... | code_fim | medium | {
"lang": "python",
"repo": "sauerseb/Week-Six-Assignment",
"path": "/world.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for measure in self.measures:
measure.replaceChords(staff=staff)
def annotateChords(self, staff=1):
"""Annotate all the chords found on the given staff"""
for measure in self.measures:
measure.annotateChords(staff=staff)
def removeKeySignature(s... | code_fim | hard | {
"lang": "python",
"repo": "Kanma/musicxml_toolbox",
"path": "/musicxml_toolbox/musicxml/part.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kanma/musicxml_toolbox path: /musicxml_toolbox/musicxml/part.py
from .xmlelementwrapper import XMLElementWrapper
from copy import deepcopy
from piano_fingering import computeFingering
from piano_fingering import listToMidi
from .measure import Measure
from .note import Note
from .chord import Ch... | code_fim | hard | {
"lang": "python",
"repo": "Kanma/musicxml_toolbox",
"path": "/musicxml_toolbox/musicxml/part.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for note_index, fingered_note in enumerate(fingered_notes):
note = all_notes[note_index]
if isinstance(note, Note):
if note.fingering is not None:
note.fingering.finger = fingered_note['fingers'][0]
... | code_fim | hard | {
"lang": "python",
"repo": "Kanma/musicxml_toolbox",
"path": "/musicxml_toolbox/musicxml/part.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: home-assistant/supervisor path: /supervisor/addons/utils.py
"""Util add-ons functions."""
from __future__ import annotations
import asyncio
import logging
from pathlib import Path
from typing import TYPE_CHECKING
from ..const import ROLE_ADMIN, ROLE_MANAGER, SECURITY_DISABLE, SECURITY_PROFILE
f... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/supervisor",
"path": "/supervisor/addons/utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Privileged options
if (
any(
privilege in addon.privileged
for privilege in (
Capabilities.BPF,
Capabilities.DAC_READ_SEARCH,
Capabilities.NET_ADMIN,
Capabilities.NET_RAW,
Capabilities... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/supervisor",
"path": "/supervisor/addons/utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Galaxies99/SVHN-playground path: /utils/builder.py
def model_builder(model_params):
from models.logistic_regression import CategoricalLogisticRegression
from models.LeNet import LeNet
from models.AlexNet import AlexNet
from models.VGG import vgg11, vgg11_bn, vgg13, vgg13_bn, vgg16... | code_fim | hard | {
"lang": "python",
"repo": "Galaxies99/SVHN-playground",
"path": "/utils/builder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> from models.VAE.VAE import VAE
from models.VAE.BetaVAE import BetaVAE
from models.VAE.DisentangledBetaVAE import DisentangledBetaVAE
from models.VAE.DFCVAE import DFCVAE
from models.VAE.MSSIMVAE import MSSIMVAE
model_name = model_params['name']
if model_name == 'VAE':
m... | code_fim | hard | {
"lang": "python",
"repo": "Galaxies99/SVHN-playground",
"path": "/utils/builder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.log.info(f"Will execute rule in {list_for_rule.id}")
ret = list_for_rule.execute_rule(rule)
self.log.info(f"Returned '{ret}'")
def __get_list_for_rule(self, execute_in: str) -> Optional[KspList]:
for _list in self.lists:
if _list.name == e... | code_fim | hard | {
"lang": "python",
"repo": "K4CZP3R/butper-for-trello",
"path": "/KspBoard.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __get_list_for_rule(self, execute_in: str) -> Optional[KspList]:
for _list in self.lists:
if _list.name == execute_in:
return _list
return None
def __str__(self):
return self._this.name<|fim_prefix|># repo: K4CZP3R/butper-for-trello path: /... | code_fim | hard | {
"lang": "python",
"repo": "K4CZP3R/butper-for-trello",
"path": "/KspBoard.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: K4CZP3R/butper-for-trello path: /KspBoard.py
from trello import Board, Label
from KspList import KspList
from KspLabel import KspLabel
from typing import List, Optional
from KspRule import KspRule
import config
import logging
<|fim_suffix|> for _list in self.lists:
if _list.n... | code_fim | hard | {
"lang": "python",
"repo": "K4CZP3R/butper-for-trello",
"path": "/KspBoard.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertAlmostEqual(orig[0], smoothed2[0])
self.assertAlmostEqual(smoothed2[1], m2.smoothing * orig[1] + (1 - m2.smoothing) * smoothed2[0])
self.assertAlmostEqual(smoothed2[len(smoothed2) - 1], 9.33, delta=0.01)
def test_remove_time_dependent_effects(self):
smoo... | code_fim | medium | {
"lang": "python",
"repo": "SteveBall/SML",
"path": "/python/sparkts/models/test/test_EWMA.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SteveBall/SML path: /python/sparkts/models/test/test_EWMA.py
import numpy as np
from sparkts.test.test_utils import PySparkTestCase
from sparkts.models import EWMA
from sparkts.models.EWMA import EWMAModel
class FitEWMAModelTestCase(PySparkTestCase):
<|fim_suffix|> smoothed = np.array([... | code_fim | hard | {
"lang": "python",
"repo": "SteveBall/SML",
"path": "/python/sparkts/models/test/test_EWMA.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AUMPcwm/Word_Segmentation_PyTorch path: /train.py
import torch
import torch.optim as optim
from net import BiLSTM_CRF, BERT_CRF, DatasetRNN, collate_fn_RNN, DatasetBERT, collate_fn_BERT
from data import tag_to_ix
import pickle
import os
DIR = os.path.dirname(os.path.abspath(__file__))
device = t... | code_fim | hard | {
"lang": "python",
"repo": "AUMPcwm/Word_Segmentation_PyTorch",
"path": "/train.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # 损失函数
loss = model.neg_log_likelihood(x_seq_batch, y_seq_batch)
loss.backward()
optimizer.step()
# 记录总损失
sum_loss += loss.item()
if (i + 1) % 10 == 0:
print('Epoch: %d ,bat... | code_fim | hard | {
"lang": "python",
"repo": "AUMPcwm/Word_Segmentation_PyTorch",
"path": "/train.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _clean_stale_servers():
# pylint: disable=anomalous-backslash-in-string
cmd = """ps aux | awk "/{}/ && !/ssh/ && ! /{}/ && ! /{}/" | awk "{{print \$2}}" | xargs kill -9""" # noqa: W605
# Processes of | the local stale servers && excluding the current starter's pid && ppid | keep pids | ki... | code_fim | hard | {
"lang": "python",
"repo": "ibrandiay/autodist",
"path": "/autodist/utils/server_starter.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ibrandiay/autodist path: /autodist/utils/server_starter.py
# Copyright 2020 Petuum, Inc. 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 copy of the License at
#
# h... | code_fim | hard | {
"lang": "python",
"repo": "ibrandiay/autodist",
"path": "/autodist/utils/server_starter.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.portfree(base.Env.port)
if base.Env.no_angel:
if base.Env.valgrind:
self.fork(base.Env.valgrind, base.Env.worker, '-m', base.Env.plugindir, '-c', base.Env.lighttpdconf)
else:
self.fork(base.Env.worker, '-m', base.Env.plugindir, '-c', base.Env.lighttpdconf)
else:
self.fork(base.... | code_fim | hard | {
"lang": "python",
"repo": "ikingye/lighttpd2",
"path": "/tests/service.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ikingye/lighttpd2 path: /tests/service.py
# -*- coding: utf-8 -*-
import os
import atexit
import subprocess
import socket
import select
import signal
import time
import base
__all__ = [ "Service", "ServiceException", "devnull", "Lighttpd", "FastCGI" ]
class ServiceException(Exception):
def _... | code_fim | hard | {
"lang": "python",
"repo": "ikingye/lighttpd2",
"path": "/tests/service.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def Prepare(self):
raise BaseException("Not implemented yet")
def Cleanup(self):
pass
def Stop(self):
pass
class Lighttpd(Service):
name = "lighttpd"
def TestConfig(self):
logfile = open(self.log, "w")
inp = self.devnull()
args = [base.Env.worker, '-m', base.Env.plugindir, '-c', base.... | code_fim | hard | {
"lang": "python",
"repo": "ikingye/lighttpd2",
"path": "/tests/service.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cwebber314/dna_tools path: /fix_dna.py
"""
TODO: Please Give me a name
======================
And a brief description.
Input files:
- DIFF: file with a set of instruction which area applied to the dna sequences in
the REFERENCE file.
- REFERENCE: File with reference DNA sequences.
... | code_fim | hard | {
"lang": "python",
"repo": "cwebber314/dna_tools",
"path": "/fix_dna.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def parse_instr(instr, loc):
"""
Parse one instruction.
Params:
instr (string): a single instruction such as ``c174g`` or ``d134-282``
loc (string): LOC field from DIFF.tsv, included for debug traces.
"""
# Default values in dict
idx1 = None
idx2 = None
base_ol... | code_fim | hard | {
"lang": "python",
"repo": "cwebber314/dna_tools",
"path": "/fix_dna.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>snapshots['test_leak_message[_ONE_LINE_AND_MULTILINE_PATCH_CONTENT-hide_secrets] 1'] = '''> This is an example header
🛡️ ⚔️ 🛡️ \x1b[94m\x1b[1m\x1b[22m3\x1b[0m policy breaks have been found in file \x1b[93m\x1b[1m\x1b[22mleak.txt\x1b[0m
\x1b[36m\x1b[22m\x1b[22m>>>\x1b[0m Policy break 1(\x1b[93m\x1b[1... | code_fim | hard | {
"lang": "python",
"repo": "elacaille18/gg-shield",
"path": "/tests/output/snapshots/snap_test_text_output.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elacaille18/gg-shield path: /tests/output/snapshots/snap_test_text_output.py
# -*- coding: utf-8 -*-
# snapshottest: v1 - https://goo.gl/zC4yUc
from __future__ import unicode_literals
from snapshottest import Snapshot
snapshots = Snapshot()
snapshots['test_leak_message[_MULTI_SECRET_ONE_LINE_... | code_fim | hard | {
"lang": "python",
"repo": "elacaille18/gg-shield",
"path": "/tests/output/snapshots/snap_test_text_output.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>\x1b[36m\x1b[22m\x1b[22m>>>\x1b[0m Policy break 1(\x1b[93m\x1b[1m\x1b[22mSecrets Detection\x1b[0m): \x1b[93m\x1b[1m\x1b[22mFacebook Access Tokens\x1b[0m (Ignore with SHA: \x1b[36m\x1b[22m\x1b[22m1945f4a0c42abb19c1a420ddd09b4b4681249a3057c427b95f794b18595e7ffa\x1b[0m) (1 occurence)
\x1b[36m\x1b[22m\x1b[22... | code_fim | hard | {
"lang": "python",
"repo": "elacaille18/gg-shield",
"path": "/tests/output/snapshots/snap_test_text_output.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def patch_areas(patch_ids):
"""
Return a list containing patch areas
"""
return np.bincount(patch_ids.reshape((-1,)))[1:]
def patch_forces(patch_ids, forces):
"""
Return a list containing patch forces
"""
return np.bincount(patch_ids.reshape((-1,)),
... | code_fim | hard | {
"lang": "python",
"repo": "sintharic/ContactMechanics",
"path": "/ContactMechanics/Tools/ContactAreaAnalysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sintharic/ContactMechanics path: /ContactMechanics/Tools/ContactAreaAnalysis.py
#
# Copyright 2017-2018, 2020 Lars Pastewka
# 2019 Antoine Sanner
#
# ### MIT license
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated docume... | code_fim | hard | {
"lang": "python",
"repo": "sintharic/ContactMechanics",
"path": "/ContactMechanics/Tools/ContactAreaAnalysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Return the length of the perimeter as measured by tracing the length of
the interface between contacting and non-contacting points.
"""
return np.sum(np.logical_not(c) * coordination(c, stencil=stencil))
def outer_perimeter(c, stencil=nn_stencil):
"""
Return a map where ... | code_fim | hard | {
"lang": "python",
"repo": "sintharic/ContactMechanics",
"path": "/ContactMechanics/Tools/ContactAreaAnalysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_pantsuits.py
from xai.brain.wordbase.nouns._pantsuit import _PANTSUIT
<|fim_suffix|> def __init__(self,):
_PANTSUIT.__init__(self)
self.name = "PANTSUITS"
self.specie = 'nouns'
self.basic = "pantsuit"
self.jsondata = {}<|fim_middle|>#cal... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_pantsuits.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _PANTSUIT.__init__(self)
self.name = "PANTSUITS"
self.specie = 'nouns'
self.basic = "pantsuit"
self.jsondata = {}<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_pantsuits.py
from xai.brain.wordbase.nouns._pantsuit import _PANTSUIT
#calss header
class _PANTSUITS(_PANTSUIT,... | code_fim | easy | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_pantsuits.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Lumexralph/fun-learning-projects path: /Projects/LinuxIntership/Linuxjobber-Internship-Django/django-ogundelescrumy/ogundelescrumy/urls.py
from django.urls import path
<|fim_suffix|>urlpatterns = [
path('', views.index, name='index'),
path('tasks/', views.add_goal, name='add_goal'),
p... | code_fim | easy | {
"lang": "python",
"repo": "Lumexralph/fun-learning-projects",
"path": "/Projects/LinuxIntership/Linuxjobber-Internship-Django/django-ogundelescrumy/ogundelescrumy/urls.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
path('', views.index, name='index'),
path('tasks/', views.add_goal, name='add_goal'),
path('tasks/<int:task_id>/', views.move_goal, name='move_goal'),
path('users/', views.add_user, name='add_user'),
]<|fim_prefix|># repo: Lumexralph/fun-learning-projects path: /Projects/Li... | code_fim | easy | {
"lang": "python",
"repo": "Lumexralph/fun-learning-projects",
"path": "/Projects/LinuxIntership/Linuxjobber-Internship-Django/django-ogundelescrumy/ogundelescrumy/urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wyfo/apischema path: /apischema/schemas.py
import re
from dataclasses import dataclass, replace
from typing import (
Any,
Callable,
Dict,
Mapping,
Optional,
Pattern,
Sequence,
TypeVar,
Union,
)
from apischema.constraints import Constraints
from apischema.metad... | code_fim | hard | {
"lang": "python",
"repo": "wyfo/apischema",
"path": "/apischema/schemas.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def merge_into(self, base_schema: Dict[str, Any]):
if self.override:
base_schema.clear()
elif self.child is not None:
self.child.merge_into(base_schema)
if self.constraints is not None:
self.constraints.merge_into(base_schema)
if self... | code_fim | hard | {
"lang": "python",
"repo": "wyfo/apischema",
"path": "/apischema/schemas.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SiriusKoan/repair_system path: /src/app/database/db_helper.py
y.order_by(Offices.sequence).all()]
statuses = [
get_dict(row) for row in Statuses.query.order_by(Statuses.sequence).all()
]
return (buildings, items, offices, statuses)
@cache.memoize()
def get_admin_emails():
... | code_fim | hard | {
"lang": "python",
"repo": "SiriusKoan/repair_system",
"path": "/src/app/database/db_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SiriusKoan/repair_system path: /src/app/database/db_helper.py
return (buildings, items, offices, statuses)
@cache.memoize()
def get_admin_emails():
admins = db.session.query(Users.email).filter(Users.is_admin).all()
return [admin.email for admin in admins if admin.email != ""]
de... | code_fim | hard | {
"lang": "python",
"repo": "SiriusKoan/repair_system",
"path": "/src/app/database/db_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def render_records(Filter=dict(), page=1, per_page=100) -> dict:
if page < 1:
page = 1
q = db.session.query(Records.id)
valid = True
if "username" in Filter:
user_id = (
db.session.query(Users.id)
.filter_by(username=Filter.pop("username"))
... | code_fim | hard | {
"lang": "python",
"repo": "SiriusKoan/repair_system",
"path": "/src/app/database/db_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for slc in session.query(models.Slice).all():
if slc.datasource:
slc.perm = slc.datasource.perm
session.merge(slc)
session.commit()
db.session.close()
def downgrade():
# Use batch_alter_table because dropping columns is not supported in SQLite
... | code_fim | hard | {
"lang": "python",
"repo": "stitchfix/caravel",
"path": "/caravel/migrations/versions/c3a8f8611885_materializing_permission.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stitchfix/caravel path: /caravel/migrations/versions/c3a8f8611885_materializing_permission.py
"""Materializing permission
Revision ID: c3a8f8611885
Revises: 4fa88fe24e94
Create Date: 2016-04-25 08:54:04.303859
"""
# revision identifiers, used by Alembic.
revision = 'c3a8f8611885'
down_revision... | code_fim | hard | {
"lang": "python",
"repo": "stitchfix/caravel",
"path": "/caravel/migrations/versions/c3a8f8611885_materializing_permission.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: david4096/job-manager path: /servers/dsub/jobs/models/aggregation_entry.py
# coding: utf-8
from __future__ import absolute_import
from jobs.models.status_counts import StatusCounts
from .base_model_ import Model
from datetime import date, datetime
from typing import List, Dict
from ..util import... | code_fim | hard | {
"lang": "python",
"repo": "david4096/job-manager",
"path": "/servers/dsub/jobs/models/aggregation_entry.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param dikt: A dict.
:type: dict
:return: The AggregationEntry of this AggregationEntry.
:rtype: AggregationEntry
"""
return deserialize_model(dikt, cls)
@property
def label(self):
"""
Gets the label of this AggregationEntry.
... | code_fim | hard | {
"lang": "python",
"repo": "david4096/job-manager",
"path": "/servers/dsub/jobs/models/aggregation_entry.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: puzzlelib/PuzzleLib path: /Modules/LCN.py
import numpy as np
from PuzzleLib import Config
from PuzzleLib.Backend import gpuarray, Blas
from PuzzleLib.Backend.Dnn import PoolMode, poolNd, poolNdBackward, mapLRN, mapLRNBackward
from PuzzleLib.Modules.Module import ModuleError
from PuzzleLib.Modu... | code_fim | hard | {
"lang": "python",
"repo": "puzzlelib/PuzzleLib",
"path": "/Modules/LCN.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def updateData(self, data):
self.means, self.poolspace = poolNd(
data, size=self.size, stride=1, pad=self.pad, mode=self.mode, test=not self.train
)
self.data, self.lrnspace = mapLRN(
data, self.means, N=self.N, alpha=self.alpha, beta=self.beta, K=self.K, test=not self.train
)
def updat... | code_fim | hard | {
"lang": "python",
"repo": "puzzlelib/PuzzleLib",
"path": "/Modules/LCN.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
a = "Die Zahl lautet"
b = 5
c = [1,3,5]
print("Globale Werte: a = {}, b = {}, c = {}".format(a,b,c))
ausgabe1()
print("Globale Werte: a = {}, b = {}, c = {}".format(a,b,c))
ausgabe2(a,b)
print("Globale Werte: a = {}, b = {}, c = {}".format(a,b,c))<|fim_prefix|># repo: hobbyelektroniker/Micropython-Grund... | code_fim | medium | {
"lang": "python",
"repo": "hobbyelektroniker/Micropython-Grundlagen",
"path": "/011_Globale und lokale Variablen/Code/global3.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hobbyelektroniker/Micropython-Grundlagen path: /011_Globale und lokale Variablen/Code/global3.py
def ausgabe1():
print("*** Ausgabe 1 ***")
print(a,b,c)
print()
<|fim_suffix|>a = "Die Zahl lautet"
b = 5
c = [1,3,5]
print("Globale Werte: a = {}, b = {}, c = {}".format(a,b,c))
ausgab... | code_fim | hard | {
"lang": "python",
"repo": "hobbyelektroniker/Micropython-Grundlagen",
"path": "/011_Globale und lokale Variablen/Code/global3.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>print("Globale Werte: a = {}, b = {}, c = {}".format(a,b,c))
ausgabe1()
print("Globale Werte: a = {}, b = {}, c = {}".format(a,b,c))
ausgabe2(a,b)
print("Globale Werte: a = {}, b = {}, c = {}".format(a,b,c))<|fim_prefix|># repo: hobbyelektroniker/Micropython-Grundlagen path: /011_Globale und lokale Varia... | code_fim | hard | {
"lang": "python",
"repo": "hobbyelektroniker/Micropython-Grundlagen",
"path": "/011_Globale und lokale Variablen/Code/global3.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>accuracy = good / len(test_X)
precision = 0
recall = 0
f_measure = 0
if true_positive != 0:
precision = true_positive / (true_positive + false_positive)
recall = true_positive / (true_positive + false_negative)
if precision != 0 or recall != 0:
f_measure = (5 * ((precision * recall) / (4 * pre... | code_fim | hard | {
"lang": "python",
"repo": "varisd/MLFix",
"path": "/scripts/test_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: varisd/MLFix path: /scripts/test_model.py
#!/usr/bin/env python
from __future__ import division
import os, sys, argparse
import datetime
import gzip
import model
# TODO: dump some info?
def myPrint (msg, verbose):
if verbose > 0:
print msg;
def dumpInst (inst, pred, true, feature_... | code_fim | hard | {
"lang": "python",
"repo": "varisd/MLFix",
"path": "/scripts/test_model.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = [filter(lambda x: x[1] != 0, line) for line in res]
for i in range(len(res)):
lemma = test_X[idx_first + i]["old_node_lemma"]
pred = res[i][0][0]
base = base_Y[idx_first + i]
true = test_Y[idx_first + i]
base_str = ";".join([base[x] for x in base_targ... | code_fim | hard | {
"lang": "python",
"repo": "varisd/MLFix",
"path": "/scripts/test_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class LDAPUserMixin:
uid: str = Field("", description=("User ID"))
email: EmailStr = Field("", description=("Email"))
cn: str = Field("", description=("Common name"))
sn: str = Field("", description=("Surname"))<|fim_prefix|># repo: mekanix/freenit-backend path: /freenit/models/ldap/base... | code_fim | medium | {
"lang": "python",
"repo": "mekanix/freenit-backend",
"path": "/freenit/models/ldap/base.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mekanix/freenit-backend path: /freenit/models/ldap/base.py
from typing import Generic, TypeVar
from pydantic import EmailStr, Field, generics
T = TypeVar("T")
class LDAPBaseModel(generics.GenericModel, Generic[T]):
class Meta:
<|fim_suffix|>class LDAPUserMixin:
uid: str = Field("", de... | code_fim | medium | {
"lang": "python",
"repo": "mekanix/freenit-backend",
"path": "/freenit/models/ldap/base.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> uid: str = Field("", description=("User ID"))
email: EmailStr = Field("", description=("Email"))
cn: str = Field("", description=("Common name"))
sn: str = Field("", description=("Surname"))<|fim_prefix|># repo: mekanix/freenit-backend path: /freenit/models/ldap/base.py
from typing import... | code_fim | easy | {
"lang": "python",
"repo": "mekanix/freenit-backend",
"path": "/freenit/models/ldap/base.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenchy/Speech_synthesis path: /taco2_vae_aae/loss_function2.py
from torch import nn
import torch
import numpy as np
class Tacotron2Loss(nn.Module):
def __init__(self, hparams):
super(Tacotron2Loss, self).__init__()
self.anneal_function = hparams.anneal_function
... | code_fim | hard | {
"lang": "python",
"repo": "chenchy/Speech_synthesis",
"path": "/taco2_vae_aae/loss_function2.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> #total_loss = 10*(mel_loss + gate_loss) + 0.01*(S_kl_loss*S_kl_weight + R_kl_loss*R_kl_weight) + 0.01*speaker_loss + 0.0001*augment_loss + alignment_loss*lamb
#total_loss = 10 * (mel_loss + gate_loss) + 0.01 * (S_kl_loss*S_kl_weight + R_kl_loss*R_kl_weight) + 0.1 * speaker_loss + 0.1 * ... | code_fim | hard | {
"lang": "python",
"repo": "chenchy/Speech_synthesis",
"path": "/taco2_vae_aae/loss_function2.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ascend/ModelZoo-PyTorch path: /PyTorch/contrib/cv/detection/SSD-MobilenetV2/vision/utils/measurements.py
# Copyright 2021 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may o... | code_fim | hard | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/contrib/cv/detection/SSD-MobilenetV2/vision/utils/measurements.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def compute_voc2007_average_precision(precision, recall):
ap = 0.
for t in np.arange(0., 1.1, 0.1):
if np.sum(recall >= t) == 0:
p = 0
else:
p = np.max(precision[recall >= t])
ap = ap + p / 11.
return ap<|fim_prefix|># repo: Ascend/ModelZoo-PyTo... | code_fim | hard | {
"lang": "python",
"repo": "Ascend/ModelZoo-PyTorch",
"path": "/PyTorch/contrib/cv/detection/SSD-MobilenetV2/vision/utils/measurements.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>text = break_single_xor(ciphertext, score=naive_score)
assert text[0] == "Cooking MC's like a pound of bacon"<|fim_prefix|># repo: diofeher/ctf-writeups path: /cryptopals/set1/3.py
import operator
import string
from matasano import xor_strings, naive_score, break_single_xor
<|fim_middle|>ciphertext = '1... | code_fim | medium | {
"lang": "python",
"repo": "diofeher/ctf-writeups",
"path": "/cryptopals/set1/3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: diofeher/ctf-writeups path: /cryptopals/set1/3.py
import operator
import string
from matasano import xor_strings, naive_score, break_single_xor
<|fim_suffix|>text = break_single_xor(ciphertext, score=naive_score)
assert text[0] == "Cooking MC's like a pound of bacon"<|fim_middle|>ciphertext = '1... | code_fim | medium | {
"lang": "python",
"repo": "diofeher/ctf-writeups",
"path": "/cryptopals/set1/3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BenWoodford/home-assistant path: /tests/components/plugwise/conftest.py
"""Setup mocks for the Plugwise integration tests."""
from functools import partial
import re
from unittest.mock import AsyncMock, Mock, patch
import jsonpickle
from plugwise.exceptions import (
ConnectionFailedError,
... | code_fim | hard | {
"lang": "python",
"repo": "BenWoodford/home-assistant",
"path": "/tests/components/plugwise/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> smile_mock.return_value.single_master_thermostat.side_effect = Mock(
return_value=None
)
smile_mock.return_value.get_all_devices.return_value = _read_json(
chosen_env, "get_all_devices"
)
smile_mock.return_value.get_device_data.side_effect =... | code_fim | hard | {
"lang": "python",
"repo": "BenWoodford/home-assistant",
"path": "/tests/components/plugwise/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def save(self, *args, **kwargs):
logger.debug('Saving')
self.encrypt()
# TODO: here body could be removed
super(Email, self).save(*args, **kwargs)
self.send()
class Profile(models.Model):
name = models.CharField(default="default", max_length=255)
peers... | code_fim | hard | {
"lang": "python",
"repo": "juga0/djac",
"path": "/ac/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juga0/djac path: /ac/models.py
# -*- coding: utf-8 -*-
# vim:ts=4:sw=4:expandtab
# Copyright 2017 juga (juga at riseup dot net), under MIT license.
import logging
from django.conf import settings
from django.core import serializers
from django.db import models
from django.utils.translation impo... | code_fim | hard | {
"lang": "python",
"repo": "juga0/djac",
"path": "/ac/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dw/scratch path: /bisect-test.py
# http://pythonsweetness.tumblr.com/post/74073984682/cowboy-optimization-bisecting-a-function
import math
import time
import zlib
<|fim_suffix|>maxlines, (ratio, output) = doink
if maxlines and (ratio > 1.0):
maxlines -= 1
ratio, output = compo(maxlines... | code_fim | hard | {
"lang": "python",
"repo": "dw/scratch",
"path": "/bisect-test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print
print 'time taken:', 1000 * (time.time() - t0)
print 'output steps:', steps
print 'maxlines:', maxlines
print 'maxlines len:', sum(map(len, lines[:maxlines]))
print 'target ratio:', ratio
print 'outlen:', len(output)
#print compo(50, (15000,))<|fim_prefix|># repo: dw/scratch path: /bisect-test.py
... | code_fim | hard | {
"lang": "python",
"repo": "dw/scratch",
"path": "/bisect-test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # curl -X POST -H "Content-Type: application/json" -d '{ "price":"123", "name":"fork"}' "http://localhost:5000/sample_controls"
def post(self):
args = parser.parse_args()
input_json = request.get_json()
try:
validate(input_json, Schemas.get_sequencer_schema())
... | code_fim | medium | {
"lang": "python",
"repo": "bcoffe/python-examples",
"path": "/resources/sample_control.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args['control_id'] is not None:
abort(400, message="Can not create a new sample control if id is passed in")
elif DictionaryHelper(args).keys_have_value(['type', 'site']):
return "Yeah, you passed in the correct parameters to create a new sample control"
... | code_fim | hard | {
"lang": "python",
"repo": "bcoffe/python-examples",
"path": "/resources/sample_control.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bcoffe/python-examples path: /resources/sample_control.py
import json
from flask_restful import abort, request, reqparse, Resource
from jsonschema import validate, SchemaError
from accessors.sample_control_accessor import SampleControlAccessor
from common.dictionary_helper import DictionaryHelper... | code_fim | hard | {
"lang": "python",
"repo": "bcoffe/python-examples",
"path": "/resources/sample_control.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>?-*.jpg"):
shutil.move(f, "0{}".format(f))<|fim_prefix|># repo: wgong/open_source_learning path: /learn_stem/python/utilities/mv_file.py
import glob
import shutil
for f in glob.glob("100*.jpg"):
shutil.move(f, "0{}-{}".for<|fim_middle|>mat(f[0], f[1:]))
for f in glob.glob(" | code_fim | easy | {
"lang": "python",
"repo": "wgong/open_source_learning",
"path": "/learn_stem/python/utilities/mv_file.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wgong/open_source_learning path: /learn_stem/python/utilities/mv_file.py
import glob
import shutil
for f in glob.glo<|fim_suffix|>?-*.jpg"):
shutil.move(f, "0{}".format(f))<|fim_middle|>b("100*.jpg"):
shutil.move(f, "0{}-{}".format(f[0], f[1:]))
for f in glob.glob(" | code_fim | medium | {
"lang": "python",
"repo": "wgong/open_source_learning",
"path": "/learn_stem/python/utilities/mv_file.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mmakowski/shapeshifter path: /bootstrap/html.py
'''
Provides functions and templates for generating HTML reponses.
'''
import httplib
__author__ = 'Maciek Makowski'
__version__ = '1.2.0'
def send_html_response(http, title, body, status=httplib.OK):
http.send_response(status)
h... | code_fim | medium | {
"lang": "python",
"repo": "mmakowski/shapeshifter",
"path": "/bootstrap/html.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
_page_template = '''
<html>
<head>
<title>%s</title>
</head>
<body>
%s
</body>
</html>
'''
_properties_template = '''
<table class='properties'>
%s
</table>
'''
_property_template = '<tr><th>%s</th><td>%s</td></tr>\n'<|fim_prefix|># repo: mmakowski/shapeshifter path: /boo... | code_fim | medium | {
"lang": "python",
"repo": "mmakowski/shapeshifter",
"path": "/bootstrap/html.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def format_properties(properties):
return _properties_template % ''.join([_property_template % (k, v) for (k, v) in properties.items()])
_page_template = '''
<html>
<head>
<title>%s</title>
</head>
<body>
%s
</body>
</html>
'''
_properties_template = '''
<table class='... | code_fim | hard | {
"lang": "python",
"repo": "mmakowski/shapeshifter",
"path": "/bootstrap/html.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_binary(binaries_folder, program_name):
path = os.path.join(binaries_folder, os_folder_name, program_name)
return path
def get_niftyreg_binaries():
return resource_filename("brainreg", "bin/nifty_reg")<|fim_prefix|># repo: stephenlenzi/brainreg path: /brainreg/backend/niftyreg/nifty... | code_fim | hard | {
"lang": "python",
"repo": "stephenlenzi/brainreg",
"path": "/brainreg/backend/niftyreg/niftyreg_binaries.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stephenlenzi/brainreg path: /brainreg/backend/niftyreg/niftyreg_binaries.py
import os
import platform
from pkg_resources import resource_filename
<|fim_suffix|> path = os.path.join(binaries_folder, os_folder_name, program_name)
return path
def get_niftyreg_binaries():
return resourc... | code_fim | hard | {
"lang": "python",
"repo": "stephenlenzi/brainreg",
"path": "/brainreg/backend/niftyreg/niftyreg_binaries.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bonattt/name-masher path: /tests/xml_rules.py
import unittest
from xml.etree import ElementTree
from masher import xml_rules
from masher.xml_rules import MasherXmlRuleError
from masher.generators import ConstantGenerator
def make_xml(xml):
return '<?xml version="1.0"?><data>' + xml + '</data... | code_fim | hard | {
"lang": "python",
"repo": "bonattt/name-masher",
"path": "/tests/xml_rules.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> xml = """
<random chance='.3'>
<const>hello</const>
<const>goodbye</const>
</random>"""
# xml = make_xml(xml)
root = ElementTree.fromstring(xml)
gen = xml_rules.RandomRule(MockParser()).getGenerator(root)
self.assertEqual(.3, ... | code_fim | hard | {
"lang": "python",
"repo": "bonattt/name-masher",
"path": "/tests/xml_rules.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def setUp(self):
self.rule = xml_rules.PhraseRule(MockParser())
def testMetBy(self):
xml = '<phrase></phrase>'
root = ElementTree.fromstring(xml)
xml_rules.ConstantRule().metBy(root)
def testPhraseDefaultCorrectNumberGenerators(self):
xml = """<phrase>... | code_fim | hard | {
"lang": "python",
"repo": "bonattt/name-masher",
"path": "/tests/xml_rules.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> task = get_object_or_404(Task, pk=kwargs["task_id"])
days = int(kwargs["days"])
if days < 0:
task.show_immediately = True
task.snooze = None
task.save()
else:
task.snooze_by(days)
return HttpResponse("ok")
class Done... | code_fim | hard | {
"lang": "python",
"repo": "ojarva/home-info-display",
"path": "/homedisplay/repeating_tasks/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Done(View):
def patch(self, request, *args, **kwargs):
task = get_object_or_404(Task, pk=kwargs["task_id"])
if task.time_since_completion() and task.time_since_completion() < datetime.timedelta(minutes=5):
return HttpResponse("too_soon")
task.completed()
... | code_fim | hard | {
"lang": "python",
"repo": "ojarva/home-info-display",
"path": "/homedisplay/repeating_tasks/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ojarva/home-info-display path: /homedisplay/repeating_tasks/views.py
from .models import Task, get_repeating_data
from django.core import serializers
from django.http import HttpResponse
from django.shortcuts import get_object_or_404
from django.views.generic import View
import datetime
import js... | code_fim | medium | {
"lang": "python",
"repo": "ojarva/home-info-display",
"path": "/homedisplay/repeating_tasks/views.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>process.source = cms.Source("PoolSource",
skipEvents = cms.untracked.uint32(1),
fileNames = cms.untracked.vstring('file:/tmp/Cum_store.root')
)
process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(-1)
)
process.out = cms.OutputModule("PoolOutputModule",
outputCommands = cms... | code_fim | medium | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/SimGeneral/MixingModule/test/mm_back_cfg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-sw/cmssw path: /SimGeneral/MixingModule/test/mm_back_cfg.py
# This is an example to run in playback mode
# Please note that it must be run with the same configuration as the initial job
import FWCore.ParameterSet.Config as cms
process = cms.Process("PRODMIXBack")
process.load("SimGeneral.Mix... | code_fim | hard | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/SimGeneral/MixingModule/test/mm_back_cfg.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DMTF/Redfish-Tacklebox path: /redfish_utilities/misc.py
#! /usr/bin/python
# Copyright Notice:
# Copyright 2019-2022 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Tacklebox/blob/main/LICENSE.md
"""
Miscellaneous
<|fim_suffix|... | code_fim | medium | {
"lang": "python",
"repo": "DMTF/Redfish-Tacklebox",
"path": "/redfish_utilities/misc.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Args:
context: The Redfish client object with an open session
args: The argparse object from the calling script
"""
print( "Password change required. To set a new password, run the following:" )
print( "rf_accounts.py -r {} -u {} -p <old password> --setpassword {} <new pa... | code_fim | hard | {
"lang": "python",
"repo": "DMTF/Redfish-Tacklebox",
"path": "/redfish_utilities/misc.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PDi-Communication-Systems-Inc/lollipop_external_chromium_org path: /tools/perf/PRESUBMIT.py
# Copyright 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Presubmit script for changes affecting ... | code_fim | medium | {
"lang": "python",
"repo": "PDi-Communication-Systems-Inc/lollipop_external_chromium_org",
"path": "/tools/perf/PRESUBMIT.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _CheckJson(input_api, output_api):
"""Checks whether JSON files in this change can be parsed."""
for affected_file in input_api.AffectedFiles(include_deletes=False):
filename = affected_file.AbsoluteLocalPath()
if os.path.splitext(filename)[1] != '.json':
continue
try:
inpu... | code_fim | hard | {
"lang": "python",
"repo": "PDi-Communication-Systems-Inc/lollipop_external_chromium_org",
"path": "/tools/perf/PRESUBMIT.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.