The Song Class

class, value_dict, max_neighbors=None, max_distance=None)[source]

Creates a Song (a set of attributes) that behaves like a dictionary:

  • session (munin.session.Session) – A Session objective (the session this song belongs to)
  • value_dict (Mapping) – A mapping from the keys to the values you want to set.
  • max_neighbors – max. numbers of neighbor-distances to save.
  • max_distance (float) – The minimal distance for distance_add() - You should try to keep this small (i.e. to only filter 1.0 distances)

Deletes all edges to other songs and tries to fill the resulting hole.

Filling the hole that may be created is done by comparing it’s neighbors with each other and adding new distances.

distance_add(other, distance)[source]

Add a relation to other with a certain distance.

  • other ( – The song to add a relation to. Will also add a relation in other_song to self with same Distance.
  • distance (munin.distance.Distance) – The Distance to add to the “edge”.

False if the song was not added because of a worse distance. True in any other case.


Compute the distance to another song.

This is a method of Song and not a static method for convinience. If you need a static method do this: Song.distance_compute(s1, s2).

Parameters:other_song – a
Returns:A munin.distance.Distance with according weighting.

Delete/Fix all invalid edges and neighbors of this song

distance_get(other_song, default_value=None)[source]

Return the distance to the song other_song

  • other_song – The song to lookup the relation to.
  • default_value – The default value to return (default to None)

A Distance.


Iterate over the indirect neighbors of this song.

Returns:an generator that yields one song at a time.

Iterate over all distances stored in this song.

Will yield songs with smallest distance first.

Returns:iterable that yields (song, distance) tuples.
Return type:generator

Remove all distances known by this song.

distance_finalize should be called afterwards.


Like distance_iter(), but only return the neighbor song, not the distance


Shortcut for dict(iter(song))

Related Topics

This Page

Useful links: