text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>Addition = Predicate("Addition")
@PyPred(Addition(_.A, _.B, _.C))
def _add(A, B, C):
bound = tuple(0 if isinstance(v, Variable) else 1 for v in (A, B, C))
if bound == (0, 1, 1):
yield {A: C-B}
elif bound == (1, 0, 1):
yield {B: C-A}
elif bound == (1, 1, 0):
yield {C... | code_fim | hard | {
"lang": "python",
"repo": "mistasse/Prology",
"path": "/examples/math.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># Here, B will be forced to be a smallInteger
SmallIntegerAddition = Predicate("smintegeraddition")
SmallIntegerAddition(_.A, _.B, _.C).known_when(SmallInteger(_.A), SmallInteger(_.B), SmallInteger(_.C), Addition(_.A, _.B, _.C))
print(SmallIntegerAddition(_.B, _.A, 5).all())
# Here, no constraint on B, t... | code_fim | hard | {
"lang": "python",
"repo": "mistasse/Prology",
"path": "/examples/math.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mistasse/Prology path: /examples/math.py
from _prology import *
_ = L
SmallInteger = Predicate("sminteger")
@PyPred(SmallInteger(_.A))
def sminteger(A):
if isinstance(A, Variable):
for i in range(0, 10):
yield {A: i}
if isinstance(A, int):
if 0 <= A < 10:
... | code_fim | hard | {
"lang": "python",
"repo": "mistasse/Prology",
"path": "/examples/math.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pprp/SimpleCVReproduction path: /NAS/AngleNAS/NAS-Bench-201/exps/angle/get_standalone_ranks.py
##################################################
# Copyright (c) Xuanyi Dong [GitHub D-X-Y], 2019 #
######################################################################################
import os, sy... | code_fim | hard | {
"lang": "python",
"repo": "pprp/SimpleCVReproduction",
"path": "/NAS/AngleNAS/NAS-Bench-201/exps/angle/get_standalone_ranks.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == '__main__':
parser = argparse.ArgumentParser("SETN")
parser.add_argument('--data_path', type=str, help='Path to dataset')
parser.add_argument('--dataset', type=str, choices=['cifar10', 'cifar100', 'ImageNet16-120'], help='Choose between Cifar10/100 and ImageNet... | code_fim | hard | {
"lang": "python",
"repo": "pprp/SimpleCVReproduction",
"path": "/NAS/AngleNAS/NAS-Bench-201/exps/angle/get_standalone_ranks.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def as_dict(self):
data = dict(
name=self.name,
card_type=self.card_type,
mana=self.mana
)
return data
class DeckEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, Card):
return obj.as_dict()
if isinstance(obj, Mana):
return obj.value
return json.JSONEnco... | code_fim | hard | {
"lang": "python",
"repo": "ProfessorBeekums/mtg-deck-stats",
"path": "/deck_stats/deck.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.mana = []
for mana_value in mana_values:
self.mana.append(Mana(mana_value))
def get_mana_key(self):
"""
This lets us group mana so we know what we may get in starting hands
"""
# return json.dumps(self.mana, cls=DeckEncoder)
mana_keys = []
for mana in self.mana:
mana_keys.app... | code_fim | hard | {
"lang": "python",
"repo": "ProfessorBeekums/mtg-deck-stats",
"path": "/deck_stats/deck.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ProfessorBeekums/mtg-deck-stats path: /deck_stats/deck.py
from enum import Enum
import json
CARD_TYPE_LAND = 1
CARD_TYPE_CREATURE = 2
class Mana(Enum):
red = 1
green = 2
blue = 3
black = 4
white = 5
colorless = 6
class Deck:
def __init__(self, card_jsons=[]):
self.num_lands = 0
self... | code_fim | hard | {
"lang": "python",
"repo": "ProfessorBeekums/mtg-deck-stats",
"path": "/deck_stats/deck.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: E1mir/PySandbox path: /src/problems/other/rectangle_intersection.py
"""
Problem
Given two rectangles, determine if they overlap. The rectangles are defined as a Dictionary:
r1 = {
# x and y coordinates of the bottom-left corner of the rectangle
'x': 2, 'y': 4,
# Width and Height of r... | code_fim | hard | {
"lang": "python",
"repo": "E1mir/PySandbox",
"path": "/src/problems/other/rectangle_intersection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not w_overlap or not h_overlap:
print('No overlap')
return None
return {
'x': x_overlap,
'y': y_overlap,
'w': w_overlap,
'h': h_overlap
}
if __name__ == '__main__':
r1 = {'x': 2, 'y': 4, 'w': 5, 'h': 12}
r2 = {'x': 1, 'y': 5, 'w': 7... | code_fim | hard | {
"lang": "python",
"repo": "E1mir/PySandbox",
"path": "/src/problems/other/rectangle_intersection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> valor_formatado = f"{simbolo_moeda}{valor:.2f}".replace('.', ',')
return valor_formatado<|fim_prefix|># repo: reglabel/PraticaIntroducaoPython path: /Introducao-Python/ex109/moeda.py
def metade(valor=0.0, formatar=False):
res = valor / 2
if formatar:
res = moeda(res)
return re... | code_fim | medium | {
"lang": "python",
"repo": "reglabel/PraticaIntroducaoPython",
"path": "/Introducao-Python/ex109/moeda.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> res = ((taxa / 100.0) + 1.0) * valor
if formatar:
res = moeda(res)
return res
def diminuir(valor=0.0, taxa=0.0, formatar=False):
res = (1.0 - (taxa / 100.0)) * valor
if formatar:
res = moeda(res)
return res
def moeda(valor=0.0, simbolo_moeda="R$"):
valor_for... | code_fim | medium | {
"lang": "python",
"repo": "reglabel/PraticaIntroducaoPython",
"path": "/Introducao-Python/ex109/moeda.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: reglabel/PraticaIntroducaoPython path: /Introducao-Python/ex109/moeda.py
def metade(valor=0.0, formatar=False):
res = valor / 2
if formatar:
res = moeda(res)
return res
<|fim_suffix|>def moeda(valor=0.0, simbolo_moeda="R$"):
valor_formatado = f"{simbolo_moeda}{valor:.2f}... | code_fim | hard | {
"lang": "python",
"repo": "reglabel/PraticaIntroducaoPython",
"path": "/Introducao-Python/ex109/moeda.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.app.register('HEAD', '/v1/AUTH_test2/test+versions',
swob.HTTPNoContent,
{'X-Timestamp': 0,
'X-Container-Read': 'test2:tester',
'X-Container-Write': 'test2:tester'}, None)... | code_fim | hard | {
"lang": "python",
"repo": "ichi-shin/swift3",
"path": "/swift3/test/unit/test_service.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> super(TestSwift3Service, self).setUp()
self.app.register(
'GET', '/', swob.HTTPOk, {}, 'passed')
self.app.register(
'PUT', '/', swob.HTTPOk, {}, 'passed')
self.buckets = (('apple', 1, 200), ('orange', 3, 430))
json_pattern = ['"name":%s', ... | code_fim | hard | {
"lang": "python",
"repo": "ichi-shin/swift3",
"path": "/swift3/test/unit/test_service.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ichi-shin/swift3 path: /swift3/test/unit/test_service.py
# Copyright (c) 2014 OpenStack Foundation
# Copyright(c)2014 NTT corp.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the Lic... | code_fim | hard | {
"lang": "python",
"repo": "ichi-shin/swift3",
"path": "/swift3/test/unit/test_service.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.options = options or {}
self.application = app
super(StandaloneApplication, self).__init__()
def load_config(self):
config = dict(
[(key, value) for key, value in six.iteritems(self.options)
if key in self.cfg.settings and value is not Non... | code_fim | medium | {
"lang": "python",
"repo": "indigo-dc/bdocker",
"path": "/bdocker/middleware/__init__.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: indigo-dc/bdocker path: /bdocker/middleware/__init__.py
# -*- coding: utf-8 -*-
# Copyright 2015 LIP - INDIGODataCLOUD
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
... | code_fim | hard | {
"lang": "python",
"repo": "indigo-dc/bdocker",
"path": "/bdocker/middleware/__init__.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Ziang-Lu/Design-Patterns path: /2-Creational Patterns/1-Factory Method Pattern & Abstract Factory Pattern/GUI Example/Python/factory.py
#!usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Factory module.
"""
__author__ = 'Ziang Lu'
from abc import ABC, abstractmethod
from product_button import... | code_fim | hard | {
"lang": "python",
"repo": "Ziang-Lu/Design-Patterns",
"path": "/2-Creational Patterns/1-Factory Method Pattern & Abstract Factory Pattern/GUI Example/Python/factory.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if not hasattr(cls, '_instance'):
cls._instance = super().__new__(cls)
return cls._instance
def create_button(self):
return WinButton()<|fim_prefix|># repo: Ziang-Lu/Design-Patterns path: /2-Creational Patterns/1-Factory Method Pattern & Abstract Factory Pattern/G... | code_fim | hard | {
"lang": "python",
"repo": "Ziang-Lu/Design-Patterns",
"path": "/2-Creational Patterns/1-Factory Method Pattern & Abstract Factory Pattern/GUI Example/Python/factory.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: shell-drick/midifiles path: /py/src/MIDI/Events/messages/__init__.py
from .notes import NoteMessage, PressureMessage
f<|fim_suffix|>ve import SystemMessage
from .other import ProgramMessage, ChannelPressureMessage, PitchBendMessage<|fim_middle|>rom .controls import ControlMessage
from .exclusi | code_fim | easy | {
"lang": "python",
"repo": "shell-drick/midifiles",
"path": "/py/src/MIDI/Events/messages/__init__.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>mMessage, ChannelPressureMessage, PitchBendMessage<|fim_prefix|># repo: shell-drick/midifiles path: /py/src/MIDI/Events/messages/__init__.py
from .notes import NoteMessage, PressureMessage
f<|fim_middle|>rom .controls import ControlMessage
from .exclusive import SystemMessage
from .other import Progra | code_fim | medium | {
"lang": "python",
"repo": "shell-drick/midifiles",
"path": "/py/src/MIDI/Events/messages/__init__.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: virtru-ops/salt-verifier path: /tests/manual-test.py
from saltverifier.client import is_valid_server_public_key
<|fim_suffix|>if __name__ == '__main__':
main()<|fim_middle|>
def main():
result = is_valid_server_public_key('tcp://127.0.0.1:4533', open('tests/fixtures/test-bad-pub.pem').re... | code_fim | hard | {
"lang": "python",
"repo": "virtru-ops/salt-verifier",
"path": "/tests/manual-test.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if result:
print "Worked"
else:
print "Didn't work"
if __name__ == '__main__':
main()<|fim_prefix|># repo: virtru-ops/salt-verifier path: /tests/manual-test.py
from saltverifier.client import is_valid_server_public_key
<|fim_middle|>def main():
result = is_valid_server_... | code_fim | medium | {
"lang": "python",
"repo": "virtru-ops/salt-verifier",
"path": "/tests/manual-test.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ischeinkman/Server-Wall path: /server/config.py
from Crypto.Hash import SHA256
from time import gmtime, strftime
def _parseFile(name):
cfg = open(name, 'r')
paramList = [x.replace(' ','') for x in cfg.read().split('\n') if len(x) > 0]
prmMap = {}
for prm in paramList:
key... | code_fim | hard | {
"lang": "python",
"repo": "ischeinkman/Server-Wall",
"path": "/server/config.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def __init__(self, fileName='CONFIG.txt'):
self.setUp(fileName)
def setUp(self, fileName):
prmMap = _parseFile(fileName)
self.password = prmMap['password']
self._key = (prmMap['key'])
self.ip = prmMap['ip']
self.port = int(prmMap['port'])
... | code_fim | medium | {
"lang": "python",
"repo": "ischeinkman/Server-Wall",
"path": "/server/config.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def weights_init(self, m):
if isinstance(m, nn.Bilinear):
torch.nn.init.xavier_uniform_(m.weight.data)
if m.bias is not None:
m.bias.data.fill_(0.0)
def forward(self, c1, c2, h1, h2, h3, h4):
c_x1 = torch.unsqueeze(c1, 1)
c_x1 = c_x1... | code_fim | hard | {
"lang": "python",
"repo": "Shiguang-Guo/cogdl",
"path": "/cogdl/models/nn/mvgrl.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Shiguang-Guo/cogdl path: /cogdl/models/nn/mvgrl.py
import networkx as nx
import numpy as np
import scipy.sparse as sp
import torch
import torch.nn as nn
from scipy.linalg import fractional_matrix_power, inv
from sklearn.preprocessing import MinMaxScaler
from .. import BaseModel, register_model
f... | code_fim | hard | {
"lang": "python",
"repo": "Shiguang-Guo/cogdl",
"path": "/cogdl/models/nn/mvgrl.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: MrCorba/AbletonScripts path: /AbletonScripts/Sysex.py
import Live
class Sysex:
CLIP = [0, 0]
SCENE = [0, 1]
TRACK = [0, 2]
CLIP_POSITION = [0, 8]
TRACK_METERS = [0, 9]
SET_OFFSETS = [0, 10]
TRACK_DEVICE_NAME = [0, 11]
SET_WIDTH = [0, 12]
SNAPSHOT_STATES = [0, ... | code_fim | hard | {
"lang": "python",
"repo": "MrCorba/AbletonScripts",
"path": "/AbletonScripts/Sysex.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class SysexParser:
def __init__(self, msg):
self._msg = msg
def _int(self, start):
if start < len(self._msg) - 1:
return (self._msg[start] << 7) + self._msg[start + 1]
else:
return 0
def _byte(self, id):
if id < len(self._msg):
... | code_fim | hard | {
"lang": "python",
"repo": "MrCorba/AbletonScripts",
"path": "/AbletonScripts/Sysex.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> branch = self.bn(self.conv(x))
out = torch.max(x, branch)
return out
if __name__ == "__main__":
m = FReLU(32)
inten = torch.randn(4, 32, 224, 224)
out = m(inten)
print(out.size())<|fim_prefix|># repo: CoinCheung/pytorch-loss path: /pytorch_loss/frelu.py
import ... | code_fim | hard | {
"lang": "python",
"repo": "CoinCheung/pytorch-loss",
"path": "/pytorch_loss/frelu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>if __name__ == "__main__":
m = FReLU(32)
inten = torch.randn(4, 32, 224, 224)
out = m(inten)
print(out.size())<|fim_prefix|># repo: CoinCheung/pytorch-loss path: /pytorch_loss/frelu.py
import torch
import torch.nn as nn
class FReLU(nn.Module):
def __init__(self, in_chan):
<|fim_m... | code_fim | hard | {
"lang": "python",
"repo": "CoinCheung/pytorch-loss",
"path": "/pytorch_loss/frelu.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: CoinCheung/pytorch-loss path: /pytorch_loss/frelu.py
import torch
import torch.nn as nn
class FReLU(nn.Module):
<|fim_suffix|> super(FReLU, self).__init__()
self.conv = nn.Conv2d(in_chan, in_chan, 3, 1, 1, groups=in_chan)
self.bn = nn.BatchNorm2d(in_chan)
nn.in... | code_fim | medium | {
"lang": "python",
"repo": "CoinCheung/pytorch-loss",
"path": "/pytorch_loss/frelu.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def get_results():
"""Parse all search result pages."""
# store info in a dictionary {name -> shortname}
res = {}
session = requests.Session()
handle_url('http://www.gocomics.com/features', session, res)
handle_url('http://www.gocomics.com/explore/editorial_list', session, res)
... | code_fim | hard | {
"lang": "python",
"repo": "Manabi/dosage",
"path": "/scripts/gocomics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Parse all search result pages."""
# store info in a dictionary {name -> shortname}
res = {}
session = requests.Session()
handle_url('http://www.gocomics.com/features', session, res)
handle_url('http://www.gocomics.com/explore/editorial_list', session, res)
handle_url('http:/... | code_fim | hard | {
"lang": "python",
"repo": "Manabi/dosage",
"path": "/scripts/gocomics.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Manabi/dosage path: /scripts/gocomics.py
#!/usr/bin/env python
# Copyright (C) 2012-2014 Bastian Kleineidam
"""
Script to get a list of gocomics and save the info in a JSON file for further processing.
"""
from __future__ import print_function
import codecs
import re
import sys
import os
import r... | code_fim | hard | {
"lang": "python",
"repo": "Manabi/dosage",
"path": "/scripts/gocomics.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def createUser():
conn, cursor = open()
cursor.execute("DROP table if EXISTS user")
cursor.execute('''create table user (
id INT(11) primary key not null unique auto_increment,
name VARCHAR(45),
isAdmin VARCHAR(45),
regTime DATE,
password VARCHAR(45)
)''')
close(conn, cursor)
return
... | code_fim | hard | {
"lang": "python",
"repo": "Daniel-TheProgrammer/C_Blog",
"path": "/C_Blog/db.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Daniel-TheProgrammer/C_Blog path: /C_Blog/db.py
# encoding:utf-8 -*-
import hashlib
import MySQLdb
import sys
import datetime
reload(sys)
sys.setdefaultencoding("utf-8")
host = "127.0.0.1"
user = "root"
password = "root"
database = "Blog"
charset = "utf8"
def open():
conn = MySQLdb.connec... | code_fim | hard | {
"lang": "python",
"repo": "Daniel-TheProgrammer/C_Blog",
"path": "/C_Blog/db.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: abhaikollara/light path: /light/ast.py
class Statement:
pass
class Expression:
pass
class Program():
def __init__(self, statements):
self.statements = statements
def __getitem__(self, idx):
return self.statements[idx]
class Block(Statement):
def __i... | code_fim | hard | {
"lang": "python",
"repo": "abhaikollara/light",
"path": "/light/ast.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
class BoolLiteral(Expression):
def __init__(self, token):
self.token = token
self.literal = self.token.literal
def __repr__(self):
return f"BoolLiteral({repr(self.literal)})"
class StringLiteral(Expression):
def __init__(self, literal):
self.token = token
... | code_fim | hard | {
"lang": "python",
"repo": "abhaikollara/light",
"path": "/light/ast.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @staticmethod
def _append_sentence_start_and_end_tokens(tokenized_corpus):
return [['SENTENCE_START'] + sentence + ['SENTENCE_END'] for sentence in tokenized_corpus]
class _RNNTrainingData:
def __init__(self, tokenized_corpus):
self.training_data_as_tokens = tokenized_corpus... | code_fim | medium | {
"lang": "python",
"repo": "cavaunpeu/vanilla-neural-nets",
"path": "/vanilla_neural_nets/recurrent_neural_network/training_data.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: cavaunpeu/vanilla-neural-nets path: /vanilla_neural_nets/recurrent_neural_network/training_data.py
from collections import namedtuple
import itertools
import nltk
class WordLevelRNNTrainingDataBuilder:
UNKNOWN_TOKEN = 'UNKNOWN_TOKEN'
NUMBER_OF_WORDS_TO_ADD_IN_MANUALLY = len(['UNKNOWN_T... | code_fim | hard | {
"lang": "python",
"repo": "cavaunpeu/vanilla-neural-nets",
"path": "/vanilla_neural_nets/recurrent_neural_network/training_data.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>cargo[1]))
print("debug: with weight: {}".format(cargo[1]))
cargo_hold.append(cargo[0])
cargo_weight += cargo[1]<|fim_prefix|># repo: adityasurana/Programming-Notes path: /load bearing capicity.py
manifest = [["bananas", 15], ["mattresses", 34], ["dog kennels",42], ["machine th... | code_fim | medium | {
"lang": "python",
"repo": "adityasurana/Programming-Notes",
"path": "/load bearing capicity.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: adityasurana/Programming-Notes path: /load bearing capicity.py
manifest = [["bananas", 15], ["mattresses", 34], ["dog kennels",42], ["machine that goes ping!", 120], ["tea chests", 10], ["cheeses", 0]]
cargo_weight = 0
cargo_hold = []
for cargo in manifest:
print("debug: the weight is c... | code_fim | medium | {
"lang": "python",
"repo": "adityasurana/Programming-Notes",
"path": "/load bearing capicity.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sess = tf.get_default_session()
return sess.run([self.probs, self.sample, self.vf] + self.state_out,
{self.x: [ob], self.state_in[0]: c, self.state_in[1]: h})
def value(self, ob, c, h):
sess = tf.get_default_session()
return sess.run(self.vf, {s... | code_fim | hard | {
"lang": "python",
"repo": "pde/noreward-rl",
"path": "/src/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> sess = tf.get_default_session()
return sess.run(self.vf, {self.x: [ob], self.state_in[0]: c, self.state_in[1]: h})[0]
class StateActionPredictor(object):
def __init__(self, ob_space, ac_space, designHead='universe'):
# input: s1,s2: : [None, h, w, ch] (usually ch=1 or 4)
... | code_fim | hard | {
"lang": "python",
"repo": "pde/noreward-rl",
"path": "/src/model.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pde/noreward-rl path: /src/model.py
r(shape, dtype=None, partition_info=None):
out = np.random.randn(*shape).astype(np.float32)
out *= std / np.sqrt(np.square(out).sum(axis=0, keepdims=True))
return tf.constant(out)
return _initializer
def cosineLoss(A, B, name):
... | code_fim | hard | {
"lang": "python",
"repo": "pde/noreward-rl",
"path": "/src/model.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: methane/sandbox path: /2019/ordered-set/bm_set.py
"""Script for testing the performance of pickling/unpickling.
This will pickle/unpickle several real world-representative objects a few
thousand times. The methodology below was chosen for was chosen to be similar
to real-world scenarios which o... | code_fim | hard | {
"lang": "python",
"repo": "methane/sandbox",
"path": "/2019/ordered-set/bm_set.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> L = [f"s{i}" for i in range(n)]
range_it = range(loops)
t0 = perf.perf_counter()
for _ in range_it:
set(L)
set(L)
set(L)
set(L)
set(L)
set(L)
set(L)
set(L)
set(L)
set(L)
return perf.perf_counter() - t0
... | code_fim | hard | {
"lang": "python",
"repo": "methane/sandbox",
"path": "/2019/ordered-set/bm_set.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>def mishit(loops, n):
range_it = range(loops)
s = set(f"s{i}" for i in range(n))
t0 = perf.perf_counter()
for _ in range_it:
"ss" in s
"ss" in s
"ss" in s
"ss" in s
"ss" in s
"ss" in s
"ss" in s
"ss" in s
"ss" in s
... | code_fim | hard | {
"lang": "python",
"repo": "methane/sandbox",
"path": "/2019/ordered-set/bm_set.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> for r in range(0, len(renderers)):
LabelMapper = vtk.vtkPolyDataMapper()
LabelMapper.SetInputConnection(TextSrc.GetOutputPort())
LabelActor = vtk.vtkFollower()
LabelActor.SetMapper(LabelMapper)
LabelActor.SetPosition(x, y, z)
LabelActor.SetScale(2, 2, 2... | code_fim | hard | {
"lang": "python",
"repo": "moezb/opensimQt",
"path": "/VTKbook/SupplementaryCode/Chapter12/Stocks1.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: moezb/opensimQt path: /VTKbook/SupplementaryCode/Chapter12/Stocks1.py
#!/usr/bin/env python
import os
import vtk
def main():
colors = vtk.vtkNamedColors()
fileNames = ['GE.vtk', 'GM.vtk', 'IBM.vtk', 'DEC.vtk']
# Set up the stocks
renderers = list()
topRenderer = vtk.vtkRe... | code_fim | hard | {
"lang": "python",
"repo": "moezb/opensimQt",
"path": "/VTKbook/SupplementaryCode/Chapter12/Stocks1.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: bopopescu/nova-token path: /nova/wsgi.py
\n'
DECL|member|__init__
name|'def'
name|'__init__'
op|'('
name|'self'
op|','
name|'name'
op|','
name|'app'
op|','
name|'host'
op|'='
string|"'0.0.0.0'"
op|','
name|'port'
op|'='
number|'0'
op|','
name|'pool_size'
op|'='
name|'None'
op|','
nl|'\n'
name|'pr... | code_fim | hard | {
"lang": "python",
"repo": "bopopescu/nova-token",
"path": "/nova/wsgi.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> '
name|'response'
op|'='
name|'self'
op|'.'
name|'process_request'
op|'('
name|'req'
op|')'
newline|'\n'
name|'if'
name|'response'
op|':'
newline|'\n'
indent|' '
name|'return'
name|'response'
newline|'\n'
dedent|''
name|'response'
op|'='
name|'req'
op|'.'
name|'get_response'
op|'('
name|'se... | code_fim | hard | {
"lang": "python",
"repo": "bopopescu/nova-token",
"path": "/nova/wsgi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>wsgi'
op|'.'
name|'secure_proxy_ssl_header'
op|')'
newline|'\n'
name|'if'
name|'scheme'
op|':'
newline|'\n'
indent|' '
name|'environ'
op|'['
string|"'wsgi.url_scheme'"
op|']'
op|'='
name|'scheme'
newline|'\n'
dedent|''
dedent|''
name|'super'
op|'('
name|'Request'
op|','
name|'self'
op|')'
o... | code_fim | hard | {
"lang": "python",
"repo": "bopopescu/nova-token",
"path": "/nova/wsgi.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ChenhaoJiang/LeetCode-Solution path: /51-100/61_rotate_list.py
"""
Given a linked list, rotate the list to the right by k places, where k is non-negative.
Example 1:
Input: 1->2->3->4->5->NULL, k = 2
Output: 4->5->1->2->3->NULL
Explanation:
rotate 1 steps to the right: 5->1->2->3->4->NULL
rotate ... | code_fim | medium | {
"lang": "python",
"repo": "ChenhaoJiang/LeetCode-Solution",
"path": "/51-100/61_rotate_list.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def rotateRight(self, head, k):
"""
:type head: ListNode
:type k: int
:rtype: ListNode
"""
# 特殊情况
if not head:
return None
if not head.next:
return head
old_tail = head
# 用来统计链表的长度
length = ... | code_fim | medium | {
"lang": "python",
"repo": "ChenhaoJiang/LeetCode-Solution",
"path": "/51-100/61_rotate_list.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: JasperJuergensen/elastalert path: /elastalert/ruletypes/ruletype.py
import copy
from abc import ABCMeta
from datetime import datetime
from typing import Dict, List
from deprecated import deprecated
from elastalert.rule import Rule
from elastalert.utils.time import dt_to_ts
class RuleType(Rule,... | code_fim | hard | {
"lang": "python",
"repo": "JasperJuergensen/elastalert",
"path": "/elastalert/ruletypes/ruletype.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> :param terms: A list of buckets with a key, corresponding to query_key, and the count """
raise NotImplementedError()
@deprecated
def add_aggregation_data(self, payload):
""" Gets called when a rule has use_terms_query set to True.
:param terms: A list of buckets w... | code_fim | hard | {
"lang": "python",
"repo": "JasperJuergensen/elastalert",
"path": "/elastalert/ruletypes/ruletype.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # For each secondary_id
for dupid in dup_ids:
duplicates = peak_df[peak_df['sec_id'] == dupid]
for index, row in duplicates.iterrows():
name = row['compound']
adduct = row['adduct']
name_match = peak_df['compound']... | code_fim | hard | {
"lang": "python",
"repo": "kmcluskey/FlyOmics",
"path": "/met_explore/peak_selection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> for index, row in dup_peaks.iterrows():
dup_indexes.append(index)
name_rt_dict[index] = [row['compound'], row['rt']]
keep_index = self.get_closest_rt_match(name_rt_dict)
peak_df = self.drop_duplicates(dup_indexes, keep_index, peak_df)
... | code_fim | hard | {
"lang": "python",
"repo": "kmcluskey/FlyOmics",
"path": "/met_explore/peak_selection.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: kmcluskey/FlyOmics path: /met_explore/peak_selection.py
_df[self.selected_df.sec_id == sid]
print("The single SID DF is")
display(sid_df)
# If the peak has an identified compound then keep that
identified_df = sid_df[sid_df.identified == 'True']
... | code_fim | hard | {
"lang": "python",
"repo": "kmcluskey/FlyOmics",
"path": "/met_explore/peak_selection.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> return "<User(username='%s', email='%s')>" \
% (self.username, self.email)
class UserSchema(Schema):
username = fields.String()
email = fields.String()
registered = fields.DateTime(dump_only=True)
tasks = fields.List(fields.Nested(TaskSchema))
user_schema = User... | code_fim | medium | {
"lang": "python",
"repo": "mradzikowski/flask-trackerproductivity",
"path": "/backend/models/user.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: mradzikowski/flask-trackerproductivity path: /backend/models/user.py
from datetime import date
from marshmallow import Schema, fields
from backend.extensions import db
from .task import TaskSchema
<|fim_suffix|> __tablename__ = 'users'
username = db.Column(db.String(50), primary_key=... | code_fim | medium | {
"lang": "python",
"repo": "mradzikowski/flask-trackerproductivity",
"path": "/backend/models/user.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> username = fields.String()
email = fields.String()
registered = fields.DateTime(dump_only=True)
tasks = fields.List(fields.Nested(TaskSchema))
user_schema = UserSchema()
users_schema = UserSchema(many=True)<|fim_prefix|># repo: mradzikowski/flask-trackerproductivity path: /backend/model... | code_fim | hard | {
"lang": "python",
"repo": "mradzikowski/flask-trackerproductivity",
"path": "/backend/models/user.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: rwst/wikidata-molbio path: /old-code/enzfam-wrong-broad.py
import pronto, six, csv
from sys import *
"""
For all items with broad molfunc, and not being an InterPro family:
SELECT DISTINCT ?p ?pLabel ?funcLabel ?go
{
?p p:P680 [ ps:P680 ?func; pq:P4390 wd:Q39894595; ].
MINUS {
?... | code_fim | medium | {
"lang": "python",
"repo": "rwst/wikidata-molbio",
"path": "/old-code/enzfam-wrong-broad.py",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> term = ont.get(goid)
if term is None:
#print(goid)
continue
d = term.name.replace(' activity', '')
#print('{} "{}" "{}"'.format(goid, term.name, lab))
if reduce(d) == lab:
print('---{} "{}"'.format(qit, d))
continue
for s in list(term.synonyms):
... | code_fim | hard | {
"lang": "python",
"repo": "rwst/wikidata-molbio",
"path": "/old-code/enzfam-wrong-broad.py",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: antmont/wmda-stuff path: /wmdadict/filters.py
import django_filters
from .models import DictionaryField, EmdisField, EmdisMessage, BmdwField
from .models import WmdaForm, FormFields
class DictionaryFilter(django_filters.FilterSet):
label = django_filters.CharFilter(lookup_expr='icontains')
... | code_fim | hard | {
"lang": "python",
"repo": "antmont/wmda-stuff",
"path": "/wmdadict/filters.py",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> field_identifier = django_filters.CharFilter(name='field_identifier',
lookup_expr='icontains',
)
dict_field = django_filters.CharFilter(name='dict_field__label',
... | code_fim | hard | {
"lang": "python",
"repo": "antmont/wmda-stuff",
"path": "/wmdadict/filters.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> model = BmdwField
fields = ['field_identifier', 'dict_field', 'type',]
class WmdaFormFilter(django_filters.FilterSet):
form_code = django_filters.CharFilter(name='form_code',
lookup_expr='icontains')
description = django_filters.CharFilte... | code_fim | hard | {
"lang": "python",
"repo": "antmont/wmda-stuff",
"path": "/wmdadict/filters.py",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> game = gamestate.new_game(boardsize)
while not game.is_over():
if (game.next_player in human_players):
interface.printboard(game.board, COL_NAMES)
user_input = input(game.next_player.name + ' move - ')
human_move = interface.checkcode(user_input)
... | code_fim | hard | {
"lang": "python",
"repo": "starxcf/chinese-checkers-ai",
"path": "/OurApproach/gameplay/playbase.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: starxcf/chinese-checkers-ai path: /OurApproach/gameplay/playbase.py
# -*- coding: utf-8 -*-
"""
Player abstraction base class
@author: Sean
"""
__all__ = [
'Point',
'MoveType',
'Move',
'play',
]
import sys,enum
from collections import namedtuple
from gameplay.playerbase imp... | code_fim | hard | {
"lang": "python",
"repo": "starxcf/chinese-checkers-ai",
"path": "/OurApproach/gameplay/playbase.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> boardsize=4, intercative=False):
assert(player1 != player2)
human_players = []
ai_players = []
if player1.isHuman():
human_players.append(player1.playerside)
else:
ai_players.append(player1.playerside)
if player2.isHuman():
human_players.ap... | code_fim | hard | {
"lang": "python",
"repo": "starxcf/chinese-checkers-ai",
"path": "/OurApproach/gameplay/playbase.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: pstch/pylxd path: /pylxd/deprecated/tests/test_network.py
# Copyright (c) 2015 Canonical Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http:/... | code_fim | hard | {
"lang": "python",
"repo": "pstch/pylxd",
"path": "/pylxd/deprecated/tests/test_network.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> @annotated_data(
('name', 'lxcbr0'),
('type', 'bridge'),
('members', ['/1.0/containers/trusty-1']),
)
def test_network_data(self, method, expected, ms):
self.assertEqual(
expected, getattr(self.lxd,
'network_show_' + met... | code_fim | hard | {
"lang": "python",
"repo": "pstch/pylxd",
"path": "/pylxd/deprecated/tests/test_network.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Jollyhrothgar/graphs path: /graphs/graph.py
import copy
class Graph(object):
def __init__(self, graph_dict=None):
<|fim_suffix|> def add_node(self, node_id, data=None, connections=[]):
if node not in self.graph_dict:
self.graph_dict
print(hash(lambda x: x - 1))
pri... | code_fim | medium | {
"lang": "python",
"repo": "Jollyhrothgar/graphs",
"path": "/graphs/graph.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>print(hash(g1))
print(hash(g2))
print(hash(-1))
val = -1
print(hash(val))<|fim_prefix|># repo: Jollyhrothgar/graphs path: /graphs/graph.py
import copy
class Graph(object):
def __init__(self, graph_dict=None):
if graph_dict is None:
self.graph_dict = {}
else:
... | code_fim | medium | {
"lang": "python",
"repo": "Jollyhrothgar/graphs",
"path": "/graphs/graph.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: indeedeng/django-ptrack path: /ptrack/exceptions.py
class PtrackError(Exception):
<|fim_suffix|>
class PtrackRegistrationError(PtrackError):
"""Error raised when Ptrack tracking pixel fails to register."""<|fim_middle|> """Base class for errors raised in Ptrack."""
| code_fim | easy | {
"lang": "python",
"repo": "indeedeng/django-ptrack",
"path": "/ptrack/exceptions.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> """Error raised when Ptrack tracking pixel fails to register."""<|fim_prefix|># repo: indeedeng/django-ptrack path: /ptrack/exceptions.py
class PtrackError(Exception):
<|fim_middle|> """Base class for errors raised in Ptrack."""
class PtrackRegistrationError(PtrackError):
| code_fim | medium | {
"lang": "python",
"repo": "indeedeng/django-ptrack",
"path": "/ptrack/exceptions.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: indeedeng/django-ptrack path: /ptrack/exceptions.py
class PtrackError(Exception):
"""Base class for errors raised in Ptrack."""
<|fim_suffix|> """Error raised when Ptrack tracking pixel fails to register."""<|fim_middle|>class PtrackRegistrationError(PtrackError):
| code_fim | easy | {
"lang": "python",
"repo": "indeedeng/django-ptrack",
"path": "/ptrack/exceptions.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: openstack/tacker path: /tacker/tests/functional/legacy/vnfm/test_tosca_vnfc.py
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/... | code_fim | hard | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/tests/functional/legacy/vnfm/test_tosca_vnfc.py",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> # Check the status of SoftwareDeployment
heat_stack_id = self.client.show_vnf(vnf_id)['vnf']['instance_id']
resource_types = self.h_client.resources
resources = resource_types.list(stack_id=heat_stack_id)
for resource in resources:
resource = resource.to... | code_fim | hard | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/tests/functional/legacy/vnfm/test_tosca_vnfc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>
from tacker.common import utils
from tacker.plugins.common import constants as evt_constants
from tacker.tests import constants
from tacker.tests.functional import base
from tacker.tests.utils import read_file
from tacker.tosca import utils as toscautils
CONF = cfg.CONF
SOFTWARE_DEPLOYMENT = 'OS::Heat::... | code_fim | hard | {
"lang": "python",
"repo": "openstack/tacker",
"path": "/tacker/tests/functional/legacy/vnfm/test_tosca_vnfc.py",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: Onapsis/pgdiff path: /pgdiff/parser/Parser.py
class Parser(object):
def __init__(self, statement):
self.position = 0
self.statement = statement
# Checks whether the string contains given word on current position. If not
# then throws an exception.
def expect(self,... | code_fim | hard | {
"lang": "python",
"repo": "Onapsis/pgdiff",
"path": "/pgdiff/parser/Parser.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> names = ParserUtils.split_names(name)
return names[len(names) - 3] if len(names) >= 3 else None
@staticmethod
def split_names(string):
if string.find('"') == -1:
return string.split(".")
else:
strings = []
start_pos = 0
... | code_fim | hard | {
"lang": "python",
"repo": "Onapsis/pgdiff",
"path": "/pgdiff/parser/Parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> def skip_whitespace(self):
for self.position in range(self.position, len(self.statement)):
if not self.statement[self.position].isspace():
break
self.position += 1
def throw_unsupported_command(self):
raise Exception('Cannot parse string: %s... | code_fim | hard | {
"lang": "python",
"repo": "Onapsis/pgdiff",
"path": "/pgdiff/parser/Parser.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>unit = run_length_arg[-1]
secs = to_f_or_i(run_length_arg[:-1])
if unit == 'm':
secs = secs * 60
print "Will contanct dagger at {}.".format(os.environ.get('DAGGER_URL'))
print "Will run for {} seconds.".format(secs)
curr = 0
start_time = curr_time = time.time()
last_print = start_time - 1.001
elapsed_... | code_fim | medium | {
"lang": "python",
"repo": "tylernm14/donut-dagger",
"path": "/wrapper/python/timer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: tylernm14/donut-dagger path: /wrapper/python/timer.py
#!/usr/local/bin/python -u
import json
import sys
import os
import time
#usage ./timer.py 2s | ./timer.py 2m | ./timer.py 2.5m
def to_f_or_i(v):
<|fim_suffix|>curr = 0
start_time = curr_time = time.time()
last_print = start_time - 1.001
ela... | code_fim | hard | {
"lang": "python",
"repo": "tylernm14/donut-dagger",
"path": "/wrapper/python/timer.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>curr = 0
start_time = curr_time = time.time()
last_print = start_time - 1.001
elapsed_time = 0
while elapsed_time <= secs:
curr_time = time.time()
if curr_time - last_print >= 1:
print "Running for {} seconds...".format(elapsed_time)
last_print = time.time()
curr_time = time.time()
elapse... | code_fim | hard | {
"lang": "python",
"repo": "tylernm14/donut-dagger",
"path": "/wrapper/python/timer.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: OnoKishio/Applied-Computational-Thinking-with-Python path: /Chapter08/ch8_Iterations.py
jewelry = ['ring', 'watch', 'necklace', 'earrings',<|fim_suffix|> print("Type of jewelry: %s in %s color. " %(j, c))<|fim_middle|> 'bracelets']
colors = ['gold', 'silver', 'blue', 'red', 'black']
for j, c i... | code_fim | medium | {
"lang": "python",
"repo": "OnoKishio/Applied-Computational-Thinking-with-Python",
"path": "/Chapter08/ch8_Iterations.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> print("Type of jewelry: %s in %s color. " %(j, c))<|fim_prefix|># repo: OnoKishio/Applied-Computational-Thinking-with-Python path: /Chapter08/ch8_Iterations.py
jewelry = ['ring', 'watch', 'necklace', 'earrings', 'bracelets']
colors = ['gold', 'silver', 'blue', '<|fim_middle|>red', 'black']
for j, c i... | code_fim | easy | {
"lang": "python",
"repo": "OnoKishio/Applied-Computational-Thinking-with-Python",
"path": "/Chapter08/ch8_Iterations.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#c = c | p
c = c.configure_view(strokeWidth=6.0, height=400, width=800)
save(c, "switch_throughput.svg")
#
server = pd.read_csv('../tcp_goodput_server_usnetd:usnet_sockets/last')
# usnetd:
c = Chart(server).mark_bar().encode(color=Color("Socket API:N"), x=X("Socket API:N", axis=Axis(labels=False, title=... | code_fim | hard | {
"lang": "python",
"repo": "ANLAB-KAIST/usnetd",
"path": "/eval/graphs/render",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ANLAB-KAIST/usnetd path: /eval/graphs/render
#!/usr/bin/env python3.6
import sh
from altair import *
def save(chart, fpath):
chart.save(fpath, format="svg")
with open(fpath) as f:
s = f.read()
with open(fpath, "w") as f:
s = s.replace("sans-serif", "TeX Gyre Pagella").replace("font... | code_fim | hard | {
"lang": "python",
"repo": "ANLAB-KAIST/usnetd",
"path": "/eval/graphs/render",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|># macvtap:
multi_mv = pd.read_csv('../tcp_goodput_server_macvtap:usnet_sockets/last')
single_mv = pd.read_csv('../tcp_goodput_server_macvtap:usnet_sockets (no BGT)/last')
smoltcp_mv = pd.read_csv('../tcp_goodput_server_macvtap:smoltcp/last')
d = pd.concat([multi_mv, single_mv, smoltcp_mv])
# direct:
c = C... | code_fim | hard | {
"lang": "python",
"repo": "ANLAB-KAIST/usnetd",
"path": "/eval/graphs/render",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> operations = [
migrations.AlterModelOptions(
name="element_repozytorium",
options={
"verbose_name": "element repozytorium",
"verbose_name_plural": "elementy repozytorium",
},
),
migrations.CreateModel(
... | code_fim | hard | {
"lang": "python",
"repo": "iplweb/bpp",
"path": "/src/bpp/migrations/0224_auto_20201007_0956.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: iplweb/bpp path: /src/bpp/migrations/0224_auto_20201007_0956.py
# Generated by Django 3.0.9 on 2020-10-07 07:56
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
<|fim_suffix|> operations = [
migrations.AlterModelOption... | code_fim | hard | {
"lang": "python",
"repo": "iplweb/bpp",
"path": "/src/bpp/migrations/0224_auto_20201007_0956.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>
def finish(threads):
signal.pause()
print('Please wait while data is being saved')
# Wait for threads to complete
for t in threads:
t.join()
def train_function(env, i, session, data, summary, saver):
# Get the current thread object and attach the game env and state to it
... | code_fim | hard | {
"lang": "python",
"repo": "ZeroNilZero/A3C-CarRacingGym",
"path": "/Scripts/oguzelibol-CarRacingA3C/a3c.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> network = GameACFFNetwork(Constants.ACTION_SIZE, device)
grad_applier = RMSPropApplier(learning_rate = learning_rate_input,
decay = Constants.RMSP.ALPHA,
epsilon = Constants.RMSP.EPSILON,
... | code_fim | hard | {
"lang": "python",
"repo": "ZeroNilZero/A3C-CarRacingGym",
"path": "/Scripts/oguzelibol-CarRacingA3C/a3c.py",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|># repo: ZeroNilZero/A3C-CarRacingGym path: /Scripts/oguzelibol-CarRacingA3C/a3c.py
#!/usr/bin/python
# Call XInitThreads as the _very_ first thing.
# After some Qt import, it's too late
import ctypes
import sys
if sys.platform.startswith('linux'):
try:
x11 = ctypes.cdll.LoadLibrary('libX11.s... | code_fim | hard | {
"lang": "python",
"repo": "ZeroNilZero/A3C-CarRacingGym",
"path": "/Scripts/oguzelibol-CarRacingA3C/a3c.py",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.assertEquals(newTransput('ftp') , FTPTransput)
self.assertEquals(newTransput('http') , HTTPTransput)
self.assertEquals(newTransput('https') , HTTPTransput)
self.assertEquals(newTransput('file') , FileTransput)
self.assertThrows( lambda: newTransput('svn')
... | code_fim | hard | {
"lang": "python",
"repo": "cibinsb/tesk-core",
"path": "/tests/test_filer.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.