text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|># repo: aimdarx/data-structures-and-algorithms path: /solutions/Trees and Graphs/Binary Trees/binary_tree_paths.py
"""
Binary Tree Paths
Given the root of a binary tree, return all root-to-leaf paths in any order.
https://leetcode.com/problems/binary-tree-paths
"""
# Definition for a binary tree node.... | code_fim | hard | {
"lang": "python",
"repo": "aimdarx/data-structures-and-algorithms",
"path": "/solutions/Trees and Graphs/Binary Trees/binary_tree_paths.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: KentaroKutsukake/Integrating-multiple-materials-science-projects path: /codes/MIGraph/Train/GraphNNPredictor.py
"""
this class consists of GGNN and dense layers to predict specific parameters
original script was obtained from cheiner-chemistry library (MIT lisence).
some codes were changed
#TODO... | code_fim | hard | {
"lang": "python",
"repo": "KentaroKutsukake/Integrating-multiple-materials-science-projects",
"path": "/codes/MIGraph/Train/GraphNNPredictor.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return ret
#utility funcs
def myConcat(trBatch,padding=0):
return chainer.dataset.concat_examples(trBatch,padding=0,device = gpu_device)
#node type info is removed for learning
def formatDataset(dset):
propList,adjList,targetList,nodeTypeList=zip(*dset)
return datasets.Tuple... | code_fim | hard | {
"lang": "python",
"repo": "KentaroKutsukake/Integrating-multiple-materials-science-projects",
"path": "/codes/MIGraph/Train/GraphNNPredictor.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> db_id = await cls._DATABASE.upsert(inst)
if _id:
assert _id == db_id, 'Database _id did not match given _id'
cls._fields['_id'].__set__(inst, db_id, override=True)
return inst
@classmethod
def from_document(cls, document):
return cls(**docume... | code_fim | hard | {
"lang": "python",
"repo": "chrisseto/Still",
"path": "/wdim/orm/storable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def __init__(self, **kwargs):
assert set(kwargs.keys()).issubset(self._fields.keys()), 'Specified a key that is not in fields'
self._data = {
key: value.parse(kwargs.get(key))
for key, value in self._fields.items()
}
def to_document(self, translato... | code_fim | hard | {
"lang": "python",
"repo": "chrisseto/Still",
"path": "/wdim/orm/storable.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: chrisseto/Still path: /wdim/orm/storable.py
import abc
from wdim.util import pack
from wdim.orm import fields
from wdim.orm import exceptions
class StorableMeta(abc.ABCMeta):
STORABLE_CLASSES = {}
def __init__(cls, name, bases, dct):
super().__init__(name, bases, dct)
... | code_fim | hard | {
"lang": "python",
"repo": "chrisseto/Still",
"path": "/wdim/orm/storable.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: FlMondon/sncosmo path: /docs/_examples/plot_custom_source.py
"""
===========================
Creating a new Source class
===========================
Extending sncosmo with a custom type of Source.
A ``Source`` is something that specifies a spectral timeseries as
a function of an arbitrary numbe... | code_fim | hard | {
"lang": "python",
"repo": "FlMondon/sncosmo",
"path": "/docs/_examples/plot_custom_source.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>wave = np.linspace(2000.0, 10000.0, 500)
for w in (0.0, 0.2, 0.4, 0.6, 0.8, 1.0):
source.set(w=w)
plt.plot(wave, source.flux(10., wave), label='w={:3.1f}'.format(w))
plt.legend()
plt.show()
##########################################################################
# The w=0 spectrum is that of t... | code_fim | hard | {
"lang": "python",
"repo": "FlMondon/sncosmo",
"path": "/docs/_examples/plot_custom_source.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> volume, label, output = self.prepare_data(volume, label, output)
sz = volume.size() # z,c,y,x
canvas = []
volume_visual = volume.detach().cpu().expand(sz[0],3,sz[2],sz[3])
canvas.append(volume_visual)
sz = output.size() # z,c,y,x
output_visual = [ou... | code_fim | hard | {
"lang": "python",
"repo": "mouradbelo/pytorch_connectomics",
"path": "/connectomics/model/utils/visualizer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mouradbelo/pytorch_connectomics path: /connectomics/model/utils/visualizer.py
import torch
import torchvision.utils as vutils
import numpy as np
class Visualizer(object):
def __init__(self, vis_opt=0, N=8):
self.vis_opt = vis_opt
self.N = N # default maximum number of section... | code_fim | hard | {
"lang": "python",
"repo": "mouradbelo/pytorch_connectomics",
"path": "/connectomics/model/utils/visualizer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SamSamhuns/ritpytrading path: /tests/test_orders.py
import unittest
from ritpytrading import orders
class TestOrderMethods(unittest.TestCase):
def setUp(self):
self._sample_order_resp = [
{
"order_id": 1221,
"period": 1,
"t... | code_fim | hard | {
"lang": "python",
"repo": "SamSamhuns/ritpytrading",
"path": "/tests/test_orders.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_orders_dict(self):
method_dict = orders._orders_response_handle(
self._sample_order_resp, '/orders')
class_dict = {self._sample_order_resp[0]["order_id"]: orders.Order(
self._sample_order_resp[0])}
self.assertEqual(method_dict, class_dict)
if ... | code_fim | hard | {
"lang": "python",
"repo": "SamSamhuns/ritpytrading",
"path": "/tests/test_orders.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> return self._name
def forcast(self, earnings, price, title, adding):
if adding == None:
return
if earnings < 0:
return
print title + ":%6.2f"%(adding)
earnings2 = earnings * ((1 + adding)**2)
price10 = earnings2*100 / 10 #对应10%... | code_fim | hard | {
"lang": "python",
"repo": "vewe-richard/moneysea",
"path": "/core/stock/parser.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vewe-richard/moneysea path: /core/stock/parser.py
# coding=utf-8
import os
from globals import Globals
from fileparsers.financial import FinancialHistory
from fileparsers.note import Note
from common import Common
from config import Config
class Parser:
def __init__(self, stockpath):
... | code_fim | hard | {
"lang": "python",
"repo": "vewe-richard/moneysea",
"path": "/core/stock/parser.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Handler for a message recieved over 'connect' channel
@socketio.on("connect")
def handle_connect():
print("received connect")
@socketio.on("frame")
def process_frame(data):
# print("getting frame: " + data["imageURI"])
frameDetails = FrameDetails(
name=data["name"],
frameR... | code_fim | hard | {
"lang": "python",
"repo": "eusholli/imagebus",
"path": "/webrtc_producer/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Where I am - convert dataURI to bytes
header, encoded = data["imageURI"].split(",", 1)
imageBytes = b64decode(encoded)
frameDetails.setFrame(int(data["frameReference"]), imageBytes)
producer.send(frameDetails.topic, frameDetails)
emit("frame ack")
if __name__ == "__main__":
... | code_fim | hard | {
"lang": "python",
"repo": "eusholli/imagebus",
"path": "/webrtc_producer/app.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: eusholli/imagebus path: /webrtc_producer/app.py
from flask_socketio import SocketIO, emit
from flask import Flask, Response, render_template
from kafka import KafkaProducer
import jsonpickle
import sys
from base64 import b64decode
sys.path.append("../common")
from imagebusutil import FrameDetai... | code_fim | medium | {
"lang": "python",
"repo": "eusholli/imagebus",
"path": "/webrtc_producer/app.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>)
count = int(xml.findtext('Count'))
ids += [xml_id.text for xml_id in xml.findall('IdList/Id')]
payload['retstart'] += retmax
time.sleep(sleep)
return ids<|fim_prefix|># repo: danolez1/medline path: /eutility.py
import time
import xml.etree.ElementTree as ET
import ... | code_fim | hard | {
"lang": "python",
"repo": "danolez1/medline",
"path": "/eutility.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: danolez1/medline path: /eutility.py
import time
import xml.etree.ElementTree as ET
import requests
def esearch_query(payload, retmax = 100, sleep=2):
"""
Query the esearch E-utility.
NOTE: use `pubmedpy.eutilities.esearch_query` instead.
This function might be deleted in the fu... | code_fim | medium | {
"lang": "python",
"repo": "danolez1/medline",
"path": "/eutility.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ayload['retstart'] = 0
ids = list()
count = 1
while payload['retstart'] < count:
response = requests.get(url, params=payload)
xml = ET.fromstring(response.content)
count = int(xml.findtext('Count'))
ids += [xml_id.text for xml_id in xml.findall('IdList/Id')]
... | code_fim | medium | {
"lang": "python",
"repo": "danolez1/medline",
"path": "/eutility.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: hanyanze/FS_AILPA path: /local_socket/sensor2hass_mqtt.py
# -*- coding:utf-8 -*-
# author:hyz
import sys
import threading
import binascii
import re
import time
from datetime import datetime
import json
from mySerial import myserial
import paho.mqtt.client as mqtt
import config
class mqtt2sensor... | code_fim | hard | {
"lang": "python",
"repo": "hanyanze/FS_AILPA",
"path": "/local_socket/sensor2hass_mqtt.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> battery = int(data[16:18], 16)
battery_num = battery if battery < 100 else 100
# 设备是光强传感器
if config.get("/sensor{}/payload_key".format(num)) == "lightpower":
self.client.publish('state/lightpower01', payload='{"lightpower":%d, "lightpower_battery":%d}'
... | code_fim | hard | {
"lang": "python",
"repo": "hanyanze/FS_AILPA",
"path": "/local_socket/sensor2hass_mqtt.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
if __name__ == '__main__':
count_d_path(f"../data/{USE_DATA}/Trajectories/")
Parallel(n_jobs=4)(delayed(cal_diameter_error)(f"../data/{USE_DATA}/Trajectories/",
f"../data/{USE_DATA}/SD/sd_final_epsilon_{i}/"
... | code_fim | hard | {
"lang": "python",
"repo": "nomalocaris/DP-Star",
"path": "/metrics/diameter_error.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nomalocaris/DP-Star path: /metrics/diameter_error.py
"""
-------------------------------------
# -*- coding: utf-8 -*-
# @Author : QG
# @File : diameter_error.py
# @Software: PyCharm
-------------------------------------
"""
from joblib import Parallel
from joblib import delayed
from config... | code_fim | hard | {
"lang": "python",
"repo": "nomalocaris/DP-Star",
"path": "/metrics/diameter_error.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> calculate diameter error(DE) (main function)
Args:
d_path :
sd_path:
Returns:
"""
diameter, diameter_array = d_len(d_path)
if not os.path.exists(USE_DATA):
os.mkdir(USE_DATA)
with open(f"{USE_DATA}/diameter_array.txt", "r") as output:
diamet... | code_fim | hard | {
"lang": "python",
"repo": "nomalocaris/DP-Star",
"path": "/metrics/diameter_error.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cash2one/xai path: /xai/brain/wordbase/nouns/_sap.py
#calss header
class _SAP():
def __init__(self,):
<|fim_suffix|> def run(self, obj1 = [], obj2 = []):
return self.jsondata<|fim_middle|> self.name = "SAP"
self.definitions = [u'the liquid that carries food to all parts of a plant: ', u'... | code_fim | hard | {
"lang": "python",
"repo": "cash2one/xai",
"path": "/xai/brain/wordbase/nouns/_sap.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Write constants for argparser
WRITE_CONSTANTS = ['txt', 'json']
# output filepath
OUTPUT_PATH = './output/'
# review textfiles suffix
REVIEW_TXT_SUFFIX = "_reviews.txt"
# delimiter for textfile
DELIMITER = "-;-;-;-;-;-;-"
# threadpool size
THREADPOOL_SIZE = 4<|fim_prefix|># repo: I4-Projektseminar-H... | code_fim | hard | {
"lang": "python",
"repo": "I4-Projektseminar-HHU-2017/i4-projekt-wissenstechnologien-juma-1",
"path": "/scraper/src/const.py",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: I4-Projektseminar-HHU-2017/i4-projekt-wissenstechnologien-juma-1 path: /scraper/src/const.py
# Metacritic base URL
BASE_URL = "http://www.metacritic.com"
# Categories this scraper can handle
METACRITIC_CATEGORIES = ['games', 'tv', 'albums']
# Metacritic filter options
METACRITIC_FILTERS = ['90d... | code_fim | medium | {
"lang": "python",
"repo": "I4-Projektseminar-HHU-2017/i4-projekt-wissenstechnologien-juma-1",
"path": "/scraper/src/const.py",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mathisonian/twitter-github-trending path: /twitter-github-trending.py
import twitter
import os
import sqlitedict
import requests
from bs4 import BeautifulSoup
import time
dbdict = sqlitedict.SqliteDict('tgt.db', autocommit=True)
api = twitter.Api(consumer_key=os.environ['TWITTER_CONSUMER_KEY'],... | code_fim | hard | {
"lang": "python",
"repo": "mathisonian/twitter-github-trending",
"path": "/twitter-github-trending.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> while True:
try:
get_trending_repos()
# check once every hour
except Exception, e:
print e
pass
time.sleep(60 * 60)
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host='0.0.0.0', port=p... | code_fim | hard | {
"lang": "python",
"repo": "mathisonian/twitter-github-trending",
"path": "/twitter-github-trending.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: gabrielbarker/snap path: /test/test_hand.py
import unittest
import io
import sys
from unittest.mock import Mock, patch
from snap.hand import Hand
from snap.card import Card
class TestHand(unittest.TestCase):
def test__count__mock_cards__returns_correct_number(self):
expected_count =... | code_fim | hard | {
"lang": "python",
"repo": "gabrielbarker/snap",
"path": "/test/test_hand.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> FIVE_ACE_OF_HEARTS = [
" __ __ __ __ __ ",
"|A ||A ||A ||A ||A |",
"| ♡|| ♡|| ♡|| ♡|| ♡|",
" ‾‾ ‾‾ ‾‾ ‾‾ ‾‾ ",
]<|fim_prefix|># repo: gabrielbarker/snap path: /test/test_hand.py
import unittest
import io
import sys
from unittest.mock import Mock, patch
from... | code_fim | hard | {
"lang": "python",
"repo": "gabrielbarker/snap",
"path": "/test/test_hand.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def mock_card(self, value="0"):
card = Mock()
card.value.return_value = value
card.strings.return_value = TestHand.ACE_OF_HEARTS
return card
ACE_OF_HEARTS = [
" __ ",
"|A |",
"| ♡|",
" ‾‾ ",
]
FIVE_ACE_OF_HEARTS = [
... | code_fim | hard | {
"lang": "python",
"repo": "gabrielbarker/snap",
"path": "/test/test_hand.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class Shadowed(namedtuple("Shadowed", [])):
pass
def shadowed():
return Shadowed()<|fim_prefix|># repo: vnetserg/dill path: /tests/shadowed_namedtuple/shadowed.py
# This module is used by the `test_shadowed_namedtuple` test.
# Author: Sergei Fomin (se4min at yandex-team.ru)
<|fim_middle|>from c... | code_fim | easy | {
"lang": "python",
"repo": "vnetserg/dill",
"path": "/tests/shadowed_namedtuple/shadowed.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vnetserg/dill path: /tests/shadowed_namedtuple/shadowed.py
# This module is used by the `test_shadowed_namedtuple` test.
# Author: Sergei Fomin (se4min at yandex-team.ru)
<|fim_suffix|>def shadowed():
return Shadowed()<|fim_middle|>from collections import namedtuple
class Shadowed(namedtupl... | code_fim | medium | {
"lang": "python",
"repo": "vnetserg/dill",
"path": "/tests/shadowed_namedtuple/shadowed.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: NULLCT/LOMC path: /src/data/699.py
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
for i in range(N - 1):
a, b = map(int, input().split())
graph[a - 1].append((1, b - 1))
graph[b - 1].append((1, a - 1))
ans = [0] * (N)
import heapq
hq = [(0, 0)]
g = [float('inf')] * N... | code_fim | medium | {
"lang": "python",
"repo": "NULLCT/LOMC",
"path": "/src/data/699.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>c, d = map(int, input().split())
c = c - 1
d = d - 1
if ans[c] != ans[d]:
dd[i] = 1
for i in range(Q):
if dd[i] == 0:
print('Town')
else:
print('Road')<|fim_prefix|># repo: NULLCT/LOMC path: /src/data/699.py
N, Q = map(int, input().split())
graph = [[] for _ in... | code_fim | hard | {
"lang": "python",
"repo": "NULLCT/LOMC",
"path": "/src/data/699.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justin441/risk_management path: /risk_register/forms.py
urs fois sur le même processus"""
cleaned_data = super().clean()
cleaned_data.pop('classe_de_risque')
risque = cleaned_data.get('risque', '')
type_de_risque = cleaned_data.get('type_de_risque', '')
try... | code_fim | hard | {
"lang": "python",
"repo": "justin441/risk_management",
"path": "/risk_register/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: justin441/risk_management path: /risk_register/forms.py
cleaned_data = super().clean()
debut = cleaned_data.get('start', '')
fin = cleaned_data.get('end', '')
if debut > fin:
msg = _('La date de début est postérieure à la date de fin.')
self.add_err... | code_fim | hard | {
"lang": "python",
"repo": "justin441/risk_management",
"path": "/risk_register/forms.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>class CreateInputDataForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
self.processus = kwargs.pop('processus')
super().__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_method = 'post'
self.helper.form_class = 'form-horizontal'
... | code_fim | hard | {
"lang": "python",
"repo": "justin441/risk_management",
"path": "/risk_register/forms.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: amkusmec/snptools path: /src/snpstat.py
# -*- coding: utf-8 -*-
"""
Created on Fri May 22 08:29:35 2015
@author: aaron
"""
import argparse
import textwrap
import timeit
import os
from snptools import *
###############################################################################
def version(... | code_fim | hard | {
"lang": "python",
"repo": "amkusmec/snptools",
"path": "/src/snpstat.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> counter += 1
if counter % 1e5 == 0:
print("Processed [ ", str(counter), " ] SNPs.")
return stats
###############################################################################
def vcfStat(filename):
print("Calculating statistics.")
stats = [["snpi... | code_fim | hard | {
"lang": "python",
"repo": "amkusmec/snptools",
"path": "/src/snpstat.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>allCharts = []
for f in files:
L = pickle.load(f)
allCharts.extend(L)
f.close()
with open(chart+"Results", 'wb') as f:
pickle.dump(allCharts, f)
print("Pickled")<|fim_prefix|># repo: Guptacos/spotify_analysis path: /data/combineYears.py
import pickle
import os
from os.path import isfile, join
def ... | code_fim | hard | {
"lang": "python",
"repo": "Guptacos/spotify_analysis",
"path": "/data/combineYears.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Guptacos/spotify_analysis path: /data/combineYears.py
import pickle
import os
from os.path import isfile, join
def getHandles(f):
<|fim_suffix|>allCharts = []
for f in files:
L = pickle.load(f)
allCharts.extend(L)
f.close()
with open(chart+"Results", 'wb') as f:
pickle.dump(allCharts, f)
p... | code_fim | hard | {
"lang": "python",
"repo": "Guptacos/spotify_analysis",
"path": "/data/combineYears.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def get_entities_in_group(self, group):
group = self.get_state(group, attribute="all")
return group
def check_group(self, entity, group):
group = self.get_entities_in_group(group)
return entity in group["attributes"]["entity_id"]<|fim_prefix|># repo: borland502/ha_... | code_fim | medium | {
"lang": "python",
"repo": "borland502/ha_appdaemon",
"path": "/info/info.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: borland502/ha_appdaemon path: /info/info.py
import appdaemon.plugins.hass.hassapi as hass
class Info(hass.Hass):
<|fim_suffix|> group = self.get_state(group, attribute="all")
return group
def check_group(self, entity, group):
group = self.get_entities_in_group(group)... | code_fim | medium | {
"lang": "python",
"repo": "borland502/ha_appdaemon",
"path": "/info/info.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> group = self.get_entities_in_group(group)
return entity in group["attributes"]["entity_id"]<|fim_prefix|># repo: borland502/ha_appdaemon path: /info/info.py
import appdaemon.plugins.hass.hassapi as hass
class Info(hass.Hass):
<|fim_middle|> def initialize(self):
self.log('In... | code_fim | hard | {
"lang": "python",
"repo": "borland502/ha_appdaemon",
"path": "/info/info.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rebeccahawke/msl-qt path: /msl/qt/_qt.py
"""
A wrapper over different Python Qt bindings (e.g., PyQt4_, PyQt5_, PySide_, PySide2_).
<|fim_suffix|>.. _PyQt4: http://pyqt.sourceforge.net/Docs/PyQt4/
.. _PyQt5: http://pyqt.sourceforge.net/Docs/PyQt5/
.. _PySide: https://wiki.qt.io/PySide
.. _PySide... | code_fim | hard | {
"lang": "python",
"repo": "rebeccahawke/msl-qt",
"path": "/msl/qt/_qt.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>Example repositories which unify the syntax for PyQt4_, PyQt5_, PySide_ and PySide2_:
* https://github.com/mottosso/Qt.py
* https://github.com/jupyter/qtconsole/blob/master/qtconsole/qt_loaders.py
* https://github.com/spyder-ide/qtpy
* https://github.com/pyQode/pyqode.qt
* https://github.com/silx-kit/sil... | code_fim | medium | {
"lang": "python",
"repo": "rebeccahawke/msl-qt",
"path": "/msl/qt/_qt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>.. _PyQt4: http://pyqt.sourceforge.net/Docs/PyQt4/
.. _PyQt5: http://pyqt.sourceforge.net/Docs/PyQt5/
.. _PySide: https://wiki.qt.io/PySide
.. _PySide2: https://wiki.qt.io/PySide2
"""
from PyQt5 import Qt, QtWidgets, QtCore, QtGui
__all__ = (
'Qt',
'QtGui',
'QtWidgets',
'QtCore',
)<|fim_p... | code_fim | hard | {
"lang": "python",
"repo": "rebeccahawke/msl-qt",
"path": "/msl/qt/_qt.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: lilinghell/devops path: /devops-console/apps/designs/migrations/0006_interfacegroup_project.py
# Generated by Django 2.1.5 on 2019-09-20 09:43
from django.db import migrations, models
import django.db.models.deletion
<|fim_suffix|> dependencies = [
('projects', '0009_auto_20190606_14... | code_fim | medium | {
"lang": "python",
"repo": "lilinghell/devops",
"path": "/devops-console/apps/designs/migrations/0006_interfacegroup_project.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AddField(
model_name='interfacegroup',
name='project',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='project_group', to='projects.Project', verbose_name='归属项目'),
),
]<|fim_... | code_fim | medium | {
"lang": "python",
"repo": "lilinghell/devops",
"path": "/devops-console/apps/designs/migrations/0006_interfacegroup_project.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> dependencies = [
('projects', '0009_auto_20190606_1403'),
('designs', '0005_auto_20190920_1601'),
]
operations = [
migrations.AddField(
model_name='interfacegroup',
name='project',
field=models.ForeignKey(null=True, on_delete=django.... | code_fim | medium | {
"lang": "python",
"repo": "lilinghell/devops",
"path": "/devops-console/apps/designs/migrations/0006_interfacegroup_project.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cosanlab/nltools path: /nltools/tests/test_analysis.py
from nltools.simulator import Simulator
from nltools.analysis import Roc
def test_roc(tmpdir):
sim = Simulator()
sigma = 0.1
y = [0, 1]
n_reps = 10
# output_dir = str(tmpdir)
dat = sim.create_data(y, sigma, reps=... | code_fim | hard | {
"lang": "python",
"repo": "cosanlab/nltools",
"path": "/nltools/tests/test_analysis.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Forced Choice
binary_outcome = output["Y"] == 1
forced_choice = list(range(int(len(binary_outcome) / 2))) + list(
range(int(len(binary_outcome) / 2))
)
forced_choice = forced_choice.sort()
roc_fc = Roc(
input_values=output["yfit_all"],
binary_outcome=binar... | code_fim | hard | {
"lang": "python",
"repo": "cosanlab/nltools",
"path": "/nltools/tests/test_analysis.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: maticardenas/python_api_testing path: /tests/covid_test.py
from lxml import etree
import requests
from assertpy import assert_that
from config import COVID_TRACKER_HOST
from utils.print_helpers import pretty_print
from utils.xml_utils import get_xml_etree
def test_covid_cases_have_crossed_a_m... | code_fim | hard | {
"lang": "python",
"repo": "maticardenas/python_api_testing",
"path": "/tests/covid_test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> overall_cases = int(xml_tree.xpath("//data/summary/total_cases")[0].text)
# Another way to specify XPath first and then use to evaluate
# on an XML tree
search_for = etree.XPath("//data//regions//total_cases")
cases_by_country = sum(
[int(region.text) for region in search_for(x... | code_fim | hard | {
"lang": "python",
"repo": "maticardenas/python_api_testing",
"path": "/tests/covid_test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cjlovering/interpretable-reinforcement-learning-using-attention path: /tests/polybeast_inference_test.py
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You ... | code_fim | hard | {
"lang": "python",
"repo": "cjlovering/interpretable-reinforcement-learning-using-attention",
"path": "/tests/polybeast_inference_test.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> def test_inference_cpu_no_lstm(self):
self._test_inference(use_lstm=False, device=torch.device("cpu"))
def test_inference_cuda_no_lstm(self):
if not torch.cuda.is_available():
warnings.warn("Not testing cuda as it's not available")
return
self._test... | code_fim | hard | {
"lang": "python",
"repo": "cjlovering/interpretable-reinforcement-learning-using-attention",
"path": "/tests/polybeast_inference_test.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cmattey/leetcode_problems path: /Python/lc_222_count_complete_tree_nodes.py
# Nov 3rd '19
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# Time: O(log^2n), each iterations does logn... | code_fim | hard | {
"lang": "python",
"repo": "cmattey/leetcode_problems",
"path": "/Python/lc_222_count_complete_tree_nodes.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def countNodes(self, root):
"""
Normal Binary Tree approach, not utilizing complete nature... | code_fim | hard | {
"lang": "python",
"repo": "cmattey/leetcode_problems",
"path": "/Python/lc_222_count_complete_tree_nodes.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> backing_file = data.backing_file
if backing_file is not None:
raise exception.ImageUnacceptable(image_id=image_href,
reason=_("fmt=%(fmt)s backed by: %(backing_file)s") %
{'fmt': fmt,
... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/config",
"path": "/sysinv/sysinv/sysinv/sysinv/common/images.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: starlingx/config path: /sysinv/sysinv/sysinv/sysinv/common/images.py
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Copyright (c) 2010 Citri... | code_fim | hard | {
"lang": "python",
"repo": "starlingx/config",
"path": "/sysinv/sysinv/sysinv/sysinv/common/images.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: vmorris/aoc2020 path: /tests/test_day01.py
from aoc2020.day01 import solution
from aoc2020.util import get_input_as_int
input_data = get_input_as_int("tests/testinput.day01")
<|fim_suffix|> expected = 241861950
actual = solution.solve_part2(input_data)
assert expected == actual<|fim... | code_fim | medium | {
"lang": "python",
"repo": "vmorris/aoc2020",
"path": "/tests/test_day01.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def test_solve_part2():
expected = 241861950
actual = solution.solve_part2(input_data)
assert expected == actual<|fim_prefix|># repo: vmorris/aoc2020 path: /tests/test_day01.py
from aoc2020.day01 import solution
from aoc2020.util import get_input_as_int
input_data = get_input_as_int("tests... | code_fim | medium | {
"lang": "python",
"repo": "vmorris/aoc2020",
"path": "/tests/test_day01.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> expected = 514579
actual = solution.solve_part1(input_data)
assert expected == actual
def test_solve_part2():
expected = 241861950
actual = solution.solve_part2(input_data)
assert expected == actual<|fim_prefix|># repo: vmorris/aoc2020 path: /tests/test_day01.py
from aoc2020.day... | code_fim | easy | {
"lang": "python",
"repo": "vmorris/aoc2020",
"path": "/tests/test_day01.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def RemoveTempDirContents():
"""Obliterate the entire contents of the temporary directory, excluding
paths in sys.argv.
"""
temp_dir = os.path.abspath(tempfile.gettempdir())
print 'Removing contents of %s' % temp_dir
print ' Inspecting args for files to skip'
whitelist = set()
for i in s... | code_fim | hard | {
"lang": "python",
"repo": "nv-chromium/chromium-crosswalk",
"path": "/infra/scripts/legacy/scripts/slave/slave_utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: nv-chromium/chromium-crosswalk path: /infra/scripts/legacy/scripts/slave/slave_utils.py
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Functions specific to build slaves, sha... | code_fim | hard | {
"lang": "python",
"repo": "nv-chromium/chromium-crosswalk",
"path": "/infra/scripts/legacy/scripts/slave/slave_utils.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|>def RemoveChromeTemporaryFiles():
"""A large hammer to nuke what could be leaked files from unittests or
files left from a unittest that crashed, was killed, etc."""
# NOTE: print out what is cleaned up so the bots don't timeout if
# there is a lot to cleanup and also se we see the leaks in the
... | code_fim | hard | {
"lang": "python",
"repo": "nv-chromium/chromium-crosswalk",
"path": "/infra/scripts/legacy/scripts/slave/slave_utils.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: keiffster/program-y path: /test/programytest/parser/template/node_tests/richmedia_tests/test_list.py
from programy.parser.template.nodes.base import TemplateNode
from programy.parser.template.nodes.richmedia.list import TemplateListNode
from programy.parser.template.nodes.word import TemplateWord... | code_fim | medium | {
"lang": "python",
"repo": "keiffster/program-y",
"path": "/test/programytest/parser/template/node_tests/richmedia_tests/test_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> root = TemplateNode()
self.assertIsNotNone(root)
self.assertIsNotNone(root.children)
self.assertEqual(len(root.children), 0)
list = TemplateListNode()
list._items.append(TemplateWordNode("Item1"))
list._items.append(TemplateWordNode("Item2"))
... | code_fim | medium | {
"lang": "python",
"repo": "keiffster/program-y",
"path": "/test/programytest/parser/template/node_tests/richmedia_tests/test_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>port ConjugateGradientOptimizer
from meta_policy_search.optimizers.maml_first_order_optimizer import MAMLFirstOrderOptimizer<|fim_prefix|># repo: jonasrothfuss/ProMP path: /meta_policy_search/optimizers/__init__.py
from meta_policy_search.optimizers.base import Optimizer
from<|fim_middle|> meta_policy_se... | code_fim | medium | {
"lang": "python",
"repo": "jonasrothfuss/ProMP",
"path": "/meta_policy_search/optimizers/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: jonasrothfuss/ProMP path: /meta_policy_search/optimizers/__init__.py
from meta_policy_search.optimizers.base import Optimizer
from<|fim_suffix|>port ConjugateGradientOptimizer
from meta_policy_search.optimizers.maml_first_order_optimizer import MAMLFirstOrderOptimizer<|fim_middle|> meta_policy_se... | code_fim | medium | {
"lang": "python",
"repo": "jonasrothfuss/ProMP",
"path": "/meta_policy_search/optimizers/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>zers.maml_first_order_optimizer import MAMLFirstOrderOptimizer<|fim_prefix|># repo: jonasrothfuss/ProMP path: /meta_policy_search/optimizers/__init__.py
from meta_policy_search.optimizers.base import Optimizer
from meta_policy_search.optimizers.conjugate_gradient_optimizer im<|fim_middle|>port ConjugateG... | code_fim | medium | {
"lang": "python",
"repo": "jonasrothfuss/ProMP",
"path": "/meta_policy_search/optimizers/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not d:
return None
o = RelationInfo()
if 'recency' in d:
o.recency = d['recency']
return o<|fim_prefix|># repo: articuly/alipay-sdk-python-all path: /alipay/aop/api/domain/RelationInfo.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import simpl... | code_fim | hard | {
"lang": "python",
"repo": "articuly/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/RelationInfo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: articuly/alipay-sdk-python-all path: /alipay/aop/api/domain/RelationInfo.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import simplejson as json
from alipay.aop.api.constant.ParamConstants import *
class RelationInfo(object):
def __init__(self):
self._recency = None
@prope... | code_fim | medium | {
"lang": "python",
"repo": "articuly/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/RelationInfo.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @property
def recency(self):
return self._recency
@recency.setter
def recency(self, value):
self._recency = value
def to_alipay_dict(self):
params = dict()
if self.recency:
if hasattr(self.recency, 'to_alipay_dict'):
params... | code_fim | medium | {
"lang": "python",
"repo": "articuly/alipay-sdk-python-all",
"path": "/alipay/aop/api/domain/RelationInfo.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tefra/xsdata-w3c-tests path: /output/models/nist_data/union/duration_decimal/schema_instance/nistschema_sv_iv_union_duration_decimal_enumeration_3_xsd/__init__.py
from output.models.nist_data.union.duration_decimal.schema_instance.nistschema_sv_iv_union_duration_decima<|fim_suffix|>DurationDecima... | code_fim | medium | {
"lang": "python",
"repo": "tefra/xsdata-w3c-tests",
"path": "/output/models/nist_data/union/duration_decimal/schema_instance/nistschema_sv_iv_union_duration_decimal_enumeration_3_xsd/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>DurationDecimalEnumeration3,
NistschemaSvIvUnionDurationDecimalEnumeration3Type,
)
__all__ = [
"NistschemaSvIvUnionDurationDecimalEnumeration3",
"NistschemaSvIvUnionDurationDecimalEnumeration3Type",
]<|fim_prefix|># repo: tefra/xsdata-w3c-tests path: /output/models/nist_data/union/duration_d... | code_fim | medium | {
"lang": "python",
"repo": "tefra/xsdata-w3c-tests",
"path": "/output/models/nist_data/union/duration_decimal/schema_instance/nistschema_sv_iv_union_duration_decimal_enumeration_3_xsd/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: zhangjiaobxy/ToBio path: /sourceCode/formatMagna.py
# *********************************************************************
# convert network file to the file format that can be run in magna
# *********************************************************************
# input:
# 1.txt (each node is... | code_fim | medium | {
"lang": "python",
"repo": "zhangjiaobxy/ToBio",
"path": "/sourceCode/formatMagna.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fl = os.listdir(inputDir)
for f in fl:
if f.endswith('.txt') and not f.endswith('_OUT.txt'):
fi = open(inputDir + f, 'r')
fo = open(outputDir + f.strip().replace('.txt', '.gw'), 'w')
ls = fi.readlines()
nodeSet = set()
edgeList = []
for l in ls:
sNode = l.strip().split('\t')[0]
tNode = ... | code_fim | medium | {
"lang": "python",
"repo": "zhangjiaobxy/ToBio",
"path": "/sourceCode/formatMagna.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>inputDir = './../data/mfinderFeature/'
outputDir = './../data/magnaLabel/'
if not os.path.exists(outputDir):
os.makedirs(outputDir)
fl = os.listdir(inputDir)
for f in fl:
if f.endswith('.txt') and not f.endswith('_OUT.txt'):
fi = open(inputDir + f, 'r')
fo = open(outputDir + f.strip().replace('.tx... | code_fim | medium | {
"lang": "python",
"repo": "zhangjiaobxy/ToBio",
"path": "/sourceCode/formatMagna.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Thedush/Astar path: /path finding/realtime8way.py
import cv2
import numpy as np
from heapq import *
img=cv2.imread('test_images/test_image23.png') #read the image
def h(a,b):
return (b[0]-a[0])+(b[1]-a[1])
def astar(start,goal):
cs1=cs=start
gs=goal
close=set()
parent={}
... | code_fim | hard | {
"lang": "python",
"repo": "Thedush/Astar",
"path": "/path finding/realtime8way.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> for j1 in xrange (20,400,40):
j=(((j1-20)/40))
if (img[i1,j1,1]==0):
a[i].append(100)
else:
a[i].append(0)
for i in range (10):
print a[i]
start=(((stcol-20)/40),((strow-20)/40))
goal=(((gocol-20)/40),((gorow-20)/40))
... | code_fim | hard | {
"lang": "python",
"repo": "Thedush/Astar",
"path": "/path finding/realtime8way.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: martinspielmann/dcso-portal-python-sdk path: /lib/dcso/portal/auth/auth.py
# Copyright (c) 2020, 2021, DCSO GmbH
from datetime import datetime
from typing import Optional
from .rbac import RBACMixin
from .token import Token
from ..abstracts import APIAbstract
from ..exceptions import PortalAPIR... | code_fim | hard | {
"lang": "python",
"repo": "martinspielmann/dcso-portal-python-sdk",
"path": "/lib/dcso/portal/auth/auth.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> request = GraphQLRequest(api_url=self._api.api_url,
query=_GRAPHQL_MUTATION_AUTHN, variables=variables)
try:
response = request.execute_dict()
except PortalException:
raise
try:
authn = Authentication(gr... | code_fim | hard | {
"lang": "python",
"repo": "martinspielmann/dcso-portal-python-sdk",
"path": "/lib/dcso/portal/auth/auth.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: UB-info/estructura-datos path: /RafaelArqueroGimeno_S5/PColaInterface.py
__author__ = "Rafael Arquero Gimeno"
from copy import copy
from model import *
import view
import parserLastFM
def add(parser):
return parser.next()
def search(queue, minimum=0.0, maximum=1.0):
<|fim_suffix|>
def i... | code_fim | hard | {
"lang": "python",
"repo": "UB-info/estructura-datos",
"path": "/RafaelArqueroGimeno_S5/PColaInterface.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def remove(queue, minimum=0.0, maximum=1.0):
assert 0 <= minimum <= 1
assert 0 <= maximum <= 1
assert minimum <= maximum
result = PQueue()
queueCopy = copy(queue)
value = queueCopy.dequeue()
while value is not None and value > maximum:
result.enqueue(value) # append... | code_fim | hard | {
"lang": "python",
"repo": "UB-info/estructura-datos",
"path": "/RafaelArqueroGimeno_S5/PColaInterface.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>def initParser(filename):
return parserLastFM.parser(filename, PQueue())
if __name__ == "__main__":
users = PQueue()
parser = initParser('LastFM_small.dat')
app = view.MainApp(parser, add, search, remove, users)
app.mainloop()<|fim_prefix|># repo: UB-info/estructura-datos path: /Rafa... | code_fim | hard | {
"lang": "python",
"repo": "UB-info/estructura-datos",
"path": "/RafaelArqueroGimeno_S5/PColaInterface.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not stmt: return
if not hasattr(stmt, 'parent'): return
started = False
for s in stmt.parent.content:
if s==stmt:
if not isinstance(s, Comment): return s
started = True
elif started:... | code_fim | hard | {
"lang": "python",
"repo": "E3SM-Project/KGen",
"path": "/kgen/parser/kgparse.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: E3SM-Project/KGen path: /kgen/parser/kgparse.py
'''KGen parser
'''
#import os.path
from kgutils import UserException
from kgconfig import Config
from statements import Comment
from block_statements import Module, Program
import os
import logging
import kgutils
import api
import collections
logge... | code_fim | hard | {
"lang": "python",
"repo": "E3SM-Project/KGen",
"path": "/kgen/parser/kgparse.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> subs=[[]]
for i in range(len(my_list)):
n=i+1
while n<=len(my_list):
sub=my_list[i:n]
subs.append(sub)
n+=1
return subs
def maxSubarrayValue(a):
n=len(a)
if n==1:
return a[0]
# Write your code here
ans=sub_lists(a)
... | code_fim | medium | {
"lang": "python",
"repo": "Akash671/coding",
"path": "/HackerRank/subarray_combination2.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Akash671/coding path: /HackerRank/subarray_combination2.py
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'maxSubarrayValue' function below.
#
# The function is expected to return a LONG_INTEGER.
# The function accepts INTEGER_ARRAY arr as parameter.
... | code_fim | hard | {
"lang": "python",
"repo": "Akash671/coding",
"path": "/HackerRank/subarray_combination2.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.inicial = True
def isFinal(self):
return self.final
def setFinal(self):
self.final = True<|fim_prefix|># repo: dennisurtubia/Automato-Finito path: /src/estado.py
class Estado:
def __init__(self, nome):
""" Description
Método construtor de estado, define os ... | code_fim | medium | {
"lang": "python",
"repo": "dennisurtubia/Automato-Finito",
"path": "/src/estado.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: dennisurtubia/Automato-Finito path: /src/estado.py
class Estado:
def __init__(self, nome):
""" Description
Método construtor de estado, define os atributos que um estado deve ter
:type nome: str
:param nome: Nome ou descrição do estado
"""
self.nome = nome
... | code_fim | medium | {
"lang": "python",
"repo": "dennisurtubia/Automato-Finito",
"path": "/src/estado.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pedrogbmendes/TrimTuner path: /tests/run_trimtuner.py
#!/usr/bin/env python
import argparse
import sys
import numpy as np
import collections
import csv
import math
#from robo.fmin import fabolas
from trimtuner.trimtuner import trimtuner
csv.field_size_limit(sys.maxsize)
listConfig = []
####... | code_fim | hard | {
"lang": "python",
"repo": "pedrogbmendes/TrimTuner",
"path": "/tests/run_trimtuner.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> # filtering heuristic -> FLAGS.filter
# cea, random, no filter
if not (FLAGS.filter == "cea" or FLAGS.filter == "nofilter" or FLAGS.filter == "random"):
print("ERROR: Wrong filtering heuristic. Chose cea, nofilter or random")
sys.stdout.flush()
sys.exit(0)
if FLAGS... | code_fim | hard | {
"lang": "python",
"repo": "pedrogbmendes/TrimTuner",
"path": "/tests/run_trimtuner.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Arwen0905/Python_Test path: /TQC_考題練習/b0527_TQC證照_410_ex.py
# TODO
n = 5
# n = int(input())
for i in range(1,n+1): # 1-(5)
for j in range(n,i,-1): # (<|fim_suffix|>ge(1,i*2):
print('*',end='')
print()<|fim_middle|>5)-0
print(' ',end='')
for k in ran | code_fim | easy | {
"lang": "python",
"repo": "Arwen0905/Python_Test",
"path": "/TQC_考題練習/b0527_TQC證照_410_ex.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>5)-0
print(' ',end='')
for k in range(1,i*2):
print('*',end='')
print()<|fim_prefix|># repo: Arwen0905/Python_Test path: /TQC_考題練習/b0527_TQC證照_410_ex.py
# TODO
n = 5
# n = int(input())
for i in range(<|fim_middle|>1,n+1): # 1-(5)
for j in range(n,i,-1): # ( | code_fim | easy | {
"lang": "python",
"repo": "Arwen0905/Python_Test",
"path": "/TQC_考題練習/b0527_TQC證照_410_ex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: SmithJesko/volny-films path: /analytics/utils.py
import json
import urllib.request
# import httpagentparser
from django.urls import resolve
from .models import ClientConnection, UserClientConnection
def get_client_ip(request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
... | code_fim | hard | {
"lang": "python",
"repo": "SmithJesko/volny-films",
"path": "/analytics/utils.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.