text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: WebSpider/pyheos path: /pyheos/group.py
from pyheos import HEOSException, get_message_parts
import sys
def get_groups(heosobj, command, data):
"""CLI 4.3.1"""
from datetime import datetime
heosobj.save_groups(data, datetime.now())
def get_group_info(heosobj, command, data):
... | code_fim | hard | {
"lang": "python",
"repo": "WebSpider/pyheos",
"path": "/pyheos/group.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexjunq/kolibri path: /kolibri/auth/test/test_permissions.py
t3(self):
""" FacilityUsers can't remove Facilities, regardless of their roles """
self.assertFalse(self.learner1.has_perm('auth.remove_facility'))
def test_remove_facility_pt4(self):
""" Raises exception i... | code_fim | hard | {
"lang": "python",
"repo": "alexjunq/kolibri",
"path": "/kolibri/auth/test/test_permissions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexjunq/kolibri path: /kolibri/auth/test/test_permissions.py
d_coach(coach2)
admin = FacilityUser.objects.create(username='boss_hogg')
facility.add_admin(admin)
learner1, learner2 = (FacilityUser.objects.create(username='student1'),
Facilit... | code_fim | hard | {
"lang": "python",
"repo": "alexjunq/kolibri",
"path": "/kolibri/auth/test/test_permissions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_remove_learner_specific_for_admin(self):
self.assertTrue(self.admin.has_perm(self.AUTH_REMOVE_LEARNER, self.learner_groups[0]))
def test_remove_learner_specific_for_coach_pt1(self):
""" Coaches can remove Learners for their own LearnerGroups """
self.assertTrue(se... | code_fim | hard | {
"lang": "python",
"repo": "alexjunq/kolibri",
"path": "/kolibri/auth/test/test_permissions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # init metrics service
self.metricService = metrics.Metrics()
# init transporter
self.transporter = transport.Transporter(config, self.actionService)
# init notifier
self.notifier = notifier.Notifier(self.transporter)
# init tracing
self.tracing = tracing.Tracing(self.tr... | code_fim | hard | {
"lang": "python",
"repo": "keymetrics/pm2-io-apm-python",
"path": "/pm2_io_apm_python/pm2io.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keymetrics/pm2-io-apm-python path: /pm2_io_apm_python/pm2io.py
import threading
from .services import actions
from .services import metrics
from .services import status
from .services import transport
from .classes import metric as mmetric
from .classes import action as maction
from .features ... | code_fim | hard | {
"lang": "python",
"repo": "keymetrics/pm2-io-apm-python",
"path": "/pm2_io_apm_python/pm2io.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # init tracing
self.tracing = tracing.Tracing(self.transporter)
def start(self):
# start status interval thread
threading.Thread(target=self.statusInterval, args=(
self.config,
self.transporter,
self.metricService,
self.actionService,
)).start()
self.tra... | code_fim | hard | {
"lang": "python",
"repo": "keymetrics/pm2-io-apm-python",
"path": "/pm2_io_apm_python/pm2io.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jahrome/tabview path: /tabview/tabview.py
else:
self.win_y = self.win_y + 1
def up():
if self.y == 0:
if self.win_y > 0:
self.win_y = self.win_y - 1
else:
self.y = self.y - 1
... | code_fim | hard | {
"lang": "python",
"repo": "jahrome/tabview",
"path": "/tabview/tabview.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def resize(self):
"""Handle terminal resizing"""
# Check if screen was re-sized (True or False)
resize = self.max_x == 0 or \
curses.is_term_resized(self.max_y, self.max_x)
if resize is True:
self.recalculate_layout()
curses.resizeter... | code_fim | hard | {
"lang": "python",
"repo": "jahrome/tabview",
"path": "/tabview/tabview.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jahrome/tabview path: /tabview/tabview.py
xp = x * self.column_width + x * self.column_gap
if x < self.num_columns:
w = min(self.max_x, self.column_width)
else:
w = self.max_x - xp
return xp, w
def keys(self):
"""Define methods fo... | code_fim | hard | {
"lang": "python",
"repo": "jahrome/tabview",
"path": "/tabview/tabview.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with pytest.raises(AssertionError):
# Wasted too much time trying to get this to work properly so we just assert that an error is thrown.
parse_user_function_call("my_func b='thing with spaces'")
with pytest.raises(NameError):
parse_user_function_call("my_func aaa bbb=3.1"... | code_fim | hard | {
"lang": "python",
"repo": "petered/dead_easy_ui",
"path": "/dead_easy_ui/test_ui_console_menu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: petered/dead_easy_ui path: /dead_easy_ui/test_ui_console_menu.py
from __future__ import print_function
from __future__ import absolute_import
import pytest
from dead_easy_ui.ui_console_menu import parse_user_function_call
def test_parse_command_args():
<|fim_suffix|> assert parse_user_funct... | code_fim | medium | {
"lang": "python",
"repo": "petered/dead_easy_ui",
"path": "/dead_easy_ui/test_ui_console_menu.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_AMWG_execute_not_completed(self):
start_year = 51
end_year = 55
self.config['global']['project_path'] = '/p/cscratch/acme/baldwin32/20171016/'
self.config['global']['exeriment'] = '20171011.beta2_FCT2-icedeep_branch.A_WCYCL1850S.ne30_oECv3_ICG.edison'
y... | code_fim | hard | {
"lang": "python",
"repo": "KelvinFkr2015/acme_processflow",
"path": "/jobs/test_amwg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> start_year = 51
end_year = 55
self.config['global']['project_path'] = '/p/cscratch/acme/baldwin32/20171016/'
self.config['global']['exeriment'] = '20171011.beta2_FCT2-icedeep_branch.A_WCYCL1850S.ne30_oECv3_ICG.edison'
year_set_string = '{start:04d}-{end:04d}'.format... | code_fim | hard | {
"lang": "python",
"repo": "KelvinFkr2015/acme_processflow",
"path": "/jobs/test_amwg.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KelvinFkr2015/acme_processflow path: /jobs/test_amwg.py
import os
import unittest
import shutil
from AMWGDiagnostic import AMWGDiagnostic
from configobj import ConfigObj
from JobStatus import JobStatus
from lib.events import Event_list
class TestAMWGDiagnostic(unittest.TestCase):
def __i... | code_fim | hard | {
"lang": "python",
"repo": "KelvinFkr2015/acme_processflow",
"path": "/jobs/test_amwg.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yinzhe1989/real-time-news path: /rtnews/feed/async_newsevent.py
import aioredis
import pandas as pd
from datetime import datetime
import lxml.html
from lxml.html import builder as E
from lxml import etree
import asyncio
import time
import os
import sys
import traceback
from rtnews im... | code_fim | hard | {
"lang": "python",
"repo": "yinzhe1989/real-time-news",
"path": "/rtnews/feed/async_newsevent.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> logger.info('Closing redis...')
redis.close()
await redis.wait_closed()
if __name__ == '__main__':
#try:
# fh = logging.handlers.RotatingFileHandler(ct.FEED_LOG_FILE, mode='a', maxBytes=1024*1024*10, backupCount=2, encoding='utf-8', delay=False)
#except:
# fh = l... | code_fim | hard | {
"lang": "python",
"repo": "yinzhe1989/real-time-news",
"path": "/rtnews/feed/async_newsevent.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IntegralProgrammer/NeuralCR path: /tests/test_template/data_driven_api_test.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import json
import os
import sys
import requests
from nested_lookup import nested_update
URL_FILE = "url"
RESULT_FILE = "result"
f_url = open(URL_FILE, 'r')
URL_DATA = f... | code_fim | hard | {
"lang": "python",
"repo": "IntegralProgrammer/NeuralCR",
"path": "/tests/test_template/data_driven_api_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("=== BEGIN ACTUAL ===")
print(compare_actual)
print("=== END ACTUAL ===")
if "AUTOTEST" in os.environ:
if os.environ["AUTOTEST"] != "":
raise err
sys.exit(-1)<|fim_prefix|># repo: IntegralProgrammer/NeuralCR path: /tests/test_template/data_driven_api_test.py
#!/usr/bin/env python
# -*- co... | code_fim | hard | {
"lang": "python",
"repo": "IntegralProgrammer/NeuralCR",
"path": "/tests/test_template/data_driven_api_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
assert compare_actual == compare_expected
except AssertionError as err:
print("=== BEGIN EXPECTED ===")
print(compare_expected)
print("=== END EXPECTED ===")
print("=== BEGIN ACTUAL ===")
print(compare_actual)
print("=== END ACTUAL ===")
if "AUTOTEST" in os.environ:
if os.environ["AUTOTES... | code_fim | hard | {
"lang": "python",
"repo": "IntegralProgrammer/NeuralCR",
"path": "/tests/test_template/data_driven_api_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenmich/learn_rnn_tensorflow path: /large_data_preparation.py
#
class RawDataLine():
def __init__(self, token, lines):
self.token = token
self.lines = lines
example_map = {ExampleType.prediction: AllForFile.prediction_record,
ExampleType.test: AllForFile.test_r... | code_fim | hard | {
"lang": "python",
"repo": "chenmich/learn_rnn_tensorflow",
"path": "/large_data_preparation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> volumn_lines = lines[0:, self.__feature_size__ - 1 :]
stat_volumn.num = len(input_lines + target_lines)
stat_volumn.mean = np.mean(volumn_lines)
stat_volumn.std = np.std(volumn_lines)
#With the existing stat combination
combinate_stat_price = _combinate_sta... | code_fim | hard | {
"lang": "python",
"repo": "chenmich/learn_rnn_tensorflow",
"path": "/large_data_preparation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chenmich/learn_rnn_tensorflow path: /large_data_preparation.py
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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applic... | code_fim | hard | {
"lang": "python",
"repo": "chenmich/learn_rnn_tensorflow",
"path": "/large_data_preparation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with open(os.path.join(args.output_dir, 'unlabel10per_'+str(seed)+'.json'),'w') as f:
for line in dataset[num+1:]:
f.writelines(json.dumps(line,ensure_ascii=False))
f.write("\n")<|fim_prefix|># repo: zjunlp/LREBench path: /sample_10.py
import json
import numpy as np
im... | code_fim | hard | {
"lang": "python",
"repo": "zjunlp/LREBench",
"path": "/sample_10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zjunlp/LREBench path: /sample_10.py
import json
import numpy as np
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument("--input_dir", "-i", type=str, required=True,
help="The directory of the training file.")
parser.add_argument('--output_dir'... | code_fim | medium | {
"lang": "python",
"repo": "zjunlp/LREBench",
"path": "/sample_10.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tpopenfoose/OptionSuite path: /strategyManager/strategy.py
class Strategy(object):
"""This class sets up the basics for every strategy that will be used;
For example, if we want to do an iron condor or a strangle, there
are certain parameters that must be defined.
Attributes:
... | code_fim | hard | {
"lang": "python",
"repo": "tpopenfoose/OptionSuite",
"path": "/strategyManager/strategy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.__daysBeforeClose
def getExpCycle(self):
return self.__expCycle
def getOptimalDTE(self):
return self.__optimalDTE
def getMinimumDTE(self):
return self.__minimumDTE
def getROC(self):
return self.__roc
def getMinDaysToEar... | code_fim | hard | {
"lang": "python",
"repo": "tpopenfoose/OptionSuite",
"path": "/strategyManager/strategy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yindaheng98/LittleProgramSet path: /排队论大作业程序/generate_data.py
import numpy as np
import json
import pathlib
from MMnSimulator import MMnSimulator
from nMM1Simulator import nMM1Simulator
from nEnM1Simulator import nEnM1Simulator
from nMM1ShortSimulator import nMM1ShortSimulator
from common import ... | code_fim | medium | {
"lang": "python",
"repo": "yindaheng98/LittleProgramSet",
"path": "/排队论大作业程序/generate_data.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>miu = 1
for n in n_list:
data = {
'MMn': {'simulate': [], 'theory': []},
'nMM1': {'simulate': [], 'theory': []},
'nEnM1': {'simulate': [], 'theory': []},
'nMM1Short': {'simulate': []},
}
for rho in rho_list:
_miu = miu
_lambda = rho * _miu * n
... | code_fim | medium | {
"lang": "python",
"repo": "yindaheng98/LittleProgramSet",
"path": "/排队论大作业程序/generate_data.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> wgtedVals = np.zeros((nTimeSteps, nOutPolys))
matDataVals = np.zeros((nTimeSteps, nOutPolys, maxOverlaps))
# reformat var data into regular matrix matching weights format (nOutPolygons, maxOverlaps)
# used advanced indexing to extract matching input grid indices
for p in range(0, ... | code_fim | hard | {
"lang": "python",
"repo": "nmizukami/cmip5_oconus_analysis",
"path": "/scripts/basin_average/remap_vic_output.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for varname, meta in var_meta.items():
foo = xr.DataArray(remapped_data[varname][:, remap_idx],
dims=['time', 'basinID'],
name=varname)
foo.encoding = var_encodings[varname]
foo.attrs = var_attrs[varname]
dataset[varn... | code_fim | hard | {
"lang": "python",
"repo": "nmizukami/cmip5_oconus_analysis",
"path": "/scripts/basin_average/remap_vic_output.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nmizukami/cmip5_oconus_analysis path: /scripts/basin_average/remap_vic_output.py
#!/usr/bin/env python
''' Process timeseries grid into mean areal timeseries for arbitrary polygons
Depends on mapping file (i,j version) from poly2poly.py
Rewritten from earlier script pieces to use vectoriz... | code_fim | hard | {
"lang": "python",
"repo": "nmizukami/cmip5_oconus_analysis",
"path": "/scripts/basin_average/remap_vic_output.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> alpha = 0.5
l1_ratio = 0.5
model = ElasticNet(alpha=alpha, l1_ratio=l1_ratio,
random_state=kwargs['random_state'])
model.fit(X_train, y_train)
return model, mlflow_run
def eval_model(**kwargs):
print("Evaluate Model")
# paths
src_path = os.pat... | code_fim | hard | {
"lang": "python",
"repo": "tspthomas/fsdl2021_project",
"path": "/src/pipelines/dags/winequality/train_elastic_net_end2end.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tspthomas/fsdl2021_project path: /src/pipelines/dags/winequality/train_elastic_net_end2end.py
import os
import numpy as np
import pandas as pd
from sklearn.linear_model import ElasticNet
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error, mean_abs... | code_fim | hard | {
"lang": "python",
"repo": "tspthomas/fsdl2021_project",
"path": "/src/pipelines/dags/winequality/train_elastic_net_end2end.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def train_model(**kwargs):
print("Train Model")
# paths
src_path = os.path.join(kwargs['dest'], kwargs['name'])
# load training data
X_train = load_numpy_array(src_path, kwargs['X_train_filename'])
y_train = load_numpy_array(src_path, kwargs['y_train_filename'])
# create or... | code_fim | hard | {
"lang": "python",
"repo": "tspthomas/fsdl2021_project",
"path": "/src/pipelines/dags/winequality/train_elastic_net_end2end.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 13Nuse/poi path: /poi/user/migrations/0003_auto_20180918_1257.py
# Generated by Django 2.1.1 on 2018-09-18 16:57
<|fim_suffix|>
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('user', '0002_auto_20180917_133... | code_fim | medium | {
"lang": "python",
"repo": "13Nuse/poi",
"path": "/poi/user/migrations/0003_auto_20180918_1257.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('user', '0002_auto_20180917_1330'),
]
operations = [
migrations.RenameModel(
old_name='User',
new_name='Users',
),
]<|fim_prefix|># repo: 13Nuse/poi path: ... | code_fim | medium | {
"lang": "python",
"repo": "13Nuse/poi",
"path": "/poi/user/migrations/0003_auto_20180918_1257.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RenameModel(
old_name='User',
new_name='Users',
),
]<|fim_prefix|># repo: 13Nuse/poi path: /poi/user/migrations/0003_auto_20180918_1257.py
# Generated by Django 2.1.1 on 2018-09-18 16:57
<|fim_middle|>from django.conf import setti... | code_fim | hard | {
"lang": "python",
"repo": "13Nuse/poi",
"path": "/poi/user/migrations/0003_auto_20180918_1257.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GeographicaGS/GeoLibs-Dator path: /dator/datastorages/__init__.py
from dator.datastorages.bigquery import BigQuery
from dator.datastorages.carto import CARTO
from dator.datastorages.csv import CSV
from dator.datastorages.pos<|fim_suffix|> 'carto': CARTO,
'csv': CSV,
'postgresql... | code_fim | medium | {
"lang": "python",
"repo": "GeographicaGS/GeoLibs-Dator",
"path": "/dator/datastorages/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'carto': CARTO,
'csv': CSV,
'postgresql': PostgreSQL
}
)<|fim_prefix|># repo: GeographicaGS/GeoLibs-Dator path: /dator/datastorages/__init__.py
from dator.datastorages.bigquery import BigQuery
from dator.datastorages.carto <|fim_middle|>import CARTO
from dator.datastorages.csv imp... | code_fim | medium | {
"lang": "python",
"repo": "GeographicaGS/GeoLibs-Dator",
"path": "/dator/datastorages/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hesscl/helena path: /utilities/runHelenaScript.py
# usage: python runHelenaDocker.py <helenaScriptNumericId> <numParallelBrowsers> <timeoutInHours> <howManyRunsToAllowPerWorker>
# ex: python runHelenaDocker.py 651 3 23.75 1000
# ex: python runHelenaDocker.py 927 1 1 1
# ex: python runHelenaDocker... | code_fim | hard | {
"lang": "python",
"repo": "hesscl/helena",
"path": "/utilities/runHelenaScript.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class RunProgramProcess(Process):
def __init__(self, profile, programId, optionStr, numTriesSoFar=0):
super(RunProgramProcess, self).__init__()
self.profile = profile
self.programId = programId
self.optionStr = optionStr
self.numTriesSoFar = numTriesSoFar
... | code_fim | hard | {
"lang": "python",
"repo": "hesscl/helena",
"path": "/utilities/runHelenaScript.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def joinProcesses(procs, timeoutInSeconds):
pnum = len(procs)
bool_list = [True]*pnum
start = time.time()
while time.time() - start <= timeoutInSeconds:
for i in range(pnum):
bool_list[i] = procs[i].is_alive()
if np.any(bool_list):
time.sleep(5)
... | code_fim | hard | {
"lang": "python",
"repo": "hesscl/helena",
"path": "/utilities/runHelenaScript.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Brimizer/python-ant path: /ant/core/message.py
elif self.type_ == MESSAGE_CHANNEL_PERIOD:
# msg = ChannelPeriodMessage()
# elif self.type_ == MESSAGE_CHANNEL_SEARCH_TIMEOUT:
# msg = ChannelSearchTimeoutMessage()
# elif self.type_ == MESSAGE_CHANNEL_FREQUENC... | code_fim | hard | {
"lang": "python",
"repo": "Brimizer/python-ant",
"path": "/ant/core/message.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ChannelMessage.__init__(self, msg_id=MESSAGE_CHANNEL_PERIOD,
payload=b'\x00' * 2, number=number)
self.setChannelPeriod(period)
def getChannelPeriod(self):
return struct.unpack('<H', self.get_payload()[1:3])[0]
def setChannelPeriod(self, per... | code_fim | hard | {
"lang": "python",
"repo": "Brimizer/python-ant",
"path": "/ant/core/message.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ChannelMessage(Message):
def __init__(self, msg_id, payload=b'', number=0x00):
Message.__init__(self, msg_id, b'\x00' + payload)
self.setChannelNumber(number)
def get_channel_number(self):
return self._payload[0]
def setChannelNumber(self, number):
if (... | code_fim | hard | {
"lang": "python",
"repo": "Brimizer/python-ant",
"path": "/ant/core/message.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justTill/whereToLunch path: /app/main/controller/logic/absenceLogic.py
import structlog
from main.model.persistence import AbsenceDAO
from utils.enum import Reasons
from utils.date import dateManager
logger = structlog.getLogger(__name__)
class AbsenceLogic:
absence_DAO = AbsenceDAO()
... | code_fim | hard | {
"lang": "python",
"repo": "justTill/whereToLunch",
"path": "/app/main/controller/logic/absenceLogic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_active_absent_absences_from_team(self, team):
logger.debug("get active absent absences")
current_vote_day = dateManager.current_vote_day()
absences = self.absence_DAO.get_absences_from_team_for_reason(Reasons.ABSENT, team)
active_absences = []
for absenc... | code_fim | hard | {
"lang": "python",
"repo": "justTill/whereToLunch",
"path": "/app/main/controller/logic/absenceLogic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xapple/fasta path: /fasta/tests/test_validation.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Written by Lucas Sinclair.
MIT Licensed.
Contact at www.sinclair.bio
This file contains tests to be run automatically with the pytest
executable. To run all the tests just type the following on... | code_fim | medium | {
"lang": "python",
"repo": "xapple/fasta",
"path": "/fasta/tests/test_validation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> invalid_file = this_dir + "data/invalid.fastq"
from fasta import FASTQ
fastq = FASTQ(invalid_file)
assert not fastq.validator(False)<|fim_prefix|># repo: xapple/fasta path: /fasta/tests/test_validation.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Written by Lucas... | code_fim | hard | {
"lang": "python",
"repo": "xapple/fasta",
"path": "/fasta/tests/test_validation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_validation(self):
valid_file = this_dir + "data/seqs.fastq"
from fasta import FASTQ
fastq = FASTQ(valid_file)
assert fastq.validator()
def test_invalid(self):
invalid_file = this_dir + "data/invalid.fastq"
from fasta import FASTQ
fa... | code_fim | hard | {
"lang": "python",
"repo": "xapple/fasta",
"path": "/fasta/tests/test_validation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Test unknown command.
lines = expect_failure(["foo"],
["ERROR: Invalid command: foo"])
expect_failure(["-e", instance.etc_dir, "foo"],
lines)
expect_failure(["-e" + instance.etc_dir, "foo"],
lines)
expect_failure(["-i", "main", "foo"],
... | code_fim | hard | {
"lang": "python",
"repo": "jensl/critic",
"path": "/testing/tests/001-main/001-empty/003-criticctl/001-basic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jensl/critic path: /testing/tests/001-main/001-empty/003-criticctl/001-basic.py
def expect_success(argv, expected_output_lines=[]):
try:
output = instance.criticctl(argv)
except testing.CriticctlError as error:
logger.error("'criticctl %s': correct criticctl usage failed:\... | code_fim | hard | {
"lang": "python",
"repo": "jensl/critic",
"path": "/testing/tests/001-main/001-empty/003-criticctl/001-basic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GabrielEValenzuela/CursoIntensivoPython path: /Segunda clase/Código fuente/matrix.py
import random as rd
FILAS = 4
COLUMNAS = 3
<|fim_suffix|>for i in range(FILAS):
for j in range(COLUMNAS):
matrix[i][j] = rd.randint(0,(FILAS*COLUMNAS))
#Para matrices se usa el primer
... | code_fim | medium | {
"lang": "python",
"repo": "GabrielEValenzuela/CursoIntensivoPython",
"path": "/Segunda clase/Código fuente/matrix.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(FILAS):
for j in range(COLUMNAS):
matrix[i][j] = rd.randint(0,(FILAS*COLUMNAS))
#Para matrices se usa el primer
#[] para fila y el segundo [] la columna
print('Matrix modificada {0}'.format(matrix))<|fim_prefix|># repo: GabrielEValenzuela/CursoIntensivoPython p... | code_fim | medium | {
"lang": "python",
"repo": "GabrielEValenzuela/CursoIntensivoPython",
"path": "/Segunda clase/Código fuente/matrix.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> },
'expert': {
'db': 'inno_park',
'tables': ['expert', 'expert_skill', 'expert_work'],
'ref': []
},
'person': {
'db': 'inno_park',
'tables': ['person', 'person_family', 'person_school'],
'ref': []
... | code_fim | hard | {
"lang": "python",
"repo": "343829084/argo",
"path": "/bootstrap/inno_park.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 343829084/argo path: /bootstrap/inno_park.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
settings = {
'_project_': 'park',
'_Project_': 'Park',
'_company_': 'inno',
'company': 'inno',
'Company': 'Inno',
'_output_': 'E:\\stuff\\gen',
'_dburl_': 'mysql://root:123456@1... | code_fim | hard | {
"lang": "python",
"repo": "343829084/argo",
"path": "/bootstrap/inno_park.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> 'system': {
'db': 'inno_park',
'tables': ['sys_user'],
'ref': []
}
},
'_mobile_': {
},
'_pc_': {
'news': {
'db': 'inno_park',
'tables': ['kit', 'post']
},
'proposal': {
'db': 'inno_par... | code_fim | hard | {
"lang": "python",
"repo": "343829084/argo",
"path": "/bootstrap/inno_park.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tianer2820/Subtitles-for-Images path: /src/main.py
from color_reader import load_colors, str2color
from paragraph import Paragraph, TextBlock
from settings_loader import load_settings
from subtitle_reader import load_subtitle
from utilities import get_best_font_size, load_font
import os
import P... | code_fim | hard | {
"lang": "python",
"repo": "tianer2820/Subtitles-for-Images",
"path": "/src/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> img = PIL.Image.open(join(img_dir, img_list[page]))
print('image loaded')
img: Image
width = img.width
name_font = load_font(join(current_dir, try_get(settings, 'name_font', 'fonts/FZY3JW.TTF', quiet=True)),
int(get_best_font_size(width... | code_fim | hard | {
"lang": "python",
"repo": "tianer2820/Subtitles-for-Images",
"path": "/src/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vmrob/needy path: /needy/commands/dev/render.py
import textwrap
from ... import command
from ...needy import ConfiguredNeedy
class RenderCommand(command.Command):
def name(self):
<|fim_suffix|> def add_parser(self, group):
parser = group.add_parser(
self.name(),
... | code_fim | medium | {
"lang": "python",
"repo": "vmrob/needy",
"path": "/needy/commands/dev/render.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def execute(self, arguments):
with ConfiguredNeedy('.', arguments) as needy:
print(needy.render(needy.target(arguments.target)))
return 0<|fim_prefix|># repo: vmrob/needy path: /needy/commands/dev/render.py
import textwrap
from ... import command
from ...needy import Conf... | code_fim | hard | {
"lang": "python",
"repo": "vmrob/needy",
"path": "/needy/commands/dev/render.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with ConfiguredNeedy('.', arguments) as needy:
print(needy.render(needy.target(arguments.target)))
return 0<|fim_prefix|># repo: vmrob/needy path: /needy/commands/dev/render.py
import textwrap
from ... import command
from ...needy import ConfiguredNeedy
class RenderCommand(... | code_fim | hard | {
"lang": "python",
"repo": "vmrob/needy",
"path": "/needy/commands/dev/render.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amylebar/BatCan path: /li_ion/li_ion_battery_p2d_model.py
istent('IDA_YA_YDP_INIT')
t_ch, SV_ch, SV_dot_ch = sim_ch.simulate(t_f)
SV_ch_df = Label_Columns(t_ch, SV_ch, an.npoints,
sep.npoints, cat.npoints)
if Inputs.... | code_fim | hard | {
"lang": "python",
"repo": "amylebar/BatCan",
"path": "/li_ion/li_ion_battery_p2d_model.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amylebar/BatCan path: /li_ion/li_ion_battery_p2d_model.py
if Inputs.plot_potential_profiles == 1:
plot_potential(tags['Phi_an'], tags['Phi_cat'], SV_dch_df,
'Discharging', 1+(Inputs.flag_re_equil*Inputs.phi_time), fig1, axes1)
if Inputs.plo... | code_fim | hard | {
"lang": "python",
"repo": "amylebar/BatCan",
"path": "/li_ion/li_ion_battery_p2d_model.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Algebraic equation for electrolyte potential"""
res[offset + ptr['Phi']] = i_io_m - i_io_p
# %%
"""================================================================="""
"""===========================CATHODE==============================="""
offsets = cat.offsets;... | code_fim | hard | {
"lang": "python",
"repo": "amylebar/BatCan",
"path": "/li_ion/li_ion_battery_p2d_model.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dgafiulov/flowofcolors path: /rainbow.py
import pygame
import random
#:)
pygame.init()
#win settings
width = 1500
height = 900
x = 0
y = 0
z = 1
y1 = height
x1 = 0
r1 = random.randint(0, 255)
g1 = random.randint(0, 255)
b1 = random.randint(0, 255)
<|fim_suffix|>#other settings
run = True
... | code_fim | hard | {
"lang": "python",
"repo": "dgafiulov/flowofcolors",
"path": "/rainbow.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>countR = r2 - r1
countG = g2 - g1
countB = b2 - b1
numberR = countR / width
numberG = countG / width
numberB = countB / width
#other settings
run = True
#functions
win = pygame.display.set_mode((width, height))
pygame.display.flip()
while run:
for event in pygame.event.get():
if event.type == pyga... | code_fim | hard | {
"lang": "python",
"repo": "dgafiulov/flowofcolors",
"path": "/rainbow.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: telminov/park-worker-base path: /parkworker/task_processor.py
# coding: utf-8
import json
import sys
import os
import traceback
from bson import json_util
from parkworker.const import LEVEL_OK, LEVEL_FAIL, TASK_TYPE_MONIT, TASK_TYPE_WORK
from parkworker.utils import now
class DuplicatedNameEx... | code_fim | hard | {
"lang": "python",
"repo": "telminov/park-worker-base",
"path": "/parkworker/task_processor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> base_dir = os.getcwd()
root_module_name = base_dir.split('/')[-1]
package_dir = base_dir + '/%s' % package_name
if os.path.isdir(package_dir):
for module_path in os.listdir(package_dir):
if not module_path.endswith('.py'):
con... | code_fim | hard | {
"lang": "python",
"repo": "telminov/park-worker-base",
"path": "/parkworker/task_processor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = TaskResult(
level=LEVEL_FAIL,
extra={
'description': str(ex),
'exception_type': str(type(ex)),
'stack_trace': traceback.format_exc(),
}
)
return result
@staticmethod
def _get_clas... | code_fim | hard | {
"lang": "python",
"repo": "telminov/park-worker-base",
"path": "/parkworker/task_processor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser(
description='Changes the provider of specified PreprintService objects'
)
parser.add_argument(
'--dry',
action='store_true',
dest='dry_run',
help='Run migration and roll back changes to db',
)
parser.add_argument... | code_fim | hard | {
"lang": "python",
"repo": "hmoco/osf.io",
"path": "/scripts/migration/migrate_preprints_across_providers.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hmoco/osf.io path: /scripts/migration/migrate_preprints_across_providers.py
import argparse
import json
import logging
from framework.mongo import database
from framework.transactions.context import TokuTransaction
from scripts import utils as script_utils
from website.app import init_app
logge... | code_fim | hard | {
"lang": "python",
"repo": "hmoco/osf.io",
"path": "/scripts/migration/migrate_preprints_across_providers.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('portal', '0015_remove_location_other_features_bucket'),
]
operations = [
migrations.AlterField(
model_name='location',
name='language_1',
field=models.CharField(max_length=200, verbose_name=b'Language 1 (other than English... | code_fim | medium | {
"lang": "python",
"repo": "smartchicago/chicago-early-learning",
"path": "/python/ecep/portal/migrations/0016_auto_20161023_1952.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smartchicago/chicago-early-learning path: /python/ecep/portal/migrations/0016_auto_20161023_1952.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migratio... | code_fim | medium | {
"lang": "python",
"repo": "smartchicago/chicago-early-learning",
"path": "/python/ecep/portal/migrations/0016_auto_20161023_1952.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cl33per/myKungFu path: /python/dice.py
from random import randint
<|fim_suffix|>def rolldice(dieSides):
diceroll = dieSides[randint(0,5)]
return diceroll
print (f'{rolldice(dieSides)}')<|fim_middle|>dieSides = [1,2,3,4,5,6]
| code_fim | easy | {
"lang": "python",
"repo": "cl33per/myKungFu",
"path": "/python/dice.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print (f'{rolldice(dieSides)}')<|fim_prefix|># repo: cl33per/myKungFu path: /python/dice.py
from random import randint
dieSides = [1,2,3,4,5,6]
<|fim_middle|>def rolldice(dieSides):
diceroll = dieSides[randint(0,5)]
return diceroll
| code_fim | medium | {
"lang": "python",
"repo": "cl33per/myKungFu",
"path": "/python/dice.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cl33per/myKungFu path: /python/dice.py
from random import randint
dieSides = [1,2,3,4,5,6]
def rolldice(dieSides):
<|fim_suffix|>print (f'{rolldice(dieSides)}')<|fim_middle|> diceroll = dieSides[randint(0,5)]
return diceroll
| code_fim | easy | {
"lang": "python",
"repo": "cl33per/myKungFu",
"path": "/python/dice.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Test end date that is out of bounds. The end date should be the data set end date with 1 hour added to it.
start_end_dates_new = rd._get_start_end_dates_planetos(
start_date="2001-09-01 01:00",
end_date=None,
num_years=20,
start_date_ds=start_date_ds_merra2,
... | code_fim | hard | {
"lang": "python",
"repo": "NREL/OpenOA",
"path": "/test/unit/test_reanalysis_downloading_toolkit.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NREL/OpenOA path: /test/unit/test_reanalysis_downloading_toolkit.py
import pandas as pd
import pytest
from operational_analysis.toolkits import reanalysis_downloading as rd
def test_get_dataset_names():
dataset_names = {"merra2": "nasa_merra2_global", "era5": "ecmwf_era5_v2"}
assert r... | code_fim | hard | {
"lang": "python",
"repo": "NREL/OpenOA",
"path": "/test/unit/test_reanalysis_downloading_toolkit.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# print(find_SCA) # Should print the document
# print(find_California) # Should print as "None"
# --------------------------------------------------
print('------------------------------------')
# Undo everything you did in the previous step using remove and update.
# Validate wh... | code_fim | hard | {
"lang": "python",
"repo": "EricNg314/Code-Drills",
"path": "/Python_Scraping-and-Document-DBs/day-01/01-MongoDB/unsolved/basics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: EricNg314/Code-Drills path: /Python_Scraping-and-Document-DBs/day-01/01-MongoDB/unsolved/basics.py
# Import your dependencies:
# You'll need pymongo
# Including us_land that we've provided.
# Declare a variable called "us_info" and set it equal to the us_info data in us_land.py
# ---... | code_fim | hard | {
"lang": "python",
"repo": "EricNg314/Code-Drills",
"path": "/Python_Scraping-and-Document-DBs/day-01/01-MongoDB/unsolved/basics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# print(find_California) # Should print as "None"
# --------------------------------------------------
print('------------------------------------')
# Undo everything you did in the previous step using remove and update.
# Validate whether info was updated properly by uncommenting the ... | code_fim | hard | {
"lang": "python",
"repo": "EricNg314/Code-Drills",
"path": "/Python_Scraping-and-Document-DBs/day-01/01-MongoDB/unsolved/basics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return {
"name": name,
"histogram": {
"field": field, "interval": interval
}
}<|fim_prefix|># repo: briankarlberg/grip path: /gripql/python/gripql/aggregations.py
from __future__ import absolute_import, print_function, unicode_literals
<|fim_middle|>def term(... | code_fim | hard | {
"lang": "python",
"repo": "briankarlberg/grip",
"path": "/gripql/python/gripql/aggregations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: briankarlberg/grip path: /gripql/python/gripql/aggregations.py
from __future__ import absolute_import, print_function, unicode_literals
def term(name, field, size=None):
agg = {
"name": name,
"term": {"field": field}
}
if size:
agg["term"]["size"] = size
... | code_fim | medium | {
"lang": "python",
"repo": "briankarlberg/grip",
"path": "/gripql/python/gripql/aggregations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: riccardopoiani/pricing-and-advertising-machine-learning path: /bandit/combinatiorial/CombinatorialBandit.py
from copy import copy
import numpy as np
from abc import ABC
from typing import List
from advertising.data_structure.Campaign import Campaign
from advertising.optimizers.CampaignOptimize... | code_fim | hard | {
"lang": "python",
"repo": "riccardopoiani/pricing-and-advertising-machine-learning",
"path": "/bandit/combinatiorial/CombinatorialBandit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> :return: the indices of the best budgets given the actual campaign
"""
if value_per_clicks is None:
value_per_clicks = np.ones(shape=self.campaign.get_n_sub_campaigns())
temp_campaign: Campaign = copy(self.campaign)
temp_campaign.multiply_sub_campaign_v... | code_fim | hard | {
"lang": "python",
"repo": "riccardopoiani/pricing-and-advertising-machine-learning",
"path": "/bandit/combinatiorial/CombinatorialBandit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jctissier/CreateGMapMarkers path: /GMapMarkers.py
import json
import requests
from pprint import pprint
from bs4 import BeautifulSoup
import gmplot
import webbrowser
import time
class CreateGoogleMapMarkers(object):
API_KEY = ''
# Set API Key
def __init__(self, center_lat, center_l... | code_fim | hard | {
"lang": "python",
"repo": "jctissier/CreateGMapMarkers",
"path": "/GMapMarkers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def set_purple_markers(self, f):
if len(self.purple_lats) == len(self.purple_longs) and (len(self.purple_lats) and len(self.purple_longs)) != 0:
if len(self.purple_titles) != 0:
self.add_locations_info(f, self.purple_lats, self.purple_longs,
... | code_fim | hard | {
"lang": "python",
"repo": "jctissier/CreateGMapMarkers",
"path": "/GMapMarkers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shapiromatron/hawc path: /hawc/apps/epiv2/mixins.py
from django.db import models
from rest_framework import serializers
from .models import Design
class SameDesignSerializerMixin:
"""
ex: when updating an ExposureLevel, there's a related Chemical and Exposure sometimes passed into the ... | code_fim | hard | {
"lang": "python",
"repo": "shapiromatron/hawc",
"path": "/hawc/apps/epiv2/mixins.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> invalid_fields = {}
for param_name, model_klass in self.same_design_fields:
if param_name in self.initial_data:
candidate_id = self.initial_data.get(param_name)
candidate_obj = model_klass.objects.get(id=candidate_id)
... | code_fim | hard | {
"lang": "python",
"repo": "shapiromatron/hawc",
"path": "/hawc/apps/epiv2/mixins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenChemistry/tomviz path: /tomviz/python/BinaryThreshold.py
import tomviz.operators
class BinaryThreshold(tomviz.operators.CancelableOperator):
def transform(self, dataset, lower_threshold=40.0, upper_threshold=255.0):
"""This filter computes a binary threshold on the data set and... | code_fim | hard | {
"lang": "python",
"repo": "OpenChemistry/tomviz",
"path": "/tomviz/python/BinaryThreshold.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
threshold_filter.Update()
except RuntimeError:
return returnValue
self.progress.message = "Creating child data set"
# Set the output as a new child data object of the current data set
label_map_dataset = dat... | code_fim | hard | {
"lang": "python",
"repo": "OpenChemistry/tomviz",
"path": "/tomviz/python/BinaryThreshold.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Approximate percentage of work completed after each step in the
# transform
STEP_PCT = [20, 40, 75, 90, 100]
# Set up return value
returnValue = None
# Try imports to make sure we have everything that is needed
try:
self.progress.mess... | code_fim | hard | {
"lang": "python",
"repo": "OpenChemistry/tomviz",
"path": "/tomviz/python/BinaryThreshold.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ooici/pyon path: /pyon/container/procs.py
, process_id, process_cfg)
# PROCESS TYPE. Determines basic process context (messaging, service interface)
# One of the constants defined at the top of this file
service_cls = named_any("%s.%s" % (module, cls))
process_ty... | code_fim | hard | {
"lang": "python",
"repo": "ooici/pyon",
"path": "/pyon/container/procs.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ooici/pyon path: /pyon/container/procs.py
ess_instance.id)
# map gproc to process_instance
self._spawned_proc_to_process[proc.proc] = process_instance
# set service's reference to process
process_instance._process = proc
# Now call the on_init of the age... | code_fim | hard | {
"lang": "python",
"repo": "ooici/pyon",
"path": "/pyon/container/procs.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Spawn a process acting as immediate one off process.
No attachments.
"""
process_instance = self._create_process_instance(process_id, name, module, cls, config, proc_attr)
self._process_init(process_instance)
self._process_start(process_instance)... | code_fim | hard | {
"lang": "python",
"repo": "ooici/pyon",
"path": "/pyon/container/procs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RNAer/micronota path: /micronota/util.py
r'''
Utility functionality
=====================
.. currentmodule:: micronota.util
This module (:mod:`micronota.util`) provides various utility functionality,
'''
# ----------------------------------------------------------------------------
# Copyright... | code_fim | hard | {
"lang": "python",
"repo": "RNAer/micronota",
"path": "/micronota/util.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Examples
--------
Let's create a file object that has sequences separated by "//" at
the end of each record (similar to multiple GenBank records in a file):
>>> import io
>>> s = """seq1
... AT
... //
... seq2
... ATGC
... //
... """
>>> f = io.StringIO... | code_fim | hard | {
"lang": "python",
"repo": "RNAer/micronota",
"path": "/micronota/util.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: google/grr path: /grr/config/grr_response_templates/setup.py
#!/usr/bin/env python
"""This package contains GRR client templates."""
import configparser
import glob
import os
import re
import shutil
from setuptools import setup
from setuptools.command.sdist import sdist
THIS_DIRECTORY = os.pat... | code_fim | hard | {
"lang": "python",
"repo": "google/grr",
"path": "/grr/config/grr_response_templates/setup.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.