text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> """
Infers the grpc service and method name from the handler_call_details.
"""
# e.g. /package.ServiceName/MethodName
parts = handler_call_details.method.split("/")
if len(parts) < 3:
return "", "", False
grpc_service_name, grpc_method_name = parts[1:3]
return grpc_service_name, grpc... | code_fim | medium | {
"lang": "python",
"repo": "slackhq/py-grpc-prometheus",
"path": "/py_grpc_prometheus/grpc_utils.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> losses = self.losses[skip_start:-skip_end]
lrs = self.lrs[skip_start:-skip_end]
try:
min_grad = np.gradient(losses).argmin()
except ValueError:
raise ValueError('Failed to compute gradients, there might not be enough points.')
import matplo... | code_fim | hard | {
"lang": "python",
"repo": "shkarupa-alex/tfmiss",
"path": "/tfmiss/keras/callbacks/lrfind.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shkarupa-alex/tfmiss path: /tfmiss/keras/callbacks/lrfind.py
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import numpy as np
import tensorflow as tf
import tempfile
from keras import backend, callbacks
from keras.saving import regis... | code_fim | hard | {
"lang": "python",
"repo": "shkarupa-alex/tfmiss",
"path": "/tfmiss/keras/callbacks/lrfind.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_context_data(self, **kwargs):
context = super(TagDetail, self).get_context_data(**kwargs)
context['articles'] = Article.objects.public_in_board(context['board']
).filter(tags=context['tag'])
return context<|fim_prefix|># repo: yong27/paprika path: /papr... | code_fim | hard | {
"lang": "python",
"repo": "yong27/paprika",
"path": "/paprikasite/paprika/views/tag.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yong27/paprika path: /paprikasite/paprika/views/tag.py
from django.views.generic.list import ListView
from django.views.generic.detail import DetailView
from django.shortcuts import get_object_or_404
from paprika.models import Article, Board, Tag
from paprika.views import PaprikaExtraContext
c... | code_fim | hard | {
"lang": "python",
"repo": "yong27/paprika",
"path": "/paprikasite/paprika/views/tag.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class TagDetail(DetailView, PaprikaExtraContext):
model = Tag
context_object_name = 'tag'
def get_context_data(self, **kwargs):
context = super(TagDetail, self).get_context_data(**kwargs)
context['articles'] = Article.objects.public_in_board(context['board']
)... | code_fim | hard | {
"lang": "python",
"repo": "yong27/paprika",
"path": "/paprikasite/paprika/views/tag.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PFLeget/gastrometry path: /gastrometry/clean_jobs.py
import numpy as np
import glob
import os
<|fim_suffix|>for output in outputs:
logs = glob.glob(os.path.join(output, '*.log'))
if len(logs) != 0:
for log in logs:
os.system('rm %s'%(log))<|fim_middle|>outputs = glob.... | code_fim | medium | {
"lang": "python",
"repo": "PFLeget/gastrometry",
"path": "/gastrometry/clean_jobs.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>for output in outputs:
logs = glob.glob(os.path.join(output, '*.log'))
if len(logs) != 0:
for log in logs:
os.system('rm %s'%(log))<|fim_prefix|># repo: PFLeget/gastrometry path: /gastrometry/clean_jobs.py
import numpy as np
import glob
import os
<|fim_middle|>outputs = glob.... | code_fim | medium | {
"lang": "python",
"repo": "PFLeget/gastrometry",
"path": "/gastrometry/clean_jobs.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: greenelab/ccc path: /nbs/others/05_clustermatch_profiling/11_cm_optimized/py/09-many_samples.py
# ---
# jupyter:
# jupytext:
# cell_metadata_filter: all,-execution,-papermill,-trusted
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3... | code_fim | hard | {
"lang": "python",
"repo": "greenelab/ccc",
"path": "/nbs/others/05_clustermatch_profiling/11_cm_optimized/py/09-many_samples.py",
"mode": "psm",
"license": "BSD-2-Clause-Patent",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# %% [markdown] tags=[]
# # With default `internal_n_clusters`
# %% tags=[]
def func():
n_clust = list(range(2, 10 + 1))
return ccc(data, internal_n_clusters=n_clust)
# %% tags=[]
# %%timeit func()
func()
# %% tags=[]
# %%prun -s cumulative -l 50 -T 09-cm_many_samples-default_internal_n_clust... | code_fim | hard | {
"lang": "python",
"repo": "greenelab/ccc",
"path": "/nbs/others/05_clustermatch_profiling/11_cm_optimized/py/09-many_samples.py",
"mode": "spm",
"license": "BSD-2-Clause-Patent",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in tommy:
t_chr = x[1]
t_start = int(x[2])
t_end = int(x[3])
for y in macs:
m_chr = y[0]
m_start = int(y[1])
m_end = int(y[2])
if ((t_chr == m_chr) and
((((t_start > m_start) and
... | code_fim | hard | {
"lang": "python",
"repo": "colinwalshbrown/CWB_utils",
"path": "/Scripts/filter_Tommy_xls_by_MACS_xls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for x in open(args[1]):
if re.search("#",x):
print "?"
continue
spl = x.split()
tommy.append(spl)
for x in tommy:
t_chr = x[1]
t_start = int(x[2])
t_end = int(x[3])
for y in macs:
m_chr = y[0]
... | code_fim | hard | {
"lang": "python",
"repo": "colinwalshbrown/CWB_utils",
"path": "/Scripts/filter_Tommy_xls_by_MACS_xls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: colinwalshbrown/CWB_utils path: /Scripts/filter_Tommy_xls_by_MACS_xls.py
#!/usr/bin/env python
import sys
import re
def main(args):
if len(args) < 2:
print "filter_Tommy_xls_by_MACS_xls.py <MACS_xls> <Tommy_xls>"
sys.exit(1)
<|fim_suffix|> for x in tommy:
t_chr... | code_fim | hard | {
"lang": "python",
"repo": "colinwalshbrown/CWB_utils",
"path": "/Scripts/filter_Tommy_xls_by_MACS_xls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # make a list of filtered instances IDs `[i.id for i in instances]`
# Filter from all instances the instance that are not in the filtered list
instances_to_tag = [to_tag for to_tag in allinstances if to_tag.id not in [i.id for i in taggedInstances]]
for instance in instances_to_tag... | code_fim | hard | {
"lang": "python",
"repo": "ghostcodekc/aws-scripts",
"path": "/EC2/getRegionTags.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ghostcodekc/aws-scripts path: /EC2/getRegionTags.py
from __future__ import print_function
import json
import boto3
print('Loading function')
# open connection to ec2
ec2 = boto3.client('ec2')
#Set Regions Variable and get all regions
regions = ec2.describe_regions().get('Regions',[] )
all_regi... | code_fim | hard | {
"lang": "python",
"repo": "ghostcodekc/aws-scripts",
"path": "/EC2/getRegionTags.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #Get ALL instances to make reference to
allinstances = ec2.instances.all()
# Grab a list of all instnaces that have a "region" tag.
taggedInstances = ec2.instances.filter(
Filters=[
{'Name': 'tag:Region', 'Values': ['**']}
]
)
#Set reg... | code_fim | medium | {
"lang": "python",
"repo": "ghostcodekc/aws-scripts",
"path": "/EC2/getRegionTags.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmwm/T0 path: /src/python/T0/WMBS/Oracle/SMNotification/UpdateOfflineFileStatus.py
"""
_UpdateOfflineFileStatus_
Oracle implementation of UpdateOfflineFileStatus
"""
from WMCore.Database.DBFormatter import DBFormatter
<|fim_suffix|> sql = """UPDATE file_transfer_status_offline
... | code_fim | hard | {
"lang": "python",
"repo": "dmwm/T0",
"path": "/src/python/T0/WMBS/Oracle/SMNotification/UpdateOfflineFileStatus.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
sql = """UPDATE file_transfer_status_offline
SET t0_repacked_time = CURRENT_TIMESTAMP,
repacked_retrieve = 1
WHERE p5_fileid = :P5_ID
AND t0_repacked_time IS NULL
AND repacked_retrieve is NULL
... | code_fim | hard | {
"lang": "python",
"repo": "dmwm/T0",
"path": "/src/python/T0/WMBS/Oracle/SMNotification/UpdateOfflineFileStatus.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.dbi.processData(sql, binds, conn = conn,
transaction = transaction)
return<|fim_prefix|># repo: dmwm/T0 path: /src/python/T0/WMBS/Oracle/SMNotification/UpdateOfflineFileStatus.py
"""
_UpdateOfflineFileStatus_
Oracle implementation of UpdateOfflineFileSt... | code_fim | hard | {
"lang": "python",
"repo": "dmwm/T0",
"path": "/src/python/T0/WMBS/Oracle/SMNotification/UpdateOfflineFileStatus.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shared-tw/backend path: /api/api.py
from ninja import NinjaAPI
from ninja.operation import Operation
from authenticator.api import JWTAuthBearer
from authenticator.api import router as authenticator_router
from oauth2.api import router as oauth_router
from share.api import router as share_router... | code_fim | medium | {
"lang": "python",
"repo": "shared-tw/backend",
"path": "/api/api.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>api.add_router("auth", authenticator_router)
api.add_router("oauth", oauth_router)
api.add_router("", share_router, auth=JWTAuthBearer())<|fim_prefix|># repo: shared-tw/backend path: /api/api.py
from ninja import NinjaAPI
from ninja.operation import Operation
from authenticator.api import JWTAuthBearer
... | code_fim | hard | {
"lang": "python",
"repo": "shared-tw/backend",
"path": "/api/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class SharedTWApi(NinjaAPI):
def get_openapi_operation_id(self, operation: Operation) -> str:
name = operation.view_func.__name__
return name.replace(".", "_")
api = SharedTWApi(title="shared-tw API", version="0.1.0")
api.add_router("auth", authenticator_router)
api.add_router("oaut... | code_fim | medium | {
"lang": "python",
"repo": "shared-tw/backend",
"path": "/api/api.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """calc the deg cen for a graph given by vert and edge frames"""
# here we are calculating our own deg cen res on the fly
# edge counts will store the number of edges associated with
# each vertex
edge_counts = {}
# get the edge frame in pandas form and ite... | code_fim | hard | {
"lang": "python",
"repo": "trustedanalytics/spark-tk",
"path": "/regression-tests/sparktkregtests/testcases/graph/degree_centrality_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: trustedanalytics/spark-tk path: /regression-tests/sparktkregtests/testcases/graph/degree_centrality_test.py
# vim: set encoding=utf-8
# Copyright (c) 2016 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance wi... | code_fim | hard | {
"lang": "python",
"repo": "trustedanalytics/spark-tk",
"path": "/regression-tests/sparktkregtests/testcases/graph/degree_centrality_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """simple deg cen test w data from docs w deg opt as out"""
# uses the same dataset as the docs
actual_res = self.doc_graph.degree_centrality(degree_option="out")
# also from docs
expected_res = {1: 0.75, 2: 0.25, 3: 0, 4: 0.25, 5: 0}
# compare results with ... | code_fim | hard | {
"lang": "python",
"repo": "trustedanalytics/spark-tk",
"path": "/regression-tests/sparktkregtests/testcases/graph/degree_centrality_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dreipol/smallinvoice path: /smallinvoice/commons.py
# coding=utf-8
import json
import collections
class PREVIEW_SIZE(object):
SMALL = 240
MEDIUM = 600
BIG = 825
HUGE = 1240
class REQUEST_METHOD(object):
AUTO = 0
POST = 1
GET = 2
class SmallInvoiceException(Except... | code_fim | hard | {
"lang": "python",
"repo": "dreipol/smallinvoice",
"path": "/smallinvoice/commons.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def update(self, identifier, data):
"""
Updates the data of an item
:param identifier: the id of the object to be updated
:param data: the data containing all the information of the object.
"""
self.client.request_with_method(Methods.UPDATE % (self.name,... | code_fim | hard | {
"lang": "python",
"repo": "dreipol/smallinvoice",
"path": "/smallinvoice/commons.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def encode(self):
"""
Encodes the object to a json string
:return: the data as formatted json string
"""
return json.dumps(self.get_data(), indent=4)
def get_data(self):
"""
Returns this object in a serializable form
:return: a seri... | code_fim | hard | {
"lang": "python",
"repo": "dreipol/smallinvoice",
"path": "/smallinvoice/commons.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
log_fmt = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
logging.basicConfig(level=logging.INFO, format=log_fmt)
# not used in this stub but often useful for finding various files
project_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir... | code_fim | hard | {
"lang": "python",
"repo": "ndanielsen/dc_parking_violations_data",
"path": "/src/data/download_raw.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ndanielsen/dc_parking_violations_data path: /src/data/download_raw.py
# -*- coding: utf-8 -*-
import os
import click
import logging
import json
import requests
import time
from dotenv import find_dotenv, load_dotenv
@click.command()
@click.argument('input_filepath', type=click.Path(exists=True)... | code_fim | hard | {
"lang": "python",
"repo": "ndanielsen/dc_parking_violations_data",
"path": "/src/data/download_raw.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # not used in this stub but often useful for finding various files
project_dir = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir)
# find .env automagically by walking up directories until it's found, then
# load up the .env entries as environment variables
load_dotenv(fin... | code_fim | hard | {
"lang": "python",
"repo": "ndanielsen/dc_parking_violations_data",
"path": "/src/data/download_raw.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> frame[self.where] = dataclasses.I3Particle()
self.PushFrame(frame)
tray = I3Tray()
tray.AddModule("I3Reader",
Filename="pass1.i3",
skipkeys=["IceTop.*"])
tray.AddModule("FrameCheck",
ensure_physics_has = ["DrivingTime", "I3EventHeader", "InIceRawData"... | code_fim | medium | {
"lang": "python",
"repo": "hschwane/offline_production",
"path": "/dataio/resources/test/g_regex_filter_on_read_and_write.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>tray.AddModule("I3Reader",
Filename="pass1.i3",
skipkeys=["IceTop.*"])
tray.AddModule("FrameCheck",
ensure_physics_has = ["DrivingTime", "I3EventHeader", "InIceRawData"],
ensure_physics_hasnt = ["IceTopRawData", "IceTopRecoHitSeries"]
)
#
# To verify filter-out... | code_fim | hard | {
"lang": "python",
"repo": "hschwane/offline_production",
"path": "/dataio/resources/test/g_regex_filter_on_read_and_write.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hschwane/offline_production path: /dataio/resources/test/g_regex_filter_on_read_and_write.py
#!/usr/bin/env python
from I3Tray import *
from os.path import expandvars
import os
import sys
from icecube import icetray
from icecube import dataclasses
from icecube import phys_services
from ice... | code_fim | hard | {
"lang": "python",
"repo": "hschwane/offline_production",
"path": "/dataio/resources/test/g_regex_filter_on_read_and_write.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>например 'Земля' без кавычек: ")
if a == p:
print ("Совершенно верно!")
if a != p:
print ("Ответ неверен! Правильный ответ - "+p)
input ("нажмите Enter для выхода")<|fim_prefix|># repo: stasvorosh/pythonintask path: /INBa/2015/SHEMYAKIN_A_V/task_6_31.py
# Задача 6. Вариант 31.
# Созда... | code_fim | medium | {
"lang": "python",
"repo": "stasvorosh/pythonintask",
"path": "/INBa/2015/SHEMYAKIN_A_V/task_6_31.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>гает вам угадать загаданную компьютером планету нашей солнечной системы")
p = (random_number.choice(planeti))
print ("Какую систему загадал компьютер?")
a = input("Введите ваш ответ (например 'Земля' без кавычек: ")
if a == p:
print ("Совершенно верно!")
if a != p:
print ("Ответ невере... | code_fim | medium | {
"lang": "python",
"repo": "stasvorosh/pythonintask",
"path": "/INBa/2015/SHEMYAKIN_A_V/task_6_31.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stasvorosh/pythonintask path: /INBa/2015/SHEMYAKIN_A_V/task_6_31.py
# Задача 6. Вариант 31.
# Создайте игру, в которой компьютер загадывает название одной из восьми планет Солнечной системы, а игрок должен его угадать.
# Шемякин А.В.
# 24.5.16
planet<|fim_suffix|>гает вам угадать загаданную комп... | code_fim | medium | {
"lang": "python",
"repo": "stasvorosh/pythonintask",
"path": "/INBa/2015/SHEMYAKIN_A_V/task_6_31.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> RD_RE = re.compile(r"(?P<pri>\d) 0x(?P<addr>[a-f0-9]+?) " \
"\((?P<bin>.*?)\) x\s*(?P<reg>\d*?) 0x(?P<val>[a-f0-9]+)")
CORE_RE = re.compile(r"core.*0x(?P<addr>[a-f0-9]+?) \(0x(?P<bin>.*?)\) (?P<instr>.*?)$")
INSTR_RE = re.compile(r"(?P<instr>[a-z\.]+?)(\s+?)(?P<operand>.*... | code_fim | hard | {
"lang": "python",
"repo": "wrifier/riscv-dv",
"path": "/scripts/spike_log_to_trace_csv.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wrifier/riscv-dv path: /scripts/spike_log_to_trace_csv.py
"""
Copyright 2019 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LI... | code_fim | hard | {
"lang": "python",
"repo": "wrifier/riscv-dv",
"path": "/scripts/spike_log_to_trace_csv.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kyper999/mayan-edms path: /mayan/apps/folders/apps.py
from __future__ import unicode_literals
from django.apps import apps
from django.utils.translation import ugettext_lazy as _
from acls import ModelPermission
from acls.links import link_acl_list
from acls.permissions import permission_acl_ed... | code_fim | hard | {
"lang": "python",
"repo": "kyper999/mayan-edms",
"path": "/mayan/apps/folders/apps.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def ready(self):
super(FoldersApp, self).ready()
Document = apps.get_model(
app_label='documents', model_name='Document'
)
DocumentFolder = self.get_model('DocumentFolder')
Folder = self.get_model('Folder')
APIEndPoint(app=self, version_st... | code_fim | hard | {
"lang": "python",
"repo": "kyper999/mayan-edms",
"path": "/mayan/apps/folders/apps.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not self._header:
return None
if key in self._var_headers_dict:
var_header = self._var_headers_dict[key]
fmt = VAR_TYPE_MAP[var_header.type] * var_header.count
var_offset = var_header.offset + self._header.var_buf[0].buf_offset
... | code_fim | hard | {
"lang": "python",
"repo": "kutu/pyirsdk",
"path": "/irsdk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.__broadcast_msg_id is None:
self.__broadcast_msg_id = ctypes.windll.user32.RegisterWindowMessageW(BROADCASTMSGNAME)
return self.__broadcast_msg_id
def _broadcast_msg(self, broadcast_type=0, var1=0, var2=0, var3=0):
return ctypes.windll.user32.SendNotifyMess... | code_fim | hard | {
"lang": "python",
"repo": "kutu/pyirsdk",
"path": "/irsdk.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kutu/pyirsdk path: /irsdk.py
n res[0] if var_header.count == 1 else list(res)
return self._get_session_info(key)
@property
def is_connected(self):
if self._header:
if self._header.status == StatusField.status_connected:
self.__workaround_conne... | code_fim | hard | {
"lang": "python",
"repo": "kutu/pyirsdk",
"path": "/irsdk.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hpcaitech/ColossalAI path: /colossalai/nn/loss/loss_moe.py
import torch.nn as nn
from colossalai.registry import LOSSES
from torch.nn.modules.loss import _Loss
from colossalai.context.moe_context import MOE_CONTEXT
@LOSSES.register_module
class MoeCrossEntropyLoss(_Loss):
r"""torch.... | code_fim | hard | {
"lang": "python",
"repo": "hpcaitech/ColossalAI",
"path": "/colossalai/nn/loss/loss_moe.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """A wrapper class for any loss module to add with auxiliary loss.
Args:
aux_weight (float): Weight of auxiliary loss in total loss.
loss_fn (``Callable``): Loss function.
args (list): Args in loss function.
kwargs (dict): Kwargs in loss function
"""
... | code_fim | hard | {
"lang": "python",
"repo": "hpcaitech/ColossalAI",
"path": "/colossalai/nn/loss/loss_moe.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: huaweicloud/huaweicloud-sdk-python-v3 path: /huaweicloud-sdk-servicestage/huaweicloudsdkservicestage/v2/model/show_instance_detail_response.py
# coding: utf-8
import six
from huaweicloudsdkcore.sdk_response import SdkResponse
from huaweicloudsdkcore.utils.http_utils import sanitize_for_serializ... | code_fim | hard | {
"lang": "python",
"repo": "huaweicloud/huaweicloud-sdk-python-v3",
"path": "/huaweicloud-sdk-servicestage/huaweicloudsdkservicestage/v2/model/show_instance_detail_response.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Sets the refer_resources of this ShowInstanceDetailResponse.
部署资源列表。
:param refer_resources: The refer_resources of this ShowInstanceDetailResponse.
:type refer_resources: list[:class:`huaweicloudsdkservicestage.v2.ReferResources`]
"""
self._refer_resou... | code_fim | hard | {
"lang": "python",
"repo": "huaweicloud/huaweicloud-sdk-python-v3",
"path": "/huaweicloud-sdk-servicestage/huaweicloudsdkservicestage/v2/model/show_instance_detail_response.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: aryazakaria01/CodeX path: /usercodex/plugins/troll.py
"""
Created by @Jisan7509
plugin for Cat_Userbot
☝☝☝
You remove this, you gay.
"""
from telethon.errors.rpcerrorlist import YouBlockedUserError
from ..core.managers import edit_delete, edit_or_reply
from . import codex, reply_id
plugin_cate... | code_fim | hard | {
"lang": "python",
"repo": "aryazakaria01/CodeX",
"path": "/usercodex/plugins/troll.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>@codex.cod_cmd(
pattern="talkme ?([\s\S]*)",
command=("talkme", plugin_category),
info={
"header": "talk to me meme",
"description": "Send talk to me troll",
"usage": "{tr}talkme <text>",
},
)
async def cod(event):
"talk to me troll"
reply_to_id = await repl... | code_fim | hard | {
"lang": "python",
"repo": "aryazakaria01/CodeX",
"path": "/usercodex/plugins/troll.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nsemedia/repository.nsemedia path: /matrix/script.hdrezka.video/plugin.py
#!/usr/bin/python
<|fim_suffix|>########################
if __name__ == '__main__':
plugin.run()<|fim_middle|>########################
from resources.lib.widgets import *
| code_fim | medium | {
"lang": "python",
"repo": "nsemedia/repository.nsemedia",
"path": "/matrix/script.hdrezka.video/plugin.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>from resources.lib.widgets import *
########################
if __name__ == '__main__':
plugin.run()<|fim_prefix|># repo: nsemedia/repository.nsemedia path: /matrix/script.hdrezka.video/plugin.py
#!/usr/bin/python
<|fim_middle|>########################
| code_fim | easy | {
"lang": "python",
"repo": "nsemedia/repository.nsemedia",
"path": "/matrix/script.hdrezka.video/plugin.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
plugin.run()<|fim_prefix|># repo: nsemedia/repository.nsemedia path: /matrix/script.hdrezka.video/plugin.py
#!/usr/bin/python
########################
from resources.lib.widgets import *
<|fim_middle|>########################
| code_fim | easy | {
"lang": "python",
"repo": "nsemedia/repository.nsemedia",
"path": "/matrix/script.hdrezka.video/plugin.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Example:
>>> response = get_user_by_id(123456)
>>> pprint(response)
[1234] my_username
.. admonition:: Example Response
:class: toggle
.. literalinclude:: ../sample_data/get_user_by_id.py
Returns:
Response dict containing user reco... | code_fim | hard | {
"lang": "python",
"repo": "JWCook/pyinaturalist",
"path": "/pyinaturalist/v1/users.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JWCook/pyinaturalist path: /pyinaturalist/v1/users.py
from logging import getLogger
from pyinaturalist.constants import API_V1, IntOrStr, JsonResponse
from pyinaturalist.converters import convert_all_timestamps, convert_generic_timestamps
from pyinaturalist.docs import document_request_params
fr... | code_fim | medium | {
"lang": "python",
"repo": "JWCook/pyinaturalist",
"path": "/pyinaturalist/v1/users.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_search_match(query):
search = query.search('name', val='UNKNOWN', searchtype='match')
assert isinstance(search, pd.DataFrame)
assert search.shape[0] == 1
assert search['name'].iloc[0] == 'UNKNOWN'
def test_get_id(query):
fleet_id = query.get_id('Mock Fleet')
assert fleet... | code_fim | hard | {
"lang": "python",
"repo": "ge-flight-analytics/emspy",
"path": "/tests/test_fleet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> c = MockConnection(user='', pwd='')
ems = MockEMS(c)
FleetQuery = Fleet(c, ems.get_id())
return FleetQuery
def test_data_colnames(query):
expected_colnames = {
'id',
'name'
}
assert set(query.data_colnames()) == expected_colnames
def test_list_all(query):
... | code_fim | medium | {
"lang": "python",
"repo": "ge-flight-analytics/emspy",
"path": "/tests/test_fleet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ge-flight-analytics/emspy path: /tests/test_fleet.py
import pytest
from emspy.query import Fleet
from mock_connection import MockConnection
from mock_ems import MockEMS
import pandas as pd
@pytest.fixture(scope='session')
def query():
c = MockConnection(user='', pwd='')
ems = MockEMS(c)... | code_fim | hard | {
"lang": "python",
"repo": "ge-flight-analytics/emspy",
"path": "/tests/test_fleet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ketch/pyclaw path: /src/petclaw/clawpack.py
r"""
Module containing the PetClaw solvers
This file currently only exists so that these solvers have a different
__module__ property, used by pyclaw.solver.Solver.__init__ to
determine the containing claw_package to use.
<|fim_suffix|># =============... | code_fim | hard | {
"lang": "python",
"repo": "ketch/pyclaw",
"path": "/src/petclaw/clawpack.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> r"""
PetClaw solver for 2D problems using classic Clawpack algorithms.
This class implements nothing; it just inherits from ClawSolver2D.
Note that only the fortran routines are supported for now in 2D.
"""
# ==================================================================... | code_fim | hard | {
"lang": "python",
"repo": "ketch/pyclaw",
"path": "/src/petclaw/clawpack.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> This class implements nothing; it just inherits from ClawSolver2D.
Note that only the fortran routines are supported for now in 2D.
"""
# ============================================================================
# PetClaw 3d Solver Class
# ========================================... | code_fim | hard | {
"lang": "python",
"repo": "ketch/pyclaw",
"path": "/src/petclaw/clawpack.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ROBOTIS-GIT/turtlebot3_autorace_2020 path: /turtlebot3_autorace_detect/nodes/detect_traffic_light
ect.cfg import DetectTrafficLightParamsConfig
class DetectTrafficLight():
def __init__(self):
self.hue_red_l = rospy.get_param("~detect/lane/red/hue_l", 0)
self.hue_red_h = rospy... | code_fim | hard | {
"lang": "python",
"repo": "ROBOTIS-GIT/turtlebot3_autorace_2020",
"path": "/turtlebot3_autorace_detect/nodes/detect_traffic_light",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> cv_image_mask = self.fnMaskGreenTrafficLight()
cv_image_mask = cv2.GaussianBlur(cv_image_mask,(5,5),0)
status1 = self.fnFindCircleOfTrafficLight(cv_image_mask, 'green')
if status1 == 1 or status1 == 5:
rospy.loginfo("detect GREEN")
self.stop_count =... | code_fim | hard | {
"lang": "python",
"repo": "ROBOTIS-GIT/turtlebot3_autorace_2020",
"path": "/turtlebot3_autorace_detect/nodes/detect_traffic_light",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def testNotebook(request):
context={}
return render(request, 'bonjour.ipynb', context)
def afficherPage(request, niveau, chapitre, id):
"""Affiche une page de cours"""
global titres
context = {'titre': titres[niveau][chapitre][id]}
context['niveau'] = niveau
context['chapit... | code_fim | hard | {
"lang": "python",
"repo": "stephane-robin/toketa",
"path": "/home/views.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stephane-robin/toketa path: /home/views.py
from django.shortcuts import render
# dictionnaire indiquant les titres des pages et leurs types
titres = {
'maths': {
'calcul': [
'Python pour le calcul de fractions',
'Savoir calculer avec les puissances',
... | code_fim | hard | {
"lang": "python",
"repo": "stephane-robin/toketa",
"path": "/home/views.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def afficherQuiz(request, niveau, chapitre, id):
"""Affiche une page de quiz de 10 questions rassemblees"""
context = {
'niveau': niveau,
'chapitre': chapitre,
'id': id
}
return render(request, 'quizJS.html', context)
def recupererNiveau(niveau):
"""Renvoie to... | code_fim | hard | {
"lang": "python",
"repo": "stephane-robin/toketa",
"path": "/home/views.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bimri/programming_python path: /chapter_8/PIL.py
"Viewing and Processing Images with PIL"
'''
Python tkinter scripts show images by associating independently
created image objects with real widget objects. At this writing, tkinter GUIs can display
photo image files in GIF, PPM, and PGM formats by... | code_fim | hard | {
"lang": "python",
"repo": "bimri/programming_python",
"path": "/chapter_8/PIL.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>PIL, the Python Imaging Library, is an open source system that supports nearly 30
graphics file formats (including GIF, JPEG, TIFF, PNG, and BMP).
PIL also provides tools for image processing, including geometric transforms, thumbnail
creation, format conversions, and much more.
'''<|fim_prefix|># repo: b... | code_fim | hard | {
"lang": "python",
"repo": "bimri/programming_python",
"path": "/chapter_8/PIL.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TinkerMill/TinkerSpaceCommand path: /SpaceCommandServer/TinkerSpaceCommandServer/Messages.py
#
# This file contains constants and methods for messages sent through
# TinkerSpaceCommand.
#
# The value in the message envelope for the type of message that has come in.
MESSAGE_FIELD_MESSAGE_TYPE = "... | code_fim | medium | {
"lang": "python",
"repo": "TinkerMill/TinkerSpaceCommand",
"path": "/SpaceCommandServer/TinkerSpaceCommandServer/Messages.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>MESSAGE_FIELD_DATA = "data"
MESSAGE_FIELD_VALUE = "value"<|fim_prefix|># repo: TinkerMill/TinkerSpaceCommand path: /SpaceCommandServer/TinkerSpaceCommandServer/Messages.py
#
# This file contains constants and methods for messages sent through
# TinkerSpaceCommand.
#
# The value in the message envelope f... | code_fim | medium | {
"lang": "python",
"repo": "TinkerMill/TinkerSpaceCommand",
"path": "/SpaceCommandServer/TinkerSpaceCommandServer/Messages.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> margins = self.contentsMargins()
hh = self.horizontalHeader()
vh = self.verticalHeader()
hsb = self.horizontalScrollBar()
vsb = self.verticalScrollBar()
vsb.setMaximumWidth(17)
hsb.setMaximumHeight(17)
numCols, numRows = (2,... | code_fim | medium | {
"lang": "python",
"repo": "mhogg/BMDanalyse",
"path": "/BMDanalyse/TableWidget.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mhogg/BMDanalyse path: /BMDanalyse/TableWidget.py
# -*- coding: utf-8 -*-
# Copyright (C) 2016 Michael Hogg
# This file is part of BMDanalyse - See LICENSE.txt for information on usage and redistribution
from pyqtgraph.Qt import QtCore,QtGui
class TableWidget(QtGui.QTableWidget):
def... | code_fim | hard | {
"lang": "python",
"repo": "mhogg/BMDanalyse",
"path": "/BMDanalyse/TableWidget.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # add env to bashrc
bashrc_file = os.path.join(os.getenv("HOME"), ".bashrc")
try:
bashrc_read_stream = open(bashrc_file, 'r')
all_lines = []
while True:
lines = bashrc_read_stream.readlines(10000)
if not lines:
break
a... | code_fim | hard | {
"lang": "python",
"repo": "Suforlove/ascenddk",
"path": "/scripts/travis_scripts/env_init.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Suforlove/ascenddk path: /scripts/travis_scripts/env_init.py
''' env init '''
# -*- coding: UTF-8 -*-
#
# =======================================================================
# Copyright (C), 2018, Huawei Tech. Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License... | code_fim | hard | {
"lang": "python",
"repo": "Suforlove/ascenddk",
"path": "/scripts/travis_scripts/env_init.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Crea un cubo solido de arista 1.0"""
obj = glGenLists(1)
glNewList(obj, GL_COMPILE)
glPushMatrix()
glColor4fv(color)
try:
glutSolidCube(1.0)
except:
if not _ERRS[3]:
printGLError(
"la version actual de OpenGL no posee la funcion gl... | code_fim | hard | {
"lang": "python",
"repo": "danno-s/tarea-3-modelacion-grafica",
"path": "/bin/pygltoolbox/figures.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Crea un cono de base y altura de radio 1.0"""
if lat >= 3 and lng >= 10:
circlebase = create_circle(base - 0.05, 0.1, [0.0, 0.0, -1.0], color)
obj = glGenLists(1)
glNewList(obj, GL_COMPILE)
glPushMatrix()
glColor4fv(color)
try:
glutSol... | code_fim | hard | {
"lang": "python",
"repo": "danno-s/tarea-3-modelacion-grafica",
"path": "/bin/pygltoolbox/figures.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danno-s/tarea-3-modelacion-grafica path: /bin/pygltoolbox/figures.py
texlen = 0
else:
self.texlen = len(self.texture)
else:
raise Exception("total_vertex debe ser del tipo int")
else:
raise Exception(
... | code_fim | hard | {
"lang": "python",
"repo": "danno-s/tarea-3-modelacion-grafica",
"path": "/bin/pygltoolbox/figures.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmeybohm/editorconfig-git-preserve-history path: /editorconfig_git_preserve_history/__main__.py
#!/usr/bin/env python3
import os
import re
import sys
from editorconfig import get_properties, EditorConfigError
from . import git
from .change import Change, ChangesByCommit
from .util import run
fr... | code_fim | hard | {
"lang": "python",
"repo": "dmeybohm/editorconfig-git-preserve-history",
"path": "/editorconfig_git_preserve_history/__main__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def find_and_write_commits():
if git.has_changes():
print("You have modified files!\n\n")
print("Only run this script on a pristine tree.")
sys.exit(1)
for change_file in git.list_text_files():
if len(change_file) == 0:
continue
try:
... | code_fim | hard | {
"lang": "python",
"repo": "dmeybohm/editorconfig-git-preserve-history",
"path": "/editorconfig_git_preserve_history/__main__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scalet98/glue path: /glue/viewers/scatter/viewer.py
from __future__ import absolute_import, division, print_function
from glue.core.subset import roi_to_subset_state
from glue.core.util import update_ticks
from glue.utils import mpl_to_datetime64
from glue.viewers.scatter.compat import update_s... | code_fim | hard | {
"lang": "python",
"repo": "scalet98/glue",
"path": "/glue/viewers/scatter/viewer.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.state.y_att is not None:
# Update ticks, which sets the labels to categories if components are categorical
update_ticks(self.axes, 'y', self.state.y_kinds, self.state.y_log, self.state.y_categories)
if self.state.y_log:
self.state.y_axi... | code_fim | hard | {
"lang": "python",
"repo": "scalet98/glue",
"path": "/glue/viewers/scatter/viewer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> subset_state = roi_to_subset_state(roi,
x_att=self.state.x_att, x_categories=self.state.x_categories,
y_att=self.state.y_att, y_categories=self.state.y_categories)
self.apply_subset_state(subset_state, o... | code_fim | hard | {
"lang": "python",
"repo": "scalet98/glue",
"path": "/glue/viewers/scatter/viewer.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shivamraj74/django-shop path: /shop/serializers/auth.py
from django.conf import settings
from django.template.loader import select_template
from django.urls import NoReverseMatch, reverse
from django.utils.translation import get_language_from_request
from cms.models.pagemodel import Page
from res... | code_fim | hard | {
"lang": "python",
"repo": "shivamraj74/django-shop",
"path": "/shop/serializers/auth.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def save(self):
subject_template = select_template([
'{}/email/password-reset-subject.txt'.format(app_settings.APP_LABEL),
'shop/email/password-reset-subject.txt',
])
body_text_template = select_template([
'{}/email/password-reset-body.txt'.f... | code_fim | hard | {
"lang": "python",
"repo": "shivamraj74/django-shop",
"path": "/shop/serializers/auth.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> msg = "M310: timeutils.utcnow() must be used instead of datetime.%s()"
datetime_funcs = ['now', 'utcnow']
for f in datetime_funcs:
pos = logical_line.find('datetime.%s' % f)
if pos != -1:
yield (pos, msg % f)
@core.flake8ext
def dict_constructor_with_list_copy(log... | code_fim | hard | {
"lang": "python",
"repo": "openstack/magnum",
"path": "/magnum/hacking/checks.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/magnum path: /magnum/hacking/checks.py
# Copyright (c) 2015 Intel, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http:/... | code_fim | hard | {
"lang": "python",
"repo": "openstack/magnum",
"path": "/magnum/hacking/checks.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Draw the inner circle (colour should be equal to the background)
Color(0, 0, 0)
Ellipse(pos=(self.pos[0] + self.thickness / 2, self.pos[1] + self.thickness / 2),
size=(self.size[0] - self.thickness, self.size[1] - self.thickness))
# Ce... | code_fim | hard | {
"lang": "python",
"repo": "0wuxinyun/project4dprinter",
"path": "/%HOMEPATH%/kivygui/Clock_Online.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: 0wuxinyun/project4dprinter path: /%HOMEPATH%/kivygui/Clock_Online.py
from kivy.app import App
from kivy.uix.progressbar import ProgressBar
from kivy.core.text import Label as CoreLabel
from kivy.lang.builder import Builder
from kivy.graphics import Color, Ellipse, Rectangle
from kivy.clock import... | code_fim | hard | {
"lang": "python",
"repo": "0wuxinyun/project4dprinter",
"path": "/%HOMEPATH%/kivygui/Clock_Online.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>@receiver(pre_delete, sender=Auction, dispatch_uid='auction_pre_delete')
def auction_pre_delete(sender, instance, using, **kwargs):
key = "auction:%s" % instance.lot.slug
cache.delete(key)
class BidBasketManager(models.Manager):
def get_basket(self, user):
key = "basket:%s" % user.u... | code_fim | hard | {
"lang": "python",
"repo": "plankter/augeo-cloud",
"path": "/auctions/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class BidManager(models.Manager):
def get_highest_bid(self, auction):
key = "highest_bid:%s" % auction.lot.slug
highest_bid = cache.get(key)
if not highest_bid:
try:
highest_bid = Bid.objects.filter(auction=auction).aggregate(models.Max('amount'))... | code_fim | hard | {
"lang": "python",
"repo": "plankter/augeo-cloud",
"path": "/auctions/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: plankter/augeo-cloud path: /auctions/models.py
from datetime import time
from decimal import Decimal
from django.core.cache import cache
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import reverse
from django.db import models
from django.contrib.auth.models... | code_fim | hard | {
"lang": "python",
"repo": "plankter/augeo-cloud",
"path": "/auctions/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexlib/PyPostPiv path: /pypostpiv/math.py
"""
A set of functions for basic field operations
"""
import warnings
import numpy as np
def fsum(field, axis):
return np.nansum(field, axis=0, keepdims=True)
def mag(field):
"""
Compute the magnitude of the field.
Parameters
----... | code_fim | hard | {
"lang": "python",
"repo": "alexlib/PyPostPiv",
"path": "/pypostpiv/math.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif method == 'richardson':
new_field = field[:,2:-2,4:] - 8*field[:,2:-2,3:-1] + 8*field[:,2:-2,1:-3] - field[:,2:-2,:-4]
new_field = new_field/field.dL/12
new_field.x = field.x[2:-2,2:-2]
new_field.y = field.y[2:-2,2:-2]
return new_field
elif method == '... | code_fim | hard | {
"lang": "python",
"repo": "alexlib/PyPostPiv",
"path": "/pypostpiv/math.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sanjeevkanabargi/python path: /stream/addfields.py
import json
import random
filepath = "/Users/skanabargi/dataSource/firewall/cfw-less-data"
def generateDict(field):
randDic = {field : {
"AccuracyRadius": random.randint(1,101),
"Latitude": random.randint(1,101),
"Longitude": random.... | code_fim | hard | {
"lang": "python",
"repo": "sanjeevkanabargi/python",
"path": "/stream/addfields.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> print(jsonString)
#Change into extended json message with extra data.<|fim_prefix|># repo: sanjeevkanabargi/python path: /stream/addfields.py
import json
import random
filepath = "/Users/skanabargi/dataSource/firewall/cfw-less-data"
def generateDict(field):
<|fim_middle|> randDic = {fiel... | code_fim | hard | {
"lang": "python",
"repo": "sanjeevkanabargi/python",
"path": "/stream/addfields.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> jsonString.update(dest)
jsonString.update(src)
print(jsonString)
#Change into extended json message with extra data.<|fim_prefix|># repo: sanjeevkanabargi/python path: /stream/addfields.py
import json
import random
filepath = "/Users/skanabargi/dataSource/firewall/cfw-les... | code_fim | hard | {
"lang": "python",
"repo": "sanjeevkanabargi/python",
"path": "/stream/addfields.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BBN-Q/Auspex path: /src/auspex/log.py
# Copyright 2016 Raytheon BBN Technologies
#
# 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://www.apache.org/licenses/L... | code_fim | medium | {
"lang": "python",
"repo": "BBN-Q/Auspex",
"path": "/src/auspex/log.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>if in_jupyter():
importlib.reload(logging)
logger.handlers = [logging.StreamHandler(sys.stdout)]
formatter = logging.Formatter('%(name)s-%(levelname)s: %(asctime)s ----> %(message)s')
logger.handlers[0].setFormatter(formatter)
else:
logging.basicConfig(format='%(name)s-%(levelname)s: %(as... | code_fim | medium | {
"lang": "python",
"repo": "BBN-Q/Auspex",
"path": "/src/auspex/log.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return f'{self.message}.'
class MultiplicationMatrixError(Exception):
'''
Exception raised for errors when the matrices to be multiplied have
the wrong dimensions
'''
def __init__(self,
message='The first matrix needs to have the number of '
... | code_fim | hard | {
"lang": "python",
"repo": "jairNeto/basic_matrix_algebra",
"path": "/jair_matrices/exceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jairNeto/basic_matrix_algebra path: /jair_matrices/exceptions.py
'''Exceptions module.'''
class DimensionMatrixError(Exception):
'''
Exception raised for errors when the matrix has zero columns
or zero rows.
'''
def __init__(self,
dimension='row',
... | code_fim | hard | {
"lang": "python",
"repo": "jairNeto/basic_matrix_algebra",
"path": "/jair_matrices/exceptions.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.