text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: Chaos-Monkey-Island/sawtooth-next-directory path: /tests/unit/server/search_api_tests.py
# Copyright 2019 Contributors to Hyperledger Sawtooth
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a ... | code_fim | hard | {
"lang": "python",
"repo": "Chaos-Monkey-Island/sawtooth-next-directory",
"path": "/tests/unit/server/search_api_tests.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test validate_search_payload works with a good payload."""
payload = {"search_input": "The input", "search_object_types": []}
result = validate_search_payload(payload)
assert result == {}
def test_validate_search_no_query():
"""Test validation of an empty value for search query.""... | code_fim | hard | {
"lang": "python",
"repo": "Chaos-Monkey-Island/sawtooth-next-directory",
"path": "/tests/unit/server/search_api_tests.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JazzikPeng/Algorithm-in-Python path: /92. Reverse Linked List II.py
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def reverseBetween(self, head: ListNode, m: int, n: int) -> ListNode:
... | code_fim | hard | {
"lang": "python",
"repo": "JazzikPeng/Algorithm-in-Python",
"path": "/92. Reverse Linked List II.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> t = p1
while t.next:
t = t.next
t.next = p2
if p1.val == 'head':
return p1.next
return head
def reverse(self, head):
prev = None
while head:
next = head.next
head.next = prev
... | code_fim | hard | {
"lang": "python",
"repo": "JazzikPeng/Algorithm-in-Python",
"path": "/92. Reverse Linked List II.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Aliases for ctypes bindings
SDL_GetTicks = _ctypes["SDL_GetTicks"]
SDL_GetTicks64 = _ctypes["SDL_GetTicks64"]
SDL_GetPerformanceCounter = _ctypes["SDL_GetPerformanceCounter"]
SDL_GetPerformanceFrequency = _ctypes["SDL_GetPerformanceFrequency"]
SDL_Delay = _ctypes["SDL_Delay"]
SDL_AddTimer = _ctypes["S... | code_fim | hard | {
"lang": "python",
"repo": "juso40/bl2sdk_Mods",
"path": "/blimgui/dist/sdl2/timer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juso40/bl2sdk_Mods path: /blimgui/dist/sdl2/timer.py
from ctypes import CFUNCTYPE, c_void_p, c_int
from .dll import _bind, SDLFunc, AttributeDict
from .stdinc import Uint32, Uint64, SDL_bool
__all__ = [
# Defines
"SDL_TimerID",
# Macro Functions
"SDL_TICKS_PASSED",
# Callba... | code_fim | hard | {
"lang": "python",
"repo": "juso40/bl2sdk_Mods",
"path": "/blimgui/dist/sdl2/timer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Check merkle proof on received dataref txns
for dataref in [dataref1, dataref2]:
msg = conn.cb.GetDatarefTx(dataref.hash)
calculatedRootHash = merkle_root_from_branch(msg.proof.txOrId, msg.proof.index, [x.value for x in msg.proof.nodes])
... | code_fim | hard | {
"lang": "python",
"repo": "esthon/bitcoin-sv",
"path": "/test/functional/bsv-getdata-datareftx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: esthon/bitcoin-sv path: /test/functional/bsv-getdata-datareftx.py
#!/usr/bin/env python3
# Copyright (c) 2022 Bitcoin Association
# Distributed under the Open BSV software license, see the accompanying file LICENSE.
from test_framework.test_framework import BitcoinTestFramework
from test_framewo... | code_fim | hard | {
"lang": "python",
"repo": "esthon/bitcoin-sv",
"path": "/test/functional/bsv-getdata-datareftx.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> minerids = self.nodes[0].dumpminerids()
assert(len(minerids['miners']) == 1)
assert(len(minerids['miners'][0]['minerids']) == 1)
# Send getdata request for each dataref txn
conn.send_message(msg_getdata([CInv(CInv.DATAREF_TX, dataref1.sha256), C... | code_fim | hard | {
"lang": "python",
"repo": "esthon/bitcoin-sv",
"path": "/test/functional/bsv-getdata-datareftx.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> args = []
settings = json.loads(EnvironmentSettings.read_setting_from_file())
beakerx_settings = settings['beakerx']
if 'jvm_options' in beakerx_settings:
jvm_settings = beakerx_settings['jvm_options']
for x in jvm_settings['other']:
... | code_fim | hard | {
"lang": "python",
"repo": "splicemachine/beakerx",
"path": "/beakerx/beakerx/environment.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def read_setting_from_file():
try:
file = open(EnvironmentSettings.config_path, 'r')
content = file.read()
beakerx_settings = json.loads(content)
if beakerx_settings['beakerx'].get('version') is None:
content = E... | code_fim | hard | {
"lang": "python",
"repo": "splicemachine/beakerx",
"path": "/beakerx/beakerx/environment.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: splicemachine/beakerx path: /beakerx/beakerx/environment.py
# Copyright 2017 TWO SIGMA OPEN SOURCE, LLC
#
# 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": "splicemachine/beakerx",
"path": "/beakerx/beakerx/environment.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def render_to_response(self, context, **response_kwargs):
if context.get('params'): # for django 1.4 compatibility
context = context['params']
if not context.get('router'):
raise ValueError('router param missing')
maker = ModelMaker(context['router'], c... | code_fim | medium | {
"lang": "python",
"repo": "vepkenez/rest2backbone",
"path": "/rest2backbone/views.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vepkenez/rest2backbone path: /rest2backbone/views.py
from django.views.generic import TemplateView
from api import ModelMaker
from django.utils.safestring import SafeString
<|fim_suffix|> template_name = 'rest2backbone/api.js'
def render_to_response(self, context, **response_kwargs):... | code_fim | medium | {
"lang": "python",
"repo": "vepkenez/rest2backbone",
"path": "/rest2backbone/views.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jedicontributors/pythondataintegrator path: /src/scheduler/rpc/SchedulerService.py
from apscheduler.triggers.cron import CronTrigger
from IocManager import IocManager
import rpyc
from rpyc.utils.server import ThreadedServer
from models.configs.SchedulerRpcServerConfig import SchedulerRpcServerC... | code_fim | hard | {
"lang": "python",
"repo": "jedicontributors/pythondataintegrator",
"path": "/src/scheduler/rpc/SchedulerService.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.job_scheduler.resume_job(job_id, jobstore)
def exposed_remove_job(self, job_id, jobstore=None):
self.job_scheduler.remove_job(job_id, jobstore)
def exposed_get_job(self, job_id):
return self.job_scheduler.get_job(job_id)
def exposed_get_jobs(self, jobstor... | code_fim | hard | {
"lang": "python",
"repo": "jedicontributors/pythondataintegrator",
"path": "/src/scheduler/rpc/SchedulerService.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.job_scheduler.pause_job(job_id, jobstore)
def exposed_resume_job(self, job_id, jobstore=None):
return self.job_scheduler.resume_job(job_id, jobstore)
def exposed_remove_job(self, job_id, jobstore=None):
self.job_scheduler.remove_job(job_id, jobstore)
def ... | code_fim | hard | {
"lang": "python",
"repo": "jedicontributors/pythondataintegrator",
"path": "/src/scheduler/rpc/SchedulerService.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='PurchaseOrder',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('reference', models.CharField(help_text='Order reference', max_lengt... | code_fim | hard | {
"lang": "python",
"repo": "inventree/InvenTree",
"path": "/InvenTree/order/migrations/0001_initial.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: inventree/InvenTree path: /InvenTree/order/migrations/0001_initial.py
# Generated by Django 2.2 on 2019-06-04 12:17
from django.conf import settings
import django.core.validators
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
... | code_fim | hard | {
"lang": "python",
"repo": "inventree/InvenTree",
"path": "/InvenTree/order/migrations/0001_initial.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
ORCHESTRATION_SSH_KEY_PATH = Setting('ORCHESTRATION_SSH_KEY_PATH',
path.join(path.expanduser('~'), '.ssh/id_rsa')
)
ORCHESTRATION_ROUTER = Setting('ORCHESTRATION_ROUTER',
'orchestra.contrib.orchestration.models.Route',
validators=[Setting.validate_import_class]
)
ORCHESTRATION_DISABLE_EX... | code_fim | medium | {
"lang": "python",
"repo": "Ro9ueAdmin/django-orchestra",
"path": "/orchestra/contrib/orchestration/settings.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ro9ueAdmin/django-orchestra path: /orchestra/contrib/orchestration/settings.py
from os import path
from django.utils.translation import ugettext_lazy as _
from orchestra.contrib.settings import Setting
ORCHESTRATION_OS_CHOICES = Setting('ORCHESTRATION_OS_CHOICES',
(
('LINUX', "Lin... | code_fim | hard | {
"lang": "python",
"repo": "Ro9ueAdmin/django-orchestra",
"path": "/orchestra/contrib/orchestration/settings.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gmolveau/flask-sqlalchemy-heroku path: /app/models/post.py
from ..database import db
class Post(db.Model):
__tablename__ = 'posts'
id = db.Column(db.Integer, primary_key=True)
url = db.Column(db.String, nu<|fim_suffix|>)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), ... | code_fim | medium | {
"lang": "python",
"repo": "gmolveau/flask-sqlalchemy-heroku",
"path": "/app/models/post.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>llable=False, unique=True)
description = db.Column(db.String, nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('users.id'), nullable=False)<|fim_prefix|># repo: gmolveau/flask-sqlalchemy-heroku path: /app/models/post.py
from ..database import db
class Post(db.Model):
__tablename... | code_fim | medium | {
"lang": "python",
"repo": "gmolveau/flask-sqlalchemy-heroku",
"path": "/app/models/post.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tyrylu/pyfmodex path: /pyfmodex/reverb_presets.py
"""FMOD reverb presets."""
# pylint: disable=invalid-name
# Just staying close to the original names here.
from enum import Enum
from .dsp import DSP
from .enums import DSP_TYPE
class REVERB_PRESET(Enum):
"""Predefined reverb configuratio... | code_fim | hard | {
"lang": "python",
"repo": "tyrylu/pyfmodex",
"path": "/pyfmodex/reverb_presets.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #: Plain
PLAIN = (1500, 179, 100, 5000, 50, 21, 100, 250, 0, 1670, 65, -28.0)
#: Parking lot
PARKINGLOT = (1700, 8, 12, 5000, 100, 100, 100, 250, 0, 20000, 56, -19.5)
#: Sewer pipe
SEWERPIPE = (2800, 14, 21, 5000, 14, 80, 60, 250, 0, 3400, 66, -1.2)
#: Underwater
UNDERWA... | code_fim | hard | {
"lang": "python",
"repo": "tyrylu/pyfmodex",
"path": "/pyfmodex/reverb_presets.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vikasnayak123/Banking-System path: /queue.py
def prPurple(skk): print("\033[95m {}\033[00m" .format(skk))
class Queue:
def __init__(self):
self.front=-1
self.rear=-1
self.l=[]
"""def toFile(self,date,parti,trans,amt,bal):
file=open("Bank.txt","w")
file.write("\n Date:")
file.wri... | code_fim | medium | {
"lang": "python",
"repo": "vikasnayak123/Banking-System",
"path": "/queue.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
print("hi")
q=Queue()
q.enqueue(1,2,3,4)
q.enqueue(11,22,33,44)
q.enqueue(111,222,333,444)
#print(q.l)
print(q.dequeue())
#print("!!!!")
if __name__ == '__main__':
main()<|fim_prefix|># repo: vikasnayak123/Banking-System path: /queue.py
def prPurple(skk): print("\033[95m {}\033[00m"... | code_fim | hard | {
"lang": "python",
"repo": "vikasnayak123/Banking-System",
"path": "/queue.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vinayak1998/Devnagari-Character-Recognition path: /script.py
import tensorflow as tf
import numpy as np
import time
import pandas as pd
import keras
from keras import Sequential
from keras.models import Model
from keras.layers import *
from keras.optimizers import RMSprop
from keras.callbacks imp... | code_fim | hard | {
"lang": "python",
"repo": "vinayak1998/Devnagari-Character-Recognition",
"path": "/script.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>X_train_new /= 255
X_test_new /= 255
num_category = 46
y_train = keras.utils.to_categorical(Y_train, num_category)
input_shape = (32, 32, 1)
model = Sequential()
model.add(Conv2D(32, kernel_size=(5, 5),
activation='relu',
input_shape=input_shape))
model.add(Conv2D(64, (3... | code_fim | hard | {
"lang": "python",
"repo": "vinayak1998/Devnagari-Character-Recognition",
"path": "/script.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Y_train = tr_data[0].values
del tr_data[0]
X_train = tr_data.values
del test_data[0]
X_test = test_data.values
X_train_new = np.zeros((len(X_train), 32, 32, 1))
for i in range(len(X_train)):
if i % 1000 == 0:
print(i)
for a in range(32):
for b in range(32):
X_train_... | code_fim | hard | {
"lang": "python",
"repo": "vinayak1998/Devnagari-Character-Recognition",
"path": "/script.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenMath/py-scscp path: /scscp/cli.py
import socket
from openmath import convert, openmath as om
from .client import SCSCPClient
from . import scscp
def _conv_if_py(obj):
if isinstance(obj, om.OMAny):
return obj
else:
return convert.to_openmath(obj)
class SCSCPCLI(SCSCPC... | code_fim | hard | {
"lang": "python",
"repo": "OpenMath/py-scscp",
"path": "/scscp/cli.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _call_wait(self, data, cookie=False, timeout=-1, **opts):
call = self.call(data, cookie, **opts)
resp = self.wait(timeout)
if resp.id != call.id:
raise scscp.SCSCPProtocolError("Wrong call id (expected %s, got %s)."
... | code_fim | hard | {
"lang": "python",
"repo": "OpenMath/py-scscp",
"path": "/scscp/cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
for symbol in heads.data.arguments:
if isinstance(symbol, om.OMSymbol):
self.heads._get_cd(symbol.cd)._get_head(symbol.name)
elif symbol.elem.name == 'CDName':
self.heads._get_cd(symbol.arguments[0].string)
... | code_fim | hard | {
"lang": "python",
"repo": "OpenMath/py-scscp",
"path": "/scscp/cli.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tyfo = Blueprint("tyfo", __name__)
tyfo_api = Api(tyfo)
tyfo_api.add_resource(view.FilterUserView, "/api/portrait/filter_user")<|fim_prefix|># repo: iceihehe/flask-demos path: /app/blueprint/tyfo/__init__.py
# -*- coding = utf-8 -*-
from flask import Blueprint
from flask_restful import Api
<|fim_middle... | code_fim | easy | {
"lang": "python",
"repo": "iceihehe/flask-demos",
"path": "/app/blueprint/tyfo/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iceihehe/flask-demos path: /app/blueprint/tyfo/__init__.py
# -*- coding = utf-8 -*-
from flask import Blueprint
from flask_restful import Api
<|fim_suffix|>tyfo = Blueprint("tyfo", __name__)
tyfo_api = Api(tyfo)
tyfo_api.add_resource(view.FilterUserView, "/api/portrait/filter_user")<|fim_middle... | code_fim | easy | {
"lang": "python",
"repo": "iceihehe/flask-demos",
"path": "/app/blueprint/tyfo/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fos/fos-legacy path: /scratch/nbgl2/setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
<|fim_suffix|>setup(
name = 'nbgl',
ext_modules = cythonize(ext_modules),
)<|fim_middle|>ext_modules = [
Extension("FosWindow", ["Fos... | code_fim | hard | {
"lang": "python",
"repo": "fos/fos-legacy",
"path": "/scratch/nbgl2/setup.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>setup(
name = 'nbgl',
ext_modules = cythonize(ext_modules),
)<|fim_prefix|># repo: fos/fos-legacy path: /scratch/nbgl2/setup.py
from distutils.core import setup
from distutils.extension import Extension
from Cython.Build import cythonize
<|fim_middle|>ext_modules = [
Extension("FosWindow", ["Fos... | code_fim | hard | {
"lang": "python",
"repo": "fos/fos-legacy",
"path": "/scratch/nbgl2/setup.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pachyderm/pachyderm path: /examples/joins/src/inner/main.py
#!/usr/local/bin/python3
import glob, json, os, shutil, sys
store_id = str(os.environ.get('PACH_DATUM_stores_JOIN_ON'))
store_path = os.path.join("/pfs/stores","STOREID"+store_id+".txt")
purchase_path = glob.glob(os.path.join("/pfs/p... | code_fim | hard | {
"lang": "python",
"repo": "pachyderm/pachyderm",
"path": "/examples/joins/src/inner/main.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Appending : " + purchase_path + " to:" + "/pfs/out/"+zipcode+".txt")
# Copy the content of the purchase file into the text file
with open(purchase_path, 'r') as purchase_file:
location_file.write(purchase_file.read())<|fim_prefix|># repo: pachyderm/pachyderm pa... | code_fim | hard | {
"lang": "python",
"repo": "pachyderm/pachyderm",
"path": "/examples/joins/src/inner/main.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
_CIPDSETTINGS = _descriptor.Descriptor(
name='CipdSettings',
full_name='swarming.config.CipdSettings',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='default_server', full_name='swarmin... | code_fim | hard | {
"lang": "python",
"repo": "luci/luci-py",
"path": "/appengine/swarming/proto/config/config_pb2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: luci/luci-py path: /appengine/swarming/proto/config/config_pb2.py
\x1b\n\x13view_all_bots_group\x18\x05 \x01(\t\x12\x1c\n\x14view_all_tasks_group\x18\x06 \x01(\t\x12\x44\n\x1a\x65nforced_realm_permissions\x18\x07 \x03(\x0e\x32 .swarming.config.RealmPermission\"\"\n\x10ResultDBSettings\x12\x0e\n\x... | code_fim | hard | {
"lang": "python",
"repo": "luci/luci-py",
"path": "/appengine/swarming/proto/config/config_pb2.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>_CIPDSETTINGS = _descriptor.Descriptor(
name='CipdSettings',
full_name='swarming.config.CipdSettings',
filename=None,
file=DESCRIPTOR,
containing_type=None,
create_key=_descriptor._internal_create_key,
fields=[
_descriptor.FieldDescriptor(
name='default_server', full_name='swarming... | code_fim | hard | {
"lang": "python",
"repo": "luci/luci-py",
"path": "/appengine/swarming/proto/config/config_pb2.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@mod_auth.route('/refresh_token/', methods=['GET', 'POST'])
def refresh_token():
refresh_token = session.get('refresh_token')
if not refresh_token:
return redirect('/')
SPOTIFY_TOKEN_URL = 'https://accounts.spotify.com/api/token'
token_response = requests.post(SPOTIFY_TOKEN_URL, {
... | code_fim | hard | {
"lang": "python",
"repo": "marcobocc/spotify-stats",
"path": "/app/mod_auth/controllers.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> refresh_token = session.get('refresh_token')
if not refresh_token:
return redirect('/')
SPOTIFY_TOKEN_URL = 'https://accounts.spotify.com/api/token'
token_response = requests.post(SPOTIFY_TOKEN_URL, {
'client_id' : current_app.config['SPOTIFY_CLIENT_ID'],
'client_se... | code_fim | hard | {
"lang": "python",
"repo": "marcobocc/spotify-stats",
"path": "/app/mod_auth/controllers.py",
"mode": "spm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marcobocc/spotify-stats path: /app/mod_auth/controllers.py
from flask import Blueprint, request, redirect, session, current_app
import requests
import urllib.parse
mod_auth = Blueprint('auth', __name__, url_prefix='/auth')
@mod_auth.route('/signin/', methods=['GET', 'POST'])
def signin():
#... | code_fim | hard | {
"lang": "python",
"repo": "marcobocc/spotify-stats",
"path": "/app/mod_auth/controllers.py",
"mode": "psm",
"license": "LicenseRef-scancode-warranty-disclaimer",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('%s %s' % (uni, team))
unis.add(uni)
count += 1<|fim_prefix|># repo: JaredLGillespie/OpenKattis path: /Python/icpcawards.py
# https://open.kattis.com/problems/icpcawards
<|fim_middle|>n = int(input())
unis = set()
count = 0
for _ in range(n):
uni, team = input().split()
if cou... | code_fim | medium | {
"lang": "python",
"repo": "JaredLGillespie/OpenKattis",
"path": "/Python/icpcawards.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JaredLGillespie/OpenKattis path: /Python/icpcawards.py
# https://open.kattis.com/problems/icpcawards
<|fim_suffix|> print('%s %s' % (uni, team))
unis.add(uni)
count += 1<|fim_middle|>n = int(input())
unis = set()
count = 0
for _ in range(n):
uni, team = input().split()
if cou... | code_fim | medium | {
"lang": "python",
"repo": "JaredLGillespie/OpenKattis",
"path": "/Python/icpcawards.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not run_set.columns.tolist(): # if the subset of peak1 and peak2 is empty after dropping any where all = na
# print('WARNING - LOG ME')
continue
peaks1 = run_set['peak1'].values.tolist() # column of peaks, ordered 1,3,5,7,9
peaks2 = run_set['peak2'].va... | code_fim | hard | {
"lang": "python",
"repo": "ARLlab/Summit",
"path": "/processors/picarro_testing/read_methaneQC.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for ind in indices:
if ind % 5 is not 0:
date = data.loc[ind, 'date']
filename = data.loc[ind, 'filename']
print(f'File {filename} for run {date} did not have the proper number of lines to analyze.') # can't happen
indices = [i for i in indices if i % ... | code_fim | hard | {
"lang": "python",
"repo": "ARLlab/Summit",
"path": "/processors/picarro_testing/read_methaneQC.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ARLlab/Summit path: /processors/picarro_testing/read_methaneQC.py
# Import Libraries
import pandas as pd
import matplotlib.pylab as plt
def check_cols_methane(name):
"""
Mini Function passed to pd.read_excel(usecols=function)
:return: Returns True for columns 22, 27, and 29
"""
... | code_fim | hard | {
"lang": "python",
"repo": "ARLlab/Summit",
"path": "/processors/picarro_testing/read_methaneQC.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @abstractmethod
def getAllLinks(self, result, func):
"""
获取动漫的全部链接
:param result: 由detail()函数获取的结果 如: {1: ['第1集', 'url'], 2: ['第2集', 'url']}
:param func: 打印日志函数
:return: 不返回值,直接把链接保存到文本中
"""
pass
pass<|fim_prefix|># repo: AstraiaQ/AnimeAr... | code_fim | hard | {
"lang": "python",
"repo": "AstraiaQ/AnimeArtifactPro",
"path": "/Utils/CrawlUtil.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @abstractmethod
def detail(self, func, url):
"""
获取动漫的详情信息
详情信息指总共多少集和每一集的播放地址
:param url: 动漫的url 如:http://susudm.com/acg/2130/
:param func: 打印日志函数
:return: 详情信息
{
1: ['第1集'.'第1集的url'], 这里的 “第1集的url” 可以是存放url链接的json文件,也可以是真实的播放链... | code_fim | hard | {
"lang": "python",
"repo": "AstraiaQ/AnimeArtifactPro",
"path": "/Utils/CrawlUtil.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AstraiaQ/AnimeArtifactPro path: /Utils/CrawlUtil.py
from abc import abstractmethod
class CrawlUtil:
"""
接口规范:
不管接口内部是怎么实现的,
总之,要提供外部这样的实现
"""
@abstractmethod
def search(self, searchword):
"""
使用接口查询searchword
:param searchword: 关键词
:r... | code_fim | hard | {
"lang": "python",
"repo": "AstraiaQ/AnimeArtifactPro",
"path": "/Utils/CrawlUtil.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexandergagliano/grackle path: /src/python/examples/steadyState_Waternet.py
.e3)
pyplot.ylim(ymin=1.e-17)
pyplot.legend(loc='best',fontsize=4)
pyplot.savefig("metal_convergence_t%iGyr_N%i_Z%i_UMIST.pdf" %(int(np.log10(final_time/1.e3)),N_pts, np.log10(metallicity[i])),... | code_fim | hard | {
"lang": "python",
"repo": "alexandergagliano/grackle",
"path": "/src/python/examples/steadyState_Waternet.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> fc["x-velocity"][:] = 0.0
fc["y-velocity"][:] = 0.0
fc["z-velocity"][:] = 0.0
fc.calculate_hydrogen_number_density()
# then begin collapse
# evolve density and temperature according to free-fall collapse
data = evolve_freefall_metal(fc, fin... | code_fim | hard | {
"lang": "python",
"repo": "alexandergagliano/grackle",
"path": "/src/python/examples/steadyState_Waternet.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexandergagliano/grackle path: /src/python/examples/steadyState_Waternet.py
nits)), label ='XH', color='orange')
pyplot.xlabel("Time (s)",fontsize=22)
pyplot.ylabel("Xi",fontsize=22)
pyplot.title("Convergence plot for [Z/H] = %i" % np.log10(metallicity[i]));
p... | code_fim | hard | {
"lang": "python",
"repo": "alexandergagliano/grackle",
"path": "/src/python/examples/steadyState_Waternet.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Create private key file
create_private_key()
""" - Take out the git stuff it only benefits developers and it isn't implemented securely enough
as it currently stands
# ask for git config info
print('To setup your git username... | code_fim | hard | {
"lang": "python",
"repo": "ferguman/fopd",
"path": "/fopd_init.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ferguman/fopd path: /fopd_init.py
# This program iniailizes a mender based fopd system. It does the following:
# Check to see if there a hostname specifed in the /data/fopd/hostname file. If there is then
# it changes the hostname using the value found in this file. If there is no /data/fopd/host... | code_fim | hard | {
"lang": "python",
"repo": "ferguman/fopd",
"path": "/fopd_init.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bingwin/Django path: /Slackers/init_db_data.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Slackers.settings')
import django
django.setup()
import json
import argparse
import random
import datetime
import codecs
import os.path as o... | code_fim | hard | {
"lang": "python",
"repo": "bingwin/Django",
"path": "/Slackers/init_db_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> parser = argparse.ArgumentParser()
parser.add_argument("data", help=u"你要生成的数据")
args = parser.parse_args()
if args.data == 'all':
init_reader_data()
init_book_data()
elif args.data == 'book':
init_book_data()
elif args.data == 'reader':
init_reader_... | code_fim | hard | {
"lang": "python",
"repo": "bingwin/Django",
"path": "/Slackers/init_db_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Roopam-official/Calculator path: /main.py
# Configuring Kivy (sets unmutable Window size and removing maximize/minimize button)
from kivy.config import Config
Config.set('graphics', 'width', '350')
Config.set('graphics', 'height', '500')
Config.set('graphics', 'resizable', 0)
# Main Imports
from... | code_fim | hard | {
"lang": "python",
"repo": "Roopam-official/Calculator",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> slide3 = self.root.ids.modes_and_history_carousel.slides[2]
self.root.ids.modes_and_history_carousel.load_slide(slide3)
self.root.ids.top_app_bar.ids.hist_cntrlr.text = u"\U000F15A6" # calculator-variant-outline
def normal_calculator_1(self):
slide1 = self.root.ids.mo... | code_fim | hard | {
"lang": "python",
"repo": "Roopam-official/Calculator",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tijko/gruvi path: /tests/unit.py
#
# This file is part of gruvi. Gruvi is free software available under the
# terms of the MIT license. See the file "LICENSE" that was provided
# together with this source file for the licensing terms.
#
# Copyright (c) 2012-2013 the gruvi authors. See the file "A... | code_fim | hard | {
"lang": "python",
"repo": "tijko/gruvi",
"path": "/tests/unit.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>loader = TestLoader()
tests = loader.discover('.', 'test_*.py')
runner = TextTestRunner(verbosity=1, buffer=True)
runner.run(tests)<|fim_prefix|># repo: tijko/gruvi path: /tests/unit.py
#
# This file is part of gruvi. Gruvi is free software available under the
# terms of the MIT license. See the file "L... | code_fim | medium | {
"lang": "python",
"repo": "tijko/gruvi",
"path": "/tests/unit.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhulingling1995/VMRProject_K_D path: /lib/model/utils/evaluate_test.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import _init_paths
import os
import sys
import numpy as np
import argparse
import pprint
import pdb
import time
impo... | code_fim | hard | {
"lang": "python",
"repo": "zhulingling1995/VMRProject_K_D",
"path": "/lib/model/utils/evaluate_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def load_data(dataset):
if dataset == "pascal_voc":
imdb_name = "voc_2007_trainval"
imdbval_name = "voc_2007_test"
set_cfgs = ['ANCHOR_SCALES', '[8, 16, 32]', 'ANCHOR_RATIOS', '[0.5,1,2]']
elif dataset == "pascal_voc_0712":
imdb_name = "voc_2007_trainval+voc_2012_t... | code_fim | hard | {
"lang": "python",
"repo": "zhulingling1995/VMRProject_K_D",
"path": "/lib/model/utils/evaluate_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kentaroy47/AnomalyDetection.pytorch path: /make_ecg_dataset.py
import os
import numpy as np
import wfdb
# download dataset
dataset_root = './dataset'
download_dir = os.path.join(dataset_root, 'data')
wfdb.dl_database('mitdb', dl_dir=download_dir)
# setting
window_siz... | code_fim | hard | {
"lang": "python",
"repo": "kentaroy47/AnomalyDetection.pytorch",
"path": "/make_ecg_dataset.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Xs, ys = [], []
save_dir = os.path.join(dataset_root)
for i in range(len(record_list)):
signal, symbols, positions = _load_data(record_list[i])
signal = (signal - np.mean(signal)) / np.std(signal)
X, y = _segment_data(signal, symbols, positions)
Xs.append... | code_fim | hard | {
"lang": "python",
"repo": "kentaroy47/AnomalyDetection.pytorch",
"path": "/make_ecg_dataset.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Xana8U/Kipy path: /KipyServer.py
import socketserver
import sqlite3
import time
conn = sqlite3.connect("Messages.db")
c = conn.cursor()
'''Handles connections and returns a data to clients.'''
class TCPhandler(socketserver.BaseRequestHandler):
<|fim_suffix|>if __name__ == "__main__":
host, ... | code_fim | hard | {
"lang": "python",
"repo": "Xana8U/Kipy",
"path": "/KipyServer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == "__main__":
host, port = "192.168.100.10", 5479
with socketserver.TCPServer((host, port), TCPhandler) as server:
server.serve_forever()<|fim_prefix|># repo: Xana8U/Kipy path: /KipyServer.py
import socketserver
import sqlite3
import time
conn = sqlite3.connect("Messages.d... | code_fim | hard | {
"lang": "python",
"repo": "Xana8U/Kipy",
"path": "/KipyServer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pmav99/pyschism path: /pyschism/cmd/fgrid/entry.py
from argparse import Namespace
from pyschism.cmd.fgrid import manning
<|fim_suffix|> def __init__(self, args: Namespace):
if args.action == 'manning':
manning.ManningsNCli(args)
else:
raise NotImple... | code_fim | medium | {
"lang": "python",
"repo": "pmav99/pyschism",
"path": "/pyschism/cmd/fgrid/entry.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fgrid = subparsers.add_parser('fgrid')
# define subparser action
actions = fgrid.add_subparsers(dest='action')
# creating manning
manning.add_manning(actions)
add_fgrid = fgrid_subparser<|fim_prefix|># repo: pmav99/pyschism path: /pyschism/cmd/fgrid/entry.py
from argparse import Nam... | code_fim | hard | {
"lang": "python",
"repo": "pmav99/pyschism",
"path": "/pyschism/cmd/fgrid/entry.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>total_num = len(train_rec_df)
for row in tqdm(train_rec_df.iloc[:].iterrows(), total=total_num):
path = unquote(json.loads(row[1]['原始数据'])['tfspath'])
img_path = "/home/will/dataset/train/" + unquote(path.split('/')[-1])
# print(img_path)
labels = json.loads(row[1]['融合答案'])[0]
orienta... | code_fim | hard | {
"lang": "python",
"repo": "GaoXinJian-USTC/TianChiOCR",
"path": "/tools/generate_crop.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>train = [
"/home/will/dataset/csv/Xeon1OCR_round1_train_20210524.csv",
"/home/will/dataset/csv/Xeon1OCR_round1_train1_20210526.csv",
"/home/will/dataset/csv/Xeon1OCR_round1_train2_20210526.csv",
]
valset_num = 10000
train_rec_df = []
angle_dict = {"底部朝下":0, "底部朝右":270, "底部朝上":180, "底部朝左":90}
random_seed... | code_fim | hard | {
"lang": "python",
"repo": "GaoXinJian-USTC/TianChiOCR",
"path": "/tools/generate_crop.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: GaoXinJian-USTC/TianChiOCR path: /tools/generate_crop.py
import os, sys, json
import cv2
import numpy as np
import math
from PIL import Image, ImageDraw
import os
import json
import numpy as np
import pandas as pd
from urllib.parse import unquote
import random
from tqdm import tqdm
import shutil
... | code_fim | hard | {
"lang": "python",
"repo": "GaoXinJian-USTC/TianChiOCR",
"path": "/tools/generate_crop.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hykilpikonna/hyfetch path: /hyfetch/distros/instantos.py
# This file is automatically generated. Please do not modify.
from . import AsciiArt
<|fim_suffix|>${c1}
'cx0XWWMMWNKOd:'.
.;kNMMMMMMMMMMMMMWNKd'
'kNMMMMMMWNNNWMMMMMMMMXo.
,0MMMMMW0o;'..,:dKWMMMMMWx.
OMMMMMXl. .xNMMMMMNo
WM... | code_fim | medium | {
"lang": "python",
"repo": "hykilpikonna/hyfetch",
"path": "/hyfetch/distros/instantos.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>${c1}
'cx0XWWMMWNKOd:'.
.;kNMMMMMMMMMMMMMWNKd'
'kNMMMMMMWNNNWMMMMMMMMXo.
,0MMMMMW0o;'..,:dKWMMMMMWx.
OMMMMMXl. .xNMMMMMNo
WMMMMNl .kWWMMMMO'
MMMMMX; oNWMMMMK,
NMMMMWo .OWMMMMMK,
kWMMMMNd. ,kWMMMMMMK,
'kWMMMMWXxl:;;:okNMMMMMMMMK,
.oXMMMMMMMWWWMMMMMMMMMM... | code_fim | medium | {
"lang": "python",
"repo": "hykilpikonna/hyfetch",
"path": "/hyfetch/distros/instantos.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: outlyerapp/dlcli path: /dlcli/api/wrapper.py
import requests
session = requests.session()
def get(url, **kwargs):
r = session.get(url, **kwargs)
r.raise_for_status()
return r
def options(url, **kwargs):
<|fim_suffix|>
def delete(url, **kwargs):
r = session.delete(url, **kwargs... | code_fim | hard | {
"lang": "python",
"repo": "outlyerapp/dlcli",
"path": "/dlcli/api/wrapper.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def put(url, data=None, **kwargs):
r = session.put(url, data, **kwargs)
r.raise_for_status()
return r
def patch(url, data=None, **kwargs):
r = session.patch(url, data, **kwargs)
r.raise_for_status()
return r
def delete(url, **kwargs):
r = session.delete(url, **kwargs)
... | code_fim | medium | {
"lang": "python",
"repo": "outlyerapp/dlcli",
"path": "/dlcli/api/wrapper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> r = session.put(url, data, **kwargs)
r.raise_for_status()
return r
def patch(url, data=None, **kwargs):
r = session.patch(url, data, **kwargs)
r.raise_for_status()
return r
def delete(url, **kwargs):
r = session.delete(url, **kwargs)
r.raise_for_status()
return r<|f... | code_fim | hard | {
"lang": "python",
"repo": "outlyerapp/dlcli",
"path": "/dlcli/api/wrapper.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: spacetelescope/jwst path: /jwst/ami/instrument_data.py
#
# Module for defining data format, wavelength info, an mask geometry for these
# instrument: NIRISS AMI
#
import logging
import numpy as np
from .mask_definitions import NRM_mask_definitions
from . import utils
log = logging.getLogger... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/jwst",
"path": "/jwst/ami/instrument_data.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> num = (thru_st_0 * thru_st_1).sum()
den = thru_st[0, :].sum()
self.lam_c[self.filt] = num / den
area = simps(thru_st_0, thru_st_1)
ew = area / thru_st_0.max() # equivalent width
beta = ew / self.lam_c[self.filt] # fractional bandpass
self.lam_w[s... | code_fim | hard | {
"lang": "python",
"repo": "spacetelescope/jwst",
"path": "/jwst/ami/instrument_data.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def choices(values, delimiter="|"):
return delimiter.join(values)<|fim_prefix|># repo: IL2HorusTeam/il2fb-commons path: /il2fb/commons/regex.py
"""Regex primitives."""
import re
ANYTHING = r".+"
WHITESPACE = r"\s"
WHITESPACES = r"{0}+".format(WHITESPACE)
NON_WHITESPACE = r"\S"
NON_WHITESPACES = r"{... | code_fim | hard | {
"lang": "python",
"repo": "IL2HorusTeam/il2fb-commons",
"path": "/il2fb/commons/regex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IL2HorusTeam/il2fb-commons path: /il2fb/commons/regex.py
"""Regex primitives."""
import re
ANYTHING = r".+"
WHITESPACE = r"\s"
WHITESPACES = r"{0}+".format(WHITESPACE)
NON_WHITESPACE = r"\S"
NON_WHITESPACES = r"{0}+".format(NON_WHITESPACE)
DIGIT = r"\d"
NUMBER = r"{0}+".format(DIGIT)
FLOAT = r... | code_fim | medium | {
"lang": "python",
"repo": "IL2HorusTeam/il2fb-commons",
"path": "/il2fb/commons/regex.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def teardown_cluster(args):
provision_args = ['python',
args.zdutil,
'-c',
args.config_file,
'-a'
'teardown',
'-f']
block_and_check_process_output(provision_args)
de... | code_fim | hard | {
"lang": "python",
"repo": "zulily/zdutil",
"path": "/script_runner/script_runner.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not os.path.isfile(args.zdutil):
print 'Cannot find zdutil.py at: {}'.format(args.zdutil)
exit(1)
if os.path.basename(args.zdutil) != 'zdutil.py':
print 'Cannot find zdutil.py at: {}'.format(args.zdutil)
exit(1)
args = parse_command_line_args()
validate_zdutil(... | code_fim | hard | {
"lang": "python",
"repo": "zulily/zdutil",
"path": "/script_runner/script_runner.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zulily/zdutil path: /script_runner/script_runner.py
# example usage:
# python script_runner.py -c cluster_config -z <path_to_zdutil> -s <path_to_script1>,<path_to_script2>
import argparse
from subprocess import Popen
import os
def block_and_check_process_output(process_args,
... | code_fim | hard | {
"lang": "python",
"repo": "zulily/zdutil",
"path": "/script_runner/script_runner.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: acelectic/pythainlp path: /pythainlp/util/__init__.py
# -*- coding: utf-8 -*-
from nltk.util import ngrams as ngramsdata
def ngrams(token,num):
'''
ngrams สร้าง ngrams
ngrams(token,num)
- token คือ list
- num คือ จำนวน ngrams
'''
return ngramsdata(token,int(num))
def bigrams(sequence):
<|... | code_fim | medium | {
"lang": "python",
"repo": "acelectic/pythainlp",
"path": "/pythainlp/util/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''
Trigram สร้าง trigram
trigram(token)
- token คือ list
'''
return ngrams(token,3)<|fim_prefix|># repo: acelectic/pythainlp path: /pythainlp/util/__init__.py
# -*- coding: utf-8 -*-
from nltk.util import ngrams as ngramsdata
def ngrams(token,num):
'''
ngrams สร้าง ngrams
ngrams(token,num)
- ... | code_fim | medium | {
"lang": "python",
"repo": "acelectic/pythainlp",
"path": "/pythainlp/util/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
bigrams ใน Python
bigrams(sequence)
"""
return ngrams(sequence,2)
def trigram(token):
'''
Trigram สร้าง trigram
trigram(token)
- token คือ list
'''
return ngrams(token,3)<|fim_prefix|># repo: acelectic/pythainlp path: /pythainlp/util/__init__.py
# -*- coding: utf-8 -*-
from nltk.util impo... | code_fim | medium | {
"lang": "python",
"repo": "acelectic/pythainlp",
"path": "/pythainlp/util/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>criterion = nn.CrossEntropyLoss()
# Observe that all parameters are being optimized
optimizer_ft = optim.SGD(model_ft.parameters(), lr=0.001, momentum=0.9)
# Decay LR by a factor of 0.1 every 7 epochs
exp_lr_scheduler = lr_scheduler.StepLR(optimizer_ft, step_size=7, gamma=0.1)
# count tp,fp,fn,tn using... | code_fim | hard | {
"lang": "python",
"repo": "lidaoxing451x/classifyplantdisease2",
"path": "/resnet50.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>model_ft = model_ft.to(device)
criterion = nn.CrossEntropyLoss()
# Observe that all parameters are being optimized
optimizer_ft = optim.SGD(model_ft.parameters(), lr=0.001, momentum=0.9)
# Decay LR by a factor of 0.1 every 7 epochs
exp_lr_scheduler = lr_scheduler.StepLR(optimizer_ft, step_size=7, gamma... | code_fim | hard | {
"lang": "python",
"repo": "lidaoxing451x/classifyplantdisease2",
"path": "/resnet50.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lidaoxing451x/classifyplantdisease2 path: /resnet50.py
from __future__ import print_function, division
import torch
import torch.nn as nn
import torch.optim as optim
from torch.optim import lr_scheduler
import numpy as np
import torchvision
from torchvision import datasets, models, transforms
im... | code_fim | hard | {
"lang": "python",
"repo": "lidaoxing451x/classifyplantdisease2",
"path": "/resnet50.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rc1 += [0,0,0,0]
rc2 += [0,0,0]
rc3 += [0,0]
rc4 += [0]
res += rc1[:4]+rc2[:3]+rc3[:2]+rc4[:1]
res += rc1[4:]+rc2[3:]+rc3[2:]+rc4[1:]
res = list(filter(lambda x:x!=0,res))
p_w = dict()
for item in res[:10]:
p_w[item[1]] = position_weight(f"{page_d... | code_fim | hard | {
"lang": "python",
"repo": "KayJayQ/Spicy_pot_search",
"path": "/server/search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KayJayQ/Spicy_pot_search path: /server/search.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
from nltk.tokenize import word_tokenize
from nltk.stem import WordNetLemmatizer
from nltk.corpus import stopwords
import lxml.html
stop = set(stopwords.words('english'))
page_dir = "E:/WEBPAGES_RAW... | code_fim | hard | {
"lang": "python",
"repo": "KayJayQ/Spicy_pot_search",
"path": "/server/search.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for term in words:
c.execute(f"SELECT * FROM token WHERE word = '{term}';")
res = c.fetchone()
if res == None:
continue
_,postings = res
postings = postings.split(';')[:-1]
for item in postings:
doc,tfidf,tag = i... | code_fim | hard | {
"lang": "python",
"repo": "KayJayQ/Spicy_pot_search",
"path": "/server/search.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>rule count_bases:
input: WORK + 'genes'
output: WORK + 'genes.bases'
shell: '{CRUZ_PY} {SCRIPTS}count_bases.py {input} {output}'<|fim_prefix|># repo: samesense/pathopredictor path: /src/rules/sf.webtool.py
rule mk_sample_data:
input: i = WORK + 'roc_df_panel/revel-ccr'
output: o = ... | code_fim | hard | {
"lang": "python",
"repo": "samesense/pathopredictor",
"path": "/src/rules/sf.webtool.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: samesense/pathopredictor path: /src/rules/sf.webtool.py
rule mk_sample_data:
input: i = WORK + 'roc_df_panel/revel-ccr'
output: o = DATA + 'interim/webtool/sample.csv'
run:
keys = ['Disease', 'gene', 'chrom', 'pos', 'ref', 'alt', 'Protein_Change', 'y', 'mpc_pred'] + list(feat... | code_fim | hard | {
"lang": "python",
"repo": "samesense/pathopredictor",
"path": "/src/rules/sf.webtool.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return threading.Thread(target=f, args=(g,))
for t in [t(f1), t(f2), t(f3)]:
t.start()
t.join()
run()<|fim_prefix|># repo: jmgc/pyston path: /test/tests/generator_threads2.py
import threading
import traceback, sys
def exc():
1/0
def G():
traceback.print_stack(limit=2... | code_fim | medium | {
"lang": "python",
"repo": "jmgc/pyston",
"path": "/test/tests/generator_threads2.py",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jmgc/pyston path: /test/tests/generator_threads2.py
import threading
import traceback, sys
def exc():
1/0
def G():
traceback.print_stack(limit=2)
yield 1
traceback.print_stack(limit=2)
yield 2
exc()
def f1(x):
print x.next()
def f2(x):
print x.next()
def f3(x):
... | code_fim | medium | {
"lang": "python",
"repo": "jmgc/pyston",
"path": "/test/tests/generator_threads2.py",
"mode": "psm",
"license": "Python-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.