[SciPy-dev] matlab.io squeezes by default

Matthew Brett matthew.brett at gmail.com
Tue Feb 12 21:51:58 EST 2008


Hi,

The compelling reason was only that that was the behavior that we
inherited from the original scipy.io.loadmat

It's probably better for that not to happen, but I imagine the change
will break some code.

Matthew

On Feb 13, 2008 1:59 AM, Nathan Bell <wnbell at gmail.com> wrote:
> I noticed that scipy.io.loadmat() had squeeze_me=True set by default.
> Was there a compelling reason for this default choice?  I would think
> that most people expect (1,N) matrices and (N,1) matrices to retain
> their shapes when loaded.  Here's a simple example that illustrates
> the problem.
>
> from scipy.testing import *
> from scipy import array, matrix
> from scipy.io import savemat, loadmat
>
> A = matrix([[1,2,3]])
> B = matrix([[1],[2],[3]])
>
> X = {'A' : A, 'B' : B }
>
> savemat('temp.mat', X )
>
> #Y = loadmat('temp.mat', squeeze_me=False)  # preserves shape
> Y = loadmat('temp.mat')  #does not preserve shape
>
> assert_equal( Y['A'], A)
> assert_equal( Y['B'], B)
>
>
>
> For now, I have changed the default to squeeze_me=False.
>
> --
> Nathan Bell wnbell at gmail.com
> http://graphics.cs.uiuc.edu/~wnbell/
> _______________________________________________
> Scipy-dev mailing list
> Scipy-dev at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-dev
>



More information about the SciPy-Dev mailing list