text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|> def adjust_frequency(self, word):
alphas = [1 if chr(w+97) in word else 0 for w in range(26)]
reduce_indexes = [index for index in range(26) if alphas[index]==1]
increase_indexes = [index for index in range(26) if alphas[index]==0]
for ri in reduce_indexes:
CONSTANT = (self.freq[chr(ri+97)]/1... | code_fim | hard | {
"lang": "python",
"repo": "pncnmnp/Orwell",
"path": "/orwell.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if event.keysym == "Left":
self.board = list(
map(lambda x: self.perform_move(x[::-1])[::-1], self.board))
if event.keysym == "Up":
transpose = lambda l_of_l:[list(l) for l in zip(*l_of_l)]
self.board = list(map(lambda x: self.perform_move(x[::-1])[::-1],transpose(self.board)))
self.b... | code_fim | hard | {
"lang": "python",
"repo": "pncnmnp/Orwell",
"path": "/orwell.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pncnmnp/Orwell path: /orwell.py
from numpy.random import choice
from os.path import isfile
from functools import partial
from sys import exit
from itertools import chain
from csv import reader
from nltk.stem import WordNetLemmatizer
import tkinter as tk
import datetime
import json
import pickle
i... | code_fim | hard | {
"lang": "python",
"repo": "pncnmnp/Orwell",
"path": "/orwell.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CalRobert/json2parquet path: /tests/test_client.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import tempfile
import pandas as pd
import pyarrow as pa
from pyarrow import parquet as pq
from json2parquet import client
def test_ingest():
"""
Test ingesti... | code_fim | hard | {
"lang": "python",
"repo": "CalRobert/json2parquet",
"path": "/tests/test_client.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_ingest_with_column_names():
"""
Test ingesting data with given column names
"""
schema = ["foo", "bar"]
data = [{"foo": 1, "bar": 2}, {"foo": 10, "bar": 20}]
converted_data = client.ingest_data(data, schema)
assert converted_data.to_pydict() == {'foo': [1, 10], 'bar'... | code_fim | hard | {
"lang": "python",
"repo": "CalRobert/json2parquet",
"path": "/tests/test_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> data = [{"foo": 1, "bar": 2}, {"foo": 10, "bar": 20}]
converted_data = client.ingest_data(data, schema)
assert converted_data.to_pydict() == {'foo': [1, 10], 'bar': [2, 20]}
def test_ingest_with_column_names_dict():
"""
Test ingesting data with columns and user supplied aliases
... | code_fim | hard | {
"lang": "python",
"repo": "CalRobert/json2parquet",
"path": "/tests/test_client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evereux/pycatia path: /pycatia/drafting_interfaces/drawing_sheet.py
|
| Returns or sets the paper size.
|
| Example:
| This example sets the page size for the MySheet drawing sheet to
| catPa... | code_fim | hard | {
"lang": "python",
"repo": "evereux/pycatia",
"path": "/pycatia/drafting_interfaces/drawing_sheet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: evereux/pycatia path: /pycatia/drafting_interfaces/drawing_sheet.py
.exception_handling.exceptions import CATIAApplicationException
from pycatia.drafting_interfaces.drawing_page_setup import DrawingPageSetup
from pycatia.drafting_interfaces.drawing_views import DrawingViews
from pycatia.drafting_... | code_fim | hard | {
"lang": "python",
"repo": "evereux/pycatia",
"path": "/pycatia/drafting_interfaces/drawing_sheet.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
.. note::
:class: toggle
CAA V5 Visual Basic Help (2020-06-11 12:40:47.360445))
| o Sub Isolate()
|
| Isolates the drawing sheet.
| Warning: This method is not available with 2D Layout for... | code_fim | hard | {
"lang": "python",
"repo": "evereux/pycatia",
"path": "/pycatia/drafting_interfaces/drawing_sheet.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # result_select2 = client.select_article(2)
# print('\n::::client.select_article(id=2)::::')
# print(result_select2)
#
# result_update = client.update_article(2, 'grgerer')
# print("\n::::client.update_article(2, 'testtttt')::::")
# print(result_update)
#
# result_selec... | code_fim | hard | {
"lang": "python",
"repo": "qq20004604/publish-article-with-tags",
"path": "/article_server/proto_container/client/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: qq20004604/publish-article-with-tags path: /article_server/proto_container/client/__init__.py
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import time
import grpc
# 必须先设置一下环境路径
sys.path.append("../proto")
import article_pb2, article_pb2_grpc
# HOST = '127.0.0.1'
HOST = '119.3.214.... | code_fim | hard | {
"lang": "python",
"repo": "qq20004604/publish-article-with-tags",
"path": "/article_server/proto_container/client/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __get_priority(self):
return self.__priority
priority = property(fget = __get_priority)
def _available(self):
return self.rate._available()<|fim_prefix|># repo: OspreyX/flow path: /flow/finance/finins/base/cashflowrate.py
from jflow.core.cashflow import CashFlow
... | code_fim | hard | {
"lang": "python",
"repo": "OspreyX/flow",
"path": "/flow/finance/finins/base/cashflowrate.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OspreyX/flow path: /flow/finance/finins/base/cashflowrate.py
from jflow.core.cashflow import CashFlow
from finins import *
class CashFlowRate(CashFlow):
<|fim_suffix|> return self.__priority
priority = property(fget = __get_priority)
def _available(self):
... | code_fim | hard | {
"lang": "python",
"repo": "OspreyX/flow",
"path": "/flow/finance/finins/base/cashflowrate.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarcoDSilva/MIT6001x-Introduction-to-Computer-Science-and-Programming-in-Python path: /week2/payingDebtBisectionSearch.py
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 15 15:07:34 2020
write a program that calculates the minimum fixed monthly payment needed
in order pay off a credit card balan... | code_fim | hard | {
"lang": "python",
"repo": "MarcoDSilva/MIT6001x-Introduction-to-Computer-Science-and-Programming-in-Python",
"path": "/week2/payingDebtBisectionSearch.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#we loop 'til we find the value in the margin specified (0.1 in this case)
while(found):
temp_balance = balance
# calculate the balance after the payment and the interest
for month in range(1,13):
temp_balance -= min_payment
temp_balance += (monthly_interest * temp_bal... | code_fim | medium | {
"lang": "python",
"repo": "MarcoDSilva/MIT6001x-Introduction-to-Computer-Science-and-Programming-in-Python",
"path": "/week2/payingDebtBisectionSearch.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # model
model = exif['Model'] if 'Model' in exif.keys() else "unknown_model"
# only keep effective characters as filename
model = re.sub('[^a-zA-Z0-9]', '', model)
pic_info['model'] = model
# Picture Create Time
create_time = exif['DateTimeOriginal'] if 'DateTimeOriginal' in e... | code_fim | hard | {
"lang": "python",
"repo": "xidongsheng/photo_category",
"path": "/picture_category/pic_exif.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xidongsheng/photo_category path: /picture_category/pic_exif.py
from PIL import Image
from PIL.ExifTags import TAGS
from PIL.ExifTags import GPSTAGS
import time
import os
import re
def get_exif(pic_file):
# i = Image.open('F:\\DCIM\\100ANDRO\\DSC_0004.JPG')
# i = Image.open('F:\\photos\\... | code_fim | hard | {
"lang": "python",
"repo": "xidongsheng/photo_category",
"path": "/picture_category/pic_exif.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_get_current_player(self):
self.assertEqual(self.game.current_idx, 0)
self.assertEqual(self.game.current_player, self.PLAYER_ENTRY_1)
def test_get_current_after_turns(self):
expected = [
(1, 0, self.PLAYER_ENTRY_1),
(1, 1, self.PLAYER_ENTRY_... | code_fim | hard | {
"lang": "python",
"repo": "RxJellyBot/Jelly-Bot",
"path": "/tests/unit/game_pkchess/game/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.game.current_player_finished()
def test_player_action_done(self):
self.assertFalse(self.game.is_current_action_done(PlayerAction.MOVE))
self.game.record_action_done(PlayerAction.MOVE)
self.assertTrue(self.game.is_current_action_done(PlayerAction.MOVE))
... | code_fim | hard | {
"lang": "python",
"repo": "RxJellyBot/Jelly-Bot",
"path": "/tests/unit/game_pkchess/game/main.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RxJellyBot/Jelly-Bot path: /tests/unit/game_pkchess/game/main.py
from bson import ObjectId
from game.pkchess.character import Character
from game.pkchess.exception import GameActionSubmittedError, GamePlayerInsufficientError
from game.pkchess.flags import MapPointStatus, MapPointResource, Player... | code_fim | hard | {
"lang": "python",
"repo": "RxJellyBot/Jelly-Bot",
"path": "/tests/unit/game_pkchess/game/main.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return
def checkForIsUpAlert(self, website, availability):
"""
Check for is up Alert
:param website:
:param availability:
:return:
"""
checkTime = time.time()
# Verify that the system has been running for longer than 2 minutes
... | code_fim | hard | {
"lang": "python",
"repo": "pierresegonne/webMonitoring-CLI",
"path": "/monitor.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Indicator n1
:param website:
:param inFrame:
:return:
"""
maxTime = 0
for timeOfReq in inFrame:
if website.log[timeOfReq]['responseTime'] > timedelta(seconds=maxTime):
maxTime = self.timedeltaToFloat(website.lo... | code_fim | hard | {
"lang": "python",
"repo": "pierresegonne/webMonitoring-CLI",
"path": "/monitor.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pierresegonne/webMonitoring-CLI path: /monitor.py
import time
import requests
from multiprocessing import Process, Queue
from datetime import timedelta
import mailSender
# Types of indicators
indicatorsTypes = {'MAX': 'maxTime', 'AVG': 'avgTime', 'AVA': 'availability', 'STA' : 'status'}
def sta... | code_fim | hard | {
"lang": "python",
"repo": "pierresegonne/webMonitoring-CLI",
"path": "/monitor.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> return 9
def return_ten():
return 10
self.assertEqual(3, utils.if_(True, 3, 4))
self.assertEqual(4, utils.if_(False, 3, 4))
self.assertEqual(9, utils.if_(True, return_nine, return_ten))
self.assertEqual(10, utils.if_(False, return_nine, return_ten))
def test_num_or_str... | code_fim | hard | {
"lang": "python",
"repo": "Energid/energid_nlp",
"path": "/energid_nlp/tests/utils_test.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Energid/energid_nlp path: /energid_nlp/tests/utils_test.py
# Copyright 2012 Energid Technologies
import unittest
from energid_nlp import utils
class UtilsTests(unittest.TestCase):
def test_element_of(self):
"""Test element_of."""
self.assertTrue(utils.element_of(1, [1, 2, 3]))
s... | code_fim | medium | {
"lang": "python",
"repo": "Energid/energid_nlp",
"path": "/energid_nlp/tests/utils_test.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class ProgramCourseEnrollmentSerializer(serializers.Serializer):
"""
Serializer for displaying program-course enrollments.
"""
student_key = serializers.SerializerMethodField()
status = serializers.CharField()
account_exists = serializers.SerializerMethodField()
curriculum_uui... | code_fim | hard | {
"lang": "python",
"repo": "luque/better-ways-of-thinking-about-software",
"path": "/Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/lms/djangoapps/program_enrollments/rest_api/v1/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return bool(obj.program_enrollment.user)
def get_curriculum_uuid(self, obj):
return str(obj.program_enrollment.curriculum_uuid)
def get_course_staff(self, obj):
return is_course_staff_enrollment(obj)
class ProgramCourseEnrollmentRequestSerializer(serializers.Serializer,... | code_fim | hard | {
"lang": "python",
"repo": "luque/better-ways-of-thinking-about-software",
"path": "/Part-03-Understanding-Software-Crafting-Your-Own-Tools/models/edx-platform/lms/djangoapps/program_enrollments/rest_api/v1/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def processProxyHeader (self, r_buffer, mode):
r_buffer = r_buffer.lstrip('\r\n')
for eor in self.eor:
if eor in r_buffer:
client_ip, r_buffer = self.proxy_protocol.parse(r_buffer)
mode = 'http'
break
else:
client_ip, r_buffer = '', r_buffer
return client_ip, r_buffer, mod... | code_fim | hard | {
"lang": "python",
"repo": "Exa-Networks/exaproxy",
"path": "/lib/exaproxy/reactor/client/http.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Exa-Networks/exaproxy path: /lib/exaproxy/reactor/client/http.py
# encoding: utf-8
"""
server.py
Created by David Farrar on 2011-11-30.
Copyright (c) 2011-2013 Exa Networks. All rights reserved.
"""
import socket
import errno
from exaproxy.network.functions import isipv4
from exaproxy.networ... | code_fim | hard | {
"lang": "python",
"repo": "Exa-Networks/exaproxy",
"path": "/lib/exaproxy/reactor/client/http.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Daryl0819/bk-bcs-saas path: /bcs-app/backend/tests/infras/host_service/test_host.py
# -*- coding: utf-8 -*-
import pytest
from unittest.mock import patch
from backend.infras.host_service.perms import can_use_hosts
<|fim_suffix|> assert can_use_hosts(biz_id, username, expect_used_ip_list... | code_fim | hard | {
"lang": "python",
"repo": "Daryl0819/bk-bcs-saas",
"path": "/bcs-app/backend/tests/infras/host_service/test_host.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @patch("backend.infras.host_service.perms.get_cc_hosts", return_value=fake_cc_host_not_match_results)
def test_not_match_failed(self, biz_id, username):
assert not can_use_hosts(biz_id, username, expect_used_ip_list)<|fim_prefix|># repo: Daryl0819/bk-bcs-saas path: /bcs-app/backend/tests/... | code_fim | medium | {
"lang": "python",
"repo": "Daryl0819/bk-bcs-saas",
"path": "/bcs-app/backend/tests/infras/host_service/test_host.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> inbound_entry["address"] = bytes_from_hex(address)
inbound_entry["object_id"] = bytes_from_hex(object_id)
inbound_entry["object_type"] = addresser.ObjectType.ROLE.value
message = Role().imports.make(
signer_keypair=key_pair, role_id=next_id,... | code_fim | hard | {
"lang": "python",
"repo": "SaumoPal97/sawtooth-next-directory",
"path": "/rbac/ledger_sync/inbound/rbac_transactions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Any fields in data that are not sent to the blockchain state
via the message are stored in a metadata dictionary to be put
in the metadata table in RethinkDB. This creates the metadata
dictionary from data and removes fields that are in the message.
"""
message_keys... | code_fim | hard | {
"lang": "python",
"repo": "SaumoPal97/sawtooth-next-directory",
"path": "/rbac/ledger_sync/inbound/rbac_transactions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SaumoPal97/sawtooth-next-directory path: /rbac/ledger_sync/inbound/rbac_transactions.py
# Copyright 2019 Contributors to Hyperledger Sawtooth
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a c... | code_fim | hard | {
"lang": "python",
"repo": "SaumoPal97/sawtooth-next-directory",
"path": "/rbac/ledger_sync/inbound/rbac_transactions.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pombredanne/csvsimpletools path: /csvsimpletools/__init__.py
# coding: utf-8
from flask import Flask
from flask.ext.babel import Babel
from flask.ext.script import Manager
from flask_wtf.csrf import CsrfProtect
<|fim_suffix|>if not app.config['DEBUG']:
import logging
from logging.handle... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/csvsimpletools",
"path": "/csvsimpletools/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if not app.config['DEBUG']:
import logging
from logging.handlers import RotatingFileHandler
filepath = '{}/errors.log'.format(app.config['BASEDIR'])
handler = RotatingFileHandler(filepath, 'a', 1 * 1024 * 1024, 10)
row = '%(asctime)s %(levelname)s: %(message)s [in %(pathname)s:%(lineno... | code_fim | medium | {
"lang": "python",
"repo": "pombredanne/csvsimpletools",
"path": "/csvsimpletools/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('notes', '0008_auto_20210126_1824'),
]
operations = [
migrations.AddField(
model_name='note',
name='description',
field=models.CharField(default='hello', help_text='A brief description of the note that will be displayed in ... | code_fim | medium | {
"lang": "python",
"repo": "itsmegarvi/Inscribe",
"path": "/notes/migrations/0009_note_description.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: itsmegarvi/Inscribe path: /notes/migrations/0009_note_description.py
# Generated by Django 3.1.5 on 2021-01-28 14:19
from django.db import migrations, models
<|fim_suffix|> dependencies = [
('notes', '0008_auto_20210126_1824'),
]
operations = [
migrations.AddField(
... | code_fim | medium | {
"lang": "python",
"repo": "itsmegarvi/Inscribe",
"path": "/notes/migrations/0009_note_description.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: viotti/sh2py path: /t1_hello.py
# -*- coding: utf-8; -*-
#
# The MIT License (MIT)
#
# Copyright (c) 2015 Rafael Viotti
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Softwar... | code_fim | hard | {
"lang": "python",
"repo": "viotti/sh2py",
"path": "/t1_hello.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Usage:
python hello.py help
python hello.py [case=upper/lower] [shuffle=yes/no] [pace=0]
Arguments:
help, print this usage help and exit;
case=upper/lower, convert the message to uppercase, or lowercase;
shuffle=yes/no, shuffle the letter... | code_fim | hard | {
"lang": "python",
"repo": "viotti/sh2py",
"path": "/t1_hello.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amusecode/amuse path: /src/amuse/community/asterisk/interface.py
=generic_unit_system.length, direction=function.IN, description = "The radius of the particle")
for par in ["red", "green", "blue"]:
function.addParameter(par, dtype='float64', direction=function.IN,
... | code_fim | hard | {
"lang": "python",
"repo": "amusecode/amuse",
"path": "/src/amuse/community/asterisk/interface.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amusecode/amuse path: /src/amuse/community/asterisk/interface.py
gacyFunctionSpecification()
function.result_type = 'int32'
function.result_doc = """
0 - OK
Model is initialized and evolution can start
-1 - ERROR
Error happened during initi... | code_fim | hard | {
"lang": "python",
"repo": "amusecode/amuse",
"path": "/src/amuse/community/asterisk/interface.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> function = LegacyFunctionSpecification()
function.addParameter("x_rotation", dtype='float64', direction=function.OUT)
function.result_type = 'int32'
return function
@legacy_function
def get_y_rotation():
function = LegacyFunctionSpecification()
funct... | code_fim | hard | {
"lang": "python",
"repo": "amusecode/amuse",
"path": "/src/amuse/community/asterisk/interface.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> new_category = {'name': 'Friends'}
Category(**new_category).save()
response = self.client.post('/categories', new_category, format='json')
self.assertEqual(response.status_code, 400)
self.assertEqual(response.data['name'][0],
'category with ... | code_fim | hard | {
"lang": "python",
"repo": "nzediegwu1/favorite-things",
"path": "/api/tests/category/test_create_category.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_create_category_fails_when_already_existing(self):
new_category = {'name': 'Friends'}
Category(**new_category).save()
response = self.client.post('/categories', new_category, format='json')
self.assertEqual(response.status_code, 400)
self.assertEqual(re... | code_fim | hard | {
"lang": "python",
"repo": "nzediegwu1/favorite-things",
"path": "/api/tests/category/test_create_category.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nzediegwu1/favorite-things path: /api/tests/category/test_create_category.py
from rest_framework.test import APITestCase
from api.models import Category
class TestCreateCategory(APITestCase):
def test_create_category_succeeds_with_valid_data(self):
new_category = {'name': 'Family'}
... | code_fim | hard | {
"lang": "python",
"repo": "nzediegwu1/favorite-things",
"path": "/api/tests/category/test_create_category.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ameriks/drklauns path: /drklauns/timetable/models.py
import datetime
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
from drklauns.core.mixins import TimestampMixin
def this_year():
return timezone.now().year
def this... | code_fim | hard | {
"lang": "python",
"repo": "Ameriks/drklauns",
"path": "/drklauns/timetable/models.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> rate = models.DecimalField(max_digits=6, decimal_places=2, default=0)
income = models.DecimalField(max_digits=6, decimal_places=2, default=0)
class Meta:
verbose_name_plural = _("Summary")
def save(self, *args, **kwargs):
self.income = round(self.hours_worked * float(self... | code_fim | hard | {
"lang": "python",
"repo": "Ameriks/drklauns",
"path": "/drklauns/timetable/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class Summary(models.Model):
created = models.DateTimeField(_('Created'), auto_now_add=True)
modified = models.DateTimeField(_('Modified'), auto_now=True)
date = models.DateField(_("Summary Month"))
employee = models.ForeignKey("users.User", verbose_name=_("Employee"), on_delete=models.P... | code_fim | hard | {
"lang": "python",
"repo": "Ameriks/drklauns",
"path": "/drklauns/timetable/models.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: patrickmaslen/pbs path: /pbs/prescription/templatetags/prescription_tags.py
from django import template
from django.db.models import Max
from django.utils.safestring import mark_safe
from django.template.defaultfilters import stringfilter
from pbs.implementation.models import (Way, RoadSegment, ... | code_fim | hard | {
"lang": "python",
"repo": "patrickmaslen/pbs",
"path": "/pbs/prescription/templatetags/prescription_tags.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> risk, label, role = prescription._max_risk(prescription.maximum_risk)
return role
@register.simple_tag
def role_required(prescription, role):
"""
Check if the endorsing role is required, and if it has been performed.
Includes span display:none enumerator hack to make table sortable.
... | code_fim | hard | {
"lang": "python",
"repo": "patrickmaslen/pbs",
"path": "/pbs/prescription/templatetags/prescription_tags.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TheArqsz/AntiPhishMe-backend path: /antiphishme/src/helpers/db_helper.py
import os
import threading
import time
import logging as log
from antiphishme.src.models.ip_model import IP
from antiphishme.src.models.baddies_model import Baddies
from antiphishme.src.models.certs_model import Certs
from... | code_fim | hard | {
"lang": "python",
"repo": "TheArqsz/AntiPhishMe-backend",
"path": "/antiphishme/src/helpers/db_helper.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> min_lev_distance = 0
lev_distance = 0
if lev_matched_keyword:
for phrase in domain_phrases:
lev_distance = lev.calculate_levenstein(lev_matched_keyword, phrase)
if 3 > min_lev_distance > lev_distance:
min_lev_distance = lev_distance
if not le... | code_fim | hard | {
"lang": "python",
"repo": "TheArqsz/AntiPhishMe-backend",
"path": "/antiphishme/src/helpers/db_helper.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> Return:
Prior probability
'''
if ((rate >= minrate) & (rate <= maxrate)):
return 1. / (maxrate - minrate)
else:
return 0
def gaussian_prior(x, mu, sigma):
'''Evaluate a normalized Gaussian function
with mu and sigma at x. NOT TESTED.'''
return 1 / (sig... | code_fim | hard | {
"lang": "python",
"repo": "ekaterinailin/SiberianPine",
"path": "/siberianpine/priors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ekaterinailin/SiberianPine path: /siberianpine/priors.py
import numpy as np
def uninformative_prior(rate, minrate, maxrate):
'''Uninformative prior for the rates.
Uniform within [minrate, maxrate].
TESTED
Parameters:
-------------
rate : float
<|fim_suffix|> '''Evalu... | code_fim | hard | {
"lang": "python",
"repo": "ekaterinailin/SiberianPine",
"path": "/siberianpine/priors.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> '''Evaluate a normalized Gaussian function
with mu and sigma at x. NOT TESTED.'''
return 1 / (sigma * np.sqrt(2 * np.pi)) * np.exp( - (x - mu)**2 / (2 * sigma**2))<|fim_prefix|># repo: ekaterinailin/SiberianPine path: /siberianpine/priors.py
import numpy as np
def uninformative_prior(rate, ... | code_fim | hard | {
"lang": "python",
"repo": "ekaterinailin/SiberianPine",
"path": "/siberianpine/priors.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
grok.context(zeit.cms.workingcopy.interfaces.ILocalContent)
@property
def modified(self):
ts = self.context._p_mtime
if ts is None:
modified = super(LocalDCTimes, self).modified
if modified is None:
annotations = zope.annotation.interfa... | code_fim | hard | {
"lang": "python",
"repo": "louika/vivi",
"path": "/core/src/zeit/cms/content/dublincore.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @modified.setter
def modified(self, value):
# Store modified in annotations. Some code may set modified for
# temporary objects or to have a modified date before database commit.
annotations = zope.annotation.interfaces.IAnnotations(self.context)
annotations[__name_... | code_fim | hard | {
"lang": "python",
"repo": "louika/vivi",
"path": "/core/src/zeit/cms/content/dublincore.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: louika/vivi path: /core/src/zeit/cms/content/dublincore.py
import grokcore.component as grok
import pendulum
import zeit.cms.content.dav
import zeit.cms.repository.interfaces
import zeit.cms.workingcopy.interfaces
import zope.dublincore.interfaces
@grok.implementer(zope.dublincore.interfaces.ID... | code_fim | hard | {
"lang": "python",
"repo": "louika/vivi",
"path": "/core/src/zeit/cms/content/dublincore.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> result = value * 100000
return result
def hectoliter_to_m3(value):
result = value / 10
return result
# Cubic meter (m3)
def m3_to_liter(value):
result = value * 1000
return result
def m3_to_milliliter(value):
result = value * 1000000
return result
def m3_to_hectoliter(value):
result = value ... | code_fim | hard | {
"lang": "python",
"repo": "TerminAtor329/pyunitsconverter",
"path": "/build/lib/pyunitsconverter/volume.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TerminAtor329/pyunitsconverter path: /build/lib/pyunitsconverter/volume.py
"""Volume units
# @see https://www.nist.gov/pml/weights-and-measures/metric-si/si-units
# @see https://www.bipm.org/en/home
This module contains functions converting common units for volume.
"""
# Liter
def liter_to_m... | code_fim | hard | {
"lang": "python",
"repo": "TerminAtor329/pyunitsconverter",
"path": "/build/lib/pyunitsconverter/volume.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def m3_to_milliliter(value):
result = value * 1000000
return result
def m3_to_hectoliter(value):
result = value * 10
return result<|fim_prefix|># repo: TerminAtor329/pyunitsconverter path: /build/lib/pyunitsconverter/volume.py
"""Volume units
# @see https://www.nist.gov/pml/weights-and-measures/met... | code_fim | hard | {
"lang": "python",
"repo": "TerminAtor329/pyunitsconverter",
"path": "/build/lib/pyunitsconverter/volume.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Tests device detection and properties populated during detection."""
self.device.close()
time.sleep(.2)
new_file_devices_name = os.path.join(self.get_output_dir(),
"test_redetect_devices.json")
new_file_options_name = os.path.join(self.get_ou... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/gazoo-device",
"path": "/gazoo_device/tests/functional_tests/common_test_suite.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: isabella232/gazoo-device path: /gazoo_device/tests/functional_tests/common_test_suite.py
# Copyright 2021 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
#
#... | code_fim | hard | {
"lang": "python",
"repo": "isabella232/gazoo-device",
"path": "/gazoo_device/tests/functional_tests/common_test_suite.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise SkipTest # FIXME: ZeroPadding2D is supported only when it's used with convolution or pooling.from<|fim_prefix|># repo: bupt-renpei/webdnn path: /test/runtime/frontend_test/keras_test/layers_test/convolutional_test/zero_padding2d_test.py
from unittest import SkipTest
<|fim_middle|>
def test():... | code_fim | easy | {
"lang": "python",
"repo": "bupt-renpei/webdnn",
"path": "/test/runtime/frontend_test/keras_test/layers_test/convolutional_test/zero_padding2d_test.py",
"mode": "spm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bupt-renpei/webdnn path: /test/runtime/frontend_test/keras_test/layers_test/convolutional_test/zero_padding2d_test.py
from unittest import SkipTest
<|fim_suffix|> raise SkipTest # FIXME: ZeroPadding2D is supported only when it's used with convolution or pooling.from<|fim_middle|>def test():... | code_fim | easy | {
"lang": "python",
"repo": "bupt-renpei/webdnn",
"path": "/test/runtime/frontend_test/keras_test/layers_test/convolutional_test/zero_padding2d_test.py",
"mode": "psm",
"license": "Zlib",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: flavoi/diventi path: /diventi/accounts/migrations/0002_achievements.py
# -*- coding: utf-8 -*-
# Generated by Django 1.11.5 on 2018-02-24 18:09
from __future__ import unicode_literals
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration... | code_fim | hard | {
"lang": "python",
"repo": "flavoi/diventi",
"path": "/diventi/accounts/migrations/0002_achievements.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.CreateModel(
name='Achievements',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('icon', models.CharField(max_length=30, verbose_name='icon')),
... | code_fim | hard | {
"lang": "python",
"repo": "flavoi/diventi",
"path": "/diventi/accounts/migrations/0002_achievements.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>IncludeTrailingBackslash = lambda v: v + '\\' if v.find('/') == -1 else v + '/'
IncludeTrailingPathDelimiter = IncludeTrailingBackslash<|fim_prefix|># repo: jieonk/plaso path: /utils/sqliteparser/lib/delphi.py
def ExtractFilePath(fn):
p = fn.rfind('\\')
if p == -1:
p = fn.rfind('/')
if... | code_fim | hard | {
"lang": "python",
"repo": "jieonk/plaso",
"path": "/utils/sqliteparser/lib/delphi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jieonk/plaso path: /utils/sqliteparser/lib/delphi.py
def ExtractFilePath(fn):
p = fn.rfind('\\')
if p == -1:
p = fn.rfind('/')
if p == -1: return ''
return fn[0:p + 1]
def ExtractFileName(fn):
<|fim_suffix|>def ChangeFileExt(fn, ext):
p = fn.rfind('.')
if p == -1: r... | code_fim | medium | {
"lang": "python",
"repo": "jieonk/plaso",
"path": "/utils/sqliteparser/lib/delphi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def FileExists(fn):
try:
f = open(fn, 'rb')
f.close()
return True
except FileNotFoundError:
return False
IncludeTrailingBackslash = lambda v: v + '\\' if v.find('/') == -1 else v + '/'
IncludeTrailingPathDelimiter = IncludeTrailingBackslash<|fim_prefix|># repo: jieonk/plaso ... | code_fim | medium | {
"lang": "python",
"repo": "jieonk/plaso",
"path": "/utils/sqliteparser/lib/delphi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Kolaposki/Discoco path: /jumia/api/serializers.py
"""
name='serializers',
project='discoco'
date='4/9/2020',
author='Oshodi Kolapo',
"""
from rest_framework import serializers
from jumia.models import AndroidScrape, IphoneScrape
<|fim_suffix|> class Meta:
model = Iphon... | code_fim | hard | {
"lang": "python",
"repo": "Kolaposki/Discoco",
"path": "/jumia/api/serializers.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class IphoneSerializer(serializers.ModelSerializer):
class Meta:
model = IphoneScrape
fields = ['percent', 'product', 'price', 'old_price', 'product_url', 'img_url', ]<|fim_prefix|># repo: Kolaposki/Discoco path: /jumia/api/serializers.py
"""
name='serializers',
project='disc... | code_fim | medium | {
"lang": "python",
"repo": "Kolaposki/Discoco",
"path": "/jumia/api/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> class Meta:
model = IphoneScrape
fields = ['percent', 'product', 'price', 'old_price', 'product_url', 'img_url', ]<|fim_prefix|># repo: Kolaposki/Discoco path: /jumia/api/serializers.py
"""
name='serializers',
project='discoco'
date='4/9/2020',
author='Oshodi Kolapo',
... | code_fim | medium | {
"lang": "python",
"repo": "Kolaposki/Discoco",
"path": "/jumia/api/serializers.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def channel_shuffle(x, groups):
"""
# >>> a = torch.arange(12)
# >>> b = a.reshape(3,4)
# >>> c = b.transpose(1,0).contiguous()
# >>> d = c.view(3,4)
# >>> a
# tensor([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11])
# >>> b
# tensor([[ 0, 1, 2, 3],
# [ 4... | code_fim | hard | {
"lang": "python",
"repo": "CodingMice/ZCls",
"path": "/zcls/model/backbones/misc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """ Asymmetric rounding to make `val` divisible by `divisor`. With default
bias, will round up, unless the number is no more than 10% greater than the
smaller divisible value, i.e. (83, 8) -> 80, but (84, 8) -> 88. """
assert 0.0 < round_up_bias < 1.0
new_val = max(divisor, int(val + d... | code_fim | medium | {
"lang": "python",
"repo": "CodingMice/ZCls",
"path": "/zcls/model/backbones/misc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CodingMice/ZCls path: /zcls/model/backbones/misc.py
# -*- coding: utf-8 -*-
"""
@date: 2021/2/19 下午2:30
@file: misc.py
@author: zj
@description:
"""
import torch
def make_divisible(v, divisor, min_value=None):
"""
This function is taken from the original tf repo.
It ensures that ... | code_fim | hard | {
"lang": "python",
"repo": "CodingMice/ZCls",
"path": "/zcls/model/backbones/misc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Rather than looking at all roleplayers and roles played, limit the number to a multiple of the number of
# samples wanted. This makes the process pseudo-random, but saves a lot of time when querying
if self._limit is not None:
population = itertools.islice(population,... | code_fim | hard | {
"lang": "python",
"repo": "LivingMatrix/kglib",
"path": "/kglib/kgcn/core/ingest/traverse/data/sample/sample.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
:param sample_size: the number of neighbours to sample at each depth
:param sampling_method: method of sampling neighbours
:param limit: limit the available population to this amount
sampling speed but sacrifices randomness
"""
self.sample_size =... | code_fim | medium | {
"lang": "python",
"repo": "LivingMatrix/kglib",
"path": "/kglib/kgcn/core/ingest/traverse/data/sample/sample.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: LivingMatrix/kglib path: /kglib/kgcn/core/ingest/traverse/data/sample/sample.py
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership... | code_fim | hard | {
"lang": "python",
"repo": "LivingMatrix/kglib",
"path": "/kglib/kgcn/core/ingest/traverse/data/sample/sample.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # factor 2 comes from assumption that beam is reflected off a mirror,
# i. e. beam gets twice the phaseshift from the displacement
return self.wavelength / 360.0 / 2.0
@property
def _rad_in_m(self):
# factor 2 comes from assumption that beam is reflected off a mirr... | code_fim | hard | {
"lang": "python",
"repo": "lneuhaus/pyrpl",
"path": "/pyrpl/software_modules/lockbox/models/interferometer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lneuhaus/pyrpl path: /pyrpl/software_modules/lockbox/models/interferometer.py
from .. import *
class InterferometerPort1(InputDirect):
@property
def plot_range(self):
maxval = np.pi*self.lockbox._unit_in_setpoint_unit('rad')
return np.linspace(-maxval, maxval, 200)
... | code_fim | hard | {
"lang": "python",
"repo": "lneuhaus/pyrpl",
"path": "/pyrpl/software_modules/lockbox/models/interferometer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def _rad_in_m(self):
# factor 2 comes from assumption that beam is reflected off a mirror,
# i. e. beam gets twice the phaseshift from the displacement
return self._rad_in_deg * self._deg_in_m
inputs = LockboxModuleDictProperty(port1=InterferometerPort1,
... | code_fim | hard | {
"lang": "python",
"repo": "lneuhaus/pyrpl",
"path": "/pyrpl/software_modules/lockbox/models/interferometer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: xr007/CSH483-Digital-Image-Processing path: /app.py
import numpy as np
from PIL import Image
import image_processing
import os
from flask import Flask, render_template, request, make_response
from datetime import datetime
from functools import wraps, update_wrapper
app = Flask(__name__)
... | code_fim | hard | {
"lang": "python",
"repo": "xr007/CSH483-Digital-Image-Processing",
"path": "/app.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@app.route("/rotate270")
@nocache
def rotate270():
image_processing.rotation270()
return render_template("uploaded.html", file_path="img/temp_img_rotated.jpeg")
@app.route("/blurring")
@nocache
def blurring():
blur_pix = 1 / 9
image_processing.convolute(blur_pix, blur_pix, b... | code_fim | hard | {
"lang": "python",
"repo": "xr007/CSH483-Digital-Image-Processing",
"path": "/app.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
content.append({ 'text': text, 'summary': summary })
count += 1
speech['content'] = content
output_file_path = os.path.... | code_fim | hard | {
"lang": "python",
"repo": "kingsleykuan/singapore-hansard-nlp",
"path": "/pegasus-multi_news/text_summarisation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kingsleykuan/singapore-hansard-nlp path: /pegasus-multi_news/text_summarisation.py
import argparse
import json
import os
import torch
from transformers import PegasusTokenizerFast, PegasusForConditionalGeneration
DEVICE = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
def creat... | code_fim | hard | {
"lang": "python",
"repo": "kingsleykuan/singapore-hansard-nlp",
"path": "/pegasus-multi_news/text_summarisation.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> input_dir_path,
output_dir_path,
model_name_or_dir):
tokenizer = PegasusTokenizerFast.from_pretrained(model_name_or_dir)
model = PegasusForConditionalGeneration.from_pretrained(model_name_or_dir).to(DEVICE)
model.eval()
os.makedirs(output_dir_path, exist_ok=True)
... | code_fim | hard | {
"lang": "python",
"repo": "kingsleykuan/singapore-hansard-nlp",
"path": "/pegasus-multi_news/text_summarisation.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openxla/iree path: /runtime/bindings/python/iree/runtime/system_api.py
# Copyright 2019 The IREE Authors
#
# Licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"""Top-le... | code_fim | hard | {
"lang": "python",
"repo": "openxla/iree",
"path": "/runtime/bindings/python/iree/runtime/system_api.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._config
@property
def instance(self) -> _binding.VmInstance:
return self._config.vm_instance
@property
def modules(self) -> BoundModules:
return self._bound_modules
def add_module_dependency(self, name, minimum_version=0):
resolved_module ... | code_fim | hard | {
"lang": "python",
"repo": "openxla/iree",
"path": "/runtime/bindings/python/iree/runtime/system_api.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: camilog/moca-bulletin-board path: /app/models/__init__.py
from app.models import dummy_share_key, authority_public_key, ballot, candidate, <|fim_suffix|>ots, partial_decryption, voter_public_key<|fim_middle|>election, final_outcome, multiplied_ball | code_fim | easy | {
"lang": "python",
"repo": "camilog/moca-bulletin-board",
"path": "/app/models/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>election, final_outcome, multiplied_ballots, partial_decryption, voter_public_key<|fim_prefix|># repo: camilog/moca-bulletin-board path: /app/models/__init__.py
from app.models import dummy_share_key, <|fim_middle|>authority_public_key, ballot, candidate, | code_fim | easy | {
"lang": "python",
"repo": "camilog/moca-bulletin-board",
"path": "/app/models/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: YerevaNN/yarx path: /yarx/layers/multi_time_distributed.py
import torch
from torch.nn import functional as F
from allennlp.modules import TimeDistributed
from typing import List
from overrides import overrides
class MultiTimeDistributed(TimeDistributed):
"""
Given an input shaped lik... | code_fim | hard | {
"lang": "python",
"repo": "YerevaNN/yarx",
"path": "/yarx/layers/multi_time_distributed.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Need some input to then get the batch_size and time_steps.
some_input = None
if inputs:
some_input = inputs[-1]
reshaped_kwargs = {}
for key, value in kwargs.items():
if isinstance(value, torch.Tensor) and key not in pass_through:
... | code_fim | hard | {
"lang": "python",
"repo": "YerevaNN/yarx",
"path": "/yarx/layers/multi_time_distributed.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: neizod/problems path: /codejam/08/1a/minscalar.py
for case in range(int(input())):
size = int(input())
a = sorted(int(val) for val in input().split())
b = sorted(int(val) for val in input().split())[::-1]
<|fim_suffix|> print('Case #{}: {}'.format(case+1, scalar))<|fim_midd... | code_fim | easy | {
"lang": "python",
"repo": "neizod/problems",
"path": "/codejam/08/1a/minscalar.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print('Case #{}: {}'.format(case+1, scalar))<|fim_prefix|># repo: neizod/problems path: /codejam/08/1a/minscalar.py
for case in range(int(input())):
size = int(input())
<|fim_middle|> a = sorted(int(val) for val in input().split())
b = sorted(int(val) for val in input().split())[::-1]... | code_fim | medium | {
"lang": "python",
"repo": "neizod/problems",
"path": "/codejam/08/1a/minscalar.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def resolve_actions(self): ...
def get_action_categories(self) -> (Dict[str, List[Villager]], Dict[str, List[Villager]]): ...
def date_update(self): ...<|fim_prefix|># repo: woodenbell/villages-at-war path: /src/villageswar/world.pyi
from typing import Union, Dict, List
from villageswar.v... | code_fim | hard | {
"lang": "python",
"repo": "woodenbell/villages-at-war",
"path": "/src/villageswar/world.pyi",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: woodenbell/villages-at-war path: /src/villageswar/world.pyi
from typing import Union, Dict, List
from villageswar.village import Village
from villageswar.villager import Villager
config = None # type: dict
def maximum(val: Union[int, float], max_val: Union[int, float]) -> Union[int, float]: ..... | code_fim | hard | {
"lang": "python",
"repo": "woodenbell/villages-at-war",
"path": "/src/villageswar/world.pyi",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __enter__(self) -> dict:
try:
return self.response.json()
except:
return {}
def __exit__(self, exception_type, exception_value, traceback):
pass<|fim_prefix|># repo: gluo7777/MyTools path: /cli/scripts/client.py
from cli.scripts.config import P... | code_fim | hard | {
"lang": "python",
"repo": "gluo7777/MyTools",
"path": "/cli/scripts/client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, msg: str = 'Error calling API', *args, **kwargs):
super().__init__(*args, **kwargs)
self.msg = msg
def __str__(self):
return self.msg
class Json(object):
def __init__(self, response: requests.Response):
super().__init__()
self.respo... | code_fim | hard | {
"lang": "python",
"repo": "gluo7777/MyTools",
"path": "/cli/scripts/client.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.