text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: csrdxbb/sysConferences path: /systemConferencesCrawl.py
import requests
from bs4 import BeautifulSoup
CCFA = 1
CCFB = 0.5
CCFC = 0
COREASTAR = 2
COREA = 1
COREB = 0.5
headers = {'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472... | code_fim | medium | {
"lang": "python",
"repo": "csrdxbb/sysConferences",
"path": "/systemConferencesCrawl.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> url_2016 = 'https://ppopp16.sigplan.org/committee/ppopp-2016-papers-program-committee'
sysArch_CCF_A = {'PPoPP','FAST','DAC','HPCA','MICRO','SC','ASPLOS','ISCA','USENIX ATC'}
sysArch_CCF_B = {'SoCC','SPAA','PODC','FPGA','CGO','DATE','EuroSys','HOT CHIPS','CLUSTER','ICCD','ICCAD','ICDCS','CODES... | code_fim | hard | {
"lang": "python",
"repo": "csrdxbb/sysConferences",
"path": "/systemConferencesCrawl.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'''
create a protocol buffer message object
Input: string message
output: protocol buffer object
'''
def newMsg(txt):
msg = chat_pb2.message()
msg.text = txt
return msg
'''
get protocol buffer message object from serialized message
Input: string serialized protobuf message object
output: protocol bu... | code_fim | medium | {
"lang": "python",
"repo": "RobinKarlsson/protobuf-chat",
"path": "/protobuf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RobinKarlsson/protobuf-chat path: /protobuf.py
import chat_pb2
'''
create a protocol buffer user object
Input: string username
channel to join
output: protocol buffer object
'''
def newUser(nick, channel):
<|fim_suffix|> msg = chat_pb2.message()
msg.ParseFromString(serialized)
return msg
'... | code_fim | hard | {
"lang": "python",
"repo": "RobinKarlsson/protobuf-chat",
"path": "/protobuf.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>'''
get protocol buffer user object from serialized user
Input: string serialized protobuf user object
output: protocol buffer user object
'''
def getUsr(serialized):
usr = chat_pb2.join()
usr.ParseFromString(serialized)
return usr<|fim_prefix|># repo: RobinKarlsson/protobuf-chat path: /protobuf.py
i... | code_fim | hard | {
"lang": "python",
"repo": "RobinKarlsson/protobuf-chat",
"path": "/protobuf.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OCLC-Developer-Network/oclc-auth-python path: /tests/user_test.py
###############################################################################
# Copyright 2014 OCLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the Lic... | code_fim | hard | {
"lang": "python",
"repo": "OCLC-Developer-Network/oclc-auth-python",
"path": "/tests/user_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def testCreateUser(self):
self.assertEqual(self._user.principal_id, '8eaa9f92-3951-431c-975a-e5dt26b7d232')
self.assertEqual(self._user.principal_idns, 'urn:oclc:wms:da')
self.assertEqual(self._user.authenticating_institution_id, '128807')
"""Test that the string represent... | code_fim | hard | {
"lang": "python",
"repo": "OCLC-Developer-Network/oclc-auth-python",
"path": "/tests/user_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FirebirdSQL/firebird-qa path: /tests/bugs/core_3188_test.py
#coding:utf-8
"""
ID: issue-3562
ISSUE: 3562
TITLE: page 0 is of wrong type (expected 6, found 1)
DESCRIPTION:
JIRA: CORE-3188
FBTEST: bugs.core_3188
"""
import pytest
from difflib import unified_diff
f... | code_fim | medium | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/core_3188_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>act = python_act('db')
@pytest.mark.version('>=3')
def test_1(act: Action):
with act.connect_server() as srv:
srv.info.get_log()
log_before = srv.readlines()
with act.db.connect() as con1, act.db.connect() as con2:
c1 = con1.cursor()
c1.execute("create ... | code_fim | medium | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/core_3188_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> with act.connect_server() as srv:
srv.info.get_log()
log_before = srv.readlines()
with act.db.connect() as con1, act.db.connect() as con2:
c1 = con1.cursor()
c1.execute("create table test(id int primary key)")
con1.commit()
#
... | code_fim | medium | {
"lang": "python",
"repo": "FirebirdSQL/firebird-qa",
"path": "/tests/bugs/core_3188_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AdrianaViabL/ProjetoDjangoAluraBlogReceitas path: /apps/receitas/views/receita.py
from django.shortcuts import render, get_list_or_404, get_object_or_404, redirect
from receitas.models import Receita #mostra como erro mas está funcionando
from django.contrib import messages
from django.contrib.au... | code_fim | hard | {
"lang": "python",
"repo": "AdrianaViabL/ProjetoDjangoAluraBlogReceitas",
"path": "/apps/receitas/views/receita.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if request.method == 'POST':
receita_id = request.POST['receita_id']
r = Receita.objects.get(pk=receita_id)
r.nome_receita = request.POST['nome_receita']
r.ingredientes = request.POST['ingredientes']
r.modo_preparo = request.POST['modo_preparo']
r.tempo_... | code_fim | hard | {
"lang": "python",
"repo": "AdrianaViabL/ProjetoDjangoAluraBlogReceitas",
"path": "/apps/receitas/views/receita.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hyperonym/basaran path: /basaran/tokenizer.py
"""
A stateful tokenizer for stream decoding.
"""
class StreamTokenizer:
"""StreamTokenizer wraps around a tokenizer to support stream decoding."""
def __init__(self, tokenizer):
<|fim_suffix|> # Handle replacement characters caused ... | code_fim | hard | {
"lang": "python",
"repo": "hyperonym/basaran",
"path": "/basaran/tokenizer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Handle whitespace between tokens.
tokens = self.buffer + [token]
prefix = self.tokenizer.decode(self.buffer, skip_special_tokens=True)
whole = self.tokenizer.decode(tokens, skip_special_tokens=True)
if prefix + " " + text == whole:
text = " " + text
... | code_fim | hard | {
"lang": "python",
"repo": "hyperonym/basaran",
"path": "/basaran/tokenizer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jxwolstenholme/hass-custom-components path: /device_tracker/bt_smarthub.py
"""
Support for BT Smart Hub device tracking in Home Assistant.
"""
import logging
import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.device_tracker import (DOMAI... | code_fim | hard | {
"lang": "python",
"repo": "jxwolstenholme/hass-custom-components",
"path": "/device_tracker/bt_smarthub.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_bt_smarthub_data(self):
"""Retrieve data from BT Smarthub and return parsed result"""
import btsmarthub_devicelist
data = btsmarthub_devicelist.get_devicelist(router_ip=self.host, only_active_devices=True)
devices = {}
for device in data:
tr... | code_fim | hard | {
"lang": "python",
"repo": "jxwolstenholme/hass-custom-components",
"path": "/device_tracker/bt_smarthub.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _LOGGER.info("Scanning")
data = self.get_bt_smarthub_data()
if not data:
_LOGGER.warning("Error scanning devices")
return False
clients = [client for client in data.values()]
self.last_results = clients
return True
def get_bt_sm... | code_fim | hard | {
"lang": "python",
"repo": "jxwolstenholme/hass-custom-components",
"path": "/device_tracker/bt_smarthub.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: j12r12/Premier-League-Red-Cards path: /main.py
from function_file import best_fit, line_graph, normal_curve
if __name__ == "__main__":
# Create dataframe
df2 = pd.read_csv("../input/english-premier-league-data-for-10-seasons/epldat10seasons/epl-allseasons-matchstats.csv"... | code_fim | hard | {
"lang": "python",
"repo": "j12r12/Premier-League-Red-Cards",
"path": "/main.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> line_graph(season_cards["HomeReds"], "HomeReds", "Home Team Red Cards", style="seaborn-poster")
line_graph(season_cards["AwayReds"], "AwayReds", "Away Team Red Cards", style="seaborn-poster")
line_graph(season_cards["TotalReds"], "TotalReds", "Total Team Red Cards", style="seaborn-poster")
... | code_fim | medium | {
"lang": "python",
"repo": "j12r12/Premier-League-Red-Cards",
"path": "/main.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> op.alter_column("blobupload", "byte_count", existing_type=sa.BigInteger(), nullable=True)<|fim_prefix|># repo: quay/quay path: /data/migrations/versions/152edccba18c_make_blodupload_byte_count_not_nullable.py
"""
Make BlodUpload byte_count not nullable.
Revision ID: 152edccba18c
Revises: c91c564aad3... | code_fim | hard | {
"lang": "python",
"repo": "quay/quay",
"path": "/data/migrations/versions/152edccba18c_make_blodupload_byte_count_not_nullable.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def downgrade(op, tables, tester):
op.alter_column("blobupload", "byte_count", existing_type=sa.BigInteger(), nullable=True)<|fim_prefix|># repo: quay/quay path: /data/migrations/versions/152edccba18c_make_blodupload_byte_count_not_nullable.py
"""
Make BlodUpload byte_count not nullable.
Revision ID... | code_fim | medium | {
"lang": "python",
"repo": "quay/quay",
"path": "/data/migrations/versions/152edccba18c_make_blodupload_byte_count_not_nullable.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: quay/quay path: /data/migrations/versions/152edccba18c_make_blodupload_byte_count_not_nullable.py
"""
Make BlodUpload byte_count not nullable.
Revision ID: 152edccba18c
Revises: c91c564aad34
Create Date: 2018-02-23 12:41:25.571835
"""
# revision identifiers, used by Alembic.
revision = "152edcc... | code_fim | medium | {
"lang": "python",
"repo": "quay/quay",
"path": "/data/migrations/versions/152edccba18c_make_blodupload_byte_count_not_nullable.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MichaelStott/KivMob path: /setup.py
from setuptools import setup
setup(
name="kivmob",
version="2.0",
<|fim_suffix|> py_modules=["kivmob"],
install_requires=["kivy"],
zip_safe=False,
)<|fim_middle|> description="Provides AdMob support for Kivy.",
url="http://github.com/Mic... | code_fim | medium | {
"lang": "python",
"repo": "MichaelStott/KivMob",
"path": "/setup.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>om/MichaelStott/KivMob",
author="Michael Stott",
license="MIT",
py_modules=["kivmob"],
install_requires=["kivy"],
zip_safe=False,
)<|fim_prefix|># repo: MichaelStott/KivMob path: /setup.py
from setuptools import setup
setup(
name="kivmob",
version="2.0",
<|fim_middle|> des... | code_fim | medium | {
"lang": "python",
"repo": "MichaelStott/KivMob",
"path": "/setup.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tapiatellez/distance_to_MKAD path: /test.py
from app import app
import unittest
class FlaskTestCase(unittest.TestCase):
def test_index(self):
"""Ensure that flask was set up correctly."""
tester = app.test_client(self)
response = tester.get('/', content_type = 'html_... | code_fim | hard | {
"lang": "python",
"repo": "tapiatellez/distance_to_MKAD",
"path": "/test.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Test for a null address."""
tester = app.test_client(self)
response = tester.post("/result",
data = dict(location =""),
follow_redirects = True)
self.assertIn(b"Null input", response.data)
def test_addres... | code_fim | hard | {
"lang": "python",
"repo": "tapiatellez/distance_to_MKAD",
"path": "/test.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MarkyMark1000/AWS---PYTHON---COPY---MYWEBSITE path: /apps/ContactMe/forms.py
from django import forms
class ContactForm(forms.Form):
form_name = forms.CharField(widget=forms.TextInput(attrs={
'class': 'form-control',
'placehold... | code_fim | hard | {
"lang": "python",
"repo": "MarkyMark1000/AWS---PYTHON---COPY---MYWEBSITE",
"path": "/apps/ContactMe/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> }),)
form_message = forms.CharField(widget=forms.Textarea(attrs={
'class': 'form-control',
'placeholder': 'Message *',
'required': 'required',
'minlength': '1',
... | code_fim | hard | {
"lang": "python",
"repo": "MarkyMark1000/AWS---PYTHON---COPY---MYWEBSITE",
"path": "/apps/ContactMe/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: imfog/PyQtImageViewer path: /main_application.py
from PySide2 import QtCore, QtGui, QtWidgets
from PySide2.QtWidgets import *
from PySide2.QtGui import *
from PySide2.QtCore import QObject, QPoint, QPointF, QFile, QSize, QSizeF, QRect, QRectF, QMimeData, Signal, Slot
from PIL import Image
import ... | code_fim | hard | {
"lang": "python",
"repo": "imfog/PyQtImageViewer",
"path": "/main_application.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, datasets, dataset, parent=None):
super(GetDatasetDialog, self).__init__(parent)
self.setWindowFlags(QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint)
## Default values
self.dL = QLabel("Choose dataset:")
self.dInput = QComboBox(self)
for d in datasets:
self.dIn... | code_fim | hard | {
"lang": "python",
"repo": "imfog/PyQtImageViewer",
"path": "/main_application.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: VAR-solutions/Algorithms path: /Sorting/Pancake Sorting/Python3/pancake.py
tutor = False
def pancakesort(array):
if len(array) <= 1:
return array
if tutor:
print()
for size in range(len(array), 1, -1):
maxindex = max(range(size), key=lamdba <|fim_suffix|>ith:... | code_fim | hard | {
"lang": "python",
"repo": "VAR-solutions/Algorithms",
"path": "/Sorting/Pancake Sorting/Python3/pancake.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>ith: %r doflip %i' % (
' '.join(str(x) for x in array), size
)
)
array[:size] = reversed(array[:size])
if tutor:
print()<|fim_prefix|># repo: VAR-solutions/Algorithms path: /Sorting/Pancake Sorting/Python3/pancake.py
tut... | code_fim | hard | {
"lang": "python",
"repo": "VAR-solutions/Algorithms",
"path": "/Sorting/Pancake Sorting/Python3/pancake.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>' '.join(str(x) for x in array), maxindex+1)
)
array[:maxindex+1] = reversed(array[:maxindex+1])
if tutor:
print(
'With: %r doflip %i' % (
' '.join(str(x) for x in array), size
... | code_fim | hard | {
"lang": "python",
"repo": "VAR-solutions/Algorithms",
"path": "/Sorting/Pancake Sorting/Python3/pancake.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benopoku/GROOT path: /groot/provably_robust_boosting/utils.py
import os
import numpy as np
import glob
from numba import jit
class Logger:
def __init__(self, path):
self.path = path
if path != "":
folder = "/".join(path.split("/")[:-1])
if not os.path... | code_fim | hard | {
"lang": "python",
"repo": "benopoku/GROOT",
"path": "/groot/provably_robust_boosting/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return model_name.split(substr)[1].split(" ")[0]
def finalize_curr_row(latex_str, weak_learner, flag_n_trees_latex):
# finalizing the current row: apply boldfacing and add \\
# (relies on the fact that we have only 3 metrics, i.e. TE,RTE,URTE or TE,LRTE,URTE or 4 metrics if flag_n_trees_late... | code_fim | hard | {
"lang": "python",
"repo": "benopoku/GROOT",
"path": "/groot/provably_robust_boosting/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Tarkiyah/googleResearch path: /moew/crime.py
# coding=utf-8
# Copyright 2019 The Google Research Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http:/... | code_fim | hard | {
"lang": "python",
"repo": "Tarkiyah/googleResearch",
"path": "/moew/crime.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> xy = tf.concat([x, y], axis=1)
autoencoder_layer1 = tf.layers.dense(
inputs=xy, units=10, activation=tf.sigmoid)
autoencoder_embedding_layer = tf.layers.dense(
inputs=autoencoder_layer1, units=EMBEDDING_DIM, activation=tf.sigmoid)
autoencoder_layer3 = tf.layers.dense(
inputs=auto... | code_fim | hard | {
"lang": "python",
"repo": "Tarkiyah/googleResearch",
"path": "/moew/crime.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def optimization(logits, y, population, embedding, alpha):
"""Loss and optimization method."""
if FLAGS.uniform_weights:
weights = tf.ones(shape=tf.shape(population))
else:
weights = tf.where(
tf.greater(population, 0.01), tf.fill(tf.shape(population), 0.16),
tf.fill(tf.shape... | code_fim | hard | {
"lang": "python",
"repo": "Tarkiyah/googleResearch",
"path": "/moew/crime.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dmertins/sales-data-analyzer path: /tests/unit/count_customers_test.py
from unittest import TestCase
from salesdataanalyzer.analyzer import count_customers
from salesdataanalyzer.helpers import Customer
class CountCustomersTest(TestCase):
def test_count_customers(self):
<|fim_suffix|> ... | code_fim | medium | {
"lang": "python",
"repo": "dmertins/sales-data-analyzer",
"path": "/tests/unit/count_customers_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> customers_amount = count_customers([])
self.assertEqual(0, customers_amount)<|fim_prefix|># repo: dmertins/sales-data-analyzer path: /tests/unit/count_customers_test.py
from unittest import TestCase
from salesdataanalyzer.analyzer import count_customers
from salesdataanalyzer.helpers im... | code_fim | hard | {
"lang": "python",
"repo": "dmertins/sales-data-analyzer",
"path": "/tests/unit/count_customers_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chubbysingh/interview path: /python/dynamic/nth_fibonacci.py
"""
Problem Statement
=================
Given the number n, find the nth fibanacci number.
The fibonacci series is 0, 1, 1, 2, 3 ...
And follows the formula Fn = Fn-1 + Fn-2
Complexity
----------
* Recursive Solution: O(2^n)
* Dyna... | code_fim | medium | {
"lang": "python",
"repo": "chubbysingh/interview",
"path": "/python/dynamic/nth_fibonacci.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return fibonacci_recursive(n - 1) + fibonacci_recursive(n - 2)
def fibonacci(n):
n1, n2 = 0, 1
if n == n1 or n == n2:
return n
for i in range(2, n + 1):
n1, n2 = n2, n1 + n2
return n2
if __name__ == '__main__':
assert 610 == fibonacci_recursive(15)
assert ... | code_fim | medium | {
"lang": "python",
"repo": "chubbysingh/interview",
"path": "/python/dynamic/nth_fibonacci.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: AllenInstitute/aics-ml-segmentation path: /aicsmlsegment/custom_metrics.py
import numpy as np
import torch
from skimage import measure
from aicsmlsegment.custom_loss import MultiAuxillaryElementNLLLoss, compute_per_channel_dice, expand_as_one_hot
class DiceCoefficient:
"""Computes Dice... | code_fim | hard | {
"lang": "python",
"repo": "AllenInstitute/aics-ml-segmentation",
"path": "/aicsmlsegment/custom_metrics.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> per_channel_iou = []
for c in range(n_classes):
if c in self.skip_channels:
continue
per_channel_iou.append(self._jaccard_index(binary_prediction[c], target[c]))
assert per_channel_iou, "All channels were ignored from the computation... | code_fim | hard | {
"lang": "python",
"repo": "AllenInstitute/aics-ml-segmentation",
"path": "/aicsmlsegment/custom_metrics.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>class AveragePrecision:
"""
Computes Average Precision given boundary prediction and ground truth instance segmentation.
"""
def __init__(self, threshold=0.4, iou_range=(0.5, 1.0), ignore_index=-1, min_instance_size=None,
use_last_target=False):
"""
... | code_fim | hard | {
"lang": "python",
"repo": "AllenInstitute/aics-ml-segmentation",
"path": "/aicsmlsegment/custom_metrics.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: almagul-zh90/django-powerbank path: /src/django_powerbank/views/mixins.py
# coding=utf-8
import logging
from django.http import HttpResponseRedirect
from django.views.generic.base import ContextMixin, View
class ReturnUrlMx(ContextMixin, View):
def __init__(self, **kwargs):
<|fim_suffix|> ... | code_fim | hard | {
"lang": "python",
"repo": "almagul-zh90/django-powerbank",
"path": "/src/django_powerbank/views/mixins.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.return_url = request.GET.get('return_url', None)
referrer = request.META.get('HTTP_REFERER', None)
# leave alone POST and ajax requests and if return_url is explicitly left empty
if (request.method != "GET" or
request.is_ajax() or
self.... | code_fim | hard | {
"lang": "python",
"repo": "almagul-zh90/django-powerbank",
"path": "/src/django_powerbank/views/mixins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def dispatch(self, request, *args, **kwargs):
"""
Does request processing for return_url query parameter and redirects with it's missing
We can't do that in the get method, as it does not exist in the View base class
and child mixins implementing get do not call super(... | code_fim | hard | {
"lang": "python",
"repo": "almagul-zh90/django-powerbank",
"path": "/src/django_powerbank/views/mixins.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def RunWithChecker(bus, topic, answertopic, *args, **kwargs):
return ExecuteRPC(bus, topic, answertopic, *args, **kwargs)[1]
def ExecuteInOrder(bus, calls):
for item in calls:
topic, answertopic = item[:2]
arguments = []
kwargs = {}
if len(item) >= 3:
... | code_fim | hard | {
"lang": "python",
"repo": "CatEars/kattis-command",
"path": "/test/util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class CallChecker:
def __init__(self):
self.is_called = False
def __call__(self, *args, **kwargs):
self.is_called = True
@property
def yay(self):
return self.is_called
@property
def nay(self):
return not self.is_called
def ExecuteRPC(bus, topic... | code_fim | hard | {
"lang": "python",
"repo": "CatEars/kattis-command",
"path": "/test/util.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CatEars/kattis-command path: /test/util.py
import os
import tempfile
from kattcmd import core
from kattcmd import bus as busmodule
from kattcmd.commands import open as open_command, compile as compile_command, \
init, root, config, template, test_download, test, run, clean, submit, \
late... | code_fim | hard | {
"lang": "python",
"repo": "CatEars/kattis-command",
"path": "/test/util.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ascampos/police-data-trust path: /requirements/update.py
import subprocess
import sys
req_files = [
"requirements/dev_unix.in",
"requirements/dev_windows.in",
"requirements/prod.in",
"requirements/docs.in",
]
def run():
results = []
for filename in req_files:
re... | code_fim | hard | {
"lang": "python",
"repo": "ascampos/police-data-trust",
"path": "/requirements/update.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
code = run()
sys.exit(code)<|fim_prefix|># repo: ascampos/police-data-trust path: /requirements/update.py
import subprocess
import sys
req_files = [
"requirements/dev_unix.in",
"requirements/dev_windows.in",
"requirements/prod.in",
"requirements/docs.in... | code_fim | hard | {
"lang": "python",
"repo": "ascampos/police-data-trust",
"path": "/requirements/update.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(unrepeated)>0:
return unrepeated[0]
else:
return '_'<|fim_prefix|># repo: H4rliquinn/Algorithm-Solutions path: /CodeSignal/Arrays/firstNotRepeatingCharacter.py
def firstNotRepeatingCharacter(s):
<|fim_middle|> found=set()
unrepeated=[]
for char in s:
if c... | code_fim | hard | {
"lang": "python",
"repo": "H4rliquinn/Algorithm-Solutions",
"path": "/CodeSignal/Arrays/firstNotRepeatingCharacter.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: H4rliquinn/Algorithm-Solutions path: /CodeSignal/Arrays/firstNotRepeatingCharacter.py
def firstNotRepeatingCharacter(s):
<|fim_suffix|> if len(unrepeated)>0:
return unrepeated[0]
else:
return '_'<|fim_middle|> found=set()
unrepeated=[]
for char in s:
if c... | code_fim | hard | {
"lang": "python",
"repo": "H4rliquinn/Algorithm-Solutions",
"path": "/CodeSignal/Arrays/firstNotRepeatingCharacter.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if len(_L) != len(_W):
print(len(_L) != len(_W))
return False
mask = [compare_tokens(x, y) for x, y in zip(_L, _W)]
if not all(mask):
print(mask)
return False
return True
fp = open('linux_windows_comparison_report.txt', 'w')
year = None
for i in range(len... | code_fim | hard | {
"lang": "python",
"repo": "rogerlew/wepppy",
"path": "/wepppy/wepp/tests/compare.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rogerlew/wepppy path: /wepppy/wepp/tests/compare.py
linux = open('loss_pw0_linux.txt').readlines()
linux = [L.strip() for L in linux]
linux = [L for L in linux if len(L) > 0]
windows = open('loss_pw0_windows.txt').readlines()
windows = [L.strip() for L in windows]
windows = [L for L in windows... | code_fim | hard | {
"lang": "python",
"repo": "rogerlew/wepppy",
"path": "/wepppy/wepp/tests/compare.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>fp = open('linux_windows_comparison_report.txt', 'w')
year = None
for i in range(len(linux)):
L = linux[i]
W = windows[i]
if L.startswith('ANNUAL SUMMARY FOR WATERSHED IN YEAR'):
year = L.split()[-1]
if not compare_row(L, W):
fp.write('{} {}\n'.format(year, i+1))
... | code_fim | hard | {
"lang": "python",
"repo": "rogerlew/wepppy",
"path": "/wepppy/wepp/tests/compare.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> return T
def point_transform(point, T, coord):
point = torch.Tensor(point.reshape([1, 1, 2]))
d2 = torch.sum(torch.pow(point - coord, 2), 2)
r = d2 * torch.log(d2 + 1e-6)
q = torch.Tensor(np.array([[1, point[0, 0, 0], point[0, 0, 1]]]))
x = torch.cat([q, r], 1)
point_T = torch... | code_fim | hard | {
"lang": "python",
"repo": "shengzhang90/Pytorch-ThinPlateSpline",
"path": "/ThinPlateSpline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shengzhang90/Pytorch-ThinPlateSpline path: /ThinPlateSpline.py
import torch
import numpy as np
import torch.nn.functional as F
def b_inv(b_mat):
eye = b_mat.new_ones(b_mat.size(-1)).diag().expand_as(b_mat)
b_inv, _ = torch.gesv(eye, b_mat)
return b_inv
def solve_system(coord, vec):
... | code_fim | hard | {
"lang": "python",
"repo": "shengzhang90/Pytorch-ThinPlateSpline",
"path": "/ThinPlateSpline.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> point = torch.Tensor(point.reshape([1, 1, 2]))
d2 = torch.sum(torch.pow(point - coord, 2), 2)
r = d2 * torch.log(d2 + 1e-6)
q = torch.Tensor(np.array([[1, point[0, 0, 0], point[0, 0, 1]]]))
x = torch.cat([q, r], 1)
point_T = torch.matmul(T, torch.transpose(x.unsqueeze(1), 2, 1))
... | code_fim | hard | {
"lang": "python",
"repo": "shengzhang90/Pytorch-ThinPlateSpline",
"path": "/ThinPlateSpline.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># XBEE Low Power Direction (XBEE_LP <-> FTDI)
xbee_lp_dir = Pin('XBEE_LP_DIR', Pin.OUT_OD)
xbee_lp_dir.low()
# XBEE High Power Direction (XBEE_HP <-> FTDI)
xbee_hp_dir = Pin('XBEE_HP_DIR', Pin.OUT_OD)
xbee_hp_dir.low()
# Console info
print('XBEE Power-On')
print('You should see XBee serial ports on your... | code_fim | medium | {
"lang": "python",
"repo": "stalyatech/upython-samples",
"path": "/basic/[05] - xbee_power_on.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: stalyatech/upython-samples path: /basic/[05] - xbee_power_on.py
from sty import Pin
# ---------------------------------------------------------------
# Power-on the XBEE-LP subsystem of RTK board
# ---------------------------------------------------------------
# XBEE Low Power Socket
xbee_lp_p... | code_fim | medium | {
"lang": "python",
"repo": "stalyatech/upython-samples",
"path": "/basic/[05] - xbee_power_on.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: id4thomas/Story-Untangling path: /scripts/mturk_qualification.py
import argparse
import datetime
import boto3
import pandas
parser = argparse.ArgumentParser(
description='Grant a custom qualification on MTurk.')
parser.add_argument('--access-key-id', required=True, help="AWS Access Key.")
p... | code_fim | hard | {
"lang": "python",
"repo": "id4thomas/Story-Untangling",
"path": "/scripts/mturk_qualification.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>args = parser.parse_args()
def grant_or_revoke_qualification(args):
print(f"Amend qualifications: {args}")
mturk = boto3.client('mturk',
aws_access_key_id=args["access_key_id"],
aws_secret_access_key=args["secret_access_key"],
... | code_fim | hard | {
"lang": "python",
"repo": "id4thomas/Story-Untangling",
"path": "/scripts/mturk_qualification.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> except :
return '500'
if __name__ == '__main__':
app.run(debug = True)<|fim_prefix|># repo: ytype/AI-PT-MENTOR-QnA path: /flask_file_upload/app.py
from flask import Flask, render_template, request
from werkzeug.utils import secure_filename
from flask_cors import CORS
app ... | code_fim | hard | {
"lang": "python",
"repo": "ytype/AI-PT-MENTOR-QnA",
"path": "/flask_file_upload/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
@app.route('/fileUpload', methods = ['POST'])
def upload_file():
try :
f = request.files['file']
fileName = f.filename + '.wav'
f.save(f'uploads/{secure_filename(fileName)}')
return '200'
except :
return '500'
if __name__ == '__main__':
... | code_fim | medium | {
"lang": "python",
"repo": "ytype/AI-PT-MENTOR-QnA",
"path": "/flask_file_upload/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ytype/AI-PT-MENTOR-QnA path: /flask_file_upload/app.py
from flask import Flask, render_template, request
from werkzeug.utils import secure_filename
from flask_cors import CORS
<|fim_suffix|> except :
return '500'
if __name__ == '__main__':
app.run(debug = True)<|fi... | code_fim | hard | {
"lang": "python",
"repo": "ytype/AI-PT-MENTOR-QnA",
"path": "/flask_file_upload/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrValdez/pictionary-clone path: /gamebase.py
import pygame
class Action:
packet_name = None
network_command = False
data_required = True
def __init__(self, data=None, target_id=None):
# target_id is the id of the player to send this packet to
if not self.packet_... | code_fim | medium | {
"lang": "python",
"repo": "MrValdez/pictionary-clone",
"path": "/gamebase.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
Command run in the client
"""
pass
def run_server(self, GameState):
"""
Command run when server receives this action
"""
pass
class GameState:
"""
This is the store in the Flux architecture
"""
def __init__(self):
... | code_fim | medium | {
"lang": "python",
"repo": "MrValdez/pictionary-clone",
"path": "/gamebase.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyg-team/pytorch_geometric path: /torch_geometric/data/hetero_data.py
data['author', 'writes', 'paper'].edge_index = edge_index_author_paper
# or (2) pass them as keyword arguments during initialization,
data = HeteroData(author__writes__paper={
'edge_index': edge... | code_fim | hard | {
"lang": "python",
"repo": "pyg-team/pytorch_geometric",
"path": "/torch_geometric/data/hetero_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if 'edge_index' in store and store.edge_index.numel() > 0:
if store.edge_index.min() < 0:
status = False
warn_or_raise(
f"'edge_index' of edge type {edge_type} contains "
f"negative indices ... | code_fim | hard | {
"lang": "python",
"repo": "pyg-team/pytorch_geometric",
"path": "/torch_geometric/data/hetero_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if keys is not None:
sizes_dict = {
key: sizes
for key, sizes in sizes_dict.items() if key in keys
}
sizes_dict = {
key: sizes
for key, sizes in sizes_dict.items() if len(set(si... | code_fim | hard | {
"lang": "python",
"repo": "pyg-team/pytorch_geometric",
"path": "/torch_geometric/data/hetero_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('webmap', '0005_auto_20150607_1533'),
]
operations = [
migrations.RunPython(make_order),
]<|fim_prefix|># repo: timthelion/django-webmap-corpus path: /webmap/migrations/0006_auto_20150607_1534.py
# -*- coding: utf-8 -*-
from __future__ import unicode_l... | code_fim | hard | {
"lang": "python",
"repo": "timthelion/django-webmap-corpus",
"path": "/webmap/migrations/0006_auto_20150607_1534.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: timthelion/django-webmap-corpus path: /webmap/migrations/0006_auto_20150607_1534.py
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
def make_order(apps, schema_editor):
# We can't import the Person model directly as it may be a newer
... | code_fim | medium | {
"lang": "python",
"repo": "timthelion/django-webmap-corpus",
"path": "/webmap/migrations/0006_auto_20150607_1534.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_model_load():
model_path = f"{get_test_folder()}/../examples/pyomecaman.bioMod"
# From path
b1 = Viz(model_path=model_path)
# From a loaded model
m = biorbd.Model(model_path)
b2 = Viz(loaded_model=m)<|fim_prefix|># repo: pyomeca/bioviz path: /tests/test_Gui.py
import pa... | code_fim | medium | {
"lang": "python",
"repo": "pyomeca/bioviz",
"path": "/tests/test_Gui.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pyomeca/bioviz path: /tests/test_Gui.py
import pathlib
import biorbd
from bioviz import Viz
def get_test_folder():
<|fim_suffix|>
def test_model_load():
model_path = f"{get_test_folder()}/../examples/pyomecaman.bioMod"
# From path
b1 = Viz(model_path=model_path)
# From a load... | code_fim | easy | {
"lang": "python",
"repo": "pyomeca/bioviz",
"path": "/tests/test_Gui.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # From a loaded model
m = biorbd.Model(model_path)
b2 = Viz(loaded_model=m)<|fim_prefix|># repo: pyomeca/bioviz path: /tests/test_Gui.py
import pathlib
import biorbd
from bioviz import Viz
<|fim_middle|>def get_test_folder():
return pathlib.Path(__file__).parent.resolve()
def test_mo... | code_fim | hard | {
"lang": "python",
"repo": "pyomeca/bioviz",
"path": "/tests/test_Gui.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NERSC/shifter path: /imagegw/test/imagemngr_test.py
)
@attr('fast')
def test_add_remove_two(self):
"""
Test that tag is a list
"""
record = self.good_record()
# Create a fake record in mongo
id1 = self.images.insert(record.copy())
r... | code_fim | hard | {
"lang": "python",
"repo": "NERSC/shifter",
"path": "/imagegw/test/imagemngr_test.py",
"mode": "psm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_suffix|> record = self.good_record()
system = 'systemb'
record['system'] = system
# Create a fake record in mongo
id = self.images.insert(record)
self.assertIsNotNone(id)
# Create a bogus image file
file, metafile = self.create_fakeimage(system, recor... | code_fim | hard | {
"lang": "python",
"repo": "NERSC/shifter",
"path": "/imagegw/test/imagemngr_test.py",
"mode": "spm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NERSC/shifter path: /imagegw/test/imagemngr_test.py
set_mode(1)
def test_pull2(self):
"""
Test pulling two different images
"""
# Use defaults for format, arch, os, ostcount, replication
pr = self.pull
# Do the pull
session = self.mtm.... | code_fim | hard | {
"lang": "python",
"repo": "NERSC/shifter",
"path": "/imagegw/test/imagemngr_test.py",
"mode": "psm",
"license": "BSD-3-Clause-LBNL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nuprl/retic_performance path: /benchmarks/go/typed/square.py
import random
from constants import SIZE, GAMES, KOMI, EMPTY, WHITE, BLACK, SHOW, PASS, MAXMOVES, TIMESTAMP, MOVES
"""
bg: summary of changes from POPL'17 'go' to this 'go'
- add types to:
- `Square.__init__`
- `ZobristHash.__init_... | code_fim | hard | {
"lang": "python",
"repo": "nuprl/retic_performance",
"path": "/benchmarks/go/typed/square.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.board.zobrist.update(self, EMPTY)
self.removestamp = TIMESTAMP
if update:
self.color = EMPTY
self.board.emptyset.add(self.pos)
# if color == BLACK:
# self.board.black_dead += 1
# else:
# self.board.whi... | code_fim | hard | {
"lang": "python",
"repo": "nuprl/retic_performance",
"path": "/benchmarks/go/typed/square.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>eturn inputString[:i]
return inputString<|fim_prefix|># repo: RevansChen/online-judge path: /Codefights/arcade/intro/level-9/40.longestDigitsPrefix/Python/solution1.py
# Python3
def longestDigitsPrefix(inputStri<|fim_middle|>ng):
for i, e in enumerate(inputString):
if not e.isnumeric():
... | code_fim | medium | {
"lang": "python",
"repo": "RevansChen/online-judge",
"path": "/Codefights/arcade/intro/level-9/40.longestDigitsPrefix/Python/solution1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: RevansChen/online-judge path: /Codefights/arcade/intro/level-9/40.longestDigitsPrefix/Python/solution1.py
# Python3
def longestDigitsPrefix(inputStri<|fim_suffix|>
if not e.isnumeric():
return inputString[:i]
return inputString<|fim_middle|>ng):
for i, e in enumerate(... | code_fim | easy | {
"lang": "python",
"repo": "RevansChen/online-judge",
"path": "/Codefights/arcade/intro/level-9/40.longestDigitsPrefix/Python/solution1.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if not e.isnumeric():
return inputString[:i]
return inputString<|fim_prefix|># repo: RevansChen/online-judge path: /Codefights/arcade/intro/level-9/40.longestDigitsPrefix/Python/solution1.py
# Python3
def longestDigitsPrefix(inputStri<|fim_middle|>ng):
for i, e in enumerate(... | code_fim | easy | {
"lang": "python",
"repo": "RevansChen/online-judge",
"path": "/Codefights/arcade/intro/level-9/40.longestDigitsPrefix/Python/solution1.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: sqlalchemy/sqlalchemy path: /examples/asyncio/basic.py
"""Illustrates the asyncio engine / connection interface.
In this example, we have an async engine created by
:func:`_engine.create_async_engine`. We then use it using await
within a coroutine.
"""
import asyncio
from sqlalchemy import... | code_fim | medium | {
"lang": "python",
"repo": "sqlalchemy/sqlalchemy",
"path": "/examples/asyncio/basic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # for normal statement execution, a traditional "await execute()"
# pattern is used.
await conn.execute(
t1.insert(), [{"name": "some name 1"}, {"name": "some name 2"}]
)
async with engine.connect() as conn:
# the default result object is the
... | code_fim | hard | {
"lang": "python",
"repo": "sqlalchemy/sqlalchemy",
"path": "/examples/asyncio/basic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fe': ['banana', 'mulher', 'colher', {'alvo': [1, 2, 3, 'olázinho']}]}]}
print(d['k1'][3]['cafe'][3]['alvo'][3])<|fim_prefix|># repo: augustoscher/python-excercises path: /basics/excercises.py
lst = [1, 2, [3, 4], [5, [100, 200, ['olá']], 23, 11], <|fim_middle|>3, 7]
print(lst[3][1][2][0])
d = {'k1': [1,... | code_fim | easy | {
"lang": "python",
"repo": "augustoscher/python-excercises",
"path": "/basics/excercises.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: augustoscher/python-excercises path: /basics/excercises.py
lst = [1, 2, [3, 4], [5, [100, 200, ['olá']], 23, 11], 3, 7]
print(lst[3][1][2][0])
d = {'k1': [1, 2, 3, {'ca<|fim_suffix|>'olázinho']}]}]}
print(d['k1'][3]['cafe'][3]['alvo'][3])<|fim_middle|>fe': ['banana', 'mulher', 'colher', {'alvo':... | code_fim | easy | {
"lang": "python",
"repo": "augustoscher/python-excercises",
"path": "/basics/excercises.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: yangmuzhi/wuziqi path: /policy/rand_policy.py
"""
rand policy
"""
import random
class rand_agent:
def __init__(self, size):
self.reset(size)
def reset(self, size):
self.actions = set(list(range(size**2)))
<|fim_suffix|> self.actions.difference_update(set(for... | code_fim | easy | {
"lang": "python",
"repo": "yangmuzhi/wuziqi",
"path": "/policy/rand_policy.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.actions = set(list(range(size**2)))
def get_action(self, obs, forbidden_actions):
self.actions.difference_update(set(forbidden_actions))
return random.choice(list(self.actions))
def update(self, databatch):
pass<|fim_prefix|># repo: yangmuzhi/wuziqi path... | code_fim | easy | {
"lang": "python",
"repo": "yangmuzhi/wuziqi",
"path": "/policy/rand_policy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def reset(self, size):
self.actions = set(list(range(size**2)))
def get_action(self, obs, forbidden_actions):
self.actions.difference_update(set(forbidden_actions))
return random.choice(list(self.actions))
def update(self, databatch):
pass<|fim_prefix|># r... | code_fim | medium | {
"lang": "python",
"repo": "yangmuzhi/wuziqi",
"path": "/policy/rand_policy.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>A_sup = As(0.1) # Surface area with a especific diameter
Rnge_temp_K = np.arange(40+273.15,85+273.15,1) #[K] Careful the units must be in Kelvin for Q function
Q = Qemit(0.25,A_sup,Rnge_temp_K)
plt.figure(1)
plt.plot(np.arange(40,85,1),Q,'c')
plt.title("Power Dissipation\n$vs$\nTemperature Surface")
plt.x... | code_fim | hard | {
"lang": "python",
"repo": "Daz-Riza-Seriog/Transport_Phenomena",
"path": "/Heat_Transfer/1.4-Q_emit_for_sphere_in_Range_[Ts,æ].py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Daz-Riza-Seriog/Transport_Phenomena path: /Heat_Transfer/1.4-Q_emit_for_sphere_in_Range_[Ts,æ].py
# Code made for Sergio Andrés Díaz Ariza
# 06 March 2021
# License MIT
# Transport Phenomena: Python Program-Assignment 1.1
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
s... | code_fim | hard | {
"lang": "python",
"repo": "Daz-Riza-Seriog/Transport_Phenomena",
"path": "/Heat_Transfer/1.4-Q_emit_for_sphere_in_Range_[Ts,æ].py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tdgplatform/gbdxtools path: /examples/view_idaho_image.py
from gbdxtools import Interface
import json
<|fim_suffix|>idaho_images = gi.get_idaho_images_by_catid(catid)
description = gi.describe_idaho_images(idaho_images)
print json.dumps(description, indent=4, sort_keys=True)
gi.create_idaho_leaf... | code_fim | medium | {
"lang": "python",
"repo": "tdgplatform/gbdxtools",
"path": "/examples/view_idaho_image.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#catid = '101001000DB2FB00'
#catid = '1020010013C4CF00'
catid = '10400100120FEA00'
idaho_images = gi.get_idaho_images_by_catid(catid)
description = gi.describe_idaho_images(idaho_images)
print json.dumps(description, indent=4, sort_keys=True)
gi.create_idaho_leaflet_viewer(idaho_images, 'outputmap.html')... | code_fim | easy | {
"lang": "python",
"repo": "tdgplatform/gbdxtools",
"path": "/examples/view_idaho_image.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChaseKnowlden/healthchecks path: /hc/api/tests/test_notify_signal.py
# coding: utf-8
from datetime import timedelta as td
import json
from unittest.mock import patch
from django.utils.timezone import now
from django.test.utils import override_settings
from hc.api.models import Channel, Check, N... | code_fim | hard | {
"lang": "python",
"repo": "ChaseKnowlden/healthchecks",
"path": "/hc/api/tests/test_notify_signal.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> # "2862..." is sha1("+123456789test-secret")
obj = TokenBucket(value="signal-2862991ccaa15c8856e7ee0abaf3448fb3c292e0")
obj.tokens = 0
obj.save()
self.channel.notify(self.check)
n = Notification.objects.first()
self.assertEqual(n.error, "Rate limit ... | code_fim | hard | {
"lang": "python",
"repo": "ChaseKnowlden/healthchecks",
"path": "/hc/api/tests/test_notify_signal.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> @patch("hc.api.transports.dbus")
def test_it_requires_signal_cli_enabled(self, mock_bus):
with override_settings(SIGNAL_CLI_ENABLED=False):
self.channel.notify(self.check)
n = Notification.objects.get()
self.assertEqual(n.error, "Signal notifications are not en... | code_fim | hard | {
"lang": "python",
"repo": "ChaseKnowlden/healthchecks",
"path": "/hc/api/tests/test_notify_signal.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.