Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Given snippet: <|code_start|>
class ScrollText(ArtBaseClass):
description = "Scroll text across the display"
fg = None
bg = None
def __init__(self, matrix, config):
self.config = config
self._initText()
self.thisMessage = self._getText()
self.nextMessage = self._getT... | self.typeface = OPCText(typeface_bbc) |
Based on the snippet: <|code_start|> self.amp = 0
self.mult = 1+sqrt(matrix.numpix/32)/90
self.train = ClearTrain(TRAIN_LEN)
def start(self, matrix):
matrix.clear()
def refresh(self, matrix):
# this relies on the fact that the pixels we seed get multiplied and
# ... | color = hsvToRgb(fmod(self.hue, 1), 1, 1) |
Based on the snippet: <|code_start|>
PENS = 4
SCALE = 3
SIZE = 6
class Blobs(ArtBaseClass):
def __init__(self, matrix, config):
<|code_end|>
, predict the immediate next line with the help of imports:
from .. _baseclass import ArtBaseClass
from random import random, uniform
from opc.matrix import HQ
from .. ... | with HQ(matrix): |
Given the following code snippet before the placeholder: <|code_start|>
class Art(ArtBaseClass):
description = "Dense Balistics"
def __init__(self, matrix, config):
<|code_end|>
, predict the next line using imports from the current file:
from ._baseclass import ArtBaseClass
from .utils.fire import Gun
an... | self.gun = Gun(matrix) |
Given the following code snippet before the placeholder: <|code_start|>
def start(self, matrix):
matrix.clear()
def _weightedAverage(self, v0, v1, percent):
return v0 + (v1-v0)*percent
def _bilinearInterp(self, gun, px, py):
xi0 = self._weightedAverage(gun[0], gun[1], px)
x... | rgbs = self._rotate([hsvToRgb(self.cornerValues[i]) for i in range(4)]) |
Here is a snippet: <|code_start|>
def _reset(self, matrix):
self.color = random()
self.y = matrix.height - 1 - self.radius
self.dy = -1.3
def refresh(self, matrix):
matrix.shift(ds=0.75, dv=0.9)
self.x = self.x + self.dx*self.dt
self.y = self.y + self.dy*self.dt... | hsvToRgb(self.color)) |
Continue the code snippet: <|code_start|> w = matrix.width*16
h = matrix.height*16
self.url = "http://lorempixel.com/%s/%d/" % (w, h)
self.image_active = None
self._load()
def start(self, matrix):
matrix.clear()
def _load(self):
self.image_loaded = None
... | self.image_loaded = Image(bytestream=r.content) |
Here is a snippet: <|code_start|>
GRIDSIZE = 8
C_BACKGROUND = (96, 64, 24)
C_BORDER = (128, 128, 128)
class Art(ArtBaseClass):
description = "A silly chess board"
def __init__(self, matrix, config):
<|code_end|>
. Write the next line using the current file imports:
from ._baseclass import ArtBaseClass
f... | self.hue = getHueGen(0.0005) |
Given the following code snippet before the placeholder: <|code_start|>C_BACKGROUND = (96, 64, 24)
C_BORDER = (128, 128, 128)
class Art(ArtBaseClass):
description = "A silly chess board"
def __init__(self, matrix, config):
self.hue = getHueGen(0.0005)
def start(self, matrix):
matrix.cle... | color = hsvToRgb(hue, s=0.7, v=0.5) |
Predict the next line after this snippet: <|code_start|>
class Art(Barber):
description = "Barber-pole-esque (dirty)"
def _line(self, matrix, x1, x2, hue):
for x in range(x1, x2):
val = 0.8 + 0.2*random()
<|code_end|>
using the current file's imports:
from .baseclasses.barber import B... | matrix.drawPixel(x, 0, hsvToRgb(hue, 1, val)) |
Predict the next line for this snippet: <|code_start|>
class Art(ArtBaseClass):
description = "Churning candy"
def __init__(self, matrix, config):
with HQ(matrix):
self.pieces = int(sqrt(matrix.numpix/2))
cycles = int(sqrt(matrix.numpix)*2)
<|code_end|>
with the help of cu... | self.shrapnel = [Shrapnel(matrix, cycles, saturation=random(), |
Given snippet: <|code_start|>
class Art(ArtBaseClass):
description = "Churning candy"
def __init__(self, matrix, config):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from ._baseclass import ArtBaseClass
from .utils.shrapnel import Shrapnel
from math import sqrt
from... | with HQ(matrix): |
Given snippet: <|code_start|>
self.y += self.dy
if self.y <= 0 or self.y >= (matrix.height-1):
self.dy = -self.dy
return self
class Vector(object):
def __init__(self, bases, color):
self.points = [Point(base.x, base.y, base.dx, base.dy)
for base... | huegen = getColorGen(step=0.15, hue=random()) |
Continue the code snippet: <|code_start|>class Art(ArtBaseClass):
description = "Loop the loop"
def __init__(self, matrix, config):
with HQ(matrix):
self.hue = 0
self.ang = 0
self.amp = 0
self.radius = sqrt(matrix.numpix)/16
def start(self, matrix):... | color = hsvToRgb(fmod(self.hue, 1), 1, 1) |
Given the code snippet: <|code_start|>
DELTA_AMP = 0.09
DELTA_ANG = 0.033
DELTA_HUE = 0.006
class Art(ArtBaseClass):
description = "Loop the loop"
def __init__(self, matrix, config):
<|code_end|>
, generate the next line using the imports in this file:
from ._baseclass import ArtBaseClass
from opc.hue im... | with HQ(matrix): |
Predict the next line after this snippet: <|code_start|>class Art(ArtBaseClass):
description = "Classic plasma (almost)"
def __init__(self, matrix, config):
ones = np.ones(matrix.numpix).reshape((matrix.height, matrix.width))
self.x = ones*np.arange(matrix.width)
self.y = np.flipud(np.... | rgb = h_to_rgb(hue) |
Predict the next line for this snippet: <|code_start|>
class Image(object):
def __init__(self, filename=None, bytestream=None):
if filename is not None:
image = PI.open(filename).rotate(-90, PI.BICUBIC).convert('RGB')
self.image = image
if bytestream is not None:
... | @timefunc |
Predict the next line after this snippet: <|code_start|>
HUEINCYCLES = 8
class Art(ArtBaseClass):
description = "Use an LFSR to 'randomly' fill the display"
def __init__(self, matrix, config):
pass
def start(self, matrix):
# we could probably shuffle() up a range, but that sounds like... | color = hsvToRgb(self.hue, 1, 0.2+0.8*random()) |
Using the snippet: <|code_start|>
HUEINCYCLES = 8
class Art(ArtBaseClass):
description = "Use an LFSR to 'randomly' fill the display"
def __init__(self, matrix, config):
pass
def start(self, matrix):
# we could probably shuffle() up a range, but that sounds like
# it'd be less... | self.random = compoundLfsr(matrix.numpix) |
Continue the code snippet: <|code_start|>from __future__ import division
stdscr = None # for flake8
def initCurses():
global stdscr
stdscr = curses.initscr()
curses.start_color()
curses.use_default_colors()
def exitCurses():
curses.endwin()
<|code_end|>
. Use current file imports:
import... | class Driver(RopDriver): |
Based on the snippet: <|code_start|> # lines that end 'ax' are approximations
curses.color_pair(curses.COLOR_BLACK),
curses.color_pair(curses.COLOR_BLUE),
curses.color_pair(curses.COLOR_BLUE)+curses.A_BOLD,
curses.color_pair(curses.COLOR_GRE... | @timefunc |
Given the code snippet: <|code_start|>
DTYPE = np.uint8
class OPCBuffer(object):
"""
Provdes primitive buffer-level storage and operations.
"""
<|code_end|>
, generate the next line using the imports in this file:
from PIL import Image, ImageFilter
from .colors import BLACK
from .utils.prof import tim... | @timefunc |
Given the code snippet: <|code_start|> self.astep = pi/48
self.hstep = pi/1024
self.radius = min(matrix.width, matrix.height)/2.2
self.x0 = matrix.width/2
self.y0 = matrix.height/2
def start(self, matrix):
matrix.clear()
def refresh(self, matrix):
matrix... | hsvToRgb(self.hue) |
Continue the code snippet: <|code_start|>
class Art(DiamondSquare):
description = "Thin plasma using DiamondSquare and colormap rotation"
def __init__(self, matrix, config):
super(Art, self).__init__(matrix, self.generate, maxticks=20,
interpolate=False)
<|code_end... | self.colormap = Colormap(130) |
Predict the next line for this snippet: <|code_start|> # if not getattr(f, 'editable', False):
# continue
if fields and not f.name in fields:
continue
if exclude and f.name in exclude:
continue
if isinstance(f, ManyToManyField):
# If the obj... | 'avatar': gravatar_url(user.email, AVATAR_WIDTH, AVATAR_HEIGHT, GRAVATAR_DEFAULT) |
Using the snippet: <|code_start|> # if not getattr(f, 'editable', False):
# continue
if fields and not f.name in fields:
continue
if exclude and f.name in exclude:
continue
if isinstance(f, ManyToManyField):
# If the object doesn't have a pr... | 'avatar': gravatar_url(user.email, AVATAR_WIDTH, AVATAR_HEIGHT, GRAVATAR_DEFAULT) |
Given snippet: <|code_start|> # if not getattr(f, 'editable', False):
# continue
if fields and not f.name in fields:
continue
if exclude and f.name in exclude:
continue
if isinstance(f, ManyToManyField):
# If the object doesn't have a primar... | 'avatar': gravatar_url(user.email, AVATAR_WIDTH, AVATAR_HEIGHT, GRAVATAR_DEFAULT) |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
class Command(BaseCommand):
args = '[port_number]'
help = 'Starts the Tornado application for message handling.'
def sig_handler(self, sig, frame):
"""Catch signal and init callback"""
tornado.ioloop.IOLoop.... | self.http_server = tornado.httpserver.HTTPServer(application) |
Predict the next line after this snippet: <|code_start|># test_io.py
#
# Author: R. Booth
# Date: 22 - May - 2018
#
# Test input / output routines
###############################################################################
def test_event_controller():
"""Tests that event controller correctly generates events""... | EC = Event_Controller(evens=t0, threes=t1) |
Predict the next line for this snippet: <|code_start|>
def read(self, filename):
"""Read disc data from file"""
# read the header
head = ''
vars = False
count = 0
with open(filename) as f:
for line in f:
if not vars:
if... | planets = Planets(Nchem) |
Given snippet: <|code_start|> f_max : maximum accretion rate relative to disc accretion rate,
default=0.8
Piso & Youdin parameters:
f_py : accretion rate fitting factor, default=0.2
kappa_env : envelope opacity [cm^2/g], default=0.06
rho_core ... | return make_ASCII_header(self.HDF5_attributes()) |
Based on the snippet: <|code_start|> self._Mdot_ext = restartdata['M_ext']
except ValueError:
pass
try:
self._Mdot_int = restartdata['M_int']
except ValueError:
pass
try:
self._Mcum_gas = restartdata['M_wg']
except ValueE... | self._times = np.append(self._times,[driver.t / yr]) |
Here is a snippet: <|code_start|># star.py
#
# Author: R. Booth
# Date: 8 - Nov - 2016
#
# Contains stellar properties classes
################################################################################
# Base class for all stars, implements general properties that should be
# common to all stars
class StarBase... | self._Rau = R*Rsun/AU |
Next line prediction: <|code_start|># star.py
#
# Author: R. Booth
# Date: 8 - Nov - 2016
#
# Contains stellar properties classes
################################################################################
# Base class for all stars, implements general properties that should be
# common to all stars
class StarB... | self._Rau = R*Rsun/AU |
Based on the snippet: <|code_start|> sys.path.append(KROME_PATH)
except KeyError:
raise ImportError("krome_chem module requires KROME_PATH environment "
"variable to be set")
# Alias for ctypes by reference
def byref(x): return ctypes.byref(ctypes.c_double(x))
# Setup the KROME Library
... | _krome_masses /= m_H |
Predict the next line for this snippet: <|code_start|># Load the names / masses from the KROME library and convert mass to internal
# units (Hydrogen masses)
_krome_names = np.array(_krome.krome_names[:_nmols])
_krome_masses = np.empty(_nmols, dtype='f8')
_krome.lib.krome_get_mass(_krome_masses)
_krome_masses /= m_H
#... | class KromeAbund(ChemicalAbund): |
Predict the next line for this snippet: <|code_start|>#
# Check behaviour of simple chemistry functions
###############################################################################
# CO chemistry
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi = Abundanc... | _test_chemical_model(Chem, SimpleCOAtomAbund) |
Given the following code snippet before the placeholder: <|code_start|># Author: R. Booth
# Date: 22 - May - 2018
#
# Check behaviour of simple chemistry functions
###############################################################################
# CO chemistry
# CNO chemistry
def _test_chemical_model(ChemModel, Abunda... | for Chem in [ SimpleCOChemMadhu, SimpleCOChemOberg, |
Continue the code snippet: <|code_start|># Date: 22 - May - 2018
#
# Check behaviour of simple chemistry functions
###############################################################################
# CO chemistry
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi... | EquilibriumCOChemMadhu, EquilibriumCOChemOberg,]: |
Using the snippet: <|code_start|># Author: R. Booth
# Date: 22 - May - 2018
#
# Check behaviour of simple chemistry functions
###############################################################################
# CO chemistry
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
... | for Chem in [ SimpleCOChemMadhu, SimpleCOChemOberg, |
Given the code snippet: <|code_start|># Date: 22 - May - 2018
#
# Check behaviour of simple chemistry functions
###############################################################################
# CO chemistry
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi = ... | EquilibriumCOChemMadhu, EquilibriumCOChemOberg,]: |
Given the code snippet: <|code_start|># CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi = Abundances(len(T))
Xi.set_solar_abundances()
Chem = ChemModel()
mol = Chem.equilibrium_chem(T, 1e-10, 0.01, Xi)
T *= 3
Chem.update(0, T,... | _test_chemical_model(Chem, SimpleCNOAtomAbund) |
Using the snippet: <|code_start|># CO chemistry
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi = Abundances(len(T))
Xi.set_solar_abundances()
Chem = ChemModel()
mol = Chem.equilibrium_chem(T, 1e-10, 0.01, Xi)
T *= 3
Chem.u... | for Chem in [ SimpleCNOChemMadhu, SimpleCNOChemOberg, |
Based on the snippet: <|code_start|>
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi = Abundances(len(T))
Xi.set_solar_abundances()
Chem = ChemModel()
mol = Chem.equilibrium_chem(T, 1e-10, 0.01, Xi)
T *= 3
Chem.update(0, T, ... | EquilibriumCNOChemMadhu, EquilibriumCNOChemOberg,]: |
Continue the code snippet: <|code_start|># CO chemistry
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi = Abundances(len(T))
Xi.set_solar_abundances()
Chem = ChemModel()
mol = Chem.equilibrium_chem(T, 1e-10, 0.01, Xi)
T *= 3
... | for Chem in [ SimpleCNOChemMadhu, SimpleCNOChemOberg, |
Continue the code snippet: <|code_start|>
# CNO chemistry
def _test_chemical_model(ChemModel, Abundances):
T = np.logspace(0.5, 3, 6)
Xi = Abundances(len(T))
Xi.set_solar_abundances()
Chem = ChemModel()
mol = Chem.equilibrium_chem(T, 1e-10, 0.01, Xi)
T *= 3
Chem.update(0... | EquilibriumCNOChemMadhu, EquilibriumCNOChemOberg,]: |
Based on the snippet: <|code_start|>
__all__ = [ "atomic_mass", "molecular_mass", "atomic_composition",
"atomic_abundances" ]
ATOMIC_MASSES = {
<|code_end|>
, predict the immediate next line with the help of imports:
from collections import defaultdict
from ..constants import m_H, m_n, m_e
from .base_che... | 'H' : m_H, 'He' : 2*(m_H + m_n), |
Using the snippet: <|code_start|>
__all__ = [ "atomic_mass", "molecular_mass", "atomic_composition",
"atomic_abundances" ]
ATOMIC_MASSES = {
<|code_end|>
, determine the next line of code. You have imports:
from collections import defaultdict
from ..constants import m_H, m_n, m_e
from .base_chem import C... | 'H' : m_H, 'He' : 2*(m_H + m_n), |
Given the following code snippet before the placeholder: <|code_start|>
__all__ = [ "atomic_mass", "molecular_mass", "atomic_composition",
"atomic_abundances" ]
ATOMIC_MASSES = {
'H' : m_H, 'He' : 2*(m_H + m_n),
'C' : 6*(m_H + m_n), 'N' : 7*(m_H + m_n), 'O' : 8*(m_H + m_... | return m_e / m_H |
Given the following code snippet before the placeholder: <|code_start|> Whether to track the net charge, i.e. the abundance of electrons
ignore_grains : bool, optional
Whether to ignore the contribution from dust species.
returns:
atom_abund : ChemicalAbund object
... | atom_abund = ChemicalAbund(species, masses, len(atoms[species[0]])) |
Based on the snippet: <|code_start|> @property
def T(self):
"""Temperature"""
return self._eos.T
@property
def mu(self):
return self._eos.mu
@property
def H(self):
"""Scale-height"""
return self._eos.H
@property
def h(self):
"""Aspect... | return self.Sigma_G / (np.sqrt(2*np.pi) * self.H * AU) |
Predict the next line for this snippet: <|code_start|> def midplane_gas_density(self):
return self.Sigma_G / (np.sqrt(2*np.pi) * self.H * AU)
@property
def midplane_density(self):
return self.Sigma / (np.sqrt(2*np.pi) * self.H * AU)
@property
def column_density(self):
n = se... | return (self.alpha*self.Sigma_G*sig_H2) / (2*self._eos.mu*m_H) |
Predict the next line for this snippet: <|code_start|>
@property
def H(self):
"""Scale-height"""
return self._eos.H
@property
def h(self):
"""Aspect ratio"""
return self.H/self.R
@property
def H_edge(self):
"""Scale-height at cell edge"""
ret... | n = self.midplane_gas_density / (self._eos._mu * m_H) |
Here is a snippet: <|code_start|>
"""Methods to determine global properties of a viscous accretion disc"""
def Rout(self, thresh=1e-5):
"""Determine the outer radius via density threshold"""
notempty = self.Sigma_G > thresh
notempty_cells = self.R_edge[1:][notempty]
if np.size(no... | Mdot = -M_visc_out*(yr/Msun) |
Using the snippet: <|code_start|>
"""Methods to determine global properties of a viscous accretion disc"""
def Rout(self, thresh=1e-5):
"""Determine the outer radius via density threshold"""
notempty = self.Sigma_G > thresh
notempty_cells = self.R_edge[1:][notempty]
if np.size(no... | Mdot = -M_visc_out*(yr/Msun) |
Given the code snippet: <|code_start|>Designed for plotting to test things out
"""""""""
#################################################################################
class DummyDisc(object):
def __init__(self, R, star, MD=10, RC=100):
self._M = MD * Mjup
self.Rc = RC
self.R_edg... | star1 = PhotoStar(LX=1e30, M=1.0, R=2.5, T_eff=4000) |
Predict the next line for this snippet: <|code_start|>class DonorCell(object):
'''First-order upwind reconstruction
args:
xe : Cell edge locations
m : Index of radial scaling giving volume, V = x^{m+1} / m+1.
'''
STENCIL = 1
def __init__(self, xe, m):
pass
def __call__... | self._xc = xc = compute_centroids(xe, m) |
Predict the next line for this snippet: <|code_start|>
# Reconstruct the face states
Qp = Q[...,1:-1] + dQ_lim * (self._dxp[1:-1] - v_edge[1: ]*dt/2.)
Qm = Q[...,1:-1] + dQ_lim * (self._dxm[1:-1] - v_edge[ :-1]*dt/2.)
return np.where(v_edge[1:-1] > 0, Qp[...,:-1], Qm[...,1:])
class W... | wp, wm = construct_FV_edge_weights(xe, m, 1, 1) |
Given the code snippet: <|code_start|>
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
# input 0: 0.0039 BTC
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
# amount=390000,
prev... | self.assertRaises(CallException, self.client.sign_tx, 'Bitcoin', [inp1, ], [out1, ]) |
Predict the next line for this snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the... | self.assertEqual(self.client.get_address("Testnet", parse_path("49'/1'/0'/0/0"), True, None, script_type=proto.SPENDWITNESS), 'tb1qqzv60m9ajw8drqulta4ld4gfx0rdh82un5s65s') |
Using the snippet: <|code_start|> # to automatically pass unit tests.
#
# This mixing should be used only for purposes
# of unit testing, because it will fail to work
# without special DebugLink interface provided
# by the device.
def __init__(self, *args, **kwargs):
super(DebugLinkM... | self.debug = DebugLink(debug_transport) |
Using the snippet: <|code_start|># This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; ... | class WebUsbTransport(Transport): |
Using the snippet: <|code_start|>
DEFAULT_BIP32_PATH = "m/44h/931h/0h/0/0"
def make_send(from_address, to_address, amount):
return {
'type': 'thorchain/MsgSend',
'value': {
'amount': [{
'denom': 'rune',
'amount': str(amount),
}],
... | address_n=parse_path(DEFAULT_BIP32_PATH), |
Given the following code snippet before the placeholder: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as... | address = self.client.ripple_get_address(parse_path("m/44'/144'/0'/0/0")) |
Given the code snippet: <|code_start|>
DEFAULT_BIP32_PATH = "m/44h/118h/0h/0/0"
class TestMsgCosmosGetAddress(common.KeepKeyTest):
def test_standard(self):
self.requires_firmware("6.3.0")
self.setup_mnemonic_nopin_nopassphrase()
vec = [
<|code_end|>
, generate the next line using the impo... | ("cosmos15cenya0tr7nm3tz2wn3h3zwkht2rxrq7q7h3dj", parse_path(DEFAULT_BIP32_PATH)), |
Predict the next line after this snippet: <|code_start|> self.client.set_expected_responses([proto.ButtonRequest(),
proto.Success(message='wrong data')])
self._some_protected_call(True, True, True)
self.assertRaises(CallException... | self.assertRaises(PinException, self._some_protected_call, False, True, False) |
Here is a snippet: <|code_start|>#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
class TestMsgSignmessageSegwitNative(KeepKeyTest):
def test_sign(self):
self.setup_mnemonic_nopin_nopassphrase()
sig = self.c... | sig = self.client.sign_message('Groestlcoin', parse_path("84'/17'/0'/0/0"), "test", script_type=proto_types.SPENDWITNESS) |
Given the following code snippet before the placeholder: <|code_start|>'''FakeTransport implements dummy interface for Transport.'''
# Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
class FakeTransport(Transport):
def __init__(self, device, *args, **kwargs):
super(FakeTransport, self).__in... | raise NotImplementedException("Not implemented") |
Here is a snippet: <|code_start|>from __future__ import print_function
'''SocketTransport implements TCP socket interface for Transport.'''
class FakeRead(object):
# Let's pretend we have a file-like interface
def __init__(self, func):
self.func = func
def read(self, size):
return self.f... | class UDPTransport(Transport): |
Predict the next line for this snippet: <|code_start|># You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
#
# The script has been modified for KeepKey Device.
class TestMsgSignmessage(common.KeepKeyTest):
def test_sig... | sig = self.client.sign_message('Groestlcoin', parse_path("44'/17'/0'/0/0"), "test") |
Continue the code snippet: <|code_start|> #reset policy ("ShapeShift")
self.client.apply_policy('ShapeShift', 0)
def test_ethereum_xfer_account_path_error_0(self):
self.setup_mnemonic_nopin_nopassphrase()
self.client.apply_policy('ShapeShift', 1)
sig_v, sig_r, sig_s, hash, s... | except CallException as e: |
Continue the code snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Softwar... | address_n=parse_path("44'/5'/0'/0/0"), |
Based on the snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Fou... | self.client.set_tx_api(tx_api.TxApiDash) |
Continue the code snippet: <|code_start|> # balance=86242336390000000000000000000,
# )
# self.assertIsInstance(res, proto_nano.NanoSignedTx)
# self.assertEqual(hexlify(res.block_hash), '5d732d843c22f806011127655790484dbabd38dda20b24900c053c3dfc12523f')
# se... | with self.assertRaises(CallException): |
Given snippet: <|code_start|># the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOS... | self.assertEqual(hexlify(nano.encode_balance(0)), '00000000000000000000000000000000') |
Next line prediction: <|code_start|># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
#
# The script ha... | self.client.set_tx_api(tx_api.TxApiGroestlcoin) |
Given the code snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software F... | address_n=parse_path("49'/1'/0'/1/0"), # 2N1LGaGg836mqSQqiuUBLfcyGBhyZYBtBZ7 |
Predict the next line after this snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by t... | self.client.set_tx_api(TxApiGroestlcoinTestnet) |
Given the code snippet: <|code_start|>#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a ... | self.client.set_tx_api(TxApiZcashTestnet) |
Continue the code snippet: <|code_start|>
DEFAULT_BIP32_PATH = "m/44h/118h/0h/0/0"
def make_send(from_address, to_address, amount):
return {
'type': 'cosmos-sdk/MsgSend',
'value': {
'from_address': from_address,
'to_address': to_address,
'amount': [{
... | address_n=parse_path(DEFAULT_BIP32_PATH), |
Given the code snippet: <|code_start|>
DEFAULT_BIP32_PATH = "m/44h/931h/0h/0/0"
def make_deposit(asset, amount, memo, signer):
return {
'type': 'thorchain/MsgDeposit',
'value': {
'coins': [{
'asset': str(asset),
'amount': str(amount),
}],
... | address_n=parse_path(DEFAULT_BIP32_PATH), |
Based on the snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Fou... | address_n=parse_path("44'/156'/0'/1/0"), |
Predict the next line for this snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the... | self.client.set_tx_api(tx_api.TxApiBitcoinGold) |
Given the code snippet: <|code_start|>#
# You should have received a copy of the License along with this library.
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
class TestMsgSignmessageSegwit(KeepKeyTest):
def test_sign(self):
self.setup_mnemonic_nopin_nopassphrase()
sig = self.cl... | sig = self.client.sign_message('Groestlcoin', parse_path("49'/17'/0'/0/0"), "test", script_type=proto_types.SPENDP2SHWITNESS) |
Predict the next line for this snippet: <|code_start|> )
self.client.set_tx_api(tx_api.TxApiTestnet)
with self.client:
self.client.set_expected_responses([
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)... | self.assertRaises(CallException, self.client.sign_tx, 'Testnet', [inp3, inp4], [out, ]) |
Here is a snippet: <|code_start|> proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_types.TXMETA, details=proto_types.TxRequestDetailsType(tx_hash=unhexlify("d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd88... | address_n=parse_path("m/49'/1'/0'/0/0"), |
Predict the next line for this snippet: <|code_start|># This file is part of the Trezor project.
#
# Copyright (C) 2012-2018 SatoshiLabs and contributors
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the... | self.assertEqual(self.client.get_address("Testnet", parse_path("49'/1'/0'/1/0"), True, None, script_type=proto.SPENDP2SHWITNESS), '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX') |
Here is a snippet: <|code_start|> language='english')
def test_transfer(self):
self.setup_binance()
message = {
"account_number": "34",
"chain_id": "Binance-Chain-Nile",
"data": "null",
"memo": "test",
"msgs": [
... | response = binance.sign_tx(self.client, parse_path("m/44'/714'/0'/0/0"), message) |
Continue the code snippet: <|code_start|> def test_message_testnet(self):
self.setup_mnemonic_nopin_nopassphrase()
sig = base64.b64decode('IFP/nvQalDo9lWCI7kScOzRkz/fiiScdkw7tFAKPoGbl6S8AY3wEws43s2gR57AfwZP8/8y7+F+wvGK9phQghN4=')
ret = self.client.verify_message(
'Testnet',
... | self.assertRaises(CallException, self.client.call, proto.VerifyMessage(address=address, signature=signature, message=message, coin_name="Nano")) |
Next line prediction: <|code_start|> cipher = self.client.debug.read_recovery_cipher()
encoded_character = cipher[ord(character) - 97]
ret = self.client.call_raw(proto.CharacterAck(character=encoded_character))
auto_completed = self.client... | self.assertEqual(self.client.get_address("Testnet", parse_path("49'/1'/0'/1/0"), True, None, script_type=proto_types.SPENDP2SHWITNESS), '2N1LGaGg836mqSQqiuUBLfcyGBhyZbremDX') |
Given snippet: <|code_start|>#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License version 3
# as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; wi... | @session |
Given the code snippet: <|code_start|> return True
if device["interface_number"] == 0:
return True
# MacOS reports -1 as the interface_number for everything,
# inspect based on the path instead.
if platform.system() == "Darwin":
if device["interface_number"] == -1:
r... | class HidTransport(Transport): |
Given snippet: <|code_start|># (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
... | self.client = KeepKeyClient(transport) |
Given snippet: <|code_start|># This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This library is distributed in t... | self.client = KeepKeyDebuglinkClient(transport) |
Given the code snippet: <|code_start|># Copyright (C) 2012-2016 Pavol Rusnak <stick@satoshilabs.com>
#
# This library is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
... | self.client = KeepKeyDebuglinkClientVerbose(transport) |
Here is a snippet: <|code_start|> )
with self.client:
self.client.set_expected_responses([
proto.TxRequest(request_type=proto_types.TXINPUT, details=proto_types.TxRequestDetailsType(request_index=0)),
proto.TxRequest(request_type=proto_ty... | address_n=parse_path("44'/1'/0'/0/0"), |
Predict the next line for this snippet: <|code_start|> self.setup_mnemonic_nopin_nopassphrase()
# tx: d5f65ee80147b4bcc70b75e4bbf2d7382021b871bd8867ef8fa525ef50864882
# input 0: 0.0039 BTC
inp1 = proto_types.TxInputType(address_n=[0], # 14LmW5k4ssUrtbAB4255zdqv3b4w1TuX9e
... | except CallException as e: |
Using the snippet: <|code_start|>
# Accepted by network: tx fd79435246dee76b2f159d2db08032d666c95adc544de64c8c49f474df4a7fee
self.assertEqual(binascii.hexlify(serialized_tx), b'010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b422028418... | self.client.set_tx_api(tx_api.TxApiTestnet) |
Predict the next line for this snippet: <|code_start|> if ord(c) >= ord('a') and ord(c) <= ord('z'):
return (ord(c) - ord('a')) + 6
if ord(c) >= ord('1') and ord(c) <= ord('5'):
return (ord(c) - ord('1')) + 1
return 0
def symbol_from_string(p, name):
length = len(name)
result = 0
... | return _t, b58decode(pub_key, None)[:-4] |
Predict the next line for this snippet: <|code_start|>def symbol_precision(sym):
return pow(10, (sym & 0xff))
def public_key_to_buffer(pub_key):
_t = 0
if pub_key[:3] == 'EOS':
pub_key = pub_key[3:]
_t = 0
elif pub_key[:7] == 'PUB_K1_':
pub_key = pub_key[7:]
_t = 0
e... | return prefix + b58encode(compressed_pub_key + h160(compressed_pub_key)[:4]) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.