text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Nexenta/fuel-plugin-nexentaedge path: /deployment_scripts/python/modules/cinder_config.py
import ConfigParser
import subprocess
from utils import get_deployment_config, download
CINDER_PATH = '/etc/cinder/cinder.conf'
def get_raw_output(command):
try:
output = subprocess.c... | code_fim | hard | {
"lang": "python",
"repo": "Nexenta/fuel-plugin-nexentaedge",
"path": "/deployment_scripts/python/modules/cinder_config.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> access = cfg['access']
creds = ['--os-auth-url={}'.format(
config.defaults()['os_privileged_user_auth_url']),
'--os-username={}'.format(access['user']),
'--os-password={}'.format(access['password']),
'--os-tenant-name={}'.format(access['... | code_fim | hard | {
"lang": "python",
"repo": "Nexenta/fuel-plugin-nexentaedge",
"path": "/deployment_scripts/python/modules/cinder_config.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Save tf.keras model in HDF5 format.
keras_file = "keras_model.h5"
tf.keras.models.save_model(model, keras_file)
# Convert to TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_keras_model_file(keras_file)
tflite_model = converter.convert()
open("examPle_converted_model.tflite", "wb").write... | code_fim | hard | {
"lang": "python",
"repo": "frank1789/ProjectThesis",
"path": "/quantize.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: frank1789/ProjectThesis path: /quantize.py
import os
import numpy as np
import tensorflow as tf
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
keras_file = "model_data/yolov2.h5"
<|fim_suffix|>
# Generate tf.keras model.
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(2, input_... | code_fim | medium | {
"lang": "python",
"repo": "frank1789/ProjectThesis",
"path": "/quantize.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> temp = p_1 * (mean_1 - mean_g) ** 2 + p_2 * (mean_2 - mean_g) ** 2 + p_3 * (mean_3 - mean_g) ** 2;
interclass_var[ii, jj] = np.nan_to_num(temp);
threshold = np.unravel_index(np.argmax(interclass_var, axis=None), interclass_var.shape);
threshold1... | code_fim | hard | {
"lang": "python",
"repo": "almostdutch/image-segmentation",
"path": "/segmentation_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if mask_old.sum() == mask.sum():
break;
mask_old = mask;
return mask;
def ColorSegmentation(image, kernel_sigma, color_seg, sim_threshold):
"""Returns a segmentation mask with 2 classes
image: original image
kernel_sigma: sta... | code_fim | hard | {
"lang": "python",
"repo": "almostdutch/image-segmentation",
"path": "/segmentation_utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: almostdutch/image-segmentation path: /segmentation_utils.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
segmentation_utils.py
"""
import matplotlib
import numpy as np
from scipy.signal import correlate
import random
from sklearn.cluster import KMeans
def GaussianKernel1D(sigma):
'''... | code_fim | hard | {
"lang": "python",
"repo": "almostdutch/image-segmentation",
"path": "/segmentation_utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quantrocket-llc/moonshot path: /moonshot/_tests/test_prices.py
])
fields = ["Close","Volume"]
idx = pd.MultiIndex.from_product([fields, dt_idx], names=["Field", "Date"])
prices = pd.DataFrame(
{
"FI12345": [
... | code_fim | hard | {
"lang": "python",
"repo": "quantrocket-llc/moonshot",
"path": "/moonshot/_tests/test_prices.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
A basic test strategy that buys below 10.
"""
def prices_to_signals(self, prices):
signals = prices.loc["Close"] < 10
self.save_to_results("Nlv", signals.apply(lambda x: self._securities_master.Nlv, axis=1))
... | code_fim | hard | {
"lang": "python",
"repo": "quantrocket-llc/moonshot",
"path": "/moonshot/_tests/test_prices.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quantrocket-llc/moonshot path: /moonshot/_tests/test_prices.py
5", "FI23456"])
self.assertListEqual(kwargs["fields"], [
"Currency", "Multiplier", "PriceMagnifier",
"Exchange", "SecType", "Symbol", "Timezone"])
@patch("moonshot.strategies.base.get_prices")
... | code_fim | hard | {
"lang": "python",
"repo": "quantrocket-llc/moonshot",
"path": "/moonshot/_tests/test_prices.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> convoluted_feat1 = self.conv1(query_document_product)
convoluted_feat2 = self.conv2(query_document_product)
convoluted_feat3 = self.conv3(query_document_product)
convoluted_feat = self.relu(torch.cat((convoluted_feat1, convoluted_feat2, convoluted_feat3), 1))
co... | code_fim | hard | {
"lang": "python",
"repo": "skallumadi/mnsrf_ranking_suggestion",
"path": "/baselines/match_tensor/match_tensor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> query_document_product = embedded_queries * embedded_docs
exact_match = self.exact_match_channel(batch_queries, batch_docs).unsqueeze(3)
query_document_product = torch.cat((query_document_product, exact_match), 3)
query_document_product = query_document_product.transpose... | code_fim | hard | {
"lang": "python",
"repo": "skallumadi/mnsrf_ranking_suggestion",
"path": "/baselines/match_tensor/match_tensor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skallumadi/mnsrf_ranking_suggestion path: /baselines/match_tensor/match_tensor.py
###############################################################################
# Author: Wasi Ahmad
# Project: Match Tensor: a Deep Relevance Model for Search
# Date Created: 7/28/2017
#
# File Description: Th... | code_fim | hard | {
"lang": "python",
"repo": "skallumadi/mnsrf_ranking_suggestion",
"path": "/baselines/match_tensor/match_tensor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: frankhood/django-model-importer path: /tests/example/importer.py
from django_model_importer.controllers import ModelCSVImporter
from tests.example.models import Poll
class PollsImporter(ModelCSVImporter):
can_update = False
can_create = True
can_add_fk = True
can_add_m2m = True
... | code_fim | hard | {
"lang": "python",
"repo": "frankhood/django-model-importer",
"path": "/tests/example/importer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return None
def get_import_id(self, columns):
return None<|fim_prefix|># repo: frankhood/django-model-importer path: /tests/example/importer.py
from django_model_importer.controllers import ModelCSVImporter
from tests.example.models import Poll
class PollsImporter(ModelCSVImporter)... | code_fim | hard | {
"lang": "python",
"repo": "frankhood/django-model-importer",
"path": "/tests/example/importer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TorinAsakura/cooking path: /povary/apps/ingredients/urls.py
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from django.core.urlresolvers import reverse
<|fim_suffix|> url(r'autocomplete/$', 'ingredients.views.ingredients_autocomplete', name='ingredients_autocomplete'... | code_fim | medium | {
"lang": "python",
"repo": "TorinAsakura/cooking",
"path": "/povary/apps/ingredients/urls.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> url(r'autocomplete/$', 'ingredients.views.ingredients_autocomplete', name='ingredients_autocomplete'),
)<|fim_prefix|># repo: TorinAsakura/cooking path: /povary/apps/ingredients/urls.py
# -*- coding: utf-8 -*-
from django.conf.urls import patterns, include, url
from django.core.urlresolvers import rever... | code_fim | medium | {
"lang": "python",
"repo": "TorinAsakura/cooking",
"path": "/povary/apps/ingredients/urls.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vierbergenlars/Informatica path: /Module 2/approx_e.py
# Approximates e
"""
Main loop
=========
Initialisation: e = 0, mult = 1.0
Continuation: Do it for all numbers <|fim_suffix|>/2!, 3rd time +1/3!, ...)
"""
e = 1.0
mult= 1.0
for num in range(1,50):
mult *= num
e += 1.0/mult
print e<... | code_fim | hard | {
"lang": "python",
"repo": "vierbergenlars/Informatica",
"path": "/Module 2/approx_e.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ates 1!, the 2nd time 2!, 3rd 3!, ...)
* Add 1/mult to the approximation of e
( 1st time 1, 2nd time +1/2!, 3rd time +1/3!, ...)
"""
e = 1.0
mult= 1.0
for num in range(1,50):
mult *= num
e += 1.0/mult
print e<|fim_prefix|># repo: vierbergenlars/Informatica path: /Module 2/approx_e.py
#... | code_fim | medium | {
"lang": "python",
"repo": "vierbergenlars/Informatica",
"path": "/Module 2/approx_e.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@bot.group(pass_context=True)
async def cool(ctx):
"""Says if a user is cool.
In reality this just checks if a subcommand is being invoked.
"""
if ctx.invoked_subcommand is None:
await bot.say('No, {0.subcommand_passed} is not cool'.format(ctx))
@cool.command(name='bot')
async def... | code_fim | hard | {
"lang": "python",
"repo": "Kbman99/Tweet-Me-A-Song",
"path": "/TwitterToDiscordBot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kbman99/Tweet-Me-A-Song path: /TwitterToDiscordBot.py
import discord
from discord.ext import commands
import random
import tweepy
import asyncio
from collections import deque
description = '''An example bot to showcase the discord.ext.commands extension
module.
There are a number of utility comm... | code_fim | hard | {
"lang": "python",
"repo": "Kbman99/Tweet-Me-A-Song",
"path": "/TwitterToDiscordBot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@cool.command(name='bot')
async def _bot():
"""Is the bot cool?"""
await bot.say('Yes, the bot is cool.')
def parse_string(string_to_parse):
parsed_string = string_to_parse.split(" ", 2)
print(parsed_string)
print(parsed_string[1])
return parsed_string[1]
# Calls to twitter API t... | code_fim | hard | {
"lang": "python",
"repo": "Kbman99/Tweet-Me-A-Song",
"path": "/TwitterToDiscordBot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__': # pragma: no cover
main()<|fim_prefix|># repo: andyneff/terra path: /terra/executor/celery/__main__.py
#!/usr/bin/env python
from os import environ as env
from . import app, setup_task_controller
import warnings
<|fim_middle|>def main():
if env.get('TERRA_SETTINGS_FILE'... | code_fim | hard | {
"lang": "python",
"repo": "andyneff/terra",
"path": "/terra/executor/celery/__main__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: andyneff/terra path: /terra/executor/celery/__main__.py
#!/usr/bin/env python
from os import environ as env
from . import app, setup_task_controller
import warnings
<|fim_suffix|> if env.get('TERRA_SETTINGS_FILE', '') == '':
warnings.warn("terra.executor.celery.__main__ shouldn't be needed... | code_fim | easy | {
"lang": "python",
"repo": "andyneff/terra",
"path": "/terra/executor/celery/__main__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> etax = EMOD * IX / KY / GMOD / AREA / (length**2)
etay = EMOD * IY / KX / GMOD / AREA / (length**2)
rhox = 1 / (1 + 12 * etax)
rhoy = 1 / (1 + 12 * etay)
f1 = z / length
f2 = 1 - f1
f3x = f1 * (3 * f1 - 2 * f1**2 + 12 * etax) * rhox
f4x = f2... | code_fim | hard | {
"lang": "python",
"repo": "ebranlard/welib",
"path": "/welib/weio/wetb/hawc2/st_file.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f3y = f1 * (3 * f1 - 2 * f1**2 + 12 * etay) * rhoy
f4y = f2 * (3 * f2 - 2 * f2**2 + 12 * etay) * rhoy
f5y = length * (f1**2 - (1 - 6 * etay) * f1 - 6 * etay) * f1 * rhoy
f6y = length * (f2**2 - (1 - 6 * etay) * f2 - 6 * etay) * f2 * rhoy
f7y = 6 / length * f1 * f2 *... | code_fim | hard | {
"lang": "python",
"repo": "ebranlard/welib",
"path": "/welib/weio/wetb/hawc2/st_file.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ebranlard/welib path: /welib/weio/wetb/hawc2/st_file.py
'''
Created on 24/04/2014
@author: MMPE
'''
import types
import os
import numpy as np
stc = "r m x_cg y_cg ri_x ri_y x_sh y_sh E G I_x I_y I_p k_x k_y A pitch x_e y_e"
fpm = 'r m x_cg y_cg ri_x ri_y pitch x_e y_e K_11 K_12 K_13 K_14 K_15 ... | code_fim | hard | {
"lang": "python",
"repo": "ebranlard/welib",
"path": "/welib/weio/wetb/hawc2/st_file.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_ts23_mcpck(self):
self.test_data.partition = "LA"
test_data = self.tpf_server.run("TS23", self.test_data)
self.assertEqual(2, test_data.output.regs["R12"])
def test_ts23_date(self):
self.test_data.set_field("EBX000", bytes([0x01]))
self.test_data.a... | code_fim | hard | {
"lang": "python",
"repo": "crazynayan/tpf1",
"path": "/p8_test/test_local/test_execution/test_ts23_exec_macro.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: crazynayan/tpf1 path: /p8_test/test_local/test_execution/test_ts23_exec_macro.py
import unittest
from p4_execution.ex5_execute import TpfServer
from p8_test.test_local import TestDataUTS
class Ts23Test(unittest.TestCase):
def setUp(self) -> None:
self.tpf_server = TpfServer()
... | code_fim | hard | {
"lang": "python",
"repo": "crazynayan/tpf1",
"path": "/p8_test/test_local/test_execution/test_ts23_exec_macro.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sr-2020/balancer path: /roles/gurkalov.yc_autostarter/molecule/default/tests/test_default.py
import os
import testinfra.utils.ansible_runner
<|fim_suffix|> f = host.file('/var/job/yc-autostarter/healthcheck.php')
assert f.exists
def test_env_file(host):
f = host.file('/var/job/yc-... | code_fim | medium | {
"lang": "python",
"repo": "sr-2020/balancer",
"path": "/roles/gurkalov.yc_autostarter/molecule/default/tests/test_default.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_env_file(host):
f = host.file('/var/job/yc-autostarter/.env')
assert f.exists<|fim_prefix|># repo: sr-2020/balancer path: /roles/gurkalov.yc_autostarter/molecule/default/tests/test_default.py
import os
import testinfra.utils.ansible_runner
testinfra_hosts = testinfra.utils.ansible_run... | code_fim | medium | {
"lang": "python",
"repo": "sr-2020/balancer",
"path": "/roles/gurkalov.yc_autostarter/molecule/default/tests/test_default.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Initial position
x0 = np.array([0, 0, np.arctan2(z_spline(t0,1), y_spline(t0,1))])
# Integrate
sol = solve_ivp(f, (0, tf), x0, t_eval=np.linspace(t0, tf, 100), max_step=5e-3)
return plot_unicycle_trajectory(sol.t, sol.y.T, y_spline, z_spline, obs)
if __name__ == '__main__':
simulate_unic... | code_fim | hard | {
"lang": "python",
"repo": "prem-chand/MEAM517",
"path": "/hw3/simulate_unicycle.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: prem-chand/MEAM517 path: /hw3/simulate_unicycle.py
from math import *
import numpy as np
import matplotlib.pyplot as plt
from scipy.integrate import solve_ivp
import importlib
from random import uniform
# Reload the module to use the latest code
import unicycle_spline
import unicycle_input
impor... | code_fim | medium | {
"lang": "python",
"repo": "prem-chand/MEAM517",
"path": "/hw3/simulate_unicycle.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># Image datasets
image_data_dir = os.path.join(data_dir, 'images')
# FEMNIST clients data
femnist_clients_dir = os.path.join(image_data_dir, 'femnist_clients')
# CIFAR100 clients data
cifar100_clients_dir = os.path.join(image_data_dir, 'cifar100_clients')
# CIFAR10 clients data
cifar10_clients_dir = os.pa... | code_fim | hard | {
"lang": "python",
"repo": "ClonedOne/ryofl",
"path": "/ryofl/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ClonedOne/ryofl path: /ryofl/common.py
"""
Constants that should be accessible from any other file
"""
import os
# Number of processors to be used when possible
processors = 4
# This is the directory where the dataset will be saved.
# Change this to a path with sufficient disk space.
data_dir ... | code_fim | medium | {
"lang": "python",
"repo": "ClonedOne/ryofl",
"path": "/ryofl/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: filipecosta90/perf-benchmarking-infrastructure path: /scripts/redis-balancer.py
#!/usr/bin/python2.7
# Redis Balancer for NUMA Class Systems
# Python 2.7.X
# Based on scripts from Nail Sirazitdinov and Shankhadeep Shome
# Version 0.1
import argparse
import math
import os
import subprocess
import ... | code_fim | hard | {
"lang": "python",
"repo": "filipecosta90/perf-benchmarking-infrastructure",
"path": "/scripts/redis-balancer.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def taskset_numa_process(processid, numa_cpus):
if len(numa_cpus) > 0:
numa_cpus_str = "{}".format(numa_cpus[0])
for cpu_num in numa_cpus[1:]:
numa_cpus_str = numa_cpus_str + ",{}".format(cpu_num)
runcmd = 'taskset -apc {numa_cpus} {processid}'.format(numa_cpus=numa... | code_fim | hard | {
"lang": "python",
"repo": "filipecosta90/perf-benchmarking-infrastructure",
"path": "/scripts/redis-balancer.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Deletes the track point on the server"""
delete_tracks(self.project, [self])
@FeatureModel.geometry.setter
def geometry(self, value):
self._feature.geometry = value
@property
def accuracy(self):
""" The horizontal accuracy of the location measu... | code_fim | hard | {
"lang": "python",
"repo": "SherbazHashmi/HackathonServer",
"path": "/arcpyenv/arcgispro-py3-clone/Lib/site-packages/arcgis/apps/workforce/track.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SherbazHashmi/HackathonServer path: /arcpyenv/arcgispro-py3-clone/Lib/site-packages/arcgis/apps/workforce/track.py
""" Defines the Track object.
"""
from .feature_model import FeatureModel
from ._store import *
from ._schemas import TrackSchema
class Track(FeatureModel):
""" Repre... | code_fim | hard | {
"lang": "python",
"repo": "SherbazHashmi/HackathonServer",
"path": "/arcpyenv/arcgispro-py3-clone/Lib/site-packages/arcgis/apps/workforce/track.py",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self._feature.geometry = value
@property
def accuracy(self):
""" The horizontal accuracy of the location measurement, in meters."""
return self._feature.attributes[self._schema.accuracy]
@accuracy.setter
def accuracy(self, value):
self._feature.at... | code_fim | hard | {
"lang": "python",
"repo": "SherbazHashmi/HackathonServer",
"path": "/arcpyenv/arcgispro-py3-clone/Lib/site-packages/arcgis/apps/workforce/track.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>read_off, parse_off
__all__ = [
'parse_txt_array',
'read_txt_array',
'read_tu_data',
'read_planetoid_data',
'read_ply',
'read_sdf',
'parse_sdf',
'read_off',
'parse_off',
]<|fim_prefix|># repo: Cyanogenoid/fspool path: /graphs/torch_geometric/read/__init__.py
from .txt... | code_fim | medium | {
"lang": "python",
"repo": "Cyanogenoid/fspool",
"path": "/graphs/torch_geometric/read/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Cyanogenoid/fspool path: /graphs/torch_geometric/read/__init__.py
from .txt_array import parse_txt_array, read_txt_array
from .tu import read_tu_data
from .planetoid imp<|fim_suffix|>ead_planetoid_data',
'read_ply',
'read_sdf',
'parse_sdf',
'read_off',
'parse_off',
]<|fim_midd... | code_fim | hard | {
"lang": "python",
"repo": "Cyanogenoid/fspool",
"path": "/graphs/torch_geometric/read/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ead_planetoid_data',
'read_ply',
'read_sdf',
'parse_sdf',
'read_off',
'parse_off',
]<|fim_prefix|># repo: Cyanogenoid/fspool path: /graphs/torch_geometric/read/__init__.py
from .txt_array import parse_txt_array, read_txt_array
from .tu import read_tu_data
from .planetoid import read_p... | code_fim | medium | {
"lang": "python",
"repo": "Cyanogenoid/fspool",
"path": "/graphs/torch_geometric/read/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.identifier is None:
return False
self.release_lock()
def acquire_lock_with_timeout(self):
"""
获得锁
:return: success: identifier failed: None
"""
identifier = str(uuid.uuid4())
lock_timeout = int(math.ceil(self.lock_exp... | code_fim | hard | {
"lang": "python",
"repo": "ZhuoZhuoCrayon/AcousticKeyBoard-Web",
"path": "/djangocli/utils/redis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZhuoZhuoCrayon/AcousticKeyBoard-Web path: /djangocli/utils/redis.py
# -*- coding: utf-8 -*-
import math
import threading
import uuid
from django.conf import settings
from django_redis import get_redis_connection
from redis import StrictRedis
from djangocli.constants import TimeUnit
DEFAULT_TIM... | code_fim | hard | {
"lang": "python",
"repo": "ZhuoZhuoCrayon/AcousticKeyBoard-Web",
"path": "/djangocli/utils/redis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: brymer-meneses/Synapse path: /api_testing/linearRegressionNumpy.py
import numpy as np
x = np.arange(1, 20, dtype=np.float)
W = np.zeros_like(x)
y = 2 * x # [2, 4, 6, ... 10]
def MSE(y, y_predicted):
return ((y_predicted - y)**2).mean()
<|fim_suffix|>for epoch in range(maxEpochs):
y_pr... | code_fim | medium | {
"lang": "python",
"repo": "brymer-meneses/Synapse",
"path": "/api_testing/linearRegressionNumpy.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>lr = 0.00001
maxEpochs = 110
for epoch in range(maxEpochs):
y_pred = W * x
loss = MSE(y, y_pred)
dw = gradient(x, y, y_pred)
W = W - lr * dw
print(loss)<|fim_prefix|># repo: brymer-meneses/Synapse path: /api_testing/linearRegressionNumpy.py
import numpy as np
x = np.arange(1,... | code_fim | medium | {
"lang": "python",
"repo": "brymer-meneses/Synapse",
"path": "/api_testing/linearRegressionNumpy.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>CATED = "ccAUTHUnauthenticated.json"
DECLINE = "ccAUTHDeclineError.json"
UNKNOWN_ERROR = "ccAUTHUnknownError.json"
MERCHANT_DECLINE = "ccAUTHMerchantDeclineError.json"<|fim_prefix|># repo: aogdowski-pgs/py-payments-testing path: /utils/enums/responses/auth_response.py
from enum import Enum
... | code_fim | medium | {
"lang": "python",
"repo": "aogdowski-pgs/py-payments-testing",
"path": "/utils/enums/responses/auth_response.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aogdowski-pgs/py-payments-testing path: /utils/enums/responses/auth_response.py
from enum import Enum
class AUTHresponse(Enum):
OK = "ccAUTHoK.json"
INVALID_FIELD = "ccAUTHInvalidField.json"
SOCKET_ERROR = "ccAUTHSocketError.json"
UNAUTHENTI<|fim_suffix|>ERROR = "ccAUTHUnknownEr... | code_fim | medium | {
"lang": "python",
"repo": "aogdowski-pgs/py-payments-testing",
"path": "/utils/enums/responses/auth_response.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>DEVICE_NAME = "myStrom Device"
DEVICE_MAC = "6001940376EB"
@pytest.fixture
def mock_setup_entry() -> Generator[AsyncMock, None, None]:
"""Override async_setup_entry."""
with patch(
"homeassistant.components.mystrom.async_setup_entry", return_value=True
) as mock_setup_entry:
... | code_fim | medium | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/mystrom/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: home-assistant/core path: /tests/components/mystrom/conftest.py
"""Provide common mystrom fixtures and mocks."""
from collections.abc import Generator
from unittest.mock import AsyncMock, patch
import pytest
from homeassistant.components.mystrom.const import DOMAIN
from homeassistant.const imp... | code_fim | hard | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/mystrom/conftest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Override async_setup_entry."""
with patch(
"homeassistant.components.mystrom.async_setup_entry", return_value=True
) as mock_setup_entry:
yield mock_setup_entry
@pytest.fixture
def config_entry(hass: HomeAssistant) -> MockConfigEntry:
"""Create and add a config entry."... | code_fim | medium | {
"lang": "python",
"repo": "home-assistant/core",
"path": "/tests/components/mystrom/conftest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SwampertX/textbook-solutions path: /dragon/3.7.1.d/nfa_dfa.py
import string
# Task: design a function that takes in a NFA
# as a graph and returns the corresponding DFA
# input: A graph, nfa
# output: A graph, dfa
# we represent all graph as a adjacency matrix.
# nfa graph - ns * (l + 1) matrix... | code_fim | hard | {
"lang": "python",
"repo": "SwampertX/textbook-solutions",
"path": "/dragon/3.7.1.d/nfa_dfa.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def tt_from_input():
rows = int(input("Number of rows (states, including zero): "))
cols = int(input("Number of cols (letters, including epsilon): "))
letters = []
for i in range(cols - 1):
letters.append(input("{}th letter : ".format(i + 1)))
print("\nFrom now on, please inpu... | code_fim | hard | {
"lang": "python",
"repo": "SwampertX/textbook-solutions",
"path": "/dragon/3.7.1.d/nfa_dfa.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TranXuanHoang/Python path: /00-basic/exercise2.py
"""
1) Create a list of names and use a for loop to output the length of each name (len()).
2) Add an if check inside the loop to only output names longer than 5 characters.
3) Add another if check to see whether a name includes a “n” or... | code_fim | medium | {
"lang": "python",
"repo": "TranXuanHoang/Python",
"path": "/00-basic/exercise2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
for name in names:
print(len(name))
for name in names:
if len(name) > 5:
print(name)
for name in names:
if len(name) > 5 and contains(name, ['n', 'N']):
print(name)
while len(names) > 0:
names.pop()
print(names)<|fim_prefix|># repo: TranXuanHoang/Python p... | code_fim | medium | {
"lang": "python",
"repo": "TranXuanHoang/Python",
"path": "/00-basic/exercise2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
policy_value_fn: a function that takes in a board state and outputs
a list of (action, probability) tuples and also a score in [-1, 1]
(i.e. the expected value of the end game score from the current
player's perspective) for the current player.
... | code_fim | hard | {
"lang": "python",
"repo": "gmftbyGMFTBY/General-Zero",
"path": "/pure_mcts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gmftbyGMFTBY/General-Zero path: /pure_mcts.py
#!/usr/bin/python3
# Author: GMFTBY
# Time : 2018.7.9
import numpy as np
import copy
from operator import itemgetter
def rollout_policy_fn(board):
"""a coarse, fast version of policy_fn used in the rollout phase."""
# rollout randomly
... | code_fim | hard | {
"lang": "python",
"repo": "gmftbyGMFTBY/General-Zero",
"path": "/pure_mcts.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Step forward in the tree, keeping everything we already know
about the subtree.
"""
if point == -1:
# reset the tree
self._root = TreeNode(None, 1.0)
else:
self._root = self._root._children[point][last_move]
... | code_fim | hard | {
"lang": "python",
"repo": "gmftbyGMFTBY/General-Zero",
"path": "/pure_mcts.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class BadgeDoesNotExist(APIException):
status_code = HTTP_400_BAD_REQUEST
default_detail = 'The Badge with given ID does not exist'
class LocalBadgeClient(BadgeClient, ABC):
def get_token(self, badge_id: str) -> str:
try:
return Badge.objects.get(id=badge_id).token
... | code_fim | medium | {
"lang": "python",
"repo": "riichi/kcc3",
"path": "/badges/local_badge_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: riichi/kcc3 path: /badges/local_badge_client.py
from abc import ABC
from typing import Union, List, Iterable
from rest_framework.exceptions import APIException
from rest_framework.status import HTTP_400_BAD_REQUEST
from badges.models import Badge
from badgeupdater.client.badge_client import Bad... | code_fim | medium | {
"lang": "python",
"repo": "riichi/kcc3",
"path": "/badges/local_badge_client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># if __name__ == '__main__':
# a = Solution()
# b = a.nextGreatestLetter(["c","f","j"], "g")
# print(b)
# @lc code=end<|fim_prefix|># repo: 610yilingliu/leetcode path: /Python3/744.find-smallest-letter-greater-than-target.py
#
# @lc app=leetcode id=744 lang=python3
#
# [744] Find Smallest Let... | code_fim | hard | {
"lang": "python",
"repo": "610yilingliu/leetcode",
"path": "/Python3/744.find-smallest-letter-greater-than-target.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 610yilingliu/leetcode path: /Python3/744.find-smallest-letter-greater-than-target.py
#
# @lc app=leetcode id=744 lang=python3
#
# [744] Find Smallest Letter Greater Than Target
#
# @lc code=start
import heapq
class Solution:
def nextGreatestLetter(self, letters, target):
<|fim_suffix|>
# if ... | code_fim | hard | {
"lang": "python",
"repo": "610yilingliu/leetcode",
"path": "/Python3/744.find-smallest-letter-greater-than-target.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: memsharded/conan path: /conans/client/recorder/action_recorder.py
# FIXME: The functions from the tracer.py module should be called here, I removed from there some
# of them because it has to be called in the remote manager, not in the proxy, where we have info
# about the downloaded files prior... | code_fim | hard | {
"lang": "python",
"repo": "memsharded/conan",
"path": "/conans/client/recorder/action_recorder.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def recipe_downloaded(self, ref, remote_name):
self._add_recipe_action(ref, Action(INSTALL_DOWNLOADED, ref, {"remote": remote_name}))
def recipe_install_error(self, ref, error_type, description, remote_name):
doc = {"type": error_type, "description": description, "remote": remote_... | code_fim | hard | {
"lang": "python",
"repo": "memsharded/conan",
"path": "/conans/client/recorder/action_recorder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ret = {"error": self.install_errored or self.error,
"installed": []}
def get_doc_for_ref(the_ref, the_actions):
errors = [action.doc for action in the_actions if action.type == INSTALL_ERROR]
error = None if not errors else errors[0]
remo... | code_fim | hard | {
"lang": "python",
"repo": "memsharded/conan",
"path": "/conans/client/recorder/action_recorder.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lizziel/gcgridobj path: /gcgridobj/plottools.py
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cubedsphere
from gcgridobj import gc_horizontal, gc_vertical
import numpy as np
import xesmf
import xarray
crs_plot_standard = ccrs.PlateCarree()
crs_data_stan... | code_fim | hard | {
"lang": "python",
"repo": "lizziel/gcgridobj",
"path": "/gcgridobj/plottools.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def plot_latlon(layer_data,hrz_grid=None,ax=None,crs_data=None,crs_plot=None,show_colorbar=True):
'''Plot 2D lat-lon data
'''
assert len(layer_data.shape) == 2, 'Layer data must be 2-D'
if hrz_grid is None:
hrz_grid = gc_horizontal.get_grid(layer_data.shape)
assert hrz_grid... | code_fim | hard | {
"lang": "python",
"repo": "lizziel/gcgridobj",
"path": "/gcgridobj/plottools.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: emptyewer/DEEPN path: /library_quality.py
import os
import sys
import glob
import cPickle
import functions.structures as sts
directory = 'blast_results_query'
if not os.path.exists(directory):
print (">>> No blast results found. Exiting.")
sys.exit()
filelist = glob.glob(directory + "/*... | code_fim | hard | {
"lang": "python",
"repo": "emptyewer/DEEPN",
"path": "/library_quality.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> stats['backwards'],
stats['orf_frame'],
stats['up_frame']))
first_line_junction = False
else:
out... | code_fim | hard | {
"lang": "python",
"repo": "emptyewer/DEEPN",
"path": "/library_quality.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dhh1128/lect path: /pylect/env/component.py
import os
LIB_SUFFIX = '.lib'
APP_SUFFIX = '.app'
VALID_SUFFIXES = [LIB_SUFFIX, APP_SUFFIX]
<|fim_suffix|> '''
A Component is a separately compilable project in lect. Components
are always siblings of one another and reside within a Sandbox. Typi... | code_fim | medium | {
"lang": "python",
"repo": "dhh1128/lect",
"path": "/pylect/env/component.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
A Component is a separately compilable project in lect. Components
are always siblings of one another and reside within a Sandbox. Typically,
each Component corresponds to a different repo in a dvcs.
'''
def __init__(self, sandbox, relpath):
self.sandbox = sandbox
if relpath.endswi... | code_fim | medium | {
"lang": "python",
"repo": "dhh1128/lect",
"path": "/pylect/env/component.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Request project data by jira project key"""
url = cjm.request.make_cj_url(cfg, "project", project_key)
response = cjm.request.make_cj_request(cfg, url)
return response.json()<|fim_prefix|># repo: dariusz-walczak/intman path: /script/cjm/project.py
# SPDX-License-Identifier: MIT
# Copy... | code_fim | easy | {
"lang": "python",
"repo": "dariusz-walczak/intman",
"path": "/script/cjm/project.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dariusz-walczak/intman path: /script/cjm/project.py
# SPDX-License-Identifier: MIT
# Copyright (C) 2020-2021 Mobica Limited
"""Jira project related helpers"""
# Project imports
import cjm.codes
import cjm.request
<|fim_suffix|> """Request project data by jira project key"""
url = cjm.... | code_fim | easy | {
"lang": "python",
"repo": "dariusz-walczak/intman",
"path": "/script/cjm/project.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>admin.site.register(Person)
admin.site.register(Player)
admin.site.register(Tournament)
admin.site.register(TournamentPlayer)
admin.site.register(TournamentPick)<|fim_prefix|># repo: alex-evans/fgolf path: /fg/tournaments/admin.py
from django.contrib import admin
<|fim_middle|>from .models import Player... | code_fim | medium | {
"lang": "python",
"repo": "alex-evans/fgolf",
"path": "/fg/tournaments/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alex-evans/fgolf path: /fg/tournaments/admin.py
from django.contrib import admin
<|fim_suffix|>
admin.site.register(Person)
admin.site.register(Player)
admin.site.register(Tournament)
admin.site.register(TournamentPlayer)
admin.site.register(TournamentPick)<|fim_middle|>from .models import Playe... | code_fim | medium | {
"lang": "python",
"repo": "alex-evans/fgolf",
"path": "/fg/tournaments/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
admin.site.register(Person)
admin.site.register(Player)
admin.site.register(Tournament)
admin.site.register(TournamentPlayer)
admin.site.register(TournamentPick)<|fim_prefix|># repo: alex-evans/fgolf path: /fg/tournaments/admin.py
from django.contrib import admin
<|fim_middle|>from .models import Playe... | code_fim | medium | {
"lang": "python",
"repo": "alex-evans/fgolf",
"path": "/fg/tournaments/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/trove path: /trove/tests/unittests/conductor/test_conf.py
# Copyright 2014 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http... | code_fim | hard | {
"lang": "python",
"repo": "openstack/trove",
"path": "/trove/tests/unittests/conductor/test_conf.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def mock_launch(conf, server, workers, restart_method):
qualified_mgr = "%s.%s" % (server.manager_impl.__module__,
server.manager_impl.__class__.__name__)
self.assertEqual(rt_mgr_name, qualified_mgr, "Invalid manager")
retu... | code_fim | hard | {
"lang": "python",
"repo": "openstack/trove",
"path": "/trove/tests/unittests/conductor/test_conf.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # links
note = item["csljson"]["note"] if "note" in item["csljson"] else ""
item["more"] = split_text_to_list(note)
if "URL" in item["csljson"] \
and os.getenv("ZTH_INCLUDE_URL_IN_MORE") == "True":
item["more"].append(item["csljson"]["URL"])
... | code_fim | hard | {
"lang": "python",
"repo": "maxharp3r/zotero-to-html",
"path": "/bib2html.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maxharp3r/zotero-to-html path: /bib2html.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# global imports
import argparse
from HTMLParser import HTMLParser
import json
import os
from pyquery import PyQuery
import pystache
import re
import sys
# local imports
import env
logger = env.logger()
p... | code_fim | hard | {
"lang": "python",
"repo": "maxharp3r/zotero-to-html",
"path": "/bib2html.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def emit_html(zotero_json):
current_year = 0
for item in zotero_json:
# emit a year template when we encounter a new one
year = int(item["meta"]["parsedDate"][:4]) if "parsedDate" in item["meta"] else "Unknown Publication Date"
if year and year != current_year:
... | code_fim | hard | {
"lang": "python",
"repo": "maxharp3r/zotero-to-html",
"path": "/bib2html.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ccgcyber/ztag path: /ztag/annotations/FtpTypesoftFtpd.py
import re
from ztag.annotation import Annotation
from ztag.annotation import OperatingSystem
from ztag import protocols
import ztag.test
class FtpTypesoftFtpd(Annotation):
protocol = protocols.FTP
subprotocol = protocols.FTP.BANNE... | code_fim | hard | {
"lang": "python",
"repo": "ccgcyber/ztag",
"path": "/ztag/annotations/FtpTypesoftFtpd.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return meta
""" Tests
"220 TYPSoft FTP Server 1.10 ready...\r\n"
"220 TYPSoft FTP Server 1.11 ready...\r\n"
"220 TYPSoft FTP Server 1.10 ready...\r\n"
"220 TYPSoft FTP Server 1.10 ready...\r\n"
"220 TYPSoft FTP Server 1.10 ready...\r\n"
"220 TYPSoft FTP Server 1.10... | code_fim | medium | {
"lang": "python",
"repo": "ccgcyber/ztag",
"path": "/ztag/annotations/FtpTypesoftFtpd.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Let the robot stabilize first
for i in range(1000):
self.env.step(no_op)
position, orientation = p.getBasePositionAndOrientation(self.env.robot)
with self.subTest('no action'):
for i in range(10):
self.env.step(no_op)
new_pos, new_or = p.getBasePositionAndOri... | code_fim | hard | {
"lang": "python",
"repo": "WPI-MMR/gym_solo",
"path": "/gym_solo/envs/test_solo8v2vanilla.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WPI-MMR/gym_solo path: /gym_solo/envs/test_solo8v2vanilla.py
import unittest
from gym.spaces import space
from gym_solo.envs import solo8v2vanilla as solo_env
from gym_solo.core import obs as solo_obs
from gym_solo.testing import CompliantObs
from gym_solo.testing import SimpleReward
from gym_s... | code_fim | hard | {
"lang": "python",
"repo": "WPI-MMR/gym_solo",
"path": "/gym_solo/envs/test_solo8v2vanilla.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@login_not_required
@no_csrf
def editar(_resp, dic_selecionada=None):
_resp.write('oiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii')
return TemplateResponse(template_path='dicas/editar.html')
@login_not_required
@no_csrf
def salvar(_resp, **propriedade):
ctx = propriedade
_resp.write(ctx)
pr... | code_fim | medium | {
"lang": "python",
"repo": "analurandis/WebTurismo",
"path": "/backend/appengine/routes/dicas/editar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@login_not_required
@no_csrf
def pesquisar(estado_selecionado):
ctx={'salvar_path': router.to_path(salvar)}
if estado_selecionado is None:
ctx['cidade']='Selecione um estado'
ctx['estado_selecionado'] = None
else:
ctx['estado_selecionado'] = Estado.get_by_id(int(estad... | code_fim | hard | {
"lang": "python",
"repo": "analurandis/WebTurismo",
"path": "/backend/appengine/routes/dicas/editar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: analurandis/WebTurismo path: /backend/appengine/routes/dicas/editar.py
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals
from google.appengine.ext import ndb
from config.template_middleware import TemplateResponse
from gaepermission.decorator import login_not_requir... | code_fim | hard | {
"lang": "python",
"repo": "analurandis/WebTurismo",
"path": "/backend/appengine/routes/dicas/editar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mirachan010/at-vim-coder path: /python3/tex_handler.py
import re
class AVCTexHandler:
def __init__(self):
self._conv_table = [
(re.compile(r'\\frac\{.+\}'), self._frac_to_slash),
(re.compile(r'_\{[0-9aeijoruvx+-=()]+\}|_[0-9aeijoruvx+-=()]'), self._underscore_to_subscript),
(re.co... | code_fim | hard | {
"lang": "python",
"repo": "mirachan010/at-vim-coder",
"path": "/python3/tex_handler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> original_text = matchobj.group(0)
return original_text.translate(self._subscript_table)
def _caret_to_superscript(self, matchobj):
original_text = matchobj.group(0)
return original_text.translate(self._superscript_table)
def _mbox_to_text(self, matchobj):
mbox_text = re.search(r'\{.+\}', mat... | code_fim | hard | {
"lang": "python",
"repo": "mirachan010/at-vim-coder",
"path": "/python3/tex_handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> var_tags = section.find_all('var')
for var_tag in var_tags:
if var_tag != [] and not self._exclude_pattern.match(var_tag.text):
for tex_expression in self._conv_table:
if tex_expression[0].search(var_tag.text):
var_tag.string = tex_expression[0].sub(tex_expression[1], var_tag.text)
... | code_fim | hard | {
"lang": "python",
"repo": "mirachan010/at-vim-coder",
"path": "/python3/tex_handler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: christopher-demarco/exercism-exercises path: /python/hamming/hamming.py
#!/usr/bin/env python
def distance(strandA, strandB):
<|fim_suffix|>if __name__ == '__main__':
print distance('ABC','ABC')<|fim_middle|> return len(
[ a for a, b in zip(
[i for i in strandA], [i fo... | code_fim | medium | {
"lang": "python",
"repo": "christopher-demarco/exercism-exercises",
"path": "/python/hamming/hamming.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
print distance('ABC','ABC')<|fim_prefix|># repo: christopher-demarco/exercism-exercises path: /python/hamming/hamming.py
#!/usr/bin/env python
def distance(strandA, strandB):
<|fim_middle|> return len(
[ a for a, b in zip(
[i for i in strandA], [i fo... | code_fim | medium | {
"lang": "python",
"repo": "christopher-demarco/exercism-exercises",
"path": "/python/hamming/hamming.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AccentDesign/wagtailstreamforms path: /wagtailstreamforms/streamfield.py
from django.core.exceptions import ImproperlyConfigured
from wagtail.core import blocks
from wagtail.core.fields import StreamField
from wagtailstreamforms.fields import BaseField, get_fields
class FormFieldStreamBlock(bl... | code_fim | hard | {
"lang": "python",
"repo": "AccentDesign/wagtailstreamforms",
"path": "/wagtailstreamforms/streamfield.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def child_blocks(self):
return self._child_blocks
@property
def dependencies(self):
return self._dependencies
class FormFieldsStreamField(StreamField):
def __init__(self, block_types, **kwargs):
super().__init__(block_types, **kwargs)
self.s... | code_fim | hard | {
"lang": "python",
"repo": "AccentDesign/wagtailstreamforms",
"path": "/wagtailstreamforms/streamfield.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ulule/pybbm path: /tests/models/test_models.py
import os
import requests
from pybb.models import Moderator, Post, Forum, Topic
from tests.base import TestCase
from pybb.compat import get_user_model
from mock import patch, PropertyMock
from guardian.models import UserObjectPermission
class Mo... | code_fim | hard | {
"lang": "python",
"repo": "ulule/pybbm",
"path": "/tests/models/test_models.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> original_parent.refresh_from_db(fields=('forum_ids', 'forum'))
forum.refresh_from_db(fields=('forum_ids', 'forum'))
topic.refresh_from_db(fields=('forum_ids', 'forum'))
assert original_parent.forum_id is None
assert original_parent.forum_ids == []
assert f... | code_fim | hard | {
"lang": "python",
"repo": "ulule/pybbm",
"path": "/tests/models/test_models.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>if not path.exists(parameters['home']):
logging.info("Creating home directory")
makedirs((parameters['home']))
def parse_arguments(argv):
parser = OptionParser()
parser.add_option("-v", "--verbose",
action="store_true", dest="verbose", default=False,
... | code_fim | hard | {
"lang": "python",
"repo": "sethkontny/cutecoin",
"path": "/src/cutecoin/core/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sethkontny/cutecoin path: /src/cutecoin/core/config.py
'''
Created on 7 févr. 2014
@author: inso
'''
import logging
from logging import FileHandler
from optparse import OptionParser
from os import environ, path, makedirs
if "XDG_CONFIG_HOME" in environ:
config_path = environ["XDG_CONFIG_H... | code_fim | hard | {
"lang": "python",
"repo": "sethkontny/cutecoin",
"path": "/src/cutecoin/core/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.