repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.build_vocab
def build_vocab(self, texts, verbose=1, **kwargs): """Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs fo...
python
def build_vocab(self, texts, verbose=1, **kwargs): """Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs fo...
[ "def", "build_vocab", "(", "self", ",", "texts", ",", "verbose", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "has_vocab", ":", "logger", ".", "warn", "(", "\"Tokenizer already has existing vocabulary. Overriding and building new vocabulary.\"", ...
Builds the internal vocabulary and computes various statistics. Args: texts: The list of text items to encode. verbose: The verbosity level for progress. Can be 0, 1, 2. (Default value = 1) **kwargs: The kwargs for `token_generator`.
[ "Builds", "the", "internal", "vocabulary", "and", "computes", "various", "statistics", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L207-L239
train
Builds the internal vocabulary and computes various statistics.
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.pad_sequences
def pad_sequences(self, sequences, fixed_sentences_seq_length=None, fixed_token_seq_length=None, padding='pre', truncating='post', padding_token="<PAD>"): """Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequen...
python
def pad_sequences(self, sequences, fixed_sentences_seq_length=None, fixed_token_seq_length=None, padding='pre', truncating='post', padding_token="<PAD>"): """Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequen...
[ "def", "pad_sequences", "(", "self", ",", "sequences", ",", "fixed_sentences_seq_length", "=", "None", ",", "fixed_token_seq_length", "=", "None", ",", "padding", "=", "'pre'", ",", "truncating", "=", "'post'", ",", "padding_token", "=", "\"<PAD>\"", ")", ":", ...
Pads each sequence to the same fixed length (length of the longest sequence or provided override). Args: sequences: list of list (samples, words) or list of list of list (samples, sentences, words) fixed_sentences_seq_length: The fix sentence sequence length to use. If None, largest sen...
[ "Pads", "each", "sequence", "to", "the", "same", "fixed", "length", "(", "length", "of", "the", "longest", "sequence", "or", "provided", "override", ")", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L241-L271
train
Pads each sequence in the list of sequences to the same fixed length.
jfilter/text-classification-keras
texcla/preprocessing/tokenizer.py
Tokenizer.get_stats
def get_stats(self, i): """Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of to...
python
def get_stats(self, i): """Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of to...
[ "def", "get_stats", "(", "self", ",", "i", ")", ":", "# OrderedDict to always show same order if printed.", "result", "=", "OrderedDict", "(", ")", "result", "[", "'min'", "]", "=", "np", ".", "min", "(", "self", ".", "_counts", "[", "i", "]", ")", "result...
Gets the standard statistics for aux_index `i`. For example, if `token_generator` generates `(text_idx, sentence_idx, word)`, then `get_stats(0)` will return various statistics about sentence lengths across texts. Similarly, `get_counts(1)` will return statistics of token lengths across sentences. ...
[ "Gets", "the", "standard", "statistics", "for", "aux_index", "i", ".", "For", "example", "if", "token_generator", "generates", "(", "text_idx", "sentence_idx", "word", ")", "then", "get_stats", "(", "0", ")", "will", "return", "various", "statistics", "about", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/tokenizer.py#L286-L299
train
Gets the standard statistics for aux_index i.
jfilter/text-classification-keras
texcla/embeddings.py
build_embedding_weights
def build_embedding_weights(word_index, embeddings_index): """Builds an embedding matrix for all words in vocab using embeddings_index """ logger.info('Loading embeddings for all words in the corpus') embedding_dim = list(embeddings_index.values())[0].shape[-1] # setting special tokens such as UNK ...
python
def build_embedding_weights(word_index, embeddings_index): """Builds an embedding matrix for all words in vocab using embeddings_index """ logger.info('Loading embeddings for all words in the corpus') embedding_dim = list(embeddings_index.values())[0].shape[-1] # setting special tokens such as UNK ...
[ "def", "build_embedding_weights", "(", "word_index", ",", "embeddings_index", ")", ":", "logger", ".", "info", "(", "'Loading embeddings for all words in the corpus'", ")", "embedding_dim", "=", "list", "(", "embeddings_index", ".", "values", "(", ")", ")", "[", "0"...
Builds an embedding matrix for all words in vocab using embeddings_index
[ "Builds", "an", "embedding", "matrix", "for", "all", "words", "in", "vocab", "using", "embeddings_index" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L146-L161
train
Builds an embedding matrix for all words in vocab using embeddings_index
jfilter/text-classification-keras
texcla/embeddings.py
build_fasttext_wiki_embedding_obj
def build_fasttext_wiki_embedding_obj(embedding_type): """FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information:...
python
def build_fasttext_wiki_embedding_obj(embedding_type): """FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information:...
[ "def", "build_fasttext_wiki_embedding_obj", "(", "embedding_type", ")", ":", "lang", "=", "embedding_type", ".", "split", "(", "'.'", ")", "[", "2", "]", "return", "{", "'file'", ":", "'wiki.{}.vec'", ".", "format", "(", "lang", ")", ",", "'url'", ":", "'h...
FastText pre-trained word vectors for 294 languages, with 300 dimensions, trained on Wikipedia. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. It's implemented as 'FasttextWikiTokenizer'. More information: https://fasttext.cc/docs/en/pretrained-vectors.html. Arg...
[ "FastText", "pre", "-", "trained", "word", "vectors", "for", "294", "languages", "with", "300", "dimensions", "trained", "on", "Wikipedia", ".", "It", "s", "recommended", "to", "use", "the", "same", "tokenizer", "for", "your", "data", "that", "was", "used", ...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L164-L177
train
Build a dictionary with the URL and filename used later on for downloading the file.
jfilter/text-classification-keras
texcla/embeddings.py
build_fasttext_cc_embedding_obj
def build_fasttext_cc_embedding_obj(embedding_type): """FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to co...
python
def build_fasttext_cc_embedding_obj(embedding_type): """FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to co...
[ "def", "build_fasttext_cc_embedding_obj", "(", "embedding_type", ")", ":", "lang", "=", "embedding_type", ".", "split", "(", "'.'", ")", "[", "2", "]", "return", "{", "'file'", ":", "'cc.{}.300.vec.gz'", ".", "format", "(", "lang", ")", ",", "'url'", ":", ...
FastText pre-trained word vectors for 157 languages, with 300 dimensions, trained on Common Crawl and Wikipedia. Released in 2018, it succeesed the 2017 FastText Wikipedia embeddings. It's recommended to use the same tokenizer for your data that was used to construct the embeddings. This information and more can be fin...
[ "FastText", "pre", "-", "trained", "word", "vectors", "for", "157", "languages", "with", "300", "dimensions", "trained", "on", "Common", "Crawl", "and", "Wikipedia", ".", "Released", "in", "2018", "it", "succeesed", "the", "2017", "FastText", "Wikipedia", "emb...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L180-L193
train
Build a dictionary with the URL and filename used later on for downloading the file.
jfilter/text-classification-keras
texcla/embeddings.py
get_embeddings_index
def get_embeddings_index(embedding_type='glove.42B.300d', embedding_dims=None, embedding_path=None, cache=True): """Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to ...
python
def get_embeddings_index(embedding_type='glove.42B.300d', embedding_dims=None, embedding_path=None, cache=True): """Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to ...
[ "def", "get_embeddings_index", "(", "embedding_type", "=", "'glove.42B.300d'", ",", "embedding_dims", "=", "None", ",", "embedding_path", "=", "None", ",", "cache", "=", "True", ")", ":", "if", "embedding_path", "is", "not", "None", ":", "embedding_type", "=", ...
Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed. Args: embedding_type: The embedding type to load. embedding_path: Path to a local embedding to use instead of the embedding type. Ignores `embedding_type` if specified. Returns: The...
[ "Retrieves", "embeddings", "index", "from", "embedding", "name", "or", "path", ".", "Will", "automatically", "download", "and", "cache", "as", "needed", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/embeddings.py#L211-L257
train
Retrieves embeddings index from embedding name or path. Will automatically download and cache as needed.
jfilter/text-classification-keras
texcla/preprocessing/char_tokenizer.py
CharTokenizer.token_generator
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, character)` """ for text_idx, text in enumerate(texts): if self.lower: text = text.lower() for char in text: yield text_idx, char
python
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, character)` """ for text_idx, text in enumerate(texts): if self.lower: text = text.lower() for char in text: yield text_idx, char
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "for", "text_idx", ",", "text", "in", "enumerate", "(", "texts", ")", ":", "if", "self", ".", "lower", ":", "text", "=", "text", ".", "lower", "(", ")", "for", ...
Yields tokens from texts as `(text_idx, character)`
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "character", ")" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/char_tokenizer.py#L27-L34
train
Yields tokens from texts as tuples.
jfilter/text-classification-keras
texcla/preprocessing/char_tokenizer.py
SentenceCharTokenizer.token_generator
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. ...
python
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. ...
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "# Perf optimization. Only process what is necessary.", "n_threads", ",", "batch_size", "=", "utils", ".", "_parse_spacy_kwargs", "(", "*", "*", "kwargs", ")", "nlp", "=", "s...
Yields tokens from texts as `(text_idx, sent_idx, character)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate in...
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "sent_idx", "character", ")" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/char_tokenizer.py#L53-L80
train
Yields tokens from texts as tuples.
jfilter/text-classification-keras
texcla/utils/sampling.py
equal_distribution_folds
def equal_distribution_folds(y, folds=2): """Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distribu...
python
def equal_distribution_folds(y, folds=2): """Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distribu...
[ "def", "equal_distribution_folds", "(", "y", ",", "folds", "=", "2", ")", ":", "n", ",", "classes", "=", "y", ".", "shape", "# Compute sample distribution over classes", "dist", "=", "y", ".", "sum", "(", "axis", "=", "0", ")", ".", "astype", "(", "'floa...
Creates `folds` number of indices that has roughly balanced multi-label distribution. Args: y: The multi-label outputs. folds: The number of folds to create. Returns: `folds` number of indices that have roughly equal multi-label distributions.
[ "Creates", "folds", "number", "of", "indices", "that", "has", "roughly", "balanced", "multi", "-", "label", "distribution", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/utils/sampling.py#L11-L44
train
Creates a list of indices that have roughly balanced multi - label distributions.
jfilter/text-classification-keras
texcla/models/sentence_model.py
SentenceModelFactory.build_model
def build_model(self, token_encoder_model, sentence_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: to...
python
def build_model(self, token_encoder_model, sentence_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: to...
[ "def", "build_model", "(", "self", ",", "token_encoder_model", ",", "sentence_encoder_model", ",", "trainable_embeddings", "=", "True", ",", "output_activation", "=", "'softmax'", ")", ":", "if", "not", "isinstance", "(", "token_encoder_model", ",", "SequenceEncoderBa...
Builds a model that first encodes all words within sentences using `token_encoder_model`, followed by `sentence_encoder_model`. Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding tokens within sentences. This model will be applied across all sentenc...
[ "Builds", "a", "model", "that", "first", "encodes", "all", "words", "within", "sentences", "using", "token_encoder_model", "followed", "by", "sentence_encoder_model", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/sentence_model.py#L45-L104
train
Builds a model that encodes all words within sentences using token_encoder_model followed by sentence_encoder_model.
jfilter/text-classification-keras
texcla/experiment.py
process_save
def process_save(X, y, tokenizer, proc_data_path, max_len=400, train=False, ngrams=None, limit_top_tokens=None): """Process text and save as Dataset """ if train and limit_top_tokens is not None: tokenizer.apply_encoding_options(limit_top_tokens=limit_top_tokens) X_encoded = tokenizer.encode_te...
python
def process_save(X, y, tokenizer, proc_data_path, max_len=400, train=False, ngrams=None, limit_top_tokens=None): """Process text and save as Dataset """ if train and limit_top_tokens is not None: tokenizer.apply_encoding_options(limit_top_tokens=limit_top_tokens) X_encoded = tokenizer.encode_te...
[ "def", "process_save", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_path", ",", "max_len", "=", "400", ",", "train", "=", "False", ",", "ngrams", "=", "None", ",", "limit_top_tokens", "=", "None", ")", ":", "if", "train", "and", "limit_top_token...
Process text and save as Dataset
[ "Process", "text", "and", "save", "as", "Dataset" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L106-L126
train
Process text and save as Dataset
jfilter/text-classification-keras
texcla/experiment.py
setup_data
def setup_data(X, y, tokenizer, proc_data_path, **kwargs): """Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data """ # only build vocabulary once (e.g. training data) train = ...
python
def setup_data(X, y, tokenizer, proc_data_path, **kwargs): """Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data """ # only build vocabulary once (e.g. training data) train = ...
[ "def", "setup_data", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_path", ",", "*", "*", "kwargs", ")", ":", "# only build vocabulary once (e.g. training data)", "train", "=", "not", "tokenizer", ".", "has_vocab", "if", "train", ":", "tokenizer", ".", ...
Setup data Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_path: Path for the processed data
[ "Setup", "data" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L129-L145
train
Setup data for the data set in the data set.
jfilter/text-classification-keras
texcla/experiment.py
split_data
def split_data(X, y, ratio=(0.8, 0.1, 0.1)): """Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_...
python
def split_data(X, y, ratio=(0.8, 0.1, 0.1)): """Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_...
[ "def", "split_data", "(", "X", ",", "y", ",", "ratio", "=", "(", "0.8", ",", "0.1", ",", "0.1", ")", ")", ":", "assert", "(", "sum", "(", "ratio", ")", "==", "1", "and", "len", "(", "ratio", ")", "==", "3", ")", "X_train", ",", "X_rest", ",",...
Splits data into a training, validation, and test set. Args: X: text data y: data labels ratio: the ratio for splitting. Default: (0.8, 0.1, 0.1) Returns: split data: X_train, X_val, X_test, y_train, y_val, y_test
[ "Splits", "data", "into", "a", "training", "validation", "and", "test", "set", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L148-L164
train
Splits data into training validation and test set.
jfilter/text-classification-keras
texcla/experiment.py
setup_data_split
def setup_data_split(X, y, tokenizer, proc_data_dir, **kwargs): """Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed d...
python
def setup_data_split(X, y, tokenizer, proc_data_dir, **kwargs): """Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed d...
[ "def", "setup_data_split", "(", "X", ",", "y", ",", "tokenizer", ",", "proc_data_dir", ",", "*", "*", "kwargs", ")", ":", "X_train", ",", "X_val", ",", "X_test", ",", "y_train", ",", "y_val", ",", "y_test", "=", "split_data", "(", "X", ",", "y", ")",...
Setup data while splitting into a training, validation, and test set. Args: X: text data, y: data labels, tokenizer: A Tokenizer instance proc_data_dir: Directory for the split and processed data
[ "Setup", "data", "while", "splitting", "into", "a", "training", "validation", "and", "test", "set", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L167-L186
train
Setup data while splitting into training validation and test set.
jfilter/text-classification-keras
texcla/experiment.py
load_data_split
def load_data_split(proc_data_dir): """Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data) """ ds_train = Dataset.load(path.join(proc_data_dir, 'train.bin')) ds_val = Dataset...
python
def load_data_split(proc_data_dir): """Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data) """ ds_train = Dataset.load(path.join(proc_data_dir, 'train.bin')) ds_val = Dataset...
[ "def", "load_data_split", "(", "proc_data_dir", ")", ":", "ds_train", "=", "Dataset", ".", "load", "(", "path", ".", "join", "(", "proc_data_dir", ",", "'train.bin'", ")", ")", "ds_val", "=", "Dataset", ".", "load", "(", "path", ".", "join", "(", "proc_d...
Loads a split dataset Args: proc_data_dir: Directory with the split and processed data Returns: (Training Data, Validation Data, Test Data)
[ "Loads", "a", "split", "dataset" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/experiment.py#L189-L201
train
Loads a split dataset
jfilter/text-classification-keras
texcla/models/token_model.py
TokenModelFactory.build_model
def build_model(self, token_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is ...
python
def build_model(self, token_encoder_model, trainable_embeddings=True, output_activation='softmax'): """Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is ...
[ "def", "build_model", "(", "self", ",", "token_encoder_model", ",", "trainable_embeddings", "=", "True", ",", "output_activation", "=", "'softmax'", ")", ":", "if", "not", "isinstance", "(", "token_encoder_model", ",", "SequenceEncoderBase", ")", ":", "raise", "Va...
Builds a model using the given `text_model` Args: token_encoder_model: An instance of `SequenceEncoderBase` for encoding all the tokens within a document. This encoding is then fed into a final `Dense` layer for classification. trainable_embeddings: Whether or not to fin...
[ "Builds", "a", "model", "using", "the", "given", "text_model" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/token_model.py#L39-L83
train
Builds a model for classification.
jfilter/text-classification-keras
texcla/models/layers.py
_softmax
def _softmax(x, dim): """Computes softmax along a specified dim. Keras currently lacks this feature. """ if K.backend() == 'tensorflow': import tensorflow as tf return tf.nn.softmax(x, dim) elif K.backend() is 'cntk': import cntk return cntk.softmax(x, dim) elif K.ba...
python
def _softmax(x, dim): """Computes softmax along a specified dim. Keras currently lacks this feature. """ if K.backend() == 'tensorflow': import tensorflow as tf return tf.nn.softmax(x, dim) elif K.backend() is 'cntk': import cntk return cntk.softmax(x, dim) elif K.ba...
[ "def", "_softmax", "(", "x", ",", "dim", ")", ":", "if", "K", ".", "backend", "(", ")", "==", "'tensorflow'", ":", "import", "tensorflow", "as", "tf", "return", "tf", ".", "nn", ".", "softmax", "(", "x", ",", "dim", ")", "elif", "K", ".", "backen...
Computes softmax along a specified dim. Keras currently lacks this feature.
[ "Computes", "softmax", "along", "a", "specified", "dim", ".", "Keras", "currently", "lacks", "this", "feature", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/models/layers.py#L10-L33
train
Computes the softmax along a specified dim.
jfilter/text-classification-keras
texcla/preprocessing/word_tokenizer.py
SpacyTokenizer._apply_options
def _apply_options(self, token): """Applies various filtering and processing options on token. Returns: The processed token. None if filtered. """ # Apply work token filtering. if token.is_punct and self.remove_punct: return None if token.is_stop ...
python
def _apply_options(self, token): """Applies various filtering and processing options on token. Returns: The processed token. None if filtered. """ # Apply work token filtering. if token.is_punct and self.remove_punct: return None if token.is_stop ...
[ "def", "_apply_options", "(", "self", ",", "token", ")", ":", "# Apply work token filtering.", "if", "token", ".", "is_punct", "and", "self", ".", "remove_punct", ":", "return", "None", "if", "token", ".", "is_stop", "and", "self", ".", "remove_stop_words", ":...
Applies various filtering and processing options on token. Returns: The processed token. None if filtered.
[ "Applies", "various", "filtering", "and", "processing", "options", "on", "token", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/word_tokenizer.py#L52-L77
train
Applies various filtering and processing options on token.
jfilter/text-classification-keras
texcla/preprocessing/word_tokenizer.py
SpacyTokenizer.token_generator
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, word)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_si...
python
def token_generator(self, texts, **kwargs): """Yields tokens from texts as `(text_idx, word)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_si...
[ "def", "token_generator", "(", "self", ",", "texts", ",", "*", "*", "kwargs", ")", ":", "# Perf optimization. Only process what is necessary.", "n_threads", ",", "batch_size", "=", "utils", ".", "_parse_spacy_kwargs", "(", "*", "*", "kwargs", ")", "nlp", "=", "s...
Yields tokens from texts as `(text_idx, word)` Args: texts: The list of texts. **kwargs: Supported args include: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common wor...
[ "Yields", "tokens", "from", "texts", "as", "(", "text_idx", "word", ")" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/word_tokenizer.py#L79-L107
train
Yields tokens from texts as tuples.
jfilter/text-classification-keras
texcla/preprocessing/utils.py
_append
def _append(lst, indices, value): """Adds `value` to `lst` list indexed by `indices`. Will create sub lists as required. """ for i, idx in enumerate(indices): # We need to loop because sometimes indices can increment by more than 1 due to missing tokens. # Example: Sentence with no words aft...
python
def _append(lst, indices, value): """Adds `value` to `lst` list indexed by `indices`. Will create sub lists as required. """ for i, idx in enumerate(indices): # We need to loop because sometimes indices can increment by more than 1 due to missing tokens. # Example: Sentence with no words aft...
[ "def", "_append", "(", "lst", ",", "indices", ",", "value", ")", ":", "for", "i", ",", "idx", "in", "enumerate", "(", "indices", ")", ":", "# We need to loop because sometimes indices can increment by more than 1 due to missing tokens.", "# Example: Sentence with no words a...
Adds `value` to `lst` list indexed by `indices`. Will create sub lists as required.
[ "Adds", "value", "to", "lst", "list", "indexed", "by", "indices", ".", "Will", "create", "sub", "lists", "as", "required", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L82-L95
train
Adds value to list indexed by indices. Will create sub lists as required.
jfilter/text-classification-keras
texcla/preprocessing/utils.py
_parse_spacy_kwargs
def _parse_spacy_kwargs(**kwargs): """Supported args include: Args: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common working set before processing. (Default value: 1000) """ n_threads =...
python
def _parse_spacy_kwargs(**kwargs): """Supported args include: Args: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common working set before processing. (Default value: 1000) """ n_threads =...
[ "def", "_parse_spacy_kwargs", "(", "*", "*", "kwargs", ")", ":", "n_threads", "=", "kwargs", ".", "get", "(", "'n_threads'", ")", "or", "kwargs", ".", "get", "(", "'num_threads'", ")", "batch_size", "=", "kwargs", ".", "get", "(", "'batch_size'", ")", "i...
Supported args include: Args: n_threads/num_threads: Number of threads to use. Uses num_cpus - 1 by default. batch_size: The number of texts to accumulate into a common working set before processing. (Default value: 1000)
[ "Supported", "args", "include", ":" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L113-L128
train
Parse the spacy kwargs and return the number of threads and batch size.
jfilter/text-classification-keras
texcla/preprocessing/utils.py
_CountTracker.update
def update(self, indices): """Updates counts based on indices. The algorithm tracks the index change at i and update global counts for all indices beyond i with local counts tracked so far. """ # Initialize various lists for the first time based on length of indices. if self._pre...
python
def update(self, indices): """Updates counts based on indices. The algorithm tracks the index change at i and update global counts for all indices beyond i with local counts tracked so far. """ # Initialize various lists for the first time based on length of indices. if self._pre...
[ "def", "update", "(", "self", ",", "indices", ")", ":", "# Initialize various lists for the first time based on length of indices.", "if", "self", ".", "_prev_indices", "is", "None", ":", "self", ".", "_prev_indices", "=", "indices", "# +1 to track token counts in the last ...
Updates counts based on indices. The algorithm tracks the index change at i and update global counts for all indices beyond i with local counts tracked so far.
[ "Updates", "counts", "based", "on", "indices", ".", "The", "algorithm", "tracks", "the", "index", "change", "at", "i", "and", "update", "global", "counts", "for", "all", "indices", "beyond", "i", "with", "local", "counts", "tracked", "so", "far", "." ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L34-L62
train
Updates the counts based on indices. The algorithm tracks the index change at i and update global counts for all indices beyond i with local counts tracked so far.
jfilter/text-classification-keras
texcla/preprocessing/utils.py
_CountTracker.finalize
def finalize(self): """This will add the very last document to counts. We also get rid of counts[0] since that represents document level which doesnt come under anything else. We also convert all count values to numpy arrays so that stats can be computed easily. """ for i in rang...
python
def finalize(self): """This will add the very last document to counts. We also get rid of counts[0] since that represents document level which doesnt come under anything else. We also convert all count values to numpy arrays so that stats can be computed easily. """ for i in rang...
[ "def", "finalize", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "len", "(", "self", ".", "_local_counts", ")", ")", ":", "self", ".", "counts", "[", "i", "]", ".", "append", "(", "self", ".", "_local_counts", "[", "i", "]", ...
This will add the very last document to counts. We also get rid of counts[0] since that represents document level which doesnt come under anything else. We also convert all count values to numpy arrays so that stats can be computed easily.
[ "This", "will", "add", "the", "very", "last", "document", "to", "counts", ".", "We", "also", "get", "rid", "of", "counts", "[", "0", "]", "since", "that", "represents", "document", "level", "which", "doesnt", "come", "under", "anything", "else", ".", "We...
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/preprocessing/utils.py#L64-L74
train
This will add the very last document to counts. We also remove the first document from counts and add all counts to counts.
jfilter/text-classification-keras
texcla/corpus.py
read_folder
def read_folder(directory): """read text files in directory and returns them as array Args: directory: where the text files are Returns: Array of text """ res = [] for filename in os.listdir(directory): with io.open(os.path.join(directory, filename), encoding="utf-8") a...
python
def read_folder(directory): """read text files in directory and returns them as array Args: directory: where the text files are Returns: Array of text """ res = [] for filename in os.listdir(directory): with io.open(os.path.join(directory, filename), encoding="utf-8") a...
[ "def", "read_folder", "(", "directory", ")", ":", "res", "=", "[", "]", "for", "filename", "in", "os", ".", "listdir", "(", "directory", ")", ":", "with", "io", ".", "open", "(", "os", ".", "path", ".", "join", "(", "directory", ",", "filename", ")...
read text files in directory and returns them as array Args: directory: where the text files are Returns: Array of text
[ "read", "text", "files", "in", "directory", "and", "returns", "them", "as", "array" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/corpus.py#L8-L22
train
read text files in directory and returns them as array
jfilter/text-classification-keras
texcla/corpus.py
read_pos_neg_data
def read_pos_neg_data(path, folder, limit): """returns array with positive and negative examples""" training_pos_path = os.path.join(path, folder, 'pos') training_neg_path = os.path.join(path, folder, 'neg') X_pos = read_folder(training_pos_path) X_neg = read_folder(training_neg_path) if limit...
python
def read_pos_neg_data(path, folder, limit): """returns array with positive and negative examples""" training_pos_path = os.path.join(path, folder, 'pos') training_neg_path = os.path.join(path, folder, 'neg') X_pos = read_folder(training_pos_path) X_neg = read_folder(training_neg_path) if limit...
[ "def", "read_pos_neg_data", "(", "path", ",", "folder", ",", "limit", ")", ":", "training_pos_path", "=", "os", ".", "path", ".", "join", "(", "path", ",", "folder", ",", "'pos'", ")", "training_neg_path", "=", "os", ".", "path", ".", "join", "(", "pat...
returns array with positive and negative examples
[ "returns", "array", "with", "positive", "and", "negative", "examples" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/corpus.py#L25-L40
train
returns array with positive and negative examples
jfilter/text-classification-keras
texcla/corpus.py
imdb
def imdb(limit=None, shuffle=True): """Downloads (and caches) IMDB Moview Reviews. 25k training data, 25k test data Args: limit: get only first N items for each class Returns: [X_train, y_train, X_test, y_test] """ movie_review_url = 'http://ai.stanford.edu/~amaas/data/sentiment/a...
python
def imdb(limit=None, shuffle=True): """Downloads (and caches) IMDB Moview Reviews. 25k training data, 25k test data Args: limit: get only first N items for each class Returns: [X_train, y_train, X_test, y_test] """ movie_review_url = 'http://ai.stanford.edu/~amaas/data/sentiment/a...
[ "def", "imdb", "(", "limit", "=", "None", ",", "shuffle", "=", "True", ")", ":", "movie_review_url", "=", "'http://ai.stanford.edu/~amaas/data/sentiment/aclImdb_v1.tar.gz'", "# download and extract, thus remove the suffix '.tar.gz'", "path", "=", "keras", ".", "utils", ".",...
Downloads (and caches) IMDB Moview Reviews. 25k training data, 25k test data Args: limit: get only first N items for each class Returns: [X_train, y_train, X_test, y_test]
[ "Downloads", "(", "and", "caches", ")", "IMDB", "Moview", "Reviews", ".", "25k", "training", "data", "25k", "test", "data" ]
a59c652805da41d18937c7fdad0d9fd943cf8578
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/corpus.py#L43-L66
train
Downloads and caches IMDB Moview Reviews. 25k training data 25k test data 25k test data
slightlynybbled/tk_tools
tk_tools/canvas.py
Dial.to_absolute
def to_absolute(self, x, y): """ Converts coordinates provided with reference to the center \ of the canvas (0, 0) to absolute coordinates which are used \ by the canvas object in which (0, 0) is located in the top \ left of the object. :param x: x value in pixels ...
python
def to_absolute(self, x, y): """ Converts coordinates provided with reference to the center \ of the canvas (0, 0) to absolute coordinates which are used \ by the canvas object in which (0, 0) is located in the top \ left of the object. :param x: x value in pixels ...
[ "def", "to_absolute", "(", "self", ",", "x", ",", "y", ")", ":", "return", "x", "+", "self", ".", "size", "/", "2", ",", "y", "+", "self", ".", "size", "/", "2" ]
Converts coordinates provided with reference to the center \ of the canvas (0, 0) to absolute coordinates which are used \ by the canvas object in which (0, 0) is located in the top \ left of the object. :param x: x value in pixels :param y: x value in pixels :return: No...
[ "Converts", "coordinates", "provided", "with", "reference", "to", "the", "center", "\\", "of", "the", "canvas", "(", "0", "0", ")", "to", "absolute", "coordinates", "which", "are", "used", "\\", "by", "the", "canvas", "object", "in", "which", "(", "0", "...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L43-L54
train
Converts coordinates provided with reference to the center of the canvas object to absolute coordinates which are used by the canvas object.
slightlynybbled/tk_tools
tk_tools/canvas.py
RotaryScale.set_value
def set_value(self, number: (float, int)): """ Sets the value of the graphic :param number: the number (must be between 0 and \ 'max_range' or the scale will peg the limits :return: None """ self.canvas.delete('all') self.canvas.create_image(0, 0, image=s...
python
def set_value(self, number: (float, int)): """ Sets the value of the graphic :param number: the number (must be between 0 and \ 'max_range' or the scale will peg the limits :return: None """ self.canvas.delete('all') self.canvas.create_image(0, 0, image=s...
[ "def", "set_value", "(", "self", ",", "number", ":", "(", "float", ",", "int", ")", ")", ":", "self", ".", "canvas", ".", "delete", "(", "'all'", ")", "self", ".", "canvas", ".", "create_image", "(", "0", ",", "0", ",", "image", "=", "self", ".",...
Sets the value of the graphic :param number: the number (must be between 0 and \ 'max_range' or the scale will peg the limits :return: None
[ "Sets", "the", "value", "of", "the", "graphic" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L112-L145
train
Sets the value of the graphic containing the specified number.
slightlynybbled/tk_tools
tk_tools/canvas.py
RotaryScale._draw_background
def _draw_background(self, divisions=10): """ Draws the background of the dial :param divisions: the number of divisions between 'ticks' shown on the dial :return: None """ self.canvas.create_arc(2, 2, self.size-2, self.size-2, styl...
python
def _draw_background(self, divisions=10): """ Draws the background of the dial :param divisions: the number of divisions between 'ticks' shown on the dial :return: None """ self.canvas.create_arc(2, 2, self.size-2, self.size-2, styl...
[ "def", "_draw_background", "(", "self", ",", "divisions", "=", "10", ")", ":", "self", ".", "canvas", ".", "create_arc", "(", "2", ",", "2", ",", "self", ".", "size", "-", "2", ",", "self", ".", "size", "-", "2", ",", "style", "=", "tk", ".", "...
Draws the background of the dial :param divisions: the number of divisions between 'ticks' shown on the dial :return: None
[ "Draws", "the", "background", "of", "the", "dial" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L147-L179
train
Draw the background of the dialtonical time area.
slightlynybbled/tk_tools
tk_tools/canvas.py
Graph.draw_axes
def draw_axes(self): """ Removes all existing series and re-draws the axes. :return: None """ self.canvas.delete('all') rect = 50, 50, self.w - 50, self.h - 50 self.canvas.create_rectangle(rect, outline="black") for x in self.frange(0, self.x_max - self...
python
def draw_axes(self): """ Removes all existing series and re-draws the axes. :return: None """ self.canvas.delete('all') rect = 50, 50, self.w - 50, self.h - 50 self.canvas.create_rectangle(rect, outline="black") for x in self.frange(0, self.x_max - self...
[ "def", "draw_axes", "(", "self", ")", ":", "self", ".", "canvas", ".", "delete", "(", "'all'", ")", "rect", "=", "50", ",", "50", ",", "self", ".", "w", "-", "50", ",", "self", ".", "h", "-", "50", "self", ".", "canvas", ".", "create_rectangle", ...
Removes all existing series and re-draws the axes. :return: None
[ "Removes", "all", "existing", "series", "and", "re", "-", "draws", "the", "axes", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L391-L423
train
Draws the axes for the current series.
slightlynybbled/tk_tools
tk_tools/canvas.py
Graph.plot_point
def plot_point(self, x, y, visible=True, color='black', size=5): """ Places a single point on the grid :param x: the x coordinate :param y: the y coordinate :param visible: True if the individual point should be visible :param color: the color of the point :param...
python
def plot_point(self, x, y, visible=True, color='black', size=5): """ Places a single point on the grid :param x: the x coordinate :param y: the y coordinate :param visible: True if the individual point should be visible :param color: the color of the point :param...
[ "def", "plot_point", "(", "self", ",", "x", ",", "y", ",", "visible", "=", "True", ",", "color", "=", "'black'", ",", "size", "=", "5", ")", ":", "xp", "=", "(", "self", ".", "px_x", "*", "(", "x", "-", "self", ".", "x_min", ")", ")", "/", ...
Places a single point on the grid :param x: the x coordinate :param y: the y coordinate :param visible: True if the individual point should be visible :param color: the color of the point :param size: the point size in pixels :return: The absolute coordinates as a tuple
[ "Places", "a", "single", "point", "on", "the", "grid" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L425-L451
train
Plots a single point on the grid.
slightlynybbled/tk_tools
tk_tools/canvas.py
Graph.plot_line
def plot_line(self, points: list, color='black', point_visibility=False): """ Plot a line of points :param points: a list of tuples, each tuple containing an (x, y) point :param color: the color of the line :param point_visibility: True if the points \ should be individu...
python
def plot_line(self, points: list, color='black', point_visibility=False): """ Plot a line of points :param points: a list of tuples, each tuple containing an (x, y) point :param color: the color of the line :param point_visibility: True if the points \ should be individu...
[ "def", "plot_line", "(", "self", ",", "points", ":", "list", ",", "color", "=", "'black'", ",", "point_visibility", "=", "False", ")", ":", "last_point", "=", "(", ")", "for", "point", "in", "points", ":", "this_point", "=", "self", ".", "plot_point", ...
Plot a line of points :param points: a list of tuples, each tuple containing an (x, y) point :param color: the color of the line :param point_visibility: True if the points \ should be individually visible :return: None
[ "Plot", "a", "line", "of", "points" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L453-L470
train
Plot a line of points with the given color.
slightlynybbled/tk_tools
tk_tools/canvas.py
Graph.frange
def frange(start, stop, step, digits_to_round=3): """ Works like range for doubles :param start: starting value :param stop: ending value :param step: the increment_value :param digits_to_round: the digits to which to round \ (makes floating-point numbers much ea...
python
def frange(start, stop, step, digits_to_round=3): """ Works like range for doubles :param start: starting value :param stop: ending value :param step: the increment_value :param digits_to_round: the digits to which to round \ (makes floating-point numbers much ea...
[ "def", "frange", "(", "start", ",", "stop", ",", "step", ",", "digits_to_round", "=", "3", ")", ":", "while", "start", "<", "stop", ":", "yield", "round", "(", "start", ",", "digits_to_round", ")", "start", "+=", "step" ]
Works like range for doubles :param start: starting value :param stop: ending value :param step: the increment_value :param digits_to_round: the digits to which to round \ (makes floating-point numbers much easier to work with) :return: generator
[ "Works", "like", "range", "for", "doubles" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L474-L487
train
A generator that yields the value of the key - value pair in the range [ start stop ).
slightlynybbled/tk_tools
tk_tools/canvas.py
Led._load_new
def _load_new(self, img_data: str): """ Load a new image. :param img_data: the image data as a base64 string :return: None """ self._image = tk.PhotoImage(data=img_data) self._image = self._image.subsample(int(200 / self._size), ...
python
def _load_new(self, img_data: str): """ Load a new image. :param img_data: the image data as a base64 string :return: None """ self._image = tk.PhotoImage(data=img_data) self._image = self._image.subsample(int(200 / self._size), ...
[ "def", "_load_new", "(", "self", ",", "img_data", ":", "str", ")", ":", "self", ".", "_image", "=", "tk", ".", "PhotoImage", "(", "data", "=", "img_data", ")", "self", ".", "_image", "=", "self", ".", "_image", ".", "subsample", "(", "int", "(", "2...
Load a new image. :param img_data: the image data as a base64 string :return: None
[ "Load", "a", "new", "image", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L534-L548
train
Load a new image.
slightlynybbled/tk_tools
tk_tools/canvas.py
Led.to_grey
def to_grey(self, on: bool=False): """ Change the LED to grey. :param on: Unused, here for API consistency with the other states :return: None """ self._on = False self._load_new(led_grey)
python
def to_grey(self, on: bool=False): """ Change the LED to grey. :param on: Unused, here for API consistency with the other states :return: None """ self._on = False self._load_new(led_grey)
[ "def", "to_grey", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "False", "self", ".", "_load_new", "(", "led_grey", ")" ]
Change the LED to grey. :param on: Unused, here for API consistency with the other states :return: None
[ "Change", "the", "LED", "to", "grey", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L550-L558
train
Change the LED to grey.
slightlynybbled/tk_tools
tk_tools/canvas.py
Led.to_green
def to_green(self, on: bool=False): """ Change the LED to green (on or off). :param on: True or False :return: None """ self._on = on if on: self._load_new(led_green_on) if self._toggle_on_click: self._canvas.bind('<Button...
python
def to_green(self, on: bool=False): """ Change the LED to green (on or off). :param on: True or False :return: None """ self._on = on if on: self._load_new(led_green_on) if self._toggle_on_click: self._canvas.bind('<Button...
[ "def", "to_green", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "on", "if", "on", ":", "self", ".", "_load_new", "(", "led_green_on", ")", "if", "self", ".", "_toggle_on_click", ":", "self", ".", "_canvas", ...
Change the LED to green (on or off). :param on: True or False :return: None
[ "Change", "the", "LED", "to", "green", "(", "on", "or", "off", ")", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L560-L577
train
Change the LED to green.
slightlynybbled/tk_tools
tk_tools/canvas.py
Led.to_red
def to_red(self, on: bool=False): """ Change the LED to red (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_red_on) if self._toggle_on_click: self._canvas.bind('<Button-1>', la...
python
def to_red(self, on: bool=False): """ Change the LED to red (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_red_on) if self._toggle_on_click: self._canvas.bind('<Button-1>', la...
[ "def", "to_red", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "on", "if", "on", ":", "self", ".", "_load_new", "(", "led_red_on", ")", "if", "self", ".", "_toggle_on_click", ":", "self", ".", "_canvas", ".",...
Change the LED to red (on or off) :param on: True or False :return: None
[ "Change", "the", "LED", "to", "red", "(", "on", "or", "off", ")", ":", "param", "on", ":", "True", "or", "False", ":", "return", ":", "None" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L579-L595
train
Change the LED to red.
slightlynybbled/tk_tools
tk_tools/canvas.py
Led.to_yellow
def to_yellow(self, on: bool=False): """ Change the LED to yellow (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_yellow_on) if self._toggle_on_click: self._canvas.bind('<Butto...
python
def to_yellow(self, on: bool=False): """ Change the LED to yellow (on or off) :param on: True or False :return: None """ self._on = on if on: self._load_new(led_yellow_on) if self._toggle_on_click: self._canvas.bind('<Butto...
[ "def", "to_yellow", "(", "self", ",", "on", ":", "bool", "=", "False", ")", ":", "self", ".", "_on", "=", "on", "if", "on", ":", "self", ".", "_load_new", "(", "led_yellow_on", ")", "if", "self", ".", "_toggle_on_click", ":", "self", ".", "_canvas", ...
Change the LED to yellow (on or off) :param on: True or False :return: None
[ "Change", "the", "LED", "to", "yellow", "(", "on", "or", "off", ")", ":", "param", "on", ":", "True", "or", "False", ":", "return", ":", "None" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/canvas.py#L597-L615
train
Change the LED to yellow.
slightlynybbled/tk_tools
tk_tools/groups.py
_Grid._redraw
def _redraw(self): """ Forgets the current layout and redraws with the most recent information :return: None """ for row in self._rows: for widget in row: widget.grid_forget() offset = 0 if not self.headers else 1 for i, row in enumer...
python
def _redraw(self): """ Forgets the current layout and redraws with the most recent information :return: None """ for row in self._rows: for widget in row: widget.grid_forget() offset = 0 if not self.headers else 1 for i, row in enumer...
[ "def", "_redraw", "(", "self", ")", ":", "for", "row", "in", "self", ".", "_rows", ":", "for", "widget", "in", "row", ":", "widget", ".", "grid_forget", "(", ")", "offset", "=", "0", "if", "not", "self", ".", "headers", "else", "1", "for", "i", "...
Forgets the current layout and redraws with the most recent information :return: None
[ "Forgets", "the", "current", "layout", "and", "redraws", "with", "the", "most", "recent", "information" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L56-L69
train
Forgets the current layout and redraws with the most recent information
slightlynybbled/tk_tools
tk_tools/groups.py
_Grid.remove_row
def remove_row(self, row_number: int=-1): """ Removes a specified row of data :param row_number: the row to remove (defaults to the last row) :return: None """ if len(self._rows) == 0: return row = self._rows.pop(row_number) for widget in row...
python
def remove_row(self, row_number: int=-1): """ Removes a specified row of data :param row_number: the row to remove (defaults to the last row) :return: None """ if len(self._rows) == 0: return row = self._rows.pop(row_number) for widget in row...
[ "def", "remove_row", "(", "self", ",", "row_number", ":", "int", "=", "-", "1", ")", ":", "if", "len", "(", "self", ".", "_rows", ")", "==", "0", ":", "return", "row", "=", "self", ".", "_rows", ".", "pop", "(", "row_number", ")", "for", "widget"...
Removes a specified row of data :param row_number: the row to remove (defaults to the last row) :return: None
[ "Removes", "a", "specified", "row", "of", "data" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L71-L83
train
Removes a specified row of data
slightlynybbled/tk_tools
tk_tools/groups.py
LabelGrid.add_row
def add_row(self, data: list): """ Add a row of data to the current widget :param data: a row of data :return: None """ # validation if self.headers: if len(self.headers) != len(data): raise ValueError if len(data) != self.num...
python
def add_row(self, data: list): """ Add a row of data to the current widget :param data: a row of data :return: None """ # validation if self.headers: if len(self.headers) != len(data): raise ValueError if len(data) != self.num...
[ "def", "add_row", "(", "self", ",", "data", ":", "list", ")", ":", "# validation", "if", "self", ".", "headers", ":", "if", "len", "(", "self", ".", "headers", ")", "!=", "len", "(", "data", ")", ":", "raise", "ValueError", "if", "len", "(", "data"...
Add a row of data to the current widget :param data: a row of data :return: None
[ "Add", "a", "row", "of", "data", "to", "the", "current", "widget" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L109-L132
train
Adds a row of data to the current widget.
slightlynybbled/tk_tools
tk_tools/groups.py
EntryGrid.add_row
def add_row(self, data: list=None): """ Add a row of data to the current widget, add a <Tab> \ binding to the last element of the last row, and set \ the focus at the beginning of the next row. :param data: a row of data :return: None """ # validation ...
python
def add_row(self, data: list=None): """ Add a row of data to the current widget, add a <Tab> \ binding to the last element of the last row, and set \ the focus at the beginning of the next row. :param data: a row of data :return: None """ # validation ...
[ "def", "add_row", "(", "self", ",", "data", ":", "list", "=", "None", ")", ":", "# validation", "if", "self", ".", "headers", "and", "data", ":", "if", "len", "(", "self", ".", "headers", ")", "!=", "len", "(", "data", ")", ":", "raise", "ValueErro...
Add a row of data to the current widget, add a <Tab> \ binding to the last element of the last row, and set \ the focus at the beginning of the next row. :param data: a row of data :return: None
[ "Add", "a", "row", "of", "data", "to", "the", "current", "widget", "add", "a", "<Tab", ">", "\\", "binding", "to", "the", "last", "element", "of", "the", "last", "row", "and", "set", "\\", "the", "focus", "at", "the", "beginning", "of", "the", "next"...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L148-L198
train
Adds a row of data to the current widget and sets the focus at the beginning of the next row.
slightlynybbled/tk_tools
tk_tools/groups.py
EntryGrid._read_as_dict
def _read_as_dict(self): """ Read the data contained in all entries as a list of dictionaries with the headers as the dictionary keys :return: list of dicts containing all tabular data """ data = list() for row in self._rows: row_data = OrderedDict() ...
python
def _read_as_dict(self): """ Read the data contained in all entries as a list of dictionaries with the headers as the dictionary keys :return: list of dicts containing all tabular data """ data = list() for row in self._rows: row_data = OrderedDict() ...
[ "def", "_read_as_dict", "(", "self", ")", ":", "data", "=", "list", "(", ")", "for", "row", "in", "self", ".", "_rows", ":", "row_data", "=", "OrderedDict", "(", ")", "for", "i", ",", "header", "in", "enumerate", "(", "self", ".", "headers", ")", "...
Read the data contained in all entries as a list of dictionaries with the headers as the dictionary keys :return: list of dicts containing all tabular data
[ "Read", "the", "data", "contained", "in", "all", "entries", "as", "a", "list", "of", "dictionaries", "with", "the", "headers", "as", "the", "dictionary", "keys" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L200-L215
train
Read the data contained in all entries as a list of dicts with the headers as the dictionary keys
slightlynybbled/tk_tools
tk_tools/groups.py
EntryGrid._read_as_table
def _read_as_table(self): """ Read the data contained in all entries as a list of lists containing all of the data :return: list of dicts containing all tabular data """ rows = list() for row in self._rows: rows.append([row[i].get() for i in range(se...
python
def _read_as_table(self): """ Read the data contained in all entries as a list of lists containing all of the data :return: list of dicts containing all tabular data """ rows = list() for row in self._rows: rows.append([row[i].get() for i in range(se...
[ "def", "_read_as_table", "(", "self", ")", ":", "rows", "=", "list", "(", ")", "for", "row", "in", "self", ".", "_rows", ":", "rows", ".", "append", "(", "[", "row", "[", "i", "]", ".", "get", "(", ")", "for", "i", "in", "range", "(", "self", ...
Read the data contained in all entries as a list of lists containing all of the data :return: list of dicts containing all tabular data
[ "Read", "the", "data", "contained", "in", "all", "entries", "as", "a", "list", "of", "lists", "containing", "all", "of", "the", "data" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L217-L229
train
Read the data contained in all entries as a list of dicts containing all of the data
slightlynybbled/tk_tools
tk_tools/groups.py
ButtonGrid.add_row
def add_row(self, data: list): """ Add a row of buttons each with their own callbacks to the current widget. Each element in `data` will consist of a label and a command. :param data: a list of tuples of the form ('label', <callback>) :return: None """ #...
python
def add_row(self, data: list): """ Add a row of buttons each with their own callbacks to the current widget. Each element in `data` will consist of a label and a command. :param data: a list of tuples of the form ('label', <callback>) :return: None """ #...
[ "def", "add_row", "(", "self", ",", "data", ":", "list", ")", ":", "# validation", "if", "self", ".", "headers", "and", "data", ":", "if", "len", "(", "self", ".", "headers", ")", "!=", "len", "(", "data", ")", ":", "raise", "ValueError", "offset", ...
Add a row of buttons each with their own callbacks to the current widget. Each element in `data` will consist of a label and a command. :param data: a list of tuples of the form ('label', <callback>) :return: None
[ "Add", "a", "row", "of", "buttons", "each", "with", "their", "own", "callbacks", "to", "the", "current", "widget", ".", "Each", "element", "in", "data", "will", "consist", "of", "a", "label", "and", "a", "command", ".", ":", "param", "data", ":", "a", ...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L256-L287
train
Adds a row of buttons each with their own callbacks to the current widget.
slightlynybbled/tk_tools
tk_tools/groups.py
KeyValueEntry.add_row
def add_row(self, key: str, default: str=None, unit_label: str=None, enable: bool=None): """ Add a single row and re-draw as necessary :param key: the name and dict accessor :param default: the default value :param unit_label: the label that should be \ a...
python
def add_row(self, key: str, default: str=None, unit_label: str=None, enable: bool=None): """ Add a single row and re-draw as necessary :param key: the name and dict accessor :param default: the default value :param unit_label: the label that should be \ a...
[ "def", "add_row", "(", "self", ",", "key", ":", "str", ",", "default", ":", "str", "=", "None", ",", "unit_label", ":", "str", "=", "None", ",", "enable", ":", "bool", "=", "None", ")", ":", "self", ".", "keys", ".", "append", "(", "ttk", ".", ...
Add a single row and re-draw as necessary :param key: the name and dict accessor :param default: the default value :param unit_label: the label that should be \ applied at the right of the entry :param enable: the 'enabled' state (defaults to True) :return:
[ "Add", "a", "single", "row", "and", "re", "-", "draw", "as", "necessary" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L346-L399
train
Adds a row to the list and re - draw as necessary.
slightlynybbled/tk_tools
tk_tools/groups.py
KeyValueEntry.reset
def reset(self): """ Clears all entries. :return: None """ for i in range(len(self.values)): self.values[i].delete(0, tk.END) if self.defaults[i] is not None: self.values[i].insert(0, self.defaults[i])
python
def reset(self): """ Clears all entries. :return: None """ for i in range(len(self.values)): self.values[i].delete(0, tk.END) if self.defaults[i] is not None: self.values[i].insert(0, self.defaults[i])
[ "def", "reset", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "values", ")", ")", ":", "self", ".", "values", "[", "i", "]", ".", "delete", "(", "0", ",", "tk", ".", "END", ")", "if", "self", ".", "defaults",...
Clears all entries. :return: None
[ "Clears", "all", "entries", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L401-L411
train
Resets all entries in the list to their default values.
slightlynybbled/tk_tools
tk_tools/groups.py
KeyValueEntry.change_enables
def change_enables(self, enables_list: list): """ Enable/disable inputs. :param enables_list: list containing enables for each key :return: None """ for i, entry in enumerate(self.values): if enables_list[i]: entry.config(state=tk.NORMAL) ...
python
def change_enables(self, enables_list: list): """ Enable/disable inputs. :param enables_list: list containing enables for each key :return: None """ for i, entry in enumerate(self.values): if enables_list[i]: entry.config(state=tk.NORMAL) ...
[ "def", "change_enables", "(", "self", ",", "enables_list", ":", "list", ")", ":", "for", "i", ",", "entry", "in", "enumerate", "(", "self", ".", "values", ")", ":", "if", "enables_list", "[", "i", "]", ":", "entry", ".", "config", "(", "state", "=", ...
Enable/disable inputs. :param enables_list: list containing enables for each key :return: None
[ "Enable", "/", "disable", "inputs", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L413-L424
train
Change the enable states of all key - related items in the archive.
slightlynybbled/tk_tools
tk_tools/groups.py
KeyValueEntry.load
def load(self, data: dict): """ Load values into the key/values via dict. :param data: dict containing the key/values that should be inserted :return: None """ for i, label in enumerate(self.keys): key = label.cget('text') if key in data.keys(): ...
python
def load(self, data: dict): """ Load values into the key/values via dict. :param data: dict containing the key/values that should be inserted :return: None """ for i, label in enumerate(self.keys): key = label.cget('text') if key in data.keys(): ...
[ "def", "load", "(", "self", ",", "data", ":", "dict", ")", ":", "for", "i", ",", "label", "in", "enumerate", "(", "self", ".", "keys", ")", ":", "key", "=", "label", ".", "cget", "(", "'text'", ")", "if", "key", "in", "data", ".", "keys", "(", ...
Load values into the key/values via dict. :param data: dict containing the key/values that should be inserted :return: None
[ "Load", "values", "into", "the", "key", "/", "values", "via", "dict", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L426-L445
train
Load values into the key - value store via dict.
slightlynybbled/tk_tools
tk_tools/groups.py
KeyValueEntry.get
def get(self): """ Retrieve the GUI elements for program use. :return: a dictionary containing all \ of the data from the key/value entries """ data = dict() for label, entry in zip(self.keys, self.values): data[label.cget('text')] = entry.get() ...
python
def get(self): """ Retrieve the GUI elements for program use. :return: a dictionary containing all \ of the data from the key/value entries """ data = dict() for label, entry in zip(self.keys, self.values): data[label.cget('text')] = entry.get() ...
[ "def", "get", "(", "self", ")", ":", "data", "=", "dict", "(", ")", "for", "label", ",", "entry", "in", "zip", "(", "self", ".", "keys", ",", "self", ".", "values", ")", ":", "data", "[", "label", ".", "cget", "(", "'text'", ")", "]", "=", "e...
Retrieve the GUI elements for program use. :return: a dictionary containing all \ of the data from the key/value entries
[ "Retrieve", "the", "GUI", "elements", "for", "program", "use", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L447-L458
train
Retrieve the GUI elements for program use.
slightlynybbled/tk_tools
tk_tools/groups.py
Calendar._pressed
def _pressed(self, evt): """ Clicked somewhere in the calendar. """ x, y, widget = evt.x, evt.y, evt.widget item = widget.identify_row(y) column = widget.identify_column(x) if not column or not (item in self._items): # clicked in the weekdays row or j...
python
def _pressed(self, evt): """ Clicked somewhere in the calendar. """ x, y, widget = evt.x, evt.y, evt.widget item = widget.identify_row(y) column = widget.identify_column(x) if not column or not (item in self._items): # clicked in the weekdays row or j...
[ "def", "_pressed", "(", "self", ",", "evt", ")", ":", "x", ",", "y", ",", "widget", "=", "evt", ".", "x", ",", "evt", ".", "y", ",", "evt", ".", "widget", "item", "=", "widget", ".", "identify_row", "(", "y", ")", "column", "=", "widget", ".", ...
Clicked somewhere in the calendar.
[ "Clicked", "somewhere", "in", "the", "calendar", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L636-L666
train
Called when the calendar is clicked.
slightlynybbled/tk_tools
tk_tools/groups.py
_SlotFrame.add
def add(self, string: (str, list)): """ Clear the contents of the entry field and insert the contents of string. :param string: an str containing the text to display :return: """ if len(self._entries) == 1: self._entries[0].delete(0, 'end') ...
python
def add(self, string: (str, list)): """ Clear the contents of the entry field and insert the contents of string. :param string: an str containing the text to display :return: """ if len(self._entries) == 1: self._entries[0].delete(0, 'end') ...
[ "def", "add", "(", "self", ",", "string", ":", "(", "str", ",", "list", ")", ")", ":", "if", "len", "(", "self", ".", "_entries", ")", "==", "1", ":", "self", ".", "_entries", "[", "0", "]", ".", "delete", "(", "0", ",", "'end'", ")", "self",...
Clear the contents of the entry field and insert the contents of string. :param string: an str containing the text to display :return:
[ "Clear", "the", "contents", "of", "the", "entry", "field", "and", "insert", "the", "contents", "of", "string", "." ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L736-L754
train
Adds the contents of string to the entry field and clears the contents of the entry field and inserts the contents of string.
slightlynybbled/tk_tools
tk_tools/groups.py
_SlotFrame.remove
def remove(self): """ Deletes itself. :return: None """ for e in self._entries: e.grid_forget() e.destroy() self._remove_btn.grid_forget() self._remove_btn.destroy() self.deleted = True if self._remove_callback: ...
python
def remove(self): """ Deletes itself. :return: None """ for e in self._entries: e.grid_forget() e.destroy() self._remove_btn.grid_forget() self._remove_btn.destroy() self.deleted = True if self._remove_callback: ...
[ "def", "remove", "(", "self", ")", ":", "for", "e", "in", "self", ".", "_entries", ":", "e", ".", "grid_forget", "(", ")", "e", ".", "destroy", "(", ")", "self", ".", "_remove_btn", ".", "grid_forget", "(", ")", "self", ".", "_remove_btn", ".", "de...
Deletes itself. :return: None
[ "Deletes", "itself", ".", ":", "return", ":", "None" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L756-L771
train
Deletes itself.
slightlynybbled/tk_tools
tk_tools/groups.py
_SlotFrame.get
def get(self): """ Returns the value for the slot. :return: the entry value """ values = [e.get() for e in self._entries] if len(self._entries) == 1: return values[0] else: return values
python
def get(self): """ Returns the value for the slot. :return: the entry value """ values = [e.get() for e in self._entries] if len(self._entries) == 1: return values[0] else: return values
[ "def", "get", "(", "self", ")", ":", "values", "=", "[", "e", ".", "get", "(", ")", "for", "e", "in", "self", ".", "_entries", "]", "if", "len", "(", "self", ".", "_entries", ")", "==", "1", ":", "return", "values", "[", "0", "]", "else", ":"...
Returns the value for the slot. :return: the entry value
[ "Returns", "the", "value", "for", "the", "slot", ".", ":", "return", ":", "the", "entry", "value" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L773-L782
train
Returns the value for the slot.
slightlynybbled/tk_tools
tk_tools/groups.py
MultiSlotFrame._redraw
def _redraw(self): """ Clears the current layout and re-draws all elements in self._slots :return: """ if self._blank_label: self._blank_label.grid_forget() self._blank_label.destroy() self._blank_label = None for slot in self._slots: ...
python
def _redraw(self): """ Clears the current layout and re-draws all elements in self._slots :return: """ if self._blank_label: self._blank_label.grid_forget() self._blank_label.destroy() self._blank_label = None for slot in self._slots: ...
[ "def", "_redraw", "(", "self", ")", ":", "if", "self", ".", "_blank_label", ":", "self", ".", "_blank_label", ".", "grid_forget", "(", ")", "self", ".", "_blank_label", ".", "destroy", "(", ")", "self", ".", "_blank_label", "=", "None", "for", "slot", ...
Clears the current layout and re-draws all elements in self._slots :return:
[ "Clears", "the", "current", "layout", "and", "re", "-", "draws", "all", "elements", "in", "self", ".", "_slots", ":", "return", ":" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L820-L838
train
Clears the current layout and re - draw all elements in self. _slots
slightlynybbled/tk_tools
tk_tools/groups.py
MultiSlotFrame.add
def add(self, string: (str, list)): """ Add a new slot to the multi-frame containing the string. :param string: a string to insert :return: None """ slot = _SlotFrame(self, remove_callback=self._redraw, entries=self._slo...
python
def add(self, string: (str, list)): """ Add a new slot to the multi-frame containing the string. :param string: a string to insert :return: None """ slot = _SlotFrame(self, remove_callback=self._redraw, entries=self._slo...
[ "def", "add", "(", "self", ",", "string", ":", "(", "str", ",", "list", ")", ")", ":", "slot", "=", "_SlotFrame", "(", "self", ",", "remove_callback", "=", "self", ".", "_redraw", ",", "entries", "=", "self", ".", "_slot_columns", ")", "slot", ".", ...
Add a new slot to the multi-frame containing the string. :param string: a string to insert :return: None
[ "Add", "a", "new", "slot", "to", "the", "multi", "-", "frame", "containing", "the", "string", ".", ":", "param", "string", ":", "a", "string", "to", "insert", ":", "return", ":", "None" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L840-L853
train
Adds a new slot to the multi - frame containing the string.
slightlynybbled/tk_tools
tk_tools/groups.py
MultiSlotFrame.clear
def clear(self): """ Clear out the multi-frame :return: """ for slot in self._slots: slot.grid_forget() slot.destroy() self._slots = []
python
def clear(self): """ Clear out the multi-frame :return: """ for slot in self._slots: slot.grid_forget() slot.destroy() self._slots = []
[ "def", "clear", "(", "self", ")", ":", "for", "slot", "in", "self", ".", "_slots", ":", "slot", ".", "grid_forget", "(", ")", "slot", ".", "destroy", "(", ")", "self", ".", "_slots", "=", "[", "]" ]
Clear out the multi-frame :return:
[ "Clear", "out", "the", "multi", "-", "frame", ":", "return", ":" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L855-L864
train
Clear out the multi - frame cache.
slightlynybbled/tk_tools
tk_tools/groups.py
SevenSegment.clear
def clear(self): """ Clear the segment. :return: None """ for _, frame in self._segments.items(): frame.configure(background=self._bg_color)
python
def clear(self): """ Clear the segment. :return: None """ for _, frame in self._segments.items(): frame.configure(background=self._bg_color)
[ "def", "clear", "(", "self", ")", ":", "for", "_", ",", "frame", "in", "self", ".", "_segments", ".", "items", "(", ")", ":", "frame", ".", "configure", "(", "background", "=", "self", ".", "_bg_color", ")" ]
Clear the segment. :return: None
[ "Clear", "the", "segment", ".", ":", "return", ":", "None" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L944-L950
train
Clear the current color of all the active frames.
slightlynybbled/tk_tools
tk_tools/groups.py
SevenSegment.set_value
def set_value(self, value: str): """ Sets the value of the 7-segment display :param value: the desired value :return: None """ self.clear() if '.' in value: self._segments['period'].configure(background=self._color) if value in ['0', '0.']: ...
python
def set_value(self, value: str): """ Sets the value of the 7-segment display :param value: the desired value :return: None """ self.clear() if '.' in value: self._segments['period'].configure(background=self._color) if value in ['0', '0.']: ...
[ "def", "set_value", "(", "self", ",", "value", ":", "str", ")", ":", "self", ".", "clear", "(", ")", "if", "'.'", "in", "value", ":", "self", ".", "_segments", "[", "'period'", "]", ".", "configure", "(", "background", "=", "self", ".", "_color", "...
Sets the value of the 7-segment display :param value: the desired value :return: None
[ "Sets", "the", "value", "of", "the", "7", "-", "segment", "display", ":", "param", "value", ":", "the", "desired", "value", ":", "return", ":", "None" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L952-L1025
train
Sets the value of the 7 - segment display.
slightlynybbled/tk_tools
tk_tools/groups.py
SevenSegmentDigits._group
def _group(self, value: str): """ Takes a string and groups it appropriately with any period or other appropriate punctuation so that it is displayed correctly. :param value: a string containing an integer or float :return: None """ reversed_v = value[::-1...
python
def _group(self, value: str): """ Takes a string and groups it appropriately with any period or other appropriate punctuation so that it is displayed correctly. :param value: a string containing an integer or float :return: None """ reversed_v = value[::-1...
[ "def", "_group", "(", "self", ",", "value", ":", "str", ")", ":", "reversed_v", "=", "value", "[", ":", ":", "-", "1", "]", "parts", "=", "[", "]", "has_period", "=", "False", "for", "c", "in", "reversed_v", ":", "if", "has_period", ":", "parts", ...
Takes a string and groups it appropriately with any period or other appropriate punctuation so that it is displayed correctly. :param value: a string containing an integer or float :return: None
[ "Takes", "a", "string", "and", "groups", "it", "appropriately", "with", "any", "period", "or", "other", "appropriate", "punctuation", "so", "that", "it", "is", "displayed", "correctly", ".", ":", "param", "value", ":", "a", "string", "containing", "an", "int...
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L1066-L1090
train
Takes a string and groups it appropriately with any appropriate punctuation so that it is a log entry.
slightlynybbled/tk_tools
tk_tools/groups.py
SevenSegmentDigits.set_value
def set_value(self, value: str): """ Sets the displayed digits based on the value string. :param value: a string containing an integer or float value :return: None """ [digit.clear() for digit in self._digits] grouped = self._group(value) # return the parts, rev...
python
def set_value(self, value: str): """ Sets the displayed digits based on the value string. :param value: a string containing an integer or float value :return: None """ [digit.clear() for digit in self._digits] grouped = self._group(value) # return the parts, rev...
[ "def", "set_value", "(", "self", ",", "value", ":", "str", ")", ":", "[", "digit", ".", "clear", "(", ")", "for", "digit", "in", "self", ".", "_digits", "]", "grouped", "=", "self", ".", "_group", "(", "value", ")", "# return the parts, reversed", "dig...
Sets the displayed digits based on the value string. :param value: a string containing an integer or float value :return: None
[ "Sets", "the", "displayed", "digits", "based", "on", "the", "value", "string", ".", ":", "param", "value", ":", "a", "string", "containing", "an", "integer", "or", "float", "value", ":", "return", ":", "None" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/groups.py#L1092-L1118
train
Sets the displayed digits based on the value string.
slightlynybbled/tk_tools
tk_tools/widgets.py
SmartWidget.add_callback
def add_callback(self, callback: callable): """ Add a callback on change :param callback: callable function :return: None """ def internal_callback(*args): try: callback() except TypeError: callback(self.get()) ...
python
def add_callback(self, callback: callable): """ Add a callback on change :param callback: callable function :return: None """ def internal_callback(*args): try: callback() except TypeError: callback(self.get()) ...
[ "def", "add_callback", "(", "self", ",", "callback", ":", "callable", ")", ":", "def", "internal_callback", "(", "*", "args", ")", ":", "try", ":", "callback", "(", ")", "except", "TypeError", ":", "callback", "(", "self", ".", "get", "(", ")", ")", ...
Add a callback on change :param callback: callable function :return: None
[ "Add", "a", "callback", "on", "change" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/widgets.py#L18-L31
train
Add a callback on change
slightlynybbled/tk_tools
tk_tools/widgets.py
BinaryLabel.set
def set(self, value: int): """ Set the current value :param value: :return: None """ max_value = int(''.join(['1' for _ in range(self._bit_width)]), 2) if value > max_value: raise ValueError('the value {} is larger than ' ...
python
def set(self, value: int): """ Set the current value :param value: :return: None """ max_value = int(''.join(['1' for _ in range(self._bit_width)]), 2) if value > max_value: raise ValueError('the value {} is larger than ' ...
[ "def", "set", "(", "self", ",", "value", ":", "int", ")", ":", "max_value", "=", "int", "(", "''", ".", "join", "(", "[", "'1'", "for", "_", "in", "range", "(", "self", ".", "_bit_width", ")", "]", ")", ",", "2", ")", "if", "value", ">", "max...
Set the current value :param value: :return: None
[ "Set", "the", "current", "value" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/widgets.py#L217-L231
train
Set the current value of the current locale.
slightlynybbled/tk_tools
tk_tools/widgets.py
BinaryLabel.get_bit
def get_bit(self, position: int): """ Returns the bit value at position :param position: integer between 0 and <width>, inclusive :return: the value at position as a integer """ if position > (self._bit_width - 1): raise ValueError('position greater than the...
python
def get_bit(self, position: int): """ Returns the bit value at position :param position: integer between 0 and <width>, inclusive :return: the value at position as a integer """ if position > (self._bit_width - 1): raise ValueError('position greater than the...
[ "def", "get_bit", "(", "self", ",", "position", ":", "int", ")", ":", "if", "position", ">", "(", "self", ".", "_bit_width", "-", "1", ")", ":", "raise", "ValueError", "(", "'position greater than the bit width'", ")", "if", "self", ".", "_value", "&", "...
Returns the bit value at position :param position: integer between 0 and <width>, inclusive :return: the value at position as a integer
[ "Returns", "the", "bit", "value", "at", "position" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/widgets.py#L238-L252
train
Returns the bit value at the specified position
slightlynybbled/tk_tools
tk_tools/widgets.py
BinaryLabel.toggle_bit
def toggle_bit(self, position: int): """ Toggles the value at position :param position: integer between 0 and 7, inclusive :return: None """ if position > (self._bit_width - 1): raise ValueError('position greater than the bit width') self._value ^= (...
python
def toggle_bit(self, position: int): """ Toggles the value at position :param position: integer between 0 and 7, inclusive :return: None """ if position > (self._bit_width - 1): raise ValueError('position greater than the bit width') self._value ^= (...
[ "def", "toggle_bit", "(", "self", ",", "position", ":", "int", ")", ":", "if", "position", ">", "(", "self", ".", "_bit_width", "-", "1", ")", ":", "raise", "ValueError", "(", "'position greater than the bit width'", ")", "self", ".", "_value", "^=", "(", ...
Toggles the value at position :param position: integer between 0 and 7, inclusive :return: None
[ "Toggles", "the", "value", "at", "position" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/widgets.py#L254-L265
train
Toggles the value at position
slightlynybbled/tk_tools
tk_tools/widgets.py
BinaryLabel.set_bit
def set_bit(self, position: int): """ Sets the value at position :param position: integer between 0 and 7, inclusive :return: None """ if position > (self._bit_width - 1): raise ValueError('position greater than the bit width') self._value |= (1 << p...
python
def set_bit(self, position: int): """ Sets the value at position :param position: integer between 0 and 7, inclusive :return: None """ if position > (self._bit_width - 1): raise ValueError('position greater than the bit width') self._value |= (1 << p...
[ "def", "set_bit", "(", "self", ",", "position", ":", "int", ")", ":", "if", "position", ">", "(", "self", ".", "_bit_width", "-", "1", ")", ":", "raise", "ValueError", "(", "'position greater than the bit width'", ")", "self", ".", "_value", "|=", "(", "...
Sets the value at position :param position: integer between 0 and 7, inclusive :return: None
[ "Sets", "the", "value", "at", "position" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/widgets.py#L267-L278
train
Sets the value at the specified position in the bit string.
slightlynybbled/tk_tools
tk_tools/widgets.py
BinaryLabel.clear_bit
def clear_bit(self, position: int): """ Clears the value at position :param position: integer between 0 and 7, inclusive :return: None """ if position > (self._bit_width - 1): raise ValueError('position greater than the bit width') self._value &= ~(1...
python
def clear_bit(self, position: int): """ Clears the value at position :param position: integer between 0 and 7, inclusive :return: None """ if position > (self._bit_width - 1): raise ValueError('position greater than the bit width') self._value &= ~(1...
[ "def", "clear_bit", "(", "self", ",", "position", ":", "int", ")", ":", "if", "position", ">", "(", "self", ".", "_bit_width", "-", "1", ")", ":", "raise", "ValueError", "(", "'position greater than the bit width'", ")", "self", ".", "_value", "&=", "~", ...
Clears the value at position :param position: integer between 0 and 7, inclusive :return: None
[ "Clears", "the", "value", "at", "position" ]
7c1792cad42890251a34f0617ce9b4b3e7abcf50
https://github.com/slightlynybbled/tk_tools/blob/7c1792cad42890251a34f0617ce9b4b3e7abcf50/tk_tools/widgets.py#L280-L291
train
Clears the bit at the specified position.
willhardy/django-seo
rollyourown/seo/utils.py
LazyList._populate
def _populate(self): """ Populate this list by calling populate(), but only once. """ if not self._populated: logging.debug("Populating lazy list %d (%s)" % (id(self), self.__class__.__name__)) try: self.populate() self._populated = True ...
python
def _populate(self): """ Populate this list by calling populate(), but only once. """ if not self._populated: logging.debug("Populating lazy list %d (%s)" % (id(self), self.__class__.__name__)) try: self.populate() self._populated = True ...
[ "def", "_populate", "(", "self", ")", ":", "if", "not", "self", ".", "_populated", ":", "logging", ".", "debug", "(", "\"Populating lazy list %d (%s)\"", "%", "(", "id", "(", "self", ")", ",", "self", ".", "__class__", ".", "__name__", ")", ")", "try", ...
Populate this list by calling populate(), but only once.
[ "Populate", "this", "list", "by", "calling", "populate", "()", "but", "only", "once", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/utils.py#L43-L51
train
Populate this list by calling populate but only once.
willhardy/django-seo
rollyourown/seo/admin.py
_register_admin
def _register_admin(admin_site, model, admin_class): """ Register model in the admin, ignoring any previously registered models. Alternatively it could be used in the future to replace a previously registered model. """ try: admin_site.register(model, admin_class) except admin.s...
python
def _register_admin(admin_site, model, admin_class): """ Register model in the admin, ignoring any previously registered models. Alternatively it could be used in the future to replace a previously registered model. """ try: admin_site.register(model, admin_class) except admin.s...
[ "def", "_register_admin", "(", "admin_site", ",", "model", ",", "admin_class", ")", ":", "try", ":", "admin_site", ".", "register", "(", "model", ",", "admin_class", ")", "except", "admin", ".", "sites", ".", "AlreadyRegistered", ":", "pass" ]
Register model in the admin, ignoring any previously registered models. Alternatively it could be used in the future to replace a previously registered model.
[ "Register", "model", "in", "the", "admin", "ignoring", "any", "previously", "registered", "models", ".", "Alternatively", "it", "could", "be", "used", "in", "the", "future", "to", "replace", "a", "previously", "registered", "model", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/admin.py#L81-L89
train
Register model in the admin.
willhardy/django-seo
rollyourown/seo/admin.py
core_choice_fields
def core_choice_fields(metadata_class): """ If the 'optional' core fields (_site and _language) are required, list them here. """ fields = [] if metadata_class._meta.use_sites: fields.append('_site') if metadata_class._meta.use_i18n: fields.append('_language') return fi...
python
def core_choice_fields(metadata_class): """ If the 'optional' core fields (_site and _language) are required, list them here. """ fields = [] if metadata_class._meta.use_sites: fields.append('_site') if metadata_class._meta.use_i18n: fields.append('_language') return fi...
[ "def", "core_choice_fields", "(", "metadata_class", ")", ":", "fields", "=", "[", "]", "if", "metadata_class", ".", "_meta", ".", "use_sites", ":", "fields", ".", "append", "(", "'_site'", ")", "if", "metadata_class", ".", "_meta", ".", "use_i18n", ":", "f...
If the 'optional' core fields (_site and _language) are required, list them here.
[ "If", "the", "optional", "core", "fields", "(", "_site", "and", "_language", ")", "are", "required", "list", "them", "here", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/admin.py#L187-L196
train
Return a list of core choice fields.
willhardy/django-seo
rollyourown/seo/admin.py
_monkey_inline
def _monkey_inline(model, admin_class_instance, metadata_class, inline_class, admin_site): """ Monkey patch the inline onto the given admin_class instance. """ if model in metadata_class._meta.seo_models: # *Not* adding to the class attribute "inlines", as this will affect # all instances from t...
python
def _monkey_inline(model, admin_class_instance, metadata_class, inline_class, admin_site): """ Monkey patch the inline onto the given admin_class instance. """ if model in metadata_class._meta.seo_models: # *Not* adding to the class attribute "inlines", as this will affect # all instances from t...
[ "def", "_monkey_inline", "(", "model", ",", "admin_class_instance", ",", "metadata_class", ",", "inline_class", ",", "admin_site", ")", ":", "if", "model", "in", "metadata_class", ".", "_meta", ".", "seo_models", ":", "# *Not* adding to the class attribute \"inlines\", ...
Monkey patch the inline onto the given admin_class instance.
[ "Monkey", "patch", "the", "inline", "onto", "the", "given", "admin_class", "instance", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/admin.py#L199-L209
train
Monkey patch the inline onto the given admin_class instance.
willhardy/django-seo
rollyourown/seo/admin.py
_with_inline
def _with_inline(func, admin_site, metadata_class, inline_class): """ Decorator for register function that adds an appropriate inline.""" def register(model_or_iterable, admin_class=None, **options): # Call the (bound) function we were given. # We have to assume it will be bound to admin_sit...
python
def _with_inline(func, admin_site, metadata_class, inline_class): """ Decorator for register function that adds an appropriate inline.""" def register(model_or_iterable, admin_class=None, **options): # Call the (bound) function we were given. # We have to assume it will be bound to admin_sit...
[ "def", "_with_inline", "(", "func", ",", "admin_site", ",", "metadata_class", ",", "inline_class", ")", ":", "def", "register", "(", "model_or_iterable", ",", "admin_class", "=", "None", ",", "*", "*", "options", ")", ":", "# Call the (bound) function we were give...
Decorator for register function that adds an appropriate inline.
[ "Decorator", "for", "register", "function", "that", "adds", "an", "appropriate", "inline", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/admin.py#L211-L220
train
Decorator for register function that adds an appropriate inline.
willhardy/django-seo
rollyourown/seo/admin.py
auto_register_inlines
def auto_register_inlines(admin_site, metadata_class): """ This is a questionable function that automatically adds our metadata inline to all relevant models in the site. """ inline_class = get_inline(metadata_class) for model, admin_class_instance in admin_site._registry.items(): _mon...
python
def auto_register_inlines(admin_site, metadata_class): """ This is a questionable function that automatically adds our metadata inline to all relevant models in the site. """ inline_class = get_inline(metadata_class) for model, admin_class_instance in admin_site._registry.items(): _mon...
[ "def", "auto_register_inlines", "(", "admin_site", ",", "metadata_class", ")", ":", "inline_class", "=", "get_inline", "(", "metadata_class", ")", "for", "model", ",", "admin_class_instance", "in", "admin_site", ".", "_registry", ".", "items", "(", ")", ":", "_m...
This is a questionable function that automatically adds our metadata inline to all relevant models in the site.
[ "This", "is", "a", "questionable", "function", "that", "automatically", "adds", "our", "metadata", "inline", "to", "all", "relevant", "models", "in", "the", "site", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/admin.py#L222-L234
train
This is a questionable function that automatically adds our metadata inline to all relevant models in the site.
willhardy/django-seo
rollyourown/seo/base.py
get_linked_metadata
def get_linked_metadata(obj, name=None, context=None, site=None, language=None): """ Gets metadata linked from the given object. """ # XXX Check that 'modelinstance' and 'model' metadata are installed in backends # I believe that get_model() would return None if not Metadata = _get_metadata_model(name) ...
python
def get_linked_metadata(obj, name=None, context=None, site=None, language=None): """ Gets metadata linked from the given object. """ # XXX Check that 'modelinstance' and 'model' metadata are installed in backends # I believe that get_model() would return None if not Metadata = _get_metadata_model(name) ...
[ "def", "get_linked_metadata", "(", "obj", ",", "name", "=", "None", ",", "context", "=", "None", ",", "site", "=", "None", ",", "language", "=", "None", ")", ":", "# XXX Check that 'modelinstance' and 'model' metadata are installed in backends", "# I believe that get_mo...
Gets metadata linked from the given object.
[ "Gets", "metadata", "linked", "from", "the", "given", "object", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/base.py#L262-L283
train
Gets the metadata linked to the given object.
willhardy/django-seo
rollyourown/seo/base.py
populate_metadata
def populate_metadata(model, MetadataClass): """ For a given model and metadata class, ensure there is metadata for every instance. """ content_type = ContentType.objects.get_for_model(model) for instance in model.objects.all(): create_metadata_instance(MetadataClass, instance)
python
def populate_metadata(model, MetadataClass): """ For a given model and metadata class, ensure there is metadata for every instance. """ content_type = ContentType.objects.get_for_model(model) for instance in model.objects.all(): create_metadata_instance(MetadataClass, instance)
[ "def", "populate_metadata", "(", "model", ",", "MetadataClass", ")", ":", "content_type", "=", "ContentType", ".", "objects", ".", "get_for_model", "(", "model", ")", "for", "instance", "in", "model", ".", "objects", ".", "all", "(", ")", ":", "create_metada...
For a given model and metadata class, ensure there is metadata for every instance.
[ "For", "a", "given", "model", "and", "metadata", "class", "ensure", "there", "is", "metadata", "for", "every", "instance", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/base.py#L326-L331
train
Populates the metadata class with the metadata for every object in the given model.
willhardy/django-seo
rollyourown/seo/base.py
FormattedMetadata.__instances
def __instances(self): """ Cache instances, allowing generators to be used and reused. This fills a cache as the generator gets emptied, eventually reading exclusively from the cache. """ for instance in self.__instances_cache: yield instance for inst...
python
def __instances(self): """ Cache instances, allowing generators to be used and reused. This fills a cache as the generator gets emptied, eventually reading exclusively from the cache. """ for instance in self.__instances_cache: yield instance for inst...
[ "def", "__instances", "(", "self", ")", ":", "for", "instance", "in", "self", ".", "__instances_cache", ":", "yield", "instance", "for", "instance", "in", "self", ".", "__instances_original", ":", "self", ".", "__instances_cache", ".", "append", "(", "instance...
Cache instances, allowing generators to be used and reused. This fills a cache as the generator gets emptied, eventually reading exclusively from the cache.
[ "Cache", "instances", "allowing", "generators", "to", "be", "used", "and", "reused", ".", "This", "fills", "a", "cache", "as", "the", "generator", "gets", "emptied", "eventually", "reading", "exclusively", "from", "the", "cache", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/base.py#L50-L59
train
Yields all the instances in the cache.
willhardy/django-seo
rollyourown/seo/base.py
FormattedMetadata._resolve_value
def _resolve_value(self, name): """ Returns an appropriate value for the given name. This simply asks each of the instances for a value. """ for instance in self.__instances(): value = instance._resolve_value(name) if value: return value ...
python
def _resolve_value(self, name): """ Returns an appropriate value for the given name. This simply asks each of the instances for a value. """ for instance in self.__instances(): value = instance._resolve_value(name) if value: return value ...
[ "def", "_resolve_value", "(", "self", ",", "name", ")", ":", "for", "instance", "in", "self", ".", "__instances", "(", ")", ":", "value", "=", "instance", ".", "_resolve_value", "(", "name", ")", "if", "value", ":", "return", "value", "# Otherwise, return ...
Returns an appropriate value for the given name. This simply asks each of the instances for a value.
[ "Returns", "an", "appropriate", "value", "for", "the", "given", "name", ".", "This", "simply", "asks", "each", "of", "the", "instances", "for", "a", "value", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/base.py#L61-L79
train
Resolves the value for the given name.
willhardy/django-seo
rollyourown/seo/base.py
MetadataBase._get_formatted_data
def _get_formatted_data(cls, path, context=None, site=None, language=None): """ Return an object to conveniently access the appropriate values. """ return FormattedMetadata(cls(), cls._get_instances(path, context, site, language), path, site, language)
python
def _get_formatted_data(cls, path, context=None, site=None, language=None): """ Return an object to conveniently access the appropriate values. """ return FormattedMetadata(cls(), cls._get_instances(path, context, site, language), path, site, language)
[ "def", "_get_formatted_data", "(", "cls", ",", "path", ",", "context", "=", "None", ",", "site", "=", "None", ",", "language", "=", "None", ")", ":", "return", "FormattedMetadata", "(", "cls", "(", ")", ",", "cls", ".", "_get_instances", "(", "path", "...
Return an object to conveniently access the appropriate values.
[ "Return", "an", "object", "to", "conveniently", "access", "the", "appropriate", "values", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/base.py#L217-L219
train
Return an object to conveniently access the appropriate values.
willhardy/django-seo
rollyourown/seo/base.py
MetadataBase._get_instances
def _get_instances(cls, path, context=None, site=None, language=None): """ A sequence of instances to discover metadata. Each instance from each backend is looked up when possible/necessary. This is a generator to eliminate unnecessary queries. """ backend_context = {'vi...
python
def _get_instances(cls, path, context=None, site=None, language=None): """ A sequence of instances to discover metadata. Each instance from each backend is looked up when possible/necessary. This is a generator to eliminate unnecessary queries. """ backend_context = {'vi...
[ "def", "_get_instances", "(", "cls", ",", "path", ",", "context", "=", "None", ",", "site", "=", "None", ",", "language", "=", "None", ")", ":", "backend_context", "=", "{", "'view_context'", ":", "context", "}", "for", "model", "in", "cls", ".", "_met...
A sequence of instances to discover metadata. Each instance from each backend is looked up when possible/necessary. This is a generator to eliminate unnecessary queries.
[ "A", "sequence", "of", "instances", "to", "discover", "metadata", ".", "Each", "instance", "from", "each", "backend", "is", "looked", "up", "when", "possible", "/", "necessary", ".", "This", "is", "a", "generator", "to", "eliminate", "unnecessary", "queries", ...
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/base.py#L223-L234
train
A generator that yields all instances from each backend that are available for the given path.
willhardy/django-seo
rollyourown/seo/backends.py
_resolve
def _resolve(value, model_instance=None, context=None): """ Resolves any template references in the given value. """ if isinstance(value, basestring) and "{" in value: if context is None: context = Context() if model_instance is not None: context[model_instance._met...
python
def _resolve(value, model_instance=None, context=None): """ Resolves any template references in the given value. """ if isinstance(value, basestring) and "{" in value: if context is None: context = Context() if model_instance is not None: context[model_instance._met...
[ "def", "_resolve", "(", "value", ",", "model_instance", "=", "None", ",", "context", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "basestring", ")", "and", "\"{\"", "in", "value", ":", "if", "context", "is", "None", ":", "context", "="...
Resolves any template references in the given value.
[ "Resolves", "any", "template", "references", "in", "the", "given", "value", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/backends.py#L331-L341
train
Resolves any template references in the given value.
willhardy/django-seo
rollyourown/seo/backends.py
ModelBackend.validate
def validate(options): """ Validates the application of this backend to a given metadata """ try: if options.backends.index('modelinstance') > options.backends.index('model'): raise Exception("Metadata backend 'modelinstance' must come before 'model' backend") ...
python
def validate(options): """ Validates the application of this backend to a given metadata """ try: if options.backends.index('modelinstance') > options.backends.index('model'): raise Exception("Metadata backend 'modelinstance' must come before 'model' backend") ...
[ "def", "validate", "(", "options", ")", ":", "try", ":", "if", "options", ".", "backends", ".", "index", "(", "'modelinstance'", ")", ">", "options", ".", "backends", ".", "index", "(", "'model'", ")", ":", "raise", "Exception", "(", "\"Metadata backend 'm...
Validates the application of this backend to a given metadata
[ "Validates", "the", "application", "of", "this", "backend", "to", "a", "given", "metadata" ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/backends.py#L320-L327
train
Validates the application of this backend to a given metadata
willhardy/django-seo
rollyourown/seo/options.py
Options._register_elements
def _register_elements(self, elements): """ Takes elements from the metadata class and creates a base model for all backend models . """ self.elements = elements for key, obj in elements.items(): obj.contribute_to_class(self.metadata, key) # Create the common Django...
python
def _register_elements(self, elements): """ Takes elements from the metadata class and creates a base model for all backend models . """ self.elements = elements for key, obj in elements.items(): obj.contribute_to_class(self.metadata, key) # Create the common Django...
[ "def", "_register_elements", "(", "self", ",", "elements", ")", ":", "self", ".", "elements", "=", "elements", "for", "key", ",", "obj", "in", "elements", ".", "items", "(", ")", ":", "obj", ".", "contribute_to_class", "(", "self", ".", "metadata", ",", ...
Takes elements from the metadata class and creates a base model for all backend models .
[ "Takes", "elements", "from", "the", "metadata", "class", "and", "creates", "a", "base", "model", "for", "all", "backend", "models", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/options.py#L38-L64
train
Takes elements from the metadata class and creates a base model for all backend models.
willhardy/django-seo
rollyourown/seo/options.py
Options._add_backend
def _add_backend(self, backend): """ Builds a subclass model for the given backend """ md_type = backend.verbose_name base = backend().get_model(self) # TODO: Rename this field new_md_attrs = {'_metadata': self.metadata, '__module__': __name__ } new_md_meta = {} ...
python
def _add_backend(self, backend): """ Builds a subclass model for the given backend """ md_type = backend.verbose_name base = backend().get_model(self) # TODO: Rename this field new_md_attrs = {'_metadata': self.metadata, '__module__': __name__ } new_md_meta = {} ...
[ "def", "_add_backend", "(", "self", ",", "backend", ")", ":", "md_type", "=", "backend", ".", "verbose_name", "base", "=", "backend", "(", ")", ".", "get_model", "(", "self", ")", "# TODO: Rename this field", "new_md_attrs", "=", "{", "'_metadata'", ":", "se...
Builds a subclass model for the given backend
[ "Builds", "a", "subclass", "model", "for", "the", "given", "backend" ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/options.py#L66-L82
train
Adds a backend to the metadata base model
willhardy/django-seo
rollyourown/seo/options.py
Options._set_seo_models
def _set_seo_models(self, value): """ Gets the actual models to be used. """ seo_models = [] for model_name in value: if "." in model_name: app_label, model_name = model_name.split(".", 1) model = models.get_model(app_label, model_name) ...
python
def _set_seo_models(self, value): """ Gets the actual models to be used. """ seo_models = [] for model_name in value: if "." in model_name: app_label, model_name = model_name.split(".", 1) model = models.get_model(app_label, model_name) ...
[ "def", "_set_seo_models", "(", "self", ",", "value", ")", ":", "seo_models", "=", "[", "]", "for", "model_name", "in", "value", ":", "if", "\".\"", "in", "model_name", ":", "app_label", ",", "model_name", "=", "model_name", ".", "split", "(", "\".\"", ",...
Gets the actual models to be used.
[ "Gets", "the", "actual", "models", "to", "be", "used", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/options.py#L84-L98
train
Sets the list of models to be used.
willhardy/django-seo
rollyourown/seo/fields.py
MetadataField.validate
def validate(self): """ Discover certain illegal configurations """ if not self.editable: assert self.populate_from is not NotSet, u"If field (%s) is not editable, you must set populate_from" % self.name
python
def validate(self): """ Discover certain illegal configurations """ if not self.editable: assert self.populate_from is not NotSet, u"If field (%s) is not editable, you must set populate_from" % self.name
[ "def", "validate", "(", "self", ")", ":", "if", "not", "self", ".", "editable", ":", "assert", "self", ".", "populate_from", "is", "not", "NotSet", ",", "u\"If field (%s) is not editable, you must set populate_from\"", "%", "self", ".", "name" ]
Discover certain illegal configurations
[ "Discover", "certain", "illegal", "configurations" ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/fields.py#L72-L75
train
Validate that the field is valid.
willhardy/django-seo
rollyourown/seo/management/__init__.py
populate_all_metadata
def populate_all_metadata(): """ Create metadata instances for all models in seo_models if empty. Once you have created a single metadata instance, this will not run. This is because it is a potentially slow operation that need only be done once. If you want to ensure that everything is popu...
python
def populate_all_metadata(): """ Create metadata instances for all models in seo_models if empty. Once you have created a single metadata instance, this will not run. This is because it is a potentially slow operation that need only be done once. If you want to ensure that everything is popu...
[ "def", "populate_all_metadata", "(", ")", ":", "for", "Metadata", "in", "registry", ".", "values", "(", ")", ":", "InstanceMetadata", "=", "Metadata", ".", "_meta", ".", "get_model", "(", "'modelinstance'", ")", "if", "InstanceMetadata", "is", "not", "None", ...
Create metadata instances for all models in seo_models if empty. Once you have created a single metadata instance, this will not run. This is because it is a potentially slow operation that need only be done once. If you want to ensure that everything is populated, run the populate_metad...
[ "Create", "metadata", "instances", "for", "all", "models", "in", "seo_models", "if", "empty", ".", "Once", "you", "have", "created", "a", "single", "metadata", "instance", "this", "will", "not", "run", ".", "This", "is", "because", "it", "is", "a", "potent...
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/management/__init__.py#L30-L41
train
Populate all metadata instances for all models in seo_models.
willhardy/django-seo
rollyourown/seo/systemviews.py
SystemViews.populate
def populate(self): """ Populate this list with all views that take no arguments. """ from django.conf import settings from django.core import urlresolvers self.append(("", "")) urlconf = settings.ROOT_URLCONF resolver = urlresolvers.RegexURLResolver(r'^/', urlco...
python
def populate(self): """ Populate this list with all views that take no arguments. """ from django.conf import settings from django.core import urlresolvers self.append(("", "")) urlconf = settings.ROOT_URLCONF resolver = urlresolvers.RegexURLResolver(r'^/', urlco...
[ "def", "populate", "(", "self", ")", ":", "from", "django", ".", "conf", "import", "settings", "from", "django", ".", "core", "import", "urlresolvers", "self", ".", "append", "(", "(", "\"\"", ",", "\"\"", ")", ")", "urlconf", "=", "settings", ".", "RO...
Populate this list with all views that take no arguments.
[ "Populate", "this", "list", "with", "all", "views", "that", "take", "no", "arguments", "." ]
3089686a3c490091315860979ad15ef2527c3e3e
https://github.com/willhardy/django-seo/blob/3089686a3c490091315860979ad15ef2527c3e3e/rollyourown/seo/systemviews.py#L43-L65
train
Populate this list with all views that take no arguments.
geomet/geomet
geomet/util.py
block_splitter
def block_splitter(data, block_size): """ Creates a generator by slicing ``data`` into chunks of ``block_size``. >>> data = range(10) >>> list(block_splitter(data, 2)) [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] If ``data`` cannot be evenly divided by ``block_size``, the last block will simpl...
python
def block_splitter(data, block_size): """ Creates a generator by slicing ``data`` into chunks of ``block_size``. >>> data = range(10) >>> list(block_splitter(data, 2)) [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] If ``data`` cannot be evenly divided by ``block_size``, the last block will simpl...
[ "def", "block_splitter", "(", "data", ",", "block_size", ")", ":", "buf", "=", "[", "]", "for", "i", ",", "datum", "in", "enumerate", "(", "data", ")", ":", "buf", ".", "append", "(", "datum", ")", "if", "len", "(", "buf", ")", "==", "block_size", ...
Creates a generator by slicing ``data`` into chunks of ``block_size``. >>> data = range(10) >>> list(block_splitter(data, 2)) [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] If ``data`` cannot be evenly divided by ``block_size``, the last block will simply be the remainder of the data. Example: >>> ...
[ "Creates", "a", "generator", "by", "slicing", "data", "into", "chunks", "of", "block_size", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/util.py#L19-L57
train
Generates a generator that yields a list of blocks of size block_size.
geomet/geomet
geomet/util.py
round_geom
def round_geom(geom, precision=None): """Round coordinates of a geometric object to given precision.""" if geom['type'] == 'Point': x, y = geom['coordinates'] xp, yp = [x], [y] if precision is not None: xp = [round(v, precision) for v in xp] yp = [round(v, precisi...
python
def round_geom(geom, precision=None): """Round coordinates of a geometric object to given precision.""" if geom['type'] == 'Point': x, y = geom['coordinates'] xp, yp = [x], [y] if precision is not None: xp = [round(v, precision) for v in xp] yp = [round(v, precisi...
[ "def", "round_geom", "(", "geom", ",", "precision", "=", "None", ")", ":", "if", "geom", "[", "'type'", "]", "==", "'Point'", ":", "x", ",", "y", "=", "geom", "[", "'coordinates'", "]", "xp", ",", "yp", "=", "[", "x", "]", ",", "[", "y", "]", ...
Round coordinates of a geometric object to given precision.
[ "Round", "coordinates", "of", "a", "geometric", "object", "to", "given", "precision", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/util.py#L77-L112
train
Round coordinates of a geometric object to given precision.
geomet/geomet
geomet/util.py
flatten_multi_dim
def flatten_multi_dim(sequence): """Flatten a multi-dimensional array-like to a single dimensional sequence (as a generator). """ for x in sequence: if (isinstance(x, collections.Iterable) and not isinstance(x, six.string_types)): for y in flatten_multi_dim(x): ...
python
def flatten_multi_dim(sequence): """Flatten a multi-dimensional array-like to a single dimensional sequence (as a generator). """ for x in sequence: if (isinstance(x, collections.Iterable) and not isinstance(x, six.string_types)): for y in flatten_multi_dim(x): ...
[ "def", "flatten_multi_dim", "(", "sequence", ")", ":", "for", "x", "in", "sequence", ":", "if", "(", "isinstance", "(", "x", ",", "collections", ".", "Iterable", ")", "and", "not", "isinstance", "(", "x", ",", "six", ".", "string_types", ")", ")", ":",...
Flatten a multi-dimensional array-like to a single dimensional sequence (as a generator).
[ "Flatten", "a", "multi", "-", "dimensional", "array", "-", "like", "to", "a", "single", "dimensional", "sequence", "(", "as", "a", "generator", ")", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/util.py#L115-L125
train
Flatten a multi - dimensional array - like to a single dimensional sequence - like.
geomet/geomet
geomet/tool.py
cli
def cli(input, verbose, quiet, output_format, precision, indent): """Convert text read from the first positional argument, stdin, or a file to GeoJSON and write to stdout.""" verbosity = verbose - quiet configure_logging(verbosity) logger = logging.getLogger('geomet') # Handle the case of file...
python
def cli(input, verbose, quiet, output_format, precision, indent): """Convert text read from the first positional argument, stdin, or a file to GeoJSON and write to stdout.""" verbosity = verbose - quiet configure_logging(verbosity) logger = logging.getLogger('geomet') # Handle the case of file...
[ "def", "cli", "(", "input", ",", "verbose", ",", "quiet", ",", "output_format", ",", "precision", ",", "indent", ")", ":", "verbosity", "=", "verbose", "-", "quiet", "configure_logging", "(", "verbosity", ")", "logger", "=", "logging", ".", "getLogger", "(...
Convert text read from the first positional argument, stdin, or a file to GeoJSON and write to stdout.
[ "Convert", "text", "read", "from", "the", "first", "positional", "argument", "stdin", "or", "a", "file", "to", "GeoJSON", "and", "write", "to", "stdout", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/tool.py#L83-L116
train
Convert text read from the first positional argument stdin or a file to GeoJSON and write to stdout.
geomet/geomet
geomet/wkb.py
_get_geom_type
def _get_geom_type(type_bytes): """Get the GeoJSON geometry type label from a WKB type byte string. :param type_bytes: 4 byte string in big endian byte order containing a WKB type number. It may also contain a "has SRID" flag in the high byte (the first type, since this is big endian by...
python
def _get_geom_type(type_bytes): """Get the GeoJSON geometry type label from a WKB type byte string. :param type_bytes: 4 byte string in big endian byte order containing a WKB type number. It may also contain a "has SRID" flag in the high byte (the first type, since this is big endian by...
[ "def", "_get_geom_type", "(", "type_bytes", ")", ":", "# slice off the high byte, which may contain the SRID flag", "high_byte", "=", "type_bytes", "[", "0", "]", "if", "six", ".", "PY3", ":", "high_byte", "=", "bytes", "(", "[", "high_byte", "]", ")", "has_srid",...
Get the GeoJSON geometry type label from a WKB type byte string. :param type_bytes: 4 byte string in big endian byte order containing a WKB type number. It may also contain a "has SRID" flag in the high byte (the first type, since this is big endian byte order), indicated as 0x20. If the SR...
[ "Get", "the", "GeoJSON", "geometry", "type", "label", "from", "a", "WKB", "type", "byte", "string", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L110-L147
train
Get the GeoJSON geometry type label from a WKB type byte string.
geomet/geomet
geomet/wkb.py
dumps
def dumps(obj, big_endian=True): """ Dump a GeoJSON-like `dict` to a WKB string. .. note:: The dimensions of the generated WKB will be inferred from the first vertex in the GeoJSON `coordinates`. It will be assumed that all vertices are uniform. There are 4 types: - 2D (X, ...
python
def dumps(obj, big_endian=True): """ Dump a GeoJSON-like `dict` to a WKB string. .. note:: The dimensions of the generated WKB will be inferred from the first vertex in the GeoJSON `coordinates`. It will be assumed that all vertices are uniform. There are 4 types: - 2D (X, ...
[ "def", "dumps", "(", "obj", ",", "big_endian", "=", "True", ")", ":", "geom_type", "=", "obj", "[", "'type'", "]", "meta", "=", "obj", ".", "get", "(", "'meta'", ",", "{", "}", ")", "exporter", "=", "_dumps_registry", ".", "get", "(", "geom_type", ...
Dump a GeoJSON-like `dict` to a WKB string. .. note:: The dimensions of the generated WKB will be inferred from the first vertex in the GeoJSON `coordinates`. It will be assumed that all vertices are uniform. There are 4 types: - 2D (X, Y): 2-dimensional geometry - Z (X, Y,...
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "WKB", "string", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L177-L246
train
Dump a GeoJSON - like dict to a WKB string.
geomet/geomet
geomet/wkb.py
loads
def loads(string): """ Construct a GeoJSON `dict` from WKB (`string`). The resulting GeoJSON `dict` will include the SRID as an integer in the `meta` object. This was an arbitrary decision made by `geomet, the discussion of which took place here: https://github.com/geomet/geomet/issues/28. ...
python
def loads(string): """ Construct a GeoJSON `dict` from WKB (`string`). The resulting GeoJSON `dict` will include the SRID as an integer in the `meta` object. This was an arbitrary decision made by `geomet, the discussion of which took place here: https://github.com/geomet/geomet/issues/28. ...
[ "def", "loads", "(", "string", ")", ":", "# noqa", "string", "=", "iter", "(", "string", ")", "# endianness = string[0:1]", "endianness", "=", "as_bin_str", "(", "take", "(", "1", ",", "string", ")", ")", "if", "endianness", "==", "BIG_ENDIAN", ":", "big_e...
Construct a GeoJSON `dict` from WKB (`string`). The resulting GeoJSON `dict` will include the SRID as an integer in the `meta` object. This was an arbitrary decision made by `geomet, the discussion of which took place here: https://github.com/geomet/geomet/issues/28. In order to be consistent with...
[ "Construct", "a", "GeoJSON", "dict", "from", "WKB", "(", "string", ")", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L249-L331
train
Takes a WKB string and returns a GeoJSON dict.
geomet/geomet
geomet/wkb.py
_header_bytefmt_byteorder
def _header_bytefmt_byteorder(geom_type, num_dims, big_endian, meta=None): """ Utility function to get the WKB header (endian byte + type header), byte format string, and byte order string. """ dim = _INT_TO_DIM_LABEL.get(num_dims) if dim is None: pass # TODO: raise type_byte_str =...
python
def _header_bytefmt_byteorder(geom_type, num_dims, big_endian, meta=None): """ Utility function to get the WKB header (endian byte + type header), byte format string, and byte order string. """ dim = _INT_TO_DIM_LABEL.get(num_dims) if dim is None: pass # TODO: raise type_byte_str =...
[ "def", "_header_bytefmt_byteorder", "(", "geom_type", ",", "num_dims", ",", "big_endian", ",", "meta", "=", "None", ")", ":", "dim", "=", "_INT_TO_DIM_LABEL", ".", "get", "(", "num_dims", ")", "if", "dim", "is", "None", ":", "pass", "# TODO: raise", "type_by...
Utility function to get the WKB header (endian byte + type header), byte format string, and byte order string.
[ "Utility", "function", "to", "get", "the", "WKB", "header", "(", "endian", "byte", "+", "type", "header", ")", "byte", "format", "string", "and", "byte", "order", "string", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L339-L376
train
Utility function to get the header byte format string and byte order string.
geomet/geomet
geomet/wkb.py
_dump_point
def _dump_point(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a point WKB string. :param dict obj: GeoJson-like `dict` object. :param bool big_endian: If `True`, data values in the generated WKB will be represented using big endian byte order. Else, little endian. ...
python
def _dump_point(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a point WKB string. :param dict obj: GeoJson-like `dict` object. :param bool big_endian: If `True`, data values in the generated WKB will be represented using big endian byte order. Else, little endian. ...
[ "def", "_dump_point", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "num_dims", "=", "len", "(", "coords", ")", "wkb_string", ",", "byte_fmt", ",", "_", "=", "_header_bytefmt_byteorder", "(", "'Point...
Dump a GeoJSON-like `dict` to a point WKB string. :param dict obj: GeoJson-like `dict` object. :param bool big_endian: If `True`, data values in the generated WKB will be represented using big endian byte order. Else, little endian. :param dict meta: Metadata associated with...
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "point", "WKB", "string", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L379-L411
train
Dump a GeoJSON - like dict to a point WKB string.
geomet/geomet
geomet/wkb.py
_dump_linestring
def _dump_linestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a linestring WKB string. Input parameters and output are similar to :func:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] # Infer the number of dimensions from the first vertex num_dims = le...
python
def _dump_linestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a linestring WKB string. Input parameters and output are similar to :func:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] # Infer the number of dimensions from the first vertex num_dims = le...
[ "def", "_dump_linestring", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "vertex", "=", "coords", "[", "0", "]", "# Infer the number of dimensions from the first vertex", "num_dims", "=", "len", "(", "vert...
Dump a GeoJSON-like `dict` to a linestring WKB string. Input parameters and output are similar to :func:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "linestring", "WKB", "string", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L414-L434
train
Dump a GeoJSON - like dict to a linestring WKB string.
geomet/geomet
geomet/wkb.py
_dump_multipoint
def _dump_multipoint(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multipoint WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_...
python
def _dump_multipoint(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multipoint WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0] num_dims = len(vertex) wkb_string, byte_fmt, byte_order = _header_...
[ "def", "_dump_multipoint", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "vertex", "=", "coords", "[", "0", "]", "num_dims", "=", "len", "(", "vertex", ")", "wkb_string", ",", "byte_fmt", ",", "b...
Dump a GeoJSON-like `dict` to a multipoint WKB string. Input parameters and output are similar to :funct:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "multipoint", "WKB", "string", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L463-L489
train
Dump a GeoJSON - like dict to a multipoint WKB string.
geomet/geomet
geomet/wkb.py
_dump_multilinestring
def _dump_multilinestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multilinestring WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0][0] num_dims = len(vertex) wkb_string, byte_fmt, byte_ord...
python
def _dump_multilinestring(obj, big_endian, meta): """ Dump a GeoJSON-like `dict` to a multilinestring WKB string. Input parameters and output are similar to :funct:`_dump_point`. """ coords = obj['coordinates'] vertex = coords[0][0] num_dims = len(vertex) wkb_string, byte_fmt, byte_ord...
[ "def", "_dump_multilinestring", "(", "obj", ",", "big_endian", ",", "meta", ")", ":", "coords", "=", "obj", "[", "'coordinates'", "]", "vertex", "=", "coords", "[", "0", "]", "[", "0", "]", "num_dims", "=", "len", "(", "vertex", ")", "wkb_string", ",",...
Dump a GeoJSON-like `dict` to a multilinestring WKB string. Input parameters and output are similar to :funct:`_dump_point`.
[ "Dump", "a", "GeoJSON", "-", "like", "dict", "to", "a", "multilinestring", "WKB", "string", "." ]
b82d7118113ab723751eba3de5df98c368423c2b
https://github.com/geomet/geomet/blob/b82d7118113ab723751eba3de5df98c368423c2b/geomet/wkb.py#L492-L522
train
Dump a GeoJSON - like dict to a multilinestring WKB string.