text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> results = joblib.Parallel(n_jobs=-1, verbose=2)(tasks)
for artifact_id, opt in results:
if isinstance(opt, Exception):
logger.error(opt)
logger.error("error happened during the optimizing of q,"
" keep the current value; q[{}] = {}"
... | code_fim | hard | {
"lang": "python",
"repo": "FairyDevicesRD/statistical-quality-estimation",
"path": "/optimize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@given(u'Percona Mysql operator is running')
def install(context):
operator = PerconaMysqlOperator()
operator.operator_namespace = context.namespace.name
if not operator.is_running():
subscription = f'''
---
apiVersion: operators.coreos.com/v1
kind: OperatorGroup
metadata:
name: oper... | code_fim | hard | {
"lang": "python",
"repo": "redhat-developer/service-binding-operator",
"path": "/test/acceptance/features/steps/percona_mysql_operator.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: redhat-developer/service-binding-operator path: /test/acceptance/features/steps/percona_mysql_operator.py
from olm import Operator
from environment import ctx
from behave import given
class PerconaMysqlOperator(Operator):
def __init__(self, name="percona-xtradb-cluster-operator"):
<|fim_su... | code_fim | hard | {
"lang": "python",
"repo": "redhat-developer/service-binding-operator",
"path": "/test/acceptance/features/steps/percona_mysql_operator.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, model):
self.name = model['name']
self.gauge_file = model['gauges']
self.catalog = model['catalog']
def get_array_size():
"""
Defines the size of the array based on the number of tide gauges tracked and the number of subfaults
Returns
... | code_fim | medium | {
"lang": "python",
"repo": "cjeffr/meow-tsunami",
"path": "/calc_tsunami.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cjeffr/meow-tsunami path: /calc_tsunami.py
"""
This code takes the un-altered green's functions and slip, multiplies each slip value to the
appropriate subfault number to get the correct amount of slip per subfault and then sums each
waveform for each site (gauge location) and passes one array ra... | code_fim | hard | {
"lang": "python",
"repo": "cjeffr/meow-tsunami",
"path": "/calc_tsunami.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters
----------
slip_result: The slip array obtained from RabbitMQ for each model
Returns:
-------
waveheight_per_site: the new tGF array for each location
time array: time array
"""
gf = h5py.File('NA_CAS.hdf5', 'r')
time_array = np.array(gf['time/timedata'... | code_fim | hard | {
"lang": "python",
"repo": "cjeffr/meow-tsunami",
"path": "/calc_tsunami.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># import argparse
#
# ap = argparse.ArgumentParser()
# ap.add_argument("-d","--dataset", help="Path to dataset to enroll", required=True)
# ap.add_argument("-e","--embeddings", help="Path to save embeddings",
# default="face_embeddings.npy")
# ap.add_argument("-l","--labe... | code_fim | medium | {
"lang": "python",
"repo": "HrBbCi/MobieFace",
"path": "/example/enroll.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: HrBbCi/MobieFace path: /example/enroll.py
#from extractors import extract_face_embeddings
#from detectors import detect_faces
import extractors as extc
import detectors as dt
from db import add_embeddings
import dlib
import cv2
import glob
shape_predictor = dlib.shape_predictor("models/shape_pr... | code_fim | hard | {
"lang": "python",
"repo": "HrBbCi/MobieFace",
"path": "/example/enroll.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sascha0912/MAP_Elites path: /src/nicheCompete.py
import numpy as np
import pandas as pd
def nicheCompete(map,fitness,behaviour):
mapIsTuple = isinstance(map, tuple)
# Get bin of each individual based on behaviour
nDims = np.shape(behaviour)[0]
# Because map is no tuple in first it... | code_fim | hard | {
"lang": "python",
"repo": "Sascha0912/MAP_Elites",
"path": "/src/nicheCompete.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> indxSortOne = list(sortedByFeatureAndFitness.index.values)
df_drop_dupl = sortedByFeatureAndFitness.drop_duplicates(subset=[0,1])
indxSortTwo = list(df_drop_dupl.index.values)
bestIndex = indxSortTwo
bestBin = pd.DataFrame(data=df_bin1[bestIndex])
# Because map is no tuple in firs... | code_fim | medium | {
"lang": "python",
"repo": "Sascha0912/MAP_Elites",
"path": "/src/nicheCompete.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nphaterp/pytweet path: /tests/test_visualize_sentiments.py
import pandas as pd
from pytweet.pytweet import tweet_sentiment_analysis, visualize_sentiment
from pytest import raises
def test_visualize_sentiments():
"""
Tests the visualize_sentiments function to make sure the outputs are co... | code_fim | hard | {
"lang": "python",
"repo": "nphaterp/pytweet",
"path": "/tests/test_visualize_sentiments.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # standard bar chart checks
standard_plot = visualize_sentiment(sentiment)
assert str(type(standard_plot)) == "<class 'altair.vegalite.v4.api.Chart'>"
assert standard_plot.encoding.x.shorthand == 'frequency', 'x_axis should be mapped to the x_axis'
assert standard_plot.encoding.y.short... | code_fim | hard | {
"lang": "python",
"repo": "nphaterp/pytweet",
"path": "/tests/test_visualize_sentiments.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> draws = pd.read_csv(file_name, skiprows=2, usecols=[1,2,3,4,5,6,7], names=['1','2','3','4','5','6','7'], sep = '\t')
return draws
downloader = DataDownloader(2017)
downloader.download_data()<|fim_prefix|># repo: javabean68/alaricus path: /code/Euromillions/download.py
import urllib.... | code_fim | hard | {
"lang": "python",
"repo": "javabean68/alaricus",
"path": "/code/Euromillions/download.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: javabean68/alaricus path: /code/Euromillions/download.py
import urllib.request
import pandas as pd
class DataDownloader(object):
def __init__(self, data):
self.data = data
def download_data(self):
<|fim_suffix|> print(file_name)
... | code_fim | hard | {
"lang": "python",
"repo": "javabean68/alaricus",
"path": "/code/Euromillions/download.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>slack_client = SlackClient(SLACK_OAUTH_ACCESS_TOKEN)
ch = slack_client.api_call("channels.list")['channels']
for c in ch:
print(f'{c["name"]} -> id: {c["id"]}')
"""
SLACK_CHANNEL = 'Your Channel ID'<|fim_prefix|># repo: thinkAmi/DjangoCongress_JP_2019_talk path: /src/myproject/settings/slack.py
from ... | code_fim | medium | {
"lang": "python",
"repo": "thinkAmi/DjangoCongress_JP_2019_talk",
"path": "/src/myproject/settings/slack.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thinkAmi/DjangoCongress_JP_2019_talk path: /src/myproject/settings/slack.py
from .base import *
EMAIL_BACKEND = 'myapp.email_backends.SlackBackend'
<|fim_suffix|>slack_client = SlackClient(SLACK_OAUTH_ACCESS_TOKEN)
ch = slack_client.api_call("channels.list")['channels']
for c in ch:
print(... | code_fim | hard | {
"lang": "python",
"repo": "thinkAmi/DjangoCongress_JP_2019_talk",
"path": "/src/myproject/settings/slack.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>from pyomo.opt.base.error import ConverterError
from pyomo.opt.base.convert import convert_problem
from pyomo.opt.base.solvers import (
UnknownSolver, SolverFactory, check_available_solvers, OptSolver,
)
from pyomo.opt.base.results import ReaderFactory, AbstractResultsReader
from pyomo.opt.base.proble... | code_fim | medium | {
"lang": "python",
"repo": "flexciton/pyomo",
"path": "/pyomo/opt/base/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flexciton/pyomo path: /pyomo/opt/base/__init__.py
# ___________________________________________________________________________
#
# Pyomo: Python Optimization Modeling Objects
# Copyright 2017 National Technology and Engineering Solutions of Sandia, LLC
# Under the terms of Contract DE-NA0003... | code_fim | medium | {
"lang": "python",
"repo": "flexciton/pyomo",
"path": "/pyomo/opt/base/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zsqrq/Co-Correcting path: /BasicTrainer.py
import os
import copy
import json
import datetime
import numpy as np
from os.path import join
import torch
import torchvision
from dataset.cifar import CIFAR10, CIFAR100
from dataset.mnist import MNIST
from dataset.ISIC import ISIC
from dataset.clothi... | code_fim | hard | {
"lang": "python",
"repo": "zsqrq/Co-Correcting",
"path": "/BasicTrainer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return trainset, testset, valset
def _get_dataset_mnist(self):
transform1 = torchvision.transforms.Compose([
torchvision.transforms.RandomPerspective(),
torchvision.transforms.ColorJitter(0.2, 0.75, 0.25, 0.04),
torchvision.transforms.ToTensor(),
... | code_fim | hard | {
"lang": "python",
"repo": "zsqrq/Co-Correcting",
"path": "/BasicTrainer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vayw/pingadmin2slack path: /slackwebhook.py
#!/usr/bin/env python3
import json
import urllib.request
class slackWebHook:
def __init__(self, url="", name="pybot", icon = "", channel = ""):
<|fim_suffix|> def send(self, payload='', attachment=''):
"""
Send payload to slack... | code_fim | medium | {
"lang": "python",
"repo": "vayw/pingadmin2slack",
"path": "/slackwebhook.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def send(self, payload='', attachment=''):
"""
Send payload to slack API
"""
msg = {'username': self.name, "channel": self.channel, "icon_emoji": self.icon}
if attachment and type(attachment) is list:
msg['attachments'] = attachment
else:
... | code_fim | medium | {
"lang": "python",
"repo": "vayw/pingadmin2slack",
"path": "/slackwebhook.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Send payload to slack API
"""
msg = {'username': self.name, "channel": self.channel, "icon_emoji": self.icon}
if attachment and type(attachment) is list:
msg['attachments'] = attachment
else:
msg['text'] = payload
params... | code_fim | medium | {
"lang": "python",
"repo": "vayw/pingadmin2slack",
"path": "/slackwebhook.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def myFunc3(a):
a[0] += 1
print 'in myFunc: a[0] = %d' % a[0]
b = {0:1,1:2}
print b
myFunc3(b) #here b is passed as reference, so change to its elements is persitent
print b<|fim_prefix|># repo: qiuyuguo/bioinfo_toolbox path: /sandbox/python/PM599/QB3.4.1/scope.py
def myFunc(a):
a += 1
pr... | code_fim | medium | {
"lang": "python",
"repo": "qiuyuguo/bioinfo_toolbox",
"path": "/sandbox/python/PM599/QB3.4.1/scope.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qiuyuguo/bioinfo_toolbox path: /sandbox/python/PM599/QB3.4.1/scope.py
def myFunc(a):
a += 1
print 'in myFunc: a = %d' % a
b = 1
print b
myFunc(b)
print b
<|fim_suffix|>def myFunc3(a):
a[0] += 1
print 'in myFunc: a[0] = %d' % a[0]
b = {0:1,1:2}
print b
myFunc3(b) #here b is passed... | code_fim | medium | {
"lang": "python",
"repo": "qiuyuguo/bioinfo_toolbox",
"path": "/sandbox/python/PM599/QB3.4.1/scope.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
algorithms,
data,
target_metric,
baseline_loss,
temporary_directory,
time_limit=None,
max_evals=DEFAULT_MAX_EVALS,
hpo_algo=DEFAULT_HPO_ALGO,
debug=False,
):
self.algorithms = algorithms
self.data = d... | code_fim | medium | {
"lang": "python",
"repo": "thededlier/Auto-Surprise-1",
"path": "/auto_surprise/strategies/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: thededlier/Auto-Surprise-1 path: /auto_surprise/strategies/base.py
from auto_surprise.constants import DEFAULT_MAX_EVALS, DEFAULT_HPO_ALGO
class StrategyBase():
<|fim_suffix|> self,
algorithms,
data,
target_metric,
baseline_loss,
temporary_directory... | code_fim | medium | {
"lang": "python",
"repo": "thededlier/Auto-Surprise-1",
"path": "/auto_surprise/strategies/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jettify/sklearn-onnx path: /skl2onnx/shape_calculators/Concat.py
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.... | code_fim | medium | {
"lang": "python",
"repo": "jettify/sklearn-onnx",
"path": "/skl2onnx/shape_calculators/Concat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def calculate_sklearn_concat(operator):
check_input_and_output_numbers(operator, output_count_range=1)
N = operator.inputs[0].type.shape[0]
operator.outputs[0].type.shape = [N, 'None']
register_shape_calculator('SklearnConcat', calculate_sklearn_concat)
register_shape_calculator('SklearnGen... | code_fim | medium | {
"lang": "python",
"repo": "jettify/sklearn-onnx",
"path": "/skl2onnx/shape_calculators/Concat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # New array:
Clustersdata = []
result = []
deletearray = []
#Merging similar clusters (plant locations):
for k,v in deldict.items():
if len(v) > 0:
for i in v:
ClustersArray[k].updateCluster(ClustersArray[i])
Clustersdata.append(ClustersArray[k])
if index[k] == 1:
Clust... | code_fim | hard | {
"lang": "python",
"repo": "gaybro8777/ERCOTTestSystem",
"path": "/ERCOTGridComponent/SyntheticBusConstructionMethod/ClusteringAlgorithm/data2html.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gaybro8777/ERCOTTestSystem path: /ERCOTGridComponent/SyntheticBusConstructionMethod/ClusteringAlgorithm/data2html.py
import numpy as np
class Map(object):
def __init__(self, gentypes):
#gentypes is not being used now
from utils import BeginningOfString, EndOfString, colormapbygen
se... | code_fim | hard | {
"lang": "python",
"repo": "gaybro8777/ERCOTTestSystem",
"path": "/ERCOTGridComponent/SyntheticBusConstructionMethod/ClusteringAlgorithm/data2html.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fake_imgs = self.gen(self.z)
fake_validity = self.dis(fake_imgs)
g_loss = -torch.mean(fake_validity)
g_loss.backward()
self.optimizer_G.step()
# gen_cost.append(g_loss.item())
... | code_fim | hard | {
"lang": "python",
"repo": "mianasbat/mood",
"path": "/example_algos/algorithms/f_ano_gan.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mianasbat/mood path: /example_algos/algorithms/f_ano_gan.py
f"Train Epoch: {epoch} [{i}/{len(train_loader)} "
f" ({100.0 * i / len(train_loader):.0f}%)] Dis: "
f"{d_loss.item() / batch_size_curr:.6f} vs Gen: "
... | code_fim | hard | {
"lang": "python",
"repo": "mianasbat/mood",
"path": "/example_algos/algorithms/f_ano_gan.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fake_data = fake_data.view(batch_size, n_image_channels, dim, dim)
interpolates = alpha * real_data.detach() + ((1 - alpha) * fake_data.detach())
interpolates = interpolates.to(device)
interpolates.requires_grad_(True)
disc_interpolates = netD(interpolates)
... | code_fim | hard | {
"lang": "python",
"repo": "mianasbat/mood",
"path": "/example_algos/algorithms/f_ano_gan.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MatveevKirill/mysql-logs-testing path: /logparser/pyparser.py
import re
class LogParser(object):
logs: list = []
def __init__(self, log_file: str) -> None:
self.logs.clear()
with open(log_file, 'rt') as f:
for log_line in f.readlines():
patt... | code_fim | hard | {
"lang": "python",
"repo": "MatveevKirill/mysql-logs-testing",
"path": "/logparser/pyparser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def top_frequent_requests(self, count_queries: int = 10) -> dict:
count_queries_dict = {}
for log in self.logs:
if log['url'] not in count_queries_dict:
count_queries_dict[log['url']] = 1
else:
count_queries_dict[log['url']] += 1... | code_fim | hard | {
"lang": "python",
"repo": "MatveevKirill/mysql-logs-testing",
"path": "/logparser/pyparser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>f.write("\n")
for i in range(len(n)):
f.write(str(n[i])+"\t")
for j in range(6):
f.write(str(round(RESULTS[j][i], 4))+"\t")
f.write("\n")
f.close()
fig, ax = plt.subplots(figsize=(12, 8))
for i in range(6):
# print(RESULTS[i])
# print(n)
ax.plot(n, RESULTS[i], label=saturation[i... | code_fim | hard | {
"lang": "python",
"repo": "zuzg/algorithms-data-structures",
"path": "/4-backtracking-algorithms/EC_chart.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zuzg/algorithms-data-structures path: /4-backtracking-algorithms/EC_chart.py
import matplotlib.pyplot as plt
import numpy as np
import random
saturation = [0.2, 0.3, 0.4, 0.6, 0.8, 0.95]
n = [10, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000]
def read_data(filename):
data = []
f = open(... | code_fim | hard | {
"lang": "python",
"repo": "zuzg/algorithms-data-structures",
"path": "/4-backtracking-algorithms/EC_chart.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> title = soup.find('title')
print(str(title)[7: len(title)-9])<|fim_prefix|># repo: Sadamingh/Beautifulsoup-Practice path: /Challenge-01/get_title.py
from bs4 import BeautifulSoup
<|fim_middle|>with open('index.html') as f:
text = f.read()
soup = BeautifulSoup(text, 'html.parser')
| code_fim | medium | {
"lang": "python",
"repo": "Sadamingh/Beautifulsoup-Practice",
"path": "/Challenge-01/get_title.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sadamingh/Beautifulsoup-Practice path: /Challenge-01/get_title.py
from bs4 import BeautifulSoup
with open('index.html') as f:
text = f.read()
soup = BeautifulSoup(text, 'html.parser')
<|fim_suffix|>print(str(title)[7: len(title)-9])<|fim_middle|> title = soup.find('title')
| code_fim | easy | {
"lang": "python",
"repo": "Sadamingh/Beautifulsoup-Practice",
"path": "/Challenge-01/get_title.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 18F/State-TalentMAP-API path: /talentmap_api/bidding/tests/mommy_recipes.py
from model_mommy import mommy
from talentmap_api.bidding.models import BidCycle
<|fim_suffix|> # Make a bidcycle with proper datetimes for TZ comparison
return mommy.make(BidCycle,
cycle_en... | code_fim | easy | {
"lang": "python",
"repo": "18F/State-TalentMAP-API",
"path": "/talentmap_api/bidding/tests/mommy_recipes.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Make a bidcycle with proper datetimes for TZ comparison
return mommy.make(BidCycle,
cycle_end_date="2000-01-01T00:00:00+00:00",
cycle_deadline_date="1999-01-01T00:00:00+00:00",
cycle_start_date="1998-01-01T00:00:00+00:00")<|fim_pr... | code_fim | easy | {
"lang": "python",
"repo": "18F/State-TalentMAP-API",
"path": "/talentmap_api/bidding/tests/mommy_recipes.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with pytest.raises(ValueError) as ex_info:
sanitize_input('INVALID', '2020-06-06')
assert str(ex_info.value) == 'Incorrect data format, should be YYYY-MM-DD'
def test_sanitize_input_bad_end_dt(self) -> None:
with pytest.raises(ValueError) as ex_info:
... | code_fim | hard | {
"lang": "python",
"repo": "bonchae/pybaseball",
"path": "/tests/pybaseball/test_statcast.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bonchae/pybaseball path: /tests/pybaseball/test_statcast.py
from datetime import timedelta, date, datetime
from typing import Callable
import pandas as pd
import pytest
import requests
from pybaseball.statcast import (_SC_SINGLE_GAME_REQUEST, _SC_SMALL_REQUEST, sanitize_input, statcast,
... | code_fim | hard | {
"lang": "python",
"repo": "bonchae/pybaseball",
"path": "/tests/pybaseball/test_statcast.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> start_dt, end_dt = sanitize_input(str(yesterday), None)
assert start_dt == yesterday
assert end_dt == yesterday
def test_sanitize_input(self) -> None:
start_dt, end_dt = sanitize_input('2020-05-06', '2020-06-06')
assert start_dt == datetime.strptime('... | code_fim | hard | {
"lang": "python",
"repo": "bonchae/pybaseball",
"path": "/tests/pybaseball/test_statcast.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not root:
return []
ret = [str(root.val)]
ret.extend(Common.__pre_order(root.left))
ret.extend(Common.__pre_order(root.right))
return ret<|fim_prefix|># repo: faisaldialpad/hellouniverse path: /Python/tests/trees/common.py
class Common:
@staticme... | code_fim | hard | {
"lang": "python",
"repo": "faisaldialpad/hellouniverse",
"path": "/Python/tests/trees/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: faisaldialpad/hellouniverse path: /Python/tests/trees/common.py
class Common:
@staticmethod
def serialize(root):
"""
:type root: TreeNode
:rtype: string
"""
pre_order = Common.__pre_order(root)
pre_order.append('#') # separator
pre_... | code_fim | hard | {
"lang": "python",
"repo": "faisaldialpad/hellouniverse",
"path": "/Python/tests/trees/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if version is None:
import versioneer
version = versioneer.get_version()
cmdclass = versioneer.get_cmdclass()
setup(
name=__packagename__,
version=version,
description=__description__,
long_description=__longdesc__,
author=__author__... | code_fim | hard | {
"lang": "python",
"repo": "utooley/niworkflows",
"path": "/setup.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: utooley/niworkflows path: /setup.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author: oesteban
# @Date: 2015-11-19 16:44:27
# @Last Modified by: oesteban
""" niworkflows setup script """
def main():
""" Install entry-point """
from os import path as op
from inspect import... | code_fim | hard | {
"lang": "python",
"repo": "utooley/niworkflows",
"path": "/setup.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> setup(
name=__packagename__,
version=version,
description=__description__,
long_description=__longdesc__,
author=__author__,
author_email=__email__,
maintainer=__maintainer__,
maintainer_email=__email__,
license=__license__,
... | code_fim | hard | {
"lang": "python",
"repo": "utooley/niworkflows",
"path": "/setup.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: balcortex/advent_of_code_2020 path: /day_10.py
from typing import List
from functools import lru_cache
TXT = """16
10
15
5
1
11
7
19
6
12
4"""
def distribution(s: str) -> int:
inps = sorted(list(map(int, s.split("\n"))))
dif1 = [(a, b) for a, b in zip(inps[:], inps[1:]) if b - a == 1]
... | code_fim | hard | {
"lang": "python",
"repo": "balcortex/advent_of_code_2020",
"path": "/day_10.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open("day_10_input.txt") as f:
txt = f.read()
dif1, dif3 = distribution(txt)
print(dif1 * dif3)
# Part 2
@lru_cache(maxsize=1000)
def count_paths(lst: List[int], num: int) -> int:
if num == 0:
return 1
if num not in lst:
return 0
if num == 1:
retur... | code_fim | medium | {
"lang": "python",
"repo": "balcortex/advent_of_code_2020",
"path": "/day_10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>with open("day_10_input.txt") as f:
txt = f.read()
num = max(list(map(int, txt.split("\n"))))
print(count_paths(tuple(map(int, txt.split("\n"))), num))<|fim_prefix|># repo: balcortex/advent_of_code_2020 path: /day_10.py
from typing import List
from functools import lru_cache
TXT = """16
10
1... | code_fim | hard | {
"lang": "python",
"repo": "balcortex/advent_of_code_2020",
"path": "/day_10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def reset(self):
self._deltas = []
def __call__(self, timestep):
now = time.time()
delta = now - self._last if self._last is not None else 0.0
self._last = now
self._deltas.append(delta)
return delta
def result(self):
return np.array(se... | code_fim | medium | {
"lang": "python",
"repo": "jmribeiro/yaaf",
"path": "/yaaf/evaluation/SecondsPerTimestepMetric.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jmribeiro/yaaf path: /yaaf/evaluation/SecondsPerTimestepMetric.py
import time
import numpy as np
from yaaf.evaluation import Metric
class SecondsPerTimestepMetric(Metric):
def __init__(self):
super(SecondsPerTimestepMetric, self).__init__(f"Seconds Per Timestep")
self._de... | code_fim | medium | {
"lang": "python",
"repo": "jmribeiro/yaaf",
"path": "/yaaf/evaluation/SecondsPerTimestepMetric.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: goodgodth/Automation-scripts path: /cardekho_scraper/cardekho_dynamic_data_scraping.py
'''
Import the necessary libraries
'''
# !pip install selenium
from selenium import webdriver
import time
import pandas as pd
from bs4 import BeautifulSoup as soup
'''
Define the browser/driver and open the de... | code_fim | hard | {
"lang": "python",
"repo": "goodgodth/Automation-scripts",
"path": "/cardekho_scraper/cardekho_dynamic_data_scraping.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>n(f) != 0:
mileages.append(f[0].text)
else:
mileages.append(" ")
e = m[0].findAll("span", {"title": "Engine Displacement"})
if len(e) != 0:
engines.append(e[0].text)
else:
engines.append(" ")
df = pd.DataFrame(
{
'Car Name': cars,
'Price'... | code_fim | hard | {
"lang": "python",
"repo": "goodgodth/Automation-scripts",
"path": "/cardekho_scraper/cardekho_dynamic_data_scraping.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kyvinh/home-assistant path: /homeassistant/components/api_ai.py
"""
API.AI webhook implementation for Home Assistant.
Inspired from API component.
"""
import asyncio
import json
import logging
from homeassistant.components.http import HomeAssistantView
from homeassistant.const import (
ATTR... | code_fim | hard | {
"lang": "python",
"repo": "kyvinh/home-assistant",
"path": "/homeassistant/components/api_ai.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif action == 'scene.activate':
_LOGGER.info('Activating scene: %s', scene_to_activate)
if scene_to_activate:
result['speech'] = "Activating scene: {}".format(scene_to_activate)
with AsyncTrackStates(hass) as changed_states:
... | code_fim | hard | {
"lang": "python",
"repo": "kyvinh/home-assistant",
"path": "/homeassistant/components/api_ai.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> yield from hass.services.async_call('input_select', 'select_option', {ATTR_ENTITY_ID: 'input_select.projector_source', ATTR_OPTION: scene_to_activate}, True)
elif action == 'scene.activate':
_LOGGER.info('Activating scene: %s', scene_to_activate)
if scene_to_ac... | code_fim | hard | {
"lang": "python",
"repo": "kyvinh/home-assistant",
"path": "/homeassistant/components/api_ai.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>clf = SVC(random_state=0).fit(X_train, y_train)
plot_det_curve(clf, X_test, y_test) # doctest: +SKIP
# <...>
plt.show()<|fim_prefix|># repo: hercules261188/scikit-learn.github.io path: /1.0/modules/generated/sklearn-metrics-plot_det_curve-1.py
import matplotlib.pyplot as plt
from sklearn.datasets import... | code_fim | medium | {
"lang": "python",
"repo": "hercules261188/scikit-learn.github.io",
"path": "/1.0/modules/generated/sklearn-metrics-plot_det_curve-1.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hercules261188/scikit-learn.github.io path: /1.0/modules/generated/sklearn-metrics-plot_det_curve-1.py
import matplotlib.pyplot as plt
from sklearn.datasets import make_classification
from sklearn.metrics import plot_det_c<|fim_suffix|>clf = SVC(random_state=0).fit(X_train, y_train)
plot_det_curv... | code_fim | hard | {
"lang": "python",
"repo": "hercules261188/scikit-learn.github.io",
"path": "/1.0/modules/generated/sklearn-metrics-plot_det_curve-1.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>es=1000, random_state=0)
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.4, random_state=0)
clf = SVC(random_state=0).fit(X_train, y_train)
plot_det_curve(clf, X_test, y_test) # doctest: +SKIP
# <...>
plt.show()<|fim_prefix|># repo: hercules261188/scikit-learn.github.io path: ... | code_fim | medium | {
"lang": "python",
"repo": "hercules261188/scikit-learn.github.io",
"path": "/1.0/modules/generated/sklearn-metrics-plot_det_curve-1.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> import *
from .simple_models import *<|fim_prefix|># repo: sflippl/patches path: /patches/datasets/pilgrimm/test/__init__.py
"""Tests patches.pilgrimm.
"""
from .<|fim_middle|>layers import *
from .messages import *
from .pilgrimm import *
from .shapes | code_fim | medium | {
"lang": "python",
"repo": "sflippl/patches",
"path": "/patches/datasets/pilgrimm/test/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sflippl/patches path: /patches/datasets/pilgrimm/test/__init__.py
"""Tests patches.pilgrimm.
"""
from .<|fim_suffix|>*
from .pilgrimm import *
from .shapes import *
from .simple_models import *<|fim_middle|>layers import *
from .messages import | code_fim | easy | {
"lang": "python",
"repo": "sflippl/patches",
"path": "/patches/datasets/pilgrimm/test/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return top
if __name__ == '__main__':
print(get_top('sample.csv', 10))<|fim_prefix|># repo: whisk/snippets path: /py/formats/parse-csv.py
import csv
def get_top(fname, threshold=0):
<|fim_middle|> top = [None, -1]
with open(fname) as csv_file:
for row in csv.reader(csv_file):
try:
... | code_fim | hard | {
"lang": "python",
"repo": "whisk/snippets",
"path": "/py/formats/parse-csv.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whisk/snippets path: /py/formats/parse-csv.py
import csv
def get_top(fname, threshold=0):
<|fim_suffix|>if __name__ == '__main__':
print(get_top('sample.csv', 10))<|fim_middle|> top = [None, -1]
with open(fname) as csv_file:
for row in csv.reader(csv_file):
try:
if int(row... | code_fim | hard | {
"lang": "python",
"repo": "whisk/snippets",
"path": "/py/formats/parse-csv.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: whisk/snippets path: /py/formats/parse-csv.py
import csv
def get_top(fname, threshold=0):
top = [None, -1]
with open(fname) as csv_file:
for row in csv.reader(csv_file):
try:
if int(row[1]) >= threshold and top[1] <= int(row[2]):
top = [row[0], int(row[2])]
... | code_fim | easy | {
"lang": "python",
"repo": "whisk/snippets",
"path": "/py/formats/parse-csv.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> mu_star_candidate = test_pts[np.argmin(means)]
mean_mu_star_candidate = np.min(means)
start_pts = select_startpts_BFGS(list_sampled_points, mu_star_candidate, num_multistart, problem)
with Parallel(n_jobs=num_threads) as parallel:
parallel_results = parallel(de... | code_fim | hard | {
"lang": "python",
"repo": "chongkewu/NIPS2017",
"path": "/run_misoKG.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chongkewu/NIPS2017 path: /run_misoKG.py
from operator import itemgetter
from multifidelity_KG.misokg_utils import sample_initial_data, process_parallel_results, select_startpts_BFGS
from multifidelity_KG.model.hyperparameter_optimization_with_noise import optimize_hyperparameters, \
create_... | code_fim | hard | {
"lang": "python",
"repo": "chongkewu/NIPS2017",
"path": "/run_misoKG.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chongkewu/NIPS2017 path: /run_misoKG.py
b import Parallel, delayed
import sys
from operator import itemgetter
from multifidelity_KG.misokg_utils import sample_initial_data, process_parallel_results, select_startpts_BFGS
from multifidelity_KG.model.hyperparameter_optimization_with_noise import op... | code_fim | hard | {
"lang": "python",
"repo": "chongkewu/NIPS2017",
"path": "/run_misoKG.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Test parsing BSC_open.
:param pymobiledevice3.lockdown.LockdownClient lockdown: Lockdown client.
"""
events = [
Container({
'timestamp': 458577723780, 'args': Container(
data=(b'\x88\x95\xd7m\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0... | code_fim | hard | {
"lang": "python",
"repo": "charmingLitteDeveloper/pymobiledevice3",
"path": "/tests/services/instruments/test_kdebug_event_parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = KdebugEventsParser(trace_codes_map)
for event in events:
parser.feed(event)
bsc_open = parser.fetch()
assert bsc_open.path == '/System/Library/CoreServices/SpringBoard.app/SpringBoard'
assert bsc_open.ktraces == events
assert bsc_open.flags == [BscOpenFlags.O_RDONL... | code_fim | hard | {
"lang": "python",
"repo": "charmingLitteDeveloper/pymobiledevice3",
"path": "/tests/services/instruments/test_kdebug_event_parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: charmingLitteDeveloper/pymobiledevice3 path: /tests/services/instruments/test_kdebug_event_parser.py
from construct import Container, ListContainer
from pymobiledevice3.services.dvt.instruments.kdebug_events_parser import KdebugEventsParser, BscOpenFlags
from pymobiledevice3.services.dvt.instrum... | code_fim | hard | {
"lang": "python",
"repo": "charmingLitteDeveloper/pymobiledevice3",
"path": "/tests/services/instruments/test_kdebug_event_parser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GateauXD/Open-Menu path: /temp.py
import cv2
import numpy as np
import os
img = cv2.imread('Images/grayscale.jpg')
median = cv2.medianBlur(img, 3)
<|fim_suffix|>cv2.imwrite('test.jpg', compare)<|fim_middle|>compare = np.concatenate((img, median), axis=1)
| code_fim | easy | {
"lang": "python",
"repo": "GateauXD/Open-Menu",
"path": "/temp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>cv2.imwrite('test.jpg', compare)<|fim_prefix|># repo: GateauXD/Open-Menu path: /temp.py
import cv2
import numpy as np
import os
<|fim_middle|>img = cv2.imread('Images/grayscale.jpg')
median = cv2.medianBlur(img, 3)
compare = np.concatenate((img, median), axis=1)
| code_fim | medium | {
"lang": "python",
"repo": "GateauXD/Open-Menu",
"path": "/temp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>compare = np.concatenate((img, median), axis=1)
cv2.imwrite('test.jpg', compare)<|fim_prefix|># repo: GateauXD/Open-Menu path: /temp.py
import cv2
import numpy as np
import os
<|fim_middle|>img = cv2.imread('Images/grayscale.jpg')
median = cv2.medianBlur(img, 3)
| code_fim | medium | {
"lang": "python",
"repo": "GateauXD/Open-Menu",
"path": "/temp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YounesB-McGill/Comp550-Project path: /umpleonline/chatbot/modeleval.py
#!/usr/bin/python3
import json
from random import shuffle
from typing import List, Tuple
import pandas as pd
from sklearn.metrics import accuracy_score, f1_score
from model import predict
from processresponse import process_... | code_fim | hard | {
"lang": "python",
"repo": "YounesB-McGill/Comp550-Project",
"path": "/umpleonline/chatbot/modeleval.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def compute_accuracy_and_f1_model():
test = pd.read_csv(TEST_DATA_PATH, encoding="latin1", names=["Sentence", "Intent"])
complexTest = pd.read_csv(COMPLEX_TEST_DATA_PATH, encoding="latin1", names=["Sentence", "Intent"])
yPred = []
yTrue = []
for i, j in complexTest.iterrows(): #i in i... | code_fim | hard | {
"lang": "python",
"repo": "YounesB-McGill/Comp550-Project",
"path": "/umpleonline/chatbot/modeleval.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> test = pd.read_csv(TEST_DATA_PATH, encoding="latin1", names=["Sentence", "Intent"])
complexTest = pd.read_csv(COMPLEX_TEST_DATA_PATH, encoding="latin1", names=["Sentence", "Intent"])
yPred = []
yTrue = []
for i, j in complexTest.iterrows(): #i in index, j is value at row i
pre... | code_fim | hard | {
"lang": "python",
"repo": "YounesB-McGill/Comp550-Project",
"path": "/umpleonline/chatbot/modeleval.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fhfengzhiyong/task path: /apps/task/views.py
# -*- coding: utf-8 -*-
# -*- __author__=straw -*-
from flask import render_template, Blueprint, redirect
from flask import current_app,g,request
from models import Task
from config.db import Session
"""
任务核心控制类
"""
'''
使用分页查看工作列表
'''
task = Bluepr... | code_fim | medium | {
"lang": "python",
"repo": "fhfengzhiyong/task",
"path": "/apps/task/views.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> session = Session()
t = session.query(Task).filter_by(id=ids)[0]
session.delete(t)
session.commit()
session.close()
return redirect(location='/task/listTask')<|fim_prefix|># repo: fhfengzhiyong/task path: /apps/task/views.py
# -*- coding: utf-8 -*-
# -*- __author__=straw -*-
from... | code_fim | medium | {
"lang": "python",
"repo": "fhfengzhiyong/task",
"path": "/apps/task/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@task.route("/addTask", methods=['POST'])
def add_task():
form = request.form
task = Task()
task.content = form.get('content')
task.work_time = form.get("work_time")
task.complete_rate = form.get("complete_rate")
session = Session()
session.add(task)
session.commit()
s... | code_fim | hard | {
"lang": "python",
"repo": "fhfengzhiyong/task",
"path": "/apps/task/views.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pdxgx/ri-tests path: /results/figures/Figs2B_4A_S12_S13_intron_features.py
axislabel_fontsize=axislabel_size,
ticklabel_fontsize=ticklabel_size, legend_fontsize=legend_fontsize
)
curr_ax.set_ylim([20, 400000])
curr_ax.set_title(col, fontsize=title_size)
... | code_fim | hard | {
"lang": "python",
"repo": "pdxgx/ri-tests",
"path": "/results/figures/Figs2B_4A_S12_S13_intron_features.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # features_vs_detection(hx1_call, ipsc_call, out_dir, now)
# all_results_features_vs_truth(
# hx1_call, hx1_expr, ipsc_call, ipsc_expr, out_dir, now
# )
filtered_groupedbysamp_featvstruth(hx1_call, ipsc_call, out_dir, now)
#
# print('\nprinting additional info')
# df_di... | code_fim | hard | {
"lang": "python",
"repo": "pdxgx/ri-tests",
"path": "/results/figures/Figs2B_4A_S12_S13_intron_features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> output_dir, now):
cols_to_load = [_POS, 'intron', _PERS, _READS, _PERBASE_F, _GC_PERC]
for col in _TOOL_COLUMNS:
cols_to_load.append(_TOOLS[col][_TP])
cols_to_load.append(_TOOLS[col][_FP])
cols_to_load.append(_TOOLS[col][_FN])
datafram... | code_fim | hard | {
"lang": "python",
"repo": "pdxgx/ri-tests",
"path": "/results/figures/Figs2B_4A_S12_S13_intron_features.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def parse_input(value):
hhmm, tz = value.split('@')
hours, minutes = map(int, hhmm.split(':'))
timezone = pytz.timezone(tz)
return hours, minutes, timezone
def parse_now(value):
value = parse_datetime(value)
if not value.tzinfo:
raise argparse.ArgumentTypeError('formatted... | code_fim | hard | {
"lang": "python",
"repo": "elijahr/if-time-at-timezone",
"path": "/bin/if-time-at-timezone",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: elijahr/if-time-at-timezone path: /bin/if-time-at-timezone
#!/usr/bin/env python2
import argparse
import datetime
import pytz
import sys
from dateutil.parser import parse as parse_datetime
def main():
parser = argparse.ArgumentParser(
description='Determine if it is currently the... | code_fim | hard | {
"lang": "python",
"repo": "elijahr/if-time-at-timezone",
"path": "/bin/if-time-at-timezone",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: savannahghi/terminology-server path: /buildserver/manage.py
#!/usr/bin/env python3
import os
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from sil_snomed_server.app import app, db
<|fim_suffix|>manager.add_command("db", MigrateCommand)
if __name__ == "__... | code_fim | medium | {
"lang": "python",
"repo": "savannahghi/terminology-server",
"path": "/buildserver/manage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
manager.run()<|fim_prefix|># repo: savannahghi/terminology-server path: /buildserver/manage.py
#!/usr/bin/env python3
import os
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from sil_snomed_server.app import app, db
app.config.from_ob... | code_fim | easy | {
"lang": "python",
"repo": "savannahghi/terminology-server",
"path": "/buildserver/manage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>manager.add_command("db", MigrateCommand)
if __name__ == "__main__":
manager.run()<|fim_prefix|># repo: savannahghi/terminology-server path: /buildserver/manage.py
#!/usr/bin/env python3
import os
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
<|fim_middle|>fro... | code_fim | medium | {
"lang": "python",
"repo": "savannahghi/terminology-server",
"path": "/buildserver/manage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def auto_linting(input_dir: str):
spec_dir = SpecDir(input_dir)
assert spec_dir.exists(), f"Specd not found: {input_dir}"
# Iterates through each definition and removes lines that are unwanted
lint_definitions(input_dir)
# Does the same for all path files
lint_paths(input_dir)
... | code_fim | hard | {
"lang": "python",
"repo": "genomoncology/specd",
"path": "/src/specd/tasks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: genomoncology/specd path: /src/specd/tasks.py
import os
import typing
from stringcase import camelcase, snakecase
import click
from dictdiffer import diff
from swagger_spec_validator import validator20, SwaggerValidationError
from .model import SpecDir, Path, Operation, Definition, create_spec_... | code_fim | hard | {
"lang": "python",
"repo": "genomoncology/specd",
"path": "/src/specd/tasks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if definition.exists():
click.echo(f"Definition exists, merge: {name}")
definition.merge(def_spec)
else:
definition.write(def_spec)
def write_meta(input_spec, spec_dir):
# write meta (e.g. not paths or definitions)
if spec_dir.meta.exists():
... | code_fim | hard | {
"lang": "python",
"repo": "genomoncology/specd",
"path": "/src/specd/tasks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dleblond312/IEEEXtreme_WorkingAsIntended path: /2012/AE_Rob.py
import sys
line = sys.stdin.readline()
try:
price, deposit = line.split()
price = int(price)
deposit = int(deposit)
except Exception:
print "ERROR"
exit()
<|fim_suffix|>change = deposit - price
output = str(ch... | code_fim | hard | {
"lang": "python",
"repo": "dleblond312/IEEEXtreme_WorkingAsIntended",
"path": "/2012/AE_Rob.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>change = deposit - price
output = str(change / 100) + str(" ")
change %= 100
output += str(change / 25) + str(" ")
change %= 25
output += str(change / 10) + str(" ")
change %= 10
output += str(change / 5)
print output<|fim_prefix|># repo: dleblond312/IEEEXtreme_WorkingAsIntended path: /2012/AE_Rob.py
i... | code_fim | medium | {
"lang": "python",
"repo": "dleblond312/IEEEXtreme_WorkingAsIntended",
"path": "/2012/AE_Rob.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BbsonLin/flask-request-logger path: /flask_request_logger/database.py
import datetime
from sqlalchemy.ext.declarative import as_declarative
from flask_sqlalchemy import DefaultMeta as SQLModelDefaultMeta
<|fim_suffix|> def to_json(self):
result = dict()
for key in self.__ma... | code_fim | hard | {
"lang": "python",
"repo": "BbsonLin/flask-request-logger",
"path": "/flask_request_logger/database.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Use it and configure it just like flask_sqlalchemy
"""
__table_args__ = {'extend_existing': True}
def to_json(self):
result = dict()
for key in self.__mapper__.c.keys():
col = getattr(self, key)
if isinstance(col, datetime.datetime) or isinstance(co... | code_fim | medium | {
"lang": "python",
"repo": "BbsonLin/flask-request-logger",
"path": "/flask_request_logger/database.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = dict()
for key in self.__mapper__.c.keys():
col = getattr(self, key)
if isinstance(col, datetime.datetime) or isinstance(col, datetime.date):
col = col.isoformat()
result[key] = col
return result
Base = SQLModel<|fim_pr... | code_fim | medium | {
"lang": "python",
"repo": "BbsonLin/flask-request-logger",
"path": "/flask_request_logger/database.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>SENSOR_TYPES = {
"host": MikrotikDeviceTrackerEntityDescription(
key="host",
name="",
icon_enabled="mdi:lan-connect",
icon_disabled="mdi:lan-disconnect",
ha_group="",
ha_connection=CONNECTION_NETWORK_MAC,
ha_connection_value="data__mac-address",
... | code_fim | hard | {
"lang": "python",
"repo": "tomaae/homeassistant-mikrotik_router",
"path": "/custom_components/mikrotik_router/device_tracker_types.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.