pydistsim.utils.memory.positions.Positions

class Positions(subclusters=None)[source]

Bases: MemoryStructure

Class to represent subclusters positions data in node memory.

Position instances initializer has only one attribute subclusters a list of dictionaries in form {node: position_array,}. Node can be part of multiple subclusters.

Methods

__init__

create

Create Positions instance from obj which can be dict or list.

get_dic

Return value with which memory structure should be represented.

get_largest_subcluster

Returns new Positions instance with only one largest subcluster.

get_nodes

Returns nodes in all subclusters.

set_pos_copy

Empty all subclusters and copy in data from positions.

Attributes

subclusters_nodes

Returns list of subclusters without positions.

classmethod create(obj)[source]

Create Positions instance from obj which can be dict or list.

If it’s dict this method wraps it in list. Returns Position object dereferenced from the initial list or dict.

For example obj can be net.pos dict.

get_dic()[source]

Return value with which memory structure should be represented.

get_largest_subcluster()[source]

Returns new Positions instance with only one largest subcluster. If multiple subclusters have maximum number of nodes, first one is returned.

get_nodes()[source]

Returns nodes in all subclusters.

set_pos_copy(positions)[source]

Empty all subclusters and copy in data from positions.

property subclusters_nodes

Returns list of subclusters without positions.