text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: mhidas/AutoQC path: /util/main.py
## helper functions used in the top level AutoQC.py
import json, os, glob, time, pandas, csv, sys, fnmatch
import numpy as np
from wodpy import wod
from netCDF4 import Dataset
import testingProfile
from numbers import Number
import sys
import tempfile, psycopg2
... | code_fim | hard | {
"lang": "python",
"repo": "mhidas/AutoQC",
"path": "/util/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterField(
model_name='submission',
name='problem',
field=models.CharField(max_length=30),
),
migrations.AlterField(
model_name='submission',
name='user_id',
field=models.CharFiel... | code_fim | medium | {
"lang": "python",
"repo": "Luffy-wang/rebuild",
"path": "/submission/migrations/0006_auto_20180331_0622.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Luffy-wang/rebuild path: /submission/migrations/0006_auto_20180331_0622.py
# Generated by Django 2.0.3 on 2018-03-31 06:22
from django.db import migrations, models
<|fim_suffix|> dependencies = [
('submission', '0005_auto_20180329_0517'),
]
operations = [
migrations.... | code_fim | medium | {
"lang": "python",
"repo": "Luffy-wang/rebuild",
"path": "/submission/migrations/0006_auto_20180331_0622.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .density_matrix import DensityMatrix<|fim_prefix|># repo: PIQuIL/QuCumber path: /qucumber/nn_states/__init__.py
from .neural_state import NeuralStateBase
<|fim_middle|>from .wavefunction import WaveFunctionBase
from .complex_wavefunction import ComplexWaveFunction
from .positive_wavefunction import... | code_fim | medium | {
"lang": "python",
"repo": "PIQuIL/QuCumber",
"path": "/qucumber/nn_states/__init__.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PIQuIL/QuCumber path: /qucumber/nn_states/__init__.py
from .neural_state import NeuralStateBase
<|fim_suffix|>from .density_matrix import DensityMatrix<|fim_middle|>from .wavefunction import WaveFunctionBase
from .complex_wavefunction import ComplexWaveFunction
from .positive_wavefunction import... | code_fim | medium | {
"lang": "python",
"repo": "PIQuIL/QuCumber",
"path": "/qucumber/nn_states/__init__.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mycoal99/AlconCapstone path: /patient_recognition/segmentation/search_inner_bound.py
##-----------------------------------------------------------------------------
## Import
##-----------------------------------------------------------------------------
import numpy as np
from scipy import sign... | code_fim | hard | {
"lang": "python",
"repo": "mycoal99/AlconCapstone",
"path": "/patient_recognition/segmentation/search_inner_bound.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Hough Space Partial Derivative R
hspdr = hs - hs[:, :, np.insert(np.arange(hs.shape[2]-1), 0, 0)]
# Blur
sm = 3 # Size of the blurring mask
# print(">>>>>>>>>>>>>>>>>>>>>>>>>", hspdr, hspdr.shape)
hspdrs = signal.fftconvolve(hspdr, np.ones([sm,sm,sm]), mode="same")
indmax... | code_fim | hard | {
"lang": "python",
"repo": "mycoal99/AlconCapstone",
"path": "/patient_recognition/segmentation/search_inner_bound.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Hough Space (y,x,r)
sz = np.array([np.floor((Y-2*sect)/jump),
np.floor((X-2*sect)/jump),
np.floor((maxrad-minrad)/jump)]).astype(int)
# Resolution of the circular integration
integrationprecision = 1
angs = np.arange(0, 2*np.pi, integrationpre... | code_fim | hard | {
"lang": "python",
"repo": "mycoal99/AlconCapstone",
"path": "/patient_recognition/segmentation/search_inner_bound.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return redirect(url_for('blueprint_time.index'))
if __name__ == "__main__":
manager.run()<|fim_prefix|># repo: medsci-tech/mime_analysis_flask_2017 path: /manage.py
from flask import redirect
from flask import url_for
from flask_script import Manager
from flask_migrate import Migrate
from flask... | code_fim | medium | {
"lang": "python",
"repo": "medsci-tech/mime_analysis_flask_2017",
"path": "/manage.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: medsci-tech/mime_analysis_flask_2017 path: /manage.py
from flask import redirect
from flask import url_for
from flask_script import Manager
from flask_migrate import Migrate
from flask_migrate import MigrateCommand
from app import create_app
from app.models import db
<|fim_suffix|> return re... | code_fim | hard | {
"lang": "python",
"repo": "medsci-tech/mime_analysis_flask_2017",
"path": "/manage.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def climbStairs(self, n: int) -> int:
current = previous = 1
for _ in range(n-1):
current, previous = current + previous, current
return current<|fim_prefix|># repo: souvikb07/DS-Algo-and-CP path: /leetcode/easy_5.py
"""
You are climbing a stair case. It takes n st... | code_fim | hard | {
"lang": "python",
"repo": "souvikb07/DS-Algo-and-CP",
"path": "/leetcode/easy_5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># solution 1
def fib(n):
output = [1,2]
if 1<=n<=2:
return output[n-1]
else:
if fib(n-1) + fib(n-2) not in output:
output.append(fib(n-1) + fib(n-2))
return fib(n-1) + fib(n-2)
print(fib(19))
# solution 2
class Solution:
def climbStairs(self, n: in... | code_fim | hard | {
"lang": "python",
"repo": "souvikb07/DS-Algo-and-CP",
"path": "/leetcode/easy_5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: souvikb07/DS-Algo-and-CP path: /leetcode/easy_5.py
"""
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Example 1:
Input: 2
Output: 2
Explanation: There are two ways to climb to... | code_fim | medium | {
"lang": "python",
"repo": "souvikb07/DS-Algo-and-CP",
"path": "/leetcode/easy_5.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: james20141606/EM-network path: /model/loss.py
from __future__ import print_function, division
from torch.nn.modules.loss import _assert_no_grad, _Loss
import torch.nn.functional as F
import torch
class DiceLoss(_Loss):
def __init__(self, size_average=True, reduce=True, smooth=100.0):
... | code_fim | hard | {
"lang": "python",
"repo": "james20141606/EM-network",
"path": "/model/loss.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, size_average=True, reduce=True, smooth=10.0, gamma=2):
super().__init__(size_average, reduce)
self.smooth = smooth
self.gamma = gamma
def dice_loss(self, input, target):
loss = 0.
for index in range(input.size()[0]):
iflat = ... | code_fim | hard | {
"lang": "python",
"repo": "james20141606/EM-network",
"path": "/model/loss.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xflr6/gsheets path: /gsheets/oauth2.py
"""Helpers for doing OAuth 2.0 authentification."""
import os
from oauth2client import file, client, tools
from .tools import doctemplate
__all__ = ['get_credentials']
SCOPES = 'read'
SECRETS = '~/client_secrets.json'
STORAGE = '~/storage.json'
@doc... | code_fim | hard | {
"lang": "python",
"repo": "xflr6/gsheets",
"path": "/gsheets/oauth2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> default = SCOPES
@classmethod
def get(cls, scope=None):
"""Return default or predefined URLs from keyword, pass through ``scope``."""
if scope is None:
scope = cls.default
if isinstance(scope, str) and scope in cls._keywords:
return getattr(cls,... | code_fim | hard | {
"lang": "python",
"repo": "xflr6/gsheets",
"path": "/gsheets/oauth2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chahak13/HPC path: /Lab3/Code and data/vector/plotter.py
import matplotlib.pyplot as plt
import numpy as np
import sys
def loadData(fname):
inputSize, elapsedTime = [], []
try:
myData = open(fname, 'r')
except IOError:
print "File ", fname , "not found."
for l in ... | code_fim | hard | {
"lang": "python",
"repo": "chahak13/HPC",
"path": "/Lab3/Code and data/vector/plotter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#loadData from files
for f in files:
tmpInputSize, tmpElapsedTime = loadData(f)
inputSize.append(tmpInputSize)
elapsedTime.append(tmpElapsedTime)
print "loaded", f
inputSize = np.array(inputSize)
elapsedTime = np.array(elapsedTime)
#plot parallel overhead
plt.plot(inputSize[0], ((elapsedTi... | code_fim | hard | {
"lang": "python",
"repo": "chahak13/HPC",
"path": "/Lab3/Code and data/vector/plotter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#plot cores vs speedup
plt.plot(np.arange(0, cores+1), elapsedTime[0][6]/elapsedTime[:,6], 'ko-', label = r"$10^9$ elements")
plt.plot(np.arange(0, cores+1), elapsedTime[0][2]/elapsedTime[:,2], 'ks--', label = r"$10^5$ elements")
plt.plot(np.arange(0, cores+1), elapsedTime[0][0]/elapsedTime[:,0], 'k*:', l... | code_fim | hard | {
"lang": "python",
"repo": "chahak13/HPC",
"path": "/Lab3/Code and data/vector/plotter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: threatify/flask-jwt-extended path: /examples/complex_objects_from_tokens.py
from flask import Flask, jsonify, request
from flask_jwt_extended import (
JWTManager, jwt_required, create_access_token, current_user
)
app = Flask(__name__)
app.config['JWT_SECRET_KEY'] = 'super-secret' # Change... | code_fim | hard | {
"lang": "python",
"repo": "threatify/flask-jwt-extended",
"path": "/examples/complex_objects_from_tokens.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.username = username
self.roles = roles
# An example store of users. In production, this would likely
# be a sqlalchemy instance or something similar.
users_to_roles = {
'foo': ['admin'],
'bar': ['peasant'],
'baz': ['peasant']
}
# This function is called whenever a prot... | code_fim | hard | {
"lang": "python",
"repo": "threatify/flask-jwt-extended",
"path": "/examples/complex_objects_from_tokens.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tetomonti/Hydra path: /build/lib/hydra_pkg/featureCount.py
#Copyright 2015 Daniel Gusenleitner, Stefano Monti
#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://w... | code_fim | hard | {
"lang": "python",
"repo": "tetomonti/Hydra",
"path": "/build/lib/hydra_pkg/featureCount.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def main():
"""Main function that is run on each samples, which in turn calls runs
featureCount on a sample.
"""
import sys
param = MODULE_HELPER.initialize_module()
outfile = param['module_dir']+param['outstub']
call = [param['featureCount_exec']]
if param['paired']:... | code_fim | hard | {
"lang": "python",
"repo": "tetomonti/Hydra",
"path": "/build/lib/hydra_pkg/featureCount.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #For featureCount output, we want to skip the first two lines as they
#include the featureCount call and the headers which we don't want
next(csv_reader, None)
next(csv_reader, None)
#Now start by taking the list of identifier,
#which is the first column i... | code_fim | hard | {
"lang": "python",
"repo": "tetomonti/Hydra",
"path": "/build/lib/hydra_pkg/featureCount.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-sw/cmssw path: /RecoMTD/TimingIDTools/python/mtdTrackQualityMVA_cfi.py
import FWCore.ParameterSet.Config as cms
<|fim_suffix|>mtdTrackQualityMVA = mtdTrackQualityMVAProducer.clone()<|fim_middle|>from RecoMTD.TimingIDTools.mtdTrackQualityMVAProducer_cfi import *
| code_fim | medium | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/RecoMTD/TimingIDTools/python/mtdTrackQualityMVA_cfi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>mtdTrackQualityMVA = mtdTrackQualityMVAProducer.clone()<|fim_prefix|># repo: cms-sw/cmssw path: /RecoMTD/TimingIDTools/python/mtdTrackQualityMVA_cfi.py
import FWCore.ParameterSet.Config as cms
<|fim_middle|>from RecoMTD.TimingIDTools.mtdTrackQualityMVAProducer_cfi import *
| code_fim | medium | {
"lang": "python",
"repo": "cms-sw/cmssw",
"path": "/RecoMTD/TimingIDTools/python/mtdTrackQualityMVA_cfi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def decode_msg(self, es):
if self.state['keyx']['option'] & 0x0F == 0x07:
es = es[4:]
else:
es = es[:-4]
inv = (self.state['keyx']['option'] & 0xF0 == 0x30)
ds = xor_s(es, self.state['keyx']['key'], inv=inv)
return ds
def ops(self):
pass
def queue_msg(self):
... | code_fim | hard | {
"lang": "python",
"repo": "trailofbits/cb-multios",
"path": "/challenges/Loud_Square_Instant_Messaging_Protocol_LSIMP/poller/for-release/machine.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trailofbits/cb-multios path: /challenges/Loud_Square_Instant_Messaging_Protocol_LSIMP/poller/for-release/machine.py
#!/usr/bin/env python
from generator.actions import Actions, Variable
import random
import string
import struct
import sys
from collections import OrderedDict
CURRENT_VER = 103
MA... | code_fim | hard | {
"lang": "python",
"repo": "trailofbits/cb-multios",
"path": "/challenges/Loud_Square_Instant_Messaging_Protocol_LSIMP/poller/for-release/machine.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.state['dms'] = filter(lambda x: x[0] in seqs, self.state['dms'].items())
if self.state['helo']['secure'] and len(self.state['dms']) > 0:
#dc = filter(lambda x: x[:4] == 'DATA', self.state['queue'])
#dcd = OrderedDict([(struct.unpack('<I', x[4:8])[0], x[12:12+struct.unpack(... | code_fim | hard | {
"lang": "python",
"repo": "trailofbits/cb-multios",
"path": "/challenges/Loud_Square_Instant_Messaging_Protocol_LSIMP/poller/for-release/machine.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shobhitmishra/CodingProblems path: /LeetCode/Session3/maxConsecutiveOnesIII.py
from typing import List
class Solution:
def longestOnes(self, A: List[int], K: int) -> int:
<|fim_suffix|>A = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1]
K = 3
ob = Solution()
print(ob.longestOnes(A,K))<|fim_middle|> ... | code_fim | hard | {
"lang": "python",
"repo": "shobhitmishra/CodingProblems",
"path": "/LeetCode/Session3/maxConsecutiveOnesIII.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>A = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1]
K = 3
ob = Solution()
print(ob.longestOnes(A,K))<|fim_prefix|># repo: shobhitmishra/CodingProblems path: /LeetCode/Session3/maxConsecutiveOnesIII.py
from typing import List
class Solution:
def longestOnes(self, A: List[int], K: int) -> int:
<|fim_middle|> ... | code_fim | hard | {
"lang": "python",
"repo": "shobhitmishra/CodingProblems",
"path": "/LeetCode/Session3/maxConsecutiveOnesIII.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATICFILES_DIRS = [
location('static-src')
]
STATIC_URL = '/static/'
STATIC_ROOT = location('static')
AUTH_USER_MODEL = 'person... | code_fim | hard | {
"lang": "python",
"repo": "ministryofjustice/register-of-tech",
"path": "/rot/settings/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Internationalization
# https://docs.djangoproject.com/en/1.11/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.11/howto/static-files/
STATICFILES_DIRS = [
locat... | code_fim | hard | {
"lang": "python",
"repo": "ministryofjustice/register-of-tech",
"path": "/rot/settings/base.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ministryofjustice/register-of-tech path: /rot/settings/base.py
"""
Django settings for register project.
Generated by 'django-admin startproject' using Django 1.11.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/topics/settings/
For the full list of settings and ... | code_fim | hard | {
"lang": "python",
"repo": "ministryofjustice/register-of-tech",
"path": "/rot/settings/base.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mhuseinov/dormant-site-reclamation-program path: /services/dsrp-api/app/api/application/namespace.py
from flask_restplus import Namespace
from app.api.application.resources.application import ApplicationResource, ApplicationListResource, ApplicationReviewResource
from app.api.application.resourc... | code_fim | hard | {
"lang": "python",
"repo": "mhuseinov/dormant-site-reclamation-program",
"path": "/services/dsrp-api/app/api/application/namespace.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Contracted Work
api.add_resource(ApplicationApprovedContractedWorkResource,
'/<string:application_guid>/approved-contracted-work')
api.add_resource(ApplicationApprovedContractedWorkListResource, '/approved-contracted-work')
api.add_resource(ContractedWorkPaymentInterim,
... | code_fim | hard | {
"lang": "python",
"repo": "mhuseinov/dormant-site-reclamation-program",
"path": "/services/dsrp-api/app/api/application/namespace.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# initial "parent" table
class Parent(self.app.db.Model):
__tablename__ = 'parent'
id = self.app.db.Column(self.app.db.Integer,
primary_key=True)
self.dbmigrate = DBMigrate(self.app)
self.dbmigrate.init()
self.dbmigrate._upg... | code_fim | hard | {
"lang": "python",
"repo": "akostyuk/flask-dbmigrate",
"path": "/tests.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.app = Flask(__name__)
self.app.config.from_object(TestConfig)
# Use unique repository for each test
self.app.config['SQLALCHEMY_MIGRATE_REPO'] += self.id()
self.app.db = SQLAlchemy(self.app)
self.output = StringIO()
sys.stdout = self.output
... | code_fim | hard | {
"lang": "python",
"repo": "akostyuk/flask-dbmigrate",
"path": "/tests.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: akostyuk/flask-dbmigrate path: /tests.py
column1 = db.Column(db.String(60))
def __init__(self, column1):
self.column1 = column1
return Test
def with_database(test_method):
def wrapper(self):
self.dbmigrate.init()
self.dbmigrate._upgrade()
te... | code_fim | hard | {
"lang": "python",
"repo": "akostyuk/flask-dbmigrate",
"path": "/tests.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lyft/cartography path: /cartography/models/aws/ssm/instance_patch.py
from dataclasses import dataclass
from cartography.models.core.common import PropertyRef
from cartography.models.core.nodes import CartographyNodeProperties
from cartography.models.core.nodes import CartographyNodeSchema
from c... | code_fim | hard | {
"lang": "python",
"repo": "lyft/cartography",
"path": "/cartography/models/aws/ssm/instance_patch.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>@dataclass(frozen=True)
class SSMInstancePatchSchema(CartographyNodeSchema):
label: str = 'SSMInstancePatch'
properties: SSMInstancePatchNodeProperties = SSMInstancePatchNodeProperties()
sub_resource_relationship: SSMInstancePatchToAWSAccount = SSMInstancePatchToAWSAccount()
other_relation... | code_fim | hard | {
"lang": "python",
"repo": "lyft/cartography",
"path": "/cartography/models/aws/ssm/instance_patch.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>optims = ['GD', 'GDM', 'Adam', 'AEGD']
colors = ['g', 'b', 'k', 'r']
plt.figure(1, figsize=(8,6))
for i in range(4):
fs = runner(f=f, x0=x0, optim=optims[i], lr=args.lr[i],
maxiter=args.maxiter, tn=args.tn, m=args.m, c=args.c)
plt.plot(fs, colors[i], lw=1, label='{}-lr{}'.format(op... | code_fim | hard | {
"lang": "python",
"repo": "liuqi8827/AEGD",
"path": "/testfuncs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return z
args = parser.parse_args()
if args.func == 'rosen':
f = rosen
x0 = [-3, -4]
xscale = 'linear'
xstart = 0
else:
f = quad
x0 = np.ones(args.n)
xscale = 'log'
xstart = 10
optims = ['GD', 'GDM', 'Adam', 'AEGD']
colors = ['g', 'b', 'k', 'r']
plt.figure(1, figsize=... | code_fim | hard | {
"lang": "python",
"repo": "liuqi8827/AEGD",
"path": "/testfuncs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: liuqi8827/AEGD path: /testfuncs.py
import torch
import argparse
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams.update({'font.size': 15})
from aegd import AEGD
r"""
To reproduce the results for the quadratic function, run:
python testfuncs.py --func quad --n 100 --lr 0.9 0.1 0.0... | code_fim | hard | {
"lang": "python",
"repo": "liuqi8827/AEGD",
"path": "/testfuncs.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jjpersch/ectou-export path: /export.py
#!/usr/bin/env python2.7
"""
A minimal builder.
"""
import argparse
import boto3.session
import contextlib
import datetime
import os
import paramiko
import pipes
import scp
import socket
import subprocess
import sys
import time
import uuid
EXPORT_SCRIPT = ... | code_fim | hard | {
"lang": "python",
"repo": "jjpersch/ectou-export",
"path": "/export.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
args = get_parser().parse_args()
prefix = args.output_prefix
if not prefix:
prefix = "{source_ami_name}-{dt:%Y%m%d%H%M}".format(source_ami_name=args.ami_name,
dt=datetime.datetime.utcnow())
vmdk = prefix + ".... | code_fim | hard | {
"lang": "python",
"repo": "jjpersch/ectou-export",
"path": "/export.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: austinorr/nereid path: /nereid/nereid/api/api_v1/utils.py
from typing import Any, Dict, Optional, Tuple
import os
from fastapi import APIRouter, HTTPException
from celery.exceptions import TimeoutError
from celery.result import AsyncResult
from celery.task import Task
from nereid.core import co... | code_fim | hard | {
"lang": "python",
"repo": "austinorr/nereid",
"path": "/nereid/nereid/api/api_v1/utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> response = dict(task_id=task.task_id, status=task.status, result_route=result_route)
if task.successful():
response["data"] = task.result
return response
def get_valid_context(state: str = "state", region: str = "region") -> Dict[str, Any]:
context = utils.get_request_context(s... | code_fim | hard | {
"lang": "python",
"repo": "austinorr/nereid",
"path": "/nereid/nereid/api/api_v1/utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amitra/BikeMaps path: /mapApp/migrations/0004_auto_20150806_1426.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
from django.conf import settings
<|fim_suffix|> dependencies = [
('mapApp', '0003_auto_20150721_1221'),
]
... | code_fim | medium | {
"lang": "python",
"repo": "amitra/BikeMaps",
"path": "/mapApp/migrations/0004_auto_20150806_1426.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('mapApp', '0003_auto_20150721_1221'),
]
operations = [
migrations.AlterField(
model_name='administrativearea',
name='users',
field=models.ManyToManyField(to=settings.AUTH_USER_MODEL, verbose_name='users', blank=True),
... | code_fim | medium | {
"lang": "python",
"repo": "amitra/BikeMaps",
"path": "/mapApp/migrations/0004_auto_20150806_1426.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: strophy/EthereumBridge path: /src/util/web3.py
import json
import os
import time
from threading import Lock
from typing import List, Tuple, Optional, Generator
from web3 import Web3, HTTPProvider
from web3.contract import Contract as Web3Contract
from web3.datastructures import AttributeDict
fr... | code_fim | hard | {
"lang": "python",
"repo": "strophy/EthereumBridge",
"path": "/src/util/web3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def event_log(tx_hash: str, events: List[str], provider: Web3, contract: Web3Contract) -> \
Tuple[str, Optional[AttributeDict]]:
"""
Extracts logs of @event from tx_hash if present
:param tx_hash:
:param events: Case sensitive events name
:param provider:
:param contract: ... | code_fim | hard | {
"lang": "python",
"repo": "strophy/EthereumBridge",
"path": "/src/util/web3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PrefectHQ/prefect path: /tests/concurrency/test_release_concurrency_slots.py
import uuid
from unittest import mock
from httpx import Response
from prefect.client.schemas.responses import MinimalConcurrencyLimitResponse
from prefect.concurrency.asyncio import _release_concurrency_slots
async d... | code_fim | hard | {
"lang": "python",
"repo": "PrefectHQ/prefect",
"path": "/tests/concurrency/test_release_concurrency_slots.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
async def test_returns_minimal_concurrency_limit():
limits = [
MinimalConcurrencyLimitResponse(id=uuid.uuid4(), name=f"test-{i}", limit=i)
for i in range(1, 3)
]
with mock.patch(
"prefect.client.orchestration.PrefectClient.release_concurrency_slots"
) as client_re... | code_fim | hard | {
"lang": "python",
"repo": "PrefectHQ/prefect",
"path": "/tests/concurrency/test_release_concurrency_slots.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> with mock.patch(
"prefect.client.orchestration.PrefectClient.release_concurrency_slots"
) as client_release_concurrency_slots:
response = Response(
200, json=[limit.dict(json_compatible=True) for limit in limits]
)
client_release_concurrency_slots.return... | code_fim | hard | {
"lang": "python",
"repo": "PrefectHQ/prefect",
"path": "/tests/concurrency/test_release_concurrency_slots.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>random_walker = RandomWalker(2, float('inf'))
ano_walker = AnonymousWalker(2, float('inf'))
walklet_walker = WalkletWalker(2, float('inf'))
ngram_walker = NGramWalker(2, float('inf'))
wl_walker = WeisfeilerLehmanWalker(2, float('inf'))
com_walker = CommunityWalker(2, float('inf'))
halk_walker = HalkWalker... | code_fim | hard | {
"lang": "python",
"repo": "KRR-Oxford/OWL2Vec-Star",
"path": "/owl2vec_star/rdf2vec/example.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|># Fit model on the Weisfeiler-Lehman embeddings
train_embeddings = np.hstack((wl_embeddings[:len(train_people)], walk_embeddings[:len(train_people)]))
test_embeddings = np.hstack((wl_embeddings[len(train_people):], walk_embeddings[len(train_people):]))
# train_embeddings = wl_embeddings[:len(train_people)... | code_fim | hard | {
"lang": "python",
"repo": "KRR-Oxford/OWL2Vec-Star",
"path": "/owl2vec_star/rdf2vec/example.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KRR-Oxford/OWL2Vec-Star path: /owl2vec_star/rdf2vec/example.py
import random
import os
import numpy as np
os.environ['PYTHONHASHSEED'] = '42'
random.seed(42)
np.random.seed(42)
import rdflib
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.model_selection import GridSearchCV
fr... | code_fim | hard | {
"lang": "python",
"repo": "KRR-Oxford/OWL2Vec-Star",
"path": "/owl2vec_star/rdf2vec/example.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def nesting_changed(self, state):
if state == nestable.STATE_TAB:
self.arrow.set(ARROW_UP, SHADOW_ETCHED_IN)
else:
self.arrow.set(ARROW_DOWN, SHADOW_ETCHED_IN)<|fim_prefix|># repo: iivvoo-abandoned/most path: /src/view/gtkview/nestingArrowSupport.py
# $Id: nest... | code_fim | medium | {
"lang": "python",
"repo": "iivvoo-abandoned/most",
"path": "/src/view/gtkview/nestingArrowSupport.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iivvoo-abandoned/most path: /src/view/gtkview/nestingArrowSupport.py
# $Id: nestingArrowSupport.py,v 1.2 2002/02/07 23:48:51 ivo Exp $
<|fim_suffix|> def __init__(self):
self.arrow = self.get_widget("arrow")
def nesting_changed(self, state):
if state == nestable.STATE_TAB... | code_fim | medium | {
"lang": "python",
"repo": "iivvoo-abandoned/most",
"path": "/src/view/gtkview/nestingArrowSupport.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Twalord/serverSHARK path: /smartshark/migrations/0045_auto_20181113_0439.py
# -*- coding: utf-8 -*-
# Generated by Django 1.9.9 on 2018-11-13 03:39
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operati... | code_fim | hard | {
"lang": "python",
"repo": "Twalord/serverSHARK",
"path": "/smartshark/migrations/0045_auto_20181113_0439.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='commitvalidation',
name='coast_missing',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='commitvalidation',
name='coast_valid',
f... | code_fim | hard | {
"lang": "python",
"repo": "Twalord/serverSHARK",
"path": "/smartshark/migrations/0045_auto_20181113_0439.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ceeblet/OST_PythonCertificationTrack path: /Python2/FileHandling/src/test_fileops.py
import unittest
import os
import fileops
class TestReadWriteFile(unittest.TestCase):
"""Test case to verify list read/write functionality."""
def setUp(self):
"""This function is run before ... | code_fim | hard | {
"lang": "python",
"repo": "ceeblet/OST_PythonCertificationTrack",
"path": "/Python2/FileHandling/src/test_fileops.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_read_write_list_empty_strings(self):
self.verify_file(self.fixture_list_empty_strings)
def test_read_write_list_trailing_empty_strings(self):
self.verify_file(self.fixture_list_trailing_empty_strings)
def tearDown(self):
"""This function is ru... | code_fim | hard | {
"lang": "python",
"repo": "ceeblet/OST_PythonCertificationTrack",
"path": "/Python2/FileHandling/src/test_fileops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_read_write_list_trailing_empty_strings(self):
self.verify_file(self.fixture_list_trailing_empty_strings)
def tearDown(self):
"""This function is run after each test."""
try:
os.remove(self.fixture_file)
except OSError:
pass
... | code_fim | hard | {
"lang": "python",
"repo": "ceeblet/OST_PythonCertificationTrack",
"path": "/Python2/FileHandling/src/test_fileops.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mattstruble/crusty path: /tests/inputs/test_keyboard.py
#!/usr/bin/env python
# Copyright (c) 2017 Matt Struble. All Rights Reserved.
#
# Use is subject to license terms.
#
# Author: Matt Struble
# Date: Jun. 15 2017
from unittest import TestCase
from crusty.inputs import Keyboard, Keys, Keyboar... | code_fim | hard | {
"lang": "python",
"repo": "mattstruble/crusty",
"path": "/tests/inputs/test_keyboard.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertRaises(TypeError, self.keyboard.pressed, 7)
def test_release(self):
self.resetKeyboard()
self.keyDown(Keys.A)
self.assertFalse(self.keyboard.released(Keys.A))
self.assertFalse(self.keyboard.released())
self.keyboard._update()
self.ke... | code_fim | hard | {
"lang": "python",
"repo": "mattstruble/crusty",
"path": "/tests/inputs/test_keyboard.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return dir_iter(os.path.abspath(path), count)<|fim_prefix|># repo: DPS0340/DiscordDCinsideNotifier path: /src/package/fileHandler.py
import os
def safeMkdir(path):
if not os.path.exists(path):
os.mkdir(path)
return True
else:
return False
<|fim_middle|>def d... | code_fim | hard | {
"lang": "python",
"repo": "DPS0340/DiscordDCinsideNotifier",
"path": "/src/package/fileHandler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if __count__ == 0:
return __path__
else:
return dir_iter(os.path.dirname(__path__), __count__ - 1)
return dir_iter(os.path.abspath(path), count)<|fim_prefix|># repo: DPS0340/DiscordDCinsideNotifier path: /src/package/fileHandler.py
import os
def sa... | code_fim | easy | {
"lang": "python",
"repo": "DPS0340/DiscordDCinsideNotifier",
"path": "/src/package/fileHandler.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DPS0340/DiscordDCinsideNotifier path: /src/package/fileHandler.py
import os
def safeMkdir(path):
if not os.path.exists(path):
os.mkdir(path)
return True
else:
return False
<|fim_suffix|> def dir_iter(__path__, __count__):
if __count__ == 0:
... | code_fim | easy | {
"lang": "python",
"repo": "DPS0340/DiscordDCinsideNotifier",
"path": "/src/package/fileHandler.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ecalifornica/sfpython path: /sfpython/events/migrations/0004_auto_20161121_0107.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.RemoveField(
... | code_fim | hard | {
"lang": "python",
"repo": "ecalifornica/sfpython",
"path": "/sfpython/events/migrations/0004_auto_20161121_0107.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.RemoveField(
model_name='attendance',
name='attendee',
),
migrations.RemoveField(
model_name='attendance',
name='event',
),
migrations.AlterModelOptions(
name='event',
... | code_fim | hard | {
"lang": "python",
"repo": "ecalifornica/sfpython",
"path": "/sfpython/events/migrations/0004_auto_20161121_0107.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: enricorusso/incubator-ariatosca path: /aria/orchestrator/execution_plugin/ctx_proxy/server.py
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright own... | code_fim | hard | {
"lang": "python",
"repo": "enricorusso/incubator-ariatosca",
"path": "/aria/orchestrator/execution_plugin/ctx_proxy/server.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
with self.ctx.model.instrument(*self.ctx.INSTRUMENTATION_FIELDS):
typed_request = json.loads(request)
args = typed_request['args']
payload = _process_ctx_request(self.ctx, args)
result_type = 'result'
... | code_fim | hard | {
"lang": "python",
"repo": "enricorusso/incubator-ariatosca",
"path": "/aria/orchestrator/execution_plugin/ctx_proxy/server.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ziqbal/salmon-robotics path: /software/python/proxy/test-scratch7.py
from threading import Thread
import os
import sys
import signal
import time
import websocket
import threading
import random
import scratch
import logging
logging.basicConfig( )
############################################... | code_fim | hard | {
"lang": "python",
"repo": "ziqbal/salmon-robotics",
"path": "/software/python/proxy/test-scratch7.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if( msg[ 1 ] == "_scan" ) :
ws.send( "S" )
continue
if( msg[ 1 ] == "_monitor" ) :
ws.send( "M" )
continue
if( msg[ 1 ] == "_go" ) :
power_str = str( _power_left ) + "," + str( _power_right )
encoder_str = str( _encoder_left ) + "," + str... | code_fim | hard | {
"lang": "python",
"repo": "ziqbal/salmon-robotics",
"path": "/software/python/proxy/test-scratch7.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _softmax(self,x):
"""Compute softmax values for each sets of scores in x."""
e_x = np.exp(x - np.max(x))
return np.nan_to_num(e_x / np.nan_to_num(e_x.sum(axis=0)))
def _rand_psd_generator(self):
volts = np.random.uniform(.3,.1,size=100)
INTERNAL_SAMPLIN... | code_fim | hard | {
"lang": "python",
"repo": "remrama/flicker",
"path": "/src/PSDPlotWidget.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
self.plot = pg.PlotWidget()
self.curve = self.plot.plot()
grid.addWidget(self.plot)
# self.setWidget(widget)
# self.setWidgetResizable(True)
# main window stuff
self.setGeometry(500,0,900,500)
self.setWindowTitle('Power spectral density')... | code_fim | hard | {
"lang": "python",
"repo": "remrama/flicker",
"path": "/src/PSDPlotWidget.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: remrama/flicker path: /src/PSDPlotWidget.py
import sys
import numpy as np
import pyqtgraph as pg
from scipy.signal import welch
import pyqtgraph as pg
from pyqtgraph.Qt import QtCore, QtGui, QtWidgets
class PSDPlotWidget(QtGui.QWidget):
def __init__(self):
super(self.__class__, s... | code_fim | hard | {
"lang": "python",
"repo": "remrama/flicker",
"path": "/src/PSDPlotWidget.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 0;
};
"""
bpf = BPF(text=prog)
bpf.attach_kprobe(event="tcp_v4_do_rcv", fn_name="trace_socket_rcv")
def to_socket_key(k):
return inet_ntop(AF_INET, pack("I", k.saddr)) + ":" + str(k.lport) + "," + inet_ntop(AF_INET, pack("I", k.daddr)) + ":" + str(k.dport)
with open("/tmp/tcpv4-pe... | code_fim | hard | {
"lang": "python",
"repo": "nitsanw/grav",
"path": "/src/network/socket_depth.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> total = total_rcv_mem.lookup_or_init(&ipv4_key, &zero);
(*total) += rmem + skb->data_len;
max = peak_rcv_mem.lookup_or_init(&ipv4_key, &zero);
if (rmem > (*max)) {
(*max) = rmem + skb->data_len;
}
}
return 0;
};
"""
bpf = BPF(text=prog)
bpf.... | code_fim | hard | {
"lang": "python",
"repo": "nitsanw/grav",
"path": "/src/network/socket_depth.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nitsanw/grav path: /src/network/socket_depth.py
#!/usr/bin/python
## Heavily inspired by /usr/share/bcc/tools/tcptop
import sys
import time
import datetime
from bcc import BPF
from socket import inet_ntop, AF_INET, AF_INET6
from struct import pack
prog="""
#include <linux/types.h>
#include <... | code_fim | hard | {
"lang": "python",
"repo": "nitsanw/grav",
"path": "/src/network/socket_depth.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>cookies = dict(signature=str(signature, 'utf8'), user=str(user, 'utf8'))
r = requests.get('http://localhost:5000/flag', cookies=cookies)
# Flag in response.
print(r.text)
print('sig', str(signature, 'utf8'))
print('user', str(user, 'utf8'))<|fim_prefix|># repo: b01lers/bootcamp-2020 path: /web/enflask... | code_fim | medium | {
"lang": "python",
"repo": "b01lers/bootcamp-2020",
"path": "/web/enflaskcom/solve/solve.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: b01lers/bootcamp-2020 path: /web/enflaskcom/solve/solve.py
import requests
import pickle
import binascii
from Crypto.Signature import pkcs1_15
from Crypto.PublicKey import RSA
from Crypto.Hash import SHA384
def sign(msg):
if type(msg) is not bytes:
msg = bytes(msg, 'utf8')
keyPa... | code_fim | medium | {
"lang": "python",
"repo": "b01lers/bootcamp-2020",
"path": "/web/enflaskcom/solve/solve.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>user = binascii.hexlify(pickle.dumps(User()))
signature = binascii.hexlify(sign(user))
cookies = dict(signature=str(signature, 'utf8'), user=str(user, 'utf8'))
r = requests.get('http://localhost:5000/flag', cookies=cookies)
# Flag in response.
print(r.text)
print('sig', str(signature, 'utf8'))
print('... | code_fim | medium | {
"lang": "python",
"repo": "b01lers/bootcamp-2020",
"path": "/web/enflaskcom/solve/solve.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>em['tags'] or 'Shura"s Wrath' in item['tags']:
if ':' in item['title']:
postfix = item['title'].split(':', 1)[-1].strip()
return buildReleaseMessageWithType(item, "Shura's Wrath", vol, chp, frag=frag, postfix=postfix)
return False<|fim_prefix|># repo: fake-name/ReadableWebProxy path: /WebMirror/m... | code_fim | hard | {
"lang": "python",
"repo": "fake-name/ReadableWebProxy",
"path": "/WebMirror/management/rss_parser_funcs/feed_parse_extractSylver.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fake-name/ReadableWebProxy path: /WebMirror/management/rss_parser_funcs/feed_parse_extractSylver.py
def extractSylver(item):
"""
# Sylver Translations
"""
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or 'preview' in item['title'].lower():
r... | code_fim | hard | {
"lang": "python",
"repo": "fake-name/ReadableWebProxy",
"path": "/WebMirror/management/rss_parser_funcs/feed_parse_extractSylver.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fos777/MarbleChocolate path: /py-question/lv2-10.py
# 问题:编写一个程序,接受一系列空格分隔的单词作为输入,并在删除所有重复的单词并按字母数字排序后打印这些单词。
# 假设向程序提供以下输入:
# hello world and practice makes perfect and hello world again
# 则输出为:
# again and hello makes perfect practice world
# 提示:在为问题提供<|fim_suffix|>ated by Spaces")
items = [ x f... | code_fim | medium | {
"lang": "python",
"repo": "fos777/MarbleChocolate",
"path": "/py-question/lv2-10.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ated by Spaces")
items = [ x for x in input().split(' ')]
print (' '.join(sorted(list(set(items)))))<|fim_prefix|># repo: fos777/MarbleChocolate path: /py-question/lv2-10.py
# 问题:编写一个程序,接受一系列空格分隔的单词作为输入,并在删除所有重复的单词并按字母数字排序后打印这些单词。
# 假设向程序提供以下输入:
# hello world and practice m<|fim_middle|>akes perfect and... | code_fim | hard | {
"lang": "python",
"repo": "fos777/MarbleChocolate",
"path": "/py-question/lv2-10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>输入数据的情况下,应该假设它是控制台输入。
# 我们使用set容器自动删除重复的数据,然后使用sort()对数据进行排序。
# 解决方案:
print("Please enter words separated by Spaces")
items = [ x for x in input().split(' ')]
print (' '.join(sorted(list(set(items)))))<|fim_prefix|># repo: fos777/MarbleChocolate path: /py-question/lv2-10.py
# 问题:编写一个程序,接受一系列空格分隔的单词作为输入,... | code_fim | medium | {
"lang": "python",
"repo": "fos777/MarbleChocolate",
"path": "/py-question/lv2-10.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: catalyst-team/detection path: /src/__init__.py
# flake8: noqa
# from .runner import Runner
from catalyst.dl import SupervisedRunner as Runner
from catalyst.dl import registry
<|fim_suffix|>
registry.Criterion(CenterNetDetectionLoss)
registry.Criterion(RegL1Loss)
registry.Criterion(MSEIndLoss)
re... | code_fim | hard | {
"lang": "python",
"repo": "catalyst-team/detection",
"path": "/src/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from .callbacks import DecoderCallback, MeanAPCallback
from .losses import CenterNetDetectionLoss, \
RegL1Loss, MSEIndLoss, BCEIndLoss, FocalIndLoss
from . import models
registry.Criterion(CenterNetDetectionLoss)
registry.Criterion(RegL1Loss)
registry.Criterion(MSEIndLoss)
registry.Criterion(BCEIndL... | code_fim | medium | {
"lang": "python",
"repo": "catalyst-team/detection",
"path": "/src/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
yield chunk
yield from chunkerator(obj, stepsize=stepsize)
except (RuntimeError, StopIteration, UnboundLocalError):
pass
if __name__ == "__main__":
import doctest
doctest.testmod()<|fim_prefix|># repo: MarkMoretto/python-examples-main path: /recursion/iter... | code_fim | medium | {
"lang": "python",
"repo": "MarkMoretto/python-examples-main",
"path": "/recursion/iterable_chunking.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarkMoretto/python-examples-main path: /recursion/iterable_chunking.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
# Check for typing module, which was introduced in Python 3.5.x.
# If not legit, try import it from collections.abc.
# Finally, if all els... | code_fim | hard | {
"lang": "python",
"repo": "MarkMoretto/python-examples-main",
"path": "/recursion/iterable_chunking.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>f int(input("Is this acceptable?")):
csv = "\n".join(["{:.2}, {:.2}, {}".format(x, y, v) for x, y, v in zip(selected_a_0, selected_a_1, selected_b)])
with open("dataset.csv", "w") as file:
file.write(csv)
print("Done.")<|fim_prefix|># repo: InCogNiTo124/recursive-sgd path: /generate.py
im... | code_fim | hard | {
"lang": "python",
"repo": "InCogNiTo124/recursive-sgd",
"path": "/generate.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: InCogNiTo124/recursive-sgd path: /generate.py
import numpy as np
import matplotlib.pyplot as plt
def assign(x, y):
if x < 0.5:
if y < 0.5:
return int((y - 0.5) ** 2 + x ** 2 >= 0.25)
else:
return 0
else:
if y < 0.5:
<|fim_suffix|>sig... | code_fim | hard | {
"lang": "python",
"repo": "InCogNiTo124/recursive-sgd",
"path": "/generate.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gquarles/Discord-Bot-Template path: /bot.py
import discord
import json
import os
client = discord.Client()
with open('token.json', 'r') as file: # Load token from token.json
TOKEN = json.load(file)
TOKEN = TOKEN['token']
commands = [] # Initialize commands
<|fim_suffix|> sel... | code_fim | medium | {
"lang": "python",
"repo": "gquarles/Discord-Bot-Template",
"path": "/bot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Command:
def __init__(self, command, channel, output, batch):
self.command = command
self.channel = channel
self.output = output
self.batch = batch
commands.append(self) # Add command to commands list
def run(self):
os.system('start cmd /c {}... | code_fim | medium | {
"lang": "python",
"repo": "gquarles/Discord-Bot-Template",
"path": "/bot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Terminal = NewType("Terminal", str)
NonTerminal = NewType("NonTerminal", str)
Symbol = Union[Terminal, NonTerminal]
## Parsing grammar description file
Grammar = yaml.load(open("grammar.yaml", "r"), yaml.Loader)
def parse_rules(s):
left, right = map(lambda x: "".join(x.split()), s.split(RULE_SEPAR... | code_fim | medium | {
"lang": "python",
"repo": "magnickolas/formal-grammars",
"path": "/formal_grammars/grammar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.