text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> return self.history[self.ptr]
def forward(self, steps: int) -> str:
self.ptr += steps
self.ptr = min(self.size - 1, self.ptr)
return self.history[self.ptr]
# Your BrowserHistory object will be instantiated and called as such:
# obj = BrowserHistory(homepage)... | code_fim | hard | {
"lang": "python",
"repo": "Aden-Q/LeetCode",
"path": "/code/1472.Design-Browser-History.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aden-Q/LeetCode path: /code/1472.Design-Browser-History.py
class BrowserHistory:
# First, considering the requirement to go forward && backward
# There are two useful data structure: array or doulby-linked list
# The trade off is between visit and back/forward
# Array allows us qu... | code_fim | hard | {
"lang": "python",
"repo": "Aden-Q/LeetCode",
"path": "/code/1472.Design-Browser-History.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vsoch/CogPheno path: /cogpheno/apps/assessments/migrations/old/0001_initial.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
]
opera... | code_fim | hard | {
"lang": "python",
"repo": "vsoch/CogPheno",
"path": "/cogpheno/apps/assessments/migrations/old/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ions={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='QuestionOption',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('numerical_score',... | code_fim | hard | {
"lang": "python",
"repo": "vsoch/CogPheno",
"path": "/cogpheno/apps/assessments/migrations/old/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nimomaina/Pitch path: /tests/test_pitch.py
import unittest
from app.models import Pitch
class NewsTest(unittest.TestCase):
'''
Test class to test the behavior of the news source class
'''
def setUp(self):
<|fim_suffix|> '''
'''
... | code_fim | hard | {
"lang": "python",
"repo": "nimomaina/Pitch",
"path": "/tests/test_pitch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
Set up method that will run before every Test
'''
self.new_pitch = Pitch(1, 1,'my pitch', 'pitch',
'business', 'great', 0, 0)
def test_instance(self):
'''
'''
self.asser... | code_fim | hard | {
"lang": "python",
"repo": "nimomaina/Pitch",
"path": "/tests/test_pitch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pcmagic/stokes_flow path: /src/support_class.py
nstruct_matrix',
'check_file_extension', 'mpiprint', 'fullprint',
'coordinate_transformation',
'tube_flatten',
'get_rot_matrix', 'rot_vec2rot_mtx', 'vector_rotation_norm', 'vector_rotation',
'ro... | code_fim | hard | {
"lang": "python",
"repo": "pcmagic/stokes_flow",
"path": "/src/support_class.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> W = self.q[0]
X = self.q[1]
Y = self.q[2]
Z = self.q[3]
w = other.q[0]
x = other.q[1]
y = other.q[2]
z = other.q[3]
Q = Quaternion()
Q.q = np.array([
w * W - x * X - y * Y - z * Z,
W * x + w * X + Y *... | code_fim | hard | {
"lang": "python",
"repo": "pcmagic/stokes_flow",
"path": "/src/support_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """docstring for Quaternion"""
def __init__(self, axis=np.array([0, 0, 1.0]), angle=0):
axis = np.array(axis)
xyz = np.sin(.5 * angle) * axis / np.linalg.norm(axis)
self.q = np.array([
np.cos(.5 * angle),
xyz[0],
xyz[1],
xyz... | code_fim | hard | {
"lang": "python",
"repo": "pcmagic/stokes_flow",
"path": "/src/support_class.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@app.cli.command()
def test():
click.echo('Running tests...')
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)<|fim_prefix|># repo: vpaliy/react-chat path: /backend/chat.py
import os
import click
from app import create_app, db
from ... | code_fim | medium | {
"lang": "python",
"repo": "vpaliy/react-chat",
"path": "/backend/chat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@app.cli.command()
def test():
click.echo('Running tests...')
import unittest
tests = unittest.TestLoader().discover('tests')
unittest.TextTestRunner(verbosity=2).run(tests)<|fim_prefix|># repo: vpaliy/react-chat path: /backend/chat.py
import os
import click
from app import create_app, db
from a... | code_fim | medium | {
"lang": "python",
"repo": "vpaliy/react-chat",
"path": "/backend/chat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vpaliy/react-chat path: /backend/chat.py
import os
import click
from app import create_app, db
from app.user.models import User
from app.rooms.models import Room
from config import config
configuration = config[os.getenv('flavor') or 'development']
app = create_app(configuration)
@app.shell_co... | code_fim | medium | {
"lang": "python",
"repo": "vpaliy/react-chat",
"path": "/backend/chat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _register_parameters(self):
...
def discover_in_path(self, path):
self.__paths_to_discover.append(path)
def __discover_in_paths(cls, path):
modules = pkgutil.walk_packages(path=[path])
for module in modules:
logging.debug(f"Importing path {path... | code_fim | hard | {
"lang": "python",
"repo": "Hungsiro506/faust-bootstrap",
"path": "/faust_bootstrap/core/app/app_faust.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> streams_config = get_streams_config(self.PREFIX, os.environ)
return streams_config
def _generate_configuration(self) -> faust.Settings:
streams_config = self._generate_streams_config()
faust_configuration = build_faust_config(self.brokers, streams_config)
setti... | code_fim | hard | {
"lang": "python",
"repo": "Hungsiro506/faust-bootstrap",
"path": "/faust_bootstrap/core/app/app_faust.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Hungsiro506/faust-bootstrap path: /faust_bootstrap/core/app/app_faust.py
import faust
from faust import Record, ChannelT
from faust.types import CodecT
from abc import ABC, abstractmethod
import importlib
import os
import sys
import pkgutil
from typing import Any, Iterable, Union, List, Callable
... | code_fim | hard | {
"lang": "python",
"repo": "Hungsiro506/faust-bootstrap",
"path": "/faust_bootstrap/core/app/app_faust.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hhefzi/CKG path: /src/graphdb_builder/experiments/parsers/clinicalParser.py
builder_utils.get_config(config_name="clinical.yml", data_type='experiments')
clinical_directory = os.path.join(cwd, '../../../../data/experiments/PROJECTID/clinical/')
design_directory = os.path.join(cwd, '../..... | code_fim | hard | {
"lang": "python",
"repo": "hhefzi/CKG",
"path": "/src/graphdb_builder/experiments/parsers/clinicalParser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> df = pd.DataFrame(columns=['START_ID', 'END_ID', 'quantity', 'quantity_units'])
if 'analytical_sample external_id' in clinical_data:
if not pd.isna(clinical_data['analytical_sample external_id']).any():
df = clinical_data[['biological_sample external_id', 'analytical_sample ext... | code_fim | hard | {
"lang": "python",
"repo": "hhefzi/CKG",
"path": "/src/graphdb_builder/experiments/parsers/clinicalParser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def extract_biosample_identifiers(design_data):
df = pd.DataFrame(columns=['ID', 'external_id'])
data = design_data.set_index('biological_sample id').copy()
if not pd.isna(data['biological_sample external_id']).any():
df = data[['biological_sample external_id']].dropna(axis=0).reset_in... | code_fim | hard | {
"lang": "python",
"repo": "hhefzi/CKG",
"path": "/src/graphdb_builder/experiments/parsers/clinicalParser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kiorisyshen/ROMP path: /romp/predict/webcam.py
import sys
whether_set_yml = ['configs_yml' in input_arg for input_arg in sys.argv]
if sum(whether_set_yml)==0:
default_webcam_configs_yml = "--configs_yml=configs/webcam.yml"
print('No configs_yml is set, set it to the default {}'.format(de... | code_fim | hard | {
"lang": "python",
"repo": "kiorisyshen/ROMP",
"path": "/romp/predict/webcam.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('run on remote')
from utils.remote_server_utils import Server_port_receiver
capture = Server_port_receiver()
while True:
frame = capture.receive()
if isinstance(frame,list):
continue
with torch.no_grad():
... | code_fim | hard | {
"lang": "python",
"repo": "kiorisyshen/ROMP",
"path": "/romp/predict/webcam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Aunsiels/pyformlang path: /pyformlang/finite_automaton/partition.py
"""Class to manage partitions used in Hopcroft minimization algorithm
For internal usage.
"""
from .doubly_linked_list import DoublyLinkedList
class Partition:
"""Class to manage partitions used in Hopcroft minimization al... | code_fim | hard | {
"lang": "python",
"repo": "Aunsiels/pyformlang",
"path": "/pyformlang/finite_automaton/partition.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Get the valid sets"""
class_names = [0] * self._counter
for element in inverse:
class_names[self._class_names[element]] += 1
return [i for i, value in enumerate(class_names)
if value != 0 and value != len(self.part[i])]
def split(self, to... | code_fim | hard | {
"lang": "python",
"repo": "Aunsiels/pyformlang",
"path": "/pyformlang/finite_automaton/partition.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tatus('current')
cpuLoadInform = NotificationType((1, 3, 6, 1, 4, 1, 1751, 1, 1198, 4, 0, 5)).setObjects(("AGGREGATED-EXT-MIB", "host"), ("AGGREGATED-EXT-MIB", "load"), ("AGGREGATED-EXT-MIB", "status"))
if mibBuilder.loadTexts: cpuLoadInform.setStatus('current')
diskUsageWarning = NotificationType((1, 3, ... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/RM-TRAP-MIB.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: agustinhenze/mibs.snmplabs.com path: /pysnmp/RM-TRAP-MIB.py
#
# PySNMP MIB module RM-TRAP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RM-TRAP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:49:37 2019
# On host DAVWANG4-M-1475 platform Darwin ve... | code_fim | hard | {
"lang": "python",
"repo": "agustinhenze/mibs.snmplabs.com",
"path": "/pysnmp/RM-TRAP-MIB.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Bleyddyn/malpi path: /malpi/train/experiment.py
""" A class for writing out everything associated with a training run.
E.g. Command line arguments, hyperparameters, input and output sizes, model description, results
"""
import os
import sys
import argparse
import datetime
import pickle
import sub... | code_fim | hard | {
"lang": "python",
"repo": "Bleyddyn/malpi",
"path": "/malpi/train/experiment.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _writeVersions(self, fileobj):
fileobj.write( "Module Versions:\n" )
self._writeOne( fileobj, "Python", self.pythonVersionString(), indent=" " )
self._writeOne( fileobj, "Experiment", Experiment.__version__, indent=" " )
for mod in self.modules:
sel... | code_fim | hard | {
"lang": "python",
"repo": "Bleyddyn/malpi",
"path": "/malpi/train/experiment.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scytale/export_xmp path: /export_xmp.py
#!/usr/bin/python
#2018-07-20T10:54:38-0700 Fri huari4 at gmail dot com testing http://python-xmp-toolkit.readthedocs.io/en/latest/index.html after install of exempi from debian repo
# program is able to read the metadata from files listed as arguments
im... | code_fim | medium | {
"lang": "python",
"repo": "scytale/export_xmp",
"path": "/export_xmp.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># add new fileypes as needed
file_extensions = ['.jpg','.JPG','.gif','.png','.pdf','.psd','.eps','.tif','.ai','.jpeg']
for eachFile in myFiles:
xmpfile = XMPFiles( file_path=eachFile, open_forupdate=True )
xmp = xmpfile.get_xmp()
xmp_dict = file_to_dict( eachFile )
print
print("= Filename: ... | code_fim | hard | {
"lang": "python",
"repo": "scytale/export_xmp",
"path": "/export_xmp.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> xmp_dict = file_to_dict( eachFile )
print
print("= Filename: " + eachFile + " =")
# let's test for the file extension. If valid then display the xmp, else print "not a valid file type"
pos = eachFile.rfind('.',0,-1 )
input_file_extension = eachFile[pos:]
if input_file_extension in file_ex... | code_fim | medium | {
"lang": "python",
"repo": "scytale/export_xmp",
"path": "/export_xmp.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return keywords[self.value.upper()]<|fim_prefix|># repo: vcokltfre/vcoasm path: /vcoasm/token.py
from dataclasses import dataclass
from .kw import keywords
<|fim_middle|>
@dataclass
class Token:
type: str
value: str
file: str
line: int
@property
def op(self):
| code_fim | medium | {
"lang": "python",
"repo": "vcokltfre/vcoasm",
"path": "/vcoasm/token.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vcokltfre/vcoasm path: /vcoasm/token.py
from dataclasses import dataclass
from .kw import keywords
@dataclass
class Token:
<|fim_suffix|> @property
def op(self):
return keywords[self.value.upper()]<|fim_middle|> type: str
value: str
file: str
line: int
| code_fim | easy | {
"lang": "python",
"repo": "vcokltfre/vcoasm",
"path": "/vcoasm/token.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def op(self):
return keywords[self.value.upper()]<|fim_prefix|># repo: vcokltfre/vcoasm path: /vcoasm/token.py
from dataclasses import dataclass
<|fim_middle|>from .kw import keywords
@dataclass
class Token:
type: str
value: str
file: str
line: int
| code_fim | medium | {
"lang": "python",
"repo": "vcokltfre/vcoasm",
"path": "/vcoasm/token.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BenWoodford/home-assistant path: /tests/components/microsoft_face_identify/test_image_processing.py
"""The tests for the microsoft face identify platform."""
from unittest.mock import PropertyMock, patch
import homeassistant.components.image_processing as ip
import homeassistant.components.micro... | code_fim | hard | {
"lang": "python",
"repo": "BenWoodford/home-assistant",
"path": "/tests/components/microsoft_face_identify/test_image_processing.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @patch(
"homeassistant.components.microsoft_face_identify.image_processing."
"MicrosoftFaceIdentifyEntity.should_poll",
new_callable=PropertyMock(return_value=False),
)
def test_ms_identify_process_image(self, poll_mock, aioclient_mock):
"""Set up and scan a pic... | code_fim | hard | {
"lang": "python",
"repo": "BenWoodford/home-assistant",
"path": "/tests/components/microsoft_face_identify/test_image_processing.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> auth = TaskWorld.post_api('auth', {
'email': email, 'password': password
})
if not auth['ok']:
raise ValueError(sprint(auth))
self.token = auth['access_token']
self.default_workspace = auth['default_space_id']
self.workspaces = auth['... | code_fim | hard | {
"lang": "python",
"repo": "amenoyoya/slack-taskworld",
"path": "/libs/tw.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amenoyoya/slack-taskworld path: /libs/tw.py
# encoding: utf-8
'''
TaskWorld API wrapper
'''
import requests
from .utils import *
class TaskWorld:
@staticmethod
def post_api(api, data):
return requests.post(
'http://asia-api.taskworld.com/v1/' + api,
json.d... | code_fim | hard | {
"lang": "python",
"repo": "amenoyoya/slack-taskworld",
"path": "/libs/tw.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Unregisters the instance from amazon sns.
"""
try:
if instance.is_registered and not instance.deregister(save=False):
logger.warn("Could not unregister {0} on delete.".format(
sender
))
except SNSException:
# Avoid that invali... | code_fim | hard | {
"lang": "python",
"repo": "founders4schools/django-scarface",
"path": "/scarface/signals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: founders4schools/django-scarface path: /scarface/signals.py
# -*- coding: utf-8 -*-
import logging
from django.db.models.signals import post_delete
from django.dispatch import receiver
<|fim_suffix|>@receiver(post_delete, sender=Device)
@receiver(post_delete, sender=Platform)
@receiver(post_de... | code_fim | medium | {
"lang": "python",
"repo": "founders4schools/django-scarface",
"path": "/scarface/signals.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>__author__ = 'janmeier'
logger = logging.getLogger('django_scarface')
@receiver(post_delete, sender=Device)
@receiver(post_delete, sender=Platform)
@receiver(post_delete, sender=Topic)
@receiver(post_delete, sender=Subscription)
def instance_deleted(sender, instance, **kwargs):
"""
Unregisters t... | code_fim | medium | {
"lang": "python",
"repo": "founders4schools/django-scarface",
"path": "/scarface/signals.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shubhamnag14/Emotion_detector path: /camera.py
# Let us import the Libraries required.
import cv2
import numpy as np
from model import FacialExpressionModel
# Creating an instance of the class with the parameters as model and its weights.
model = FacialExpressionModel("model.json", "mode... | code_fim | hard | {
"lang": "python",
"repo": "shubhamnag14/Emotion_detector",
"path": "/camera.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Finding the Coordinates and Radius of Circle
xc = int((x + x+w)/2)
yc = int((y + y+h)/2)
radius = int(w/2)
# Drawing the Circle on the Image
cv2.circle(frame, (xc, yc), radius, (0, 255, 0), Thickness)
# Encoding th... | code_fim | hard | {
"lang": "python",
"repo": "shubhamnag14/Emotion_detector",
"path": "/camera.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rluiseugenio/dpa_rita path: /src/orquestadores/modelling.py
'''
SIMPLE
PYTHONPATH='.' AWS_PROFILE=dpa luigi --module modelling RunModelSimple --local-scheduler
PARA UN MODELO
PYTHONPATH='.' AWS_PROFILE=dpa luigi --module modelling RunModel --local-scheduler --bucname models-dpa --numIt 2 --nu... | code_fim | hard | {
"lang": "python",
"repo": "rluiseugenio/dpa_rita",
"path": "/src/orquestadores/modelling.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def output(self):
objetivo = TARGET_B
model_name = self.model
hyperparams = {"iter": int(self.numIt),
"pca": int(self.numPCA)}
output_path = parse_filename(objetivo, model_name, hyperparams)
output_path = "s3://" + str(self.bucname) + output_path[1:] + ".model.zip"
return luigi.contr... | code_fim | hard | {
"lang": "python",
"repo": "rluiseugenio/dpa_rita",
"path": "/src/orquestadores/modelling.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class RunTargetC(luigi.Task):
bucname = luigi.Parameter()
numIt = luigi.Parameter()
numPCA = luigi.Parameter()
model = luigi.Parameter()
def requires(self):
return Metadata_Semantic()
def output(self):
objetivo = TARGET_C
model_name = self.model
hyperparams = {"iter": int(self.numIt),
... | code_fim | hard | {
"lang": "python",
"repo": "rluiseugenio/dpa_rita",
"path": "/src/orquestadores/modelling.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
cols=[t + '_' + h for t in ['T','M','TUM','TM'] for h in [
'3','6','9','12','24']] + \
['T_5','T_10','T_20','T5uT20','T_25','M_10','M5uM10','M_15']
y = [x/255 for x in [249, 255, 60]]
b = [x/255 for x in [86, 112, 255]]
r = [x/255 for x in [255, 9, 60]]
g = [x/255 for x in [0,255... | code_fim | hard | {
"lang": "python",
"repo": "jennifereldiaz/drug-synergy",
"path": "/geneset_enrichment/selectedfishers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jennifereldiaz/drug-synergy path: /geneset_enrichment/selectedfishers.py
#check diff exp lists against all gene sets of selected libraries
#oct 15 2016
import pandas as pd
from itertools import product
from scipy import stats
import numpy as np
from statsmodels.sandbox.stats.multicomp import mul... | code_fim | hard | {
"lang": "python",
"repo": "jennifereldiaz/drug-synergy",
"path": "/geneset_enrichment/selectedfishers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>er = pd.read_csv('genesets.gmt',sep='\t',names = list(range(300)))
cand = pd.concat([go,er]).set_index(0)
finalsets = [
#cell cycle
'mitotic cell cycle (GO:0000278)', \
#ER
'BHAT_ESR1_TARGETS_NOT_VIA_AKT1_UP', 'BHAT_ESR1_TARGETS_NOT_VIA_AKT1_D... | code_fim | hard | {
"lang": "python",
"repo": "jennifereldiaz/drug-synergy",
"path": "/geneset_enrichment/selectedfishers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if endpoint == None or endpoint.strip() == "":
raise Exception("REST API endpoint is needed")
cur_timestamp = str(int(round(time.time()*1000)))
# if python 3
if sys.version_info > (3,0):
url_encoded_query_params = urllib.parse.urlencode(query_params)... | code_fim | hard | {
"lang": "python",
"repo": "kenial/limelight_rest_wrapper",
"path": "/limelight_rest_wrapper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kenial/limelight_rest_wrapper path: /limelight_rest_wrapper.py
import sys
import time
import urllib
import hmac
import hashlib
import requests
import json
class LimelightRESTWrapper(object):
def __init__(self, limelight_user_id, api_key):
super(LimelightRESTWrapper, self).__init__()
... | code_fim | hard | {
"lang": "python",
"repo": "kenial/limelight_rest_wrapper",
"path": "/limelight_rest_wrapper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: davidkellis/py2rb path: /tests/unittest/assertRaises.py
import unittest
class MyException(Exception):
pass
class MyException2(Exception):
pass
class MyException3(Exception):
pass
class Foo:
def test(self):
raise MyException
class Bar:
def test(self, a, b, c=1, d=2... | code_fim | medium | {
"lang": "python",
"repo": "davidkellis/py2rb",
"path": "/tests/unittest/assertRaises.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def bar(self):
assert False
def test_runnable(self):
''' NameError: name 'foo' is not defined '''
with self.assertRaises(NameError):
foo
foo = Foo()
self.assertRaises(MyException, foo.test)
bar = Bar()
self.assertRaises(MyExce... | code_fim | hard | {
"lang": "python",
"repo": "davidkellis/py2rb",
"path": "/tests/unittest/assertRaises.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class TestRunnable(unittest.TestCase):
def bar(self):
assert False
def test_runnable(self):
''' NameError: name 'foo' is not defined '''
with self.assertRaises(NameError):
foo
foo = Foo()
self.assertRaises(MyException, foo.test)
bar =... | code_fim | medium | {
"lang": "python",
"repo": "davidkellis/py2rb",
"path": "/tests/unittest/assertRaises.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Given:
beehive_before = BeeHive.objects.count()
# When:
new_beehive = create_fake_beehive()
# Then:
assert BeeHive.objects.count() == beehive_before + 1<|fim_prefix|># repo: BartekStok/beehive-apiary-sim path: /beehive/tests/temp/#test_beehive.py
import... | code_fim | medium | {
"lang": "python",
"repo": "BartekStok/beehive-apiary-sim",
"path": "/beehive/tests/temp/#test_beehive.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BartekStok/beehive-apiary-sim path: /beehive/tests/temp/#test_beehive.py
import pytest
from django.test import TestCase
from beehive.tests.conftest import set_up_apiary
from beehive.tests.utils import create_fake_beehive, BeeHive, create_fake_mother
<|fim_suffix|> # When:
new_be... | code_fim | hard | {
"lang": "python",
"repo": "BartekStok/beehive-apiary-sim",
"path": "/beehive/tests/temp/#test_beehive.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shannpersand/cooper-type path: /workshops/Python Workshop/Just/2016-06-25 CooperWest workshop day 1/09 check for components.py
for g in CurrentFont():
# if there are components in the glyph
if g.components:
# set the c<|fim_suffix|> if not, reset the color to None
g.mark =... | code_fim | easy | {
"lang": "python",
"repo": "shannpersand/cooper-type",
"path": "/workshops/Python Workshop/Just/2016-06-25 CooperWest workshop day 1/09 check for components.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not, reset the color to None
g.mark = None<|fim_prefix|># repo: shannpersand/cooper-type path: /workshops/Python Workshop/Just/2016-06-25 CooperWest workshop day 1/09 check for components.py
for g in CurrentFont():
# if there are components<|fim_middle|> in the glyph
if g.components:
... | code_fim | medium | {
"lang": "python",
"repo": "shannpersand/cooper-type",
"path": "/workshops/Python Workshop/Just/2016-06-25 CooperWest workshop day 1/09 check for components.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Use pin A2 as a fake ground for the rotary encoder
fakegnd = DigitalInOut(board.A2)
fakegnd.direction = Direction.OUTPUT
fakegnd.value = False
encoder = rotaryio.IncrementalEncoder(board.A3, board.A1)
print("---Chromakey Light Ring---")
last_encoder_val = encoder.position
ring_pos = 0
rainbow_pos = 0... | code_fim | hard | {
"lang": "python",
"repo": "adafruit/Adafruit_Learning_System_Guides",
"path": "/Chromakey_Light_Ring/code.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adafruit/Adafruit_Learning_System_Guides path: /Chromakey_Light_Ring/code.py
# SPDX-FileCopyrightText: 2021 Tod Kurt @todbot and John Park for Adafruit Industries
# SPDX-License-Identifier: MIT
# QT Py encoder based on https://github.com/todbot/qtpy-knob
# Retroreflective chromakey light ring
# ... | code_fim | hard | {
"lang": "python",
"repo": "adafruit/Adafruit_Learning_System_Guides",
"path": "/Chromakey_Light_Ring/code.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: opencbsoft/kids-worksheet-generator path: /application/core/generators/math_add_easy.py
import random
from core.utils import Generator
class Main(Generator):
name = 'Fast addition in one minute'
years = [5, 6]
directions = 'Afla cat de multe operatiuni poti rezolva in maxim 1 minut.... | code_fim | hard | {
"lang": "python",
"repo": "opencbsoft/kids-worksheet-generator",
"path": "/application/core/generators/math_add_easy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> numbers = list(range(0, 10))
results = []
for i in range(self.count):
row = []
while not len(row) == 48:
left_number = random.choice(numbers)
righ_possible = numbers.copy()
righ_possible.remove(left_number)
... | code_fim | hard | {
"lang": "python",
"repo": "opencbsoft/kids-worksheet-generator",
"path": "/application/core/generators/math_add_easy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>E = "autumn"
AWS_REGION = "ap-southeast-2"
BASE_DIR = os.path.join(OUTPUT_DATA_PATH, "remote")<|fim_prefix|># repo: malanchak/AuTuMN path: /tasks/settings.py
import os
from autumn.constants import OUTPUT_<|fim_middle|>DATA_PATH
S3_BUCKET = "autumn-data"
AWS_PROFIL | code_fim | easy | {
"lang": "python",
"repo": "malanchak/AuTuMN",
"path": "/tasks/settings.py",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: malanchak/AuTuMN path: /tasks/settings.py
import os
from autumn.constants import OUTPUT_<|fim_suffix|>_DIR = os.path.join(OUTPUT_DATA_PATH, "remote")<|fim_middle|>DATA_PATH
S3_BUCKET = "autumn-data"
AWS_PROFILE = "autumn"
AWS_REGION = "ap-southeast-2"
BASE | code_fim | medium | {
"lang": "python",
"repo": "malanchak/AuTuMN",
"path": "/tasks/settings.py",
"mode": "psm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_suffix|>_DIR = os.path.join(OUTPUT_DATA_PATH, "remote")<|fim_prefix|># repo: malanchak/AuTuMN path: /tasks/settings.py
import os
from autumn.constants import OUTPUT_DATA_PATH
S3_BUCKET = "autumn-data"
AWS_PROFIL<|fim_middle|>E = "autumn"
AWS_REGION = "ap-southeast-2"
BASE | code_fim | easy | {
"lang": "python",
"repo": "malanchak/AuTuMN",
"path": "/tasks/settings.py",
"mode": "spm",
"license": "BSD-2-Clause-Views",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ydtan123/pytorch-retinanet path: /create_dataset.py
#!/usr/bin/python3
import argparse
import cv2
import os
import pathlib
import random
def getLocation(txtfile, img_file):
#0 0.056711 0.629032 0.030246 0.204301
symbols = []
img = cv2.imread(str(img_file))
imgh, imgw, _ = img.sha... | code_fim | hard | {
"lang": "python",
"repo": "ydtan123/pytorch-retinanet",
"path": "/create_dataset.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> test_count = 0
train_count = 0
file_info = []
for f in files:
fstr = str(f)
txtfile = f.with_suffix(".txt")
if (not os.path.isfile(str(txtfile))):
print("GT file for {0} does not exist".format(f))
continue
img_labels = getLocation(tx... | code_fim | hard | {
"lang": "python",
"repo": "ydtan123/pytorch-retinanet",
"path": "/create_dataset.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> random.shuffle(files)
test_count = 0
train_count = 0
file_info = []
for f in files:
fstr = str(f)
txtfile = f.with_suffix(".txt")
if (not os.path.isfile(str(txtfile))):
print("GT file for {0} does not exist".format(f))
continue
... | code_fim | hard | {
"lang": "python",
"repo": "ydtan123/pytorch-retinanet",
"path": "/create_dataset.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pertschuk/dl4marco-bert path: /server.py
import tensorflow as tf
import tokenization
import optimization
import modeling
import queue
import time
import numpy as np
import csv
from threading import Thread
from collections import defaultdict
MAX_SEQ_LENGTH = 512
num_labels = 2
BATCH_SIZE = 4
VOCA... | code_fim | hard | {
"lang": "python",
"repo": "pertschuk/dl4marco-bert",
"path": "/server.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert len(candidates) % BATCH_SIZE == 0
input_q.put((query, candidates))
results = [output_q.get() for _ in range(size)][:true_size]
log_probs = list(zip(*results))
assert len(log_probs[0]) == size - padding
assert len(log_probs[0]) == len(log_probs[1])
... | code_fim | hard | {
"lang": "python",
"repo": "pertschuk/dl4marco-bert",
"path": "/server.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> dev_set = defaultdict(list)
dev_queries = dict()
dev_labels = defaultdict(list)
with open(data_dir + 'top1000.dev') as fn:
reader = csv.reader(fn, delimiter='\t')
i = 0
for qid, cid, query, passage in reader:
dev_set[qid].append(passage)
dev... | code_fim | hard | {
"lang": "python",
"repo": "pertschuk/dl4marco-bert",
"path": "/server.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Confirm that the mock was called.
assert mock_get_todos.called
# Confirm that the expected filtered list of todos was returned.
assert uncompleted_todos == [todo1]
@patch('project.services.get_todos')
def test_getting_uncompleted_todos_when_todos_is_none(mock_get_todos):
"""Test g... | code_fim | hard | {
"lang": "python",
"repo": "clair3st/mock",
"path": "/project/tests/test_todos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: clair3st/mock path: /project/tests/test_todos.py
"""Testing an api."""
import requests
from unittest.mock import Mock, patch
from project.services import get_todos, get_uncompleted_todos
def test_request():
"""Send a request to the API server and store the response."""
response = reque... | code_fim | hard | {
"lang": "python",
"repo": "clair3st/mock",
"path": "/project/tests/test_todos.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@patch('project.services.requests.get')
def test_getting_todos_when_response_is_not_ok(mock_get):
"""Test negative."""
# Configure the mock to not return a response with an OK status code.
mock_get.return_value.ok = False
# Call the service, which will send a request to the server.
r... | code_fim | hard | {
"lang": "python",
"repo": "clair3st/mock",
"path": "/project/tests/test_todos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.logger = rootLogger
self.log_folder = log_folder
self.print_every = print_every
self.save_every = save_every
self.log_counter = 0
self.save_counter = 0
self.logger.info("init the outputer!")
def log_step(self, log_str):
if self.log_... | code_fim | hard | {
"lang": "python",
"repo": "smallflyingpig/cross_modal_compression_pytorch_submit",
"path": "/utils/util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> file_list = []
path1_list = []
ext1_list = []
for path, folder, files in os.walk(data_folder1):
if len(files)<1:
continue
file_list.append([_f for _f in files if os.path.splitext(_f)[-1] in ext_set])
ext1_list.append(os.path.splitext(files[0])[-1])
... | code_fim | hard | {
"lang": "python",
"repo": "smallflyingpig/cross_modal_compression_pytorch_submit",
"path": "/utils/util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: smallflyingpig/cross_modal_compression_pytorch_submit path: /utils/util.py
import torch
import numpy as np
import pickle
class RunningAverage(object):
def __init__(self):
self.val_hist = {}
self.n_hist = {}
def update(self, data:dict, count:dict):
assert(isinstan... | code_fim | hard | {
"lang": "python",
"repo": "smallflyingpig/cross_modal_compression_pytorch_submit",
"path": "/utils/util.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return requests.get(HOSTS_URL).text
def isAd(host):
hst = cache.get(getit, 2880)
h = urlparse(host).netloc
return (h in hst)<|fim_prefix|># repo: feerlessleadr/plugin.video.apex_sports path: /resources/lib/modules/liveresolver/modules/adhosts.py
import re
import requests
from resources.lib.modules i... | code_fim | medium | {
"lang": "python",
"repo": "feerlessleadr/plugin.video.apex_sports",
"path": "/resources/lib/modules/liveresolver/modules/adhosts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: feerlessleadr/plugin.video.apex_sports path: /resources/lib/modules/liveresolver/modules/adhosts.py
import re
import requests
from resources.lib.modules import cache
try:
from urllib.parse import urlparse
except:
from urlparse import urlparse # Python 2
HOSTS_URL = 'https://raw.githubusercon... | code_fim | medium | {
"lang": "python",
"repo": "feerlessleadr/plugin.video.apex_sports",
"path": "/resources/lib/modules/liveresolver/modules/adhosts.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.__dict__ = d
def __str__(self):
return str(self.__dict__)
def generate_single_plot(train_data, val_data, epochs, ylabel, title, filename):
xs = list(range(0, epochs, 10))
fig, ax = plt.subplots()
ax.plot(xs, train_data, label="Train")
ax.plot(... | code_fim | hard | {
"lang": "python",
"repo": "nick-bowman/cs224w-project",
"path": "/experiments/gcn_experiments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nick-bowman/cs224w-project path: /experiments/gcn_experiments.py
import time
import networkx as nx
import numpy as np
import torch
import torch.optim as optim
import torch.nn.functional as F
import traceback
from torch_geometric.data import DataLoader
import torch_geometric.nn as pyg_nn
impo... | code_fim | hard | {
"lang": "python",
"repo": "nick-bowman/cs224w-project",
"path": "/experiments/gcn_experiments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if dev == 'fr':
beta = _fletcher_reeves(grad, ograd)
elif dev == 'pr':
beta = _polak_ribiere(grad, ograd)
return beta
def rp_directions(grads, n, device):
rp_sdirs = []
for _ in range(n):
rp_sdirs_i = []
for grad in grads:
grad_flat = grad... | code_fim | hard | {
"lang": "python",
"repo": "sidsrini12/FURL_Sim",
"path": "/LBGM/src/optim/directed_gradient.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sidsrini12/FURL_Sim path: /LBGM/src/optim/directed_gradient.py
import torch
import torch.optim as optim
class DirectedGradient(optim.Optimizer):
def __init__(self, params, lr, line_search=False):
defaults = dict(lr=lr, line_search=line_search)
super(DirectedGradient, self)._... | code_fim | medium | {
"lang": "python",
"repo": "sidsrini12/FURL_Sim",
"path": "/LBGM/src/optim/directed_gradient.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: microsoft/roman path: /test/arm_unit_test.py
import sys
import numpy as np
import math
import time
import random
import os
rootdir = os.path.dirname(os.path.dirname(__file__))
os.sys.path.insert(0, rootdir)
from roman.ur import *
from roman.ur.realtime.interface import *
########################... | code_fim | hard | {
"lang": "python",
"repo": "microsoft/roman",
"path": "/test/arm_unit_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pass
def execute(self, cmd, state):
state[:] = self.__state
return state
def chain_test():
"""Verify that nothing complains when chaining arm controllers"""
print(f"Running {__file__}::{chain_test.__name__}()")
con = Connection(State())
arm_ctrl = BasicControll... | code_fim | hard | {
"lang": "python",
"repo": "microsoft/roman",
"path": "/test/arm_unit_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ryfeus/lambda-packs path: /pytorch/source/caffe2/contrib/playground/resnetdemo/caffe2_resnet50_default_param_update.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
def gen_param_update_builde... | code_fim | hard | {
"lang": "python",
"repo": "ryfeus/lambda-packs",
"path": "/pytorch/source/caffe2/contrib/playground/resnetdemo/caffe2_resnet50_default_param_update.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Update param_grad and param_momentum in place
model.net.MomentumSGDUpdate(
[param_grad, param_momentum, LR, param],
[param_grad, param_momentum, param],
momentum=0.9,
nesterov=1
... | code_fim | hard | {
"lang": "python",
"repo": "ryfeus/lambda-packs",
"path": "/pytorch/source/caffe2/contrib/playground/resnetdemo/caffe2_resnet50_default_param_update.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmiller8/eemeter path: /eemeter/meter/helpers.py
from .base import MeterBase
from eemeter.consumption import Consumption
from eemeter.consumption import ConsumptionHistory
from itertools import chain
from pprint import pprint
try:
unicode = unicode
except NameError:
# 'unicode' is unde... | code_fim | hard | {
"lang": "python",
"repo": "cmiller8/eemeter",
"path": "/eemeter/meter/helpers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
consumption_history : eemeter.consumption.ConsumptionHistory
Meter readings to consolidate.
Returns
-------
out : dict
Contains the consolidated consumption history keyed by the string
"consumption_h... | code_fim | hard | {
"lang": "python",
"repo": "cmiller8/eemeter",
"path": "/eemeter/meter/helpers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
-------
out : dict
Contains the consolidated consumption history keyed by the string
"consumption_history_no_estimated".
"""
def combine_waitlist(wl):
usage = sum([c.to("kWh") for c in wl])
ft = wl[0].fuel_type... | code_fim | hard | {
"lang": "python",
"repo": "cmiller8/eemeter",
"path": "/eemeter/meter/helpers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Dioclesiano/Estudos_sobre_Python path: /Exercícios/ex062a - Criando PA com While.py
# Melhore o DESAFIO 061, perguntando para o usuário se ele quer mostrar mais alguns termos.
# O programa encerra quando ele disser que não quer mostrar o termo.
<|fim_suffix|>while acrescimo != 0:
total += ac... | code_fim | medium | {
"lang": "python",
"repo": "Dioclesiano/Estudos_sobre_Python",
"path": "/Exercícios/ex062a - Criando PA com While.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Pausa')
acrescimo = int(input('Digite [0] para sair ou o valor que deseja acrescentar nos termos da PA » '))<|fim_prefix|># repo: Dioclesiano/Estudos_sobre_Python path: /Exercícios/ex062a - Criando PA com While.py
# Melhore o DESAFIO 061, perguntando para o usuário se ele quer mostrar mai... | code_fim | hard | {
"lang": "python",
"repo": "Dioclesiano/Estudos_sobre_Python",
"path": "/Exercícios/ex062a - Criando PA com While.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmggh/jwst path: /jwst/dq_init/dq_init_step.py
#! /usr/bin/env python
from ..stpipe import Step
from .. import datamodels
from . import dq_initialization
class DQInitStep(Step):
"""
DQInitStep: Initialize the Data Quality extension from the
mask reference file. Also initialize th... | code_fim | hard | {
"lang": "python",
"repo": "dmggh/jwst",
"path": "/jwst/dq_init/dq_init_step.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Check for a valid reference file
if self.mask_filename == 'N/A':
self.log.warning('No MASK reference file found')
self.log.warning('DQ initialization step will be skipped')
result = input_model.copy()
result.meta.cal... | code_fim | hard | {
"lang": "python",
"repo": "dmggh/jwst",
"path": "/jwst/dq_init/dq_init_step.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Retreive the mask reference file name
self.mask_filename = self.get_reference_file(input_model, 'mask')
self.log.info('Using MASK reference file %s', self.mask_filename)
# Check for a valid reference file
if self.mask_filename == 'N/A':
... | code_fim | hard | {
"lang": "python",
"repo": "dmggh/jwst",
"path": "/jwst/dq_init/dq_init_step.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SteveGeyer/Firefly path: /src/experiments/pid.py
"""Basic PID algorithm.
This algorithm is based on:
http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/
Any errors in the implementation are mine.
"""
__author__ = "Steve Geyer"
__copyright__ = "Copyright 2019, St... | code_fim | hard | {
"lang": "python",
"repo": "SteveGeyer/Firefly",
"path": "/src/experiments/pid.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Calculate time change. Return last output if no change.
time_change = now - self.last_time
if time_change <= 0:
return self.output
# Get and update constants.
kp = self.kp
ki = self.ki * time_change
kd = self.kd / time_change
... | code_fim | hard | {
"lang": "python",
"repo": "SteveGeyer/Firefly",
"path": "/src/experiments/pid.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get and update constants.
kp = self.kp
ki = self.ki * time_change
kd = self.kd / time_change
# Compute all the working error variables.
input_error = self.set_point - input_value
d_input = input_value - self.last_input
# Remember state fo... | code_fim | hard | {
"lang": "python",
"repo": "SteveGeyer/Firefly",
"path": "/src/experiments/pid.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@click.group()
@click.option('--profile', '-p', default='Main Profile',
help='Which Outlook profile to operate on')
@click.pass_context
def cli(ctx, profile):
ctx.obj = Profile(profile)
@cli.command()
@click.argument('file', type=click.File(mode='wb'))
@click.pass_obj
def export(profil... | code_fim | hard | {
"lang": "python",
"repo": "tresni/Office-Signature-Smuggler",
"path": "/sigsmuggle.py",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tresni/Office-Signature-Smuggler path: /sigsmuggle.py
#! /usr/bin/env python3
#
# Copyright (C) 2017 Brian Hartvigsen
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this p... | code_fim | hard | {
"lang": "python",
"repo": "tresni/Office-Signature-Smuggler",
"path": "/sigsmuggle.py",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jakelever/biowordlists path: /scripts/resolveConflicts.py
import argparse
from collections import defaultdict
def main():
parser = argparse.ArgumentParser(description='')
parser.add_argument('--wordlist',required=True,type=str,help='Wordlist to help resolve conflicts')
parser.add_argument('--... | code_fim | hard | {
"lang": "python",
"repo": "jakelever/biowordlists",
"path": "/scripts/resolveConflicts.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(identifiers) > 1:
for identifier in identifiers:
outData = [ identifier, main_terms[identifier], ct ]
outF.write("\t".join(outData) + "\n")
print("Done")
if __name__ == '__main__':
main()<|fim_prefix|># repo: jakelever/biowordlists path: /scripts/resolveConflicts.py
import... | code_fim | hard | {
"lang": "python",
"repo": "jakelever/biowordlists",
"path": "/scripts/resolveConflicts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.