[Scipy-tickets] [SciPy] #859: spatial.distance.squareform - arg 'force' behaves inconsistently

SciPy scipy-tickets@scipy....
Thu Jan 29 07:50:06 CST 2009

#859: spatial.distance.squareform - arg 'force' behaves inconsistently
 Reporter:  doggo          |       Owner:  peridot
     Type:  defect         |      Status:  new    
 Priority:  normal         |   Milestone:  0.7.1  
Component:  scipy.spatial  |     Version:  devel  
 Severity:  normal         |    Keywords:  forcing
 Not sure about the intended behaviour, but I guess:

 1. The documentation should read (vector <-> matrix):
        force : string
            As with MATLAB(TM), if force is equal to 'tovector' or
            'tomatrix', the input will be treated as a distance vector
            or distance matrix respectively.

 2. The elif condition on line 1352 is wrong; if 'forcing' means just
 checking the input and raising errors, then the structure could be:

     if len(s) == 1 and force.lower() != 'tomatrix':
         # Compute X = squareform(v)
     elif len(s) == 2 and force.lower() != 'tovector':
         # Compute v = squareform(X)
     elif len(s) != 1 and force.lower() == 'tovector':
         raise ValueError("Forcing 'tovector' but input X is not one
     elif len(s) != 2 and force.lower() == 'tomatrix':
         raise ValueError("Forcing 'tomatrix' but input X is not two
         # Other cases, i.e. len(s)>2 and force != 'tovector' nor
         raise ValueError('The first argument must be one or two
 dimensional array. A %d-dimensional array is not permitted' % len(s))

 PS: wouldn't it be less redundant to use here the is_valid_dm is_valid_y


Ticket URL: <http://scipy.org/scipy/scipy/ticket/859>
SciPy <http://www.scipy.org/>
SciPy is open-source software for mathematics, science, and engineering.

More information about the Scipy-tickets mailing list