if __name__ == '__main__':
    import mlabwrap
    from mlabwrap import mlab

    import savedrvs
    xo = savedrvs.rvsdata.xar2
    x100 = xo[-100:]/1000.
    x1000 = xo/1000.

    filen = 'testsavetls.py'
    res_pacf =  HoldIt('mlpacf')
    res_pacf.comment = 'mlab.parcorr(x, [], 2, nout=3)'
    res_pacf.pacf100, res_pacf.lags100, res_pacf.bounds100 = \
                      mlab.parcorr(x100, [], 2, nout=3)
    res_pacf.pacf1000, res_pacf.lags1000, res_pacf.bounds1000 = \
                      mlab.parcorr(x1000, [], 2, nout=3)
    res_pacf.save(filename=filen, header=True)

    res_acf =  HoldIt('mlacf')
    res_acf.comment = 'mlab.autocorr(x, [], 2, nout=3)'
    res_acf.acf100, res_acf.lags100, res_acf.bounds100 = \
                    mlab.autocorr(x100, [], 2, nout=3)
    res_acf.acf1000, res_acf.lags1000, res_acf.bounds1000 = \
                    mlab.autocorr(x1000, [], 2, nout=3)
    res_acf.save(filename=filen, header=False)


    res_ccf =  HoldIt('mlccf')
    res_ccf.comment = 'mlab.crosscorr(x[4:], x[:-4], [], 2, nout=3)'
    assert_array_almost_equal(-res_armarep.arrep.ravel(), arrep, 14)


if __name__ == '__main__':
    from mlabwrap import mlab

    import savedrvs
    xo = savedrvs.rvsdata.xar2
    x100 = xo[-100:] / 1000.
    x1000 = xo / 1000.

    filen = 'testsavetls.py'
    res_pacf = HoldIt('mlpacf')
    res_pacf.comment = 'mlab.parcorr(x, [], 2, nout=3)'
    res_pacf.pacf100, res_pacf.lags100, res_pacf.bounds100 = \
                      mlab.parcorr(x100, [], 2, nout=3)
    res_pacf.pacf1000, res_pacf.lags1000, res_pacf.bounds1000 = \
                      mlab.parcorr(x1000, [], 2, nout=3)
    res_pacf.save(filename=filen, header=True)

    res_acf = HoldIt('mlacf')
    res_acf.comment = 'mlab.autocorr(x, [], 2, nout=3)'
    res_acf.acf100, res_acf.lags100, res_acf.bounds100 = \
                    mlab.autocorr(x100, [], 2, nout=3)
    res_acf.acf1000, res_acf.lags1000, res_acf.bounds1000 = \
                    mlab.autocorr(x1000, [], 2, nout=3)
    res_acf.save(filename=filen, header=False)

    res_ccf = HoldIt('mlccf')
    res_ccf.comment = 'mlab.crosscorr(x[4:], x[:-4], [], 2, nout=3)'
    res_ccf.ccf100, res_ccf.lags100, res_ccf.bounds100 = \