text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: slowy07/luna path: /stable_diffusion_tensorflow/diffusion_model.py
import tensorflow as tf
from tensorflow import keras
import tensorflow_addons as tfa
from .layers import PaddedConv2D, apply_seq, td_dot, GEGLU
class ResBlock(keras.layers.Layer):
def __init__(self, channels, out_channels):... | code_fim | hard | {
"lang": "python",
"repo": "slowy07/luna",
"path": "/stable_diffusion_tensorflow/diffusion_model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Downsample(keras.layers.Layer):
def __init__(self, channels):
super().__init__()
self.op = PaddedConv2D(channels, 3, stride=2, padding=1)
def call(self, x):
return self.op(x)
class Upsample(keras.layers.Layer):
def __init__(self, channels):
super().__i... | code_fim | hard | {
"lang": "python",
"repo": "slowy07/luna",
"path": "/stable_diffusion_tensorflow/diffusion_model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nansencenter/DAPPER path: /dapper/mods/Lorenz63/anderson2010rhf.py
"""Settings from `bib.anderson2010non`."""
import numpy as np
import dapper.mods as modelling
from dapper.mods.Lorenz63 import Tplot, dstep_dx, step, x0
tseq = modelling.Chronology(0.01, dko=12, Ko=1000, Tplot=Tplot, BurnIn=4*T... | code_fim | medium | {
"lang": "python",
"repo": "nansencenter/DAPPER",
"path": "/dapper/mods/Lorenz63/anderson2010rhf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Dyn = {
'M': Nx,
'model': step,
'linear': dstep_dx,
'noise': 0,
}
X0 = modelling.GaussRV(C=2, mu=x0)
Obs = modelling.partial_Id_Obs(Nx, np.arange(Nx))
Obs['noise'] = 8.0
HMM = modelling.HiddenMarkovModel(Dyn, Obs, tseq, X0)
####################
# Suggested tuning
####################
... | code_fim | medium | {
"lang": "python",
"repo": "nansencenter/DAPPER",
"path": "/dapper/mods/Lorenz63/anderson2010rhf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"id"):
print(''.join(line.split(" ")[1]).strip(), file = fo, end = '\t')
elif line.startswith("name:",0,5):
print(' '.join(line.split(" ")[1:]).strip(), file = fo, end = '\t')
elif line.startswith("namespace",0,9):
print(line.split(" ... | code_fim | hard | {
"lang": "python",
"repo": "yjiakang/Bioinfo-Practice",
"path": "/parse_go.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yjiakang/Bioinfo-Practice path: /parse_go.py
#!/usr/bin/env python
#-*-utf-8-*-
#jk yin
#2020.08
import argparse
parser = argparse.ArgumentParser(description = "\nThis python script is used to parse the go-basic.obo file into tab delimited table", add_help = False, usage = "\n python3 parse_go.py... | code_fim | hard | {
"lang": "python",
"repo": "yjiakang/Bioinfo-Practice",
"path": "/parse_go.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if numbsers:
return numbsers.pop() + checkio(numbsers)
return 0<|fim_prefix|># repo: JKChang2015/Checkio path: /Checkio/restricted_sum.py
# restricted_sum
# Created by JKChang
# 2019-08-05, 10:40
# Tag:
# Description:
# Our new calculator is censored and as such it does not accept certain... | code_fim | medium | {
"lang": "python",
"repo": "JKChang2015/Checkio",
"path": "/Checkio/restricted_sum.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JKChang2015/Checkio path: /Checkio/restricted_sum.py
# restricted_sum
# Created by JKChang
# 2019-08-05, 10:40
# Tag:
# Description:
# Our new calculator is censored and as such it does not accept certain words. You should try to trick by writing a program to calculate the sum of numbers.
#
# Giv... | code_fim | medium | {
"lang": "python",
"repo": "JKChang2015/Checkio",
"path": "/Checkio/restricted_sum.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bytedance/byteir path: /frontends/onnx-frontend/test/models/test_large_model.py
import pytest
from test.base import TestBase
from test.env import LARGE_MODEL_PATH
class TestLargeModel(TestBase):
<|fim_suffix|> input_shape_dtype = [
["data", (8, 3, 224, 224), "float32"],
... | code_fim | hard | {
"lang": "python",
"repo": "bytedance/byteir",
"path": "/frontends/onnx-frontend/test/models/test_large_model.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_shape_dtype = [
["data", (8, 3, 224, 224), "float32"],
]
# bs=8 in resnet50-v1-7.onnx
self.run(model_filename="resnet50-v1-7.onnx", input_shape_dtype=input_shape_dtype)
def test_transformer(self):
input_shape_dtype = [
["fbank", (2... | code_fim | hard | {
"lang": "python",
"repo": "bytedance/byteir",
"path": "/frontends/onnx-frontend/test/models/test_large_model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_shape_dtype = [
["fbank", (2, 128, 80), "float32"],
]
self.run(model_filename="transformer_encoder_-1x128x80.onnx", input_shape_dtype=input_shape_dtype, batch_size=2)<|fim_prefix|># repo: bytedance/byteir path: /frontends/onnx-frontend/test/models/test_large_mode... | code_fim | medium | {
"lang": "python",
"repo": "bytedance/byteir",
"path": "/frontends/onnx-frontend/test/models/test_large_model.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>urlpatterns = [
path('admin/', admin.site.urls),
# GraphQL
path('', csrf_exempt(AuthenticatedGraphQLView.as_view(graphiql=True))), # Private graphiQL url
path('graphql/', csrf_exempt(AuthenticatedGraphQLView.as_view(graphiql=True))), # Private graphiQL url
# REST Api
url(r'^docs/',... | code_fim | medium | {
"lang": "python",
"repo": "kwangnam/redfish",
"path": "/src/django_server/django_server/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kwangnam/redfish path: /src/django_server/django_server/urls.py
from django.urls import path, re_path
from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView
# GraphQL
from django.views.decorators.csrf import csrf_exempt
from custo... | code_fim | medium | {
"lang": "python",
"repo": "kwangnam/redfish",
"path": "/src/django_server/django_server/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>polygon1 = Polygon(contour.getSimplify(0.25), translate=[-15.0, 200.0])
polygon2 = Polygon(contour.getSimplify(0.25), translate=[15.0, 200.0])
axi.add(polygon1)
axi.add(polygon2)
indices = polygon1.getIntersections(polygon2)
for index in indices:
axi.circle( polygon1.getPointAtIndexInterpolated(index)... | code_fim | medium | {
"lang": "python",
"repo": "patriciogonzalezvivo/AxiSurface",
"path": "/examples/polyline.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: patriciogonzalezvivo/AxiSurface path: /examples/polyline.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from AxiSurface import *
# Depth
height... | code_fim | hard | {
"lang": "python",
"repo": "patriciogonzalezvivo/AxiSurface",
"path": "/examples/polyline.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># contour.
contour.head_width = 0.25
contour.fill = False
contour.stroke_width = 2.0
contour.translate=[100.0, 0.0]
axi.add( contour )
axi.text( "stroke_width=2", center=[150.0, 92.0], scale=0.1 )
axi.text( "head_width=0.25", center=[150.0, 97.0], scale=0.1 )
axi.toSVG('polyline.svg')
# axi.toPNG('poly... | code_fim | hard | {
"lang": "python",
"repo": "patriciogonzalezvivo/AxiSurface",
"path": "/examples/polyline.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AnyBuzzin/PokerCFR path: /RockPaperScissors.py
import numpy as np
from numpy.random import choice
class RPSTrainer:
def __init__(self):
self.NUM_ACTIONS = 3
self.possible_actions = np.arange(self.NUM_ACTIONS)
# Order left to right, and up to down is Rock, P... | code_fim | hard | {
"lang": "python",
"repo": "AnyBuzzin/PokerCFR",
"path": "/RockPaperScissors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_strategy(self, regret_sum):
new_sum = np.clip(regret_sum, a_min=0, a_max=None)
normalizing_sum = np.sum(new_sum)
if normalizing_sum > 0:
new_sum /= normalizing_sum
else:
new_sum = np.repeat(1/self.NUM_ACTIONS, self.NUM_ACTIONS)
... | code_fim | hard | {
"lang": "python",
"repo": "AnyBuzzin/PokerCFR",
"path": "/RockPaperScissors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def train(self, iterations):
for i in range(iterations):
strategy = self.get_strategy(self.regret_sum)
opp_strategy = self.get_strategy(self.opponent_regret_sum)
self.strategy_sum += strategy
self.opponent_strategy_sum += opp_strategy
... | code_fim | hard | {
"lang": "python",
"repo": "AnyBuzzin/PokerCFR",
"path": "/RockPaperScissors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: turovod/Otus path: /9_Lesson9/exceptions/example2-multipleexceptions.py
# First example
my_dict = {"a": 1, "b": 2, "c": 3}
<|fim_suffix|># Second example
try:
value = my_dict["d"]
except (IndexError, KeyError):
print("An IndexError or KeyError occurred!")<|fim_middle|>try:
value = ... | code_fim | hard | {
"lang": "python",
"repo": "turovod/Otus",
"path": "/9_Lesson9/exceptions/example2-multipleexceptions.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>try:
value = my_dict["d"]
except (IndexError, KeyError):
print("An IndexError or KeyError occurred!")<|fim_prefix|># repo: turovod/Otus path: /9_Lesson9/exceptions/example2-multipleexceptions.py
# First example
my_dict = {"a": 1, "b": 2, "c": 3}
<|fim_middle|>try:
value = my_dict["d"]
excep... | code_fim | hard | {
"lang": "python",
"repo": "turovod/Otus",
"path": "/9_Lesson9/exceptions/example2-multipleexceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Second example
try:
value = my_dict["d"]
except (IndexError, KeyError):
print("An IndexError or KeyError occurred!")<|fim_prefix|># repo: turovod/Otus path: /9_Lesson9/exceptions/example2-multipleexceptions.py
# First example
my_dict = {"a": 1, "b": 2, "c": 3}
<|fim_middle|>try:
value = ... | code_fim | hard | {
"lang": "python",
"repo": "turovod/Otus",
"path": "/9_Lesson9/exceptions/example2-multipleexceptions.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def _build_ec2_mapping_from_sg(resource_to_analyse, result_dict, session):
"""Build the mapping SG -> resources for EC2"""
for instance, security_group in _generate_ec2_instance_and_sg(resource_to_analyse):
sg_dict = _check_if_in_list(result_dict, security_group["GroupId"], "sg_id")
... | code_fim | hard | {
"lang": "python",
"repo": "pgupta35/aws-sg-tools",
"path": "/sgmapping.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pgupta35/aws-sg-tools path: /sgmapping.py
import boto3
import csv, StringIO
import argparse
import sys
def _check_if_in_list(dict_list, value, key):
"""Check if an elements exists in a list of dictionaries for a specific key/value pair"""
if dict_list is None:
return None
ret... | code_fim | hard | {
"lang": "python",
"repo": "pgupta35/aws-sg-tools",
"path": "/sgmapping.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> transactions = [
Transaction(statements=[
Statement(changes=[
Change(table='`binlog_analyser`.`a_table`',
where_parameters={1: 100}, set_parameters={}),
Change(table='`binlog_analyser`.`a_table`',
... | code_fim | hard | {
"lang": "python",
"repo": "mercos/mysql-binlog-explorer",
"path": "/tests/test_binlog_analyser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mercos/mysql-binlog-explorer path: /tests/test_binlog_analyser.py
from unittest import TestCase
from binlogexplorer.binlog_analyser import BinlogAnalyser
from binlogexplorer.binlog_parser import Transaction, Statement, Change
class BinlogAnalyserTests(TestCase):
def test_group_changes_by_i... | code_fim | hard | {
"lang": "python",
"repo": "mercos/mysql-binlog-explorer",
"path": "/tests/test_binlog_analyser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> to_user_id_name = msg['ToUserName']
from_user_id_name = msg['FromUserName']
if is_my_outgoing_msg(msg):
handle_outgoing_msg(msg, to_user_id_name)
else: # this is an incoming message from my friend
handle_incoming_msg(msg, from_user_id_name)
def handle_outgoing_msg(msg, ... | code_fim | hard | {
"lang": "python",
"repo": "codemonkeycxy/pondness",
"path": "/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codemonkeycxy/pondness path: /server.py
# coding=utf8
from __future__ import print_function, division
import os
import csv
import re
import ujson
import itchat
import datetime
from itchat.content import *
from collections import defaultdict
# stupid python encode workarounds
# https://stackove... | code_fim | hard | {
"lang": "python",
"repo": "codemonkeycxy/pondness",
"path": "/server.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return datetime.datetime.now()
def log(msg):
try:
print(u'{} {}'.format(now(), msg))
except Exception as e:
print(str(e))
# https://www.geeksforgeeks.org/maximum-consecutive-repeating-character-string/
def get_max_repeating_char(string):
total_len = len(string)
coun... | code_fim | hard | {
"lang": "python",
"repo": "codemonkeycxy/pondness",
"path": "/server.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ada.strip() == "":
print(f'Erro! "{entrada}" não é um valor.')
else:
valida = True
return float(entrada)<|fim_prefix|># repo: Helton-Rubens/Python-3 path: /exercicios/ex112/UtilidadesdeDev/dado/__init__.py
def leiaValor(a):
"""
Essa função lê um valor e... | code_fim | hard | {
"lang": "python",
"repo": "Helton-Rubens/Python-3",
"path": "/exercicios/ex112/UtilidadesdeDev/dado/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>el.
"""
valida = False
while not valida:
entrada = str(input(a).strip().replace(',', '.'))
if entrada.isalpha() or entrada.strip() == "":
print(f'Erro! "{entrada}" não é um valor.')
else:
valida = True
return float(entrada)<|fim_prefi... | code_fim | medium | {
"lang": "python",
"repo": "Helton-Rubens/Python-3",
"path": "/exercicios/ex112/UtilidadesdeDev/dado/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Helton-Rubens/Python-3 path: /exercicios/ex112/UtilidadesdeDev/dado/__init__.py
def leiaValor(a):
"""
Essa função lê um valor e faz uma validação.
:param a: Uma mensagem do tipo string que será usada como um input,
<|fim_suffix|>el.
"""
valida = False
while not valida:
... | code_fim | medium | {
"lang": "python",
"repo": "Helton-Rubens/Python-3",
"path": "/exercicios/ex112/UtilidadesdeDev/dado/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>##PLOT LABELLING#
ax0.set_ylabel(tex_s(r'$P_{\text{pv}}\;[\si{\watt}]$'), wrap=True)
ax1.set_ylabel(tex_s(r'$P_{r}\;[\si{\watt}]$'), wrap=True)
ax1.set_xlabel("Date", labelpad=-14)
fig.savefig(FIG_SAVE_PATH + "plot_pv_resd_scenario.pdf", bbox_inches='tight')<|fim_prefix|># repo: michchr/pyhybridcontrol ... | code_fim | medium | {
"lang": "python",
"repo": "michchr/pyhybridcontrol",
"path": "/examples/residential_mg_with_pv_and_dewhs/plotting/plot_pv_resd_scenario.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: michchr/pyhybridcontrol path: /examples/residential_mg_with_pv_and_dewhs/plotting/plot_pv_resd_scenario.py
from examples.residential_mg_with_pv_and_dewhs.plotting.plotting_helper import *
import os
import glob
from structdict import OrderedStructDict
<|fim_suffix|>dates = IDX['2018-12-10':'2018-... | code_fim | hard | {
"lang": "python",
"repo": "michchr/pyhybridcontrol",
"path": "/examples/residential_mg_with_pv_and_dewhs/plotting/plot_pv_resd_scenario.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZhiangChen/target_mapping path: /src/utils/odom2tfmsg.py
#!/usr/bin/env python
"""
Zhiang Chen
Jan 2021
convert nav_msgs/Odometry to geometry_msgs/TransformStamped for pointcloud registration using voxblox
"""
<|fim_suffix|>class Odom2tfmsg(object):
def __init__(self):
self.tfmsg_pub... | code_fim | medium | {
"lang": "python",
"repo": "ZhiangChen/target_mapping",
"path": "/src/utils/odom2tfmsg.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> tfmsg = TransformStamped()
tfmsg.header = data.header
tfmsg.child_frame_id = "pointcloud_camera"
tfmsg.transform.translation.x = data.pose.pose.position.x
tfmsg.transform.translation.y = data.pose.pose.position.y
tfmsg.transform.translation.z = data.pose.pos... | code_fim | hard | {
"lang": "python",
"repo": "ZhiangChen/target_mapping",
"path": "/src/utils/odom2tfmsg.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class RoutineAdmin(admin.ModelAdmin):
list_display = ('name', 'description', 'topic', 'updated_date')
inlines = [EffortInline]
admin.site.register(Topic, TopicAdmin)
admin.site.register(Challenge, ChallengeAdmin)
admin.site.register(Routine, RoutineAdmin)<|fim_prefix|># repo: glts/django-progres... | code_fim | hard | {
"lang": "python",
"repo": "glts/django-progress",
"path": "/admin.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: glts/django-progress path: /admin.py
from django.contrib import admin
from .models import Topic, Challenge, Routine, Portion, Effort
class TopicAdmin(admin.ModelAdmin):
list_display = ('title', 'created_date', 'updated_date')
<|fim_suffix|>class ChallengeAdmin(admin.ModelAdmin):
list... | code_fim | medium | {
"lang": "python",
"repo": "glts/django-progress",
"path": "/admin.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Output 2:
Input:
3
Output:
*
* *
* * *
n=int(input())
for i in range(1,n+1):
for j in range(1,i+1):
print("*",end=" ")
print()<|fim_prefix|># repo: muhammad-masood-ur-rehman/Skillrack path: /Python Programs/pattern-printing-half-pyramid-using-asterisk.py
Pattern Printing - Half Pyramid U... | code_fim | hard | {
"lang": "python",
"repo": "muhammad-masood-ur-rehman/Skillrack",
"path": "/Python Programs/pattern-printing-half-pyramid-using-asterisk.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: muhammad-masood-ur-rehman/Skillrack path: /Python Programs/pattern-printing-half-pyramid-using-asterisk.py
Pattern Printing - Half Pyramid Using Asterisk
The number of rows N is passed as the input. The program must print the half pyramid using asterisk *.
Input Format:
The first line contains N... | code_fim | medium | {
"lang": "python",
"repo": "muhammad-masood-ur-rehman/Skillrack",
"path": "/Python Programs/pattern-printing-half-pyramid-using-asterisk.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: InstitutoDOr/bids_events path: /tests/manual/populate_logs.py
# TEST ENV SET UP
import sys
sys.path.insert(0,'tests')
import setup_test
<|fim_suffix|># Saving data
events_h = EventHandler('example_events.tsv')
events_h.trials = [
['onset', 'duration', 'condition'],
[0, 20, 'STOP'],
... | code_fim | medium | {
"lang": "python",
"repo": "InstitutoDOr/bids_events",
"path": "/tests/manual/populate_logs.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Saving data
events_h = EventHandler('example_events.tsv')
events_h.trials = [
['onset', 'duration', 'condition'],
[0, 20, 'STOP'],
[20, 20, 'GO'],
[40, 20, 'STOP'],
[60, 20, 'GO'],
[80, 20, 'STOP'],
[100, 20, 'GO'],
[120, 20, 'STOP'],
[140, 20, 'GO'],
[160, ... | code_fim | medium | {
"lang": "python",
"repo": "InstitutoDOr/bids_events",
"path": "/tests/manual/populate_logs.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sgg10/scrapy_intelligence_agency path: /intelligence_agency/intelligence_agency/spiders/cia.py
import scrapy
from intelligence_agency.spiders.common import config
class SpiderCia(scrapy.Spider):
name = 'cia'
start_urls = [
config()["agency_sites"]["cia"]["url"]
]
custom_s... | code_fim | hard | {
"lang": "python",
"repo": "sgg10/scrapy_intelligence_agency",
"path": "/intelligence_agency/intelligence_agency/spiders/cia.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def parse(self, response):
declassified_links = response.xpath(self.queries["declassified_links"]).getall()
for link in declassified_links:
yield response.follow(link, callback=self.parse_link, cb_kwargs={'url': response.urljoin(link)})
def parse_link(self, response, *... | code_fim | medium | {
"lang": "python",
"repo": "sgg10/scrapy_intelligence_agency",
"path": "/intelligence_agency/intelligence_agency/spiders/cia.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FermiParadox/ipy_student_exercises path: /tests/test_r_int.py
from unittest import TestCase
from random import randint
from tests import REPETITIONS
from arbitrary_pieces import r_int, _ALLOWED_POS_NEG_0
class Test_r_int(TestCase):
def test_0bound_exactly_0(self):
self.assertEquals... | code_fim | hard | {
"lang": "python",
"repo": "FermiParadox/ipy_student_exercises",
"path": "/tests/test_r_int.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> s = set()
small_n = 1
# Odds of missing the bug for enough reps is extremely small
# (about 10e-200 for 1k reps)
for _ in range(10*4):
s.update({
r_int(small_n, '+0'),
r_int(small_n, '-0'),
r_int(small_n, '... | code_fim | hard | {
"lang": "python",
"repo": "FermiParadox/ipy_student_exercises",
"path": "/tests/test_r_int.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_dual_delaunay_dual_check_points(self):
np.random.seed(0)
dual = op.network.DelaunayVoronoiDual(points=100, shape=[1, 1, 1])
assert dual.num_pores('delaunay') == 100
assert dual.num_pores('voronoi') == 567
def test_find_throat_facets(self):
np.rando... | code_fim | hard | {
"lang": "python",
"repo": "PMEAL/OpenPNM",
"path": "/tests/unit/network/VoronoiDelaunayDualTest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PMEAL/OpenPNM path: /tests/unit/network/VoronoiDelaunayDualTest.py
import numpy as np
import openpnm as op
class VoronoiTest:
def setup_class(self):
pass
def teardown_class(self):
pass
def test_dual_square_trim_and_reflect(self):
np.random.seed(0)
... | code_fim | hard | {
"lang": "python",
"repo": "PMEAL/OpenPNM",
"path": "/tests/unit/network/VoronoiDelaunayDualTest.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> np.random.seed(0)
dual = op.network.DelaunayVoronoiDual(points=100, shape=[1, 1, 1])
assert dual.num_pores('delaunay') == 100
assert dual.num_pores('voronoi') == 567
def test_find_throat_facets(self):
np.random.seed(0)
dual = op.network.DelaunayVoronoiD... | code_fim | hard | {
"lang": "python",
"repo": "PMEAL/OpenPNM",
"path": "/tests/unit/network/VoronoiDelaunayDualTest.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: contimatteo/Flatland-DMM path: /src/marl/core.py
self.callbacks_history[agent_id] = {
"actions": [],
"metrics": [],
"observations": [],
"rewards": [],
"episode": None,
"episode_reward": None,
... | code_fim | hard | {
"lang": "python",
"repo": "contimatteo/Flatland-DMM",
"path": "/src/marl/core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: contimatteo/Flatland-DMM path: /src/marl/core.py
acks_history[agent_id]['metrics']
### episode
callbacks.on_episode_begin(episode, logs={})
for episode_step in range(episode_steps):
observation = ep_observations[episode_step]
a... | code_fim | hard | {
"lang": "python",
"repo": "contimatteo/Flatland-DMM",
"path": "/src/marl/core.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # if all_done is False:
# done_dict_values_as_sum = 0
# for agent_id in agents_ids:
# done_dict_values_as_sum += int(done_dict.get(agent_id, False))
# if done_dict_values_as_sum == len(agents_ids):
... | code_fim | hard | {
"lang": "python",
"repo": "contimatteo/Flatland-DMM",
"path": "/src/marl/core.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: grnet/kamaki path: /kamaki/clients/blockstorage/__init__.py
# Copyright 2014-2015 GRNET S.A. All rights reserved.
#
# Redistribution and use in source and binary forms, with or
# without modification, are permitted provided that the following
# conditions are met:
#
# 1. Redistributions of sour... | code_fim | hard | {
"lang": "python",
"repo": "grnet/kamaki",
"path": "/kamaki/clients/blockstorage/__init__.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_volume_status(self, volume_id):
"""Deprecated, will be removed in 0.15"""
r = self.get_volume_details(volume_id)
return r['status'], None
def wait_volume(
self, volume_id, stop=None, delay=1, timeout=100, wait_cb=None):
"""Wait (block) while the... | code_fim | hard | {
"lang": "python",
"repo": "grnet/kamaki",
"path": "/kamaki/clients/blockstorage/__init__.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_volume_details(self, volume_id):
""":returns: (dict)"""
r = self.volumes_get(volume_id=volume_id)
return r.json['volume']
def create_volume(
self, size,
availability_zone=None,
source_volid=None,
display_name=None,
... | code_fim | hard | {
"lang": "python",
"repo": "grnet/kamaki",
"path": "/kamaki/clients/blockstorage/__init__.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: WISVCH/dienst2 path: /ldb/serializers.py
import logging
import reversion
from drf_writable_nested.mixins import NestedCreateMixin, NestedUpdateMixin
from rest_framework import serializers
from rest_framework.exceptions import ParseError
from rest_framework.fields import CharField, ReadOnlyField
... | code_fim | hard | {
"lang": "python",
"repo": "WISVCH/dienst2",
"path": "/ldb/serializers.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>class EmployeeSerializer(serializers.ModelSerializer):
class Meta:
model = Employee
exclude = ["person"]
class CommitteeMembershipSerializer(serializers.ModelSerializer):
committee = serializers.StringRelatedField()
class Meta:
model = CommitteeMembership
exc... | code_fim | hard | {
"lang": "python",
"repo": "WISVCH/dienst2",
"path": "/ldb/serializers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> committee = serializers.StringRelatedField()
class Meta:
model = CommitteeMembership
exclude = ("ras_months",)
class EntitySerializer(
NestedCreateMixin, NestedUpdateMixin, serializers.HyperlinkedModelSerializer
):
street_address = ReadOnlyField()
formatted_address =... | code_fim | hard | {
"lang": "python",
"repo": "WISVCH/dienst2",
"path": "/ldb/serializers.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # These are needed only to please mypy.
get_beacon_blocks: BeaconBlocksExchange<|fim_prefix|># repo: hwwhww/trinity path: /trinity/protocol/bcc/handlers.py
from trinity.protocol.common.handlers import BaseExchangeHandler
from trinity.protocol.bcc.exchanges import BeaconBlocksExchange
class BCC... | code_fim | medium | {
"lang": "python",
"repo": "hwwhww/trinity",
"path": "/trinity/protocol/bcc/handlers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hwwhww/trinity path: /trinity/protocol/bcc/handlers.py
from trinity.protocol.common.handlers import BaseExchangeHandler
from trinity.protocol.bcc.exchanges import BeaconBlocksExchange
<|fim_suffix|> _exchange_config = {
"get_beacon_blocks": BeaconBlocksExchange,
}
# These ar... | code_fim | easy | {
"lang": "python",
"repo": "hwwhww/trinity",
"path": "/trinity/protocol/bcc/handlers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> signatureKey=None, validateRequests=None, validationKey=None, sendValidationConfirmation=None, issuer=None,
appliesTo=None, properties=None, new_name=None, ignore_password_for_idempotency=False, check_mode=False,
force=False):
"""
Creating or Modifying an STS Chain
"""
... | code_fim | hard | {
"lang": "python",
"repo": "IBM-Security/ibmsecurity",
"path": "/ibmsecurity/isam/fed/sts/module_chains.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: IBM-Security/ibmsecurity path: /ibmsecurity/isam/fed/sts/module_chains.py
import logging
import copy
from ibmsecurity.utilities import tools
from ibmsecurity.isam.fed.sts import templates
from ibmsecurity.isam.aac import mapping_rules
logger = logging.getLogger(__name__)
# URI for this module
u... | code_fim | hard | {
"lang": "python",
"repo": "IBM-Security/ibmsecurity",
"path": "/ibmsecurity/isam/fed/sts/module_chains.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bcdonadio/python-netapp-ocum path: /netapp_ocum/http.py
import requests
class NetApp_OCUM_HTTP(object):
"""
Class object for handling HTTP requests/responses for the OCUM.
"""
def __init__(self, settings):
<|fim_suffix|> # Request failed
if not int(response.status_... | code_fim | hard | {
"lang": "python",
"repo": "bcdonadio/python-netapp-ocum",
"path": "/netapp_ocum/http.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Make the API request
response = requests.get(request_url,
auth = (self.settings.api_user, self.settings.api_password),
verify = self.settings.verify_ssl,
headers = self.settings.headers,
params = params
)
# Request fai... | code_fim | hard | {
"lang": "python",
"repo": "bcdonadio/python-netapp-ocum",
"path": "/netapp_ocum/http.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: paulharter/fam path: /src/fam/firestore_sync/syncer.py
from fam.exceptions import *
from fam.database.firestore_adapter import FirestoreDataAdapter
class FirestoreSyncer(object):
def __init__(self, couchdb_wrapper, firestore_wrapper, batch_size=100, since_in_db=False):
self.couc... | code_fim | hard | {
"lang": "python",
"repo": "paulharter/fam",
"path": "/src/fam/firestore_sync/syncer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def sync_down(self):
items = []
for query in self.queries:
for snapshot in self.firestore_wrapper.query_snapshots(query, batch_size=self.batch_size):
item = self.add_snapshot(snapshot)
if item is not None:
items.append(i... | code_fim | hard | {
"lang": "python",
"repo": "paulharter/fam",
"path": "/src/fam/firestore_sync/syncer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if self.since_in_db:
since_result = self.couchdb_wrapper._get("sync_since")
if since_result is not None:
self.since_rev = since_result.rev
return since_result.value["since"]
else:
return 0
else:
... | code_fim | hard | {
"lang": "python",
"repo": "paulharter/fam",
"path": "/src/fam/firestore_sync/syncer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def contains(self, perm):
if type(perm) is not Permutation:
perm = Permutation(list(perm))
self._assure_length(len(perm))
return perm in self.permutations[len(perm)]
def count_of_length(self, l):
self._assure_length(l)
return len(self.permutatio... | code_fim | hard | {
"lang": "python",
"repo": "PermutaTriangle/PermStruct",
"path": "/permstruct/input.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> if l in self.permutations:
return
if l == 0:
self.permutations[0] = []
maybe = Permutation([])
if maybe.avoids(*self.avoidance):
self.permutations[0].append(maybe)
else:
self._assure_length(l-1)
... | code_fim | hard | {
"lang": "python",
"repo": "PermutaTriangle/PermStruct",
"path": "/permstruct/input.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PermutaTriangle/PermStruct path: /permstruct/input.py
from permuta import AvoidanceClass, Permutation
import datetime
class StructInput(object):
def __init__(self, settings, perm_prop, generator, is_classical=False, avoidance=None):
self.settings = settings
self.perm_prop = ... | code_fim | hard | {
"lang": "python",
"repo": "PermutaTriangle/PermStruct",
"path": "/permstruct/input.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: P4xos/P4xos path: /scripts/wiretap.py
#!/usr/bin/env python
from scapy.all import *
import sys
import argparse
import datetime
class Paxos(Packet):
name ="PaxosPacket "
fields_desc = [
XShortField("msgtype", 0x3),
XIntField("inst", 0x1),
... | code_fim | medium | {
"lang": "python",
"repo": "P4xos/P4xos",
"path": "/scripts/wiretap.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def server(args):
sniff(iface = args.interface, filter= 'udp', prn = lambda x: handle(x))
if __name__=='__main__':
parser = argparse.ArgumentParser(description='P4Paxos demo')
parser.add_argument("interface", help="bind to specified interface")
parser.add_argument("--address", default="22... | code_fim | hard | {
"lang": "python",
"repo": "P4xos/P4xos",
"path": "/scripts/wiretap.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AspirinCode/vabene path: /src/vabene/atom/atom.py
"""
Atom
====
"""
class Atom:
"""
An atom of a molecule.
"""
def __init__(self, atomic_number, charge, valid_valences):
"""
Initialize an :class:`.Atom` instance.
Parameters
----------
... | code_fim | medium | {
"lang": "python",
"repo": "AspirinCode/vabene",
"path": "/src/vabene/atom/atom.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Returns
-------
:class:`int`
The formal charge of the atom.
"""
return self._charge
def get_valid_valences(self):
"""
Return the valences the atom is allowed to have.
Returns
-------
:class:`frozenset` of :... | code_fim | medium | {
"lang": "python",
"repo": "AspirinCode/vabene",
"path": "/src/vabene/atom/atom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._atomic_number
def get_charge(self):
"""
Return the formal charge of the atom.
Returns
-------
:class:`int`
The formal charge of the atom.
"""
return self._charge
def get_valid_valences(self):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "AspirinCode/vabene",
"path": "/src/vabene/atom/atom.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BUserName/PGL path: /models/graphbase.py
from __future__ import absolute_import
import torch
import torch.nn as nn
import torch.nn.functional as F
from collections import OrderedDict
import torch.nn.init as init
from torchvision import models
# from models.__init__ import weight_init
__all__ = [... | code_fim | hard | {
"lang": "python",
"repo": "BUserName/PGL",
"path": "/models/graphbase.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return edge_feat
class GraphNetwork(nn.Module):
def __init__(self, args):
super(GraphNetwork, self).__init__()
# set size
self.in_features = args.in_features
self.node_features = args.node_features
self.edge_features = args.edge_features
self.nu... | code_fim | hard | {
"lang": "python",
"repo": "BUserName/PGL",
"path": "/models/graphbase.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> super('HACCP Process', self).on_trash()
delete_events(self.doctype, self.name)<|fim_prefix|># repo: gchartas/hands path: /hands/fsms/doctype/haccp_process/haccp_process.py
# -*- coding: utf-8 -*-
# Copyright (c) 2020, EngLandGR and contributors
# For license information, please see license.txt
from ... | code_fim | medium | {
"lang": "python",
"repo": "gchartas/hands",
"path": "/hands/fsms/doctype/haccp_process/haccp_process.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> NestedSet.on_update(self)
def on_trash(self):
super('HACCP Process', self).on_trash()
delete_events(self.doctype, self.name)<|fim_prefix|># repo: gchartas/hands path: /hands/fsms/doctype/haccp_process/haccp_process.py
# -*- coding: utf-8 -*-
# Copyright (c) 2020, EngLandGR and contributors
# For l... | code_fim | medium | {
"lang": "python",
"repo": "gchartas/hands",
"path": "/hands/fsms/doctype/haccp_process/haccp_process.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gchartas/hands path: /hands/fsms/doctype/haccp_process/haccp_process.py
# -*- coding: utf-8 -*-
# Copyright (c) 2020, EngLandGR and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
# import frappe
from frappe.model.document import Document
fr... | code_fim | medium | {
"lang": "python",
"repo": "gchartas/hands",
"path": "/hands/fsms/doctype/haccp_process/haccp_process.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Utah-Data-Science/dimensional path: /tests/entities/test_entities.py
import unittest
from unittest.mock import MagicMock
import dimensional as dim
class TestEntities(unittest.TestCase):
def setUp(self):
self.subject = "foo"
@unittest.expectedFailure
def test_entity_attribut... | code_fim | hard | {
"lang": "python",
"repo": "Utah-Data-Science/dimensional",
"path": "/tests/entities/test_entities.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> name = "Dataset"
header = ['foo', 'bar']
rows = [[1,2], [3,4]]
dataset.name = name
dataset.header = header
dataset.rows = rows
self.assertEqual(name, dataset.name)
self.assertEqual(header, dataset.header)
self.assertEqual(rows, data... | code_fim | medium | {
"lang": "python",
"repo": "Utah-Data-Science/dimensional",
"path": "/tests/entities/test_entities.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@solid(
input_defs=[InputDefinition(_START, Nothing)],
config_field=define_bigquery_delete_dataset_config(),
required_resource_keys={'bq'},
)
def bq_delete_dataset(context):
'''BigQuery Delete Dataset.
This solid encapsulates deleting a BigQuery dataset.
Expects a BQ client to b... | code_fim | hard | {
"lang": "python",
"repo": "cclauss/dagster",
"path": "/python_modules/libraries/dagster-gcp/dagster_gcp/bigquery/solids.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if time_partitioning is not None:
cfg['time_partitioning'] = TimePartitioning(**time_partitioning)
return cfg
def bq_solid_for_queries(sql_queries):
"""
Executes BigQuery SQL queries.
Expects a BQ client to be provisioned in resources as context.resources.bq.
"""
s... | code_fim | hard | {
"lang": "python",
"repo": "cclauss/dagster",
"path": "/python_modules/libraries/dagster-gcp/dagster_gcp/bigquery/solids.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cclauss/dagster path: /python_modules/libraries/dagster-gcp/dagster_gcp/bigquery/solids.py
from google.cloud.bigquery.job import QueryJobConfig, LoadJobConfig
from google.cloud.bigquery.table import EncryptionConfiguration, TimePartitioning
from dagster_pandas import DataFrame
from dagster impo... | code_fim | hard | {
"lang": "python",
"repo": "cclauss/dagster",
"path": "/python_modules/libraries/dagster-gcp/dagster_gcp/bigquery/solids.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: marcomusy/vedo path: /examples/advanced/warp2.py
"""Warp a region of a mesh using Thin Plate Splines.
Red points stay fixed while a single point in space
moves as the arrow indicates."""
from vedo import *
settings.use_depth_peeling = True
mesh = Mesh(dataurl+"man.vtk").color('w')
<|fim_suffix|... | code_fim | hard | {
"lang": "python",
"repo": "marcomusy/vedo",
"path": "/examples/advanced/warp2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>sphere = Sphere(r=0.3).pos(1,0,-.50)
sphere.apply_transform(warp.transform)
# print(warp.transform)
show(mesh, arrow, warp, apts, sphere, axes=1).close()<|fim_prefix|># repo: marcomusy/vedo path: /examples/advanced/warp2.py
"""Warp a region of a mesh using Thin Plate Splines.
Red points stay fixed while... | code_fim | medium | {
"lang": "python",
"repo": "marcomusy/vedo",
"path": "/examples/advanced/warp2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> service = get_oauth_service()
try:
return service.get_auth_session(
data = {
'code': request.GET['code'],
'grant_type': 'authorization_code',
'redirect_uri': 'http://ec2-54-69-48-63.us-west-2.compute.amazonaws.com:8000/oa2callback'
},
decoder=json.loads
)
except:
raise Exce... | code_fim | hard | {
"lang": "python",
"repo": "xplainr/EDGI",
"path": "/hackathon/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xplainr/EDGI path: /hackathon/utils.py
from rauth import OAuth2Service
from rauth.session import OAuth2Session
from django.conf import settings
from django import http
import json
def get_oauth_service():
return OAuth2Service (
client_id = settings.SM_CLIENT_ID,
client_secret= settings.SM_... | code_fim | hard | {
"lang": "python",
"repo": "xplainr/EDGI",
"path": "/hackathon/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif isinstance(exc, exceptions.Throttled):
return Response(codes.get('throttled'),
status=exc.status_code,
exception=True)
elif isinstance(exc, Http404):
return Response(codes.get('not_found'),
... | code_fim | hard | {
"lang": "python",
"repo": "dlooto/driver-vision",
"path": "/apps/core/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> elif isinstance(exc, exceptions.NotAuthenticated):
return Response(codes.get('not_authenticated'),
status=exc.status_code,
exception=True)
elif isinstance(exc, exceptions.PermissionDenied):
return Response(cod... | code_fim | hard | {
"lang": "python",
"repo": "dlooto/driver-vision",
"path": "/apps/core/views.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dlooto/driver-vision path: /apps/core/views.py
#coding=utf-8
#
# Copyright (C) 2015 Feigr TECH Co., Ltd. All rights reserved.
# Created on 2013-8-13, by Junn
#
#
#import settings
from django.middleware.csrf import get_token
from django.http.response import Http404
from django.core.exceptions imp... | code_fim | hard | {
"lang": "python",
"repo": "dlooto/driver-vision",
"path": "/apps/core/views.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vollov/django-template path: /django/esite/page/urls.py
from django.conf.urls import patterns, url
<|fim_suffix|> # ex: /page/about/
url(r'^(?P<page_slug>\S+)/$', views.detail, name='detail'),
)<|fim_middle|>from page import views
urlpatterns = patterns('',
| code_fim | easy | {
"lang": "python",
"repo": "vollov/django-template",
"path": "/django/esite/page/urls.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # ex: /page/about/
url(r'^(?P<page_slug>\S+)/$', views.detail, name='detail'),
)<|fim_prefix|># repo: vollov/django-template path: /django/esite/page/urls.py
from django.conf.urls import patterns, url
from page import views
<|fim_middle|>urlpatterns = patterns('',
| code_fim | easy | {
"lang": "python",
"repo": "vollov/django-template",
"path": "/django/esite/page/urls.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> The code class for neuromorphic dataset. Users can define a new dataset by inheriting this class and implementing
all abstract methods. Users can refer to :class:`spikingjelly.datasets.dvs128_gesture.DVS128Gesture`.
If ``data_type == 'event'``
the sample in this datase... | code_fim | hard | {
"lang": "python",
"repo": "Brain-Cog-Lab/BP-STA",
"path": "/code/datasets/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Brain-Cog-Lab/BP-STA path: /code/datasets/common.py
\\frac{N}{M}] \\cdot (j + 1), & j < M - 1 \\cr N, & j = M - 1 \\end{cases}
'''
j_l = np.zeros(shape=[frames_num], dtype=int)
j_r = np.zeros(shape=[frames_num], dtype=int)
N = events_t.size
if split_by == 'number':
d... | code_fim | hard | {
"lang": "python",
"repo": "Brain-Cog-Lab/BP-STA",
"path": "/code/datasets/common.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self,
root: str,
train: bool = None,
data_type: str = 'event',
frames_number: int = None,
split_by: str = None,
duration: int = None,
transform: Optional[Callable] = None,
target_transform: Optional... | code_fim | hard | {
"lang": "python",
"repo": "Brain-Cog-Lab/BP-STA",
"path": "/code/datasets/common.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ethan-ou/colour-calibration-tools path: /src/main.py
from pathlib import Path
import ffmpeg
import numpy as np
from scipy.optimize._lsq import least_squares
from colour import LUT3D, LUT3x1D, write_LUT, cctf_encoding, cctf_decoding
from extract import get_metadata, sample_frames, save_patches
fr... | code_fim | hard | {
"lang": "python",
"repo": "ethan-ou/colour-calibration-tools",
"path": "/src/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> LUT_table = solve_colour_matrix(
LUT_table, source_colour, target_colour, source_gamma=source_gamma,
target_gamma=target_gamma, LUT_gamma=LUT_gamma, algorithm=LUT_algorithm)
LUT_table = cctf_encoding(LUT_table, function=LUT_gamma)
return LUT3D(np.clip(LUT_table, 0, 1))
def ... | code_fim | hard | {
"lang": "python",
"repo": "ethan-ou/colour-calibration-tools",
"path": "/src/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: slackhq/py-grpc-prometheus path: /py_grpc_prometheus/grpc_utils.py
UNARY = "UNARY"
SERVER_STREAMING = "SERVER_STREAMING"
CLIENT_STREAMING = "CLIENT_STREAMING"
BIDI_STREAMING = "BIDI_STREAMING"
UNKNOWN = "UNKNOWN"
def wrap_iterator_inc_counter(iterator, counter, grpc_type, grpc_service_name, grp... | code_fim | hard | {
"lang": "python",
"repo": "slackhq/py-grpc-prometheus",
"path": "/py_grpc_prometheus/grpc_utils.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.