def to_mlab_linkage(Z):
 Z = np.asarray(Z, order='c', dtype=np.double)
 Zs = Z.shape
 if ((len(Zs) == 0) or ((len(Zs) == 1) and (Zs[0] == 0))):
  return Z.copy()
 is_valid_linkage(Z, throw=True, name='Z')
 ZP = Z[:, 0:3].copy()
 ZP[:, 0:2] += 1.0
 return ZP

def to_mlab_linkage ( Z ) : Z = np . asarray ( Z , order = 'c' , dtype = np . double ) Zs = Z . shape if ( ( len ( Zs ) == 0 ) or ( ( len ( Zs ) == 1 ) and ( Zs [ 0 ] == 0 ) ) ) : return Z . copy ( ) is_valid_linkage ( Z , throw = True , name = 'Z' ) ZP = Z [ : , 0 : 3 ] . copy ( ) ZP [ : , 0 : 2 ] += 1.0 return ZP
converts a linkage matrix to a matlab compatible one .