partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
test
Transaction.get_signature_validation_trytes
Returns the values needed to validate the transaction's ``signature_message_fragment`` value.
iota/transaction/base.py
def get_signature_validation_trytes(self): # type: () -> TryteString """ Returns the values needed to validate the transaction's ``signature_message_fragment`` value. """ return ( self.address.address + self.value_as_trytes ...
def get_signature_validation_trytes(self): # type: () -> TryteString """ Returns the values needed to validate the transaction's ``signature_message_fragment`` value. """ return ( self.address.address + self.value_as_trytes ...
[ "Returns", "the", "values", "needed", "to", "validate", "the", "transaction", "s", "signature_message_fragment", "value", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/base.py#L366-L379
[ "def", "get_signature_validation_trytes", "(", "self", ")", ":", "# type: () -> TryteString", "return", "(", "self", ".", "address", ".", "address", "+", "self", ".", "value_as_trytes", "+", "self", ".", "legacy_tag", "+", "self", ".", "timestamp_as_trytes", "+", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
Bundle.is_confirmed
Sets the ``is_confirmed`` for the bundle.
iota/transaction/base.py
def is_confirmed(self, new_is_confirmed): # type: (bool) -> None """ Sets the ``is_confirmed`` for the bundle. """ self._is_confirmed = new_is_confirmed for txn in self: txn.is_confirmed = new_is_confirmed
def is_confirmed(self, new_is_confirmed): # type: (bool) -> None """ Sets the ``is_confirmed`` for the bundle. """ self._is_confirmed = new_is_confirmed for txn in self: txn.is_confirmed = new_is_confirmed
[ "Sets", "the", "is_confirmed", "for", "the", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/base.py#L467-L475
[ "def", "is_confirmed", "(", "self", ",", "new_is_confirmed", ")", ":", "# type: (bool) -> None", "self", ".", "_is_confirmed", "=", "new_is_confirmed", "for", "txn", "in", "self", ":", "txn", ".", "is_confirmed", "=", "new_is_confirmed" ]
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
Bundle.get_messages
Attempts to decipher encoded messages from the transactions in the bundle. :param errors: How to handle trytes that can't be converted, or bytes that can't be decoded using UTF-8: 'drop' Drop the trytes from the result. 'strict' ...
iota/transaction/base.py
def get_messages(self, errors='drop'): # type: (Text) -> List[Text] """ Attempts to decipher encoded messages from the transactions in the bundle. :param errors: How to handle trytes that can't be converted, or bytes that can't be decoded using UTF-8: ...
def get_messages(self, errors='drop'): # type: (Text) -> List[Text] """ Attempts to decipher encoded messages from the transactions in the bundle. :param errors: How to handle trytes that can't be converted, or bytes that can't be decoded using UTF-8: ...
[ "Attempts", "to", "decipher", "encoded", "messages", "from", "the", "transactions", "in", "the", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/base.py#L501-L543
[ "def", "get_messages", "(", "self", ",", "errors", "=", "'drop'", ")", ":", "# type: (Text) -> List[Text]", "decode_errors", "=", "'strict'", "if", "errors", "==", "'drop'", "else", "errors", "messages", "=", "[", "]", "for", "group", "in", "self", ".", "gro...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
Bundle.as_tryte_strings
Returns TryteString representations of the transactions in this bundle. :param head_to_tail: Determines the order of the transactions: - ``True``: head txn first, tail txn last. - ``False`` (default): tail txn first, head txn last. Note that the order i...
iota/transaction/base.py
def as_tryte_strings(self, head_to_tail=False): # type: (bool) -> List[TransactionTrytes] """ Returns TryteString representations of the transactions in this bundle. :param head_to_tail: Determines the order of the transactions: - ``True``: head txn firs...
def as_tryte_strings(self, head_to_tail=False): # type: (bool) -> List[TransactionTrytes] """ Returns TryteString representations of the transactions in this bundle. :param head_to_tail: Determines the order of the transactions: - ``True``: head txn firs...
[ "Returns", "TryteString", "representations", "of", "the", "transactions", "in", "this", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/base.py#L545-L561
[ "def", "as_tryte_strings", "(", "self", ",", "head_to_tail", "=", "False", ")", ":", "# type: (bool) -> List[TransactionTrytes]", "transactions", "=", "self", "if", "head_to_tail", "else", "reversed", "(", "self", ")", "return", "[", "t", ".", "as_tryte_string", "...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
Bundle.group_transactions
Groups transactions in the bundle by address.
iota/transaction/base.py
def group_transactions(self): # type: () -> List[List[Transaction]] """ Groups transactions in the bundle by address. """ groups = [] if self: last_txn = self.tail_transaction current_group = [last_txn] for current_txn in self.transact...
def group_transactions(self): # type: () -> List[List[Transaction]] """ Groups transactions in the bundle by address. """ groups = [] if self: last_txn = self.tail_transaction current_group = [last_txn] for current_txn in self.transact...
[ "Groups", "transactions", "in", "the", "bundle", "by", "address", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/base.py#L574-L599
[ "def", "group_transactions", "(", "self", ")", ":", "# type: () -> List[List[Transaction]]", "groups", "=", "[", "]", "if", "self", ":", "last_txn", "=", "self", ".", "tail_transaction", "current_group", "=", "[", "last_txn", "]", "for", "current_txn", "in", "se...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
discover_commands
Automatically discover commands in the specified package. :param package: Package path or reference. :param recursively: If True, will descend recursively into sub-packages. :return: All commands discovered in the specified package, indexed by command name (note: not class name).
iota/commands/__init__.py
def discover_commands(package, recursively=True): # type: (Union[ModuleType, Text], bool) -> Dict[Text, 'CommandMeta'] """ Automatically discover commands in the specified package. :param package: Package path or reference. :param recursively: If True, will descend recursively into sub-packages. ...
def discover_commands(package, recursively=True): # type: (Union[ModuleType, Text], bool) -> Dict[Text, 'CommandMeta'] """ Automatically discover commands in the specified package. :param package: Package path or reference. :param recursively: If True, will descend recursively into sub-packages. ...
[ "Automatically", "discover", "commands", "in", "the", "specified", "package", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/commands/__init__.py#L35-L75
[ "def", "discover_commands", "(", "package", ",", "recursively", "=", "True", ")", ":", "# type: (Union[ModuleType, Text], bool) -> Dict[Text, 'CommandMeta']", "# http://stackoverflow.com/a/25562415/", "if", "isinstance", "(", "package", ",", "string_types", ")", ":", "package...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
BaseCommand._execute
Sends the request object to the adapter and returns the response. The command name will be automatically injected into the request before it is sent (note: this will modify the request object).
iota/commands/__init__.py
def _execute(self, request): # type: (dict) -> dict """ Sends the request object to the adapter and returns the response. The command name will be automatically injected into the request before it is sent (note: this will modify the request object). """ request['command'] = self.command ...
def _execute(self, request): # type: (dict) -> dict """ Sends the request object to the adapter and returns the response. The command name will be automatically injected into the request before it is sent (note: this will modify the request object). """ request['command'] = self.command ...
[ "Sends", "the", "request", "object", "to", "the", "adapter", "and", "returns", "the", "response", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/commands/__init__.py#L149-L158
[ "def", "_execute", "(", "self", ",", "request", ")", ":", "# type: (dict) -> dict", "request", "[", "'command'", "]", "=", "self", ".", "command", "return", "self", ".", "adapter", ".", "send_request", "(", "request", ")" ]
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
FilterCommand._apply_filter
Applies a filter to a value. If the value does not pass the filter, an exception will be raised with lots of contextual info attached to it.
iota/commands/__init__.py
def _apply_filter(value, filter_, failure_message): # type: (dict, Optional[f.BaseFilter], Text) -> dict """ Applies a filter to a value. If the value does not pass the filter, an exception will be raised with lots of contextual info attached to it. """ if filter_: runner = f.FilterRu...
def _apply_filter(value, filter_, failure_message): # type: (dict, Optional[f.BaseFilter], Text) -> dict """ Applies a filter to a value. If the value does not pass the filter, an exception will be raised with lots of contextual info attached to it. """ if filter_: runner = f.FilterRu...
[ "Applies", "a", "filter", "to", "a", "value", ".", "If", "the", "value", "does", "not", "pass", "the", "filter", "an", "exception", "will", "be", "raised", "with", "lots", "of", "contextual", "info", "attached", "to", "it", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/commands/__init__.py#L310-L338
[ "def", "_apply_filter", "(", "value", ",", "filter_", ",", "failure_message", ")", ":", "# type: (dict, Optional[f.BaseFilter], Text) -> dict", "if", "filter_", ":", "runner", "=", "f", ".", "FilterRunner", "(", "filter_", ",", "value", ")", "if", "runner", ".", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
SandboxAdapter.get_jobs_url
Returns the URL to check job status. :param job_id: The ID of the job to check.
iota/adapter/sandbox.py
def get_jobs_url(self, job_id): # type: (Text) -> Text """ Returns the URL to check job status. :param job_id: The ID of the job to check. """ return compat.urllib_parse.urlunsplit(( self.uri.scheme, self.uri.netloc, self.u...
def get_jobs_url(self, job_id): # type: (Text) -> Text """ Returns the URL to check job status. :param job_id: The ID of the job to check. """ return compat.urllib_parse.urlunsplit(( self.uri.scheme, self.uri.netloc, self.u...
[ "Returns", "the", "URL", "to", "check", "job", "status", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/adapter/sandbox.py#L191-L205
[ "def", "get_jobs_url", "(", "self", ",", "job_id", ")", ":", "# type: (Text) -> Text", "return", "compat", ".", "urllib_parse", ".", "urlunsplit", "(", "(", "self", ".", "uri", ".", "scheme", ",", "self", ".", "uri", ".", "netloc", ",", "self", ".", "uri...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
BundleValidator.errors
Returns all errors found with the bundle.
iota/transaction/validator.py
def errors(self): # type: () -> List[Text] """ Returns all errors found with the bundle. """ try: self._errors.extend(self._validator) # type: List[Text] except StopIteration: pass return self._errors
def errors(self): # type: () -> List[Text] """ Returns all errors found with the bundle. """ try: self._errors.extend(self._validator) # type: List[Text] except StopIteration: pass return self._errors
[ "Returns", "all", "errors", "found", "with", "the", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/validator.py#L41-L51
[ "def", "errors", "(", "self", ")", ":", "# type: () -> List[Text]", "try", ":", "self", ".", "_errors", ".", "extend", "(", "self", ".", "_validator", ")", "# type: List[Text]", "except", "StopIteration", ":", "pass", "return", "self", ".", "_errors" ]
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
BundleValidator.is_valid
Returns whether the bundle is valid.
iota/transaction/validator.py
def is_valid(self): # type: () -> bool """ Returns whether the bundle is valid. """ if not self._errors: try: # We only have to check for a single error to determine # if the bundle is valid or not. self._errors.append(n...
def is_valid(self): # type: () -> bool """ Returns whether the bundle is valid. """ if not self._errors: try: # We only have to check for a single error to determine # if the bundle is valid or not. self._errors.append(n...
[ "Returns", "whether", "the", "bundle", "is", "valid", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/validator.py#L53-L66
[ "def", "is_valid", "(", "self", ")", ":", "# type: () -> bool", "if", "not", "self", ".", "_errors", ":", "try", ":", "# We only have to check for a single error to determine", "# if the bundle is valid or not.", "self", ".", "_errors", ".", "append", "(", "next", "("...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
BundleValidator._create_validator
Creates a generator that does all the work.
iota/transaction/validator.py
def _create_validator(self): # type: () -> Generator[Text, None, None] """ Creates a generator that does all the work. """ # Group transactions by address to make it easier to iterate # over inputs. grouped_transactions = self.bundle.group_transactions() ...
def _create_validator(self): # type: () -> Generator[Text, None, None] """ Creates a generator that does all the work. """ # Group transactions by address to make it easier to iterate # over inputs. grouped_transactions = self.bundle.group_transactions() ...
[ "Creates", "a", "generator", "that", "does", "all", "the", "work", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/validator.py#L68-L186
[ "def", "_create_validator", "(", "self", ")", ":", "# type: () -> Generator[Text, None, None]", "# Group transactions by address to make it easier to iterate", "# over inputs.", "grouped_transactions", "=", "self", ".", "bundle", ".", "group_transactions", "(", ")", "# Define a f...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
BundleValidator._get_bundle_signature_errors
Validates the signature fragments in the bundle. :return: List of error messages. If empty, signature fragments are valid.
iota/transaction/validator.py
def _get_bundle_signature_errors(self, groups): # type: (List[List[Transaction]]) -> List[Text] """ Validates the signature fragments in the bundle. :return: List of error messages. If empty, signature fragments are valid. """ # Start with the cur...
def _get_bundle_signature_errors(self, groups): # type: (List[List[Transaction]]) -> List[Text] """ Validates the signature fragments in the bundle. :return: List of error messages. If empty, signature fragments are valid. """ # Start with the cur...
[ "Validates", "the", "signature", "fragments", "in", "the", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/validator.py#L188-L235
[ "def", "_get_bundle_signature_errors", "(", "self", ",", "groups", ")", ":", "# type: (List[List[Transaction]]) -> List[Text]", "# Start with the currently-supported hash algo.", "current_pos", "=", "None", "current_errors", "=", "[", "]", "for", "current_pos", ",", "group", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
BundleValidator._get_group_signature_error
Validates the signature fragments for a group of transactions using the specified sponge type. Note: this method assumes that the transactions in the group have already passed basic validation (see :py:meth:`_create_validator`). :return: - ``None``: Indicates that th...
iota/transaction/validator.py
def _get_group_signature_error(group, sponge_type): # type: (List[Transaction], type) -> Optional[Text] """ Validates the signature fragments for a group of transactions using the specified sponge type. Note: this method assumes that the transactions in the group have al...
def _get_group_signature_error(group, sponge_type): # type: (List[Transaction], type) -> Optional[Text] """ Validates the signature fragments for a group of transactions using the specified sponge type. Note: this method assumes that the transactions in the group have al...
[ "Validates", "the", "signature", "fragments", "for", "a", "group", "of", "transactions", "using", "the", "specified", "sponge", "type", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/validator.py#L238-L268
[ "def", "_get_group_signature_error", "(", "group", ",", "sponge_type", ")", ":", "# type: (List[Transaction], type) -> Optional[Text]", "validate_group_signature", "=", "validate_signature_fragments", "(", "fragments", "=", "[", "txn", ".", "signature_message_fragment", "for", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
GetBundlesCommand._traverse_bundle
Recursively traverse the Tangle, collecting transactions until we hit a new bundle. This method is (usually) faster than ``findTransactions``, and it ensures we don't collect transactions from replayed bundles.
iota/commands/extended/get_bundles.py
def _traverse_bundle(self, txn_hash, target_bundle_hash=None): # type: (TransactionHash, Optional[BundleHash]) -> List[Transaction] """ Recursively traverse the Tangle, collecting transactions until we hit a new bundle. This method is (usually) faster than ``findTransactions``, ...
def _traverse_bundle(self, txn_hash, target_bundle_hash=None): # type: (TransactionHash, Optional[BundleHash]) -> List[Transaction] """ Recursively traverse the Tangle, collecting transactions until we hit a new bundle. This method is (usually) faster than ``findTransactions``, ...
[ "Recursively", "traverse", "the", "Tangle", "collecting", "transactions", "until", "we", "hit", "a", "new", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/commands/extended/get_bundles.py#L61-L118
[ "def", "_traverse_bundle", "(", "self", ",", "txn_hash", ",", "target_bundle_hash", "=", "None", ")", ":", "# type: (TransactionHash, Optional[BundleHash]) -> List[Transaction]", "trytes", "=", "(", "GetTrytesCommand", "(", "self", ".", "adapter", ")", "(", "hashes", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
IotaReplCommandLineApp._start_repl
Starts the REPL.
iota/bin/repl.py
def _start_repl(api): # type: (Iota) -> None """ Starts the REPL. """ banner = ( 'IOTA API client for {uri} ({testnet}) ' 'initialized as variable `api`.\n' 'Type `help(api)` for list of API commands.'.format( testnet='testnet' ...
def _start_repl(api): # type: (Iota) -> None """ Starts the REPL. """ banner = ( 'IOTA API client for {uri} ({testnet}) ' 'initialized as variable `api`.\n' 'Type `help(api)` for list of API commands.'.format( testnet='testnet' ...
[ "Starts", "the", "REPL", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/bin/repl.py#L86-L111
[ "def", "_start_repl", "(", "api", ")", ":", "# type: (Iota) -> None", "banner", "=", "(", "'IOTA API client for {uri} ({testnet}) '", "'initialized as variable `api`.\\n'", "'Type `help(api)` for list of API commands.'", ".", "format", "(", "testnet", "=", "'testnet'", "if", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
Seed.random
Generates a random seed using a CSPRNG. :param length: Length of seed, in trytes. For maximum security, this should always be set to 81, but you can change it if you're 110% sure you know what you're doing. See https://iota.stackexchange.com/q/249 f...
iota/crypto/types.py
def random(cls, length=Hash.LEN): """ Generates a random seed using a CSPRNG. :param length: Length of seed, in trytes. For maximum security, this should always be set to 81, but you can change it if you're 110% sure you know what you're doing. ...
def random(cls, length=Hash.LEN): """ Generates a random seed using a CSPRNG. :param length: Length of seed, in trytes. For maximum security, this should always be set to 81, but you can change it if you're 110% sure you know what you're doing. ...
[ "Generates", "a", "random", "seed", "using", "a", "CSPRNG", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/crypto/types.py#L100-L113
[ "def", "random", "(", "cls", ",", "length", "=", "Hash", ".", "LEN", ")", ":", "return", "super", "(", "Seed", ",", "cls", ")", ".", "random", "(", "length", ")" ]
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
PrivateKey.get_digest
Generates the digest used to do the actual signing. Signing keys can have variable length and tend to be quite long, which makes them not-well-suited for use in crypto algorithms. The digest is essentially the result of running the signing key through a PBKDF, yielding a constant-lengt...
iota/crypto/types.py
def get_digest(self): # type: () -> Digest """ Generates the digest used to do the actual signing. Signing keys can have variable length and tend to be quite long, which makes them not-well-suited for use in crypto algorithms. The digest is essentially the result of run...
def get_digest(self): # type: () -> Digest """ Generates the digest used to do the actual signing. Signing keys can have variable length and tend to be quite long, which makes them not-well-suited for use in crypto algorithms. The digest is essentially the result of run...
[ "Generates", "the", "digest", "used", "to", "do", "the", "actual", "signing", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/crypto/types.py#L152-L205
[ "def", "get_digest", "(", "self", ")", ":", "# type: () -> Digest", "hashes_per_fragment", "=", "FRAGMENT_LENGTH", "//", "Hash", ".", "LEN", "key_fragments", "=", "self", ".", "iter_chunks", "(", "FRAGMENT_LENGTH", ")", "# The digest will contain one hash per key fragment...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
PrivateKey.sign_input_transactions
Signs the inputs starting at the specified index. :param bundle: The bundle that contains the input transactions to sign. :param start_index: The index of the first input transaction. If necessary, the resulting signature will be split across subsequent...
iota/crypto/types.py
def sign_input_transactions(self, bundle, start_index): # type: (Bundle, int) -> None """ Signs the inputs starting at the specified index. :param bundle: The bundle that contains the input transactions to sign. :param start_index: The index of the first...
def sign_input_transactions(self, bundle, start_index): # type: (Bundle, int) -> None """ Signs the inputs starting at the specified index. :param bundle: The bundle that contains the input transactions to sign. :param start_index: The index of the first...
[ "Signs", "the", "inputs", "starting", "at", "the", "specified", "index", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/crypto/types.py#L207-L296
[ "def", "sign_input_transactions", "(", "self", ",", "bundle", ",", "start_index", ")", ":", "# type: (Bundle, int) -> None", "if", "not", "bundle", ".", "hash", ":", "raise", "with_context", "(", "exc", "=", "ValueError", "(", "'Cannot sign inputs without a bundle has...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
JsonSerializable._repr_pretty_
Makes JSON-serializable objects play nice with IPython's default pretty-printer. Sadly, :py:func:`pprint.pprint` does not have a similar mechanism. References: - http://ipython.readthedocs.io/en/stable/api/generated/IPython.lib.pretty.html - :py:meth:`IPython.lib.prett...
iota/json.py
def _repr_pretty_(self, p, cycle): """ Makes JSON-serializable objects play nice with IPython's default pretty-printer. Sadly, :py:func:`pprint.pprint` does not have a similar mechanism. References: - http://ipython.readthedocs.io/en/stable/api/generated/IPytho...
def _repr_pretty_(self, p, cycle): """ Makes JSON-serializable objects play nice with IPython's default pretty-printer. Sadly, :py:func:`pprint.pprint` does not have a similar mechanism. References: - http://ipython.readthedocs.io/en/stable/api/generated/IPytho...
[ "Makes", "JSON", "-", "serializable", "objects", "play", "nice", "with", "IPython", "s", "default", "pretty", "-", "printer", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/json.py#L30-L63
[ "def", "_repr_pretty_", "(", "self", ",", "p", ",", "cycle", ")", ":", "class_name", "=", "type", "(", "self", ")", ".", "__name__", "if", "cycle", ":", "p", ".", "text", "(", "'{cls}(...)'", ".", "format", "(", "cls", "=", "class_name", ",", ")", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
Kerl.absorb
Absorb trits into the sponge from a buffer. :param trits: Buffer that contains the trits to absorb. :param offset: Starting offset in ``trits``. :param length: Number of trits to absorb. Defaults to ``len(trits)``.
iota/crypto/kerl/pykerl.py
def absorb(self, trits, offset=0, length=None): # type: (MutableSequence[int], int, Optional[int]) -> None """ Absorb trits into the sponge from a buffer. :param trits: Buffer that contains the trits to absorb. :param offset: Starting offset in ``trits``...
def absorb(self, trits, offset=0, length=None): # type: (MutableSequence[int], int, Optional[int]) -> None """ Absorb trits into the sponge from a buffer. :param trits: Buffer that contains the trits to absorb. :param offset: Starting offset in ``trits``...
[ "Absorb", "trits", "into", "the", "sponge", "from", "a", "buffer", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/crypto/kerl/pykerl.py#L27-L80
[ "def", "absorb", "(", "self", ",", "trits", ",", "offset", "=", "0", ",", "length", "=", "None", ")", ":", "# type: (MutableSequence[int], int, Optional[int]) -> None", "# Pad input if necessary, so that it can be divided evenly into", "# hashes.", "# Note that this operation c...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
Kerl.squeeze
Squeeze trits from the sponge into a buffer. :param trits: Buffer that will hold the squeezed trits. IMPORTANT: If ``trits`` is too small, it will be extended! :param offset: Starting offset in ``trits``. :param length: Number of trits to sque...
iota/crypto/kerl/pykerl.py
def squeeze(self, trits, offset=0, length=None): # type: (MutableSequence[int], int, Optional[int]) -> None """ Squeeze trits from the sponge into a buffer. :param trits: Buffer that will hold the squeezed trits. IMPORTANT: If ``trits`` is too small, it will be...
def squeeze(self, trits, offset=0, length=None): # type: (MutableSequence[int], int, Optional[int]) -> None """ Squeeze trits from the sponge into a buffer. :param trits: Buffer that will hold the squeezed trits. IMPORTANT: If ``trits`` is too small, it will be...
[ "Squeeze", "trits", "from", "the", "sponge", "into", "a", "buffer", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/crypto/kerl/pykerl.py#L82-L144
[ "def", "squeeze", "(", "self", ",", "trits", ",", "offset", "=", "0", ",", "length", "=", "None", ")", ":", "# type: (MutableSequence[int], int, Optional[int]) -> None", "# Pad input if necessary, so that it can be divided evenly into", "# hashes.", "pad", "=", "(", "(", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
with_context
Attaches a ``context`` value to an Exception. Before: .. code-block:: python exc = Exception('Frog blast the vent core!') exc.context = { ... } raise exc After: .. code-block:: python raise with_context( exc=Exception('Frog blast the vent core!'), ...
iota/exceptions.py
def with_context(exc, context): # type: (Exception, dict) -> Exception """ Attaches a ``context`` value to an Exception. Before: .. code-block:: python exc = Exception('Frog blast the vent core!') exc.context = { ... } raise exc After: .. code-block:: python ...
def with_context(exc, context): # type: (Exception, dict) -> Exception """ Attaches a ``context`` value to an Exception. Before: .. code-block:: python exc = Exception('Frog blast the vent core!') exc.context = { ... } raise exc After: .. code-block:: python ...
[ "Attaches", "a", "context", "value", "to", "an", "Exception", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/exceptions.py#L10-L36
[ "def", "with_context", "(", "exc", ",", "context", ")", ":", "# type: (Exception, dict) -> Exception", "if", "not", "hasattr", "(", "exc", ",", "'context'", ")", ":", "exc", ".", "context", "=", "{", "}", "exc", ".", "context", ".", "update", "(", "context...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
SecurityLevel
Generates a filter chain for validating a security level.
iota/filters.py
def SecurityLevel(): """ Generates a filter chain for validating a security level. """ return ( f.Type(int) | f.Min(1) | f.Max(3) | f.Optional(default=AddressGenerator.DEFAULT_SECURITY_LEVEL) )
def SecurityLevel(): """ Generates a filter chain for validating a security level. """ return ( f.Type(int) | f.Min(1) | f.Max(3) | f.Optional(default=AddressGenerator.DEFAULT_SECURITY_LEVEL) )
[ "Generates", "a", "filter", "chain", "for", "validating", "a", "security", "level", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/filters.py#L78-L87
[ "def", "SecurityLevel", "(", ")", ":", "return", "(", "f", ".", "Type", "(", "int", ")", "|", "f", ".", "Min", "(", "1", ")", "|", "f", ".", "Max", "(", "3", ")", "|", "f", ".", "Optional", "(", "default", "=", "AddressGenerator", ".", "DEFAULT...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedTransaction.as_tryte_string
Returns a TryteString representation of the transaction.
iota/transaction/creation.py
def as_tryte_string(self): # type: () -> TryteString """ Returns a TryteString representation of the transaction. """ if not self.bundle_hash: raise with_context( exc=RuntimeError( 'Cannot get TryteString representation of {cls} ins...
def as_tryte_string(self): # type: () -> TryteString """ Returns a TryteString representation of the transaction. """ if not self.bundle_hash: raise with_context( exc=RuntimeError( 'Cannot get TryteString representation of {cls} ins...
[ "Returns", "a", "TryteString", "representation", "of", "the", "transaction", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L72-L92
[ "def", "as_tryte_string", "(", "self", ")", ":", "# type: () -> TryteString", "if", "not", "self", ".", "bundle_hash", ":", "raise", "with_context", "(", "exc", "=", "RuntimeError", "(", "'Cannot get TryteString representation of {cls} instance '", "'without a bundle hash; ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedTransaction.increment_legacy_tag
Increments the transaction's legacy tag, used to fix insecure bundle hashes when finalizing a bundle. References: - https://github.com/iotaledger/iota.lib.py/issues/84
iota/transaction/creation.py
def increment_legacy_tag(self): """ Increments the transaction's legacy tag, used to fix insecure bundle hashes when finalizing a bundle. References: - https://github.com/iotaledger/iota.lib.py/issues/84 """ self._legacy_tag = ( Tag.from_trits(add_tr...
def increment_legacy_tag(self): """ Increments the transaction's legacy tag, used to fix insecure bundle hashes when finalizing a bundle. References: - https://github.com/iotaledger/iota.lib.py/issues/84 """ self._legacy_tag = ( Tag.from_trits(add_tr...
[ "Increments", "the", "transaction", "s", "legacy", "tag", "used", "to", "fix", "insecure", "bundle", "hashes", "when", "finalizing", "a", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L94-L105
[ "def", "increment_legacy_tag", "(", "self", ")", ":", "self", ".", "_legacy_tag", "=", "(", "Tag", ".", "from_trits", "(", "add_trits", "(", "self", ".", "legacy_tag", ".", "as_trits", "(", ")", ",", "[", "1", "]", ")", ")", ")" ]
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedBundle.tag
Determines the most relevant tag for the bundle.
iota/transaction/creation.py
def tag(self): # type: () -> Tag """ Determines the most relevant tag for the bundle. """ for txn in reversed(self): # type: ProposedTransaction if txn.tag: return txn.tag return Tag(b'')
def tag(self): # type: () -> Tag """ Determines the most relevant tag for the bundle. """ for txn in reversed(self): # type: ProposedTransaction if txn.tag: return txn.tag return Tag(b'')
[ "Determines", "the", "most", "relevant", "tag", "for", "the", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L194-L203
[ "def", "tag", "(", "self", ")", ":", "# type: () -> Tag", "for", "txn", "in", "reversed", "(", "self", ")", ":", "# type: ProposedTransaction", "if", "txn", ".", "tag", ":", "return", "txn", ".", "tag", "return", "Tag", "(", "b''", ")" ]
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedBundle.add_transaction
Adds a transaction to the bundle. If the transaction message is too long, it will be split automatically into multiple transactions.
iota/transaction/creation.py
def add_transaction(self, transaction): # type: (ProposedTransaction) -> None """ Adds a transaction to the bundle. If the transaction message is too long, it will be split automatically into multiple transactions. """ if self.hash: raise RuntimeError...
def add_transaction(self, transaction): # type: (ProposedTransaction) -> None """ Adds a transaction to the bundle. If the transaction message is too long, it will be split automatically into multiple transactions. """ if self.hash: raise RuntimeError...
[ "Adds", "a", "transaction", "to", "the", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L216-L251
[ "def", "add_transaction", "(", "self", ",", "transaction", ")", ":", "# type: (ProposedTransaction) -> None", "if", "self", ".", "hash", ":", "raise", "RuntimeError", "(", "'Bundle is already finalized.'", ")", "if", "transaction", ".", "value", "<", "0", ":", "ra...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedBundle.add_inputs
Adds inputs to spend in the bundle. Note that each input may require multiple transactions, in order to hold the entire signature. :param inputs: Addresses to use as the inputs for this bundle. .. important:: Must have ``balance`` and ``key_index`` attr...
iota/transaction/creation.py
def add_inputs(self, inputs): # type: (Iterable[Address]) -> None """ Adds inputs to spend in the bundle. Note that each input may require multiple transactions, in order to hold the entire signature. :param inputs: Addresses to use as the inputs for this bu...
def add_inputs(self, inputs): # type: (Iterable[Address]) -> None """ Adds inputs to spend in the bundle. Note that each input may require multiple transactions, in order to hold the entire signature. :param inputs: Addresses to use as the inputs for this bu...
[ "Adds", "inputs", "to", "spend", "in", "the", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L253-L300
[ "def", "add_inputs", "(", "self", ",", "inputs", ")", ":", "# type: (Iterable[Address]) -> None", "if", "self", ".", "hash", ":", "raise", "RuntimeError", "(", "'Bundle is already finalized.'", ")", "for", "addy", "in", "inputs", ":", "if", "addy", ".", "balance...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedBundle.finalize
Finalizes the bundle, preparing it to be attached to the Tangle.
iota/transaction/creation.py
def finalize(self): # type: () -> None """ Finalizes the bundle, preparing it to be attached to the Tangle. """ if self.hash: raise RuntimeError('Bundle is already finalized.') if not self: raise ValueError('Bundle has no transactions.') ...
def finalize(self): # type: () -> None """ Finalizes the bundle, preparing it to be attached to the Tangle. """ if self.hash: raise RuntimeError('Bundle is already finalized.') if not self: raise ValueError('Bundle has no transactions.') ...
[ "Finalizes", "the", "bundle", "preparing", "it", "to", "be", "attached", "to", "the", "Tangle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L315-L384
[ "def", "finalize", "(", "self", ")", ":", "# type: () -> None", "if", "self", ".", "hash", ":", "raise", "RuntimeError", "(", "'Bundle is already finalized.'", ")", "if", "not", "self", ":", "raise", "ValueError", "(", "'Bundle has no transactions.'", ")", "# Quic...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedBundle.sign_inputs
Sign inputs in a finalized bundle.
iota/transaction/creation.py
def sign_inputs(self, key_generator): # type: (KeyGenerator) -> None """ Sign inputs in a finalized bundle. """ if not self.hash: raise RuntimeError('Cannot sign inputs until bundle is finalized.') # Use a counter for the loop so that we can skip ahead as we ...
def sign_inputs(self, key_generator): # type: (KeyGenerator) -> None """ Sign inputs in a finalized bundle. """ if not self.hash: raise RuntimeError('Cannot sign inputs until bundle is finalized.') # Use a counter for the loop so that we can skip ahead as we ...
[ "Sign", "inputs", "in", "a", "finalized", "bundle", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L386-L438
[ "def", "sign_inputs", "(", "self", ",", "key_generator", ")", ":", "# type: (KeyGenerator) -> None", "if", "not", "self", ".", "hash", ":", "raise", "RuntimeError", "(", "'Cannot sign inputs until bundle is finalized.'", ")", "# Use a counter for the loop so that we can skip ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedBundle.sign_input_at
Signs the input at the specified index. :param start_index: The index of the first input transaction. If necessary, the resulting signature will be split across multiple transactions automatically (i.e., if an input has ``security_level=2``, you still only need ...
iota/transaction/creation.py
def sign_input_at(self, start_index, private_key): # type: (int, PrivateKey) -> None """ Signs the input at the specified index. :param start_index: The index of the first input transaction. If necessary, the resulting signature will be split across ...
def sign_input_at(self, start_index, private_key): # type: (int, PrivateKey) -> None """ Signs the input at the specified index. :param start_index: The index of the first input transaction. If necessary, the resulting signature will be split across ...
[ "Signs", "the", "input", "at", "the", "specified", "index", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L440-L464
[ "def", "sign_input_at", "(", "self", ",", "start_index", ",", "private_key", ")", ":", "# type: (int, PrivateKey) -> None", "if", "not", "self", ".", "hash", ":", "raise", "RuntimeError", "(", "'Cannot sign inputs until bundle is finalized.'", ")", "private_key", ".", ...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
ProposedBundle._create_input_transactions
Creates transactions for the specified input address.
iota/transaction/creation.py
def _create_input_transactions(self, addy): # type: (Address) -> None """ Creates transactions for the specified input address. """ self._transactions.append(ProposedTransaction( address=addy, tag=self.tag, # Spend the entire address balance; ...
def _create_input_transactions(self, addy): # type: (Address) -> None """ Creates transactions for the specified input address. """ self._transactions.append(ProposedTransaction( address=addy, tag=self.tag, # Spend the entire address balance; ...
[ "Creates", "transactions", "for", "the", "specified", "input", "address", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/creation.py#L466-L490
[ "def", "_create_input_transactions", "(", "self", ",", "addy", ")", ":", "# type: (Address) -> None", "self", ".", "_transactions", ".", "append", "(", "ProposedTransaction", "(", "address", "=", "addy", ",", "tag", "=", "self", ".", "tag", ",", "# Spend the ent...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
convert_value_to_standard_unit
Converts between any two standard units of iota. :param value: Value (affixed) to convert. For example: '1.618 Mi'. :param symbol: Unit symbol of iota to convert to. For example: 'Gi'. :return: Float as units of given symbol to convert to.
iota/transaction/utils.py
def convert_value_to_standard_unit(value, symbol='i'): # type: (Text, Text) -> float """ Converts between any two standard units of iota. :param value: Value (affixed) to convert. For example: '1.618 Mi'. :param symbol: Unit symbol of iota to convert to. For example: 'Gi'. :re...
def convert_value_to_standard_unit(value, symbol='i'): # type: (Text, Text) -> float """ Converts between any two standard units of iota. :param value: Value (affixed) to convert. For example: '1.618 Mi'. :param symbol: Unit symbol of iota to convert to. For example: 'Gi'. :re...
[ "Converts", "between", "any", "two", "standard", "units", "of", "iota", "." ]
iotaledger/iota.lib.py
python
https://github.com/iotaledger/iota.lib.py/blob/97cdd1e241498446b46157b79b2a1ea2ec6d387a/iota/transaction/utils.py#L18-L61
[ "def", "convert_value_to_standard_unit", "(", "value", ",", "symbol", "=", "'i'", ")", ":", "# type: (Text, Text) -> float", "try", ":", "# Get input value", "value_tuple", "=", "value", ".", "split", "(", ")", "amount", "=", "float", "(", "value_tuple", "[", "0...
97cdd1e241498446b46157b79b2a1ea2ec6d387a
test
modular_squareroot_in_FQ2
``modular_squareroot_in_FQ2(x)`` returns the value ``y`` such that ``y**2 % q == x``, and None if this is not possible. In cases where there are two solutions, the value with higher imaginary component is favored; if both solutions have equal imaginary component the value with higher real component is f...
py_ecc/bls/utils.py
def modular_squareroot_in_FQ2(value: FQ2) -> FQ2: """ ``modular_squareroot_in_FQ2(x)`` returns the value ``y`` such that ``y**2 % q == x``, and None if this is not possible. In cases where there are two solutions, the value with higher imaginary component is favored; if both solutions have equal ima...
def modular_squareroot_in_FQ2(value: FQ2) -> FQ2: """ ``modular_squareroot_in_FQ2(x)`` returns the value ``y`` such that ``y**2 % q == x``, and None if this is not possible. In cases where there are two solutions, the value with higher imaginary component is favored; if both solutions have equal ima...
[ "modular_squareroot_in_FQ2", "(", "x", ")", "returns", "the", "value", "y", "such", "that", "y", "**", "2", "%", "q", "==", "x", "and", "None", "if", "this", "is", "not", "possible", ".", "In", "cases", "where", "there", "are", "two", "solutions", "the...
ethereum/py_ecc
python
https://github.com/ethereum/py_ecc/blob/2088796c59574b256dc8e18f8c9351bc3688ca71/py_ecc/bls/utils.py#L49-L65
[ "def", "modular_squareroot_in_FQ2", "(", "value", ":", "FQ2", ")", "->", "FQ2", ":", "candidate_squareroot", "=", "value", "**", "(", "(", "FQ2_order", "+", "8", ")", "//", "16", ")", "check", "=", "candidate_squareroot", "**", "2", "/", "value", "if", "...
2088796c59574b256dc8e18f8c9351bc3688ca71
test
compress_G1
A compressed point is a 384-bit integer with the bit order (c_flag, b_flag, a_flag, x), where the c_flag bit is always set to 1, the b_flag bit indicates infinity when set to 1, the a_flag bit helps determine the y-coordinate when decompressing, and the 381-bit integer x is the x-coordinate of the point...
py_ecc/bls/utils.py
def compress_G1(pt: G1Uncompressed) -> G1Compressed: """ A compressed point is a 384-bit integer with the bit order (c_flag, b_flag, a_flag, x), where the c_flag bit is always set to 1, the b_flag bit indicates infinity when set to 1, the a_flag bit helps determine the y-coordinate when decompressin...
def compress_G1(pt: G1Uncompressed) -> G1Compressed: """ A compressed point is a 384-bit integer with the bit order (c_flag, b_flag, a_flag, x), where the c_flag bit is always set to 1, the b_flag bit indicates infinity when set to 1, the a_flag bit helps determine the y-coordinate when decompressin...
[ "A", "compressed", "point", "is", "a", "384", "-", "bit", "integer", "with", "the", "bit", "order", "(", "c_flag", "b_flag", "a_flag", "x", ")", "where", "the", "c_flag", "bit", "is", "always", "set", "to", "1", "the", "b_flag", "bit", "indicates", "in...
ethereum/py_ecc
python
https://github.com/ethereum/py_ecc/blob/2088796c59574b256dc8e18f8c9351bc3688ca71/py_ecc/bls/utils.py#L99-L115
[ "def", "compress_G1", "(", "pt", ":", "G1Uncompressed", ")", "->", "G1Compressed", ":", "if", "is_inf", "(", "pt", ")", ":", "# Set c_flag = 1 and b_flag = 1. leave a_flag = x = 0", "return", "G1Compressed", "(", "POW_2_383", "+", "POW_2_382", ")", "else", ":", "x...
2088796c59574b256dc8e18f8c9351bc3688ca71
test
decompress_G1
Recovers x and y coordinates from the compressed point.
py_ecc/bls/utils.py
def decompress_G1(z: G1Compressed) -> G1Uncompressed: """ Recovers x and y coordinates from the compressed point. """ # b_flag == 1 indicates the infinity point b_flag = (z % POW_2_383) // POW_2_382 if b_flag == 1: return Z1 x = z % POW_2_381 # Try solving y coordinate from the ...
def decompress_G1(z: G1Compressed) -> G1Uncompressed: """ Recovers x and y coordinates from the compressed point. """ # b_flag == 1 indicates the infinity point b_flag = (z % POW_2_383) // POW_2_382 if b_flag == 1: return Z1 x = z % POW_2_381 # Try solving y coordinate from the ...
[ "Recovers", "x", "and", "y", "coordinates", "from", "the", "compressed", "point", "." ]
ethereum/py_ecc
python
https://github.com/ethereum/py_ecc/blob/2088796c59574b256dc8e18f8c9351bc3688ca71/py_ecc/bls/utils.py#L118-L140
[ "def", "decompress_G1", "(", "z", ":", "G1Compressed", ")", "->", "G1Uncompressed", ":", "# b_flag == 1 indicates the infinity point", "b_flag", "=", "(", "z", "%", "POW_2_383", ")", "//", "POW_2_382", "if", "b_flag", "==", "1", ":", "return", "Z1", "x", "=", ...
2088796c59574b256dc8e18f8c9351bc3688ca71
test
compress_G2
The compressed point (z1, z2) has the bit order: z1: (c_flag1, b_flag1, a_flag1, x1) z2: (c_flag2, b_flag2, a_flag2, x2) where - c_flag1 is always set to 1 - b_flag1 indicates infinity when set to 1 - a_flag1 helps determine the y-coordinate when decompressing, - a_flag2, b_flag2, and c_flag...
py_ecc/bls/utils.py
def compress_G2(pt: G2Uncompressed) -> G2Compressed: """ The compressed point (z1, z2) has the bit order: z1: (c_flag1, b_flag1, a_flag1, x1) z2: (c_flag2, b_flag2, a_flag2, x2) where - c_flag1 is always set to 1 - b_flag1 indicates infinity when set to 1 - a_flag1 helps determine the y-...
def compress_G2(pt: G2Uncompressed) -> G2Compressed: """ The compressed point (z1, z2) has the bit order: z1: (c_flag1, b_flag1, a_flag1, x1) z2: (c_flag2, b_flag2, a_flag2, x2) where - c_flag1 is always set to 1 - b_flag1 indicates infinity when set to 1 - a_flag1 helps determine the y-...
[ "The", "compressed", "point", "(", "z1", "z2", ")", "has", "the", "bit", "order", ":", "z1", ":", "(", "c_flag1", "b_flag1", "a_flag1", "x1", ")", "z2", ":", "(", "c_flag2", "b_flag2", "a_flag2", "x2", ")", "where", "-", "c_flag1", "is", "always", "s...
ethereum/py_ecc
python
https://github.com/ethereum/py_ecc/blob/2088796c59574b256dc8e18f8c9351bc3688ca71/py_ecc/bls/utils.py#L157-L186
[ "def", "compress_G2", "(", "pt", ":", "G2Uncompressed", ")", "->", "G2Compressed", ":", "if", "not", "is_on_curve", "(", "pt", ",", "b2", ")", ":", "raise", "ValueError", "(", "\"The given point is not on the twisted curve over FQ**2\"", ")", "if", "is_inf", "(", ...
2088796c59574b256dc8e18f8c9351bc3688ca71
test
decompress_G2
Recovers x and y coordinates from the compressed point (z1, z2).
py_ecc/bls/utils.py
def decompress_G2(p: G2Compressed) -> G2Uncompressed: """ Recovers x and y coordinates from the compressed point (z1, z2). """ z1, z2 = p # b_flag == 1 indicates the infinity point b_flag1 = (z1 % POW_2_383) // POW_2_382 if b_flag1 == 1: return Z2 x1 = z1 % POW_2_381 x2 = z...
def decompress_G2(p: G2Compressed) -> G2Uncompressed: """ Recovers x and y coordinates from the compressed point (z1, z2). """ z1, z2 = p # b_flag == 1 indicates the infinity point b_flag1 = (z1 % POW_2_383) // POW_2_382 if b_flag1 == 1: return Z2 x1 = z1 % POW_2_381 x2 = z...
[ "Recovers", "x", "and", "y", "coordinates", "from", "the", "compressed", "point", "(", "z1", "z2", ")", "." ]
ethereum/py_ecc
python
https://github.com/ethereum/py_ecc/blob/2088796c59574b256dc8e18f8c9351bc3688ca71/py_ecc/bls/utils.py#L189-L219
[ "def", "decompress_G2", "(", "p", ":", "G2Compressed", ")", "->", "G2Uncompressed", ":", "z1", ",", "z2", "=", "p", "# b_flag == 1 indicates the infinity point", "b_flag1", "=", "(", "z1", "%", "POW_2_383", ")", "//", "POW_2_382", "if", "b_flag1", "==", "1", ...
2088796c59574b256dc8e18f8c9351bc3688ca71
test
prime_field_inv
Extended euclidean algorithm to find modular inverses for integers
py_ecc/utils.py
def prime_field_inv(a: int, n: int) -> int: """ Extended euclidean algorithm to find modular inverses for integers """ if a == 0: return 0 lm, hm = 1, 0 low, high = a % n, n while low > 1: r = high // low nm, new = hm - lm * r, high - low * r lm, low, hm, high...
def prime_field_inv(a: int, n: int) -> int: """ Extended euclidean algorithm to find modular inverses for integers """ if a == 0: return 0 lm, hm = 1, 0 low, high = a % n, n while low > 1: r = high // low nm, new = hm - lm * r, high - low * r lm, low, hm, high...
[ "Extended", "euclidean", "algorithm", "to", "find", "modular", "inverses", "for", "integers" ]
ethereum/py_ecc
python
https://github.com/ethereum/py_ecc/blob/2088796c59574b256dc8e18f8c9351bc3688ca71/py_ecc/utils.py#L21-L33
[ "def", "prime_field_inv", "(", "a", ":", "int", ",", "n", ":", "int", ")", "->", "int", ":", "if", "a", "==", "0", ":", "return", "0", "lm", ",", "hm", "=", "1", ",", "0", "low", ",", "high", "=", "a", "%", "n", ",", "n", "while", "low", ...
2088796c59574b256dc8e18f8c9351bc3688ca71
test
Lexicon.from_json_file
Load a lexicon from a JSON file. Args: filename (str): The path to a JSON dump.
striplog/lexicon.py
def from_json_file(cls, filename): """ Load a lexicon from a JSON file. Args: filename (str): The path to a JSON dump. """ with open(filename, 'r') as fp: return cls(json.load(fp))
def from_json_file(cls, filename): """ Load a lexicon from a JSON file. Args: filename (str): The path to a JSON dump. """ with open(filename, 'r') as fp: return cls(json.load(fp))
[ "Load", "a", "lexicon", "from", "a", "JSON", "file", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L72-L80
[ "def", "from_json_file", "(", "cls", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "fp", ":", "return", "cls", "(", "json", ".", "load", "(", "fp", ")", ")" ]
8033b673a151f96c29802b43763e863519a3124c
test
Lexicon.find_word_groups
Given a string and a category, finds and combines words into groups based on their proximity. Args: text (str): Some text. tokens (list): A list of regex strings. Returns: list. The combined strings it found. Example: COLOURS = [r"red(?:...
striplog/lexicon.py
def find_word_groups(self, text, category, proximity=2): """ Given a string and a category, finds and combines words into groups based on their proximity. Args: text (str): Some text. tokens (list): A list of regex strings. Returns: list. The...
def find_word_groups(self, text, category, proximity=2): """ Given a string and a category, finds and combines words into groups based on their proximity. Args: text (str): Some text. tokens (list): A list of regex strings. Returns: list. The...
[ "Given", "a", "string", "and", "a", "category", "finds", "and", "combines", "words", "into", "groups", "based", "on", "their", "proximity", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L82-L134
[ "def", "find_word_groups", "(", "self", ",", "text", ",", "category", ",", "proximity", "=", "2", ")", ":", "f", "=", "re", ".", "IGNORECASE", "words", "=", "getattr", "(", "self", ",", "category", ")", "regex", "=", "re", ".", "compile", "(", "r'(\\...
8033b673a151f96c29802b43763e863519a3124c
test
Lexicon.find_synonym
Given a string and a dict of synonyms, returns the 'preferred' word. Case insensitive. Args: word (str): A word. Returns: str: The preferred word, or the input word if not found. Example: >>> syn = {'snake': ['python', 'adder']} >>> find...
striplog/lexicon.py
def find_synonym(self, word): """ Given a string and a dict of synonyms, returns the 'preferred' word. Case insensitive. Args: word (str): A word. Returns: str: The preferred word, or the input word if not found. Example: >>> syn = {...
def find_synonym(self, word): """ Given a string and a dict of synonyms, returns the 'preferred' word. Case insensitive. Args: word (str): A word. Returns: str: The preferred word, or the input word if not found. Example: >>> syn = {...
[ "Given", "a", "string", "and", "a", "dict", "of", "synonyms", "returns", "the", "preferred", "word", ".", "Case", "insensitive", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L136-L168
[ "def", "find_synonym", "(", "self", ",", "word", ")", ":", "if", "word", "and", "self", ".", "synonyms", ":", "# Make the reverse look-up table.", "reverse_lookup", "=", "{", "}", "for", "k", ",", "v", "in", "self", ".", "synonyms", ".", "items", "(", ")...
8033b673a151f96c29802b43763e863519a3124c
test
Lexicon.expand_abbreviations
Parse a piece of text and replace any abbreviations with their full word equivalents. Uses the lexicon.abbreviations dictionary to find abbreviations. Args: text (str): The text to parse. Returns: str: The text with abbreviations replaced.
striplog/lexicon.py
def expand_abbreviations(self, text): """ Parse a piece of text and replace any abbreviations with their full word equivalents. Uses the lexicon.abbreviations dictionary to find abbreviations. Args: text (str): The text to parse. Returns: str: Th...
def expand_abbreviations(self, text): """ Parse a piece of text and replace any abbreviations with their full word equivalents. Uses the lexicon.abbreviations dictionary to find abbreviations. Args: text (str): The text to parse. Returns: str: Th...
[ "Parse", "a", "piece", "of", "text", "and", "replace", "any", "abbreviations", "with", "their", "full", "word", "equivalents", ".", "Uses", "the", "lexicon", ".", "abbreviations", "dictionary", "to", "find", "abbreviations", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L170-L209
[ "def", "expand_abbreviations", "(", "self", ",", "text", ")", ":", "if", "not", "self", ".", "abbreviations", ":", "raise", "LexiconError", "(", "\"No abbreviations in lexicon.\"", ")", "def", "chunks", "(", "data", ",", "SIZE", "=", "25", ")", ":", "\"\"\"\...
8033b673a151f96c29802b43763e863519a3124c
test
Lexicon.get_component
Takes a piece of text representing a lithologic description for one component, e.g. "Red vf-f sandstone" and turns it into a dictionary of attributes. TODO: Generalize this so that we can use any types of word, as specified in the lexicon.
striplog/lexicon.py
def get_component(self, text, required=False, first_only=True): """ Takes a piece of text representing a lithologic description for one component, e.g. "Red vf-f sandstone" and turns it into a dictionary of attributes. TODO: Generalize this so that we can use any typ...
def get_component(self, text, required=False, first_only=True): """ Takes a piece of text representing a lithologic description for one component, e.g. "Red vf-f sandstone" and turns it into a dictionary of attributes. TODO: Generalize this so that we can use any typ...
[ "Takes", "a", "piece", "of", "text", "representing", "a", "lithologic", "description", "for", "one", "component", "e", ".", "g", ".", "Red", "vf", "-", "f", "sandstone", "and", "turns", "it", "into", "a", "dictionary", "of", "attributes", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L211-L251
[ "def", "get_component", "(", "self", ",", "text", ",", "required", "=", "False", ",", "first_only", "=", "True", ")", ":", "component", "=", "{", "}", "for", "i", ",", "(", "category", ",", "words", ")", "in", "enumerate", "(", "self", ".", "__dict__...
8033b673a151f96c29802b43763e863519a3124c
test
Lexicon.split_description
Split a description into parts, each of which can be turned into a single component.
striplog/lexicon.py
def split_description(self, text): """ Split a description into parts, each of which can be turned into a single component. """ # Protect some special sequences. t = re.sub(r'(\d) ?in\. ', r'\1 inch ', text) # Protect. t = re.sub(r'(\d) ?ft\. ', r'\1 feet ', t) ...
def split_description(self, text): """ Split a description into parts, each of which can be turned into a single component. """ # Protect some special sequences. t = re.sub(r'(\d) ?in\. ', r'\1 inch ', text) # Protect. t = re.sub(r'(\d) ?ft\. ', r'\1 feet ', t) ...
[ "Split", "a", "description", "into", "parts", "each", "of", "which", "can", "be", "turned", "into", "a", "single", "component", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L253-L275
[ "def", "split_description", "(", "self", ",", "text", ")", ":", "# Protect some special sequences.", "t", "=", "re", ".", "sub", "(", "r'(\\d) ?in\\. '", ",", "r'\\1 inch '", ",", "text", ")", "# Protect.", "t", "=", "re", ".", "sub", "(", "r'(\\d) ?ft\\. '", ...
8033b673a151f96c29802b43763e863519a3124c
test
Lexicon.categories
Lists the categories in the lexicon, except the optional categories. Returns: list: A list of strings of category names.
striplog/lexicon.py
def categories(self): """ Lists the categories in the lexicon, except the optional categories. Returns: list: A list of strings of category names. """ keys = [k for k in self.__dict__.keys() if k not in SPECIAL] return keys
def categories(self): """ Lists the categories in the lexicon, except the optional categories. Returns: list: A list of strings of category names. """ keys = [k for k in self.__dict__.keys() if k not in SPECIAL] return keys
[ "Lists", "the", "categories", "in", "the", "lexicon", "except", "the", "optional", "categories", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/lexicon.py#L278-L287
[ "def", "categories", "(", "self", ")", ":", "keys", "=", "[", "k", "for", "k", "in", "self", ".", "__dict__", ".", "keys", "(", ")", "if", "k", "not", "in", "SPECIAL", "]", "return", "keys" ]
8033b673a151f96c29802b43763e863519a3124c
test
Decor._repr_html_
Jupyter Notebook magic repr function.
striplog/legend.py
def _repr_html_(self): """ Jupyter Notebook magic repr function. """ rows, c = '', '' s = '<tr><td><strong>{k}</strong></td><td style="{stl}">{v}</td></tr>' for k, v in self.__dict__.items(): if k == '_colour': k = 'colour' c =...
def _repr_html_(self): """ Jupyter Notebook magic repr function. """ rows, c = '', '' s = '<tr><td><strong>{k}</strong></td><td style="{stl}">{v}</td></tr>' for k, v in self.__dict__.items(): if k == '_colour': k = 'colour' c =...
[ "Jupyter", "Notebook", "magic", "repr", "function", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L153-L176
[ "def", "_repr_html_", "(", "self", ")", ":", "rows", ",", "c", "=", "''", ",", "''", "s", "=", "'<tr><td><strong>{k}</strong></td><td style=\"{stl}\">{v}</td></tr>'", "for", "k", ",", "v", "in", "self", ".", "__dict__", ".", "items", "(", ")", ":", "if", "...
8033b673a151f96c29802b43763e863519a3124c
test
Decor._repr_html_row_
Jupyter Notebook magic repr function as a row – used by ``Legend._repr_html_()``.
striplog/legend.py
def _repr_html_row_(self, keys): """ Jupyter Notebook magic repr function as a row – used by ``Legend._repr_html_()``. """ tr, th, c = '', '', '' r = '<td style="{stl}">{v}</td>' h = '<th>{k}</th>' for k in keys: v = self.__dict__.get(k) ...
def _repr_html_row_(self, keys): """ Jupyter Notebook magic repr function as a row – used by ``Legend._repr_html_()``. """ tr, th, c = '', '', '' r = '<td style="{stl}">{v}</td>' h = '<th>{k}</th>' for k in keys: v = self.__dict__.get(k) ...
[ "Jupyter", "Notebook", "magic", "repr", "function", "as", "a", "row", "–", "used", "by", "Legend", ".", "_repr_html_", "()", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L178-L205
[ "def", "_repr_html_row_", "(", "self", ",", "keys", ")", ":", "tr", ",", "th", ",", "c", "=", "''", ",", "''", ",", "''", "r", "=", "'<td style=\"{stl}\">{v}</td>'", "h", "=", "'<th>{k}</th>'", "for", "k", "in", "keys", ":", "v", "=", "self", ".", ...
8033b673a151f96c29802b43763e863519a3124c
test
Decor.random
Returns a minimal Decor with a random colour.
striplog/legend.py
def random(cls, component): """ Returns a minimal Decor with a random colour. """ colour = random.sample([i for i in range(256)], 3) return cls({'colour': colour, 'component': component, 'width': 1.0})
def random(cls, component): """ Returns a minimal Decor with a random colour. """ colour = random.sample([i for i in range(256)], 3) return cls({'colour': colour, 'component': component, 'width': 1.0})
[ "Returns", "a", "minimal", "Decor", "with", "a", "random", "colour", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L264-L269
[ "def", "random", "(", "cls", ",", "component", ")", ":", "colour", "=", "random", ".", "sample", "(", "[", "i", "for", "i", "in", "range", "(", "256", ")", "]", ",", "3", ")", "return", "cls", "(", "{", "'colour'", ":", "colour", ",", "'component...
8033b673a151f96c29802b43763e863519a3124c
test
Decor.plot
Make a simple plot of the Decor. Args: fmt (str): A Python format string for the component summaries. fig (Pyplot figure): A figure, optional. Use either fig or ax, not both. ax (Pyplot axis): An axis, optional. Use either fig or ax, not both....
striplog/legend.py
def plot(self, fmt=None, fig=None, ax=None): """ Make a simple plot of the Decor. Args: fmt (str): A Python format string for the component summaries. fig (Pyplot figure): A figure, optional. Use either fig or ax, not both. ax (Pyplot axis): A...
def plot(self, fmt=None, fig=None, ax=None): """ Make a simple plot of the Decor. Args: fmt (str): A Python format string for the component summaries. fig (Pyplot figure): A figure, optional. Use either fig or ax, not both. ax (Pyplot axis): A...
[ "Make", "a", "simple", "plot", "of", "the", "Decor", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L271-L321
[ "def", "plot", "(", "self", ",", "fmt", "=", "None", ",", "fig", "=", "None", ",", "ax", "=", "None", ")", ":", "u", "=", "4", "# aspect ratio of decor plot", "v", "=", "0.25", "# ratio of decor tile width", "r", "=", "None", "if", "(", "fig", "is", ...
8033b673a151f96c29802b43763e863519a3124c
test
Legend._repr_html_
Jupyter Notebook magic repr function.
striplog/legend.py
def _repr_html_(self): """ Jupyter Notebook magic repr function. """ all_keys = list(set(itertools.chain(*[d.keys for d in self]))) rows = '' for decor in self: th, tr = decor._repr_html_row_(keys=all_keys) rows += '<tr>{}</tr>'.format(tr) ...
def _repr_html_(self): """ Jupyter Notebook magic repr function. """ all_keys = list(set(itertools.chain(*[d.keys for d in self]))) rows = '' for decor in self: th, tr = decor._repr_html_row_(keys=all_keys) rows += '<tr>{}</tr>'.format(tr) ...
[ "Jupyter", "Notebook", "magic", "repr", "function", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L409-L420
[ "def", "_repr_html_", "(", "self", ")", ":", "all_keys", "=", "list", "(", "set", "(", "itertools", ".", "chain", "(", "*", "[", "d", ".", "keys", "for", "d", "in", "self", "]", ")", ")", ")", "rows", "=", "''", "for", "decor", "in", "self", ":...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.builtin
Generate a default legend. Args: name (str): The name of the legend you want. Not case sensitive. 'nsdoe': Nova Scotia Dept. of Energy 'canstrat': Canstrat 'nagmdm__6_2': USGS N. Am. Geol. Map Data Model 6.2 'nagmdm__6_1': USGS N. ...
striplog/legend.py
def builtin(cls, name): """ Generate a default legend. Args: name (str): The name of the legend you want. Not case sensitive. 'nsdoe': Nova Scotia Dept. of Energy 'canstrat': Canstrat 'nagmdm__6_2': USGS N. Am. Geol. Map Data Model ...
def builtin(cls, name): """ Generate a default legend. Args: name (str): The name of the legend you want. Not case sensitive. 'nsdoe': Nova Scotia Dept. of Energy 'canstrat': Canstrat 'nagmdm__6_2': USGS N. Am. Geol. Map Data Model ...
[ "Generate", "a", "default", "legend", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L423-L449
[ "def", "builtin", "(", "cls", ",", "name", ")", ":", "names", "=", "{", "'nsdoe'", ":", "LEGEND__NSDOE", ",", "'canstrat'", ":", "LEGEND__Canstrat", ",", "'nagmdm__6_2'", ":", "LEGEND__NAGMDM__6_2", ",", "'nagmdm__6_1'", ":", "LEGEND__NAGMDM__6_1", ",", "'nagmdm...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.builtin_timescale
Generate a default timescale legend. No arguments. Returns: Legend: The timescale stored in `defaults.py`.
striplog/legend.py
def builtin_timescale(cls, name): """ Generate a default timescale legend. No arguments. Returns: Legend: The timescale stored in `defaults.py`. """ names = { 'isc': TIMESCALE__ISC, 'usgs_isc': TIMESCALE__USGS_ISC, '...
def builtin_timescale(cls, name): """ Generate a default timescale legend. No arguments. Returns: Legend: The timescale stored in `defaults.py`. """ names = { 'isc': TIMESCALE__ISC, 'usgs_isc': TIMESCALE__USGS_ISC, '...
[ "Generate", "a", "default", "timescale", "legend", ".", "No", "arguments", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L452-L464
[ "def", "builtin_timescale", "(", "cls", ",", "name", ")", ":", "names", "=", "{", "'isc'", ":", "TIMESCALE__ISC", ",", "'usgs_isc'", ":", "TIMESCALE__USGS_ISC", ",", "'dnag'", ":", "TIMESCALE__DNAG", ",", "}", "return", "cls", ".", "from_csv", "(", "text", ...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.random
Generate a random legend for a given list of components. Args: components (list or Striplog): A list of components. If you pass a Striplog, it will use the primary components. If you pass a component on its own, you will get a random Decor. width (bool): ...
striplog/legend.py
def random(cls, components, width=False, colour=None): """ Generate a random legend for a given list of components. Args: components (list or Striplog): A list of components. If you pass a Striplog, it will use the primary components. If you pass a co...
def random(cls, components, width=False, colour=None): """ Generate a random legend for a given list of components. Args: components (list or Striplog): A list of components. If you pass a Striplog, it will use the primary components. If you pass a co...
[ "Generate", "a", "random", "legend", "for", "a", "given", "list", "of", "components", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L471-L510
[ "def", "random", "(", "cls", ",", "components", ",", "width", "=", "False", ",", "colour", "=", "None", ")", ":", "try", ":", "# Treating as a Striplog.", "list_of_Decors", "=", "[", "Decor", ".", "random", "(", "c", ")", "for", "c", "in", "[", "i", ...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.from_image
A slightly easier way to make legends from images. Args: filename (str) components (list) ignore (list): Colours to ignore, e.g. "#FFFFFF" to ignore white. col_offset (Number): If < 1, interpreted as proportion of way across the image. If > 1, int...
striplog/legend.py
def from_image(cls, filename, components, ignore=None, col_offset=0.1, row_offset=2): """ A slightly easier way to make legends from images. Args: filename (str) components (list) ignore (list): Colours...
def from_image(cls, filename, components, ignore=None, col_offset=0.1, row_offset=2): """ A slightly easier way to make legends from images. Args: filename (str) components (list) ignore (list): Colours...
[ "A", "slightly", "easier", "way", "to", "make", "legends", "from", "images", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L513-L550
[ "def", "from_image", "(", "cls", ",", "filename", ",", "components", ",", "ignore", "=", "None", ",", "col_offset", "=", "0.1", ",", "row_offset", "=", "2", ")", ":", "if", "ignore", "is", "None", ":", "ignore", "=", "[", "]", "rgb", "=", "utils", ...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.from_csv
Read CSV text and generate a Legend. Args: string (str): The CSV string. In the first row, list the properties. Precede the properties of the component with 'comp ' or 'component '. For example: colour, width, comp lithology, comp colour #FFFFFF, 0, , #F7E...
striplog/legend.py
def from_csv(cls, filename=None, text=None): """ Read CSV text and generate a Legend. Args: string (str): The CSV string. In the first row, list the properties. Precede the properties of the component with 'comp ' or 'component '. For example: colour, widt...
def from_csv(cls, filename=None, text=None): """ Read CSV text and generate a Legend. Args: string (str): The CSV string. In the first row, list the properties. Precede the properties of the component with 'comp ' or 'component '. For example: colour, widt...
[ "Read", "CSV", "text", "and", "generate", "a", "Legend", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L553-L635
[ "def", "from_csv", "(", "cls", ",", "filename", "=", "None", ",", "text", "=", "None", ")", ":", "if", "(", "filename", "is", "None", ")", "and", "(", "text", "is", "None", ")", ":", "raise", "LegendError", "(", "\"You must provide a filename or CSV text.\...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.to_csv
Renders a legend as a CSV string. No arguments. Returns: str: The legend as a CSV.
striplog/legend.py
def to_csv(self): """ Renders a legend as a CSV string. No arguments. Returns: str: The legend as a CSV. """ # We can't delegate this to Decor because we need to know the superset # of all Decor properties. There may be lots of blanks. header...
def to_csv(self): """ Renders a legend as a CSV string. No arguments. Returns: str: The legend as a CSV. """ # We can't delegate this to Decor because we need to know the superset # of all Decor properties. There may be lots of blanks. header...
[ "Renders", "a", "legend", "as", "a", "CSV", "string", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L637-L682
[ "def", "to_csv", "(", "self", ")", ":", "# We can't delegate this to Decor because we need to know the superset", "# of all Decor properties. There may be lots of blanks.", "header", "=", "[", "]", "component_header", "=", "[", "]", "for", "row", "in", "self", ":", "for", ...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.max_width
The maximum width of all the Decors in the Legend. This is needed to scale a Legend or Striplog when plotting with widths turned on.
striplog/legend.py
def max_width(self): """ The maximum width of all the Decors in the Legend. This is needed to scale a Legend or Striplog when plotting with widths turned on. """ try: maximum = max([row.width for row in self.__list if row.width is not None]) return maximum...
def max_width(self): """ The maximum width of all the Decors in the Legend. This is needed to scale a Legend or Striplog when plotting with widths turned on. """ try: maximum = max([row.width for row in self.__list if row.width is not None]) return maximum...
[ "The", "maximum", "width", "of", "all", "the", "Decors", "in", "the", "Legend", ".", "This", "is", "needed", "to", "scale", "a", "Legend", "or", "Striplog", "when", "plotting", "with", "widths", "turned", "on", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L685-L694
[ "def", "max_width", "(", "self", ")", ":", "try", ":", "maximum", "=", "max", "(", "[", "row", ".", "width", "for", "row", "in", "self", ".", "__list", "if", "row", ".", "width", "is", "not", "None", "]", ")", "return", "maximum", "except", ":", ...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.get_decor
Get the decor for a component. Args: c (component): The component to look up. match_only (list of str): The component attributes to include in the comparison. Default: All of them. Returns: Decor. The matching Decor from the Legend, or None if not found.
striplog/legend.py
def get_decor(self, c, match_only=None): """ Get the decor for a component. Args: c (component): The component to look up. match_only (list of str): The component attributes to include in the comparison. Default: All of them. Returns: Dec...
def get_decor(self, c, match_only=None): """ Get the decor for a component. Args: c (component): The component to look up. match_only (list of str): The component attributes to include in the comparison. Default: All of them. Returns: Dec...
[ "Get", "the", "decor", "for", "a", "component", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L696-L726
[ "def", "get_decor", "(", "self", ",", "c", ",", "match_only", "=", "None", ")", ":", "if", "isinstance", "(", "c", ",", "Component", ")", ":", "if", "c", ":", "if", "match_only", ":", "# Filter the component only those attributes", "c", "=", "Component", "...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.getattr
Get the attribute of a component. Args: c (component): The component to look up. attr (str): The attribute to get. default (str): What to return in the event of no match. match_only (list of str): The component attributes to include in the comparison. ...
striplog/legend.py
def getattr(self, c, attr, default=None, match_only=None): """ Get the attribute of a component. Args: c (component): The component to look up. attr (str): The attribute to get. default (str): What to return in the event of no match. match_only (list ...
def getattr(self, c, attr, default=None, match_only=None): """ Get the attribute of a component. Args: c (component): The component to look up. attr (str): The attribute to get. default (str): What to return in the event of no match. match_only (list ...
[ "Get", "the", "attribute", "of", "a", "component", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L728-L747
[ "def", "getattr", "(", "self", ",", "c", ",", "attr", ",", "default", "=", "None", ",", "match_only", "=", "None", ")", ":", "matching_decor", "=", "self", ".", "get_decor", "(", "c", ",", "match_only", "=", "match_only", ")", "try", ":", "return", "...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.get_colour
Get the display colour of a component. Wraps `getattr()`. Development note: Cannot define this as a `partial()` because I want to maintain the order of arguments in `getattr()`. Args: c (component): The component to look up. default (str): The colour to re...
striplog/legend.py
def get_colour(self, c, default='#eeeeee', match_only=None): """ Get the display colour of a component. Wraps `getattr()`. Development note: Cannot define this as a `partial()` because I want to maintain the order of arguments in `getattr()`. Args: c ...
def get_colour(self, c, default='#eeeeee', match_only=None): """ Get the display colour of a component. Wraps `getattr()`. Development note: Cannot define this as a `partial()` because I want to maintain the order of arguments in `getattr()`. Args: c ...
[ "Get", "the", "display", "colour", "of", "a", "component", ".", "Wraps", "getattr", "()", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L749-L769
[ "def", "get_colour", "(", "self", ",", "c", ",", "default", "=", "'#eeeeee'", ",", "match_only", "=", "None", ")", ":", "return", "self", ".", "getattr", "(", "c", "=", "c", ",", "attr", "=", "'colour'", ",", "default", "=", "default", ",", "match_on...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.get_width
Get the display width of a component. Wraps `getattr()`. Development note: Cannot define this as a `partial()` because I want to maintain the order of arguments in `getattr()`. Args: c (component): The component to look up. default (float): The width to return in the ev...
striplog/legend.py
def get_width(self, c, default=0, match_only=None): """ Get the display width of a component. Wraps `getattr()`. Development note: Cannot define this as a `partial()` because I want to maintain the order of arguments in `getattr()`. Args: c (component): The componen...
def get_width(self, c, default=0, match_only=None): """ Get the display width of a component. Wraps `getattr()`. Development note: Cannot define this as a `partial()` because I want to maintain the order of arguments in `getattr()`. Args: c (component): The componen...
[ "Get", "the", "display", "width", "of", "a", "component", ".", "Wraps", "getattr", "()", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L771-L790
[ "def", "get_width", "(", "self", ",", "c", ",", "default", "=", "0", ",", "match_only", "=", "None", ")", ":", "return", "self", ".", "getattr", "(", "c", "=", "c", ",", "attr", "=", "'width'", ",", "default", "=", "default", ",", "match_only", "="...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.get_component
Get the component corresponding to a display colour. This is for generating a Striplog object from a colour image of a striplog. Args: colour (str): The hex colour string to look up. tolerance (float): The colourspace distance within which to match. default (component o...
striplog/legend.py
def get_component(self, colour, tolerance=0, default=None): """ Get the component corresponding to a display colour. This is for generating a Striplog object from a colour image of a striplog. Args: colour (str): The hex colour string to look up. tolerance (float):...
def get_component(self, colour, tolerance=0, default=None): """ Get the component corresponding to a display colour. This is for generating a Striplog object from a colour image of a striplog. Args: colour (str): The hex colour string to look up. tolerance (float):...
[ "Get", "the", "component", "corresponding", "to", "a", "display", "colour", ".", "This", "is", "for", "generating", "a", "Striplog", "object", "from", "a", "colour", "image", "of", "a", "striplog", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L792-L840
[ "def", "get_component", "(", "self", ",", "colour", ",", "tolerance", "=", "0", ",", "default", "=", "None", ")", ":", "if", "not", "(", "0", "<=", "tolerance", "<=", "np", ".", "sqrt", "(", "195075", ")", ")", ":", "raise", "LegendError", "(", "'T...
8033b673a151f96c29802b43763e863519a3124c
test
Legend.plot
Make a simple plot of the legend. Simply calls Decor.plot() on all of its members. TODO: Build a more attractive plot.
striplog/legend.py
def plot(self, fmt=None): """ Make a simple plot of the legend. Simply calls Decor.plot() on all of its members. TODO: Build a more attractive plot. """ for d in self.__list: d.plot(fmt=fmt) return None
def plot(self, fmt=None): """ Make a simple plot of the legend. Simply calls Decor.plot() on all of its members. TODO: Build a more attractive plot. """ for d in self.__list: d.plot(fmt=fmt) return None
[ "Make", "a", "simple", "plot", "of", "the", "legend", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/legend.py#L842-L853
[ "def", "plot", "(", "self", ",", "fmt", "=", "None", ")", ":", "for", "d", "in", "self", ".", "__list", ":", "d", ".", "plot", "(", "fmt", "=", "fmt", ")", "return", "None" ]
8033b673a151f96c29802b43763e863519a3124c
test
Component._repr_html_
Jupyter Notebook magic repr function.
striplog/component.py
def _repr_html_(self): """ Jupyter Notebook magic repr function. """ rows = '' s = '<tr><td><strong>{k}</strong></td><td>{v}</td></tr>' for k, v in self.__dict__.items(): rows += s.format(k=k, v=v) html = '<table>{}</table>'.format(rows) return...
def _repr_html_(self): """ Jupyter Notebook magic repr function. """ rows = '' s = '<tr><td><strong>{k}</strong></td><td>{v}</td></tr>' for k, v in self.__dict__.items(): rows += s.format(k=k, v=v) html = '<table>{}</table>'.format(rows) return...
[ "Jupyter", "Notebook", "magic", "repr", "function", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/component.py#L130-L139
[ "def", "_repr_html_", "(", "self", ")", ":", "rows", "=", "''", "s", "=", "'<tr><td><strong>{k}</strong></td><td>{v}</td></tr>'", "for", "k", ",", "v", "in", "self", ".", "__dict__", ".", "items", "(", ")", ":", "rows", "+=", "s", ".", "format", "(", "k"...
8033b673a151f96c29802b43763e863519a3124c
test
Component.from_text
Generate a Component from a text string, using a Lexicon. Args: text (str): The text string to parse. lexicon (Lexicon): The dictionary to use for the categories and lexemes. required (str): An attribute that we must have. If a required attrib...
striplog/component.py
def from_text(cls, text, lexicon, required=None, first_only=True): """ Generate a Component from a text string, using a Lexicon. Args: text (str): The text string to parse. lexicon (Lexicon): The dictionary to use for the categories and lexemes. ...
def from_text(cls, text, lexicon, required=None, first_only=True): """ Generate a Component from a text string, using a Lexicon. Args: text (str): The text string to parse. lexicon (Lexicon): The dictionary to use for the categories and lexemes. ...
[ "Generate", "a", "Component", "from", "a", "text", "string", "using", "a", "Lexicon", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/component.py#L148-L169
[ "def", "from_text", "(", "cls", ",", "text", ",", "lexicon", ",", "required", "=", "None", ",", "first_only", "=", "True", ")", ":", "component", "=", "lexicon", ".", "get_component", "(", "text", ",", "first_only", "=", "first_only", ")", "if", "require...
8033b673a151f96c29802b43763e863519a3124c
test
Component.summary
Given a format string, return a summary description of a component. Args: component (dict): A component dictionary. fmt (str): Describes the format with a string. If no format is given, you will just get a list of attributes. If you give the empty string ...
striplog/component.py
def summary(self, fmt=None, initial=True, default=''): """ Given a format string, return a summary description of a component. Args: component (dict): A component dictionary. fmt (str): Describes the format with a string. If no format is given, you will j...
def summary(self, fmt=None, initial=True, default=''): """ Given a format string, return a summary description of a component. Args: component (dict): A component dictionary. fmt (str): Describes the format with a string. If no format is given, you will j...
[ "Given", "a", "format", "string", "return", "a", "summary", "description", "of", "a", "component", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/component.py#L171-L215
[ "def", "summary", "(", "self", ",", "fmt", "=", "None", ",", "initial", "=", "True", ",", "default", "=", "''", ")", ":", "if", "default", "and", "not", "self", ".", "__dict__", ":", "return", "default", "if", "fmt", "==", "''", ":", "return", "def...
8033b673a151f96c29802b43763e863519a3124c
test
Rock
Graceful deprecation for old class name.
striplog/rock.py
def Rock(*args, **kwargs): """ Graceful deprecation for old class name. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "The 'Rock' class was renamed 'Component'. " w += "Please update your code." warnings.warn(w, DeprecationWarning, stacklevel=2)...
def Rock(*args, **kwargs): """ Graceful deprecation for old class name. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "The 'Rock' class was renamed 'Component'. " w += "Please update your code." warnings.warn(w, DeprecationWarning, stacklevel=2)...
[ "Graceful", "deprecation", "for", "old", "class", "name", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/rock.py#L14-L25
[ "def", "Rock", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "w", "=", "\"The 'Rock' class was renamed 'Component'. \"", "w", "+=", "\"P...
8033b673a151f96c29802b43763e863519a3124c
test
_process_row
Processes a single row from the file.
striplog/canstrat.py
def _process_row(text, columns): """ Processes a single row from the file. """ if not text: return # Construct the column dictionary that maps each field to # its start, its length, and its read and write functions. coldict = {k: {'start': s, 'len': l, ...
def _process_row(text, columns): """ Processes a single row from the file. """ if not text: return # Construct the column dictionary that maps each field to # its start, its length, and its read and write functions. coldict = {k: {'start': s, 'len': l, ...
[ "Processes", "a", "single", "row", "from", "the", "file", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/canstrat.py#L130-L151
[ "def", "_process_row", "(", "text", ",", "columns", ")", ":", "if", "not", "text", ":", "return", "# Construct the column dictionary that maps each field to", "# its start, its length, and its read and write functions.", "coldict", "=", "{", "k", ":", "{", "'start'", ":",...
8033b673a151f96c29802b43763e863519a3124c
test
parse_canstrat
Read all the rows and return a dict of the results.
striplog/canstrat.py
def parse_canstrat(text): """ Read all the rows and return a dict of the results. """ result = {} for row in text.split('\n'): if not row: continue if len(row) < 8: # Not a real record. continue # Read the metadata for this row/ row_header =...
def parse_canstrat(text): """ Read all the rows and return a dict of the results. """ result = {} for row in text.split('\n'): if not row: continue if len(row) < 8: # Not a real record. continue # Read the metadata for this row/ row_header =...
[ "Read", "all", "the", "rows", "and", "return", "a", "dict", "of", "the", "results", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/canstrat.py#L154-L183
[ "def", "parse_canstrat", "(", "text", ")", ":", "result", "=", "{", "}", "for", "row", "in", "text", ".", "split", "(", "'\\n'", ")", ":", "if", "not", "row", ":", "continue", "if", "len", "(", "row", ")", "<", "8", ":", "# Not a real record.", "co...
8033b673a151f96c29802b43763e863519a3124c
test
get_template
Still unsure about best way to do this, hence cruft.
striplog/templates.py
def get_template(name): """ Still unsure about best way to do this, hence cruft. """ text = re.sub(r'\r\n', r'\n', name) text = re.sub(r'\{([FISDE°].*?)\}', r'{{\1}}', text) return text
def get_template(name): """ Still unsure about best way to do this, hence cruft. """ text = re.sub(r'\r\n', r'\n', name) text = re.sub(r'\{([FISDE°].*?)\}', r'{{\1}}', text) return text
[ "Still", "unsure", "about", "best", "way", "to", "do", "this", "hence", "cruft", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/templates.py#L11-L17
[ "def", "get_template", "(", "name", ")", ":", "text", "=", "re", ".", "sub", "(", "r'\\r\\n'", ",", "r'\\n'", ",", "name", ")", "text", "=", "re", ".", "sub", "(", "r'\\{([FISDE°].*?)\\}',", " ", "'{{\\1}}',", " ", "ext)", "", "return", "text" ]
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.__strict
Private method. Checks if striplog is monotonically increasing in depth. Returns: Bool.
striplog/striplog.py
def __strict(self): """ Private method. Checks if striplog is monotonically increasing in depth. Returns: Bool. """ def conc(a, b): return a + b # Check boundaries, b b = np.array(reduce(conc, [[i.top.z, i.base.z] for i in self]))...
def __strict(self): """ Private method. Checks if striplog is monotonically increasing in depth. Returns: Bool. """ def conc(a, b): return a + b # Check boundaries, b b = np.array(reduce(conc, [[i.top.z, i.base.z] for i in self]))...
[ "Private", "method", ".", "Checks", "if", "striplog", "is", "monotonically", "increasing", "in", "depth", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L248-L262
[ "def", "__strict", "(", "self", ")", ":", "def", "conc", "(", "a", ",", "b", ")", ":", "return", "a", "+", "b", "# Check boundaries, b", "b", "=", "np", ".", "array", "(", "reduce", "(", "conc", ",", "[", "[", "i", ".", "top", ".", "z", ",", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.unique
Property. Summarize a Striplog with some statistics. Returns: List. A list of (Component, total thickness thickness) tuples.
striplog/striplog.py
def unique(self): """ Property. Summarize a Striplog with some statistics. Returns: List. A list of (Component, total thickness thickness) tuples. """ all_rx = set([iv.primary for iv in self]) table = {r: 0 for r in all_rx} for iv in self: ...
def unique(self): """ Property. Summarize a Striplog with some statistics. Returns: List. A list of (Component, total thickness thickness) tuples. """ all_rx = set([iv.primary for iv in self]) table = {r: 0 for r in all_rx} for iv in self: ...
[ "Property", ".", "Summarize", "a", "Striplog", "with", "some", "statistics", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L304-L316
[ "def", "unique", "(", "self", ")", ":", "all_rx", "=", "set", "(", "[", "iv", ".", "primary", "for", "iv", "in", "self", "]", ")", "table", "=", "{", "r", ":", "0", "for", "r", "in", "all_rx", "}", "for", "iv", "in", "self", ":", "table", "["...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.top
Property.
striplog/striplog.py
def top(self): """ Property. """ # For backwards compatibility. with warnings.catch_warnings(): warnings.simplefilter("always") w = "Striplog.top is deprecated; please use Striplog.unique" warnings.warn(w, DeprecationWarning, stacklevel=2) ...
def top(self): """ Property. """ # For backwards compatibility. with warnings.catch_warnings(): warnings.simplefilter("always") w = "Striplog.top is deprecated; please use Striplog.unique" warnings.warn(w, DeprecationWarning, stacklevel=2) ...
[ "Property", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L319-L328
[ "def", "top", "(", "self", ")", ":", "# For backwards compatibility.", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "w", "=", "\"Striplog.top is deprecated; please use Striplog.unique\"", "warnings", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.__intervals_from_tops
Private method. Take a sequence of tops in an arbitrary dimension, and provide a list of intervals from which a striplog can be made. This is only intended to be used by ``from_image()``. Args: tops (iterable). A list of floats. values (iterable). A list of values to lo...
striplog/striplog.py
def __intervals_from_tops(self, tops, values, basis, components, field=None, ignore_nan=True): """ Private method. Take a se...
def __intervals_from_tops(self, tops, values, basis, components, field=None, ignore_nan=True): """ Private method. Take a se...
[ "Private", "method", ".", "Take", "a", "sequence", "of", "tops", "in", "an", "arbitrary", "dimension", "and", "provide", "a", "list", "of", "intervals", "from", "which", "a", "striplog", "can", "be", "made", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L331-L382
[ "def", "__intervals_from_tops", "(", "self", ",", "tops", ",", "values", ",", "basis", ",", "components", ",", "field", "=", "None", ",", "ignore_nan", "=", "True", ")", ":", "# Scale tops to actual depths.", "length", "=", "float", "(", "basis", ".", "size"...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog._clean_longitudinal_data
Private function. Make sure we have what we need to make a striplog.
striplog/striplog.py
def _clean_longitudinal_data(cls, data, null=None): """ Private function. Make sure we have what we need to make a striplog. """ # Rename 'depth' or 'MD' if ('top' not in data.keys()): data['top'] = data.pop('depth', data.pop('MD', None)) # Sort everything ...
def _clean_longitudinal_data(cls, data, null=None): """ Private function. Make sure we have what we need to make a striplog. """ # Rename 'depth' or 'MD' if ('top' not in data.keys()): data['top'] = data.pop('depth', data.pop('MD', None)) # Sort everything ...
[ "Private", "function", ".", "Make", "sure", "we", "have", "what", "we", "need", "to", "make", "a", "striplog", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L385-L407
[ "def", "_clean_longitudinal_data", "(", "cls", ",", "data", ",", "null", "=", "None", ")", ":", "# Rename 'depth' or 'MD'", "if", "(", "'top'", "not", "in", "data", ".", "keys", "(", ")", ")", ":", "data", "[", "'top'", "]", "=", "data", ".", "pop", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_petrel
Makes a striplog from a Petrel text file. Returns: striplog.
striplog/striplog.py
def from_petrel(cls, filename, stop=None, points=False, null=None, function=None, include=None, exclude=None, remap=None, ignore=None): """ Mak...
def from_petrel(cls, filename, stop=None, points=False, null=None, function=None, include=None, exclude=None, remap=None, ignore=None): """ Mak...
[ "Makes", "a", "striplog", "from", "a", "Petrel", "text", "file", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L410-L444
[ "def", "from_petrel", "(", "cls", ",", "filename", ",", "stop", "=", "None", ",", "points", "=", "False", ",", "null", "=", "None", ",", "function", "=", "None", ",", "include", "=", "None", ",", "exclude", "=", "None", ",", "remap", "=", "None", "...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog._build_list_of_Intervals
Private function. Takes a data dictionary and reconstructs a list of Intervals from it. Args: data_dict (dict) stop (float): Where to end the last interval. points (bool) include (dict) exclude (dict) ignore (list) lexi...
striplog/striplog.py
def _build_list_of_Intervals(cls, data_dict, stop=None, points=False, include=None, exclude=None, ignore=None, ...
def _build_list_of_Intervals(cls, data_dict, stop=None, points=False, include=None, exclude=None, ignore=None, ...
[ "Private", "function", ".", "Takes", "a", "data", "dictionary", "and", "reconstructs", "a", "list", "of", "Intervals", "from", "it", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L447-L546
[ "def", "_build_list_of_Intervals", "(", "cls", ",", "data_dict", ",", "stop", "=", "None", ",", "points", "=", "False", ",", "include", "=", "None", ",", "exclude", "=", "None", ",", "ignore", "=", "None", ",", "lexicon", "=", "None", ")", ":", "includ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_csv
Load from a CSV file or text.
striplog/striplog.py
def from_csv(cls, filename=None, text=None, dlm=',', lexicon=None, points=False, include=None, exclude=None, remap=None, function=None, null=None, ign...
def from_csv(cls, filename=None, text=None, dlm=',', lexicon=None, points=False, include=None, exclude=None, remap=None, function=None, null=None, ign...
[ "Load", "from", "a", "CSV", "file", "or", "text", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L549-L619
[ "def", "from_csv", "(", "cls", ",", "filename", "=", "None", ",", "text", "=", "None", ",", "dlm", "=", "','", ",", "lexicon", "=", "None", ",", "points", "=", "False", ",", "include", "=", "None", ",", "exclude", "=", "None", ",", "remap", "=", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_descriptions
Convert a CSV string into a striplog. Expects 2 or 3 fields: top, description OR top, base, description Args: text (str): The input text, given by ``well.other``. lexicon (Lexicon): A lexicon, required to extract components. source (str): ...
striplog/striplog.py
def from_descriptions(cls, text, lexicon=None, source='CSV', dlm=',', points=False, abbreviations=False, complete=False, order='depth', ...
def from_descriptions(cls, text, lexicon=None, source='CSV', dlm=',', points=False, abbreviations=False, complete=False, order='depth', ...
[ "Convert", "a", "CSV", "string", "into", "a", "striplog", ".", "Expects", "2", "or", "3", "fields", ":", "top", "description", "OR", "top", "base", "description" ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L622-L735
[ "def", "from_descriptions", "(", "cls", ",", "text", ",", "lexicon", "=", "None", ",", "source", "=", "'CSV'", ",", "dlm", "=", "','", ",", "points", "=", "False", ",", "abbreviations", "=", "False", ",", "complete", "=", "False", ",", "order", "=", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_image
Read an image and generate Striplog. Args: filename (str): An image file, preferably high-res PNG. start (float or int): The depth at the top of the image. stop (float or int): The depth at the bottom of the image. legend (Legend): A legend to look up the compone...
striplog/striplog.py
def from_image(cls, filename, start, stop, legend, source="Image", col_offset=0.1, row_offset=2, tolerance=0): """ Read an image and generate Striplog. Args: filename (str): An image file, preferably high-re...
def from_image(cls, filename, start, stop, legend, source="Image", col_offset=0.1, row_offset=2, tolerance=0): """ Read an image and generate Striplog. Args: filename (str): An image file, preferably high-re...
[ "Read", "an", "image", "and", "generate", "Striplog", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L738-L794
[ "def", "from_image", "(", "cls", ",", "filename", ",", "start", ",", "stop", ",", "legend", ",", "source", "=", "\"Image\"", ",", "col_offset", "=", "0.1", ",", "row_offset", "=", "2", ",", "tolerance", "=", "0", ")", ":", "rgb", "=", "utils", ".", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_img
For backwards compatibility.
striplog/striplog.py
def from_img(cls, *args, **kwargs): """ For backwards compatibility. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "from_img() is deprecated; please use from_image()" warnings.warn(w) return cls.from_image(*args, **kwa...
def from_img(cls, *args, **kwargs): """ For backwards compatibility. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "from_img() is deprecated; please use from_image()" warnings.warn(w) return cls.from_image(*args, **kwa...
[ "For", "backwards", "compatibility", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L797-L805
[ "def", "from_img", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "w", "=", "\"from_img() is deprecated; please use from_image(...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog._from_array
DEPRECATING. Turn an array-like into a Striplog. It should have the following format (where ``base`` is optional): [(top, base, description), (top, base, description), ... ] Args: a (array-like): A list of lists or of tuples, or a...
striplog/striplog.py
def _from_array(cls, a, lexicon=None, source="", points=False, abbreviations=False): """ DEPRECATING. Turn an array-like into a Striplog. It should have the following format (where ``base`` is optional): ...
def _from_array(cls, a, lexicon=None, source="", points=False, abbreviations=False): """ DEPRECATING. Turn an array-like into a Striplog. It should have the following format (where ``base`` is optional): ...
[ "DEPRECATING", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L808-L853
[ "def", "_from_array", "(", "cls", ",", "a", ",", "lexicon", "=", "None", ",", "source", "=", "\"\"", ",", "points", "=", "False", ",", "abbreviations", "=", "False", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_log
Turn a 1D array into a striplog, given a cutoff. Args: log (array-like): A 1D array or a list of integers. cutoff (number or array-like): The log value(s) at which to bin the log. Optional. components (array-like): A list of components. Use this or ...
striplog/striplog.py
def from_log(cls, log, cutoff=None, components=None, legend=None, legend_field=None, field=None, right=False, basis=None, source='Log'): """ Turn a 1D array into a stri...
def from_log(cls, log, cutoff=None, components=None, legend=None, legend_field=None, field=None, right=False, basis=None, source='Log'): """ Turn a 1D array into a stri...
[ "Turn", "a", "1D", "array", "into", "a", "striplog", "given", "a", "cutoff", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L856-L939
[ "def", "from_log", "(", "cls", ",", "log", ",", "cutoff", "=", "None", ",", "components", "=", "None", ",", "legend", "=", "None", ",", "legend_field", "=", "None", ",", "field", "=", "None", ",", "right", "=", "False", ",", "basis", "=", "None", "...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_las3
Turn LAS3 'lithology' section into a Striplog. Args: string (str): A section from an LAS3 file. lexicon (Lexicon): The language for conversion to components. source (str): A source for the data. dlm (str): The delimiter. abbreviations (bool): Whether ...
striplog/striplog.py
def from_las3(cls, string, lexicon=None, source="LAS", dlm=',', abbreviations=False): """ Turn LAS3 'lithology' section into a Striplog. Args: string (str): A section from an LAS3 file. lexicon (Lexicon): The language...
def from_las3(cls, string, lexicon=None, source="LAS", dlm=',', abbreviations=False): """ Turn LAS3 'lithology' section into a Striplog. Args: string (str): A section from an LAS3 file. lexicon (Lexicon): The language...
[ "Turn", "LAS3", "lithology", "section", "into", "a", "Striplog", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L942-L978
[ "def", "from_las3", "(", "cls", ",", "string", ",", "lexicon", "=", "None", ",", "source", "=", "\"LAS\"", ",", "dlm", "=", "','", ",", "abbreviations", "=", "False", ")", ":", "f", "=", "re", ".", "DOTALL", "|", "re", ".", "IGNORECASE", "regex", "...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.from_canstrat
Eat a Canstrat DAT file and make a striplog.
striplog/striplog.py
def from_canstrat(cls, filename, source='canstrat'): """ Eat a Canstrat DAT file and make a striplog. """ with open(filename) as f: dat = f.read() data = parse_canstrat(dat) list_of_Intervals = [] for d in data[7]: # 7 is the 'card type' for litholo...
def from_canstrat(cls, filename, source='canstrat'): """ Eat a Canstrat DAT file and make a striplog. """ with open(filename) as f: dat = f.read() data = parse_canstrat(dat) list_of_Intervals = [] for d in data[7]: # 7 is the 'card type' for litholo...
[ "Eat", "a", "Canstrat", "DAT", "file", "and", "make", "a", "striplog", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L981-L1002
[ "def", "from_canstrat", "(", "cls", ",", "filename", ",", "source", "=", "'canstrat'", ")", ":", "with", "open", "(", "filename", ")", "as", "f", ":", "dat", "=", "f", ".", "read", "(", ")", "data", "=", "parse_canstrat", "(", "dat", ")", "list_of_In...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.copy
Returns a shallow copy.
striplog/striplog.py
def copy(self): """Returns a shallow copy.""" return Striplog([i.copy() for i in self], order=self.order, source=self.source)
def copy(self): """Returns a shallow copy.""" return Striplog([i.copy() for i in self], order=self.order, source=self.source)
[ "Returns", "a", "shallow", "copy", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1004-L1008
[ "def", "copy", "(", "self", ")", ":", "return", "Striplog", "(", "[", "i", ".", "copy", "(", ")", "for", "i", "in", "self", "]", ",", "order", "=", "self", ".", "order", ",", "source", "=", "self", ".", "source", ")" ]
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.to_csv
Returns a CSV string built from the summaries of the Intervals. Args: use_descriptions (bool): Whether to use descriptions instead of summaries, if available. dlm (str): The delimiter. header (bool): Whether to form a header row. Returns: ...
striplog/striplog.py
def to_csv(self, filename=None, as_text=True, use_descriptions=False, dlm=",", header=True): """ Returns a CSV string built from the summaries of the Intervals. Args: use_descriptions (bool): Whether to use d...
def to_csv(self, filename=None, as_text=True, use_descriptions=False, dlm=",", header=True): """ Returns a CSV string built from the summaries of the Intervals. Args: use_descriptions (bool): Whether to use d...
[ "Returns", "a", "CSV", "string", "built", "from", "the", "summaries", "of", "the", "Intervals", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1027-L1080
[ "def", "to_csv", "(", "self", ",", "filename", "=", "None", ",", "as_text", "=", "True", ",", "use_descriptions", "=", "False", ",", "dlm", "=", "\",\"", ",", "header", "=", "True", ")", ":", "if", "(", "filename", "is", "None", ")", ":", "if", "("...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.to_las3
Returns an LAS 3.0 section string. Args: use_descriptions (bool): Whether to use descriptions instead of summaries, if available. dlm (str): The delimiter. source (str): The sourse of the data. Returns: str: A string forming Lithology sec...
striplog/striplog.py
def to_las3(self, use_descriptions=False, dlm=",", source="Striplog"): """ Returns an LAS 3.0 section string. Args: use_descriptions (bool): Whether to use descriptions instead of summaries, if available. dlm (str): The delimiter. source (str)...
def to_las3(self, use_descriptions=False, dlm=",", source="Striplog"): """ Returns an LAS 3.0 section string. Args: use_descriptions (bool): Whether to use descriptions instead of summaries, if available. dlm (str): The delimiter. source (str)...
[ "Returns", "an", "LAS", "3", ".", "0", "section", "string", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1083-L1103
[ "def", "to_las3", "(", "self", ",", "use_descriptions", "=", "False", ",", "dlm", "=", "\",\"", ",", "source", "=", "\"Striplog\"", ")", ":", "data", "=", "self", ".", "to_csv", "(", "use_descriptions", "=", "use_descriptions", ",", "dlm", "=", "dlm", ",...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.to_log
Return a fully sampled log from a striplog. Useful for crossplotting with log data, for example. Args: step (float): The step size. Default: 1.0. start (float): The start depth of the new log. You will want to match the logs, so use the start depth from the LAS f...
striplog/striplog.py
def to_log(self, step=1.0, start=None, stop=None, basis=None, field=None, field_function=None, dtype=None, table=None, legend=None, legend_field=None, matc...
def to_log(self, step=1.0, start=None, stop=None, basis=None, field=None, field_function=None, dtype=None, table=None, legend=None, legend_field=None, matc...
[ "Return", "a", "fully", "sampled", "log", "from", "a", "striplog", ".", "Useful", "for", "crossplotting", "with", "log", "data", "for", "example", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1106-L1256
[ "def", "to_log", "(", "self", ",", "step", "=", "1.0", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "basis", "=", "None", ",", "field", "=", "None", ",", "field_function", "=", "None", ",", "dtype", "=", "None", ",", "table", "=", "N...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.plot_points
Plotting, but only for points (as opposed to intervals).
striplog/striplog.py
def plot_points(self, ax, legend=None, field=None, field_function=None, undefined=0, **kwargs): """ Plotting, but only for points (as opposed to intervals). """ ys = [iv.top.z for iv in s...
def plot_points(self, ax, legend=None, field=None, field_function=None, undefined=0, **kwargs): """ Plotting, but only for points (as opposed to intervals). """ ys = [iv.top.z for iv in s...
[ "Plotting", "but", "only", "for", "points", "(", "as", "opposed", "to", "intervals", ")", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1265-L1289
[ "def", "plot_points", "(", "self", ",", "ax", ",", "legend", "=", "None", ",", "field", "=", "None", ",", "field_function", "=", "None", ",", "undefined", "=", "0", ",", "*", "*", "kwargs", ")", ":", "ys", "=", "[", "iv", ".", "top", ".", "z", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.plot_tops
Plotting, but only for tops (as opposed to intervals).
striplog/striplog.py
def plot_tops(self, ax, legend=None, field=None, **kwargs): """ Plotting, but only for tops (as opposed to intervals). """ if field is None: raise StriplogError('You must provide a field to plot.') ys = [iv.top.z for iv in self] try: try: ...
def plot_tops(self, ax, legend=None, field=None, **kwargs): """ Plotting, but only for tops (as opposed to intervals). """ if field is None: raise StriplogError('You must provide a field to plot.') ys = [iv.top.z for iv in self] try: try: ...
[ "Plotting", "but", "only", "for", "tops", "(", "as", "opposed", "to", "intervals", ")", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1291-L1312
[ "def", "plot_tops", "(", "self", ",", "ax", ",", "legend", "=", "None", ",", "field", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "field", "is", "None", ":", "raise", "StriplogError", "(", "'You must provide a field to plot.'", ")", "ys", "=", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.plot_field
Plotting, but only for tops (as opposed to intervals).
striplog/striplog.py
def plot_field(self, ax, legend=None, field=None, **kwargs): """ Plotting, but only for tops (as opposed to intervals). """ if field is None: raise StriplogError('You must provide a field to plot.') try: try: xs = [getattr(iv.primary, fiel...
def plot_field(self, ax, legend=None, field=None, **kwargs): """ Plotting, but only for tops (as opposed to intervals). """ if field is None: raise StriplogError('You must provide a field to plot.') try: try: xs = [getattr(iv.primary, fiel...
[ "Plotting", "but", "only", "for", "tops", "(", "as", "opposed", "to", "intervals", ")", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1314-L1334
[ "def", "plot_field", "(", "self", ",", "ax", ",", "legend", "=", "None", ",", "field", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "field", "is", "None", ":", "raise", "StriplogError", "(", "'You must provide a field to plot.'", ")", "try", ":"...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.plot_axis
Plotting, but only the Rectangles. You have to set up the figure. Returns a matplotlib axis object. Args: ax (axis): The matplotlib axis to plot into. legend (Legend): The Legend to use for colours, etc. ladder (bool): Whether to use widths or not. Default False. ...
striplog/striplog.py
def plot_axis(self, ax, legend, ladder=False, default_width=1, match_only=None, colour=None, colour_function=None, cmap=None, default=None, ...
def plot_axis(self, ax, legend, ladder=False, default_width=1, match_only=None, colour=None, colour_function=None, cmap=None, default=None, ...
[ "Plotting", "but", "only", "the", "Rectangles", ".", "You", "have", "to", "set", "up", "the", "figure", ".", "Returns", "a", "matplotlib", "axis", "object", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1339-L1427
[ "def", "plot_axis", "(", "self", ",", "ax", ",", "legend", ",", "ladder", "=", "False", ",", "default_width", "=", "1", ",", "match_only", "=", "None", ",", "colour", "=", "None", ",", "colour_function", "=", "None", ",", "cmap", "=", "None", ",", "d...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.get_data
Get data from the striplog.
striplog/striplog.py
def get_data(self, field, function=None, default=None): """ Get data from the striplog. """ f = function or utils.null data = [] for iv in self: d = iv.data.get(field) if d is None: if default is not None: d = de...
def get_data(self, field, function=None, default=None): """ Get data from the striplog. """ f = function or utils.null data = [] for iv in self: d = iv.data.get(field) if d is None: if default is not None: d = de...
[ "Get", "data", "from", "the", "striplog", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1429-L1444
[ "def", "get_data", "(", "self", ",", "field", ",", "function", "=", "None", ",", "default", "=", "None", ")", ":", "f", "=", "function", "or", "utils", ".", "null", "data", "=", "[", "]", "for", "iv", "in", "self", ":", "d", "=", "iv", ".", "da...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.plot
Hands-free plotting. Args: legend (Legend): The Legend to use for colours, etc. width (int): The width of the plot, in inches. Default 1. ladder (bool): Whether to use widths or not. Default False. aspect (int): The aspect ratio of the plot. Default 10. ...
striplog/striplog.py
def plot(self, legend=None, width=1.5, ladder=True, aspect=10, ticks=(1, 10), match_only=None, ax=None, return_fig=False, colour=None, cmap='viridis', default=None, ...
def plot(self, legend=None, width=1.5, ladder=True, aspect=10, ticks=(1, 10), match_only=None, ax=None, return_fig=False, colour=None, cmap='viridis', default=None, ...
[ "Hands", "-", "free", "plotting", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1447-L1571
[ "def", "plot", "(", "self", ",", "legend", "=", "None", ",", "width", "=", "1.5", ",", "ladder", "=", "True", ",", "aspect", "=", "10", ",", "ticks", "=", "(", "1", ",", "10", ")", ",", "match_only", "=", "None", ",", "ax", "=", "None", ",", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.read_at
Get the index of the interval at a particular 'depth' (though this might be an elevation or age or anything). Args: d (Number): The 'depth' to query. index (bool): Whether to return the index instead of the interval. Returns: Interval: The interval, or i...
striplog/striplog.py
def read_at(self, d, index=False): """ Get the index of the interval at a particular 'depth' (though this might be an elevation or age or anything). Args: d (Number): The 'depth' to query. index (bool): Whether to return the index instead of the interval. ...
def read_at(self, d, index=False): """ Get the index of the interval at a particular 'depth' (though this might be an elevation or age or anything). Args: d (Number): The 'depth' to query. index (bool): Whether to return the index instead of the interval. ...
[ "Get", "the", "index", "of", "the", "interval", "at", "a", "particular", "depth", "(", "though", "this", "might", "be", "an", "elevation", "or", "age", "or", "anything", ")", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1573-L1590
[ "def", "read_at", "(", "self", ",", "d", ",", "index", "=", "False", ")", ":", "for", "i", ",", "iv", "in", "enumerate", "(", "self", ")", ":", "if", "iv", ".", "spans", "(", "d", ")", ":", "return", "i", "if", "index", "else", "iv", "return", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.depth
For backwards compatibility.
striplog/striplog.py
def depth(self, d): """ For backwards compatibility. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "depth() is deprecated; please use read_at()" warnings.warn(w) return self.read_at(d)
def depth(self, d): """ For backwards compatibility. """ with warnings.catch_warnings(): warnings.simplefilter("always") w = "depth() is deprecated; please use read_at()" warnings.warn(w) return self.read_at(d)
[ "For", "backwards", "compatibility", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1592-L1600
[ "def", "depth", "(", "self", ",", "d", ")", ":", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "\"always\"", ")", "w", "=", "\"depth() is deprecated; please use read_at()\"", "warnings", ".", "warn", "(", "w", ...
8033b673a151f96c29802b43763e863519a3124c
test
Striplog.extract
'Extract' a log into the components of a striplog. Args: log (array_like). A log or other 1D data. basis (array_like). The depths or elevations of the log samples. name (str). The name of the attribute to store in the components. function (function). A function t...
striplog/striplog.py
def extract(self, log, basis, name, function=None): """ 'Extract' a log into the components of a striplog. Args: log (array_like). A log or other 1D data. basis (array_like). The depths or elevations of the log samples. name (str). The name of the attribute t...
def extract(self, log, basis, name, function=None): """ 'Extract' a log into the components of a striplog. Args: log (array_like). A log or other 1D data. basis (array_like). The depths or elevations of the log samples. name (str). The name of the attribute t...
[ "Extract", "a", "log", "into", "the", "components", "of", "a", "striplog", "." ]
agile-geoscience/striplog
python
https://github.com/agile-geoscience/striplog/blob/8033b673a151f96c29802b43763e863519a3124c/striplog/striplog.py#L1602-L1635
[ "def", "extract", "(", "self", ",", "log", ",", "basis", ",", "name", ",", "function", "=", "None", ")", ":", "# Build a dict of {index: [log values]} to keep track.", "intervals", "=", "{", "}", "previous_ix", "=", "-", "1", "for", "i", ",", "z", "in", "e...
8033b673a151f96c29802b43763e863519a3124c