SciPy

tethne.utilities package

Module contents

Helper functions.

class tethne.utilities.Dictionary[source]

A two-way index for integer/string pairs.

tethne.utilities.attribs_to_string(attrib_dict, keys)[source]

A more specific version of the subdict utility aimed at handling node and edge attribute dictionaries for NetworkX file formats such as gexf (which does not allow attributes to have a list type) by making them writable in those formats

tethne.utilities.concat_list(listA, listB, delim=' ')[source]

Concatenate list elements pair-wise with the delim character Returns the concatenated list Raises index error if lists are not parallel

tethne.utilities.contains(l, f)[source]

Searches list l for a pattern specified in a lambda function f.

tethne.utilities.dict_from_node(node, recursive=False)[source]

Converts ElementTree node to a dictionary.

Parameters:

node : ElementTree node

recursive : boolean

If recursive=False, the value of any field with children will be the number of children.

Returns:

dict : nested dictionary.

Tags as keys and values as values. Sub-elements that occur multiple times in an element are contained in a list.

tethne.utilities.overlap(listA, listB)[source]

Return list of objects shared by listA, listB.

tethne.utilities.strip_non_ascii(s)[source]

Returns the string without non-ASCII characters.

Parameters:

string : string

A string that may contain non-ASCII characters.

Returns:

clean_string : string

A string that does not contain non-ASCII characters.

tethne.utilities.strip_punctuation(s)[source]
tethne.utilities.subdict(super_dict, keys)[source]

Returns a subset of the super_dict with the specified keys.

tethne.utilities.swap(u, v)[source]

exchange the values of u and v