The Song Class

class munin.song.Song(session, value_dict, max_neighbors=None, max_distance=None)[source]

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

Parameters:
  • 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)
disconnect()[source]

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.

Parameters:
  • other (munin.song.Song) – 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”.
Returns:

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

distance_compute(other_song)[source]

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 munin.song.Song
Returns:A munin.distance.Distance with according weighting.
distance_finalize()[source]

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

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

A Distance.

distance_indirect_iter(dist_threshold=1.1)[source]

Iterate over the indirect neighbors of this song.

Returns:an generator that yields one song at a time.
distance_iter()[source]

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
distance_reset()[source]

Remove all distances known by this song.

distance_finalize should be called afterwards.

neighbors()[source]

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

to_dict()[source]

Shortcut for dict(iter(song))

Related Topics

This Page

Useful links:

Package:

Github: