text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: manikantavasupalli/python-practice path: /BasicProgramming/decorator.py
def decorate_lowercase(function):
def lowerfy():
funcaa = function()
string_lower = funcaa.lower()
return string_lower
return lowerfy
<|fim_suffix|>@splitfy
@decorate_lowercase
def hello():
return "Hello World!"
... | code_fim | medium | {
"lang": "python",
"repo": "manikantavasupalli/python-practice",
"path": "/BasicProgramming/decorator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@splitfy
@decorate_lowercase
def hello():
return "Hello World!"
print(hello())<|fim_prefix|># repo: manikantavasupalli/python-practice path: /BasicProgramming/decorator.py
def decorate_lowercase(function):
def lowerfy():
<|fim_middle|> funcaa = function()
string_lower = funcaa.lower()
return st... | code_fim | hard | {
"lang": "python",
"repo": "manikantavasupalli/python-practice",
"path": "/BasicProgramming/decorator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>-v1',
entry_point='pilco.envs:ContinuousAcrobotEnv'
)<|fim_prefix|># repo: Kajiyu/PILCO path: /pilco/__init__.py
from . import models
from . import controllers
from . import rewards
from . import envs
from gym.envs.registrat<|fim_middle|>ion import register
register(
id='acrobot-continuous | code_fim | easy | {
"lang": "python",
"repo": "Kajiyu/PILCO",
"path": "/pilco/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kajiyu/PILCO path: /pilco/__init__.py
from . import models
from . import controllers
from . import rewards
from . import envs
from gym.envs.registrat<|fim_suffix|>-v1',
entry_point='pilco.envs:ContinuousAcrobotEnv'
)<|fim_middle|>ion import register
register(
id='acrobot-continuous | code_fim | easy | {
"lang": "python",
"repo": "Kajiyu/PILCO",
"path": "/pilco/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class SVHN_Domain_classifier(nn.Module):
def __init__(self):
super(SVHN_Domain_classifier, self).__init__()
self.fc1 = nn.Linear(128 * 3 * 3, 1024)
#self.bn1 = nn.BatchNorm1d(1024)
self.fc2 = nn.Linear(1024, 1024)
#self.bn2 = nn.BatchNorm1d(1024)
self.f... | code_fim | hard | {
"lang": "python",
"repo": "fcdl94/ICL",
"path": "/networks/svhn.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: fcdl94/ICL path: /networks/svhn.py
"""
This network are inspired to the ones defined in https://github.com/CuthbertCai/pytorch_DANN
Credits to @CuthbertCai
"""
import torch.nn as nn
import torch.nn.functional as F
import torch.nn.init as init
from .rev_grad import grad_reverse as GRL
from .dial... | code_fim | hard | {
"lang": "python",
"repo": "fcdl94/ICL",
"path": "/networks/svhn.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aia/GamestonkTerminal-old path: /gamestonk_terminal/prediction_techniques/sma.py
import argparse
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from pandas.plotting import register_matplotlib_converters
from gamestonk_terminal.helper_funcs import check_positive, get_next_... | code_fim | hard | {
"lang": "python",
"repo": "aia/GamestonkTerminal-old",
"path": "/gamestonk_terminal/prediction_techniques/sma.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> l_pred_days = get_next_stock_market_days(
last_stock_day=df_stock["5. adjusted close"].index[-1],
n_next_days=ns_parser.n_days,
)
df_pred = pd.Series(l_predictions, index=l_pred_days, name="Price")
# Plotting
plt.plot(df_stock.index, df_stoc... | code_fim | hard | {
"lang": "python",
"repo": "aia/GamestonkTerminal-old",
"path": "/gamestonk_terminal/prediction_techniques/sma.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
model = UserProfile
fields = '__all__'
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ('url', 'name')
class PermissionSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model... | code_fim | hard | {
"lang": "python",
"repo": "gucciwu/cycling-cap-pyrenees",
"path": "/common/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
model = Permission
fields = ('url', 'name', 'content_type', 'codename')<|fim_prefix|># repo: gucciwu/cycling-cap-pyrenees path: /common/serializers.py
from rest_framework import serializers
from django.contrib.auth.models import Group, Permission, User
from base.serialize... | code_fim | hard | {
"lang": "python",
"repo": "gucciwu/cycling-cap-pyrenees",
"path": "/common/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gucciwu/cycling-cap-pyrenees path: /common/serializers.py
from rest_framework import serializers
from django.contrib.auth.models import Group, Permission, User
from base.serializers import BaseHyperlinkedModelSerializer
from common.models import UserProfile
class UserSerializer(BaseHyperlinked... | code_fim | hard | {
"lang": "python",
"repo": "gucciwu/cycling-cap-pyrenees",
"path": "/common/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> +-----------+-------------------------------------------------------------------------------------------------------------------------------------+
| Database | Create Database |
... | code_fim | hard | {
"lang": "python",
"repo": "DamonMok/PythonLearning",
"path": "/MySQL数据库_数据库的基本使用_1.数据库操作.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DamonMok/PythonLearning path: /MySQL数据库_数据库的基本使用_1.数据库操作.py
--数据库的操作
-- 连接数据库(root是用户名、damonmok是密码)
mysql -uroot -p
或者
mysql -uroot -pdamonmok
-- 退出数据库
exit/quit/ctrl+d
<|fim_suffix|> -- 查看数据库创建的语句(查看数据库是怎么创建的)
show create database python_db;
+-----------+--... | code_fim | hard | {
"lang": "python",
"repo": "DamonMok/PythonLearning",
"path": "/MySQL数据库_数据库的基本使用_1.数据库操作.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cms-nanoAOD/cmssw path: /HiggsAnalysis/Skimming/python/higgsToInvisible_AODSIM_cff.py
import FWCore.ParameterSet.Config as cms
from Configuration.EventContent.EventContent_cff import *
from HiggsAnalysis.Skimming.higgsToInvisible_EventContent_cff import *
higgsToInvisibleEventContentAODSIM = cms... | code_fim | medium | {
"lang": "python",
"repo": "cms-nanoAOD/cmssw",
"path": "/HiggsAnalysis/Skimming/python/higgsToInvisible_AODSIM_cff.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>tputCommands)
higgsToInvisibleEventContentAODSIM.outputCommands.extend(higgsToInvisibleEventContent.outputCommands)<|fim_prefix|># repo: cms-nanoAOD/cmssw path: /HiggsAnalysis/Skimming/python/higgsToInvisible_AODSIM_cff.py
import FWCore.ParameterSet.Config as cms
from Configuration.EventContent.EventCon... | code_fim | medium | {
"lang": "python",
"repo": "cms-nanoAOD/cmssw",
"path": "/HiggsAnalysis/Skimming/python/higgsToInvisible_AODSIM_cff.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert correct_stopping_condition, "Grid search did not find a model that fits the search_criteria_tune."
print(air_grid.get_grid("logloss"))
stacker = H2OStackedEnsembleEstimator(base_models=air_grid.model_ids)
stacker.train(model_id="my_ensemble", y="IsDepDelayed", training_frame=air_he... | code_fim | hard | {
"lang": "python",
"repo": "h2oai/h2o-3",
"path": "/h2o-py/tests/testdir_algos/gbm/pyunit_gbm_random_grid_large.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: h2oai/h2o-3 path: /h2o-py/tests/testdir_algos/gbm/pyunit_gbm_random_grid_large.py
from builtins import range
import math
import sys
sys.path.insert(1,"../../../")
import h2o
from tests import pyunit_utils
from h2o.grid.grid_search import H2OGridSearch
from h2o.estimators.gbm import H2OGradientBoo... | code_fim | hard | {
"lang": "python",
"repo": "h2oai/h2o-3",
"path": "/h2o-py/tests/testdir_algos/gbm/pyunit_gbm_random_grid_large.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benhoff/RPAAutomatedTest path: /test/tasks/customTasks.py
from interactions.defaultInteractions import tailAndWaitFor
from logDriver import LogDriver
def sendTheEmail(log : LogDriver,**kwargs) -> LogDriver:
<|fim_suffix|> tailAndWaitFor(log,kwargs['Row'])
def andDelete(log : LogDriver,**kwar... | code_fim | medium | {
"lang": "python",
"repo": "benhoff/RPAAutomatedTest",
"path": "/test/tasks/customTasks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def andDelete(log : LogDriver,**kwargs) -> LogDriver:
tailAndWaitFor(log,kwargs['The'])<|fim_prefix|># repo: benhoff/RPAAutomatedTest path: /test/tasks/customTasks.py
from interactions.defaultInteractions import tailAndWaitFor
from logDriver import LogDriver
def sendTheEmail(log : LogDriver,**kwargs... | code_fim | medium | {
"lang": "python",
"repo": "benhoff/RPAAutomatedTest",
"path": "/test/tasks/customTasks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>out':150}, 2003:{'intensity':0, 'timeout':90},
2005:{'intensity':0, 'timeout':300}, 2049:{'intensity':7, 'timeout':270}, 2103:{'intensity':4, 'timeout':660}, 2105:{'intensity':4, 'timeout':660},
2107:{'intensity':4, 'timeout':660}, 2121:{'intensity':7, 'timeout':150}, 2601:{'intensity':4, 'timeout':60}, 3... | code_fim | hard | {
"lang": "python",
"repo": "DeusMechanicus/Omnissiah",
"path": "/install/cfg/omni_config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (53, 5353)) OR (type='udp' AND state IN ('open', 'open|filtered') AND port IN (53, 5353))"},
{'threadsnum':20, 'arguments':'-n -T5 --host-timeout 720s -Pn --script nbstat,smb-enum-shares,smb-mbenum,smb-os-discovery,smb-protocols,smb-security-mode,\
smb2-capabilities,smb2-security-mode', 'timeout':840, 'f... | code_fim | hard | {
"lang": "python",
"repo": "DeusMechanicus/Omnissiah",
"path": "/install/cfg/omni_config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: DeusMechanicus/Omnissiah path: /install/cfg/omni_config.py
import logging
#programs
log_path = '/var/log/omnissiah'
#log_level = logging.ERROR
log_level = logging.INFO
#log_level = logging.DEBUG
log_format = '%(asctime)s:%(levelname)s:%(name)s:%(message)s'
log_date_format = '%Y%m%d:%H%M%S'
#dat... | code_fim | hard | {
"lang": "python",
"repo": "DeusMechanicus/Omnissiah",
"path": "/install/cfg/omni_config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> values.
"""
ENV_FILE = '.env'
ENV_PREFIX = 'PROBOT_'
METHOD = 'POST'
PATH = '/'<|fim_prefix|># repo: flyingdice/probot-py path: /probot/defaults.py
"""
probot/defaults
~~~~~~~~~~~<|fim_middle|>~~~~
Contains commonly used default | code_fim | easy | {
"lang": "python",
"repo": "flyingdice/probot-py",
"path": "/probot/defaults.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flyingdice/probot-py path: /probot/defaults.py
"""
probot/defaults
~~~~~~~~~~~<|fim_suffix|>X = 'PROBOT_'
METHOD = 'POST'
PATH = '/'<|fim_middle|>~~~~
Contains commonly used default values.
"""
ENV_FILE = '.env'
ENV_PREFI | code_fim | medium | {
"lang": "python",
"repo": "flyingdice/probot-py",
"path": "/probot/defaults.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jayhe/objc4_debug path: /objc4-756.2/编译素材/libpthread-330.250.2/lldbmacros/init.py
from xnu import *
import struct
def GetSeqCount(seq):
return (seq >> 8)
def GetLSeqBits(seq):
rv = ""
if seq & 0x1:
rv += "K"
if seq & 0x2:
rv += "E"
if seq & 0x4:
rv += "W"
if seq & 0x20:
rv += "M"
... | code_fim | hard | {
"lang": "python",
"repo": "jayhe/objc4_debug",
"path": "/objc4-756.2/编译素材/libpthread-330.250.2/lldbmacros/init.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> kflags = ""
if kwq.kw_kflags & 0x1:
kflags += "C" # INITCLEARED
if kwq.kw_kflags & 0x2:
kflags += "Z" # ZEROED
if kwq.kw_kflags & 0x4:
kflags += "Q" # QOS APPLIED
if kwq.kw_kflags & 0x8:
kflags += "O" # OVERLAP
rs = format.format(kwq, kwq.kw_addr, kwqtype, pflags, kflags, kwq.kw_iocount, kw... | code_fim | hard | {
"lang": "python",
"repo": "jayhe/objc4_debug",
"path": "/objc4-756.2/编译素材/libpthread-330.250.2/lldbmacros/init.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return API_CACHE
class SparkHistoryServerApi(object):
def __init__(self, spark_hs_url, security_enabled=False, ssl_cert_ca_verify=False):
self._ui_url = spark_hs_url
self._url = posixpath.join(spark_hs_url, 'api/%s/' % _API_VERSION)
self._client = HttpClient(self._url, logger=LOG)
s... | code_fim | hard | {
"lang": "python",
"repo": "lockhart39/HueQualityAndIngestionApp",
"path": "/desktop/libs/hadoop/src/hadoop/yarn/spark_history_server_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def applications(self):
return self._root.get('applications', headers=self.headers)
def application(self, app_id):
return self._root.get('applications/%(app_id)s' % {'app_id': app_id}, headers=self.headers)
def jobs(self, app_id, attempt_id):
return self._root.get('applications/%(app_i... | code_fim | hard | {
"lang": "python",
"repo": "lockhart39/HueQualityAndIngestionApp",
"path": "/desktop/libs/hadoop/src/hadoop/yarn/spark_history_server_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lockhart39/HueQualityAndIngestionApp path: /desktop/libs/hadoop/src/hadoop/yarn/spark_history_server_api.py
#!/usr/bin/env python
# Licensed to Cloudera, Inc. under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regardi... | code_fim | hard | {
"lang": "python",
"repo": "lockhart39/HueQualityAndIngestionApp",
"path": "/desktop/libs/hadoop/src/hadoop/yarn/spark_history_server_api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chandanbose/CUPyDO path: /tests/SU2_Metafor/CantileverSquareChannel_IQN_parallel_fsi.py
#! /usr/bin/env python
# -*- coding: utf8 -*-
'''
Copyright 2018 University of Liège
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the ... | code_fim | hard | {
"lang": "python",
"repo": "chandanbose/CUPyDO",
"path": "/tests/SU2_Metafor/CantileverSquareChannel_IQN_parallel_fsi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def main():
import cupydo.interfaces.Cupydo as cupy
p = getFsiP() # get parameters
cupydo = cupy.CUPyDO(p) # create fsi driver
cupydo.run() # run fsi process
test(cupydo.algorithm.errValue, p['tol']) # check the results
# eof
print ''
# --- This is only accessed if runnin... | code_fim | hard | {
"lang": "python",
"repo": "chandanbose/CUPyDO",
"path": "/tests/SU2_Metafor/CantileverSquareChannel_IQN_parallel_fsi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: snowyxx/aliyun-python-demo path: /aliyun/api/rest/Ecs20140526ModifyAutoSnapshotPolicyRequest.py
'''
Created by auto_sdk on 2014.07.23
'''
from aliyun.api.base import RestApi
class Ecs20140526ModifyAutoSnapshotPolicyRequest(RestApi):
<|fim_suffix|> RestApi.__init__(self,domain, port)
self... | code_fim | medium | {
"lang": "python",
"repo": "snowyxx/aliyun-python-demo",
"path": "/aliyun/api/rest/Ecs20140526ModifyAutoSnapshotPolicyRequest.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def getapiname(self):
return 'ecs.aliyuncs.com.ModifyAutoSnapshotPolicy.2014-05-26'<|fim_prefix|># repo: snowyxx/aliyun-python-demo path: /aliyun/api/rest/Ecs20140526ModifyAutoSnapshotPolicyRequest.py
'''
Created by auto_sdk on 2014.07.23
'''
from aliyun.api.base import RestApi
class Ecs20140526M... | code_fim | hard | {
"lang": "python",
"repo": "snowyxx/aliyun-python-demo",
"path": "/aliyun/api/rest/Ecs20140526ModifyAutoSnapshotPolicyRequest.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.cmd_log:
cmd_log = args.cmd_log
else:
cmd_log = buginfo['command log']
print "copy command log"
subprocess.check_call("scp %s:andchecker/%s cmd_log" % (args.hostname, cmd_log), shell=Tru... | code_fim | hard | {
"lang": "python",
"repo": "Xiangxingqian/appdoctor",
"path": "/analyze.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Xiangxingqian/appdoctor path: /analyze.py
#!/usr/bin/env python
import argparse
import subprocess
import os
import sys
import shutil
import flags
import buglib
def process_cmd():
argparser = argparse.ArgumentParser()
argparser.add_argument("cmd", type=str, help='command to run')
argp... | code_fim | hard | {
"lang": "python",
"repo": "Xiangxingqian/appdoctor",
"path": "/analyze.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> axs.xaxis.set_major_formatter(fmt)
# axs.xaxis.set_minor_formatter(fmt)
plt.xticks(rotation=self.options.get('xticksrotation'))
plt.legend()
fig.tight_layout()
def save_plot(self, outfile):
frmt = outfile.split('.')[-1].lower()
frmt_supported =... | code_fim | hard | {
"lang": "python",
"repo": "jgarte/qp",
"path": "/plotter.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jgarte/qp path: /plotter.py
import logging
import matplotlib.pyplot as plt
import matplotlib
from options import Options
log = logging.getLogger('qp')
# For plot style, color and marker symbols refer to the format strings section under:
# https://matplotlib.org/stable/api/_as_gen/matplotlib.axe... | code_fim | hard | {
"lang": "python",
"repo": "jgarte/qp",
"path": "/plotter.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
(float, float): ES test stat and p-value of rejecting the null hypothesis (that the two distributions are identical)
"""
d1 = assure_numpy_array(d1)
d2 = assure_numpy_array(d2)
es, pvalue = stats.epps_singleton_2samp(d1, d2)
return es, pvalue<|fim_prefix|># repo... | code_fim | hard | {
"lang": "python",
"repo": "python-polymatrix-games/probatus",
"path": "/probatus/stat_tests/es.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: python-polymatrix-games/probatus path: /probatus/stat_tests/es.py
# Copyright (c) 2020 ING Bank N.V.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restricti... | code_fim | medium | {
"lang": "python",
"repo": "python-polymatrix-games/probatus",
"path": "/probatus/stat_tests/es.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: asdfang/CC-AugmentedDeepBach path: /main.py
from grader.grader import score_chorale
from DatasetManager.chorale_dataset import ChoraleDataset
from DatasetManager.dataset_manager import DatasetManager, all_datasets
from DatasetManager.metadata import FermataMetadata, TickMetadata, KeyMetadata
from... | code_fim | hard | {
"lang": "python",
"repo": "asdfang/CC-AugmentedDeepBach",
"path": "/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(dataset.gaussian.covariances_)
# chorale = converter.parse('generations/6/c187.mid')
# score = score_chorale(chorale, dataset)
# print(score)<|fim_prefix|># repo: asdfang/CC-AugmentedDeepBach path: /main.py
from grader.grader import score_chorale
from DatasetManager.chorale_dataset import ChoraleD... | code_fim | hard | {
"lang": "python",
"repo": "asdfang/CC-AugmentedDeepBach",
"path": "/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>PYBITES_BORN = datetime(year=2016, month=12, day=19)
def gen_special_pybites_dates():
days = 0
while True:
days += 1
if days % 100 == 0 or days % 365 == 0:
yield PYBITES_BORN + timedelta(days=days)
# def gen_special_pybites_dates():
# start_date = PYBITES_BORN
# ... | code_fim | hard | {
"lang": "python",
"repo": "Anthlis/100daysofcode-with-python-course",
"path": "/days/01-03-datetimes/my_code/016_Special PyBites date generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># def gen_special_pybites_dates():
# start_date = PYBITES_BORN
# end_date = start_date + timedelta(days=100)
# while start_date <= end_date:
# yield start_date
# start_date = start_date + timedelta(days=1) # this counts every day for a hundred days.
# failed because I ... | code_fim | hard | {
"lang": "python",
"repo": "Anthlis/100daysofcode-with-python-course",
"path": "/days/01-03-datetimes/my_code/016_Special PyBites date generator.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Anthlis/100daysofcode-with-python-course path: /days/01-03-datetimes/my_code/016_Special PyBites date generator.py
'''
Bite 16. Special PyBites date generator
Write a generator that returns special dates for PyBites:
Every year mark counting from PYBITES_BORN date
Every 100 days mark counting fr... | code_fim | hard | {
"lang": "python",
"repo": "Anthlis/100daysofcode-with-python-course",
"path": "/days/01-03-datetimes/my_code/016_Special PyBites date generator.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Parameters:
----------
index: int
index of a specific image
Returns:
----------
ground-truths of this image
"""
assert self.labels is not None, "Labels not processed"
#return self.labels[index, :, :]
return self.la... | code_fim | hard | {
"lang": "python",
"repo": "juliuswang0728/mxnet-ssd",
"path": "/dataset/caltech_pedestrain.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns:
---------
cache path
"""
cache_path = os.path.join(os.path.dirname(__file__), '..', 'cache')
if not os.path.exists(cache_path):
os.mkdir(cache_path)
return cache_path
def label_from_index(self, index):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "juliuswang0728/mxnet-ssd",
"path": "/dataset/caltech_pedestrain.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: juliuswang0728/mxnet-ssd path: /dataset/caltech_pedestrain.py
import os
import numpy as np
import glob
from imdb import Imdb
import xml.etree.ElementTree as ET
from evaluate.eval_voc import voc_eval
import cv2
def load_caltech(image_set, devkit_path, shuffle=False):
"""
wrapper funct... | code_fim | hard | {
"lang": "python",
"repo": "juliuswang0728/mxnet-ssd",
"path": "/dataset/caltech_pedestrain.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@http.route('/corp/bind', type='http', auth="public", website=True)
def wx_bind(self, **kw):
qr_id = kw.get('qr_id')
redirect = kw.get('redirect', '')
redirect = base64.urlsafe_b64decode(redirect.encode('utf-8')).decode('utf-8')
_info = QR_DICT[qr_id]['data']
... | code_fim | medium | {
"lang": "python",
"repo": "niulinlnc/weodoo",
"path": "/controllers/controllers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: niulinlnc/weodoo path: /controllers/controllers.py
# -*- coding: utf-8 -*-
import logging
import time
import random
import json
import base64
from odoo import http
from odoo.addons.web.controllers.main import Home, ensure_db
from odoo.addons.web.controllers.main import db_monodb, ensure_db, set_... | code_fim | medium | {
"lang": "python",
"repo": "niulinlnc/weodoo",
"path": "/controllers/controllers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vulhub/vulhub path: /django/CVE-2018-14574/app.py
import os
import sys
from django.urls import include, path, re_path
from django.http import HttpResponse
os.environ.setdefault("DJANGO_SETTINGS_MODULE", __name__)
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DEBUG = False
SECRET_KEY = 'v... | code_fim | medium | {
"lang": "python",
"repo": "vulhub/vulhub",
"path": "/django/CVE-2018-14574/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
path('', home),
re_path(r'^(.*)/$', home),
]
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)<|fim_prefix|># repo: vulhub/vulhub path: /django/CVE-2018-14574/app.py
import os
import sys
from django.urls import include, path, re_path... | code_fim | hard | {
"lang": "python",
"repo": "vulhub/vulhub",
"path": "/django/CVE-2018-14574/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#pode colocar os calculos dentro do print tbm
#pode usar 'pow' exemplo pow(n,(1/2))<|fim_prefix|># repo: Kimberly07-Ernane/Pythondesafios path: /Desafios/Desafio 006 (Dobro,Tripo,Raiz quad.).py
#Desafio 06
#Crie um algoritmo que leia um número e mostre o seu dobro,
#triplo e raiz quadrada
<|fim_middle|>... | code_fim | medium | {
"lang": "python",
"repo": "Kimberly07-Ernane/Pythondesafios",
"path": "/Desafios/Desafio 006 (Dobro,Tripo,Raiz quad.).py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kimberly07-Ernane/Pythondesafios path: /Desafios/Desafio 006 (Dobro,Tripo,Raiz quad.).py
#Desafio 06
#Crie um algoritmo que leia um número e mostre o seu dobro,
#triplo e raiz quadrada
<|fim_suffix|>#pode colocar os calculos dentro do print tbm
#pode usar 'pow' exemplo pow(n,(1/2))<|fim_middle|>... | code_fim | medium | {
"lang": "python",
"repo": "Kimberly07-Ernane/Pythondesafios",
"path": "/Desafios/Desafio 006 (Dobro,Tripo,Raiz quad.).py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Generate a useful version string for a QGreenland build.
It's not always enough to use bumpversion to manage versions. If we want to
release a dev build or a pre-release for human validation, it needs a
fully-unique name so we know exactly what the user tested.
* For release build... | code_fim | hard | {
"lang": "python",
"repo": "nsidc/qgreenland",
"path": "/qgreenland/util/version.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nsidc/qgreenland path: /qgreenland/util/version.py
import functools
import os
import re
import subprocess
import qgreenland.exceptions as exc
from qgreenland import __version__
VERSION_REGEX = re.compile(r"^v\d+\.\d+\.\d+(?P<modifier>.*)$")
def _select_version_tags(tags):
"""Return any me... | code_fim | hard | {
"lang": "python",
"repo": "nsidc/qgreenland",
"path": "/qgreenland/util/version.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return version
def version_is_full_release(version_string):
"""Check if a version string is a release version `vX.Y.Z`.
Exclude any pre-release versions like `vX.Y.Z-rc1`, `vX.Y.Zfoobarbaz`.
"""
match = VERSION_REGEX.match(version_string)
if match and match.groupdict()["modifie... | code_fim | hard | {
"lang": "python",
"repo": "nsidc/qgreenland",
"path": "/qgreenland/util/version.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FlareSolverr/FlareSolverr path: /src/undetected_chromedriver/dprocess.py
import atexit
import logging
import multiprocessing
import os
import platform
import signal
from subprocess import PIPE
from subprocess import Popen
import sys
CREATE_NEW_PROCESS_GROUP = 0x00000200
DETACHED_PROCESS = 0x000... | code_fim | hard | {
"lang": "python",
"repo": "FlareSolverr/FlareSolverr",
"path": "/src/undetected_chromedriver/dprocess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for pid in REGISTERED:
try:
logging.getLogger(__name__).debug("cleaning up pid %d " % pid)
os.kill(pid, signal.SIGTERM)
except: # noqa
pass
atexit.register(_cleanup)<|fim_prefix|># repo: FlareSolverr/FlareSolverr path: /src/undetected_chromedrive... | code_fim | hard | {
"lang": "python",
"repo": "FlareSolverr/FlareSolverr",
"path": "/src/undetected_chromedriver/dprocess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>for i in range(1, 65535):
ports.append(i)
# Check what time the scan started
t1 = datetime.now()
pool = ThreadPool(processes=1000)
results = pool.map(scan_port, ports)
pool.close()
pool.join()
print ('Multiprocess Scanning Completed in ', datetime.now() - t1)
print ('number is ', totalnumber)<|fi... | code_fim | hard | {
"lang": "python",
"repo": "YaKaiLi/hbuComputerNetworkCourseProject-ScanPort",
"path": "/scanport5.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YaKaiLi/hbuComputerNetworkCourseProject-ScanPort path: /scanport5.py
# coding: utf-8
import socket
from datetime import datetime
from multiprocessing.dummy import Pool as ThreadPool
#remote_server = input("Enter a remote host to scan:")
remote_server = "103.79.76.177"
remote_server_ip = socket.g... | code_fim | hard | {
"lang": "python",
"repo": "YaKaiLi/hbuComputerNetworkCourseProject-ScanPort",
"path": "/scanport5.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Calculate the preparation time in minutes"""
return PREPARATION_TIME * number_of_layers
def elapsed_time_in_minutes(number_of_layers, elapsed_bake_time):
"""Calculate the elapsed time in minutes"""
return preparation_time_in_minutes(number_of_layers) + elapsed_bake_time<|fim_prefix|># ... | code_fim | medium | {
"lang": "python",
"repo": "ErikSchierboom/exercism",
"path": "/python/guidos-gorgeous-lasagna/lasagna.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ErikSchierboom/exercism path: /python/guidos-gorgeous-lasagna/lasagna.py
EXPECTED_BAKE_TIME = 40
PREPARATION_TIME = 2
def bake_time_remaining(elapsed_bake_time):
<|fim_suffix|> """Calculate the elapsed time in minutes"""
return preparation_time_in_minutes(number_of_layers) + elapsed_bake_... | code_fim | hard | {
"lang": "python",
"repo": "ErikSchierboom/exercism",
"path": "/python/guidos-gorgeous-lasagna/lasagna.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lluxury/P_U_S_A path: /9_package_management/distutils/setup.py
from setuptools import setup
setup(
name = "distutils_example",
description = "A completly Useless Script Th<|fim_suffix|>",
version = "0.1",
url = "htt这://www.pyatl.org"
)<|fim_middle|>at Prints",
author = "yann",... | code_fim | easy | {
"lang": "python",
"repo": "lluxury/P_U_S_A",
"path": "/9_package_management/distutils/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>",
version = "0.1",
url = "htt这://www.pyatl.org"
)<|fim_prefix|># repo: lluxury/P_U_S_A path: /9_package_management/distutils/setup.py
from setuptools import setup
setup(
name = "distutils_<|fim_middle|>example",
description = "A completly Useless Script That Prints",
author = "yann",... | code_fim | medium | {
"lang": "python",
"repo": "lluxury/P_U_S_A",
"path": "/9_package_management/distutils/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> matches = [i for i in LANGLIST if match[0].lower() in i.lower()]
if matches:
return ', '.join(matches)
else:
return 'No languages matching {}. See !languages for a list of languages I support.'.format(match[0])
TIOBot = Bot(
nick = 'TIOBot',
room = 'xkcd',
sho... | code_fim | hard | {
"lang": "python",
"repo": "totallyhuman/TIOBot",
"path": "/TIOBot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 'Output:\n' + res[0]
def list_languages(match, trigger):
return ', '.join(LANGLIST)
def search_languages(match, trigger):
matches = [i for i in LANGLIST if match[0].lower() in i.lower()]
if matches:
return ', '.join(matches)
else:
return 'No languages matc... | code_fim | hard | {
"lang": "python",
"repo": "totallyhuman/TIOBot",
"path": "/TIOBot.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: totallyhuman/TIOBot path: /TIOBot.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
import zlib
from literate_banana import Bot
LANGUAGES = {
'c': 'c-gcc',
'c#': 'cs-core',
'c++': 'cpp-gcc',
'common lisp': 'clisp',
'groovy': 'groovy',
'go': 'go',
'ha... | code_fim | hard | {
"lang": "python",
"repo": "totallyhuman/TIOBot",
"path": "/TIOBot.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_normal_user_can_remove_all_emails(user_gql_client, email_data):
profile = ProfileWithPrimaryEmailFactory(user=user_gql_client.user, emails=2)
primary_email = profile.emails.filter(primary=True).first()
email = profile.emails.filter(primary=False).first()
t = Template(
"""... | code_fim | hard | {
"lang": "python",
"repo": "SuviVappula/open-city-profile",
"path": "/profiles/tests/test_gql_update_my_profile_mutation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> profile = ProfileWithPrimaryEmailFactory(user=user_gql_client.user)
phone = PhoneFactory(profile=profile)
t = Template(
"""
mutation {
updateMyProfile(
input: {
profile: {
removePhones:... | code_fim | hard | {
"lang": "python",
"repo": "SuviVappula/open-city-profile",
"path": "/profiles/tests/test_gql_update_my_profile_mutation.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SuviVappula/open-city-profile path: /profiles/tests/test_gql_update_my_profile_mutation.py
"address": address_data["address"],
"postalCode": address_data["postal_code"],
"city": address_data["city"],
... | code_fim | hard | {
"lang": "python",
"repo": "SuviVappula/open-city-profile",
"path": "/profiles/tests/test_gql_update_my_profile_mutation.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: geordi/kelvin path: /common/utils.py
from datetime import timedelta
import re
import ldap
from functools import lru_cache
LDAP_CONNECTION = None
@lru_cache()
def is_teacher(user):
return user.groups.filter(name='teachers').exists()
def points_to_color(points, max_points):
ratio = max(0... | code_fim | hard | {
"lang": "python",
"repo": "geordi/kelvin",
"path": "/common/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not LDAP_CONNECTION:
connect()
def get():
return LDAP_CONNECTION.search_s("", ldap.SCOPE_SUBTREE, f"(cn={login})", ["sn", "givenname", "mail"])
# TODO: escape needed?
try:
res = get()
except ldap.UNAVAILABLE:
connect()
res = get()
if no... | code_fim | medium | {
"lang": "python",
"repo": "geordi/kelvin",
"path": "/common/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sndg-arg/sndg-web path: /bioresources/models/Expression.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from model_utils import Choices
from django.utils.translation import gettext_lazy as _, ngettext as __
from django.db import models
from .Resource import Resource
class Expr... | code_fim | hard | {
"lang": "python",
"repo": "sndg-arg/sndg-web",
"path": "/bioresources/models/Expression.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ran = []
for affiliation in self.targets.all():
ran += affiliation.source.author_names()
return list(set(ran))
def related_org_names(self):
ran = []
for affiliation in self.targets.all():
ran += affiliation.source.affiliation_names()
... | code_fim | hard | {
"lang": "python",
"repo": "sndg-arg/sndg-web",
"path": "/bioresources/models/Expression.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ran = []
for affiliation in self.targets.all():
ran += affiliation.source.affiliation_names()
return list(set(ran))<|fim_prefix|># repo: sndg-arg/sndg-web path: /bioresources/models/Expression.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from mode... | code_fim | medium | {
"lang": "python",
"repo": "sndg-arg/sndg-web",
"path": "/bioresources/models/Expression.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # get url for authenticating user
url = graph.get_auth_url(app_id, canvas_url, perms)
webbrowser.open(url)
FacebookApi.wait_for_request(server_class=Server, handler_class=Handler)
global code # pylint: disable=global-statement
# g... | code_fim | hard | {
"lang": "python",
"repo": "cash2one/Postr",
"path": "/postr/facebook_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/Postr path: /postr/facebook_api.py
# Facebook API
from http.server import BaseHTTPRequestHandler, HTTPServer
import webbrowser
import json
from typing import Type, List
from postr.config import get_api_key
from postr.config import update_api_key
from postr.api_interface import ApiInterf... | code_fim | hard | {
"lang": "python",
"repo": "cash2one/Postr",
"path": "/postr/facebook_api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> server_class: Type[HTTPServer],
handler_class: Type[BaseHTTPRequestHandler],
) -> None:
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
httpd.timeout = 10
try:
httpd.handle_request() # this can get me the code... | code_fim | hard | {
"lang": "python",
"repo": "cash2one/Postr",
"path": "/postr/facebook_api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Input data dimensions
n_batches = test_data.shape[0]
# T = test_data.shape[1]
# Limit the length of the input data
test_data = test_data[:, :self.in_seq_length]
# Compute the forecast
with tf.Session() as sess:
saver.restore(sess, sel... | code_fim | hard | {
"lang": "python",
"repo": "dickkky/forecastNet",
"path": "/TensorFlow/forecastNet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def forecast(self, test_data):
"""
Perform a forecast with the input data: test_data. Note that only the first in_seq_length values in test_data
are used are used to forecast the next out_seq_length values. It is best practice to compute several forecasts
and average o... | code_fim | hard | {
"lang": "python",
"repo": "dickkky/forecastNet",
"path": "/TensorFlow/forecastNet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dickkky/forecastNet path: /TensorFlow/forecastNet.py
"""
This file contains the class which constructs the TensorFlow graph of ForecastNet and provides a function for
forecasting.
Paper:
"ForecastNet: A Time-Variant Deep Feed-Forward Neural Network Architecture for Multi-Step-Ahead Time-Series F... | code_fim | hard | {
"lang": "python",
"repo": "dickkky/forecastNet",
"path": "/TensorFlow/forecastNet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: les-tallman/cloudbolt-forge path: /blueprints/azure_k8s/sync.py
"""
Discover Azure Resource groups and clusters
Return Azure Resource groups and clusters identified by sku, handler_id and location
"""
from common.methods import set_progress
from azure.common.credentials import ServicePrincipalCre... | code_fim | medium | {
"lang": "python",
"repo": "les-tallman/cloudbolt-forge",
"path": "/blueprints/azure_k8s/sync.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
discovered_resource_groups = []
for handler in AzureARMHandler.objects.all():
set_progress('Connecting to Azure Resource Groups \
for handler: {}'.format(handler))
credentials = ServicePrincipalCredentials(
client_id=handler.client_id,
secret=handle... | code_fim | medium | {
"lang": "python",
"repo": "les-tallman/cloudbolt-forge",
"path": "/blueprints/azure_k8s/sync.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> transformation_fn_dict = dict()
transformation_fn_dict["tf_name"] = tf
transformation_fn_dict["tf1_name"] = tf
fv = feature_view.FeatureView(
featurestore_id=feature_store_id,
name="test_fv",
version=1,
query=q,
t... | code_fim | hard | {
"lang": "python",
"repo": "logicalclocks/feature-store-api",
"path": "/python/tests/test_feature_view.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: logicalclocks/feature-store-api path: /python/tests/test_feature_view.py
#
# Copyright 2022 Hopsworks AB
#
# 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
#
# ... | code_fim | hard | {
"lang": "python",
"repo": "logicalclocks/feature-store-api",
"path": "/python/tests/test_feature_view.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kort/kort-core path: /src/api/tokeninfo/tokenAccess.py
#!/usr/bin/env python3
import logging
from api import models
db_session = models.init_db()
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
<|fim_suffix|>
def get_user_by_secret(secret: str):
user = db_sessi... | code_fim | medium | {
"lang": "python",
"repo": "kort/kort-core",
"path": "/src/api/tokeninfo/tokenAccess.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_user_by_secret(secret: str):
user = db_session.query(models.User).filter(models.User.secret == secret).one_or_none()
logger.info('get user token with id '+str(user.id))
return user.id<|fim_prefix|># repo: kort/kort-core path: /src/api/tokeninfo/tokenAccess.py
#!/usr/bin/env python3
i... | code_fim | medium | {
"lang": "python",
"repo": "kort/kort-core",
"path": "/src/api/tokeninfo/tokenAccess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def get_user_by_secret(secret: str):
user = db_session.query(models.User).filter(models.User.secret == secret).one_or_none()
logger.info('get user token with id '+str(user.id))
return user.id<|fim_prefix|># repo: kort/kort-core path: /src/api/tokeninfo/tokenAccess.py
#!/usr/bin/env python3
im... | code_fim | hard | {
"lang": "python",
"repo": "kort/kort-core",
"path": "/src/api/tokeninfo/tokenAccess.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jfkz/tvoeradio path: /tvoeradio/radio/decorators.py
import httpagentparser
from django.shortcuts import render_to_response
from django.template import RequestContext
<|fim_suffix|> def _wrap(request, *args, **kwargs):
ua = request.META.get('HTTP_USER_AGENT')
no_ua_check = requ... | code_fim | hard | {
"lang": "python",
"repo": "jfkz/tvoeradio",
"path": "/tvoeradio/radio/decorators.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ua = request.META.get('HTTP_USER_AGENT')
no_ua_check = request.GET.get('no_ua_check', False)
if ua and not no_ua_check:
info = httpagentparser.detect(ua)
browser = info.get('browser', {})
if browser.get('name') == 'Microsoft Internet Explorer':
... | code_fim | hard | {
"lang": "python",
"repo": "jfkz/tvoeradio",
"path": "/tvoeradio/radio/decorators.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __str__(self):
return self.nombre
class Capitulos(models.Model):
programa = models.ForeignKey(Programa, related_name='programa', on_delete=models.CASCADE)
numero_capitulo = models.IntegerField('Numero')
fecha_emision = models.DateTimeField('Fecha de emision')
titulo = models.TextField('Tit... | code_fim | medium | {
"lang": "python",
"repo": "ddvloayza/str3am-app",
"path": "/tvempresa/src/apps/web/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self.nombre
class Capitulos(models.Model):
programa = models.ForeignKey(Programa, related_name='programa', on_delete=models.CASCADE)
numero_capitulo = models.IntegerField('Numero')
fecha_emision = models.DateTimeField('Fecha de emision')
titulo = models.TextField('Titulo', max_length=70,... | code_fim | hard | {
"lang": "python",
"repo": "ddvloayza/str3am-app",
"path": "/tvempresa/src/apps/web/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ddvloayza/str3am-app path: /tvempresa/src/apps/web/models.py
from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
from taggit.managers import TaggableManager
class Principal(models.Model):
nombre_video_principal = models.CharField('Nombre Vid... | code_fim | medium | {
"lang": "python",
"repo": "ddvloayza/str3am-app",
"path": "/tvempresa/src/apps/web/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> f.write(str(find_big_prime(37))+'\n')<|fim_prefix|># repo: rshorey/primefactors path: /list_of_primes.py
from find_big_prime import *
with open('list_of_primes2.csv', 'w') as f:
f.writel<|fim_middle|>ines('prime\n')
for i in range(0,50):
| code_fim | easy | {
"lang": "python",
"repo": "rshorey/primefactors",
"path": "/list_of_primes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rshorey/primefactors path: /list_of_primes.py
from find_big_prime import *
with open('li<|fim_suffix|>ines('prime\n')
for i in range(0,50):
f.write(str(find_big_prime(37))+'\n')<|fim_middle|>st_of_primes2.csv', 'w') as f:
f.writel | code_fim | easy | {
"lang": "python",
"repo": "rshorey/primefactors",
"path": "/list_of_primes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> hot_label_train = []
hot_label_val = []
hot_label_test = []
# One hot encode the training labels
for i in range(self.num_train):
hot_label_train.append(np.eye(self.num_classes, dtype=float)[label_train[i]])
hot_label_train = np.array(hot_label_t... | code_fim | hard | {
"lang": "python",
"repo": "bvsk35/TensorFlow-V1.13-V2.0-Examples",
"path": "/TensorFlow v1.13/3-MNIST-Classification-CNN/Load_MNIST_Data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bvsk35/TensorFlow-V1.13-V2.0-Examples path: /TensorFlow v1.13/3-MNIST-Classification-CNN/Load_MNIST_Data.py
# This file prepares the training, validation and testing MNIST dataset
# Import required functions
import gzip
import numpy as np
from sklearn.preprocessing import StandardScaler
from skle... | code_fim | hard | {
"lang": "python",
"repo": "bvsk35/TensorFlow-V1.13-V2.0-Examples",
"path": "/TensorFlow v1.13/3-MNIST-Classification-CNN/Load_MNIST_Data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Function for converting the labels to one hot encoded vectors
def one_hot_encoded(self, label_train, label_val, label_test):
hot_label_train = []
hot_label_val = []
hot_label_test = []
# One hot encode the training labels
for i in range(self.num_train):
... | code_fim | hard | {
"lang": "python",
"repo": "bvsk35/TensorFlow-V1.13-V2.0-Examples",
"path": "/TensorFlow v1.13/3-MNIST-Classification-CNN/Load_MNIST_Data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># histogram of number of observations by date
df_grouped_date = df.groupby(['date'])
df_date_count = df_grouped_date['reqid'].aggregate(['count'])
#df_date_count = df_grouped_date.aggregate(['count'])
print(df_date_count)
#exclude_cols = ['title count']
#df_date_count.ix[:, df_date_count.columns.differe... | code_fim | hard | {
"lang": "python",
"repo": "robmarano/nyu-python",
"path": "/course-2/session-7/pandas/df_basics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: robmarano/nyu-python path: /course-2/session-7/pandas/df_basics.py
#!/usr/bin/env python3
try:
# for Python 2.x
import StringIO
except:
# for Python 3.x
import io
import csv
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import re
# define data
csv_inpu... | code_fim | hard | {
"lang": "python",
"repo": "robmarano/nyu-python",
"path": "/course-2/session-7/pandas/df_basics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.