text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: samallenqing/Rental-House-Information-Query-System path: /FetchRawData.py
import re
f = open('test.txt','r').read().strip()
zipCode = re.fi<|fim_suffix|> s = line[0]+' '+line[1]
res.add(s)
fhand = open('California.txt','a')
for line in res:
fhand.write(line+'\n')
fhand.close()<|fim_middle... | code_fim | medium | {
"lang": "python",
"repo": "samallenqing/Rental-House-Information-Query-System",
"path": "/FetchRawData.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rapid7/insightconnect-plugins path: /plugins/gitlab/komand_gitlab/actions/list_ssh/action.py
import komand
from .schema import ListSshInput, ListSshOutput
# Custom imports below
import json
import requests
class ListSsh(komand.Action):
<|fim_suffix|> try:
r = requests.get(r_... | code_fim | hard | {
"lang": "python",
"repo": "rapid7/insightconnect-plugins",
"path": "/plugins/gitlab/komand_gitlab/actions/list_ssh/action.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> try:
r = requests.get(r_url, headers={"PRIVATE-TOKEN": self.connection.token}, verify=False) # noqa: B501
except requests.exceptions.RequestException as e: # This is the correct syntax
self.logger.error(e)
raise Exception(e)
if r.ok:
... | code_fim | hard | {
"lang": "python",
"repo": "rapid7/insightconnect-plugins",
"path": "/plugins/gitlab/komand_gitlab/actions/list_ssh/action.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return pointMap
def resize_crop(img, scale, size):
re_size = int(img.shape[0]*scale)
img = utils.imageResize(img, (re_size, re_size))
if size <= re_size:
pd = int((re_size-size)/2)
img = img[pd:pd+size,pd:pd+size]
else:
new = np.zeros((size,siz... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/LED2-Net",
"path": "/LED2Net/DuLaPost/tool.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: TrendingTechnology/LED2-Net path: /LED2Net/DuLaPost/tool.py
from __future__ import division
import sys
import os
import argparse
import numpy as np
import math
import objs
import utils
def json2scene(json):
scene = objs.Scene()
utils.loadLabelByJson(json, scene)
#scen... | code_fim | hard | {
"lang": "python",
"repo": "TrendingTechnology/LED2-Net",
"path": "/LED2Net/DuLaPost/tool.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
if len(sys.argv) != 3:
print(__doc__)
sys.exit()
host = sys.argv[2]
endpoint = f"tcp://{host}:5550"
push_msg(sys.argv[1], endpoint) # config file and ip
time.sleep(10)
push_msg("quit", endpoint)<|fim_prefix|># repo: tf-czu/kloubak path:... | code_fim | hard | {
"lang": "python",
"repo": "tf-czu/kloubak",
"path": "/app/run_jetson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def join(self, timeout=None):
push_msg('quit', self.endpoint)
self.input_thread.join(timeout=timeout)
def request_stop(self):
push_msg('quit', self.endpoint)
self.bus.shutdown()
if __name__ == "__main__":
if len(sys.argv) != 3:
print(__doc__)
... | code_fim | hard | {
"lang": "python",
"repo": "tf-czu/kloubak",
"path": "/app/run_jetson.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tf-czu/kloubak path: /app/run_jetson.py
"""
Usage:
python run_jetson.py <config> <ip>
"""
import contextlib
import zmq
import time
import osgar.lib.serialize
import sys
from threading import Thread
def push_msg(msg, endpoint):
context = zmq.Context.instance()
socket = contex... | code_fim | medium | {
"lang": "python",
"repo": "tf-czu/kloubak",
"path": "/app/run_jetson.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Sp3ctralM0nki3/FuzzingTool path: /src/fuzzingtool/core/Payloader.py
## FuzzingTool
#
# Authors:
# Vitor Oriel C N Borges <https://github.com/VitorOriel>
# License: MIT (LICENSE.md)
# Copyright (c) 2021 Vitor Oriel
# Permission is hereby granted, free of charge, to any person obtaining a... | code_fim | hard | {
"lang": "python",
"repo": "Sp3ctralM0nki3/FuzzingTool",
"path": "/src/fuzzingtool/core/Payloader.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @type payload: str
@param payload: The string payload gived by the payloads queue
@returns list: The payloads used in the request
"""
ajustedPayload = [payload]
if self._prefix:
ajustedPayload = [(prefix+payload) for prefix in self._prefix for pa... | code_fim | hard | {
"lang": "python",
"repo": "Sp3ctralM0nki3/FuzzingTool",
"path": "/src/fuzzingtool/core/Payloader.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tokuma09/algorithm_problems path: /problems/chapter04/Ysi/4-1.py
def tripnach(n):
if n == 1:
return 0
elif n == 2:
return 0
elif n == 3:
return 1
else:
return tripnach(n-1) + tripnach(n-2) + tripnach(n-3)
def main():
<|fim_suffix|> print(ans)
i... | code_fim | easy | {
"lang": "python",
"repo": "tokuma09/algorithm_problems",
"path": "/problems/chapter04/Ysi/4-1.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> n = int(input())
ans = tripnach(n)
print(ans)
if __name__=='__main__':
main()<|fim_prefix|># repo: tokuma09/algorithm_problems path: /problems/chapter04/Ysi/4-1.py
def tripnach(n):
if n == 1:
return 0
elif n == 2:
return 0
elif n == 3:
return 1
els... | code_fim | easy | {
"lang": "python",
"repo": "tokuma09/algorithm_problems",
"path": "/problems/chapter04/Ysi/4-1.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: codxse/mitx6001 path: /2016/PSET_3/ps3-3.py
def getAvailableLetters(lettersGuessed):
'''
lettersGuessed: list, what letters have been guessed so far
returns: string, comprised of letters that represents what letters have not
yet been guessed.
'''
lettersGuessedLower = []... | code_fim | hard | {
"lang": "python",
"repo": "codxse/mitx6001",
"path": "/2016/PSET_3/ps3-3.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # convert letterlist to string
# remove letterlist (pop)
letterList.reverse()
while len(letterList) > 0:
letterTrim += letterList.pop()
return letterTrim
else:
return letters<|fim_prefix|># repo: codxse/mitx6001 path: /2016/PSET_3/ps3-3.py
... | code_fim | medium | {
"lang": "python",
"repo": "codxse/mitx6001",
"path": "/2016/PSET_3/ps3-3.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: BarbaAlGhul/recommender-system-thesis path: /load_ratings.py
import pandas as pd
def load(path=''):
ratings = pd.read_csv(path+'ml-latest-small/ratings.csv')
# remove todos os NaNs
ratings.dropna(inplace=True)
<|fim_suffix|> # organiza as informações do arquivo
ratings.sort... | code_fim | hard | {
"lang": "python",
"repo": "BarbaAlGhul/recommender-system-thesis",
"path": "/load_ratings.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # organiza as informações do arquivo
ratings.sort_values(by='movieId', inplace=True)
ratings.reset_index(inplace=True, drop=True)
return ratings<|fim_prefix|># repo: BarbaAlGhul/recommender-system-thesis path: /load_ratings.py
import pandas as pd
def load(path=''):
ratings = pd.read... | code_fim | hard | {
"lang": "python",
"repo": "BarbaAlGhul/recommender-system-thesis",
"path": "/load_ratings.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: wwang107/master-thesis path: /src/test_cmu.py
from numpy.core.numeric import zeros_like
import torch
import pytorch_lightning as pl
from argparse import ArgumentParser
from pytorch_lightning.callbacks import ModelCheckpoint
from torch.utils.data import dataloader
from utils.load_model import load... | code_fim | hard | {
"lang": "python",
"repo": "wwang107/master-thesis",
"path": "/src/test_cmu.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Axs[0].imshow(cv2.resize(imgs[...,0].permute(1, 2, 0).numpy(), dsize=None, fx=1/2, fy=1/2))
# Axs[1].imshow(cv2.resize(imgs[...,1].permute(1, 2, 0).numpy(), dsize=None, fx=1/2, fy=1/2))
# Axs[2].imshow(cv2.resize(imgs[...,2].permute(1, 2, 0).numpy(), dsize=None, fx=1/... | code_fim | hard | {
"lang": "python",
"repo": "wwang107/master-thesis",
"path": "/src/test_cmu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Welcome to Python based hand cricket")
print("NOTE: Team names 'Computer' and 'CPU' are system reserved. \
Hence, they are not allowed.")
teamname = input("Team name: ")
reserved_names = ["CPU", "Computer", ""]
if teamname in reserved_names:
perror_sysreserved = input("S... | code_fim | hard | {
"lang": "python",
"repo": "Rohan-Great/Python-Hand-Cricket",
"path": "/src/setupateam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Rohan-Great/Python-Hand-Cricket path: /src/setupateam.py
import json
from modules import hashfunc
def team_setup():
""" Creates a new JSON file containing all the team details
Usage:
team_setup()
Arguments: None.
Returns:
A JSON file containing all the team details, s... | code_fim | hard | {
"lang": "python",
"repo": "Rohan-Great/Python-Hand-Cricket",
"path": "/src/setupateam.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
print("Welcome to Python based hand cricket")
print("NOTE: Team names 'Computer' and 'CPU' are system reserved. \
Hence, they are not allowed.")
teamname = input("Team name: ")
reserved_names = ["CPU", "Computer", ""]
if teamname in reserved_names:
perror_sysreserved =... | code_fim | hard | {
"lang": "python",
"repo": "Rohan-Great/Python-Hand-Cricket",
"path": "/src/setupateam.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jerrymakesjelly/autoremove-torrents path: /autoremovetorrents/condition/ratio.py
#-*- coding:utf-8 -*-
from .base import Comparer
from .base import Condition
from ..torrentstatus import TorrentStatus
<|fim_suffix|> for torrent in torrents:
if self.compare(torrent.ratio, self.... | code_fim | hard | {
"lang": "python",
"repo": "jerrymakesjelly/autoremove-torrents",
"path": "/autoremovetorrents/condition/ratio.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def apply(self, client_status, torrents):
for torrent in torrents:
if self.compare(torrent.ratio, self._ratio, self._comparer):
self.remove.add(torrent)
else:
self.remain.add(torrent)<|fim_prefix|># repo: jerrymakesjelly/autoremove-torren... | code_fim | medium | {
"lang": "python",
"repo": "jerrymakesjelly/autoremove-torrents",
"path": "/autoremovetorrents/condition/ratio.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def calcular_media_turma(alunos):
'''
Essa função retorna a média geral da turma
(soma de todas as notas dividida pela quantidade de todas as notas)
Entrada:
alunos: dicionario com os dados dos alunos
Retorno:
A função deve retornar a média da turma
'''
d... | code_fim | hard | {
"lang": "python",
"repo": "pedrobritoneto/pedro",
"path": "/AC01.PY",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>'''dic_alunos = {'Pedro': [10.0, 9.0], 'Rafael': [9.0, 9.0], 'Thyana': [8.0, 7.0]}
media = sum(dic_alunos['Pedro'])/len(dic_alunos['Pedro'])
print(dic_alunos['Pedro'])
print (media)'''
#Programa Principal
'''dic_notas = {}
for x in range(3):
nome = (input("Nome:"))
nota = float(input('... | code_fim | hard | {
"lang": "python",
"repo": "pedrobritoneto/pedro",
"path": "/AC01.PY",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pedrobritoneto/pedro path: /AC01.PY
# Atividade Contínua 01
# Aluno 01: Insira seu nome aqui
# Aluno 02: Insira seu nome aqui
def adicionar_aluno(alunos, nome, notas):
'''
Essa função acrescenta os dados de um novo aluno no dicionário
Entrada:
alunos: dicionario c... | code_fim | hard | {
"lang": "python",
"repo": "pedrobritoneto/pedro",
"path": "/AC01.PY",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Francisobiagwu/DocumentSharing path: /DSServer.py
changed_section = 0
section_id = section_id
reserved_1 = self.null_byte
reserved_2 = self.null_byte
reserved_3 = self.null_byte
... | code_fim | hard | {
"lang": "python",
"repo": "Francisobiagwu/DocumentSharing",
"path": "/DSServer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> freq_to_send = len(data_break_down)
count = 0
previous_data_sent_to_client = client_state.received_document
for new_item, old_item in zip(data_break_down, previous_data_sent_to_client.values()): # we need to make provision f... | code_fim | hard | {
"lang": "python",
"repo": "Francisobiagwu/DocumentSharing",
"path": "/DSServer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> reserved_1 = self.null_byte
reserved_2 = self.null_byte
reserved_3 = self.null_byte
section_id = (count - 1)
data = data # verify if the data is already encoded
data_size = len(data)
... | code_fim | hard | {
"lang": "python",
"repo": "Francisobiagwu/DocumentSharing",
"path": "/DSServer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # We start with tcpclientsrc, and immediately demux it into audio and video.
pipeline_string = 'tcpclientsrc name=tcpclientsrc ! %s name=demux ' % demux_element
if self.has_video():
# We need to decode the video:
pipeline_string += (' queue2 max-size-time=3... | code_fim | hard | {
"lang": "python",
"repo": "bitwave-tv/brave",
"path": "/brave/inputs/tcp_client.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def _on_decodebin_pad_added(self, _, pad):
'''
Like demux, decodebin creates new pads every time the stream starts.
This handles the creation of a new pad by linking it to the relevant element.
The pipeline is:
- For video: decodebin --> video_output_queue --> t... | code_fim | hard | {
"lang": "python",
"repo": "bitwave-tv/brave",
"path": "/brave/inputs/tcp_client.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bitwave-tv/brave path: /brave/inputs/tcp_client.py
from brave.inputs.input import Input
from gi.repository import Gst
import brave.config as config
import brave.exceptions
class TcpClientInput(Input):
'''
Allows an an input by receiving from another server via TCP.
Basically using t... | code_fim | hard | {
"lang": "python",
"repo": "bitwave-tv/brave",
"path": "/brave/inputs/tcp_client.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> raise NotImplementedError
def get_buckingham_potential_section_as_string(potential):
raise NotImplementedError
class GulpInputFile(object):
def __init__(self):
self.potential = None
self.potential<|fim_prefix|># repo: eragasa/pypospack path: /pypospack/io/gulp.py
from pypos... | code_fim | medium | {
"lang": "python",
"repo": "eragasa/pypospack",
"path": "/pypospack/io/gulp.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eragasa/pypospack path: /pypospack/io/gulp.py
from pypospack.task import Task
import pypospack.crystal as crystal
import pypospack.io.vasp as vasp
def poscar_to_gulp_string(poscar):
if isinstance(poscar,crystal.SimulationCell):
return simulation_cell_to_gulp_string(poscar)
elif i... | code_fim | hard | {
"lang": "python",
"repo": "eragasa/pypospack",
"path": "/pypospack/io/gulp.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ast_utils.convert_ast_to_code(self.tree)
def parse(self):
# ast_utils.parse_print(self.tree)
meta = {}
if self.tree:
self.visit(self.tree, meta)
@staticmethod
def get_base_caller(node):
if isinstance(node, ast.Name):
return node.id
elif hasattr(node, "val... | code_fim | hard | {
"lang": "python",
"repo": "Eduardo95/COSAL",
"path": "/code/src/main/python/analysis/parsers/ssfix_tokenizer.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Eduardo95/COSAL path: /code/src/main/python/analysis/parsers/ssfix_tokenizer.py
import sys
import os
sys.path.append(os.path.abspath("."))
sys.dont_write_bytecode = True
__author__ = "COSAL"
from analysis.blocks import block_utils
from analysis.helpers import constants as a_consts
from analys... | code_fim | hard | {
"lang": "python",
"repo": "Eduardo95/COSAL",
"path": "/code/src/main/python/analysis/parsers/ssfix_tokenizer.py",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_hash_key(function_body):
return hash(function_body.strip())
def index_tokens():
_STORE = get_token_store()
tokens = _STORE.get_tokens()
els = get_elastic_store()
els.create_index(delete_old=True)
els.index_documents(tokens)
def tokenize_function(gen_func_meta, token_size):
token... | code_fim | hard | {
"lang": "python",
"repo": "Eduardo95/COSAL",
"path": "/code/src/main/python/analysis/parsers/ssfix_tokenizer.py",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: innersourcedo/intergrow path: /src/inner_source/TeamWork/serializers/goalProgressSerializer.py
from rest_framework import serializers
from TeamWork.models import GoalProgress
class GoalProgressSerializer(serializers.ModelSerializer):
<|fim_suffix|> model = GoalProgress
fields = [... | code_fim | easy | {
"lang": "python",
"repo": "innersourcedo/intergrow",
"path": "/src/inner_source/TeamWork/serializers/goalProgressSerializer.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = GoalProgress
fields = ['goal', 'progress_description', 'progress_date']<|fim_prefix|># repo: innersourcedo/intergrow path: /src/inner_source/TeamWork/serializers/goalProgressSerializer.py
from rest_framework import serializers
from TeamWork.models import GoalProgress
<|fim_middle... | code_fim | medium | {
"lang": "python",
"repo": "innersourcedo/intergrow",
"path": "/src/inner_source/TeamWork/serializers/goalProgressSerializer.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def test_io_pickle_restore():
"""Ensures that object can be restored."""
container = IO(2)
container.__setstate__({'container_value': 1}) # noqa: WPS609, E501
assert container == IO(1)<|fim_prefix|># repo: dry-python/returns path: /tests/test_io/test_io_container/test_io_pickle.py
from r... | code_fim | medium | {
"lang": "python",
"repo": "dry-python/returns",
"path": "/tests/test_io/test_io_container/test_io_pickle.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dry-python/returns path: /tests/test_io/test_io_container/test_io_pickle.py
from returns.io import IO
def test_io_pickle():
<|fim_suffix|> """Ensures that object can be restored."""
container = IO(2)
container.__setstate__({'container_value': 1}) # noqa: WPS609, E501
assert cont... | code_fim | medium | {
"lang": "python",
"repo": "dry-python/returns",
"path": "/tests/test_io/test_io_container/test_io_pickle.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> n_ed = 5000.0
m_ed = 25.0
as_1 = 15.58093 * 10 ** -4
as_2 = 17.00950 * 10 ** -4
n_rd, m_rd = compression_diagnostic.main(h, b, a1, a2, m_ed, n_ed, as_1, as_2, eta_bet, lambda_bet, f_cd, f_ck)
self.assertAlmostEqual(n_rd, n_ed, 0)
self.assertAlmostE... | code_fim | hard | {
"lang": "python",
"repo": "skypaw/zelbet",
"path": "/tests/test_compression_diagnostic.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: skypaw/zelbet path: /tests/test_compression_diagnostic.py
import unittest
from uls import compression_diagnostic
h = 0.6
b = 0.3
a1 = a2 = 0.05
eta_bet = 1.0
lambda_bet = 0.8
f_cd = 21.43
f_ck = 50
class TestAsymmetric(unittest.TestCase):
def test_5_10(self):
"""
Test... | code_fim | hard | {
"lang": "python",
"repo": "skypaw/zelbet",
"path": "/tests/test_compression_diagnostic.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_alert(self):
""" Retrieve alert """
id = ""
d = {}
country=self.country.upper()
province=self.province
language=self.language
#language+= '*'
try:
file = urlopen('http://meteoalarm.eu/ATOM/'+ country +'.xml')
... | code_fim | hard | {
"lang": "python",
"repo": "roaldnefs/meteoalert-api",
"path": "/meteoalertapi/meteoalertapi.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if "info" in data2['alert']:
for i in data2['alert']['info']:
if language in i['language']:
for x in i:
if... | code_fim | hard | {
"lang": "python",
"repo": "roaldnefs/meteoalert-api",
"path": "/meteoalertapi/meteoalertapi.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: roaldnefs/meteoalert-api path: /meteoalertapi/meteoalertapi.py
import sys
import xmltodict
try:
# For Python 3.0 and later
from urllib.request import urlopen
except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import urlopen
class WrongCountry(Exception):
pass... | code_fim | hard | {
"lang": "python",
"repo": "roaldnefs/meteoalert-api",
"path": "/meteoalertapi/meteoalertapi.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> actual = utilities.match_level_1(
level_2=xr.load_dataset(goes_level_2["level_2"]),
level_1_directory=goes_level_2["level_1_directory"],
)
assert isinstance(actual, goes_level_1.GoesScan)
assert actual == goes_level_1.read_netcdfs(goes_level_2["level_1"])<|fim_prefix|># rep... | code_fim | easy | {
"lang": "python",
"repo": "joyprojects/wildfire",
"path": "/tests/unit/data/goes_level_2/test_utilities.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: joyprojects/wildfire path: /tests/unit/data/goes_level_2/test_utilities.py
import xarray as xr
from wildfire.data import goes_level_1
from wildfire.data.goes_level_2 import utilities
<|fim_suffix|> actual = utilities.match_level_1(
level_2=xr.load_dataset(goes_level_2["level_2"]),
... | code_fim | easy | {
"lang": "python",
"repo": "joyprojects/wildfire",
"path": "/tests/unit/data/goes_level_2/test_utilities.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>new_coord_tel = telescope.getCoordinates()
print(f"get again coordinates form telescope: {coord_to_str(new_coord_tel)}")
sep = coords_telescope.separation(new_coord_tel)
print(f"separate : {sep}, or {sep.arcminute} arcmin {sep.arcsecond} arcsecond")
exit()
for i in range(5):
oldCoords = coords
... | code_fim | hard | {
"lang": "python",
"repo": "tlemoult/spectroDb",
"path": "/telescope/indi/simpleTelescopeDebug.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># setup log file
logging.basicConfig(filename=config["path"]["root"] + config["path"]["log"]+'/'+config['logFile'],level=logging.DEBUG,format='%(asctime)s %(message)s')
# create Telescope Client
telescope=Telescope(config['telescope'])
if not telescope.connect():
exit(1)
print("Telescope connected")... | code_fim | hard | {
"lang": "python",
"repo": "tlemoult/spectroDb",
"path": "/telescope/indi/simpleTelescopeDebug.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tlemoult/spectroDb path: /telescope/indi/simpleTelescopeDebug.py
import sys,time, logging,json,os
import PyIndi
from libindi.telescope import TelescopeClient as Telescope
import libcalc.util as myUtil
from astropy import units as u
from astropy.coordinates import SkyCoord,FK5,ICRS,AltAz,EarthLo... | code_fim | hard | {
"lang": "python",
"repo": "tlemoult/spectroDb",
"path": "/telescope/indi/simpleTelescopeDebug.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def reset(self):
for s in self.searches:
s.reset()
self.items = [s.next() for s in self.searches]
self.idx = 0
def next(self):
if not self.items:
raise StopIteration
items = self.items[:]
searches = self.searches
whil... | code_fim | hard | {
"lang": "python",
"repo": "punkdit/pyfinder",
"path": "/pyfinder/search.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: punkdit/pyfinder path: /pyfinder/search.py
#!/usr/bin/env python
from itertools import product
def crossiter(sets, verbose=False):
for item in product(*sets):
yield item
def search(keys, n=5):
if len(keys)==1:
for i in range(n):
yield (i,)
else:
... | code_fim | hard | {
"lang": "python",
"repo": "punkdit/pyfinder",
"path": "/pyfinder/search.py",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for s in self.searches:
s.reset()
self.items = [s.next() for s in self.searches]
self.idx = 0
def next(self):
if not self.items:
raise StopIteration
items = self.items[:]
searches = self.searches
while self.idx < len(sear... | code_fim | hard | {
"lang": "python",
"repo": "punkdit/pyfinder",
"path": "/pyfinder/search.py",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: PirateRoberts98/capstone-hygeine-managment path: /hardware/src/temp_humidity_sensor.py
import RPi.GPIO as GPIO
import time
class TempAndHumiditySensor:
GPIO_PIN = 17
humidityVal = 0
tempVal = 0
dht_pulses = 41
dht_max = 32000
def __init__(self,temp_api_info,hum_api_info... | code_fim | hard | {
"lang": "python",
"repo": "PirateRoberts98/capstone-hygeine-managment",
"path": "/hardware/src/temp_humidity_sensor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sensor = TempAndHumiditySensor(None,None)
try:
while True:
time.sleep(3)
status = sensor.read_from_sensor()
if(status == 1):
print(sensor.humidityVal)
print(sensor.tempVal)
else:
pass
except... | code_fim | hard | {
"lang": "python",
"repo": "PirateRoberts98/capstone-hygeine-managment",
"path": "/hardware/src/temp_humidity_sensor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> GPIO.setup(TempAndHumiditySensor.GPIO_PIN, GPIO.OUT)
GPIO.output(TempAndHumiditySensor.GPIO_PIN, GPIO.HIGH)
time.sleep(0.5)
GPIO.output(TempAndHumiditySensor.GPIO_PIN, GPIO.LOW)
time.sleep(0.02)
GPIO.setup(TempAndHumiditySensor.GPIO_PIN, GPIO.IN)
... | code_fim | hard | {
"lang": "python",
"repo": "PirateRoberts98/capstone-hygeine-managment",
"path": "/hardware/src/temp_humidity_sensor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def get_muni_specifics(cls, api_data):
GAPD_categories = {
"Budget & Treasury Office",
"Executive & Council",
"Planning and Development",
"Corporate Services",
}
GAPD_label = "Governance, Administration, Planning ... | code_fim | hard | {
"lang": "python",
"repo": "OpenUpSA/municipal-data",
"path": "/scorecard/profile_data/indicators/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @classmethod
def get_muni_specifics(cls, api_data):
v1_results = group_by(api_data.results["expenditure_breakdown_v1"], year_key)
v2_results = group_by(api_data.results["expenditure_breakdown_v2"], year_key)
values = []
for year in api_data.years:
try:... | code_fim | hard | {
"lang": "python",
"repo": "OpenUpSA/municipal-data",
"path": "/scorecard/profile_data/indicators/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OpenUpSA/municipal-data path: /scorecard/profile_data/indicators/__init__.py
from .utils import *
from .indicator_calculator import IndicatorCalculator
from .current_ratio import CurrentRatio
from .liquidity_ratio import LiquidityRatio
from .current_debtors_collection_rate import CurrentDebtorsCo... | code_fim | hard | {
"lang": "python",
"repo": "OpenUpSA/municipal-data",
"path": "/scorecard/profile_data/indicators/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def colmap_vocab_tree_pipeline_command_line():
"""
Parse the command line arguments to build a map and localize images using colmap on the given kapture data.
"""
parser = argparse.ArgumentParser(description='localize images given in kapture format on a colmap map')
parser_verbosity = ... | code_fim | hard | {
"lang": "python",
"repo": "ssssjiang/kapture-localization",
"path": "/pipeline/kapture_pipeline_colmap_vocab_tree.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ssssjiang/kapture-localization path: /pipeline/kapture_pipeline_colmap_vocab_tree.py
#!/usr/bin/env python3
# Copyright 2020-present NAVER Corp. Under BSD 3-clause license
"""
This script builds a COLMAP model (map) from kapture format (images, cameras, trajectories) with colmap sift+vocab tree
... | code_fim | hard | {
"lang": "python",
"repo": "ssssjiang/kapture-localization",
"path": "/pipeline/kapture_pipeline_colmap_vocab_tree.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benjisympa/HierarchicalRNN path: /model.py
ture.shape)
#torch.Size([1, 32, 300]) torch.Size([1, 32, 300]) torch.Size([1, 32, 300]) torch.Size([1, 32, 300]) torch.Size([4, 32, 300]) torch.Size([4, 32, 300])
seq_tensor_output_sum = torch.cat((torch.unsqueeze(seq_tensor_outp... | code_fim | hard | {
"lang": "python",
"repo": "benjisympa/HierarchicalRNN",
"path": "/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: benjisympa/HierarchicalRNN path: /model.py
(handle)'''
#model = torch.nn.DataParallel(model, dim=dim)#, device_ids=[0, 1, 2])
#pos_weight = torch.FloatTensor(len(negatives)/len(positives))
#pos_weight = pos_weight.to(device)
criterion = nn.BCELoss()#nn.BCEWithLogitsLoss(pos_weigh... | code_fim | hard | {
"lang": "python",
"repo": "benjisympa/HierarchicalRNN",
"path": "/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def launch_train(config, model, path_model, path_data_train, path_data_dev, nb_epoch=5, device='cpu', type_sentence_embedding='lstm', restart_at_epoch=0):
#https://gist.github.com/Tushar-N/dfca335e370a2bc3bc79876e6270099e
check_dev_epoch = 1
writer = SummaryWriter(comment='1 couche')
'''w... | code_fim | hard | {
"lang": "python",
"repo": "benjisympa/HierarchicalRNN",
"path": "/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FraunhoferIWES/foxes path: /foxes/opt/objectives/farm_vars.py
import numpy as np
import xarray as xr
from foxes.opt.core.farm_objective import FarmObjective
from foxes import variables as FV
import foxes.constants as FC
class FarmVarObjective(FarmObjective):
"""
Objectives based on far... | code_fim | hard | {
"lang": "python",
"repo": "FraunhoferIWES/foxes",
"path": "/foxes/opt/objectives/farm_vars.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, problem, name="maximize_power", **kwargs):
if "scale" in kwargs:
scale = kwargs.pop("scale")
else:
scale = 0.0
ttypes = problem.algo.mbook.turbine_types
for t in problem.farm.turbines:
for mname in t.mod... | code_fim | hard | {
"lang": "python",
"repo": "FraunhoferIWES/foxes",
"path": "/foxes/opt/objectives/farm_vars.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
return (
super().finalize_individual(
vars_int, vars_float, problem_results, verbosity
)
* self.scale
)
class MaxFarmPower(FarmVarObjective):
"""
Maximize the mean wind farm power
Parameters
----------
p... | code_fim | hard | {
"lang": "python",
"repo": "FraunhoferIWES/foxes",
"path": "/foxes/opt/objectives/farm_vars.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>c_dict = Counter(c_list)
pair_num = 0
for key in c_dict:
pair_num += c_dict[key] / 2
print pair_num<|fim_prefix|># repo: baby5/HackerRank path: /Algorithms/Implementation/SockMerchant.py
#coding:utf-8
from collections import Counter
n = int(raw_input())
<|fim_middle|>c_list = map(int, raw_input(... | code_fim | easy | {
"lang": "python",
"repo": "baby5/HackerRank",
"path": "/Algorithms/Implementation/SockMerchant.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: baby5/HackerRank path: /Algorithms/Implementation/SockMerchant.py
#coding:utf-8
from collections import Counter
<|fim_suffix|>c_dict = Counter(c_list)
pair_num = 0
for key in c_dict:
pair_num += c_dict[key] / 2
print pair_num<|fim_middle|>n = int(raw_input())
c_list = map(int, raw_input(... | code_fim | medium | {
"lang": "python",
"repo": "baby5/HackerRank",
"path": "/Algorithms/Implementation/SockMerchant.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># %%
_, ax = plt.subplots()
ax.hist(raccoon_face.ravel(), bins=256)
color = "tab:orange"
for center in bin_center:
ax.axvline(center, color=color)
ax.text(center - 10, ax.get_ybound()[1] + 100, f"{center:.1f}", color=color)
# %%
# As previously stated, the uniform sampling strategy is not optimal... | code_fim | hard | {
"lang": "python",
"repo": "scikit-learn/scikit-learn",
"path": "/examples/cluster/plot_face_compress.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># %%
# It is quite surprising to see that our compressed image is taking x8 more
# memory than the original image. This is indeed the opposite of what we
# expected. The reason is mainly due to the type of data used to encode the
# image.
print(f"Type of the compressed image: {compressed_raccoon_kmeans.d... | code_fim | hard | {
"lang": "python",
"repo": "scikit-learn/scikit-learn",
"path": "/examples/cluster/plot_face_compress.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scikit-learn/scikit-learn path: /examples/cluster/plot_face_compress.py
"""
===========================
Vector Quantization Example
===========================
This example shows how one can use :class:`~sklearn.preprocessing.KBinsDiscretizer`
to perform vector quantization on a set of toy image... | code_fim | hard | {
"lang": "python",
"repo": "scikit-learn/scikit-learn",
"path": "/examples/cluster/plot_face_compress.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|># Sample
post_dist = pybitup.solve_problem.Sampling(input_file_name)
post_dist.sample(my_spring_model)
post_dist.__del__()
# Post process
pybitup.post_process.post_process_data(input_file_name)<|fim_prefix|># repo: jcoheur/pybitup-examples path: /spring_model/run.py
import spring_model
import pybitup... | code_fim | medium | {
"lang": "python",
"repo": "jcoheur/pybitup-examples",
"path": "/spring_model/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jcoheur/pybitup-examples path: /spring_model/run.py
import spring_model
import pybitup
case_name = "spring_model"
#case_name = "spring_model_1param" # Uncomment this line to run the case with only one parameter
input_file_name = "{}.json".format(case_name)
# Define the model
my_spring_model... | code_fim | medium | {
"lang": "python",
"repo": "jcoheur/pybitup-examples",
"path": "/spring_model/run.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Post process
pybitup.post_process.post_process_data(input_file_name)<|fim_prefix|># repo: jcoheur/pybitup-examples path: /spring_model/run.py
import spring_model
import pybitup
case_name = "spring_model"
#case_name = "spring_model_1param" # Uncomment this line to run the case with only one parameter... | code_fim | hard | {
"lang": "python",
"repo": "jcoheur/pybitup-examples",
"path": "/spring_model/run.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> await asyncio.wait_for(consume(), 5)
assert messages == [
[b"message", b"channel1", b"message1"],
[b"pmessage", b"channel*", b"channel1", b"message1"],
[b"pmessage", b"channel*", b"channel*", b"message2"],
]
async def test_subscribe_and_... | code_fim | hard | {
"lang": "python",
"repo": "levsh/siderpy",
"path": "/tests/tests_medium.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: levsh/siderpy path: /tests/tests_medium.py
import asyncio
import os
import ssl
import pytest
import pytest_asyncio
import siderpy
siderpy.logger.setLevel("DEBUG")
REDIS_HOST = os.environ.get("REDIS_HOST", "redis")
REDIS_PORT = os.environ.get("REDIS_PORT", "6379")
TESTS_USE_SSL = os.environ.ge... | code_fim | hard | {
"lang": "python",
"repo": "levsh/siderpy",
"path": "/tests/tests_medium.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lemariva/N-Queens-Problem path: /queenpool_multithread.py
import sys
from multiprocessing import Pool as ThreadPool
from datetime import datetime
try:
from temperature import tempControl
temp = True
except:
temp = False
from tqdm import tqdm
_num_queens = 12 # default number ... | code_fim | hard | {
"lang": "python",
"repo": "lemariva/N-Queens-Problem",
"path": "/queenpool_multithread.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> start = 0 if (col > 0) else int(thr_index * (self._nq / self._nthreads))
end = self._nq - 1 if ((col > 0) or (thr_index == self._nthreads - 1)) else int((thr_index + 1) * (self._nq / self._nthreads) - 1)
if (col == self._nq): # tried N queens permutations... | code_fim | hard | {
"lang": "python",
"repo": "lemariva/N-Queens-Problem",
"path": "/queenpool_multithread.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if inserted:
print("value %s inserted after value %s" % (data_to_insert, data_after))
else:
print("value not found")
def remove_by_value(self, data):
found = False
if self.head.data == data:
self.head = self.head.next
fo... | code_fim | hard | {
"lang": "python",
"repo": "dushyantbhatt2007/data-structure-and-algo",
"path": "/DS/01_LinkedList/linked_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dushyantbhatt2007/data-structure-and-algo path: /DS/01_LinkedList/linked_list.py
class Node:
def __init__(self, data=None, next=None):
self.data = data
self.next = next
class LinkedList:
def __init__(self):
self.head = None
def insert_at_begining(self, data)... | code_fim | hard | {
"lang": "python",
"repo": "dushyantbhatt2007/data-structure-and-algo",
"path": "/DS/01_LinkedList/linked_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Nedgang/adt_project path: /stop_word.py
#!/usr/bin/env python3
# -*- coding: utf8 -*-
class StopWord:
def __init__(self, french, english):
self.__stopword = dict()
if not french and not english:
from nltk.corpus import stopwords
self.__stopword["eng... | code_fim | hard | {
"lang": "python",
"repo": "Nedgang/adt_project",
"path": "/stop_word.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
word_filter = set()
with open(filename, "r") as filtr_list:
for word in filtr_list:
word_filter.add(word.strip())
return word_filter
def get_stopword(self):
return self.__stopword
def get_ponctuation(self):
return ... | code_fim | hard | {
"lang": "python",
"repo": "Nedgang/adt_project",
"path": "/stop_word.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: martyzz1/heroku3.py path: /heroku3/models/sni_endpoint.py
# Project libraries
from . import BaseResource
from .ssl_cert import SSLCert
class SNIEndpoint(BaseResource):
<|fim_suffix|> return "<SSL Endpoint '{0}'>".format(self.name)<|fim_middle|> """SSL Endpoint."""
_strs = ["certi... | code_fim | hard | {
"lang": "python",
"repo": "martyzz1/heroku3.py",
"path": "/heroku3/models/sni_endpoint.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _strs = ["certificate_chain", "cname", "display_name", "id", "name"]
_dates = ["created_at", "updated_at"]
_map = {"ssl_cert": SSLCert}
_pks = ["id"]
order_by = "id"
def __init__(self):
self.app = None
super(SNIEndpoint, self).__init__()
def __repr__(self):
... | code_fim | easy | {
"lang": "python",
"repo": "martyzz1/heroku3.py",
"path": "/heroku3/models/sni_endpoint.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>//trade.pics-twosigma.com/api/strategies/8a61c73a-5ff7-40ba-9777-8517264a029c/positions?instrumentId=BBG000BVPV84&beginDate=2017-11-01&endDate=2017-12-01"
# -H "Authorization: Bearer 4e6264031dbf4a51864a797b9b7c67e"
headers = {
'Authorization': 'Bearer 4e6264031dbf4a51864a797b9b7c67e',
}
params = (
... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/TradingEvolved",
"path": "/examples/old/live_trade.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: webclinic017/TradingEvolved path: /examples/old/live_trade.py
import requests
# Making Requests
# curl "https://trade.pics-twosigma.com/api" -H "Authorization: Bearer 4e6264031dbf4a51864a797b9b7c67ea"
headers = {
'Authorization': 'Bearer 4e6264031dbf4a51864a797b9b7c67ea',
}
url = 'https://tra... | code_fim | hard | {
"lang": "python",
"repo": "webclinic017/TradingEvolved",
"path": "/examples/old/live_trade.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: giulio93/anticipating-activities path: /Breakfast/Epic-paradigma II/main_s.py
#!/usr/bin/python2.7
import tensorflow as tf
import numpy as np
import argparse
import math
from models.cnn import ModelCNN
from models.rnn import ModelRNN
from utils.base_batch_gen import Base_batch_generator
from uti... | code_fim | hard | {
"lang": "python",
"repo": "giulio93/anticipating-activities",
"path": "/Breakfast/Epic-paradigma II/main_s.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> max_sq_len = 0
if args.input_type == "gt":
start_To=0
file_ptr = open(vid, 'r')
content = file_ptr.read().split()[:-1]
vid_len = len(content)
T = (1.0/args.alpha)*vid_len
i... | code_fim | hard | {
"lang": "python",
"repo": "giulio93/anticipating-activities",
"path": "/Breakfast/Epic-paradigma II/main_s.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if args.input_type == "gt":
start_To=0
file_ptr = open(vid, 'r')
content = file_ptr.read().split()[:-1]
vid_len = len(content)
T = (1.0/args.alpha)*vid_len
if args.input_type == "decode... | code_fim | hard | {
"lang": "python",
"repo": "giulio93/anticipating-activities",
"path": "/Breakfast/Epic-paradigma II/main_s.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """
The source of the types (little pre-processing step):
https://github.com/filipekiss/pokemon-type-chart/blob/master/types.json
:return:
"""
file: str = "types.json"
json_obj = load_json(file)
new_json_obj = {}
for type_obj in json_obj:
new_json_obj[type_obj['... | code_fim | medium | {
"lang": "python",
"repo": "alexemm/pokemon-type-coverage",
"path": "/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def read_file(file: str) -> List[str]:
text: List[str] = []
with open(file) as f:
text = f.read().splitlines()
return text<|fim_prefix|># repo: alexemm/pokemon-type-coverage path: /utils.py
from typing import Optional, List
import json
def load_json(file) -> Optional[any]:
json... | code_fim | hard | {
"lang": "python",
"repo": "alexemm/pokemon-type-coverage",
"path": "/utils.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: alexemm/pokemon-type-coverage path: /utils.py
from typing import Optional, List
import json
def load_json(file) -> Optional[any]:
json_obj = None
with open(file) as f:
json_obj = json.load(f)
return json_obj
<|fim_suffix|>
def create_json_of_types():
"""
The sourc... | code_fim | medium | {
"lang": "python",
"repo": "alexemm/pokemon-type-coverage",
"path": "/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CODARcode/cheetah path: /codar/savanna/pipeline.py
s that share nodes may add the same node to the
# Queue multiple times. We need a SetQueue for this, or a way to
# have all Runs in a shared node release nodes just once.
self._nodes_assigned = Queue()
@classmethod
... | code_fim | hard | {
"lang": "python",
"repo": "CODARcode/cheetah",
"path": "/codar/savanna/pipeline.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CODARcode/cheetah path: /codar/savanna/pipeline.py
fatal_callbacks = set()
self.total_procs = 0
self.log_prefix = self.id
self._start_time = None
self._walltime_path = self.working_dir+"/codar.savanna.total.walltime"
for run in runs:
self.total... | code_fim | hard | {
"lang": "python",
"repo": "CODARcode/cheetah",
"path": "/codar/savanna/pipeline.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Get num nodes required to run this layout
for l in codes_on_node:
if len(l) == 0:
continue
num_nodes_reqd_for_layout = max([code.nodes for code in l])
# Ensure required nodes are available
num_nodes_in_queue = len(list(sel... | code_fim | hard | {
"lang": "python",
"repo": "CODARcode/cheetah",
"path": "/codar/savanna/pipeline.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.session.add(
Setting(name="about_page_content", value="example content value")
)
self.session.add(
Setting(
name="welcome_page_content", value="example welcome content <br>here"
)
)
self.session.add(Setting(na... | code_fim | medium | {
"lang": "python",
"repo": "scoringengine/scoringengine",
"path": "/tests/scoring_engine/unit_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: scoringengine/scoringengine path: /tests/scoring_engine/unit_test.py
from scoring_engine.db import session, delete_db, init_db
from scoring_engine.models.setting import Setting
class UnitTest(object):
def setup(self):
<|fim_suffix|> def teardown(self):
delete_db(self.session)
... | code_fim | medium | {
"lang": "python",
"repo": "scoringengine/scoringengine",
"path": "/tests/scoring_engine/unit_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Component(pulumi.ComponentResource):
echo: pulumi.Output[Any]
childId: pulumi.Output[str]
def __init__(self, name: str, echo: pulumi.Input[Any], opts: Optional[pulumi.ResourceOptions] = None):
props = dict()
props["echo"] = echo
props["childId"] = None
pr... | code_fim | medium | {
"lang": "python",
"repo": "pulumi/pulumi",
"path": "/tests/integration/construct_component/python/component.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.