class Partition
module partition
The documentation is here.
Instances of this class are sets of
Segment that part a
data in several segments.
A npartition is a partition with n segments.
A Partition is made of

a list of Segment;
 a value, as much as possible the predictive value of the
Partition;
 a name (the empty string if it does not have).
In all computations on data, if not specified, the first position of
the partition is 0 and the last len(data)1.
Construction

__init__
 Optional keyword fic allows
construction by reading from a filename
in specific format;
 s_name
 sets the name from a
given string;
 read_nf
 builds from a filename
in specific format;
 read_str
 builds from a string in specific
format;
 read_Matrice
 builds from a
Matrice, keeping at each
position the descriptor number that is selected by a function. A
segment is made for each run of
identical descriptors numbers, and its value is the sum on its
positions of the values returned by the function.
Optional keyword:

func=f
 uses function f for selecting the descriptor
number. Function f has two arguments, a Matrice and a position, and
returns a tuple descriptor number, floating point value (default:
returns the tuple best descriptor,best value (the first of the bests
descriptors is returned if there are several bests)).
 copy
 builds a new Partition by copying this
one;
 build_random
 builds a
random Partition on a given length with a given number of
segments. Positions of the
segments are uniformly
distributed;
Optional keyword:

ec=ec
 sets the minimum length of the segments. It must
be lower than the length of the sequence divided by (the number of
segments +1) (default: 0).
 viterbi
 using Viterbi
algorithm (see [Rab89]), computes the most likely
prediction Partition of
a Lexique on a
Sequence;
Optional keyword:

maxseg=m
 limits to m the maximum number of segments
allowed in the computed partition (default: 10000). If m equals 0,
there is no limit to this number.
 mpp
 computes the
maximumprediction partition of
a given number of segments by a
Lexique on a
data.
Handling

__iadd__
 appends a
Segment after the highest
position of the Partition;
 val
 returns the value;
 name
 returns the name;
 len_don
 returns the data length;
 __len__
 returns the number of
Segment;
 num
 returns the list of descriptors numbers;
 __getitem__
 returns the
Segment of a given number;
Other methods:

group
 returns a new
Partition by clustering the
Segment given their descriptors
numbers. The argument is a list of numbers lists, each list being a
set of clustered descriptors numbers. In the new Partition,
the resulting Segment have no
descriptors numbers.
Following the increasing positions order, the
Segment are grouped as long as
the set of the descriptors numbers of the group is included in a
list of the argument; if this set is not included in such a list, a
new Segment is built, and the
new set is the descriptors numbers of the considered
Segment;
 prediction
 computes the
prediction on a
data by a
Lexique, computing one best
descriptor per class, without between
descriptors transitions;
 pts_comm
 on a
Partition, it returns the number of positions where the
descriptors numbers are the same in both Partition.
If the datalengths are different, returns 1;
InputOutput
Specific format is:
description 
outputs of Segment separated by ’
XXX ’ —> value 

examples 
<0123>1,2:5.0:+{A(1)CG}T XXX <124341>3:7.0: > 12.0 
<04>0:1.25: XXX <53922>:0.45: XXX <39234000>:0.31: > 2.01 
<086>:: XXX <87332>1:: > 0 


__str__
 outputs in specific format;
 abr
 outputs in specific format,
without the descriptors patterns.
Graphical output
Horizontal axis represents the data, and each segment is drawn by an
arc. The height of each arc is computed by a given function on the
segments (here their lengths).

draw_nf
 outputs in postscript language in file of
given name;
Optional keywords:

seg=l
 draws only segments which numbers are in list
l;
 num=n
 if equals 1, numbers of the descriptors are
written;
 func=f
 the height of each arc is proportional to
value of function f computed on the corresponding
Segment.
 R language
 A drawing function of a
Parti_simp in R language is
available
here.