body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
@staticmethod def verify_bitcoin(message, signature, address): ' Verifies a message signed using PrivateKey.sign_bitcoin()\n or any of the bitcoin utils (e.g. bitcoin-cli, bx, etc.)\n\n Args:\n message(bytes): The message that the signature corresponds to.\n signature (bytes or str): A Base64 encoded signature\n address (str): Base58Check encoded address.\n\n Returns:\n bool: True if the signature verified properly, False otherwise.\n ' magic_sig = base64.b64decode(signature) magic = magic_sig[0] sig = Signature.from_bytes(magic_sig[1:]) sig.recovery_id = ((magic - 27) & 3) compressed = (((magic - 27) & 4) != 0) msg = ((b'\x18Bitcoin Signed Message:\n' + bytes([len(message)])) + message) msg_hash = hashlib.sha256(msg).digest() derived_public_key = PublicKey.from_signature(msg_hash, sig) if (derived_public_key is None): raise ValueError('Could not recover public key from the provided signature.') n = base58.b58decode_check(address) version = n[0] h160 = n[1:] hash160 = derived_public_key.hash160(compressed) if (hash160 != h160): return False return derived_public_key.verify(msg_hash, sig)
7,227,219,737,541,673,000
Verifies a message signed using PrivateKey.sign_bitcoin() or any of the bitcoin utils (e.g. bitcoin-cli, bx, etc.) Args: message(bytes): The message that the signature corresponds to. signature (bytes or str): A Base64 encoded signature address (str): Base58Check encoded address. Returns: bool: True if the signature verified properly, False otherwise.
pywallet/utils/ethereum.py
verify_bitcoin
ukor/pywallet
python
@staticmethod def verify_bitcoin(message, signature, address): ' Verifies a message signed using PrivateKey.sign_bitcoin()\n or any of the bitcoin utils (e.g. bitcoin-cli, bx, etc.)\n\n Args:\n message(bytes): The message that the signature corresponds to.\n signature (bytes or str): A Base64 encoded signature\n address (str): Base58Check encoded address.\n\n Returns:\n bool: True if the signature verified properly, False otherwise.\n ' magic_sig = base64.b64decode(signature) magic = magic_sig[0] sig = Signature.from_bytes(magic_sig[1:]) sig.recovery_id = ((magic - 27) & 3) compressed = (((magic - 27) & 4) != 0) msg = ((b'\x18Bitcoin Signed Message:\n' + bytes([len(message)])) + message) msg_hash = hashlib.sha256(msg).digest() derived_public_key = PublicKey.from_signature(msg_hash, sig) if (derived_public_key is None): raise ValueError('Could not recover public key from the provided signature.') n = base58.b58decode_check(address) version = n[0] h160 = n[1:] hash160 = derived_public_key.hash160(compressed) if (hash160 != h160): return False return derived_public_key.verify(msg_hash, sig)
def hash160(self, compressed=True): ' Return the RIPEMD-160 hash of the SHA-256 hash of the\n public key.\n\n Args:\n compressed (bool): Whether or not the compressed key should\n be used.\n Returns:\n bytes: RIPEMD-160 byte string.\n ' return (self.ripe_compressed if compressed else self.ripe)
2,221,346,376,300,860,200
Return the RIPEMD-160 hash of the SHA-256 hash of the public key. Args: compressed (bool): Whether or not the compressed key should be used. Returns: bytes: RIPEMD-160 byte string.
pywallet/utils/ethereum.py
hash160
ukor/pywallet
python
def hash160(self, compressed=True): ' Return the RIPEMD-160 hash of the SHA-256 hash of the\n public key.\n\n Args:\n compressed (bool): Whether or not the compressed key should\n be used.\n Returns:\n bytes: RIPEMD-160 byte string.\n ' return (self.ripe_compressed if compressed else self.ripe)
def address(self, compressed=True, testnet=False): ' Address property that returns the Base58Check\n encoded version of the HASH160.\n\n Args:\n compressed (bool): Whether or not the compressed key should\n be used.\n testnet (bool): Whether or not the key is intended for testnet\n usage. False indicates mainnet usage.\n\n Returns:\n bytes: Base58Check encoded string\n ' version = '0x' return (version + binascii.hexlify(self.keccak[12:]).decode('ascii'))
-7,028,471,823,252,193,000
Address property that returns the Base58Check encoded version of the HASH160. Args: compressed (bool): Whether or not the compressed key should be used. testnet (bool): Whether or not the key is intended for testnet usage. False indicates mainnet usage. Returns: bytes: Base58Check encoded string
pywallet/utils/ethereum.py
address
ukor/pywallet
python
def address(self, compressed=True, testnet=False): ' Address property that returns the Base58Check\n encoded version of the HASH160.\n\n Args:\n compressed (bool): Whether or not the compressed key should\n be used.\n testnet (bool): Whether or not the key is intended for testnet\n usage. False indicates mainnet usage.\n\n Returns:\n bytes: Base58Check encoded string\n ' version = '0x' return (version + binascii.hexlify(self.keccak[12:]).decode('ascii'))
def verify(self, message, signature, do_hash=True): ' Verifies that message was appropriately signed.\n\n Args:\n message (bytes): The message to be verified.\n signature (Signature): A signature object.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n verified (bool): True if the signature is verified, False\n otherwise.\n ' msg = get_bytes(message) return bitcoin_curve.verify(msg, signature, self.point, do_hash)
294,918,660,936,284,300
Verifies that message was appropriately signed. Args: message (bytes): The message to be verified. signature (Signature): A signature object. do_hash (bool): True if the message should be hashed prior to signing, False if not. This should always be left as True except in special situations which require doing the hash outside (e.g. handling Bitcoin bugs). Returns: verified (bool): True if the signature is verified, False otherwise.
pywallet/utils/ethereum.py
verify
ukor/pywallet
python
def verify(self, message, signature, do_hash=True): ' Verifies that message was appropriately signed.\n\n Args:\n message (bytes): The message to be verified.\n signature (Signature): A signature object.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n verified (bool): True if the signature is verified, False\n otherwise.\n ' msg = get_bytes(message) return bitcoin_curve.verify(msg, signature, self.point, do_hash)
def to_base64(self): ' Hex representation of the serialized byte stream.\n\n Returns:\n b (str): A Base64-encoded string.\n ' return base64.b64encode(bytes(self))
3,128,094,007,399,917,000
Hex representation of the serialized byte stream. Returns: b (str): A Base64-encoded string.
pywallet/utils/ethereum.py
to_base64
ukor/pywallet
python
def to_base64(self): ' Hex representation of the serialized byte stream.\n\n Returns:\n b (str): A Base64-encoded string.\n ' return base64.b64encode(bytes(self))
@property def compressed_bytes(self): ' Byte string corresponding to a compressed representation\n of this public key.\n\n Returns:\n b (bytes): A 33-byte long byte string.\n ' return self.point.compressed_bytes
-355,551,882,697,130,600
Byte string corresponding to a compressed representation of this public key. Returns: b (bytes): A 33-byte long byte string.
pywallet/utils/ethereum.py
compressed_bytes
ukor/pywallet
python
@property def compressed_bytes(self): ' Byte string corresponding to a compressed representation\n of this public key.\n\n Returns:\n b (bytes): A 33-byte long byte string.\n ' return self.point.compressed_bytes
@staticmethod def from_der(der): ' Decodes a Signature that was DER-encoded.\n\n Args:\n der (bytes or str): The DER encoding to be decoded.\n\n Returns:\n Signature: The deserialized signature.\n ' d = get_bytes(der) if (len(d) < 8): raise ValueError('DER signature string is too short.') if (len(d) > 72): raise ValueError('DER signature string is too long.') if (d[0] != 48): raise ValueError('DER signature does not start with 0x30.') if (d[1] != len(d[2:])): raise ValueError('DER signature length incorrect.') total_length = d[1] if (d[2] != 2): raise ValueError('DER signature no 1st int marker.') if ((d[3] <= 0) or (d[3] > (total_length - 7))): raise ValueError('DER signature incorrect R length.') rlen = d[3] s_magic_index = (4 + rlen) rb = d[4:s_magic_index] if ((rb[0] & 128) != 0): raise ValueError('DER signature R is negative.') if ((len(rb) > 1) and (rb[0] == 0) and ((rb[1] & 128) != 128)): raise ValueError('DER signature R is excessively padded.') r = int.from_bytes(rb, 'big') if (d[s_magic_index] != 2): raise ValueError('DER signature no 2nd int marker.') slen_index = (s_magic_index + 1) slen = d[slen_index] if ((slen <= 0) or (slen > (len(d) - (slen_index + 1)))): raise ValueError('DER signature incorrect S length.') sb = d[(slen_index + 1):] if ((sb[0] & 128) != 0): raise ValueError('DER signature S is negative.') if ((len(sb) > 1) and (sb[0] == 0) and ((sb[1] & 128) != 128)): raise ValueError('DER signature S is excessively padded.') s = int.from_bytes(sb, 'big') if ((r < 1) or (r >= bitcoin_curve.n)): raise ValueError('DER signature R is not between 1 and N - 1.') if ((s < 1) or (s >= bitcoin_curve.n)): raise ValueError('DER signature S is not between 1 and N - 1.') return Signature(r, s)
178,877,373,032,888,100
Decodes a Signature that was DER-encoded. Args: der (bytes or str): The DER encoding to be decoded. Returns: Signature: The deserialized signature.
pywallet/utils/ethereum.py
from_der
ukor/pywallet
python
@staticmethod def from_der(der): ' Decodes a Signature that was DER-encoded.\n\n Args:\n der (bytes or str): The DER encoding to be decoded.\n\n Returns:\n Signature: The deserialized signature.\n ' d = get_bytes(der) if (len(d) < 8): raise ValueError('DER signature string is too short.') if (len(d) > 72): raise ValueError('DER signature string is too long.') if (d[0] != 48): raise ValueError('DER signature does not start with 0x30.') if (d[1] != len(d[2:])): raise ValueError('DER signature length incorrect.') total_length = d[1] if (d[2] != 2): raise ValueError('DER signature no 1st int marker.') if ((d[3] <= 0) or (d[3] > (total_length - 7))): raise ValueError('DER signature incorrect R length.') rlen = d[3] s_magic_index = (4 + rlen) rb = d[4:s_magic_index] if ((rb[0] & 128) != 0): raise ValueError('DER signature R is negative.') if ((len(rb) > 1) and (rb[0] == 0) and ((rb[1] & 128) != 128)): raise ValueError('DER signature R is excessively padded.') r = int.from_bytes(rb, 'big') if (d[s_magic_index] != 2): raise ValueError('DER signature no 2nd int marker.') slen_index = (s_magic_index + 1) slen = d[slen_index] if ((slen <= 0) or (slen > (len(d) - (slen_index + 1)))): raise ValueError('DER signature incorrect S length.') sb = d[(slen_index + 1):] if ((sb[0] & 128) != 0): raise ValueError('DER signature S is negative.') if ((len(sb) > 1) and (sb[0] == 0) and ((sb[1] & 128) != 128)): raise ValueError('DER signature S is excessively padded.') s = int.from_bytes(sb, 'big') if ((r < 1) or (r >= bitcoin_curve.n)): raise ValueError('DER signature R is not between 1 and N - 1.') if ((s < 1) or (s >= bitcoin_curve.n)): raise ValueError('DER signature S is not between 1 and N - 1.') return Signature(r, s)
@staticmethod def from_base64(b64str): ' Generates a signature object from a Base64 encoded string.\n\n Args:\n b64str (str): A Base64-encoded string.\n\n Returns:\n Signature: A Signature object.\n ' return Signature.from_bytes(base64.b64decode(b64str))
7,248,638,769,553,480,000
Generates a signature object from a Base64 encoded string. Args: b64str (str): A Base64-encoded string. Returns: Signature: A Signature object.
pywallet/utils/ethereum.py
from_base64
ukor/pywallet
python
@staticmethod def from_base64(b64str): ' Generates a signature object from a Base64 encoded string.\n\n Args:\n b64str (str): A Base64-encoded string.\n\n Returns:\n Signature: A Signature object.\n ' return Signature.from_bytes(base64.b64decode(b64str))
@staticmethod def from_bytes(b): ' Extracts the r and s components from a byte string.\n\n Args:\n b (bytes): A 64-byte long string. The first 32 bytes are\n extracted as the r component and the second 32 bytes\n are extracted as the s component.\n\n Returns:\n Signature: A Signature object.\n\n Raises:\n ValueError: If signature is incorrect length\n ' if (len(b) != 64): raise ValueError('from_bytes: Signature length != 64.') r = int.from_bytes(b[0:32], 'big') s = int.from_bytes(b[32:64], 'big') return Signature(r, s)
-7,242,112,644,742,968,000
Extracts the r and s components from a byte string. Args: b (bytes): A 64-byte long string. The first 32 bytes are extracted as the r component and the second 32 bytes are extracted as the s component. Returns: Signature: A Signature object. Raises: ValueError: If signature is incorrect length
pywallet/utils/ethereum.py
from_bytes
ukor/pywallet
python
@staticmethod def from_bytes(b): ' Extracts the r and s components from a byte string.\n\n Args:\n b (bytes): A 64-byte long string. The first 32 bytes are\n extracted as the r component and the second 32 bytes\n are extracted as the s component.\n\n Returns:\n Signature: A Signature object.\n\n Raises:\n ValueError: If signature is incorrect length\n ' if (len(b) != 64): raise ValueError('from_bytes: Signature length != 64.') r = int.from_bytes(b[0:32], 'big') s = int.from_bytes(b[32:64], 'big') return Signature(r, s)
@staticmethod def from_hex(h): ' Extracts the r and s components from a hex-encoded string.\n\n Args:\n h (str): A 64-byte (128 character) long string. The first\n 32 bytes are extracted as the r component and the\n second 32 bytes are extracted as the s component.\n\n Returns:\n Signature: A Signature object.\n ' return Signature.from_bytes(bytes.fromhex(h))
5,435,641,828,722,916,000
Extracts the r and s components from a hex-encoded string. Args: h (str): A 64-byte (128 character) long string. The first 32 bytes are extracted as the r component and the second 32 bytes are extracted as the s component. Returns: Signature: A Signature object.
pywallet/utils/ethereum.py
from_hex
ukor/pywallet
python
@staticmethod def from_hex(h): ' Extracts the r and s components from a hex-encoded string.\n\n Args:\n h (str): A 64-byte (128 character) long string. The first\n 32 bytes are extracted as the r component and the\n second 32 bytes are extracted as the s component.\n\n Returns:\n Signature: A Signature object.\n ' return Signature.from_bytes(bytes.fromhex(h))
@property def x(self): ' Convenience property for any method that requires\n this object to provide a Point interface.\n ' return self.r
-5,011,515,628,047,565,000
Convenience property for any method that requires this object to provide a Point interface.
pywallet/utils/ethereum.py
x
ukor/pywallet
python
@property def x(self): ' Convenience property for any method that requires\n this object to provide a Point interface.\n ' return self.r
@property def y(self): ' Convenience property for any method that requires\n this object to provide a Point interface.\n ' return self.s
-9,056,976,346,146,439,000
Convenience property for any method that requires this object to provide a Point interface.
pywallet/utils/ethereum.py
y
ukor/pywallet
python
@property def y(self): ' Convenience property for any method that requires\n this object to provide a Point interface.\n ' return self.s
def to_der(self): ' Encodes this signature using DER\n\n Returns:\n bytes: The DER encoding of (self.r, self.s).\n ' (r, s) = self._canonicalize() total_length = ((6 + len(r)) + len(s)) der = (((bytes([48, (total_length - 2), 2, len(r)]) + r) + bytes([2, len(s)])) + s) return der
2,245,976,467,492,142,800
Encodes this signature using DER Returns: bytes: The DER encoding of (self.r, self.s).
pywallet/utils/ethereum.py
to_der
ukor/pywallet
python
def to_der(self): ' Encodes this signature using DER\n\n Returns:\n bytes: The DER encoding of (self.r, self.s).\n ' (r, s) = self._canonicalize() total_length = ((6 + len(r)) + len(s)) der = (((bytes([48, (total_length - 2), 2, len(r)]) + r) + bytes([2, len(s)])) + s) return der
def to_hex(self): ' Hex representation of the serialized byte stream.\n\n Returns:\n str: A hex-encoded string.\n ' return codecs.encode(bytes(self), 'hex_codec').decode('ascii')
-5,866,200,977,990,551,000
Hex representation of the serialized byte stream. Returns: str: A hex-encoded string.
pywallet/utils/ethereum.py
to_hex
ukor/pywallet
python
def to_hex(self): ' Hex representation of the serialized byte stream.\n\n Returns:\n str: A hex-encoded string.\n ' return codecs.encode(bytes(self), 'hex_codec').decode('ascii')
def to_base64(self): ' Hex representation of the serialized byte stream.\n\n Returns:\n str: A Base64-encoded string.\n ' return base64.b64encode(bytes(self))
-2,654,131,553,993,369,000
Hex representation of the serialized byte stream. Returns: str: A Base64-encoded string.
pywallet/utils/ethereum.py
to_base64
ukor/pywallet
python
def to_base64(self): ' Hex representation of the serialized byte stream.\n\n Returns:\n str: A Base64-encoded string.\n ' return base64.b64encode(bytes(self))
@staticmethod def from_b58check(key): ' Decodes a Base58Check encoded key.\n\n The encoding must conform to the description in:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format\n\n Args:\n key (str): A Base58Check encoded key.\n\n Returns:\n HDPrivateKey or HDPublicKey:\n Either an HD private or\n public key object, depending on what was serialized.\n ' return HDKey.from_bytes(base58.b58decode_check(key))
-8,928,533,890,202,212,000
Decodes a Base58Check encoded key. The encoding must conform to the description in: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format Args: key (str): A Base58Check encoded key. Returns: HDPrivateKey or HDPublicKey: Either an HD private or public key object, depending on what was serialized.
pywallet/utils/ethereum.py
from_b58check
ukor/pywallet
python
@staticmethod def from_b58check(key): ' Decodes a Base58Check encoded key.\n\n The encoding must conform to the description in:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format\n\n Args:\n key (str): A Base58Check encoded key.\n\n Returns:\n HDPrivateKey or HDPublicKey:\n Either an HD private or\n public key object, depending on what was serialized.\n ' return HDKey.from_bytes(base58.b58decode_check(key))
@staticmethod def from_bytes(b): ' Generates either a HDPrivateKey or HDPublicKey from the underlying\n bytes.\n\n The serialization must conform to the description in:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format\n\n Args:\n b (bytes): A byte stream conforming to the above.\n\n Returns:\n HDPrivateKey or HDPublicKey:\n Either an HD private or\n public key object, depending on what was serialized.\n ' if (len(b) < 78): raise ValueError('b must be at least 78 bytes long.') version = int.from_bytes(b[:4], 'big') depth = b[4] parent_fingerprint = b[5:9] index = int.from_bytes(b[9:13], 'big') chain_code = b[13:45] key_bytes = b[45:78] rv = None if ((version == HDPrivateKey.MAINNET_VERSION) or (version == HDPrivateKey.TESTNET_VERSION)): if (key_bytes[0] != 0): raise ValueError('First byte of private key must be 0x00!') private_key = int.from_bytes(key_bytes[1:], 'big') rv = HDPrivateKey(key=private_key, chain_code=chain_code, index=index, depth=depth, parent_fingerprint=parent_fingerprint) elif ((version == HDPublicKey.MAINNET_VERSION) or (version == HDPublicKey.TESTNET_VERSION)): if ((key_bytes[0] != 2) and (key_bytes[0] != 3)): raise ValueError('First byte of public key must be 0x02 or 0x03!') public_key = PublicKey.from_bytes(key_bytes) rv = HDPublicKey(x=public_key.point.x, y=public_key.point.y, chain_code=chain_code, index=index, depth=depth, parent_fingerprint=parent_fingerprint) else: raise ValueError('incorrect encoding.') return rv
4,919,203,036,137,217,000
Generates either a HDPrivateKey or HDPublicKey from the underlying bytes. The serialization must conform to the description in: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format Args: b (bytes): A byte stream conforming to the above. Returns: HDPrivateKey or HDPublicKey: Either an HD private or public key object, depending on what was serialized.
pywallet/utils/ethereum.py
from_bytes
ukor/pywallet
python
@staticmethod def from_bytes(b): ' Generates either a HDPrivateKey or HDPublicKey from the underlying\n bytes.\n\n The serialization must conform to the description in:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format\n\n Args:\n b (bytes): A byte stream conforming to the above.\n\n Returns:\n HDPrivateKey or HDPublicKey:\n Either an HD private or\n public key object, depending on what was serialized.\n ' if (len(b) < 78): raise ValueError('b must be at least 78 bytes long.') version = int.from_bytes(b[:4], 'big') depth = b[4] parent_fingerprint = b[5:9] index = int.from_bytes(b[9:13], 'big') chain_code = b[13:45] key_bytes = b[45:78] rv = None if ((version == HDPrivateKey.MAINNET_VERSION) or (version == HDPrivateKey.TESTNET_VERSION)): if (key_bytes[0] != 0): raise ValueError('First byte of private key must be 0x00!') private_key = int.from_bytes(key_bytes[1:], 'big') rv = HDPrivateKey(key=private_key, chain_code=chain_code, index=index, depth=depth, parent_fingerprint=parent_fingerprint) elif ((version == HDPublicKey.MAINNET_VERSION) or (version == HDPublicKey.TESTNET_VERSION)): if ((key_bytes[0] != 2) and (key_bytes[0] != 3)): raise ValueError('First byte of public key must be 0x02 or 0x03!') public_key = PublicKey.from_bytes(key_bytes) rv = HDPublicKey(x=public_key.point.x, y=public_key.point.y, chain_code=chain_code, index=index, depth=depth, parent_fingerprint=parent_fingerprint) else: raise ValueError('incorrect encoding.') return rv
@staticmethod def from_hex(h): ' Generates either a HDPrivateKey or HDPublicKey from the underlying\n hex-encoded string.\n\n The serialization must conform to the description in:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format\n\n Args:\n h (str): A hex-encoded string conforming to the above.\n\n Returns:\n HDPrivateKey or HDPublicKey:\n Either an HD private or\n public key object, depending on what was serialized.\n ' return HDKey.from_bytes(bytes.fromhex(h))
-5,066,633,890,945,613,000
Generates either a HDPrivateKey or HDPublicKey from the underlying hex-encoded string. The serialization must conform to the description in: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format Args: h (str): A hex-encoded string conforming to the above. Returns: HDPrivateKey or HDPublicKey: Either an HD private or public key object, depending on what was serialized.
pywallet/utils/ethereum.py
from_hex
ukor/pywallet
python
@staticmethod def from_hex(h): ' Generates either a HDPrivateKey or HDPublicKey from the underlying\n hex-encoded string.\n\n The serialization must conform to the description in:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#serialization-format\n\n Args:\n h (str): A hex-encoded string conforming to the above.\n\n Returns:\n HDPrivateKey or HDPublicKey:\n Either an HD private or\n public key object, depending on what was serialized.\n ' return HDKey.from_bytes(bytes.fromhex(h))
@property def master(self): ' Whether or not this is a master node.\n\n Returns:\n bool: True if this is a master node, False otherwise.\n ' return (self.depth == 0)
-6,666,981,387,012,515,000
Whether or not this is a master node. Returns: bool: True if this is a master node, False otherwise.
pywallet/utils/ethereum.py
master
ukor/pywallet
python
@property def master(self): ' Whether or not this is a master node.\n\n Returns:\n bool: True if this is a master node, False otherwise.\n ' return (self.depth == 0)
@property def hardened(self): ' Whether or not this is a hardened node.\n\n Hardened nodes are those with indices >= 0x80000000.\n\n Returns:\n bool: True if this is hardened, False otherwise.\n ' return (self.index & 2147483648)
-6,217,019,830,460,732,000
Whether or not this is a hardened node. Hardened nodes are those with indices >= 0x80000000. Returns: bool: True if this is hardened, False otherwise.
pywallet/utils/ethereum.py
hardened
ukor/pywallet
python
@property def hardened(self): ' Whether or not this is a hardened node.\n\n Hardened nodes are those with indices >= 0x80000000.\n\n Returns:\n bool: True if this is hardened, False otherwise.\n ' return (self.index & 2147483648)
@property def identifier(self): " Returns the identifier for the key.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n Returns:\n bytes: A 20-byte RIPEMD-160 hash.\n " raise NotImplementedError
796,333,715,178,832,100
Returns the identifier for the key. A key's identifier and fingerprint are defined as: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers Returns: bytes: A 20-byte RIPEMD-160 hash.
pywallet/utils/ethereum.py
identifier
ukor/pywallet
python
@property def identifier(self): " Returns the identifier for the key.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n Returns:\n bytes: A 20-byte RIPEMD-160 hash.\n " raise NotImplementedError
@property def fingerprint(self): " Returns the key's fingerprint, which is the first 4 bytes\n of its identifier.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n Returns:\n bytes: The first 4 bytes of the RIPEMD-160 hash.\n " return self.identifier[:4]
8,939,580,986,969,387,000
Returns the key's fingerprint, which is the first 4 bytes of its identifier. A key's identifier and fingerprint are defined as: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers Returns: bytes: The first 4 bytes of the RIPEMD-160 hash.
pywallet/utils/ethereum.py
fingerprint
ukor/pywallet
python
@property def fingerprint(self): " Returns the key's fingerprint, which is the first 4 bytes\n of its identifier.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n Returns:\n bytes: The first 4 bytes of the RIPEMD-160 hash.\n " return self.identifier[:4]
def to_b58check(self, testnet=False): ' Generates a Base58Check encoding of this key.\n\n Args:\n testnet (bool): True if the key is to be used with\n testnet, False otherwise.\n Returns:\n str: A Base58Check encoded string representing the key.\n ' b = (self.testnet_bytes if testnet else bytes(self)) return base58.b58encode_check(b)
-555,311,680,589,127,360
Generates a Base58Check encoding of this key. Args: testnet (bool): True if the key is to be used with testnet, False otherwise. Returns: str: A Base58Check encoded string representing the key.
pywallet/utils/ethereum.py
to_b58check
ukor/pywallet
python
def to_b58check(self, testnet=False): ' Generates a Base58Check encoding of this key.\n\n Args:\n testnet (bool): True if the key is to be used with\n testnet, False otherwise.\n Returns:\n str: A Base58Check encoded string representing the key.\n ' b = (self.testnet_bytes if testnet else bytes(self)) return base58.b58encode_check(b)
@property def testnet_bytes(self): ' Serialization of the key for testnet.\n\n Returns:\n bytes:\n A 78-byte serialization of the key, specifically for\n testnet (i.e. the first 2 bytes will be 0x0435).\n ' return self._serialize(True)
-6,797,410,677,608,330,000
Serialization of the key for testnet. Returns: bytes: A 78-byte serialization of the key, specifically for testnet (i.e. the first 2 bytes will be 0x0435).
pywallet/utils/ethereum.py
testnet_bytes
ukor/pywallet
python
@property def testnet_bytes(self): ' Serialization of the key for testnet.\n\n Returns:\n bytes:\n A 78-byte serialization of the key, specifically for\n testnet (i.e. the first 2 bytes will be 0x0435).\n ' return self._serialize(True)
@staticmethod def master_key_from_mnemonic(mnemonic, passphrase=''): ' Generates a master key from a mnemonic.\n\n Args:\n mnemonic (str): The mnemonic sentence representing\n the seed from which to generate the master key.\n passphrase (str): Password if one was used.\n\n Returns:\n HDPrivateKey: the master private key.\n ' return HDPrivateKey.master_key_from_seed(Mnemonic.to_seed(mnemonic, passphrase))
-5,843,158,790,375,251,000
Generates a master key from a mnemonic. Args: mnemonic (str): The mnemonic sentence representing the seed from which to generate the master key. passphrase (str): Password if one was used. Returns: HDPrivateKey: the master private key.
pywallet/utils/ethereum.py
master_key_from_mnemonic
ukor/pywallet
python
@staticmethod def master_key_from_mnemonic(mnemonic, passphrase=): ' Generates a master key from a mnemonic.\n\n Args:\n mnemonic (str): The mnemonic sentence representing\n the seed from which to generate the master key.\n passphrase (str): Password if one was used.\n\n Returns:\n HDPrivateKey: the master private key.\n ' return HDPrivateKey.master_key_from_seed(Mnemonic.to_seed(mnemonic, passphrase))
@staticmethod def master_key_from_entropy(passphrase='', strength=128): ' Generates a master key from system entropy.\n\n Args:\n strength (int): Amount of entropy desired. This should be\n a multiple of 32 between 128 and 256.\n passphrase (str): An optional passphrase for the generated\n mnemonic string.\n\n Returns:\n HDPrivateKey, str:\n a tuple consisting of the master\n private key and a mnemonic string from which the seed\n can be recovered.\n ' if ((strength % 32) != 0): raise ValueError('strength must be a multiple of 32') if ((strength < 128) or (strength > 256)): raise ValueError('strength should be >= 128 and <= 256') entropy = os.urandom((strength // 8)) m = Mnemonic(language='english') n = m.to_mnemonic(entropy) return (HDPrivateKey.master_key_from_seed(Mnemonic.to_seed(n, passphrase)), n)
-689,727,026,407,204,400
Generates a master key from system entropy. Args: strength (int): Amount of entropy desired. This should be a multiple of 32 between 128 and 256. passphrase (str): An optional passphrase for the generated mnemonic string. Returns: HDPrivateKey, str: a tuple consisting of the master private key and a mnemonic string from which the seed can be recovered.
pywallet/utils/ethereum.py
master_key_from_entropy
ukor/pywallet
python
@staticmethod def master_key_from_entropy(passphrase=, strength=128): ' Generates a master key from system entropy.\n\n Args:\n strength (int): Amount of entropy desired. This should be\n a multiple of 32 between 128 and 256.\n passphrase (str): An optional passphrase for the generated\n mnemonic string.\n\n Returns:\n HDPrivateKey, str:\n a tuple consisting of the master\n private key and a mnemonic string from which the seed\n can be recovered.\n ' if ((strength % 32) != 0): raise ValueError('strength must be a multiple of 32') if ((strength < 128) or (strength > 256)): raise ValueError('strength should be >= 128 and <= 256') entropy = os.urandom((strength // 8)) m = Mnemonic(language='english') n = m.to_mnemonic(entropy) return (HDPrivateKey.master_key_from_seed(Mnemonic.to_seed(n, passphrase)), n)
@staticmethod def master_key_from_seed(seed): ' Generates a master key from a provided seed.\n\n Args:\n seed (bytes or str): a string of bytes or a hex string\n\n Returns:\n HDPrivateKey: the master private key.\n ' S = get_bytes(seed) I = hmac.new(b'Bitcoin seed', S, hashlib.sha512).digest() (Il, Ir) = (I[:32], I[32:]) parse_Il = int.from_bytes(Il, 'big') if ((parse_Il == 0) or (parse_Il >= bitcoin_curve.n)): raise ValueError('Bad seed, resulting in invalid key!') return HDPrivateKey(key=parse_Il, chain_code=Ir, index=0, depth=0)
2,719,579,831,305,562,000
Generates a master key from a provided seed. Args: seed (bytes or str): a string of bytes or a hex string Returns: HDPrivateKey: the master private key.
pywallet/utils/ethereum.py
master_key_from_seed
ukor/pywallet
python
@staticmethod def master_key_from_seed(seed): ' Generates a master key from a provided seed.\n\n Args:\n seed (bytes or str): a string of bytes or a hex string\n\n Returns:\n HDPrivateKey: the master private key.\n ' S = get_bytes(seed) I = hmac.new(b'Bitcoin seed', S, hashlib.sha512).digest() (Il, Ir) = (I[:32], I[32:]) parse_Il = int.from_bytes(Il, 'big') if ((parse_Il == 0) or (parse_Il >= bitcoin_curve.n)): raise ValueError('Bad seed, resulting in invalid key!') return HDPrivateKey(key=parse_Il, chain_code=Ir, index=0, depth=0)
@staticmethod def from_parent(parent_key, i): ' Derives a child private key from a parent\n private key. It is not possible to derive a child\n private key from a public parent key.\n\n Args:\n parent_private_key (HDPrivateKey):\n ' if (not isinstance(parent_key, HDPrivateKey)): raise TypeError('parent_key must be an HDPrivateKey object.') hmac_key = parent_key.chain_code if (i & 2147483648): hmac_data = ((b'\x00' + bytes(parent_key._key)) + i.to_bytes(length=4, byteorder='big')) else: hmac_data = (parent_key.public_key.compressed_bytes + i.to_bytes(length=4, byteorder='big')) I = hmac.new(hmac_key, hmac_data, hashlib.sha512).digest() (Il, Ir) = (I[:32], I[32:]) parse_Il = int.from_bytes(Il, 'big') if (parse_Il >= bitcoin_curve.n): return None child_key = ((parse_Il + parent_key._key.key) % bitcoin_curve.n) if (child_key == 0): return None child_depth = (parent_key.depth + 1) return HDPrivateKey(key=child_key, chain_code=Ir, index=i, depth=child_depth, parent_fingerprint=parent_key.fingerprint)
3,602,754,436,133,424,600
Derives a child private key from a parent private key. It is not possible to derive a child private key from a public parent key. Args: parent_private_key (HDPrivateKey):
pywallet/utils/ethereum.py
from_parent
ukor/pywallet
python
@staticmethod def from_parent(parent_key, i): ' Derives a child private key from a parent\n private key. It is not possible to derive a child\n private key from a public parent key.\n\n Args:\n parent_private_key (HDPrivateKey):\n ' if (not isinstance(parent_key, HDPrivateKey)): raise TypeError('parent_key must be an HDPrivateKey object.') hmac_key = parent_key.chain_code if (i & 2147483648): hmac_data = ((b'\x00' + bytes(parent_key._key)) + i.to_bytes(length=4, byteorder='big')) else: hmac_data = (parent_key.public_key.compressed_bytes + i.to_bytes(length=4, byteorder='big')) I = hmac.new(hmac_key, hmac_data, hashlib.sha512).digest() (Il, Ir) = (I[:32], I[32:]) parse_Il = int.from_bytes(Il, 'big') if (parse_Il >= bitcoin_curve.n): return None child_key = ((parse_Il + parent_key._key.key) % bitcoin_curve.n) if (child_key == 0): return None child_depth = (parent_key.depth + 1) return HDPrivateKey(key=child_key, chain_code=Ir, index=i, depth=child_depth, parent_fingerprint=parent_key.fingerprint)
@property def public_key(self): ' Returns the public key associated with this private key.\n\n Returns:\n HDPublicKey:\n The HDPublicKey object that corresponds to this\n private key.\n ' if (self._public_key is None): self._public_key = HDPublicKey(x=self._key.public_key.point.x, y=self._key.public_key.point.y, chain_code=self.chain_code, index=self.index, depth=self.depth, parent_fingerprint=self.parent_fingerprint) return self._public_key
-3,351,380,143,480,722,400
Returns the public key associated with this private key. Returns: HDPublicKey: The HDPublicKey object that corresponds to this private key.
pywallet/utils/ethereum.py
public_key
ukor/pywallet
python
@property def public_key(self): ' Returns the public key associated with this private key.\n\n Returns:\n HDPublicKey:\n The HDPublicKey object that corresponds to this\n private key.\n ' if (self._public_key is None): self._public_key = HDPublicKey(x=self._key.public_key.point.x, y=self._key.public_key.point.y, chain_code=self.chain_code, index=self.index, depth=self.depth, parent_fingerprint=self.parent_fingerprint) return self._public_key
def raw_sign(self, message, do_hash=True): " Signs message using the underlying non-extended private key.\n\n Args:\n message (bytes): The message to be signed. If a string is\n provided it is assumed the encoding is 'ascii' and\n converted to bytes. If this is not the case, it is up\n to the caller to convert the string to bytes\n appropriately and pass in the bytes.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n ECPointAffine:\n a raw point (r = pt.x, s = pt.y) which is\n the signature.\n " return self._key.raw_sign(message, do_hash)
-3,268,282,181,061,833,700
Signs message using the underlying non-extended private key. Args: message (bytes): The message to be signed. If a string is provided it is assumed the encoding is 'ascii' and converted to bytes. If this is not the case, it is up to the caller to convert the string to bytes appropriately and pass in the bytes. do_hash (bool): True if the message should be hashed prior to signing, False if not. This should always be left as True except in special situations which require doing the hash outside (e.g. handling Bitcoin bugs). Returns: ECPointAffine: a raw point (r = pt.x, s = pt.y) which is the signature.
pywallet/utils/ethereum.py
raw_sign
ukor/pywallet
python
def raw_sign(self, message, do_hash=True): " Signs message using the underlying non-extended private key.\n\n Args:\n message (bytes): The message to be signed. If a string is\n provided it is assumed the encoding is 'ascii' and\n converted to bytes. If this is not the case, it is up\n to the caller to convert the string to bytes\n appropriately and pass in the bytes.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n ECPointAffine:\n a raw point (r = pt.x, s = pt.y) which is\n the signature.\n " return self._key.raw_sign(message, do_hash)
def sign(self, message, do_hash=True): " Signs message using the underlying non-extended private key.\n\n Note:\n This differs from `raw_sign()` since it returns a Signature object.\n\n Args:\n message (bytes or str): The message to be signed. If a\n string is provided it is assumed the encoding is\n 'ascii' and converted to bytes. If this is not the\n case, it is up to the caller to convert the string to\n bytes appropriately and pass in the bytes.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n Signature: The signature corresponding to message.\n " return self._key.sign(message, do_hash)
2,026,012,484,002,148,900
Signs message using the underlying non-extended private key. Note: This differs from `raw_sign()` since it returns a Signature object. Args: message (bytes or str): The message to be signed. If a string is provided it is assumed the encoding is 'ascii' and converted to bytes. If this is not the case, it is up to the caller to convert the string to bytes appropriately and pass in the bytes. do_hash (bool): True if the message should be hashed prior to signing, False if not. This should always be left as True except in special situations which require doing the hash outside (e.g. handling Bitcoin bugs). Returns: Signature: The signature corresponding to message.
pywallet/utils/ethereum.py
sign
ukor/pywallet
python
def sign(self, message, do_hash=True): " Signs message using the underlying non-extended private key.\n\n Note:\n This differs from `raw_sign()` since it returns a Signature object.\n\n Args:\n message (bytes or str): The message to be signed. If a\n string is provided it is assumed the encoding is\n 'ascii' and converted to bytes. If this is not the\n case, it is up to the caller to convert the string to\n bytes appropriately and pass in the bytes.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n Signature: The signature corresponding to message.\n " return self._key.sign(message, do_hash)
def sign_bitcoin(self, message, compressed=False): ' Signs a message using the underlying non-extended private\n key such that it is compatible with bitcoind, bx, and other\n Bitcoin clients/nodes/utilities.\n\n Note:\n 0x18 + b"Bitcoin Signed Message:" + newline + len(message) is\n prepended to the message before signing.\n\n Args:\n message (bytes or str): Message to be signed.\n compressed (bool):\n True if the corresponding public key will be\n used in compressed format. False if the uncompressed version\n is used.\n\n Returns:\n bytes: A Base64-encoded byte string of the signed message.\n The first byte of the encoded message contains information\n about how to recover the public key. In bitcoind parlance,\n this is the magic number containing the recovery ID and\n whether or not the key was compressed or not. (This function\n always processes full, uncompressed public-keys, so the\n magic number will always be either 27 or 28).\n ' return self._key.sign_bitcoin(message, compressed)
-615,899,387,025,259,000
Signs a message using the underlying non-extended private key such that it is compatible with bitcoind, bx, and other Bitcoin clients/nodes/utilities. Note: 0x18 + b"Bitcoin Signed Message:" + newline + len(message) is prepended to the message before signing. Args: message (bytes or str): Message to be signed. compressed (bool): True if the corresponding public key will be used in compressed format. False if the uncompressed version is used. Returns: bytes: A Base64-encoded byte string of the signed message. The first byte of the encoded message contains information about how to recover the public key. In bitcoind parlance, this is the magic number containing the recovery ID and whether or not the key was compressed or not. (This function always processes full, uncompressed public-keys, so the magic number will always be either 27 or 28).
pywallet/utils/ethereum.py
sign_bitcoin
ukor/pywallet
python
def sign_bitcoin(self, message, compressed=False): ' Signs a message using the underlying non-extended private\n key such that it is compatible with bitcoind, bx, and other\n Bitcoin clients/nodes/utilities.\n\n Note:\n 0x18 + b"Bitcoin Signed Message:" + newline + len(message) is\n prepended to the message before signing.\n\n Args:\n message (bytes or str): Message to be signed.\n compressed (bool):\n True if the corresponding public key will be\n used in compressed format. False if the uncompressed version\n is used.\n\n Returns:\n bytes: A Base64-encoded byte string of the signed message.\n The first byte of the encoded message contains information\n about how to recover the public key. In bitcoind parlance,\n this is the magic number containing the recovery ID and\n whether or not the key was compressed or not. (This function\n always processes full, uncompressed public-keys, so the\n magic number will always be either 27 or 28).\n ' return self._key.sign_bitcoin(message, compressed)
@property def identifier(self): " Returns the identifier for the key.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n In this case, it will return the RIPEMD-160 hash of the\n corresponding public key.\n\n Returns:\n bytes: A 20-byte RIPEMD-160 hash.\n " return self.public_key.hash160()
394,542,324,917,610,300
Returns the identifier for the key. A key's identifier and fingerprint are defined as: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers In this case, it will return the RIPEMD-160 hash of the corresponding public key. Returns: bytes: A 20-byte RIPEMD-160 hash.
pywallet/utils/ethereum.py
identifier
ukor/pywallet
python
@property def identifier(self): " Returns the identifier for the key.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n In this case, it will return the RIPEMD-160 hash of the\n corresponding public key.\n\n Returns:\n bytes: A 20-byte RIPEMD-160 hash.\n " return self.public_key.hash160()
@property def identifier(self): " Returns the identifier for the key.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n In this case, it will return the RIPEMD-160 hash of the\n non-extended public key.\n\n Returns:\n bytes: A 20-byte RIPEMD-160 hash.\n " return self.hash160()
1,443,509,380,358,592,800
Returns the identifier for the key. A key's identifier and fingerprint are defined as: https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers In this case, it will return the RIPEMD-160 hash of the non-extended public key. Returns: bytes: A 20-byte RIPEMD-160 hash.
pywallet/utils/ethereum.py
identifier
ukor/pywallet
python
@property def identifier(self): " Returns the identifier for the key.\n\n A key's identifier and fingerprint are defined as:\n https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#key-identifiers\n\n In this case, it will return the RIPEMD-160 hash of the\n non-extended public key.\n\n Returns:\n bytes: A 20-byte RIPEMD-160 hash.\n " return self.hash160()
def hash160(self, compressed=True): ' Return the RIPEMD-160 hash of the SHA-256 hash of the\n non-extended public key.\n\n Note:\n This always returns the hash of the compressed version of\n the public key.\n\n Returns:\n bytes: RIPEMD-160 byte string.\n ' return self._key.hash160(True)
-2,092,964,254,580,674,800
Return the RIPEMD-160 hash of the SHA-256 hash of the non-extended public key. Note: This always returns the hash of the compressed version of the public key. Returns: bytes: RIPEMD-160 byte string.
pywallet/utils/ethereum.py
hash160
ukor/pywallet
python
def hash160(self, compressed=True): ' Return the RIPEMD-160 hash of the SHA-256 hash of the\n non-extended public key.\n\n Note:\n This always returns the hash of the compressed version of\n the public key.\n\n Returns:\n bytes: RIPEMD-160 byte string.\n ' return self._key.hash160(True)
def address(self, compressed=True, testnet=False): ' Address property that returns the Base58Check\n encoded version of the HASH160.\n\n Args:\n compressed (bool): Whether or not the compressed key should\n be used.\n testnet (bool): Whether or not the key is intended for testnet\n usage. False indicates mainnet usage.\n\n Returns:\n bytes: Base58Check encoded string\n ' return self._key.address(True, testnet)
-6,539,582,272,185,335,000
Address property that returns the Base58Check encoded version of the HASH160. Args: compressed (bool): Whether or not the compressed key should be used. testnet (bool): Whether or not the key is intended for testnet usage. False indicates mainnet usage. Returns: bytes: Base58Check encoded string
pywallet/utils/ethereum.py
address
ukor/pywallet
python
def address(self, compressed=True, testnet=False): ' Address property that returns the Base58Check\n encoded version of the HASH160.\n\n Args:\n compressed (bool): Whether or not the compressed key should\n be used.\n testnet (bool): Whether or not the key is intended for testnet\n usage. False indicates mainnet usage.\n\n Returns:\n bytes: Base58Check encoded string\n ' return self._key.address(True, testnet)
def verify(self, message, signature, do_hash=True): ' Verifies that message was appropriately signed.\n\n Args:\n message (bytes): The message to be verified.\n signature (Signature): A signature object.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n verified (bool): True if the signature is verified, False\n otherwise.\n ' return self._key.verify(message, signature, do_hash)
6,523,901,315,159,231,000
Verifies that message was appropriately signed. Args: message (bytes): The message to be verified. signature (Signature): A signature object. do_hash (bool): True if the message should be hashed prior to signing, False if not. This should always be left as True except in special situations which require doing the hash outside (e.g. handling Bitcoin bugs). Returns: verified (bool): True if the signature is verified, False otherwise.
pywallet/utils/ethereum.py
verify
ukor/pywallet
python
def verify(self, message, signature, do_hash=True): ' Verifies that message was appropriately signed.\n\n Args:\n message (bytes): The message to be verified.\n signature (Signature): A signature object.\n do_hash (bool): True if the message should be hashed prior\n to signing, False if not. This should always be left as\n True except in special situations which require doing\n the hash outside (e.g. handling Bitcoin bugs).\n\n Returns:\n verified (bool): True if the signature is verified, False\n otherwise.\n ' return self._key.verify(message, signature, do_hash)
@property def compressed_bytes(self): ' Byte string corresponding to a compressed representation\n of this public key.\n\n Returns:\n b (bytes): A 33-byte long byte string.\n ' return self._key.compressed_bytes
4,253,535,832,634,557,400
Byte string corresponding to a compressed representation of this public key. Returns: b (bytes): A 33-byte long byte string.
pywallet/utils/ethereum.py
compressed_bytes
ukor/pywallet
python
@property def compressed_bytes(self): ' Byte string corresponding to a compressed representation\n of this public key.\n\n Returns:\n b (bytes): A 33-byte long byte string.\n ' return self._key.compressed_bytes
def __init__(self, master, codice, calcolatore, emulatore): "\n Inizializza i frame per l'interfaccia dell'emulatore\n " self.CD = calcolatore self.codice = codice self.delay = 100 self.master = Frame(master) self.root = emulatore self.ram = LabelFrame(self.master, text='Memoria RAM', relief=RIDGE, borderwidth=5, labelanchor='n', pady=5) self.ram.rowconfigure(0, weight=1) self.ram.columnconfigure(0, weight=1) self.ram.grid(row=0, column=0, rowspan=3, columnspan=5, sticky=(((W + E) + N) + S)) self.controlli = Frame(self.master, padx=10, pady=10) self.controlli.grid(row=0, column=5, rowspan=1) self.registri = LabelFrame(self.master, text='REGISTRI', relief=RIDGE, borderwidth=5, labelanchor='n', padx=25, pady=10) self.registri.grid(row=0, column=6, rowspan=1, sticky=(((W + E) + N) + S)) self.unita = LabelFrame(self.master, text='UC', relief=RIDGE, borderwidth=5, labelanchor='n', padx=10, pady=10) self.unita.grid(row=2, column=6, rowspan=1, sticky=N) self.variabili = Frame(self.master) self.variabili.grid(row=2, column=5) self.nstep = LabelFrame(self.variabili, text='Num. Step', relief=RIDGE, borderwidth=5, labelanchor='n') self.nstep.grid(row=0, column=5, sticky=(W + E)) self.delays = LabelFrame(self.variabili, text='Delay', relief=RIDGE, borderwidth=5, labelanchor='n') self.delays.grid(row=1, column=5, sticky=(W + E)) self.tempo = LabelFrame(self.variabili, text='Tempo', relief=RIDGE, borderwidth=5, labelanchor='n') self.tempo.grid(row=1, column=6, sticky=(W + E)) self.unitas = LabelFrame(self.unita, text='S', labelanchor='s', padx=10) self.unitas.grid(row=0, column=0, sticky=N) self.unitaf = LabelFrame(self.unita, text='F', labelanchor='s', padx=10) self.unitaf.grid(row=0, column=1, sticky=N) self.unitar = LabelFrame(self.unita, text='R', labelanchor='s', padx=10) self.unitar.grid(row=0, column=2, sticky=N) self.unitaint = LabelFrame(self.unita, text='Int.', labelanchor='s', padx=10) self.unitaint.grid(row=0, column=3, sticky=N) self.programc = LabelFrame(self.registri, text='PC', relief=FLAT, labelanchor='e', padx=5) self.programc.grid(row=0, column=0, sticky=(W + E)) self.mar = LabelFrame(self.registri, text='MAR', relief=FLAT, labelanchor='e', padx=5) self.mar.grid(row=1, column=0, sticky=(W + E)) self.mbr = LabelFrame(self.registri, text='MBR', relief=FLAT, labelanchor='e', padx=5) self.mbr.grid(row=2, column=0, sticky=(W + E)) self.lopr = LabelFrame(self.registri, text='OPR', relief=FLAT, labelanchor='e', padx=5) self.lopr.grid(row=3, column=0, sticky=(W + E)) self.vari = LabelFrame(self.registri, text='I', relief=FLAT, labelanchor='e', padx=5) self.vari.grid(row=4, column=0, sticky=(W + E)) self.vare = LabelFrame(self.registri, text='E', relief=FLAT, labelanchor='e', padx=5) self.vare.grid(row=5, column=0, sticky=(W + E)) self.lac = LabelFrame(self.registri, text='AC', relief=FLAT, labelanchor='e', padx=5) self.lac.grid(row=6, column=0, sticky=(W + E)) self.lacint = LabelFrame(self.registri, text='INT AC', relief=FLAT, labelanchor='e', padx=5) self.lacint.grid(row=7, column=0, sticky=(W + E)) self.lachex = LabelFrame(self.registri, text='HEX AC', relief=FLAT, labelanchor='e', padx=5) self.lachex.grid(row=8, column=0, sticky=(W + E)) self.micro = LabelFrame(self.master, text='Microistruzioni eseguite', relief=RIDGE, borderwidth=5, labelanchor='n', pady=5) self.micro.rowconfigure(0, weight=1) self.micro.columnconfigure(0, weight=1) self.micro.grid(row=3, column=4, rowspan=5, columnspan=5, sticky=(((W + E) + N) + S)) self.inout = LabelFrame(self.master, text='Input & Output', relief=RIDGE, borderwidth=5, labelanchor='n', pady=5) self.inout.rowconfigure(0, weight=1) self.inout.columnconfigure(0, weight=1) self.inout.grid(row=3, column=0, columnspan=4, sticky=(((W + E) + N) + S)) self.create_widgets()
-8,868,046,694,783,535,000
Inizializza i frame per l'interfaccia dell'emulatore
Emulatore.py
__init__
MircoT/py-pdp8-tk
python
def __init__(self, master, codice, calcolatore, emulatore): "\n \n " self.CD = calcolatore self.codice = codice self.delay = 100 self.master = Frame(master) self.root = emulatore self.ram = LabelFrame(self.master, text='Memoria RAM', relief=RIDGE, borderwidth=5, labelanchor='n', pady=5) self.ram.rowconfigure(0, weight=1) self.ram.columnconfigure(0, weight=1) self.ram.grid(row=0, column=0, rowspan=3, columnspan=5, sticky=(((W + E) + N) + S)) self.controlli = Frame(self.master, padx=10, pady=10) self.controlli.grid(row=0, column=5, rowspan=1) self.registri = LabelFrame(self.master, text='REGISTRI', relief=RIDGE, borderwidth=5, labelanchor='n', padx=25, pady=10) self.registri.grid(row=0, column=6, rowspan=1, sticky=(((W + E) + N) + S)) self.unita = LabelFrame(self.master, text='UC', relief=RIDGE, borderwidth=5, labelanchor='n', padx=10, pady=10) self.unita.grid(row=2, column=6, rowspan=1, sticky=N) self.variabili = Frame(self.master) self.variabili.grid(row=2, column=5) self.nstep = LabelFrame(self.variabili, text='Num. Step', relief=RIDGE, borderwidth=5, labelanchor='n') self.nstep.grid(row=0, column=5, sticky=(W + E)) self.delays = LabelFrame(self.variabili, text='Delay', relief=RIDGE, borderwidth=5, labelanchor='n') self.delays.grid(row=1, column=5, sticky=(W + E)) self.tempo = LabelFrame(self.variabili, text='Tempo', relief=RIDGE, borderwidth=5, labelanchor='n') self.tempo.grid(row=1, column=6, sticky=(W + E)) self.unitas = LabelFrame(self.unita, text='S', labelanchor='s', padx=10) self.unitas.grid(row=0, column=0, sticky=N) self.unitaf = LabelFrame(self.unita, text='F', labelanchor='s', padx=10) self.unitaf.grid(row=0, column=1, sticky=N) self.unitar = LabelFrame(self.unita, text='R', labelanchor='s', padx=10) self.unitar.grid(row=0, column=2, sticky=N) self.unitaint = LabelFrame(self.unita, text='Int.', labelanchor='s', padx=10) self.unitaint.grid(row=0, column=3, sticky=N) self.programc = LabelFrame(self.registri, text='PC', relief=FLAT, labelanchor='e', padx=5) self.programc.grid(row=0, column=0, sticky=(W + E)) self.mar = LabelFrame(self.registri, text='MAR', relief=FLAT, labelanchor='e', padx=5) self.mar.grid(row=1, column=0, sticky=(W + E)) self.mbr = LabelFrame(self.registri, text='MBR', relief=FLAT, labelanchor='e', padx=5) self.mbr.grid(row=2, column=0, sticky=(W + E)) self.lopr = LabelFrame(self.registri, text='OPR', relief=FLAT, labelanchor='e', padx=5) self.lopr.grid(row=3, column=0, sticky=(W + E)) self.vari = LabelFrame(self.registri, text='I', relief=FLAT, labelanchor='e', padx=5) self.vari.grid(row=4, column=0, sticky=(W + E)) self.vare = LabelFrame(self.registri, text='E', relief=FLAT, labelanchor='e', padx=5) self.vare.grid(row=5, column=0, sticky=(W + E)) self.lac = LabelFrame(self.registri, text='AC', relief=FLAT, labelanchor='e', padx=5) self.lac.grid(row=6, column=0, sticky=(W + E)) self.lacint = LabelFrame(self.registri, text='INT AC', relief=FLAT, labelanchor='e', padx=5) self.lacint.grid(row=7, column=0, sticky=(W + E)) self.lachex = LabelFrame(self.registri, text='HEX AC', relief=FLAT, labelanchor='e', padx=5) self.lachex.grid(row=8, column=0, sticky=(W + E)) self.micro = LabelFrame(self.master, text='Microistruzioni eseguite', relief=RIDGE, borderwidth=5, labelanchor='n', pady=5) self.micro.rowconfigure(0, weight=1) self.micro.columnconfigure(0, weight=1) self.micro.grid(row=3, column=4, rowspan=5, columnspan=5, sticky=(((W + E) + N) + S)) self.inout = LabelFrame(self.master, text='Input & Output', relief=RIDGE, borderwidth=5, labelanchor='n', pady=5) self.inout.rowconfigure(0, weight=1) self.inout.columnconfigure(0, weight=1) self.inout.grid(row=3, column=0, columnspan=4, sticky=(((W + E) + N) + S)) self.create_widgets()
def create_widgets(self): "\n Crea il layout del programma, finestra dell'emulatore\n " self.Visualizza = Text(self.ram, width=80) self.Visualizzascrollbar = Scrollbar(self.ram) self.Visualizzascrollbar.config(command=self.Visualizza.yview) self.Visualizza.config(yscrollcommand=self.Visualizzascrollbar.set) self.Visualizzascrollbar.grid(row=0, column=1, sticky=(N + S)) self.Visualizza.grid(row=0, column=0, sticky=W) self.Visualizzainout = Text(self.inout, width=62, height=7, fg='green', bg='black') self.Visualizzascrollbar_inout = Scrollbar(self.inout) self.Visualizzascrollbar_inout.config(command=self.Visualizzainout.yview) self.Visualizzainout.config(yscrollcommand=self.Visualizzascrollbar_inout.set) self.Visualizzascrollbar_inout.grid(row=0, column=1, sticky=(N + S)) self.Visualizzainout.grid(row=0, column=0, sticky=W) self.Visualizzamicro = Text(self.micro, width=55, height=7) self.Visualizzascrollbar_m = Scrollbar(self.micro) self.Visualizzascrollbar_m.config(command=self.Visualizzamicro.yview) self.Visualizzamicro.config(yscrollcommand=self.Visualizzascrollbar_m.set) self.Visualizzascrollbar_m.grid(row=0, column=1, sticky=(N + S)) self.Visualizzamicro.grid(row=0, column=0, sticky=W) self.butload = Button(self.controlli, text='LOAD', anchor=CENTER, width=15, command=self.loading, bg='SkyBlue') self.butload.grid(row=0, column=0) self.butstep = Button(self.controlli, text='Step', anchor=CENTER, width=15, command=self.step, bg='linen') self.butstep.grid(row=1, column=0) self.butminstep = Button(self.controlli, text='miniStep', anchor=CENTER, width=15, command=self.mini_step, bg='linen') self.butminstep.grid(row=2, column=0) self.butstep = Button(self.controlli, text='microStep', anchor=CENTER, width=15, command=self.micro_step, bg='linen') self.butstep.grid(row=3, column=0) self.butsetstep = Button(self.controlli, text='Set n Step', anchor=CENTER, width=15, command=self.setnstep, bg='linen') self.butsetstep.grid(row=4, column=0) self.butsetdelay = Button(self.controlli, text='Set Delay', anchor=CENTER, width=15, command=self.setdelay, bg='linen') self.butsetdelay.grid(row=5, column=0) self.butstart = Button(self.controlli, text='START', anchor=CENTER, width=15, command=self.start, bg='DarkOliveGreen3') self.butstart.grid(row=6, column=0) self.butreset = Button(self.controlli, text='RESET', anchor=CENTER, width=15, command=self.resetCD, bg='Orange3') self.butreset.grid(row=7, column=0) self.butstop = Button(self.controlli, text='STOP', anchor=CENTER, width=15, command=self.stop, bg='IndianRed') self.butstop.grid(row=8, column=0) self.butbreak = Button(self.controlli, text='BREAK', anchor=CENTER, width=15, command=self.breakpoint, bg='Magenta2') self.butbreak.grid(row=9, column=0) self.butcontinue = Button(self.controlli, text='CONTINUA', anchor=CENTER, width=15, command=self.continua, bg='Magenta2') self.butcontinue.grid(row=10, column=0) self.butesegui = Button(self.controlli, text='ESEGUI', anchor=CENTER, width=15, command=self.esegui, bg='Yellow') self.butesegui.grid(row=11, column=0) self.labelprogramc = Label(self.programc, text='00000000000', relief=SUNKEN, bg='red') self.labelprogramc.grid() self.labelmar = Label(self.mar, text='00000000000', relief=SUNKEN, bg='yellow') self.labelmar.grid() self.labelmbr = Label(self.mbr, text='000000000000000', relief=SUNKEN) self.labelmbr.grid() self.labelvari = Label(self.vari, text='0', relief=SUNKEN) self.labelvari.grid() self.labelopr = Label(self.lopr, text='000', relief=SUNKEN) self.labelopr.grid() self.labelucs = Label(self.unitas, text='0') self.labelucs.grid() self.labelucf = Label(self.unitaf, text='0') self.labelucf.grid() self.labelucr = Label(self.unitar, text='0') self.labelucr.grid() self.labelucint = Label(self.unitaint, text='0') self.labelucint.grid() self.labelnstep = Label(self.nstep, text='1') self.labelnstep.grid() self.labeldelay = Label(self.delays, text=str(self.delay)) self.labeldelay.grid() self.labeltempo = Label(self.tempo, text=str(self.CD.tempo)) self.labeltempo.grid() self.labelac = Label(self.lac, text='000000000000000', relief=SUNKEN) self.labelac.grid() self.labelacint = Label(self.lacint, text='000000000000000', relief=SUNKEN) self.labelacint.grid() self.labelachex = Label(self.lachex, text='000000000000000', relief=SUNKEN) self.labelachex.grid() self.labelvare = Label(self.vare, text='0', relief=SUNKEN) self.labelvare.grid()
2,399,548,688,207,588,400
Crea il layout del programma, finestra dell'emulatore
Emulatore.py
create_widgets
MircoT/py-pdp8-tk
python
def create_widgets(self): "\n \n " self.Visualizza = Text(self.ram, width=80) self.Visualizzascrollbar = Scrollbar(self.ram) self.Visualizzascrollbar.config(command=self.Visualizza.yview) self.Visualizza.config(yscrollcommand=self.Visualizzascrollbar.set) self.Visualizzascrollbar.grid(row=0, column=1, sticky=(N + S)) self.Visualizza.grid(row=0, column=0, sticky=W) self.Visualizzainout = Text(self.inout, width=62, height=7, fg='green', bg='black') self.Visualizzascrollbar_inout = Scrollbar(self.inout) self.Visualizzascrollbar_inout.config(command=self.Visualizzainout.yview) self.Visualizzainout.config(yscrollcommand=self.Visualizzascrollbar_inout.set) self.Visualizzascrollbar_inout.grid(row=0, column=1, sticky=(N + S)) self.Visualizzainout.grid(row=0, column=0, sticky=W) self.Visualizzamicro = Text(self.micro, width=55, height=7) self.Visualizzascrollbar_m = Scrollbar(self.micro) self.Visualizzascrollbar_m.config(command=self.Visualizzamicro.yview) self.Visualizzamicro.config(yscrollcommand=self.Visualizzascrollbar_m.set) self.Visualizzascrollbar_m.grid(row=0, column=1, sticky=(N + S)) self.Visualizzamicro.grid(row=0, column=0, sticky=W) self.butload = Button(self.controlli, text='LOAD', anchor=CENTER, width=15, command=self.loading, bg='SkyBlue') self.butload.grid(row=0, column=0) self.butstep = Button(self.controlli, text='Step', anchor=CENTER, width=15, command=self.step, bg='linen') self.butstep.grid(row=1, column=0) self.butminstep = Button(self.controlli, text='miniStep', anchor=CENTER, width=15, command=self.mini_step, bg='linen') self.butminstep.grid(row=2, column=0) self.butstep = Button(self.controlli, text='microStep', anchor=CENTER, width=15, command=self.micro_step, bg='linen') self.butstep.grid(row=3, column=0) self.butsetstep = Button(self.controlli, text='Set n Step', anchor=CENTER, width=15, command=self.setnstep, bg='linen') self.butsetstep.grid(row=4, column=0) self.butsetdelay = Button(self.controlli, text='Set Delay', anchor=CENTER, width=15, command=self.setdelay, bg='linen') self.butsetdelay.grid(row=5, column=0) self.butstart = Button(self.controlli, text='START', anchor=CENTER, width=15, command=self.start, bg='DarkOliveGreen3') self.butstart.grid(row=6, column=0) self.butreset = Button(self.controlli, text='RESET', anchor=CENTER, width=15, command=self.resetCD, bg='Orange3') self.butreset.grid(row=7, column=0) self.butstop = Button(self.controlli, text='STOP', anchor=CENTER, width=15, command=self.stop, bg='IndianRed') self.butstop.grid(row=8, column=0) self.butbreak = Button(self.controlli, text='BREAK', anchor=CENTER, width=15, command=self.breakpoint, bg='Magenta2') self.butbreak.grid(row=9, column=0) self.butcontinue = Button(self.controlli, text='CONTINUA', anchor=CENTER, width=15, command=self.continua, bg='Magenta2') self.butcontinue.grid(row=10, column=0) self.butesegui = Button(self.controlli, text='ESEGUI', anchor=CENTER, width=15, command=self.esegui, bg='Yellow') self.butesegui.grid(row=11, column=0) self.labelprogramc = Label(self.programc, text='00000000000', relief=SUNKEN, bg='red') self.labelprogramc.grid() self.labelmar = Label(self.mar, text='00000000000', relief=SUNKEN, bg='yellow') self.labelmar.grid() self.labelmbr = Label(self.mbr, text='000000000000000', relief=SUNKEN) self.labelmbr.grid() self.labelvari = Label(self.vari, text='0', relief=SUNKEN) self.labelvari.grid() self.labelopr = Label(self.lopr, text='000', relief=SUNKEN) self.labelopr.grid() self.labelucs = Label(self.unitas, text='0') self.labelucs.grid() self.labelucf = Label(self.unitaf, text='0') self.labelucf.grid() self.labelucr = Label(self.unitar, text='0') self.labelucr.grid() self.labelucint = Label(self.unitaint, text='0') self.labelucint.grid() self.labelnstep = Label(self.nstep, text='1') self.labelnstep.grid() self.labeldelay = Label(self.delays, text=str(self.delay)) self.labeldelay.grid() self.labeltempo = Label(self.tempo, text=str(self.CD.tempo)) self.labeltempo.grid() self.labelac = Label(self.lac, text='000000000000000', relief=SUNKEN) self.labelac.grid() self.labelacint = Label(self.lacint, text='000000000000000', relief=SUNKEN) self.labelacint.grid() self.labelachex = Label(self.lachex, text='000000000000000', relief=SUNKEN) self.labelachex.grid() self.labelvare = Label(self.vare, text='0', relief=SUNKEN) self.labelvare.grid()
def continua(self): "\n Continua l'esecuzione dopo un break\n " self.CD.S = True self.esegui()
-5,933,921,717,104,816,000
Continua l'esecuzione dopo un break
Emulatore.py
continua
MircoT/py-pdp8-tk
python
def continua(self): "\n \n " self.CD.S = True self.esegui()
def micro_step(self): '\n Esegue il metodo step del calcolatore didattico ed aggiorna\n ' if self.CD.S: self.CD.step(self.root, self.codice) if ((self.CD.tempo == 0) and (not self.CD.F) and (not self.CD.R)): self.CD.previstr = self.CD.nextistr self.aggiornaall()
-2,389,170,151,703,013,400
Esegue il metodo step del calcolatore didattico ed aggiorna
Emulatore.py
micro_step
MircoT/py-pdp8-tk
python
def micro_step(self): '\n \n ' if self.CD.S: self.CD.step(self.root, self.codice) if ((self.CD.tempo == 0) and (not self.CD.F) and (not self.CD.R)): self.CD.previstr = self.CD.nextistr self.aggiornaall()
def step(self): '\n Esegue il metodo step del calcolatore didattico ed aggiorna\n ' var = True if (self.CD.S and (self.CD.nstep > 0)): while (var and self.CD.S): self.CD.step(self.root, self.codice) if ((not self.CD.F) and (not self.CD.R) and (self.CD.tempo == 0)): self.CD.nstep -= 1 self.aggiornaall() self.CD.previstr = self.CD.nextistr var = False if (self.CD.nstep > 0): self.butstep.after(self.delay, self.step) else: self.CD.setnstep(1) else: self.CD.setnstep(1) self.aggiornaall()
1,178,585,213,689,599,500
Esegue il metodo step del calcolatore didattico ed aggiorna
Emulatore.py
step
MircoT/py-pdp8-tk
python
def step(self): '\n \n ' var = True if (self.CD.S and (self.CD.nstep > 0)): while (var and self.CD.S): self.CD.step(self.root, self.codice) if ((not self.CD.F) and (not self.CD.R) and (self.CD.tempo == 0)): self.CD.nstep -= 1 self.aggiornaall() self.CD.previstr = self.CD.nextistr var = False if (self.CD.nstep > 0): self.butstep.after(self.delay, self.step) else: self.CD.setnstep(1) else: self.CD.setnstep(1) self.aggiornaall()
def esegui(self): "\n Esegue il programma fino all'arresto della macchina tramite\n l'istruzione HLT\n " while self.CD.S: self.CD.step(self.root, self.codice) if ((not self.CD.F) and (not self.CD.R) and (self.CD.tempo == 0)): self.aggiornaall() self.CD.previstr = self.CD.nextistr break if self.CD.S: self.butesegui.after(self.delay, self.esegui) else: self.CD.setnstep(1) self.aggiornaall()
7,673,595,272,641,957,000
Esegue il programma fino all'arresto della macchina tramite l'istruzione HLT
Emulatore.py
esegui
MircoT/py-pdp8-tk
python
def esegui(self): "\n Esegue il programma fino all'arresto della macchina tramite\n l'istruzione HLT\n " while self.CD.S: self.CD.step(self.root, self.codice) if ((not self.CD.F) and (not self.CD.R) and (self.CD.tempo == 0)): self.aggiornaall() self.CD.previstr = self.CD.nextistr break if self.CD.S: self.butesegui.after(self.delay, self.esegui) else: self.CD.setnstep(1) self.aggiornaall()
def mini_step(self): '\n Esegue un singolo ciclo della macchina\n ' if self.CD.S: for x in range(0, 4): self.CD.step(self.root, self.codice) self.CD.nstep = 1 self.aggiornaall() if ((self.CD.F is False) and (self.CD.R is False)): self.CD.previstr = self.CD.nextistr
-9,035,354,765,232,446,000
Esegue un singolo ciclo della macchina
Emulatore.py
mini_step
MircoT/py-pdp8-tk
python
def mini_step(self): '\n \n ' if self.CD.S: for x in range(0, 4): self.CD.step(self.root, self.codice) self.CD.nstep = 1 self.aggiornaall() if ((self.CD.F is False) and (self.CD.R is False)): self.CD.previstr = self.CD.nextistr
def cerca_istr_prev(self): "\n Evidenzia di VERDE l'ultima istruzione eseguita\n " if (self.CD.PC == '000000000000'): return try: if ((self.CD.previstr == '') and (int(self.CD.PC, 2) == self.CD.START)): return else: pospc = str((3.0 + self.CD.previstr)) self.Visualizza.tag_add('PISTR', str((pospc[:(- 1)] + '16')), str((pospc[:(- 1)] + 'end'))) self.Visualizza.tag_config('PISTR', background='green') self.Visualizza.see(pospc) except TypeError: pass
6,070,608,328,843,375,000
Evidenzia di VERDE l'ultima istruzione eseguita
Emulatore.py
cerca_istr_prev
MircoT/py-pdp8-tk
python
def cerca_istr_prev(self): "\n \n " if (self.CD.PC == '000000000000'): return try: if ((self.CD.previstr == ) and (int(self.CD.PC, 2) == self.CD.START)): return else: pospc = str((3.0 + self.CD.previstr)) self.Visualizza.tag_add('PISTR', str((pospc[:(- 1)] + '16')), str((pospc[:(- 1)] + 'end'))) self.Visualizza.tag_config('PISTR', background='green') self.Visualizza.see(pospc) except TypeError: pass
def cerca_MAR(self): "\n Evidenzia di giallo l'indirizzo puntato dal MAR\n " try: pos = 3.0 stringa = self.Visualizza.get(str(pos), 'end') while ((stringa[:12] != self.CD.MAR) and (int(pos) < (len(self.CD.RAM) + 3)) and (len(self.CD.RAM) > 0)): pos += 1 stringa = self.Visualizza.get(str(pos), 'end') if (int(pos) >= (len(self.CD.RAM) + 3)): return self.Visualizza.tag_add('MAR', pos, str((float(pos) + 0.12))) self.Visualizza.tag_config('MAR', background='yellow') except TypeError: pass
1,720,936,399,942,872,800
Evidenzia di giallo l'indirizzo puntato dal MAR
Emulatore.py
cerca_MAR
MircoT/py-pdp8-tk
python
def cerca_MAR(self): "\n \n " try: pos = 3.0 stringa = self.Visualizza.get(str(pos), 'end') while ((stringa[:12] != self.CD.MAR) and (int(pos) < (len(self.CD.RAM) + 3)) and (len(self.CD.RAM) > 0)): pos += 1 stringa = self.Visualizza.get(str(pos), 'end') if (int(pos) >= (len(self.CD.RAM) + 3)): return self.Visualizza.tag_add('MAR', pos, str((float(pos) + 0.12))) self.Visualizza.tag_config('MAR', background='yellow') except TypeError: pass
def cerca_PC(self): "\n Evidenzia di rosso l'indirizzo puntato da PC\n " try: pos = 3.0 stringa = self.Visualizza.get(str(pos), 'end') while ((stringa[:12] != self.CD.PC) and (int(pos) < (len(self.CD.RAM) + 3)) and (len(self.CD.RAM) > 0)): pos += 1 stringa = self.Visualizza.get(str(pos), 'end') if (int(pos) >= (len(self.CD.RAM) + 3)): return self.Visualizza.tag_add('PC', pos, str((float(pos) + 0.12))) self.Visualizza.tag_config('PC', background='red') except TypeError: pass
-559,732,223,055,177,600
Evidenzia di rosso l'indirizzo puntato da PC
Emulatore.py
cerca_PC
MircoT/py-pdp8-tk
python
def cerca_PC(self): "\n \n " try: pos = 3.0 stringa = self.Visualizza.get(str(pos), 'end') while ((stringa[:12] != self.CD.PC) and (int(pos) < (len(self.CD.RAM) + 3)) and (len(self.CD.RAM) > 0)): pos += 1 stringa = self.Visualizza.get(str(pos), 'end') if (int(pos) >= (len(self.CD.RAM) + 3)): return self.Visualizza.tag_add('PC', pos, str((float(pos) + 0.12))) self.Visualizza.tag_config('PC', background='red') except TypeError: pass
def aggiornaout(self): '\n Aggiorna micro e input/output\n ' self.aggiornamicro() self.aggiornainout()
6,511,139,235,739,962,000
Aggiorna micro e input/output
Emulatore.py
aggiornaout
MircoT/py-pdp8-tk
python
def aggiornaout(self): '\n \n ' self.aggiornamicro() self.aggiornainout()
def aggiornamicro(self): '\n Aggiorna le microistruzioni eseguite\n ' self.Visualizzamicro.delete(1.0, END) stringa = self.CD.microistruzioni self.Visualizzamicro.insert(INSERT, stringa) self.Visualizzamicro.see(END)
-7,334,009,341,202,917,000
Aggiorna le microistruzioni eseguite
Emulatore.py
aggiornamicro
MircoT/py-pdp8-tk
python
def aggiornamicro(self): '\n \n ' self.Visualizzamicro.delete(1.0, END) stringa = self.CD.microistruzioni self.Visualizzamicro.insert(INSERT, stringa) self.Visualizzamicro.see(END)
def aggiornainout(self): '\n Aggiorna gli input ed output di sistema\n ' self.Visualizzainout.delete(1.0, END) stringa = self.CD.inout self.Visualizzainout.insert(INSERT, stringa) self.Visualizzainout.see(END)
5,196,792,618,315,077,000
Aggiorna gli input ed output di sistema
Emulatore.py
aggiornainout
MircoT/py-pdp8-tk
python
def aggiornainout(self): '\n \n ' self.Visualizzainout.delete(1.0, END) stringa = self.CD.inout self.Visualizzainout.insert(INSERT, stringa) self.Visualizzainout.see(END)
def aggiornaram(self): '\n Aggiorna lo stato della RAM\n ' self.Visualizza.delete(1.0, END) stringa = self.CD.statusRAM() self.Visualizza.insert(INSERT, stringa) self.cerca_MAR() self.cerca_PC() self.cerca_istr_prev()
-637,533,283,161,984,500
Aggiorna lo stato della RAM
Emulatore.py
aggiornaram
MircoT/py-pdp8-tk
python
def aggiornaram(self): '\n \n ' self.Visualizza.delete(1.0, END) stringa = self.CD.statusRAM() self.Visualizza.insert(INSERT, stringa) self.cerca_MAR() self.cerca_PC() self.cerca_istr_prev()
def aggiornareg(self): '\n Aggiorna lo stato dei Registri\n ' self.labelprogramc.config(text=self.CD.PC) self.labelmar.config(text=self.CD.MAR) self.labelmbr.config(text=self.CD.MBR) self.labelac.config(text=self.CD.AC) self.labelacint.config(text=str(self.CD.range(int(self.CD.AC, 2)))) self.labelachex.config(text=str(hex(int(self.CD.AC, 2))[2:].upper()).zfill(4)) self.labelvare.config(text=self.CD.E) self.labelvari.config(text=self.CD.I) self.labelopr.config(text=self.CD.OPR)
6,939,395,657,199,489,000
Aggiorna lo stato dei Registri
Emulatore.py
aggiornareg
MircoT/py-pdp8-tk
python
def aggiornareg(self): '\n \n ' self.labelprogramc.config(text=self.CD.PC) self.labelmar.config(text=self.CD.MAR) self.labelmbr.config(text=self.CD.MBR) self.labelac.config(text=self.CD.AC) self.labelacint.config(text=str(self.CD.range(int(self.CD.AC, 2)))) self.labelachex.config(text=str(hex(int(self.CD.AC, 2))[2:].upper()).zfill(4)) self.labelvare.config(text=self.CD.E) self.labelvari.config(text=self.CD.I) self.labelopr.config(text=self.CD.OPR)
def aggiornauc(self): "\n Aggiorna lo stato dell'unita' di controllo\n " if (self.CD.S and (not self.CD.breaks)): self.labelucs.config(text=self.CD.S, bg='green') self.unitas.config(bg='green') elif ((not self.CD.S) and self.CD.breaks): self.labelucs.config(text=self.CD.S, bg='Magenta2') self.unitas.config(bg='Magenta2') else: self.labelucs.config(text=self.CD.S, bg='red') self.unitas.config(bg='red') self.labelucf.config(text=self.CD.F) self.labelucr.config(text=self.CD.R) self.labelucint.config(text=self.CD.Interrupt) self.labeltempo.config(text=self.CD.tempo)
-5,809,643,282,104,300,000
Aggiorna lo stato dell'unita' di controllo
Emulatore.py
aggiornauc
MircoT/py-pdp8-tk
python
def aggiornauc(self): "\n \n " if (self.CD.S and (not self.CD.breaks)): self.labelucs.config(text=self.CD.S, bg='green') self.unitas.config(bg='green') elif ((not self.CD.S) and self.CD.breaks): self.labelucs.config(text=self.CD.S, bg='Magenta2') self.unitas.config(bg='Magenta2') else: self.labelucs.config(text=self.CD.S, bg='red') self.unitas.config(bg='red') self.labelucf.config(text=self.CD.F) self.labelucr.config(text=self.CD.R) self.labelucint.config(text=self.CD.Interrupt) self.labeltempo.config(text=self.CD.tempo)
def aggiornaall(self): '\n Aggiorna tutto\n ' self.aggiornaram() self.aggiornareg() self.aggiornauc() self.aggiornamicro() self.aggiornaout() self.labelnstep.config(text=self.CD.nstep)
-8,646,146,253,776,637,000
Aggiorna tutto
Emulatore.py
aggiornaall
MircoT/py-pdp8-tk
python
def aggiornaall(self): '\n \n ' self.aggiornaram() self.aggiornareg() self.aggiornauc() self.aggiornamicro() self.aggiornaout() self.labelnstep.config(text=self.CD.nstep)
def loading(self): '\n Carica il contenuto del codice assembly decodificandolo in binario\n nella RAM\n ' contenuto = self.codice.Inserisci.get(1.0, END) if (len(contenuto) > 1): self.resetCD() if (self.CD.carica(contenuto, self) is not None): self.CD.S = 0 self.aggiornaall()
-4,438,673,585,903,791,600
Carica il contenuto del codice assembly decodificandolo in binario nella RAM
Emulatore.py
loading
MircoT/py-pdp8-tk
python
def loading(self): '\n Carica il contenuto del codice assembly decodificandolo in binario\n nella RAM\n ' contenuto = self.codice.Inserisci.get(1.0, END) if (len(contenuto) > 1): self.resetCD() if (self.CD.carica(contenuto, self) is not None): self.CD.S = 0 self.aggiornaall()
def resetCD(self): '\n Resetta il calcolatore didattico\n ' self.CD = pdp8() self.aggiornaall()
110,645,149,466,588,060
Resetta il calcolatore didattico
Emulatore.py
resetCD
MircoT/py-pdp8-tk
python
def resetCD(self): '\n \n ' self.CD = pdp8() self.aggiornaall()
def start(self): "\n Mette la variabile Start (S) ad 1, cioe' True\n " self.CD.S = True if (self.CD.breaks == True): self.CD.breaks = False self.aggiornauc()
6,829,089,600,509,237,000
Mette la variabile Start (S) ad 1, cioe' True
Emulatore.py
start
MircoT/py-pdp8-tk
python
def start(self): "\n \n " self.CD.S = True if (self.CD.breaks == True): self.CD.breaks = False self.aggiornauc()
def stop(self): "\n Mette la variabile Start (S) ad 0, cioe' False\n " self.CD.S = False self.aggiornauc()
-8,117,244,839,212,324,000
Mette la variabile Start (S) ad 0, cioe' False
Emulatore.py
stop
MircoT/py-pdp8-tk
python
def stop(self): "\n \n " self.CD.S = False self.aggiornauc()
def setnstep(self): '\n Setta, in base al valore passato, il numero di cicli da eseguire\n ' temp = askinteger('Num Step', 'Numero di step da eseguire', initialvalue=1, minvalue=1, parent=self.root) if (temp is None): self.CD.setnstep(1) else: self.CD.setnstep(temp) self.labelnstep.config(text=self.CD.nstep)
2,629,730,336,373,217,000
Setta, in base al valore passato, il numero di cicli da eseguire
Emulatore.py
setnstep
MircoT/py-pdp8-tk
python
def setnstep(self): '\n \n ' temp = askinteger('Num Step', 'Numero di step da eseguire', initialvalue=1, minvalue=1, parent=self.root) if (temp is None): self.CD.setnstep(1) else: self.CD.setnstep(temp) self.labelnstep.config(text=self.CD.nstep)
def setdelay(self): '\n Setta, in base al valore passato, il ritardo di esecuzione.\n Il valore è espresso in millisecondi, di default = 1000\n ' temp = askinteger('Set Delay', 'Ritardo in millisecondi', initialvalue=100, minvalue=1, parent=self.root) if (temp is not None): self.delay = temp self.labeldelay.config(text=self.delay)
-2,701,462,037,646,407,700
Setta, in base al valore passato, il ritardo di esecuzione. Il valore è espresso in millisecondi, di default = 1000
Emulatore.py
setdelay
MircoT/py-pdp8-tk
python
def setdelay(self): '\n Setta, in base al valore passato, il ritardo di esecuzione.\n Il valore è espresso in millisecondi, di default = 1000\n ' temp = askinteger('Set Delay', 'Ritardo in millisecondi', initialvalue=100, minvalue=1, parent=self.root) if (temp is not None): self.delay = temp self.labeldelay.config(text=self.delay)
def breakpoint(self): '\n Setta o elimina i breakpoint dal programma caricato in memoria\n ' temp = askstring('Cella di memoria', 'Indirizzo esadecimale', parent=self.root) if (temp is not None): temp = self.CD.binario(int(temp, 16)).zfill(12) self.CD.breakpoint(temp) self.aggiornaram()
-7,659,988,798,097,755,000
Setta o elimina i breakpoint dal programma caricato in memoria
Emulatore.py
breakpoint
MircoT/py-pdp8-tk
python
def breakpoint(self): '\n \n ' temp = askstring('Cella di memoria', 'Indirizzo esadecimale', parent=self.root) if (temp is not None): temp = self.CD.binario(int(temp, 16)).zfill(12) self.CD.breakpoint(temp) self.aggiornaram()
def exit(self): '\n Esce dal programma\n ' if (askquestion('Exit', 'Sicuro di voler uscire?', parent=self.master) == YES): self.codice.master.quit() self.codice.master.destroy() else: showinfo('Suggerimento', "Forse e' meglio fare una pausa!", icon=WARNING, parent=self.master)
-8,835,884,903,772,825,000
Esce dal programma
Emulatore.py
exit
MircoT/py-pdp8-tk
python
def exit(self): '\n \n ' if (askquestion('Exit', 'Sicuro di voler uscire?', parent=self.master) == YES): self.codice.master.quit() self.codice.master.destroy() else: showinfo('Suggerimento', "Forse e' meglio fare una pausa!", icon=WARNING, parent=self.master)
def _wraps_with_cleaned_sig(wrapped, num_args_to_remove): 'Simplify the function signature by removing arguments from it.\n\n Removes the first N arguments from function signature (where N is\n num_args_to_remove). This is useful since function signatures are visible\n in our user-facing docs, and many methods in DeltaGenerator have arguments\n that users have no access to.\n\n Note that "self" is ignored by default. So to remove both "self" and the\n next argument you\'d pass num_args_to_remove=1.\n ' args_to_remove = ((None,) * num_args_to_remove) fake_wrapped = functools.partial(wrapped, *args_to_remove) fake_wrapped.__doc__ = wrapped.__doc__ fake_wrapped.__name__ = wrapped.__name__ fake_wrapped.__module__ = wrapped.__module__ return functools.wraps(fake_wrapped)
-498,736,037,893,288,960
Simplify the function signature by removing arguments from it. Removes the first N arguments from function signature (where N is num_args_to_remove). This is useful since function signatures are visible in our user-facing docs, and many methods in DeltaGenerator have arguments that users have no access to. Note that "self" is ignored by default. So to remove both "self" and the next argument you'd pass num_args_to_remove=1.
lib/streamlit/DeltaGenerator.py
_wraps_with_cleaned_sig
OakNorthAI/streamlit-base
python
def _wraps_with_cleaned_sig(wrapped, num_args_to_remove): 'Simplify the function signature by removing arguments from it.\n\n Removes the first N arguments from function signature (where N is\n num_args_to_remove). This is useful since function signatures are visible\n in our user-facing docs, and many methods in DeltaGenerator have arguments\n that users have no access to.\n\n Note that "self" is ignored by default. So to remove both "self" and the\n next argument you\'d pass num_args_to_remove=1.\n ' args_to_remove = ((None,) * num_args_to_remove) fake_wrapped = functools.partial(wrapped, *args_to_remove) fake_wrapped.__doc__ = wrapped.__doc__ fake_wrapped.__name__ = wrapped.__name__ fake_wrapped.__module__ = wrapped.__module__ return functools.wraps(fake_wrapped)
def _with_element(method): 'Wrap function and pass a NewElement proto to be filled.\n\n This is a function decorator.\n\n Converts a method of the with arguments (self, element, ...) into a method\n with arguments (self, ...). Thus, the instantiation of the element proto\n object and creation of the element are handled automatically.\n\n Parameters\n ----------\n method : callable\n A DeltaGenerator method with arguments (self, element, ...)\n\n Returns\n -------\n callable\n A new DeltaGenerator method with arguments (self, ...)\n\n ' @_wraps_with_cleaned_sig(method, 1) def wrapped_method(dg, *args, **kwargs): caching.maybe_show_cached_st_function_warning(dg, method.__name__) delta_type = method.__name__ last_index = None if ((delta_type in DELTAS_TYPES_THAT_MELT_DATAFRAMES) and (len(args) > 0)): data = args[0] if type_util.is_dataframe_compatible(data): data = type_util.convert_anything_to_df(data) if (data.index.size > 0): last_index = data.index[(- 1)] else: last_index = None def marshall_element(element): return method(dg, element, *args, **kwargs) return dg._enqueue_new_element_delta(marshall_element, delta_type, last_index) return wrapped_method
1,382,497,044,708,321,300
Wrap function and pass a NewElement proto to be filled. This is a function decorator. Converts a method of the with arguments (self, element, ...) into a method with arguments (self, ...). Thus, the instantiation of the element proto object and creation of the element are handled automatically. Parameters ---------- method : callable A DeltaGenerator method with arguments (self, element, ...) Returns ------- callable A new DeltaGenerator method with arguments (self, ...)
lib/streamlit/DeltaGenerator.py
_with_element
OakNorthAI/streamlit-base
python
def _with_element(method): 'Wrap function and pass a NewElement proto to be filled.\n\n This is a function decorator.\n\n Converts a method of the with arguments (self, element, ...) into a method\n with arguments (self, ...). Thus, the instantiation of the element proto\n object and creation of the element are handled automatically.\n\n Parameters\n ----------\n method : callable\n A DeltaGenerator method with arguments (self, element, ...)\n\n Returns\n -------\n callable\n A new DeltaGenerator method with arguments (self, ...)\n\n ' @_wraps_with_cleaned_sig(method, 1) def wrapped_method(dg, *args, **kwargs): caching.maybe_show_cached_st_function_warning(dg, method.__name__) delta_type = method.__name__ last_index = None if ((delta_type in DELTAS_TYPES_THAT_MELT_DATAFRAMES) and (len(args) > 0)): data = args[0] if type_util.is_dataframe_compatible(data): data = type_util.convert_anything_to_df(data) if (data.index.size > 0): last_index = data.index[(- 1)] else: last_index = None def marshall_element(element): return method(dg, element, *args, **kwargs) return dg._enqueue_new_element_delta(marshall_element, delta_type, last_index) return wrapped_method
def _set_widget_id(widget_type, element, user_key=None): "Set the widget id.\n\n Parameters\n ----------\n widget_type : str\n The type of the widget as stored in proto.\n element : proto\n The proto of the element\n user_key : str\n Optional user-specified key to use for the widget ID.\n If this is None, we'll generate an ID by hashing the element.\n\n " element_hash = hash(element.SerializeToString()) if (user_key is not None): widget_id = ('%s-%s' % (user_key, element_hash)) else: widget_id = ('%s' % element_hash) ctx = get_report_ctx() if (ctx is not None): added = ctx.widget_ids_this_run.add(widget_id) if (not added): raise DuplicateWidgetID(_build_duplicate_widget_message(widget_type, user_key)) el = getattr(element, widget_type) el.id = widget_id
-2,941,223,114,238,296,000
Set the widget id. Parameters ---------- widget_type : str The type of the widget as stored in proto. element : proto The proto of the element user_key : str Optional user-specified key to use for the widget ID. If this is None, we'll generate an ID by hashing the element.
lib/streamlit/DeltaGenerator.py
_set_widget_id
OakNorthAI/streamlit-base
python
def _set_widget_id(widget_type, element, user_key=None): "Set the widget id.\n\n Parameters\n ----------\n widget_type : str\n The type of the widget as stored in proto.\n element : proto\n The proto of the element\n user_key : str\n Optional user-specified key to use for the widget ID.\n If this is None, we'll generate an ID by hashing the element.\n\n " element_hash = hash(element.SerializeToString()) if (user_key is not None): widget_id = ('%s-%s' % (user_key, element_hash)) else: widget_id = ('%s' % element_hash) ctx = get_report_ctx() if (ctx is not None): added = ctx.widget_ids_this_run.add(widget_id) if (not added): raise DuplicateWidgetID(_build_duplicate_widget_message(widget_type, user_key)) el = getattr(element, widget_type) el.id = widget_id
def _get_widget_ui_value(widget_type, element, user_key=None): "Get the widget ui_value from the report context.\n NOTE: This function should be called after the proto has been filled.\n\n Parameters\n ----------\n widget_type : str\n The type of the widget as stored in proto.\n element : proto\n The proto of the element\n user_key : str\n Optional user-specified string to use as the widget ID.\n If this is None, we'll generate an ID by hashing the element.\n\n Returns\n -------\n ui_value : any\n The value of the widget set by the client or\n the default value passed. If the report context\n doesn't exist, None will be returned.\n\n " _set_widget_id(widget_type, element, user_key) el = getattr(element, widget_type) ctx = get_report_ctx() ui_value = (ctx.widgets.get_widget_value(el.id) if ctx else None) return ui_value
3,817,472,688,542,238,700
Get the widget ui_value from the report context. NOTE: This function should be called after the proto has been filled. Parameters ---------- widget_type : str The type of the widget as stored in proto. element : proto The proto of the element user_key : str Optional user-specified string to use as the widget ID. If this is None, we'll generate an ID by hashing the element. Returns ------- ui_value : any The value of the widget set by the client or the default value passed. If the report context doesn't exist, None will be returned.
lib/streamlit/DeltaGenerator.py
_get_widget_ui_value
OakNorthAI/streamlit-base
python
def _get_widget_ui_value(widget_type, element, user_key=None): "Get the widget ui_value from the report context.\n NOTE: This function should be called after the proto has been filled.\n\n Parameters\n ----------\n widget_type : str\n The type of the widget as stored in proto.\n element : proto\n The proto of the element\n user_key : str\n Optional user-specified string to use as the widget ID.\n If this is None, we'll generate an ID by hashing the element.\n\n Returns\n -------\n ui_value : any\n The value of the widget set by the client or\n the default value passed. If the report context\n doesn't exist, None will be returned.\n\n " _set_widget_id(widget_type, element, user_key) el = getattr(element, widget_type) ctx = get_report_ctx() ui_value = (ctx.widgets.get_widget_value(el.id) if ctx else None) return ui_value
def _value_or_dg(value, dg): 'Return either value, or None, or dg.\n\n This is needed because Widgets have meaningful return values. This is\n unlike other elements, which always return None. Then we internally replace\n that None with a DeltaGenerator instance.\n\n However, sometimes a widget may want to return None, and in this case it\n should not be replaced by a DeltaGenerator. So we have a special NoValue\n object that gets replaced by None.\n\n ' if (value is NoValue): return None if (value is None): return dg return value
2,538,830,385,503,340,500
Return either value, or None, or dg. This is needed because Widgets have meaningful return values. This is unlike other elements, which always return None. Then we internally replace that None with a DeltaGenerator instance. However, sometimes a widget may want to return None, and in this case it should not be replaced by a DeltaGenerator. So we have a special NoValue object that gets replaced by None.
lib/streamlit/DeltaGenerator.py
_value_or_dg
OakNorthAI/streamlit-base
python
def _value_or_dg(value, dg): 'Return either value, or None, or dg.\n\n This is needed because Widgets have meaningful return values. This is\n unlike other elements, which always return None. Then we internally replace\n that None with a DeltaGenerator instance.\n\n However, sometimes a widget may want to return None, and in this case it\n should not be replaced by a DeltaGenerator. So we have a special NoValue\n object that gets replaced by None.\n\n ' if (value is NoValue): return None if (value is None): return dg return value
def _enqueue_message(msg): 'Enqueues a ForwardMsg proto to send to the app.' ctx = get_report_ctx() if (ctx is None): raise NoSessionContext() ctx.enqueue(msg)
-3,615,354,086,389,056,500
Enqueues a ForwardMsg proto to send to the app.
lib/streamlit/DeltaGenerator.py
_enqueue_message
OakNorthAI/streamlit-base
python
def _enqueue_message(msg): ctx = get_report_ctx() if (ctx is None): raise NoSessionContext() ctx.enqueue(msg)
def __init__(self, container=BlockPath_pb2.BlockPath.MAIN, cursor=None): 'Inserts or updates elements in Streamlit apps.\n\n As a user, you should never initialize this object by hand. Instead,\n DeltaGenerator objects are initialized for you in two places:\n\n 1) When you call `dg = st.foo()` for some method "foo", sometimes `dg`\n is a DeltaGenerator object. You can call methods on the `dg` object to\n update the element `foo` that appears in the Streamlit app.\n\n 2) This is an internal detail, but `st.sidebar` itself is a\n DeltaGenerator. That\'s why you can call `st.sidebar.foo()` to place\n an element `foo` inside the sidebar.\n\n ' self._container = container self._provided_cursor = cursor
-6,126,102,335,790,701,000
Inserts or updates elements in Streamlit apps. As a user, you should never initialize this object by hand. Instead, DeltaGenerator objects are initialized for you in two places: 1) When you call `dg = st.foo()` for some method "foo", sometimes `dg` is a DeltaGenerator object. You can call methods on the `dg` object to update the element `foo` that appears in the Streamlit app. 2) This is an internal detail, but `st.sidebar` itself is a DeltaGenerator. That's why you can call `st.sidebar.foo()` to place an element `foo` inside the sidebar.
lib/streamlit/DeltaGenerator.py
__init__
OakNorthAI/streamlit-base
python
def __init__(self, container=BlockPath_pb2.BlockPath.MAIN, cursor=None): 'Inserts or updates elements in Streamlit apps.\n\n As a user, you should never initialize this object by hand. Instead,\n DeltaGenerator objects are initialized for you in two places:\n\n 1) When you call `dg = st.foo()` for some method "foo", sometimes `dg`\n is a DeltaGenerator object. You can call methods on the `dg` object to\n update the element `foo` that appears in the Streamlit app.\n\n 2) This is an internal detail, but `st.sidebar` itself is a\n DeltaGenerator. That\'s why you can call `st.sidebar.foo()` to place\n an element `foo` inside the sidebar.\n\n ' self._container = container self._provided_cursor = cursor
def _get_coordinates(self): 'Returns the element\'s 4-component location as string like "M.(1,2).3".\n\n This function uniquely identifies the element\'s position in the front-end,\n which allows (among other potential uses) the MediaFileManager to maintain\n session-specific maps of MediaFile objects placed with their "coordinates".\n\n This way, users can (say) use st.image with a stream of different images,\n and Streamlit will expire the older images and replace them in place.\n ' container = self._container if self._cursor: path = self._cursor.path index = self._cursor.index else: path = '(,)' index = '' return '{}.{}.{}'.format(container, path, index)
6,901,358,751,241,483,000
Returns the element's 4-component location as string like "M.(1,2).3". This function uniquely identifies the element's position in the front-end, which allows (among other potential uses) the MediaFileManager to maintain session-specific maps of MediaFile objects placed with their "coordinates". This way, users can (say) use st.image with a stream of different images, and Streamlit will expire the older images and replace them in place.
lib/streamlit/DeltaGenerator.py
_get_coordinates
OakNorthAI/streamlit-base
python
def _get_coordinates(self): 'Returns the element\'s 4-component location as string like "M.(1,2).3".\n\n This function uniquely identifies the element\'s position in the front-end,\n which allows (among other potential uses) the MediaFileManager to maintain\n session-specific maps of MediaFile objects placed with their "coordinates".\n\n This way, users can (say) use st.image with a stream of different images,\n and Streamlit will expire the older images and replace them in place.\n ' container = self._container if self._cursor: path = self._cursor.path index = self._cursor.index else: path = '(,)' index = return '{}.{}.{}'.format(container, path, index)
def _enqueue_new_element_delta(self, marshall_element, delta_type, last_index=None, element_width=None, element_height=None): 'Create NewElement delta, fill it, and enqueue it.\n\n Parameters\n ----------\n marshall_element : callable\n Function which sets the fields for a NewElement protobuf.\n element_width : int or None\n Desired width for the element\n element_height : int or None\n Desired height for the element\n\n Returns\n -------\n DeltaGenerator\n A DeltaGenerator that can be used to modify the newly-created\n element.\n\n ' rv = None msg = ForwardMsg_pb2.ForwardMsg() rv = marshall_element(msg.delta.new_element) msg_was_enqueued = False if (self._container and self._cursor): msg.metadata.parent_block.container = self._container msg.metadata.parent_block.path[:] = self._cursor.path msg.metadata.delta_id = self._cursor.index if (element_width is not None): msg.metadata.element_dimension_spec.width = element_width if (element_height is not None): msg.metadata.element_dimension_spec.height = element_height _enqueue_message(msg) msg_was_enqueued = True if msg_was_enqueued: output_dg = DeltaGenerator(container=self._container, cursor=self._cursor.get_locked_cursor(delta_type=delta_type, last_index=last_index)) else: output_dg = self return _value_or_dg(rv, output_dg)
3,325,375,162,167,999,500
Create NewElement delta, fill it, and enqueue it. Parameters ---------- marshall_element : callable Function which sets the fields for a NewElement protobuf. element_width : int or None Desired width for the element element_height : int or None Desired height for the element Returns ------- DeltaGenerator A DeltaGenerator that can be used to modify the newly-created element.
lib/streamlit/DeltaGenerator.py
_enqueue_new_element_delta
OakNorthAI/streamlit-base
python
def _enqueue_new_element_delta(self, marshall_element, delta_type, last_index=None, element_width=None, element_height=None): 'Create NewElement delta, fill it, and enqueue it.\n\n Parameters\n ----------\n marshall_element : callable\n Function which sets the fields for a NewElement protobuf.\n element_width : int or None\n Desired width for the element\n element_height : int or None\n Desired height for the element\n\n Returns\n -------\n DeltaGenerator\n A DeltaGenerator that can be used to modify the newly-created\n element.\n\n ' rv = None msg = ForwardMsg_pb2.ForwardMsg() rv = marshall_element(msg.delta.new_element) msg_was_enqueued = False if (self._container and self._cursor): msg.metadata.parent_block.container = self._container msg.metadata.parent_block.path[:] = self._cursor.path msg.metadata.delta_id = self._cursor.index if (element_width is not None): msg.metadata.element_dimension_spec.width = element_width if (element_height is not None): msg.metadata.element_dimension_spec.height = element_height _enqueue_message(msg) msg_was_enqueued = True if msg_was_enqueued: output_dg = DeltaGenerator(container=self._container, cursor=self._cursor.get_locked_cursor(delta_type=delta_type, last_index=last_index)) else: output_dg = self return _value_or_dg(rv, output_dg)
@_with_element def balloons(self, element): 'Draw celebratory balloons.\n\n Example\n -------\n >>> st.balloons()\n\n ...then watch your app and get ready for a celebration!\n\n ' element.balloons.type = Balloons_pb2.Balloons.DEFAULT element.balloons.execution_id = random.randrange(4294967295)
-8,763,906,819,590,347,000
Draw celebratory balloons. Example ------- >>> st.balloons() ...then watch your app and get ready for a celebration!
lib/streamlit/DeltaGenerator.py
balloons
OakNorthAI/streamlit-base
python
@_with_element def balloons(self, element): 'Draw celebratory balloons.\n\n Example\n -------\n >>> st.balloons()\n\n ...then watch your app and get ready for a celebration!\n\n ' element.balloons.type = Balloons_pb2.Balloons.DEFAULT element.balloons.execution_id = random.randrange(4294967295)
@_with_element def text(self, element, body): "Write fixed-width and preformatted text.\n\n Parameters\n ----------\n body : str\n The string to display.\n\n Example\n -------\n >>> st.text('This is some text.')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PYxU1kee5ubuhGR11NsnT1\n height: 50px\n\n " element.text.body = _clean_text(body)
-8,381,293,017,526,778,000
Write fixed-width and preformatted text. Parameters ---------- body : str The string to display. Example ------- >>> st.text('This is some text.') .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PYxU1kee5ubuhGR11NsnT1 height: 50px
lib/streamlit/DeltaGenerator.py
text
OakNorthAI/streamlit-base
python
@_with_element def text(self, element, body): "Write fixed-width and preformatted text.\n\n Parameters\n ----------\n body : str\n The string to display.\n\n Example\n -------\n >>> st.text('This is some text.')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PYxU1kee5ubuhGR11NsnT1\n height: 50px\n\n " element.text.body = _clean_text(body)
@_with_element def markdown(self, element, body, unsafe_allow_html=False): 'Display string formatted as Markdown.\n\n Parameters\n ----------\n body : str\n The string to display as Github-flavored Markdown. Syntax\n information can be found at: https://github.github.com/gfm.\n\n This also supports:\n\n * Emoji shortcodes, such as `:+1:` and `:sunglasses:`.\n For a list of all supported codes,\n see https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json.\n\n * LaTeX expressions, by just wrapping them in "$" or "$$" (the "$$"\n must be on their own lines). Supported LaTeX functions are listed\n at https://katex.org/docs/supported.html.\n\n unsafe_allow_html : bool\n By default, any HTML tags found in the body will be escaped and\n therefore treated as pure text. This behavior may be turned off by\n setting this argument to True.\n\n That said, we *strongly advise against it*. It is hard to write\n secure HTML, so by using this argument you may be compromising your\n users\' security. For more information, see:\n\n https://github.com/streamlit/streamlit/issues/152\n\n *Also note that `unsafe_allow_html` is a temporary measure and may\n be removed from Streamlit at any time.*\n\n If you decide to turn on HTML anyway, we ask you to please tell us\n your exact use case here:\n\n https://discuss.streamlit.io/t/96\n\n This will help us come up with safe APIs that allow you to do what\n you want.\n\n Example\n -------\n >>> st.markdown(\'Streamlit is **_really_ cool**.\')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PXz9xgY8aB88eziDVEZLyS\n height: 50px\n\n ' element.markdown.body = _clean_text(body) element.markdown.allow_html = unsafe_allow_html
4,004,008,554,206,298,000
Display string formatted as Markdown. Parameters ---------- body : str The string to display as Github-flavored Markdown. Syntax information can be found at: https://github.github.com/gfm. This also supports: * Emoji shortcodes, such as `:+1:` and `:sunglasses:`. For a list of all supported codes, see https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json. * LaTeX expressions, by just wrapping them in "$" or "$$" (the "$$" must be on their own lines). Supported LaTeX functions are listed at https://katex.org/docs/supported.html. unsafe_allow_html : bool By default, any HTML tags found in the body will be escaped and therefore treated as pure text. This behavior may be turned off by setting this argument to True. That said, we *strongly advise against it*. It is hard to write secure HTML, so by using this argument you may be compromising your users' security. For more information, see: https://github.com/streamlit/streamlit/issues/152 *Also note that `unsafe_allow_html` is a temporary measure and may be removed from Streamlit at any time.* If you decide to turn on HTML anyway, we ask you to please tell us your exact use case here: https://discuss.streamlit.io/t/96 This will help us come up with safe APIs that allow you to do what you want. Example ------- >>> st.markdown('Streamlit is **_really_ cool**.') .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PXz9xgY8aB88eziDVEZLyS height: 50px
lib/streamlit/DeltaGenerator.py
markdown
OakNorthAI/streamlit-base
python
@_with_element def markdown(self, element, body, unsafe_allow_html=False): 'Display string formatted as Markdown.\n\n Parameters\n ----------\n body : str\n The string to display as Github-flavored Markdown. Syntax\n information can be found at: https://github.github.com/gfm.\n\n This also supports:\n\n * Emoji shortcodes, such as `:+1:` and `:sunglasses:`.\n For a list of all supported codes,\n see https://raw.githubusercontent.com/omnidan/node-emoji/master/lib/emoji.json.\n\n * LaTeX expressions, by just wrapping them in "$" or "$$" (the "$$"\n must be on their own lines). Supported LaTeX functions are listed\n at https://katex.org/docs/supported.html.\n\n unsafe_allow_html : bool\n By default, any HTML tags found in the body will be escaped and\n therefore treated as pure text. This behavior may be turned off by\n setting this argument to True.\n\n That said, we *strongly advise against it*. It is hard to write\n secure HTML, so by using this argument you may be compromising your\n users\' security. For more information, see:\n\n https://github.com/streamlit/streamlit/issues/152\n\n *Also note that `unsafe_allow_html` is a temporary measure and may\n be removed from Streamlit at any time.*\n\n If you decide to turn on HTML anyway, we ask you to please tell us\n your exact use case here:\n\n https://discuss.streamlit.io/t/96\n\n This will help us come up with safe APIs that allow you to do what\n you want.\n\n Example\n -------\n >>> st.markdown(\'Streamlit is **_really_ cool**.\')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PXz9xgY8aB88eziDVEZLyS\n height: 50px\n\n ' element.markdown.body = _clean_text(body) element.markdown.allow_html = unsafe_allow_html
@_with_element def latex(self, element, body): "Display mathematical expressions formatted as LaTeX.\n\n Supported LaTeX functions are listed at\n https://katex.org/docs/supported.html.\n\n Parameters\n ----------\n body : str or SymPy expression\n The string or SymPy expression to display as LaTeX. If str, it's\n a good idea to use raw Python strings since LaTeX uses backslashes\n a lot.\n\n\n Example\n -------\n >>> st.latex(r'''\n ... a + ar + a r^2 + a r^3 + \\cdots + a r^{n-1} =\n ... \\sum_{k=0}^{n-1} ar^k =\n ... a \\left(\\frac{1-r^{n}}{1-r}\\right)\n ... ''')\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=NJFsy6NbGTsH2RF9W6ioQ4\n height: 75px\n\n " if type_util.is_sympy_expession(body): import sympy body = sympy.latex(body) element.markdown.body = ('$$\n%s\n$$' % _clean_text(body))
2,476,711,617,061,567,000
Display mathematical expressions formatted as LaTeX. Supported LaTeX functions are listed at https://katex.org/docs/supported.html. Parameters ---------- body : str or SymPy expression The string or SymPy expression to display as LaTeX. If str, it's a good idea to use raw Python strings since LaTeX uses backslashes a lot. Example ------- >>> st.latex(r''' ... a + ar + a r^2 + a r^3 + \cdots + a r^{n-1} = ... \sum_{k=0}^{n-1} ar^k = ... a \left(\frac{1-r^{n}}{1-r}\right) ... ''') .. output:: https://share.streamlit.io/0.50.0-td2L/index.html?id=NJFsy6NbGTsH2RF9W6ioQ4 height: 75px
lib/streamlit/DeltaGenerator.py
latex
OakNorthAI/streamlit-base
python
@_with_element def latex(self, element, body): "Display mathematical expressions formatted as LaTeX.\n\n Supported LaTeX functions are listed at\n https://katex.org/docs/supported.html.\n\n Parameters\n ----------\n body : str or SymPy expression\n The string or SymPy expression to display as LaTeX. If str, it's\n a good idea to use raw Python strings since LaTeX uses backslashes\n a lot.\n\n\n Example\n -------\n >>> st.latex(r'\n ... a + ar + a r^2 + a r^3 + \\cdots + a r^{n-1} =\n ... \\sum_{k=0}^{n-1} ar^k =\n ... a \\left(\\frac{1-r^{n}}{1-r}\\right)\n ... ')\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=NJFsy6NbGTsH2RF9W6ioQ4\n height: 75px\n\n " if type_util.is_sympy_expession(body): import sympy body = sympy.latex(body) element.markdown.body = ('$$\n%s\n$$' % _clean_text(body))
@_with_element def code(self, element, body, language='python'): 'Display a code block with optional syntax highlighting.\n\n (This is a convenience wrapper around `st.markdown()`)\n\n Parameters\n ----------\n body : str\n The string to display as code.\n\n language : str\n The language that the code is written in, for syntax highlighting.\n If omitted, the code will be unstyled.\n\n Example\n -------\n >>> code = \'\'\'def hello():\n ... print("Hello, Streamlit!")\'\'\'\n >>> st.code(code, language=\'python\')\n\n .. output::\n https://share.streamlit.io/0.27.0-kBtt/index.html?id=VDRnaCEZWSBCNUd5gNQZv2\n height: 100px\n\n ' markdown = ('```%(language)s\n%(body)s\n```' % {'language': (language or ''), 'body': body}) element.markdown.body = _clean_text(markdown)
-6,307,285,162,227,188,000
Display a code block with optional syntax highlighting. (This is a convenience wrapper around `st.markdown()`) Parameters ---------- body : str The string to display as code. language : str The language that the code is written in, for syntax highlighting. If omitted, the code will be unstyled. Example ------- >>> code = '''def hello(): ... print("Hello, Streamlit!")''' >>> st.code(code, language='python') .. output:: https://share.streamlit.io/0.27.0-kBtt/index.html?id=VDRnaCEZWSBCNUd5gNQZv2 height: 100px
lib/streamlit/DeltaGenerator.py
code
OakNorthAI/streamlit-base
python
@_with_element def code(self, element, body, language='python'): 'Display a code block with optional syntax highlighting.\n\n (This is a convenience wrapper around `st.markdown()`)\n\n Parameters\n ----------\n body : str\n The string to display as code.\n\n language : str\n The language that the code is written in, for syntax highlighting.\n If omitted, the code will be unstyled.\n\n Example\n -------\n >>> code = \'\'\'def hello():\n ... print("Hello, Streamlit!")\'\'\'\n >>> st.code(code, language=\'python\')\n\n .. output::\n https://share.streamlit.io/0.27.0-kBtt/index.html?id=VDRnaCEZWSBCNUd5gNQZv2\n height: 100px\n\n ' markdown = ('```%(language)s\n%(body)s\n```' % {'language': (language or ), 'body': body}) element.markdown.body = _clean_text(markdown)
@_with_element def json(self, element, body): "Display object or string as a pretty-printed JSON string.\n\n Parameters\n ----------\n body : Object or str\n The object to print as JSON. All referenced objects should be\n serializable to JSON as well. If object is a string, we assume it\n contains serialized JSON.\n\n Example\n -------\n >>> st.json({\n ... 'foo': 'bar',\n ... 'baz': 'boz',\n ... 'stuff': [\n ... 'stuff 1',\n ... 'stuff 2',\n ... 'stuff 3',\n ... 'stuff 5',\n ... ],\n ... })\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=CTFkMQd89hw3yZbZ4AUymS\n height: 280px\n\n " import streamlit as st if (not isinstance(body, str)): try: body = json.dumps(body, default=(lambda o: str(type(o)))) except TypeError as err: st.warning(('Warning: this data structure was not fully serializable as JSON due to one or more unexpected keys. (Error was: %s)' % err)) body = json.dumps(body, skipkeys=True, default=(lambda o: str(type(o)))) element.json.body = body
-4,540,416,328,640,454,000
Display object or string as a pretty-printed JSON string. Parameters ---------- body : Object or str The object to print as JSON. All referenced objects should be serializable to JSON as well. If object is a string, we assume it contains serialized JSON. Example ------- >>> st.json({ ... 'foo': 'bar', ... 'baz': 'boz', ... 'stuff': [ ... 'stuff 1', ... 'stuff 2', ... 'stuff 3', ... 'stuff 5', ... ], ... }) .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=CTFkMQd89hw3yZbZ4AUymS height: 280px
lib/streamlit/DeltaGenerator.py
json
OakNorthAI/streamlit-base
python
@_with_element def json(self, element, body): "Display object or string as a pretty-printed JSON string.\n\n Parameters\n ----------\n body : Object or str\n The object to print as JSON. All referenced objects should be\n serializable to JSON as well. If object is a string, we assume it\n contains serialized JSON.\n\n Example\n -------\n >>> st.json({\n ... 'foo': 'bar',\n ... 'baz': 'boz',\n ... 'stuff': [\n ... 'stuff 1',\n ... 'stuff 2',\n ... 'stuff 3',\n ... 'stuff 5',\n ... ],\n ... })\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=CTFkMQd89hw3yZbZ4AUymS\n height: 280px\n\n " import streamlit as st if (not isinstance(body, str)): try: body = json.dumps(body, default=(lambda o: str(type(o)))) except TypeError as err: st.warning(('Warning: this data structure was not fully serializable as JSON due to one or more unexpected keys. (Error was: %s)' % err)) body = json.dumps(body, skipkeys=True, default=(lambda o: str(type(o)))) element.json.body = body
@_with_element def title(self, element, body): "Display text in title formatting.\n\n Each document should have a single `st.title()`, although this is not\n enforced.\n\n Parameters\n ----------\n body : str\n The text to display.\n\n Example\n -------\n >>> st.title('This is a title')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=SFcBGANWd8kWXF28XnaEZj\n height: 100px\n\n " element.markdown.body = ('# %s' % _clean_text(body))
-6,305,926,949,152,020,000
Display text in title formatting. Each document should have a single `st.title()`, although this is not enforced. Parameters ---------- body : str The text to display. Example ------- >>> st.title('This is a title') .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=SFcBGANWd8kWXF28XnaEZj height: 100px
lib/streamlit/DeltaGenerator.py
title
OakNorthAI/streamlit-base
python
@_with_element def title(self, element, body): "Display text in title formatting.\n\n Each document should have a single `st.title()`, although this is not\n enforced.\n\n Parameters\n ----------\n body : str\n The text to display.\n\n Example\n -------\n >>> st.title('This is a title')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=SFcBGANWd8kWXF28XnaEZj\n height: 100px\n\n " element.markdown.body = ('# %s' % _clean_text(body))
@_with_element def header(self, element, body): "Display text in header formatting.\n\n Parameters\n ----------\n body : str\n The text to display.\n\n Example\n -------\n >>> st.header('This is a header')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=AnfQVFgSCQtGv6yMUMUYjj\n height: 100px\n\n " element.markdown.body = ('## %s' % _clean_text(body))
5,263,767,285,842,401,000
Display text in header formatting. Parameters ---------- body : str The text to display. Example ------- >>> st.header('This is a header') .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=AnfQVFgSCQtGv6yMUMUYjj height: 100px
lib/streamlit/DeltaGenerator.py
header
OakNorthAI/streamlit-base
python
@_with_element def header(self, element, body): "Display text in header formatting.\n\n Parameters\n ----------\n body : str\n The text to display.\n\n Example\n -------\n >>> st.header('This is a header')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=AnfQVFgSCQtGv6yMUMUYjj\n height: 100px\n\n " element.markdown.body = ('## %s' % _clean_text(body))
@_with_element def subheader(self, element, body): "Display text in subheader formatting.\n\n Parameters\n ----------\n body : str\n The text to display.\n\n Example\n -------\n >>> st.subheader('This is a subheader')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=LBKJTfFUwudrbWENSHV6cJ\n height: 100px\n\n " element.markdown.body = ('### %s' % _clean_text(body))
5,586,132,893,850,543,000
Display text in subheader formatting. Parameters ---------- body : str The text to display. Example ------- >>> st.subheader('This is a subheader') .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=LBKJTfFUwudrbWENSHV6cJ height: 100px
lib/streamlit/DeltaGenerator.py
subheader
OakNorthAI/streamlit-base
python
@_with_element def subheader(self, element, body): "Display text in subheader formatting.\n\n Parameters\n ----------\n body : str\n The text to display.\n\n Example\n -------\n >>> st.subheader('This is a subheader')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=LBKJTfFUwudrbWENSHV6cJ\n height: 100px\n\n " element.markdown.body = ('### %s' % _clean_text(body))
@_with_element def error(self, element, body): "Display error message.\n\n Parameters\n ----------\n body : str\n The error text to display.\n\n Example\n -------\n >>> st.error('This is an error')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.ERROR
1,972,284,234,575,259,400
Display error message. Parameters ---------- body : str The error text to display. Example ------- >>> st.error('This is an error')
lib/streamlit/DeltaGenerator.py
error
OakNorthAI/streamlit-base
python
@_with_element def error(self, element, body): "Display error message.\n\n Parameters\n ----------\n body : str\n The error text to display.\n\n Example\n -------\n >>> st.error('This is an error')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.ERROR
@_with_element def warning(self, element, body): "Display warning message.\n\n Parameters\n ----------\n body : str\n The warning text to display.\n\n Example\n -------\n >>> st.warning('This is a warning')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.WARNING
1,412,789,457,126,936,000
Display warning message. Parameters ---------- body : str The warning text to display. Example ------- >>> st.warning('This is a warning')
lib/streamlit/DeltaGenerator.py
warning
OakNorthAI/streamlit-base
python
@_with_element def warning(self, element, body): "Display warning message.\n\n Parameters\n ----------\n body : str\n The warning text to display.\n\n Example\n -------\n >>> st.warning('This is a warning')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.WARNING
@_with_element def info(self, element, body): "Display an informational message.\n\n Parameters\n ----------\n body : str\n The info text to display.\n\n Example\n -------\n >>> st.info('This is a purely informational message')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.INFO
-542,370,585,494,341,060
Display an informational message. Parameters ---------- body : str The info text to display. Example ------- >>> st.info('This is a purely informational message')
lib/streamlit/DeltaGenerator.py
info
OakNorthAI/streamlit-base
python
@_with_element def info(self, element, body): "Display an informational message.\n\n Parameters\n ----------\n body : str\n The info text to display.\n\n Example\n -------\n >>> st.info('This is a purely informational message')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.INFO
@_with_element def success(self, element, body): "Display a success message.\n\n Parameters\n ----------\n body : str\n The success text to display.\n\n Example\n -------\n >>> st.success('This is a success message!')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.SUCCESS
-3,019,921,363,302,528,500
Display a success message. Parameters ---------- body : str The success text to display. Example ------- >>> st.success('This is a success message!')
lib/streamlit/DeltaGenerator.py
success
OakNorthAI/streamlit-base
python
@_with_element def success(self, element, body): "Display a success message.\n\n Parameters\n ----------\n body : str\n The success text to display.\n\n Example\n -------\n >>> st.success('This is a success message!')\n\n " element.alert.body = _clean_text(body) element.alert.format = Alert_pb2.Alert.SUCCESS
@_with_element def help(self, element, obj): "Display object's doc string, nicely formatted.\n\n Displays the doc string for this object.\n\n Parameters\n ----------\n obj : Object\n The object whose docstring should be displayed.\n\n Example\n -------\n\n Don't remember how to initialize a dataframe? Try this:\n\n >>> st.help(pandas.DataFrame)\n\n Want to quickly check what datatype is output by a certain function?\n Try:\n\n >>> x = my_poorly_documented_function()\n >>> st.help(x)\n\n " import streamlit.elements.doc_string as doc_string doc_string.marshall(element, obj)
-3,615,020,235,629,871,000
Display object's doc string, nicely formatted. Displays the doc string for this object. Parameters ---------- obj : Object The object whose docstring should be displayed. Example ------- Don't remember how to initialize a dataframe? Try this: >>> st.help(pandas.DataFrame) Want to quickly check what datatype is output by a certain function? Try: >>> x = my_poorly_documented_function() >>> st.help(x)
lib/streamlit/DeltaGenerator.py
help
OakNorthAI/streamlit-base
python
@_with_element def help(self, element, obj): "Display object's doc string, nicely formatted.\n\n Displays the doc string for this object.\n\n Parameters\n ----------\n obj : Object\n The object whose docstring should be displayed.\n\n Example\n -------\n\n Don't remember how to initialize a dataframe? Try this:\n\n >>> st.help(pandas.DataFrame)\n\n Want to quickly check what datatype is output by a certain function?\n Try:\n\n >>> x = my_poorly_documented_function()\n >>> st.help(x)\n\n " import streamlit.elements.doc_string as doc_string doc_string.marshall(element, obj)
@_with_element def exception(self, element, exception): "Display an exception.\n\n Parameters\n ----------\n exception : Exception\n The exception to display.\n\n Example\n -------\n >>> e = RuntimeError('This is an exception of type RuntimeError')\n >>> st.exception(e)\n\n " import streamlit.elements.exception_proto as exception_proto exception_proto.marshall(element.exception, exception)
-1,978,820,827,651,106,000
Display an exception. Parameters ---------- exception : Exception The exception to display. Example ------- >>> e = RuntimeError('This is an exception of type RuntimeError') >>> st.exception(e)
lib/streamlit/DeltaGenerator.py
exception
OakNorthAI/streamlit-base
python
@_with_element def exception(self, element, exception): "Display an exception.\n\n Parameters\n ----------\n exception : Exception\n The exception to display.\n\n Example\n -------\n >>> e = RuntimeError('This is an exception of type RuntimeError')\n >>> st.exception(e)\n\n " import streamlit.elements.exception_proto as exception_proto exception_proto.marshall(element.exception, exception)
def dataframe(self, data=None, width=None, height=None): "Display a dataframe as an interactive table.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict,\n or None\n The data to display.\n\n If 'data' is a pandas.Styler, it will be used to style its\n underyling DataFrame. Streamlit supports custom cell\n values and colors. (It does not support some of the more exotic\n pandas styling features, like bar charts, hovering, and captions.)\n Styler support is experimental!\n width : int or None\n Desired width of the UI element expressed in pixels. If None, a\n default width based on the page width is used.\n height : int or None\n Desired height of the UI element expressed in pixels. If None, a\n default height is used.\n\n Examples\n --------\n >>> df = pd.DataFrame(\n ... np.random.randn(50, 20),\n ... columns=('col %d' % i for i in range(20)))\n ...\n >>> st.dataframe(df) # Same as st.write(df)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=165mJbzWdAC8Duf8a4tjyQ\n height: 330px\n\n >>> st.dataframe(df, 200, 100)\n\n You can also pass a Pandas Styler object to change the style of\n the rendered DataFrame:\n\n >>> df = pd.DataFrame(\n ... np.random.randn(10, 20),\n ... columns=('col %d' % i for i in range(20)))\n ...\n >>> st.dataframe(df.style.highlight_max(axis=0))\n\n .. output::\n https://share.streamlit.io/0.29.0-dV1Y/index.html?id=Hb6UymSNuZDzojUNybzPby\n height: 285px\n\n " import streamlit.elements.data_frame_proto as data_frame_proto def set_data_frame(delta): data_frame_proto.marshall_data_frame(data, delta.data_frame) return self._enqueue_new_element_delta(set_data_frame, 'dataframe', element_width=width, element_height=height)
3,596,530,301,364,283,000
Display a dataframe as an interactive table. Parameters ---------- data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict, or None The data to display. If 'data' is a pandas.Styler, it will be used to style its underyling DataFrame. Streamlit supports custom cell values and colors. (It does not support some of the more exotic pandas styling features, like bar charts, hovering, and captions.) Styler support is experimental! width : int or None Desired width of the UI element expressed in pixels. If None, a default width based on the page width is used. height : int or None Desired height of the UI element expressed in pixels. If None, a default height is used. Examples -------- >>> df = pd.DataFrame( ... np.random.randn(50, 20), ... columns=('col %d' % i for i in range(20))) ... >>> st.dataframe(df) # Same as st.write(df) .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=165mJbzWdAC8Duf8a4tjyQ height: 330px >>> st.dataframe(df, 200, 100) You can also pass a Pandas Styler object to change the style of the rendered DataFrame: >>> df = pd.DataFrame( ... np.random.randn(10, 20), ... columns=('col %d' % i for i in range(20))) ... >>> st.dataframe(df.style.highlight_max(axis=0)) .. output:: https://share.streamlit.io/0.29.0-dV1Y/index.html?id=Hb6UymSNuZDzojUNybzPby height: 285px
lib/streamlit/DeltaGenerator.py
dataframe
OakNorthAI/streamlit-base
python
def dataframe(self, data=None, width=None, height=None): "Display a dataframe as an interactive table.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict,\n or None\n The data to display.\n\n If 'data' is a pandas.Styler, it will be used to style its\n underyling DataFrame. Streamlit supports custom cell\n values and colors. (It does not support some of the more exotic\n pandas styling features, like bar charts, hovering, and captions.)\n Styler support is experimental!\n width : int or None\n Desired width of the UI element expressed in pixels. If None, a\n default width based on the page width is used.\n height : int or None\n Desired height of the UI element expressed in pixels. If None, a\n default height is used.\n\n Examples\n --------\n >>> df = pd.DataFrame(\n ... np.random.randn(50, 20),\n ... columns=('col %d' % i for i in range(20)))\n ...\n >>> st.dataframe(df) # Same as st.write(df)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=165mJbzWdAC8Duf8a4tjyQ\n height: 330px\n\n >>> st.dataframe(df, 200, 100)\n\n You can also pass a Pandas Styler object to change the style of\n the rendered DataFrame:\n\n >>> df = pd.DataFrame(\n ... np.random.randn(10, 20),\n ... columns=('col %d' % i for i in range(20)))\n ...\n >>> st.dataframe(df.style.highlight_max(axis=0))\n\n .. output::\n https://share.streamlit.io/0.29.0-dV1Y/index.html?id=Hb6UymSNuZDzojUNybzPby\n height: 285px\n\n " import streamlit.elements.data_frame_proto as data_frame_proto def set_data_frame(delta): data_frame_proto.marshall_data_frame(data, delta.data_frame) return self._enqueue_new_element_delta(set_data_frame, 'dataframe', element_width=width, element_height=height)
@_with_element def line_chart(self, element, data=None, width=0, height=0, use_container_width=True): 'Display a line chart.\n\n This is just syntax-sugar around st.altair_chart. The main difference\n is this command uses the data\'s own column and indices to figure out\n the chart\'s spec. As a result this is easier to use for many "just plot\n this" scenarios, while being less customizable.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict\n or None\n Data to be plotted.\n\n width : int\n The chart width in pixels. If 0, selects the width automatically.\n\n height : int\n The chart width in pixels. If 0, selects the height automatically.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the width argument.\n\n Example\n -------\n >>> chart_data = pd.DataFrame(\n ... np.random.randn(20, 3),\n ... columns=[\'a\', \'b\', \'c\'])\n ...\n >>> st.line_chart(chart_data)\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=BdxXG3MmrVBfJyqS2R2ki8\n height: 220px\n\n ' import streamlit.elements.altair as altair chart = altair.generate_chart('line', data, width, height) altair.marshall(element.vega_lite_chart, chart, use_container_width)
3,271,366,809,158,010,000
Display a line chart. This is just syntax-sugar around st.altair_chart. The main difference is this command uses the data's own column and indices to figure out the chart's spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. Parameters ---------- data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict or None Data to be plotted. width : int The chart width in pixels. If 0, selects the width automatically. height : int The chart width in pixels. If 0, selects the height automatically. use_container_width : bool If True, set the chart width to the column width. This takes precedence over the width argument. Example ------- >>> chart_data = pd.DataFrame( ... np.random.randn(20, 3), ... columns=['a', 'b', 'c']) ... >>> st.line_chart(chart_data) .. output:: https://share.streamlit.io/0.50.0-td2L/index.html?id=BdxXG3MmrVBfJyqS2R2ki8 height: 220px
lib/streamlit/DeltaGenerator.py
line_chart
OakNorthAI/streamlit-base
python
@_with_element def line_chart(self, element, data=None, width=0, height=0, use_container_width=True): 'Display a line chart.\n\n This is just syntax-sugar around st.altair_chart. The main difference\n is this command uses the data\'s own column and indices to figure out\n the chart\'s spec. As a result this is easier to use for many "just plot\n this" scenarios, while being less customizable.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict\n or None\n Data to be plotted.\n\n width : int\n The chart width in pixels. If 0, selects the width automatically.\n\n height : int\n The chart width in pixels. If 0, selects the height automatically.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the width argument.\n\n Example\n -------\n >>> chart_data = pd.DataFrame(\n ... np.random.randn(20, 3),\n ... columns=[\'a\', \'b\', \'c\'])\n ...\n >>> st.line_chart(chart_data)\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=BdxXG3MmrVBfJyqS2R2ki8\n height: 220px\n\n ' import streamlit.elements.altair as altair chart = altair.generate_chart('line', data, width, height) altair.marshall(element.vega_lite_chart, chart, use_container_width)
@_with_element def area_chart(self, element, data=None, width=0, height=0, use_container_width=True): 'Display a area chart.\n\n This is just syntax-sugar around st.altair_chart. The main difference\n is this command uses the data\'s own column and indices to figure out\n the chart\'s spec. As a result this is easier to use for many "just plot\n this" scenarios, while being less customizable.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, or dict\n Data to be plotted.\n\n width : int\n The chart width in pixels. If 0, selects the width automatically.\n\n height : int\n The chart width in pixels. If 0, selects the height automatically.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the width argument.\n\n Example\n -------\n >>> chart_data = pd.DataFrame(\n ... np.random.randn(20, 3),\n ... columns=[\'a\', \'b\', \'c\'])\n ...\n >>> st.area_chart(chart_data)\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=Pp65STuFj65cJRDfhGh4Jt\n height: 220px\n\n ' import streamlit.elements.altair as altair chart = altair.generate_chart('area', data, width, height) altair.marshall(element.vega_lite_chart, chart, use_container_width)
8,608,271,067,037,099,000
Display a area chart. This is just syntax-sugar around st.altair_chart. The main difference is this command uses the data's own column and indices to figure out the chart's spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. Parameters ---------- data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, or dict Data to be plotted. width : int The chart width in pixels. If 0, selects the width automatically. height : int The chart width in pixels. If 0, selects the height automatically. use_container_width : bool If True, set the chart width to the column width. This takes precedence over the width argument. Example ------- >>> chart_data = pd.DataFrame( ... np.random.randn(20, 3), ... columns=['a', 'b', 'c']) ... >>> st.area_chart(chart_data) .. output:: https://share.streamlit.io/0.50.0-td2L/index.html?id=Pp65STuFj65cJRDfhGh4Jt height: 220px
lib/streamlit/DeltaGenerator.py
area_chart
OakNorthAI/streamlit-base
python
@_with_element def area_chart(self, element, data=None, width=0, height=0, use_container_width=True): 'Display a area chart.\n\n This is just syntax-sugar around st.altair_chart. The main difference\n is this command uses the data\'s own column and indices to figure out\n the chart\'s spec. As a result this is easier to use for many "just plot\n this" scenarios, while being less customizable.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, or dict\n Data to be plotted.\n\n width : int\n The chart width in pixels. If 0, selects the width automatically.\n\n height : int\n The chart width in pixels. If 0, selects the height automatically.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the width argument.\n\n Example\n -------\n >>> chart_data = pd.DataFrame(\n ... np.random.randn(20, 3),\n ... columns=[\'a\', \'b\', \'c\'])\n ...\n >>> st.area_chart(chart_data)\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=Pp65STuFj65cJRDfhGh4Jt\n height: 220px\n\n ' import streamlit.elements.altair as altair chart = altair.generate_chart('area', data, width, height) altair.marshall(element.vega_lite_chart, chart, use_container_width)
@_with_element def bar_chart(self, element, data=None, width=0, height=0, use_container_width=True): 'Display a bar chart.\n\n This is just syntax-sugar around st.altair_chart. The main difference\n is this command uses the data\'s own column and indices to figure out\n the chart\'s spec. As a result this is easier to use for many "just plot\n this" scenarios, while being less customizable.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, or dict\n Data to be plotted.\n\n width : int\n The chart width in pixels. If 0, selects the width automatically.\n\n height : int\n The chart width in pixels. If 0, selects the height automatically.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the width argument.\n\n Example\n -------\n >>> chart_data = pd.DataFrame(\n ... np.random.randn(50, 3),\n ... columns=["a", "b", "c"])\n ...\n >>> st.bar_chart(chart_data)\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=5U5bjR2b3jFwnJdDfSvuRk\n height: 220px\n\n ' import streamlit.elements.altair as altair chart = altair.generate_chart('bar', data, width, height) altair.marshall(element.vega_lite_chart, chart, use_container_width)
1,886,139,325,102,552,600
Display a bar chart. This is just syntax-sugar around st.altair_chart. The main difference is this command uses the data's own column and indices to figure out the chart's spec. As a result this is easier to use for many "just plot this" scenarios, while being less customizable. Parameters ---------- data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, or dict Data to be plotted. width : int The chart width in pixels. If 0, selects the width automatically. height : int The chart width in pixels. If 0, selects the height automatically. use_container_width : bool If True, set the chart width to the column width. This takes precedence over the width argument. Example ------- >>> chart_data = pd.DataFrame( ... np.random.randn(50, 3), ... columns=["a", "b", "c"]) ... >>> st.bar_chart(chart_data) .. output:: https://share.streamlit.io/0.50.0-td2L/index.html?id=5U5bjR2b3jFwnJdDfSvuRk height: 220px
lib/streamlit/DeltaGenerator.py
bar_chart
OakNorthAI/streamlit-base
python
@_with_element def bar_chart(self, element, data=None, width=0, height=0, use_container_width=True): 'Display a bar chart.\n\n This is just syntax-sugar around st.altair_chart. The main difference\n is this command uses the data\'s own column and indices to figure out\n the chart\'s spec. As a result this is easier to use for many "just plot\n this" scenarios, while being less customizable.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, or dict\n Data to be plotted.\n\n width : int\n The chart width in pixels. If 0, selects the width automatically.\n\n height : int\n The chart width in pixels. If 0, selects the height automatically.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the width argument.\n\n Example\n -------\n >>> chart_data = pd.DataFrame(\n ... np.random.randn(50, 3),\n ... columns=["a", "b", "c"])\n ...\n >>> st.bar_chart(chart_data)\n\n .. output::\n https://share.streamlit.io/0.50.0-td2L/index.html?id=5U5bjR2b3jFwnJdDfSvuRk\n height: 220px\n\n ' import streamlit.elements.altair as altair chart = altair.generate_chart('bar', data, width, height) altair.marshall(element.vega_lite_chart, chart, use_container_width)
@_with_element def vega_lite_chart(self, element, data=None, spec=None, width=0, use_container_width=False, **kwargs): "Display a chart using the Vega-Lite library.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict,\n or None\n Either the data to be plotted or a Vega-Lite spec containing the\n data (which more closely follows the Vega-Lite API).\n\n spec : dict or None\n The Vega-Lite spec for the chart. If the spec was already passed in\n the previous argument, this must be set to None. See\n https://vega.github.io/vega-lite/docs/ for more info.\n\n width : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the Vega-Lite\n spec. Please refer to the Vega-Lite documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over Vega-Lite's native `width` value.\n\n **kwargs : any\n Same as spec, but as keywords.\n\n Example\n -------\n\n >>> import pandas as pd\n >>> import numpy as np\n >>>\n >>> df = pd.DataFrame(\n ... np.random.randn(200, 3),\n ... columns=['a', 'b', 'c'])\n >>>\n >>> st.vega_lite_chart(df, {\n ... 'mark': {'type': 'circle', 'tooltip': True},\n ... 'encoding': {\n ... 'x': {'field': 'a', 'type': 'quantitative'},\n ... 'y': {'field': 'b', 'type': 'quantitative'},\n ... 'size': {'field': 'c', 'type': 'quantitative'},\n ... 'color': {'field': 'c', 'type': 'quantitative'},\n ... },\n ... })\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=8jmmXR8iKoZGV4kXaKGYV5\n height: 200px\n\n Examples of Vega-Lite usage without Streamlit can be found at\n https://vega.github.io/vega-lite/examples/. Most of those can be easily\n translated to the syntax shown above.\n\n " import streamlit.elements.vega_lite as vega_lite if (width != 0): import streamlit as st st.warning("The `width` argument in `st.vega_lite_chart` is deprecated and will be removed on 2020-03-04. To set the width, you should instead use Vega-Lite's native `width` argument as described at https://vega.github.io/vega-lite/docs/size.html") vega_lite.marshall(element.vega_lite_chart, data, spec, use_container_width=use_container_width, **kwargs)
-3,457,005,380,634,783,000
Display a chart using the Vega-Lite library. Parameters ---------- data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict, or None Either the data to be plotted or a Vega-Lite spec containing the data (which more closely follows the Vega-Lite API). spec : dict or None The Vega-Lite spec for the chart. If the spec was already passed in the previous argument, this must be set to None. See https://vega.github.io/vega-lite/docs/ for more info. width : number Deprecated. If != 0 (default), will show an alert. From now on you should set the width directly in the Vega-Lite spec. Please refer to the Vega-Lite documentation for details. use_container_width : bool If True, set the chart width to the column width. This takes precedence over Vega-Lite's native `width` value. **kwargs : any Same as spec, but as keywords. Example ------- >>> import pandas as pd >>> import numpy as np >>> >>> df = pd.DataFrame( ... np.random.randn(200, 3), ... columns=['a', 'b', 'c']) >>> >>> st.vega_lite_chart(df, { ... 'mark': {'type': 'circle', 'tooltip': True}, ... 'encoding': { ... 'x': {'field': 'a', 'type': 'quantitative'}, ... 'y': {'field': 'b', 'type': 'quantitative'}, ... 'size': {'field': 'c', 'type': 'quantitative'}, ... 'color': {'field': 'c', 'type': 'quantitative'}, ... }, ... }) .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=8jmmXR8iKoZGV4kXaKGYV5 height: 200px Examples of Vega-Lite usage without Streamlit can be found at https://vega.github.io/vega-lite/examples/. Most of those can be easily translated to the syntax shown above.
lib/streamlit/DeltaGenerator.py
vega_lite_chart
OakNorthAI/streamlit-base
python
@_with_element def vega_lite_chart(self, element, data=None, spec=None, width=0, use_container_width=False, **kwargs): "Display a chart using the Vega-Lite library.\n\n Parameters\n ----------\n data : pandas.DataFrame, pandas.Styler, numpy.ndarray, Iterable, dict,\n or None\n Either the data to be plotted or a Vega-Lite spec containing the\n data (which more closely follows the Vega-Lite API).\n\n spec : dict or None\n The Vega-Lite spec for the chart. If the spec was already passed in\n the previous argument, this must be set to None. See\n https://vega.github.io/vega-lite/docs/ for more info.\n\n width : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the Vega-Lite\n spec. Please refer to the Vega-Lite documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over Vega-Lite's native `width` value.\n\n **kwargs : any\n Same as spec, but as keywords.\n\n Example\n -------\n\n >>> import pandas as pd\n >>> import numpy as np\n >>>\n >>> df = pd.DataFrame(\n ... np.random.randn(200, 3),\n ... columns=['a', 'b', 'c'])\n >>>\n >>> st.vega_lite_chart(df, {\n ... 'mark': {'type': 'circle', 'tooltip': True},\n ... 'encoding': {\n ... 'x': {'field': 'a', 'type': 'quantitative'},\n ... 'y': {'field': 'b', 'type': 'quantitative'},\n ... 'size': {'field': 'c', 'type': 'quantitative'},\n ... 'color': {'field': 'c', 'type': 'quantitative'},\n ... },\n ... })\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=8jmmXR8iKoZGV4kXaKGYV5\n height: 200px\n\n Examples of Vega-Lite usage without Streamlit can be found at\n https://vega.github.io/vega-lite/examples/. Most of those can be easily\n translated to the syntax shown above.\n\n " import streamlit.elements.vega_lite as vega_lite if (width != 0): import streamlit as st st.warning("The `width` argument in `st.vega_lite_chart` is deprecated and will be removed on 2020-03-04. To set the width, you should instead use Vega-Lite's native `width` argument as described at https://vega.github.io/vega-lite/docs/size.html") vega_lite.marshall(element.vega_lite_chart, data, spec, use_container_width=use_container_width, **kwargs)
@_with_element def altair_chart(self, element, altair_chart, width=0, use_container_width=False): "Display a chart using the Altair library.\n\n Parameters\n ----------\n altair_chart : altair.vegalite.v2.api.Chart\n The Altair chart object to display.\n\n width : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the Altair\n spec. Please refer to the Altair documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over Altair's native `width` value.\n\n Example\n -------\n\n >>> import pandas as pd\n >>> import numpy as np\n >>> import altair as alt\n >>>\n >>> df = pd.DataFrame(\n ... np.random.randn(200, 3),\n ... columns=['a', 'b', 'c'])\n ...\n >>> c = alt.Chart(df).mark_circle().encode(\n ... x='a', y='b', size='c', color='c', tooltip=['a', 'b', 'c'])\n >>>\n >>> st.altair_chart(c, use_container_width=True)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=8jmmXR8iKoZGV4kXaKGYV5\n height: 200px\n\n Examples of Altair charts can be found at\n https://altair-viz.github.io/gallery/.\n\n " import streamlit.elements.altair as altair if (width != 0): import streamlit as st st.warning("The `width` argument in `st.vega_lite_chart` is deprecated and will be removed on 2020-03-04. To set the width, you should instead use altair's native `width` argument as described at https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html") altair.marshall(element.vega_lite_chart, altair_chart, use_container_width=use_container_width)
-2,914,322,783,231,960,600
Display a chart using the Altair library. Parameters ---------- altair_chart : altair.vegalite.v2.api.Chart The Altair chart object to display. width : number Deprecated. If != 0 (default), will show an alert. From now on you should set the width directly in the Altair spec. Please refer to the Altair documentation for details. use_container_width : bool If True, set the chart width to the column width. This takes precedence over Altair's native `width` value. Example ------- >>> import pandas as pd >>> import numpy as np >>> import altair as alt >>> >>> df = pd.DataFrame( ... np.random.randn(200, 3), ... columns=['a', 'b', 'c']) ... >>> c = alt.Chart(df).mark_circle().encode( ... x='a', y='b', size='c', color='c', tooltip=['a', 'b', 'c']) >>> >>> st.altair_chart(c, use_container_width=True) .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=8jmmXR8iKoZGV4kXaKGYV5 height: 200px Examples of Altair charts can be found at https://altair-viz.github.io/gallery/.
lib/streamlit/DeltaGenerator.py
altair_chart
OakNorthAI/streamlit-base
python
@_with_element def altair_chart(self, element, altair_chart, width=0, use_container_width=False): "Display a chart using the Altair library.\n\n Parameters\n ----------\n altair_chart : altair.vegalite.v2.api.Chart\n The Altair chart object to display.\n\n width : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the Altair\n spec. Please refer to the Altair documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over Altair's native `width` value.\n\n Example\n -------\n\n >>> import pandas as pd\n >>> import numpy as np\n >>> import altair as alt\n >>>\n >>> df = pd.DataFrame(\n ... np.random.randn(200, 3),\n ... columns=['a', 'b', 'c'])\n ...\n >>> c = alt.Chart(df).mark_circle().encode(\n ... x='a', y='b', size='c', color='c', tooltip=['a', 'b', 'c'])\n >>>\n >>> st.altair_chart(c, use_container_width=True)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=8jmmXR8iKoZGV4kXaKGYV5\n height: 200px\n\n Examples of Altair charts can be found at\n https://altair-viz.github.io/gallery/.\n\n " import streamlit.elements.altair as altair if (width != 0): import streamlit as st st.warning("The `width` argument in `st.vega_lite_chart` is deprecated and will be removed on 2020-03-04. To set the width, you should instead use altair's native `width` argument as described at https://altair-viz.github.io/user_guide/generated/toplevel/altair.Chart.html") altair.marshall(element.vega_lite_chart, altair_chart, use_container_width=use_container_width)
@_with_element def graphviz_chart(self, element, figure_or_dot, width=0, height=0, use_container_width=False): "Display a graph using the dagre-d3 library.\n\n Parameters\n ----------\n figure_or_dot : graphviz.dot.Graph, graphviz.dot.Digraph, str\n The Graphlib graph object or dot string to display\n\n width : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the Graphviz\n spec. Please refer to the Graphviz documentation for details.\n\n height : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the height directly in the Graphviz\n spec. Please refer to the Graphviz documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the figure's native `width` value.\n\n Example\n -------\n\n >>> import streamlit as st\n >>> import graphviz as graphviz\n >>>\n >>> # Create a graphlib graph object\n >>> graph = graphviz.Digraph()\n >>> graph.edge('run', 'intr')\n >>> graph.edge('intr', 'runbl')\n >>> graph.edge('runbl', 'run')\n >>> graph.edge('run', 'kernel')\n >>> graph.edge('kernel', 'zombie')\n >>> graph.edge('kernel', 'sleep')\n >>> graph.edge('kernel', 'runmem')\n >>> graph.edge('sleep', 'swap')\n >>> graph.edge('swap', 'runswap')\n >>> graph.edge('runswap', 'new')\n >>> graph.edge('runswap', 'runmem')\n >>> graph.edge('new', 'runmem')\n >>> graph.edge('sleep', 'runmem')\n >>>\n >>> st.graphviz_chart(graph)\n\n Or you can render the chart from the graph using GraphViz's Dot\n language:\n\n >>> st.graphviz_chart('''\n digraph {\n run -> intr\n intr -> runbl\n runbl -> run\n run -> kernel\n kernel -> zombie\n kernel -> sleep\n kernel -> runmem\n sleep -> swap\n swap -> runswap\n runswap -> new\n runswap -> runmem\n new -> runmem\n sleep -> runmem\n }\n ''')\n\n .. output::\n https://share.streamlit.io/0.56.0-xTAd/index.html?id=GBn3GXZie5K1kXuBKe4yQL\n height: 400px\n\n " import streamlit.elements.graphviz_chart as graphviz_chart if ((width != 0) and (height != 0)): import streamlit as st st.warning('The `width` and `height` arguments in `st.graphviz` are deprecated and will be removed on 2020-03-04') elif (width != 0): import streamlit as st st.warning('The `width` argument in `st.graphviz` is deprecated and will be removed on 2020-03-04') elif (height != 0): import streamlit as st st.warning('The `height` argument in `st.graphviz` is deprecated and will be removed on 2020-03-04') graphviz_chart.marshall(element.graphviz_chart, figure_or_dot, use_container_width)
-580,667,264,566,975,000
Display a graph using the dagre-d3 library. Parameters ---------- figure_or_dot : graphviz.dot.Graph, graphviz.dot.Digraph, str The Graphlib graph object or dot string to display width : number Deprecated. If != 0 (default), will show an alert. From now on you should set the width directly in the Graphviz spec. Please refer to the Graphviz documentation for details. height : number Deprecated. If != 0 (default), will show an alert. From now on you should set the height directly in the Graphviz spec. Please refer to the Graphviz documentation for details. use_container_width : bool If True, set the chart width to the column width. This takes precedence over the figure's native `width` value. Example ------- >>> import streamlit as st >>> import graphviz as graphviz >>> >>> # Create a graphlib graph object >>> graph = graphviz.Digraph() >>> graph.edge('run', 'intr') >>> graph.edge('intr', 'runbl') >>> graph.edge('runbl', 'run') >>> graph.edge('run', 'kernel') >>> graph.edge('kernel', 'zombie') >>> graph.edge('kernel', 'sleep') >>> graph.edge('kernel', 'runmem') >>> graph.edge('sleep', 'swap') >>> graph.edge('swap', 'runswap') >>> graph.edge('runswap', 'new') >>> graph.edge('runswap', 'runmem') >>> graph.edge('new', 'runmem') >>> graph.edge('sleep', 'runmem') >>> >>> st.graphviz_chart(graph) Or you can render the chart from the graph using GraphViz's Dot language: >>> st.graphviz_chart(''' digraph { run -> intr intr -> runbl runbl -> run run -> kernel kernel -> zombie kernel -> sleep kernel -> runmem sleep -> swap swap -> runswap runswap -> new runswap -> runmem new -> runmem sleep -> runmem } ''') .. output:: https://share.streamlit.io/0.56.0-xTAd/index.html?id=GBn3GXZie5K1kXuBKe4yQL height: 400px
lib/streamlit/DeltaGenerator.py
graphviz_chart
OakNorthAI/streamlit-base
python
@_with_element def graphviz_chart(self, element, figure_or_dot, width=0, height=0, use_container_width=False): "Display a graph using the dagre-d3 library.\n\n Parameters\n ----------\n figure_or_dot : graphviz.dot.Graph, graphviz.dot.Digraph, str\n The Graphlib graph object or dot string to display\n\n width : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the Graphviz\n spec. Please refer to the Graphviz documentation for details.\n\n height : number\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the height directly in the Graphviz\n spec. Please refer to the Graphviz documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the figure's native `width` value.\n\n Example\n -------\n\n >>> import streamlit as st\n >>> import graphviz as graphviz\n >>>\n >>> # Create a graphlib graph object\n >>> graph = graphviz.Digraph()\n >>> graph.edge('run', 'intr')\n >>> graph.edge('intr', 'runbl')\n >>> graph.edge('runbl', 'run')\n >>> graph.edge('run', 'kernel')\n >>> graph.edge('kernel', 'zombie')\n >>> graph.edge('kernel', 'sleep')\n >>> graph.edge('kernel', 'runmem')\n >>> graph.edge('sleep', 'swap')\n >>> graph.edge('swap', 'runswap')\n >>> graph.edge('runswap', 'new')\n >>> graph.edge('runswap', 'runmem')\n >>> graph.edge('new', 'runmem')\n >>> graph.edge('sleep', 'runmem')\n >>>\n >>> st.graphviz_chart(graph)\n\n Or you can render the chart from the graph using GraphViz's Dot\n language:\n\n >>> st.graphviz_chart('\n digraph {\n run -> intr\n intr -> runbl\n runbl -> run\n run -> kernel\n kernel -> zombie\n kernel -> sleep\n kernel -> runmem\n sleep -> swap\n swap -> runswap\n runswap -> new\n runswap -> runmem\n new -> runmem\n sleep -> runmem\n }\n ')\n\n .. output::\n https://share.streamlit.io/0.56.0-xTAd/index.html?id=GBn3GXZie5K1kXuBKe4yQL\n height: 400px\n\n " import streamlit.elements.graphviz_chart as graphviz_chart if ((width != 0) and (height != 0)): import streamlit as st st.warning('The `width` and `height` arguments in `st.graphviz` are deprecated and will be removed on 2020-03-04') elif (width != 0): import streamlit as st st.warning('The `width` argument in `st.graphviz` is deprecated and will be removed on 2020-03-04') elif (height != 0): import streamlit as st st.warning('The `height` argument in `st.graphviz` is deprecated and will be removed on 2020-03-04') graphviz_chart.marshall(element.graphviz_chart, figure_or_dot, use_container_width)
@_with_element def plotly_chart(self, element, figure_or_data, width=0, height=0, use_container_width=False, sharing='streamlit', **kwargs): "Display an interactive Plotly chart.\n\n Plotly is a charting library for Python. The arguments to this function\n closely follow the ones for Plotly's `plot()` function. You can find\n more about Plotly at https://plot.ly/python.\n\n Parameters\n ----------\n figure_or_data : plotly.graph_objs.Figure, plotly.graph_objs.Data,\n dict/list of plotly.graph_objs.Figure/Data, or\n matplotlib.figure.Figure\n\n See https://plot.ly/python/ for examples of graph descriptions.\n\n If a Matplotlib Figure, converts it to a Plotly figure and displays\n it.\n\n width : int\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the figure.\n Please refer to the Plotly documentation for details.\n\n height : int\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the height directly in the figure.\n Please refer to the Plotly documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the figure's native `width` value.\n\n sharing : {'streamlit', 'private', 'secret', 'public'}\n Use 'streamlit' to insert the plot and all its dependencies\n directly in the Streamlit app, which means it works offline too.\n This is the default.\n Use any other sharing mode to send the app to Plotly's servers,\n and embed the result into the Streamlit app. See\n https://plot.ly/python/privacy/ for more. Note that these sharing\n modes require a Plotly account.\n\n **kwargs\n Any argument accepted by Plotly's `plot()` function.\n\n\n To show Plotly charts in Streamlit, just call `st.plotly_chart`\n wherever you would call Plotly's `py.plot` or `py.iplot`.\n\n Example\n -------\n\n The example below comes straight from the examples at\n https://plot.ly/python:\n\n >>> import streamlit as st\n >>> import plotly.figure_factory as ff\n >>> import numpy as np\n >>>\n >>> # Add histogram data\n >>> x1 = np.random.randn(200) - 2\n >>> x2 = np.random.randn(200)\n >>> x3 = np.random.randn(200) + 2\n >>>\n >>> # Group data together\n >>> hist_data = [x1, x2, x3]\n >>>\n >>> group_labels = ['Group 1', 'Group 2', 'Group 3']\n >>>\n >>> # Create distplot with custom bin_size\n >>> fig = ff.create_distplot(\n ... hist_data, group_labels, bin_size=[.1, .25, .5])\n >>>\n >>> # Plot!\n >>> st.plotly_chart(fig, use_container_width=True)\n\n .. output::\n https://share.streamlit.io/0.56.0-xTAd/index.html?id=TuP96xX8JnsoQeUGAPjkGQ\n height: 400px\n\n " import streamlit.elements.plotly_chart as plotly_chart if ((width != 0) and (height != 0)): import streamlit as st st.warning("The `width` and `height` arguments in `st.plotly_chart` are deprecated and will be removed on 2020-03-04. To set these values, you should instead use Plotly's native arguments as described at https://plot.ly/python/setting-graph-size/") elif (width != 0): import streamlit as st st.warning("The `width` argument in `st.plotly_chart` is deprecated and will be removed on 2020-03-04. To set the width, you should instead use Plotly's native `width` argument as described at https://plot.ly/python/setting-graph-size/") elif (height != 0): import streamlit as st st.warning("The `height` argument in `st.plotly_chart` is deprecated and will be removed on 2020-03-04. To set the height, you should instead use Plotly's native `height` argument as described at https://plot.ly/python/setting-graph-size/") plotly_chart.marshall(element.plotly_chart, figure_or_data, use_container_width, sharing, **kwargs)
1,226,472,571,385,272,000
Display an interactive Plotly chart. Plotly is a charting library for Python. The arguments to this function closely follow the ones for Plotly's `plot()` function. You can find more about Plotly at https://plot.ly/python. Parameters ---------- figure_or_data : plotly.graph_objs.Figure, plotly.graph_objs.Data, dict/list of plotly.graph_objs.Figure/Data, or matplotlib.figure.Figure See https://plot.ly/python/ for examples of graph descriptions. If a Matplotlib Figure, converts it to a Plotly figure and displays it. width : int Deprecated. If != 0 (default), will show an alert. From now on you should set the width directly in the figure. Please refer to the Plotly documentation for details. height : int Deprecated. If != 0 (default), will show an alert. From now on you should set the height directly in the figure. Please refer to the Plotly documentation for details. use_container_width : bool If True, set the chart width to the column width. This takes precedence over the figure's native `width` value. sharing : {'streamlit', 'private', 'secret', 'public'} Use 'streamlit' to insert the plot and all its dependencies directly in the Streamlit app, which means it works offline too. This is the default. Use any other sharing mode to send the app to Plotly's servers, and embed the result into the Streamlit app. See https://plot.ly/python/privacy/ for more. Note that these sharing modes require a Plotly account. **kwargs Any argument accepted by Plotly's `plot()` function. To show Plotly charts in Streamlit, just call `st.plotly_chart` wherever you would call Plotly's `py.plot` or `py.iplot`. Example ------- The example below comes straight from the examples at https://plot.ly/python: >>> import streamlit as st >>> import plotly.figure_factory as ff >>> import numpy as np >>> >>> # Add histogram data >>> x1 = np.random.randn(200) - 2 >>> x2 = np.random.randn(200) >>> x3 = np.random.randn(200) + 2 >>> >>> # Group data together >>> hist_data = [x1, x2, x3] >>> >>> group_labels = ['Group 1', 'Group 2', 'Group 3'] >>> >>> # Create distplot with custom bin_size >>> fig = ff.create_distplot( ... hist_data, group_labels, bin_size=[.1, .25, .5]) >>> >>> # Plot! >>> st.plotly_chart(fig, use_container_width=True) .. output:: https://share.streamlit.io/0.56.0-xTAd/index.html?id=TuP96xX8JnsoQeUGAPjkGQ height: 400px
lib/streamlit/DeltaGenerator.py
plotly_chart
OakNorthAI/streamlit-base
python
@_with_element def plotly_chart(self, element, figure_or_data, width=0, height=0, use_container_width=False, sharing='streamlit', **kwargs): "Display an interactive Plotly chart.\n\n Plotly is a charting library for Python. The arguments to this function\n closely follow the ones for Plotly's `plot()` function. You can find\n more about Plotly at https://plot.ly/python.\n\n Parameters\n ----------\n figure_or_data : plotly.graph_objs.Figure, plotly.graph_objs.Data,\n dict/list of plotly.graph_objs.Figure/Data, or\n matplotlib.figure.Figure\n\n See https://plot.ly/python/ for examples of graph descriptions.\n\n If a Matplotlib Figure, converts it to a Plotly figure and displays\n it.\n\n width : int\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the width directly in the figure.\n Please refer to the Plotly documentation for details.\n\n height : int\n Deprecated. If != 0 (default), will show an alert.\n From now on you should set the height directly in the figure.\n Please refer to the Plotly documentation for details.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over the figure's native `width` value.\n\n sharing : {'streamlit', 'private', 'secret', 'public'}\n Use 'streamlit' to insert the plot and all its dependencies\n directly in the Streamlit app, which means it works offline too.\n This is the default.\n Use any other sharing mode to send the app to Plotly's servers,\n and embed the result into the Streamlit app. See\n https://plot.ly/python/privacy/ for more. Note that these sharing\n modes require a Plotly account.\n\n **kwargs\n Any argument accepted by Plotly's `plot()` function.\n\n\n To show Plotly charts in Streamlit, just call `st.plotly_chart`\n wherever you would call Plotly's `py.plot` or `py.iplot`.\n\n Example\n -------\n\n The example below comes straight from the examples at\n https://plot.ly/python:\n\n >>> import streamlit as st\n >>> import plotly.figure_factory as ff\n >>> import numpy as np\n >>>\n >>> # Add histogram data\n >>> x1 = np.random.randn(200) - 2\n >>> x2 = np.random.randn(200)\n >>> x3 = np.random.randn(200) + 2\n >>>\n >>> # Group data together\n >>> hist_data = [x1, x2, x3]\n >>>\n >>> group_labels = ['Group 1', 'Group 2', 'Group 3']\n >>>\n >>> # Create distplot with custom bin_size\n >>> fig = ff.create_distplot(\n ... hist_data, group_labels, bin_size=[.1, .25, .5])\n >>>\n >>> # Plot!\n >>> st.plotly_chart(fig, use_container_width=True)\n\n .. output::\n https://share.streamlit.io/0.56.0-xTAd/index.html?id=TuP96xX8JnsoQeUGAPjkGQ\n height: 400px\n\n " import streamlit.elements.plotly_chart as plotly_chart if ((width != 0) and (height != 0)): import streamlit as st st.warning("The `width` and `height` arguments in `st.plotly_chart` are deprecated and will be removed on 2020-03-04. To set these values, you should instead use Plotly's native arguments as described at https://plot.ly/python/setting-graph-size/") elif (width != 0): import streamlit as st st.warning("The `width` argument in `st.plotly_chart` is deprecated and will be removed on 2020-03-04. To set the width, you should instead use Plotly's native `width` argument as described at https://plot.ly/python/setting-graph-size/") elif (height != 0): import streamlit as st st.warning("The `height` argument in `st.plotly_chart` is deprecated and will be removed on 2020-03-04. To set the height, you should instead use Plotly's native `height` argument as described at https://plot.ly/python/setting-graph-size/") plotly_chart.marshall(element.plotly_chart, figure_or_data, use_container_width, sharing, **kwargs)
@_with_element def pyplot(self, element, fig=None, clear_figure=None, **kwargs): 'Display a matplotlib.pyplot figure.\n\n Parameters\n ----------\n fig : Matplotlib Figure\n The figure to plot. When this argument isn\'t specified, which is\n the usual case, this function will render the global plot.\n\n clear_figure : bool\n If True, the figure will be cleared after being rendered.\n If False, the figure will not be cleared after being rendered.\n If left unspecified, we pick a default based on the value of `fig`.\n\n * If `fig` is set, defaults to `False`.\n\n * If `fig` is not set, defaults to `True`. This simulates Jupyter\'s\n approach to matplotlib rendering.\n\n **kwargs : any\n Arguments to pass to Matplotlib\'s savefig function.\n\n Example\n -------\n >>> import matplotlib.pyplot as plt\n >>> import numpy as np\n >>>\n >>> arr = np.random.normal(1, 1, size=100)\n >>> plt.hist(arr, bins=20)\n >>>\n >>> st.pyplot()\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PwzFN7oLZsvb6HDdwdjkRB\n height: 530px\n\n Notes\n -----\n Matplotlib support several different types of "backends". If you\'re\n getting an error using Matplotlib with Streamlit, try setting your\n backend to "TkAgg"::\n\n echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc\n\n For more information, see https://matplotlib.org/faq/usage_faq.html.\n\n ' import streamlit.elements.pyplot as pyplot pyplot.marshall(self._get_coordinates, element, fig, clear_figure, **kwargs)
-147,165,660,458,301,900
Display a matplotlib.pyplot figure. Parameters ---------- fig : Matplotlib Figure The figure to plot. When this argument isn't specified, which is the usual case, this function will render the global plot. clear_figure : bool If True, the figure will be cleared after being rendered. If False, the figure will not be cleared after being rendered. If left unspecified, we pick a default based on the value of `fig`. * If `fig` is set, defaults to `False`. * If `fig` is not set, defaults to `True`. This simulates Jupyter's approach to matplotlib rendering. **kwargs : any Arguments to pass to Matplotlib's savefig function. Example ------- >>> import matplotlib.pyplot as plt >>> import numpy as np >>> >>> arr = np.random.normal(1, 1, size=100) >>> plt.hist(arr, bins=20) >>> >>> st.pyplot() .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PwzFN7oLZsvb6HDdwdjkRB height: 530px Notes ----- Matplotlib support several different types of "backends". If you're getting an error using Matplotlib with Streamlit, try setting your backend to "TkAgg":: echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc For more information, see https://matplotlib.org/faq/usage_faq.html.
lib/streamlit/DeltaGenerator.py
pyplot
OakNorthAI/streamlit-base
python
@_with_element def pyplot(self, element, fig=None, clear_figure=None, **kwargs): 'Display a matplotlib.pyplot figure.\n\n Parameters\n ----------\n fig : Matplotlib Figure\n The figure to plot. When this argument isn\'t specified, which is\n the usual case, this function will render the global plot.\n\n clear_figure : bool\n If True, the figure will be cleared after being rendered.\n If False, the figure will not be cleared after being rendered.\n If left unspecified, we pick a default based on the value of `fig`.\n\n * If `fig` is set, defaults to `False`.\n\n * If `fig` is not set, defaults to `True`. This simulates Jupyter\'s\n approach to matplotlib rendering.\n\n **kwargs : any\n Arguments to pass to Matplotlib\'s savefig function.\n\n Example\n -------\n >>> import matplotlib.pyplot as plt\n >>> import numpy as np\n >>>\n >>> arr = np.random.normal(1, 1, size=100)\n >>> plt.hist(arr, bins=20)\n >>>\n >>> st.pyplot()\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=PwzFN7oLZsvb6HDdwdjkRB\n height: 530px\n\n Notes\n -----\n Matplotlib support several different types of "backends". If you\'re\n getting an error using Matplotlib with Streamlit, try setting your\n backend to "TkAgg"::\n\n echo "backend: TkAgg" >> ~/.matplotlib/matplotlibrc\n\n For more information, see https://matplotlib.org/faq/usage_faq.html.\n\n ' import streamlit.elements.pyplot as pyplot pyplot.marshall(self._get_coordinates, element, fig, clear_figure, **kwargs)
@_with_element def bokeh_chart(self, element, figure, use_container_width=False): "Display an interactive Bokeh chart.\n\n Bokeh is a charting library for Python. The arguments to this function\n closely follow the ones for Bokeh's `show` function. You can find\n more about Bokeh at https://bokeh.pydata.org.\n\n Parameters\n ----------\n figure : bokeh.plotting.figure.Figure\n A Bokeh figure to plot.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over Bokeh's native `width` value.\n\n To show Bokeh charts in Streamlit, just call `st.bokeh_chart`\n wherever you would call Bokeh's `show`.\n\n Example\n -------\n >>> import streamlit as st\n >>> from bokeh.plotting import figure\n >>>\n >>> x = [1, 2, 3, 4, 5]\n >>> y = [6, 7, 2, 4, 5]\n >>>\n >>> p = figure(\n ... title='simple line example',\n ... x_axis_label='x',\n ... y_axis_label='y')\n ...\n >>> p.line(x, y, legend='Trend', line_width=2)\n >>>\n >>> st.bokeh_chart(p, use_container_width=True)\n\n .. output::\n https://share.streamlit.io/0.56.0-xTAd/index.html?id=Fdhg51uMbGMLRRxXV6ubzp\n height: 600px\n\n " import streamlit.elements.bokeh_chart as bokeh_chart bokeh_chart.marshall(element.bokeh_chart, figure, use_container_width)
-6,488,593,160,728,467,000
Display an interactive Bokeh chart. Bokeh is a charting library for Python. The arguments to this function closely follow the ones for Bokeh's `show` function. You can find more about Bokeh at https://bokeh.pydata.org. Parameters ---------- figure : bokeh.plotting.figure.Figure A Bokeh figure to plot. use_container_width : bool If True, set the chart width to the column width. This takes precedence over Bokeh's native `width` value. To show Bokeh charts in Streamlit, just call `st.bokeh_chart` wherever you would call Bokeh's `show`. Example ------- >>> import streamlit as st >>> from bokeh.plotting import figure >>> >>> x = [1, 2, 3, 4, 5] >>> y = [6, 7, 2, 4, 5] >>> >>> p = figure( ... title='simple line example', ... x_axis_label='x', ... y_axis_label='y') ... >>> p.line(x, y, legend='Trend', line_width=2) >>> >>> st.bokeh_chart(p, use_container_width=True) .. output:: https://share.streamlit.io/0.56.0-xTAd/index.html?id=Fdhg51uMbGMLRRxXV6ubzp height: 600px
lib/streamlit/DeltaGenerator.py
bokeh_chart
OakNorthAI/streamlit-base
python
@_with_element def bokeh_chart(self, element, figure, use_container_width=False): "Display an interactive Bokeh chart.\n\n Bokeh is a charting library for Python. The arguments to this function\n closely follow the ones for Bokeh's `show` function. You can find\n more about Bokeh at https://bokeh.pydata.org.\n\n Parameters\n ----------\n figure : bokeh.plotting.figure.Figure\n A Bokeh figure to plot.\n\n use_container_width : bool\n If True, set the chart width to the column width. This takes\n precedence over Bokeh's native `width` value.\n\n To show Bokeh charts in Streamlit, just call `st.bokeh_chart`\n wherever you would call Bokeh's `show`.\n\n Example\n -------\n >>> import streamlit as st\n >>> from bokeh.plotting import figure\n >>>\n >>> x = [1, 2, 3, 4, 5]\n >>> y = [6, 7, 2, 4, 5]\n >>>\n >>> p = figure(\n ... title='simple line example',\n ... x_axis_label='x',\n ... y_axis_label='y')\n ...\n >>> p.line(x, y, legend='Trend', line_width=2)\n >>>\n >>> st.bokeh_chart(p, use_container_width=True)\n\n .. output::\n https://share.streamlit.io/0.56.0-xTAd/index.html?id=Fdhg51uMbGMLRRxXV6ubzp\n height: 600px\n\n " import streamlit.elements.bokeh_chart as bokeh_chart bokeh_chart.marshall(element.bokeh_chart, figure, use_container_width)
@_with_element def image(self, element, image, caption=None, width=None, use_column_width=False, clamp=False, channels='RGB', format='JPEG'): "Display an image or list of images.\n\n Parameters\n ----------\n image : numpy.ndarray, [numpy.ndarray], BytesIO, str, or [str]\n Monochrome image of shape (w,h) or (w,h,1)\n OR a color image of shape (w,h,3)\n OR an RGBA image of shape (w,h,4)\n OR a URL to fetch the image from\n OR a list of one of the above, to display multiple images.\n caption : str or list of str\n Image caption. If displaying multiple images, caption should be a\n list of captions (one for each image).\n width : int or None\n Image width. None means use the image width.\n use_column_width : bool\n If True, set the image width to the column width. This takes\n precedence over the `width` parameter.\n clamp : bool\n Clamp image pixel values to a valid range ([0-255] per channel).\n This is only meaningful for byte array images; the parameter is\n ignored for image URLs. If this is not set, and an image has an\n out-of-range value, an error will be thrown.\n channels : 'RGB' or 'BGR'\n If image is an nd.array, this parameter denotes the format used to\n represent color information. Defaults to 'RGB', meaning\n `image[:, :, 0]` is the red channel, `image[:, :, 1]` is green, and\n `image[:, :, 2]` is blue. For images coming from libraries like\n OpenCV you should set this to 'BGR', instead.\n format : 'JPEG' or 'PNG'\n This parameter specifies the image format to use when transferring\n the image data. Defaults to 'JPEG'.\n\n Example\n -------\n >>> from PIL import Image\n >>> image = Image.open('sunrise.jpg')\n >>>\n >>> st.image(image, caption='Sunrise by the mountains',\n ... use_column_width=True)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=YCFaqPgmgpEz7jwE4tHAzY\n height: 630px\n\n " from .elements import image_proto if use_column_width: width = (- 2) elif (width is None): width = (- 1) elif (width <= 0): raise StreamlitAPIException('Image width must be positive.') image_proto.marshall_images(self._get_coordinates(), image, caption, width, element.imgs, clamp, channels, format)
-6,240,400,164,668,515,000
Display an image or list of images. Parameters ---------- image : numpy.ndarray, [numpy.ndarray], BytesIO, str, or [str] Monochrome image of shape (w,h) or (w,h,1) OR a color image of shape (w,h,3) OR an RGBA image of shape (w,h,4) OR a URL to fetch the image from OR a list of one of the above, to display multiple images. caption : str or list of str Image caption. If displaying multiple images, caption should be a list of captions (one for each image). width : int or None Image width. None means use the image width. use_column_width : bool If True, set the image width to the column width. This takes precedence over the `width` parameter. clamp : bool Clamp image pixel values to a valid range ([0-255] per channel). This is only meaningful for byte array images; the parameter is ignored for image URLs. If this is not set, and an image has an out-of-range value, an error will be thrown. channels : 'RGB' or 'BGR' If image is an nd.array, this parameter denotes the format used to represent color information. Defaults to 'RGB', meaning `image[:, :, 0]` is the red channel, `image[:, :, 1]` is green, and `image[:, :, 2]` is blue. For images coming from libraries like OpenCV you should set this to 'BGR', instead. format : 'JPEG' or 'PNG' This parameter specifies the image format to use when transferring the image data. Defaults to 'JPEG'. Example ------- >>> from PIL import Image >>> image = Image.open('sunrise.jpg') >>> >>> st.image(image, caption='Sunrise by the mountains', ... use_column_width=True) .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=YCFaqPgmgpEz7jwE4tHAzY height: 630px
lib/streamlit/DeltaGenerator.py
image
OakNorthAI/streamlit-base
python
@_with_element def image(self, element, image, caption=None, width=None, use_column_width=False, clamp=False, channels='RGB', format='JPEG'): "Display an image or list of images.\n\n Parameters\n ----------\n image : numpy.ndarray, [numpy.ndarray], BytesIO, str, or [str]\n Monochrome image of shape (w,h) or (w,h,1)\n OR a color image of shape (w,h,3)\n OR an RGBA image of shape (w,h,4)\n OR a URL to fetch the image from\n OR a list of one of the above, to display multiple images.\n caption : str or list of str\n Image caption. If displaying multiple images, caption should be a\n list of captions (one for each image).\n width : int or None\n Image width. None means use the image width.\n use_column_width : bool\n If True, set the image width to the column width. This takes\n precedence over the `width` parameter.\n clamp : bool\n Clamp image pixel values to a valid range ([0-255] per channel).\n This is only meaningful for byte array images; the parameter is\n ignored for image URLs. If this is not set, and an image has an\n out-of-range value, an error will be thrown.\n channels : 'RGB' or 'BGR'\n If image is an nd.array, this parameter denotes the format used to\n represent color information. Defaults to 'RGB', meaning\n `image[:, :, 0]` is the red channel, `image[:, :, 1]` is green, and\n `image[:, :, 2]` is blue. For images coming from libraries like\n OpenCV you should set this to 'BGR', instead.\n format : 'JPEG' or 'PNG'\n This parameter specifies the image format to use when transferring\n the image data. Defaults to 'JPEG'.\n\n Example\n -------\n >>> from PIL import Image\n >>> image = Image.open('sunrise.jpg')\n >>>\n >>> st.image(image, caption='Sunrise by the mountains',\n ... use_column_width=True)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=YCFaqPgmgpEz7jwE4tHAzY\n height: 630px\n\n " from .elements import image_proto if use_column_width: width = (- 2) elif (width is None): width = (- 1) elif (width <= 0): raise StreamlitAPIException('Image width must be positive.') image_proto.marshall_images(self._get_coordinates(), image, caption, width, element.imgs, clamp, channels, format)
@_with_element def audio(self, element, data, format='audio/wav', start_time=0): "Display an audio player.\n\n Parameters\n ----------\n data : str, bytes, BytesIO, numpy.ndarray, or file opened with\n io.open().\n Raw audio data, filename, or a URL pointing to the file to load.\n Numpy arrays and raw data formats must include all necessary file\n headers to match specified file format.\n start_time: int\n The time from which this element should start playing.\n format : str\n The mime type for the audio file. Defaults to 'audio/wav'.\n See https://tools.ietf.org/html/rfc4281 for more info.\n\n Example\n -------\n >>> audio_file = open('myaudio.ogg', 'rb')\n >>> audio_bytes = audio_file.read()\n >>>\n >>> st.audio(audio_bytes, format='audio/ogg')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=Dv3M9sA7Cg8gwusgnVNTHb\n height: 400px\n\n " from .elements import media_proto media_proto.marshall_audio(self._get_coordinates(), element.audio, data, format, start_time)
-4,706,573,096,117,969,000
Display an audio player. Parameters ---------- data : str, bytes, BytesIO, numpy.ndarray, or file opened with io.open(). Raw audio data, filename, or a URL pointing to the file to load. Numpy arrays and raw data formats must include all necessary file headers to match specified file format. start_time: int The time from which this element should start playing. format : str The mime type for the audio file. Defaults to 'audio/wav'. See https://tools.ietf.org/html/rfc4281 for more info. Example ------- >>> audio_file = open('myaudio.ogg', 'rb') >>> audio_bytes = audio_file.read() >>> >>> st.audio(audio_bytes, format='audio/ogg') .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=Dv3M9sA7Cg8gwusgnVNTHb height: 400px
lib/streamlit/DeltaGenerator.py
audio
OakNorthAI/streamlit-base
python
@_with_element def audio(self, element, data, format='audio/wav', start_time=0): "Display an audio player.\n\n Parameters\n ----------\n data : str, bytes, BytesIO, numpy.ndarray, or file opened with\n io.open().\n Raw audio data, filename, or a URL pointing to the file to load.\n Numpy arrays and raw data formats must include all necessary file\n headers to match specified file format.\n start_time: int\n The time from which this element should start playing.\n format : str\n The mime type for the audio file. Defaults to 'audio/wav'.\n See https://tools.ietf.org/html/rfc4281 for more info.\n\n Example\n -------\n >>> audio_file = open('myaudio.ogg', 'rb')\n >>> audio_bytes = audio_file.read()\n >>>\n >>> st.audio(audio_bytes, format='audio/ogg')\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=Dv3M9sA7Cg8gwusgnVNTHb\n height: 400px\n\n " from .elements import media_proto media_proto.marshall_audio(self._get_coordinates(), element.audio, data, format, start_time)
@_with_element def video(self, element, data, format='video/mp4', start_time=0): "Display a video player.\n\n Parameters\n ----------\n data : str, bytes, BytesIO, numpy.ndarray, or file opened with\n io.open().\n Raw video data, filename, or URL pointing to a video to load.\n Includes support for YouTube URLs.\n Numpy arrays and raw data formats must include all necessary file\n headers to match specified file format.\n format : str\n The mime type for the video file. Defaults to 'video/mp4'.\n See https://tools.ietf.org/html/rfc4281 for more info.\n start_time: int\n The time from which this element should start playing.\n\n Example\n -------\n >>> video_file = open('myvideo.mp4', 'rb')\n >>> video_bytes = video_file.read()\n >>>\n >>> st.video(video_bytes)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=Wba9sZELKfKwXH4nDCCbMv\n height: 600px\n\n .. note::\n Some videos may not display if they are encoded using MP4V (which is an export option in OpenCV), as this codec is\n not widely supported by browsers. Converting your video to H.264 will allow the video to be displayed in Streamlit.\n See this `StackOverflow post <https://stackoverflow.com/a/49535220/2394542>`_ or this\n `Streamlit forum post <https://discuss.streamlit.io/t/st-video-doesnt-show-opencv-generated-mp4/3193/2>`_\n for more information.\n\n " from .elements import media_proto media_proto.marshall_video(self._get_coordinates(), element.video, data, format, start_time)
6,395,827,962,340,364,000
Display a video player. Parameters ---------- data : str, bytes, BytesIO, numpy.ndarray, or file opened with io.open(). Raw video data, filename, or URL pointing to a video to load. Includes support for YouTube URLs. Numpy arrays and raw data formats must include all necessary file headers to match specified file format. format : str The mime type for the video file. Defaults to 'video/mp4'. See https://tools.ietf.org/html/rfc4281 for more info. start_time: int The time from which this element should start playing. Example ------- >>> video_file = open('myvideo.mp4', 'rb') >>> video_bytes = video_file.read() >>> >>> st.video(video_bytes) .. output:: https://share.streamlit.io/0.25.0-2JkNY/index.html?id=Wba9sZELKfKwXH4nDCCbMv height: 600px .. note:: Some videos may not display if they are encoded using MP4V (which is an export option in OpenCV), as this codec is not widely supported by browsers. Converting your video to H.264 will allow the video to be displayed in Streamlit. See this `StackOverflow post <https://stackoverflow.com/a/49535220/2394542>`_ or this `Streamlit forum post <https://discuss.streamlit.io/t/st-video-doesnt-show-opencv-generated-mp4/3193/2>`_ for more information.
lib/streamlit/DeltaGenerator.py
video
OakNorthAI/streamlit-base
python
@_with_element def video(self, element, data, format='video/mp4', start_time=0): "Display a video player.\n\n Parameters\n ----------\n data : str, bytes, BytesIO, numpy.ndarray, or file opened with\n io.open().\n Raw video data, filename, or URL pointing to a video to load.\n Includes support for YouTube URLs.\n Numpy arrays and raw data formats must include all necessary file\n headers to match specified file format.\n format : str\n The mime type for the video file. Defaults to 'video/mp4'.\n See https://tools.ietf.org/html/rfc4281 for more info.\n start_time: int\n The time from which this element should start playing.\n\n Example\n -------\n >>> video_file = open('myvideo.mp4', 'rb')\n >>> video_bytes = video_file.read()\n >>>\n >>> st.video(video_bytes)\n\n .. output::\n https://share.streamlit.io/0.25.0-2JkNY/index.html?id=Wba9sZELKfKwXH4nDCCbMv\n height: 600px\n\n .. note::\n Some videos may not display if they are encoded using MP4V (which is an export option in OpenCV), as this codec is\n not widely supported by browsers. Converting your video to H.264 will allow the video to be displayed in Streamlit.\n See this `StackOverflow post <https://stackoverflow.com/a/49535220/2394542>`_ or this\n `Streamlit forum post <https://discuss.streamlit.io/t/st-video-doesnt-show-opencv-generated-mp4/3193/2>`_\n for more information.\n\n " from .elements import media_proto media_proto.marshall_video(self._get_coordinates(), element.video, data, format, start_time)