view testing/utp_1.1/utps/ao/utp_ao_split_samples.m @ 49:0bcdf74587d1 database-connection-manager

Cleanup
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:24:36 +0100
parents 409a22968d5e
children
line wrap: on
line source

% UTP_AO_SPLIT a set of UTPs for the ao/split method
%
% M Hewitson 06-08-08
%
% $Id: utp_ao_split_samples.m,v 1.10 2011/09/29 12:09:56 ingo Exp $
%

% <MethodDescription>
%
% The split method of the ao class splits an analysis object into the
% specified segments. This UTP splits the AOs into sample segments.
%
% </MethodDescription>

function results = utp_ao_split_samples(varargin)

  % Check the inputs
  if nargin == 0

    % Some keywords
    class   = 'ao';
    mthd    = 'split';

    results = [];
    disp('******************************************************');
    disp(['****  Running UTPs for ' class '/' mthd]);
    disp('******************************************************');

    % Test AOs
    [at1,at2,at3,at4,at5,at6,atvec,atmat] = get_test_objects_ao;
    at4.setY(randn(15));

    % Exception list for the UTPs:
    [ple1,ple2,ple3,ple4,ple5,ple6] = get_test_ples();

    % Run the tests
    results = [results utp_01];    % getInfo call
    results = [results utp_02];    % Vector input
    results = [results utp_03];    % Matrix input
    results = [results utp_04];    % List input
    results = [results utp_05];    % Test with mixed input
    results = [results utp_06];    % Test history is working
    results = [results utp_07];    % Test the modify call works
    results = [results utp_08];    % Test input data shape == output data shape
    results = [results utp_09];    % Test output of the data
    results = [results utp_10];    % Test 'dx' and 'dy'    
    
    pli  = plist('samples', [4 150 10 125]);
    results = [results utp_11(mthd, a1, ple1, pli)];    % Test plotinfo doesn't disappear
    results = [results utp_15];    % Test not equal sampled data (tsdata) and 'timeshift' option
    
    disp('Done.');
    disp('******************************************************');

  elseif nargin == 1 % Check for UTP functions
    if strcmp(varargin{1}, 'isutp')
      results = 1;
    else
      results = 0;
    end
  else
    error('### Incorrect inputs')
  end

  %% UTP_01

  % <TestDescription>
  %
  % Tests that the getInfo call works for this method.
  %
  % </TestDescription>
  function result = utp_01


    % <SyntaxDescription>
    %
    % Test that the getInfo call works for no sets, all sets, and each set
    % individually.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      % Call for no sets
      io(1) = eval([class '.getInfo(''' mthd ''', ''None'')']);
      % Call for all sets
      io(2) = eval([class '.getInfo(''' mthd ''')']);
      % Call for each set
      for kk=1:numel(io(2).sets)
        io(kk+2) = eval([class '.getInfo(''' mthd ''', ''' io(2).sets{kk} ''')']);
      end
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that getInfo call returned an minfo object in all cases.
    % 2) Check that all plists have the correct parameters.
    %
    % </AlgoDescription>

    atest = true;
    if stest
      % <AlgoCode>
      % check we have minfo objects
      if isa(io, 'minfo')
        %%% SET 'None'
        idx = 1;
        if ~isempty(io(idx).sets), atest = false; end
        if ~isempty(io(idx).plists), atest = false; end
        %%% Check all Sets
        idx = 2;
        if ~any(strcmpi(io(idx).sets, 'Default')), atest = false; end
        if ~any(strcmpi(io(idx).sets, 'By times')), atest = false; end
        if ~any(strcmpi(io(idx).sets, 'By frequencies')), atest = false; end
        if ~any(strcmpi(io(idx).sets, 'By samples')), atest = false; end
        if ~any(strcmpi(io(idx).sets, 'By chunks')), atest = false; end
        if ~any(strcmpi(io(idx).sets, 'By interval start/end')), atest = false; end
        if ~any(strcmpi(io(idx).sets, 'By interval start/duration')), atest = false; end
        if ~any(strcmpi(io(idx).sets, 'By interval timespan')), atest = false; end
        if numel(io(idx).plists) ~= numel(io(idx).sets), atest = false; end
        %%%%%%%%%%   SET 'Default'
        idx = 3;
        if io(idx).plists.nparams ~= 1, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('times'), atest = false; end
        % Check default value
        if ~isEmptyDouble(io(idx).plists.find('times')), atest = false; end        
        % Check options
        if ~isequal(io(idx).plists.getOptionsForParam('times'), {[]}), atest = false; end
        %%%%%%%%%%   SET 'By times'
        idx = 4;
        if io(idx).plists.nparams ~= 1, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('times'), atest = false; end
        % Check default value
        if ~isEmptyDouble(io(idx).plists.find('times')), atest = false; end
        % Check options
        if ~isequal(io(idx).plists.getOptionsForParam('times'), {[]}), atest = false; end
        %%%%%%%%%%   SET 'By frequencies'
        idx = 5;
        if io(idx).plists.nparams ~= 1, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('frequencies'), atest = false; end
        % Check default value
        if ~isEmptyDouble(io(idx).plists.find('frequencies')), atest = false; end
        % Check options
        if ~isequal(io(idx).plists.getOptionsForParam('frequencies'), {[]}), atest = false; end
        %%%%%%%%%%   SET 'By samples'
        idx = 6;
        if io(idx).plists.nparams ~= 1, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('samples'), atest = false; end
       % Check default value
        if ~isEmptyDouble(io(idx).plists.find('samples')), atest = false; end
        % Check options
        if ~isequal(io(idx).plists.getOptionsForParam('samples'), {[]}), atest = false; end
        %%%%%%%%%%   SET 'By chunks'
        idx = 7;
        if io(idx).plists.nparams ~= 2, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('N'), atest = false; end
        if ~io(idx).plists.isparam('match'), atest = false; end
        % Check default value
        if ~isEmptyDouble(io(idx).plists.find('N')), atest = false; end
        if ~isequal(io(idx).plists.find('match'), true), atest = false; end
        % Check options
        if ~isequal(io(idx).plists.getOptionsForParam('N'), {[]}), atest = false; end
        if ~isequal(io(idx).plists.getOptionsForParam('match'), {true, false}), atest = false; end
        %%%%%%%%%%   SET 'By interval start/end'
        idx = 8;
        if io(idx).plists.nparams ~= 2, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('start_time'), atest = false; end
        if ~io(idx).plists.isparam('end_time'), atest = false; end
        % Check default value
        if ~eq(io(idx).plists.find('start_time'), time(0), ple1), atest = false; end
        if ~eq(io(idx).plists.find('end_time'), time(0), ple1), atest = false; end
        % Check options
        %%%%%%%%%%   SET 'By interval start/duration'
        idx = 9;
        if io(idx).plists.nparams ~= 2, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('start_time'), atest = false; end
        if ~io(idx).plists.isparam('duration'), atest = false; end
        % Check default value
        if ~eq(io(idx).plists.find('start_time'), time(0), ple1), atest = false; end
        if ~eq(io(idx).plists.find('duration'), time(0), ple1), atest = false; end
        % Check options
        %%%%%%%%%%   SET 'By interval timespan'
        idx = 10;
        if io(idx).plists.nparams ~= 1, atest = false; end
        % Check key
        if ~io(idx).plists.isparam('timespan'), atest = false; end
        % Check default value
        ts = timespan(0,0);
        if ~eq(io(idx).plists.find('timespan'), ts, ple1), atest = false; end
        % Check options
      end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_01

  %% UTP_02

  % <TestDescription>
  %
  % Tests that the split method works with a vector of AOs as input.
  %
  % </TestDescription>
  function result = utp_02

    % <SyntaxDescription>
    %
    % Test that the split method works for a vector of AOs as input.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl  = plist('samples', [4 150 10 125]);
      out = split(atvec, pl);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that the number of elements in 'out' is the same as in
    %    'atvec' times numbers of intervals
    % 2) Check that each output AO contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-14;
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= numel(atvec) * numel(pl.find('samples'))/2, atest = false; end
      % Check each output
      for kk=1:2:numel(out)
        %%%% Check Interval 4 .. 150
        x   = atvec((kk+1)/2).x;
        y   = atvec((kk+1)/2).y;
        if isa(out(kk).data, 'tsdata')
          t0off = (out(kk).t0.utc_epoch_milli - atvec((kk+1)/2).t0.utc_epoch_milli)/1e3;
          ox = out(kk).x + t0off;
        else
          ox = out(kk).x;
        end
        oy = out(kk).y;
        if any(abs(ox - x(4:150)) > TOL), atest = false; end
        if ~isequal(oy, y(4:150)),        atest = false; end
        %%%% Check Interval 10 .. 125
        x   = atvec((kk+1)/2).x;
        y   = atvec((kk+1)/2).y;
        if isa(out(kk+1).data, 'tsdata')
          t0off = (out(kk+1).t0.utc_epoch_milli - atvec((kk+1)/2).t0.utc_epoch_milli)/1e3;
          ox = out(kk+1).x + t0off;
        else
          ox = out(kk+1).x;
        end
        oy = out(kk+1).y;
        if any(abs(ox - x(10:125)) > TOL), atest = false; end
        if ~isequal(oy, y(10:125)),        atest = false; end
      end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_02

  %% UTP_03

  % <TestDescription>
  %
  % Tests that the split method works with a matrix of AOs as input.
  %
  % </TestDescription>
  function result = utp_03

    % <SyntaxDescription>
    %
    % Tests that the split method works with a matrix of AOs as input.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl  = plist('samples', [50 90]);
      out = split(atmat, pl);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that the number of elements in 'out' is the same as in
    %    'atmat' times numbers of intervals
    % 2) Check that each output AO contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-14;
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= numel(atmat) * numel(pl.find('samples'))/2, atest = false; end
      % Check each output
      for kk=1:numel(out)
        %%%% Check Interval 50 .. 90
        x   = atmat(kk).x;
        y   = atmat(kk).y;
        if isa(out(kk).data, 'tsdata')
          t0off = (out(kk).t0.utc_epoch_milli - atmat(kk).t0.utc_epoch_milli)/1e3;
          ox = out(kk).x + t0off;
        else
          ox = out(kk).x;
        end
        oy = out(kk).y;
        if ~isa(out(kk).data, 'cdata')
          if any(abs(ox - x(50:90)) > TOL), atest = false; end
          if ~isequal(oy, y(50:90)),        atest = false; end
        else
          if ~isequal(oy, []),      atest = false; end
        end
      end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_03

  %% UTP_04

  % <TestDescription>
  %
  % Tests that the split method works with a list of AOs as input.
  %
  % </TestDescription>
  function result = utp_04

    % <SyntaxDescription>
    %
    % Tests that the split method works with a list of AOs as input.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl  = plist('samples', [4 15]);
      out = split(at1, at2, at3, pl);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that the number of elements in 'out' is the same as in
    %    'atvec' times numbers of intervals
    % 2) Check that each output AO contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-14;
    aoin  = [at1, at2, at3];
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= numel(aoin) * numel(pl.find('samples'))/2, atest = false; end
      % Check each output
      for kk=1:numel(out)
        %%%% Check Interval 4 .. 15
        x   = aoin(kk).x;
        y   = aoin(kk).y;
        if isa(out(kk).data, 'tsdata')
          t0off = (out(kk).t0.utc_epoch_milli - aoin(kk).t0.utc_epoch_milli)/1e3;
          ox = out(kk).x + t0off;
        else
          ox = out(kk).x;
        end
        oy = out(kk).y;
        if any(abs(ox - x(4:15)) > TOL), atest = false; end
        if ~isequal(oy, y(4:15)),        atest = false; end
      end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_04

  %% UTP_05

  % <TestDescription>
  %
  % Tests that the split method works with a mix of different shaped AOs as
  % input.
  %
  % </TestDescription>
  function result = utp_05

    % <SyntaxDescription>
    %
    % Tests that the split method works with a mix of different shaped AOs as
    % input.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl  = plist('samples', [13 99]);
      out = split(at1, atmat, atvec, at6, pl);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that the number of elements in 'out' is the same as in
    %    'atvec' times numbers of intervals
    % 2) Check that each output AO contains the correct data.
    %
    % </AlgoDescription>

    atest = true;
    TOL   = 1e-14;
    aoin  = [at1, reshape(atmat, 1, []), reshape(atvec, 1, []), at6];
    if stest
      % <AlgoCode>
      % Check we have the correct number of outputs
      if numel(out) ~= numel(aoin) * numel(pl.find('samples'))/2, atest = false; end
      % Check each output
      for kk=1:numel(out)
        %%%% Check Interval 13 .. 99
        x   = aoin(kk).x;
        y   = aoin(kk).y;
        if isa(out(kk).data, 'tsdata')
          t0off = (out(kk).t0.utc_epoch_milli - aoin(kk).t0.utc_epoch_milli)/1e3;
          ox = out(kk).x + t0off;
        else
          ox = out(kk).x;
        end
        oy = out(kk).y;
        if ~isa(out(kk).data, 'cdata')
          if any(abs(ox - x(13:99)) > TOL), atest = false; end
          if ~isequal(oy, y(13:99)),        atest = false; end
        else
          if ~isequal(oy, y(13:15)'),      atest = false; end
        end
      end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_05

  %% UTP_06

  % <TestDescription>
  %
  % Tests that the split method properly applies history.
  %
  % </TestDescription>
  function result = utp_06

    % <SyntaxDescription>
    %
    % Test that the result of applying the split method can be processed back.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl   = plist('samples', [10 30 25 55]);
      out  = split(at1, pl);
      mout = rebuild(out);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that the last entry in the history of 'out' corresponds to
    %    'split'.
    % 2) Check that the re-built object is the same object as the input.
    %
    % </AlgoDescription>

    atest = true;
    if stest
      % <AlgoCode>
      % Check the last step in the history of 'out'
      if ~strcmp(out(1).hist.methodInfo.mname, 'split'), atest = false; end
      if ~strcmp(out(2).hist.methodInfo.mname, 'split'), atest = false; end
      % The rebuilt object must be the same as 'out'
      if ~eq(mout, out, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_06

  %% UTP_07

  % <TestDescription>
  %
  % The split method can not modify the input AO.
  %
  % </TestDescription>
  function result = utp_07

    % <SyntaxDescription>
    %
    % The split method can not modify the input AO.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl    = plist('samples', [4 15]);
      amodi = ao(at1);
      aeq   = ao(at1);
      out = aeq.split(pl);
      amodi.split(pl);
      stest = false;
      % </SyntaxCode>
    catch
      stest = true;
    end

    % <AlgoDescription>
    %
    % 1) Nothind to do.
    %
    % </AlgoDescription>

    atest = true;
    if stest
      % <AlgoCode>
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_07

  %% UTP_08

  % <TestDescription>
  %
  % Test the shape of the output.
  %
  % </TestDescription>
  function result = utp_08

    % <SyntaxDescription>
    %
    % Test that the split method keeps the data shape of the input object.
    % The input AO must be an AO with row data and an AO with column data.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl   = plist('samples', [5 7]);
      out1 = split(at5, pl);
      out2 = split(at6, pl);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that the shape of the data doesn't change.
    %
    % </AlgoDescription>

    atest = true;
    if stest
      % <AlgoCode>
      % Check the shape of the output data
      if size(out1.data.y,1) == 1, atest = false; end
      if size(out2.data.y,2) == 1, atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_08

  %% UTP_09

  % <TestDescription>
  %
  % Check that the split method pass back the output objects to a list of
  % output variables or to a single variable.
  %
  % </TestDescription>
  function result = utp_09

    % <SyntaxDescription>
    %
    % Call the method with a list of output variables and with a single
    % output variable. Additionaly check that the rebuild method works on
    % the output.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      pl = plist('samples', [2 6 10 12]);
      [o1, o2] = split(at5, pl);
      o3  = split(at5, pl);
      mout1 = rebuild(o1);
      mout2 = rebuild(o2);
      mout3 = rebuild(o3);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check that the output contains the right number of objects
    % 2) Check that the 'rebuild' method produces the same object as 'out'.
    %
    % </AlgoDescription>

    atest = true;
    if stest
      % <AlgoCode>
      % Check the number of outputs
      if numel(o1) ~=1, atest = false; end
      if numel(o2) ~=1, atest = false; end
      if numel(o3) ~=2, atest = false; end
      % Check the rebuilding of the object
      if ~eq(o1, mout1, ple2), atest = false; end
      if ~eq(o2, mout2, ple2), atest = false; end
      if ~eq(o3, mout3, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_09

  %% UTP_10

  % <TestDescription>
  %
  % Test that the split method also splits the 'dx' and 'dy' values.
  %
  % </TestDescription>
  function result = utp_10

    % <SyntaxDescription>
    %
    % Test that the split method also splits the 'dx' and 'dy' values.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      % Create default values for 'dx' and 'dy'
      dx = randn(1000,1);
      dy = randn(1000,1);
      % tsdata
      a1 = at1.setDx(dx(1:at1.len));
      a1.setDy(dy(1:at1.len));
      % fsdata
      a2 = at2.setDx(dx(1:at2.len));
      a2.setDy(dy(1:at2.len));
      % xydata
      a3 = at3.setDx(dx(1:at3.len));
      a3.setDy(dy(1:a3.len));
      % cdata
      a4 = at4.setDy(dy(1:at4.len));
      
      % Test with only one value for 'dx' and 'dy'
      % tsdata
      a5 = at1.setDx(123);
      a5.setDy(123);

      sl = [20 90];
      out1 = split(a1, plist('samples', sl));
      out2 = split(a2, plist('samples', sl));
      out3 = split(a3, plist('samples', sl));
      out4 = split(a4, plist('samples', [3 7]));
      out5 = split(a5, plist('samples', sl));

      mout1 = rebuild(out1);
      mout2 = rebuild(out2);
      mout3 = rebuild(out3);
      mout4 = rebuild(out4);
      mout5 = rebuild(out5);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check the output
    % 2) Check that the re-built object is the same as in 'out'.
    %
    % </AlgoDescription>

    atest = true;
    if stest
      % <AlgoCode>
      % Check the output
      ddx = dx(1:at1.len);
      ddy = dy(1:at1.len);
      if ~isequal(out1.dx, ddx(sl(1):sl(2))); atest = false; end
      if ~isequal(out1.dy, ddy(sl(1):sl(2))); atest = false; end
      ddx = dx(1:at1.len);
      ddy = dy(1:at2.len);
      if ~isequal(out2.dx, ddx(sl(1):sl(2))); atest = false; end
      if ~isequal(out2.dy, ddy(sl(1):sl(2))); atest = false; end
      ddx = dx(1:at3.len);
      ddy = dy(1:at3.len);
      if ~isequal(out3.dx, ddx(sl(1):sl(2))); atest = false; end
      if ~isequal(out3.dy, ddy(sl(1):sl(2))); atest = false; end
      ddy = dy(1:at4.len);
      if ~isequal(out4.dy, ddy(3:7)); atest = false; end
      if ~isequal(out5.dx, a5.dx); atest = false; end
      if ~isequal(out5.dy, a5.dy); atest = false; end
      % Check the re-built objects
      if ~eq(mout1, out1, ple2), atest = false; end
      if ~eq(mout2, out2, ple2), atest = false; end
      if ~eq(mout3, out3, ple2), atest = false; end
      if ~eq(mout4, out4, ple2), atest = false; end
      if ~eq(mout5, out5, ple2), atest = false; end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_10

  %% UTP_15

  % <TestDescription>
  %
  % Check that the split method works with notequal sampled data.
  % Check that the split method works with 'timeshift' option.  
  %
  % </TestDescription>
  function result = utp_15

    % <SyntaxDescription>
    %
    % Check that the split method works with notequal sampled data.
    % Check that the split method works with 'timeshift' option.
    %
    % </SyntaxDescription>

    try
      % <SyntaxCode>
      a1 = ao(plist('tsfcn', 'randn(size(t))', 'fs', 10, 'nsecs', 200, 'yunits', 'N'));
      in = [1:150 152:400 402:1019 1021:1999];
      a1.setXY(a1.x(in) + 60, a1.y(in));
      a1.setT0(time('2009-11-03 18:00:00.000'));

      samples_v = [120 300 500 1500 2500 2600];
      samples_o = [samples_v(2) - samples_v(1) + 1;samples_v(4) - samples_v(3) + 1;0;];
      
      pl1   = plist(...
        'samples', samples_v);
      out1  = split(a1, pl1);
      mout1 = rebuild(out1);
      % </SyntaxCode>
      stest = true;
    catch err
      disp(err.message)
      stest = false;
    end

    % <AlgoDescription>
    %
    % 1) Check the outputs
    % 2) Check that the 'rebuild' method produces the same object as 'out'.
    %
    % </AlgoDescription>

    atest = true;
    if stest
      % <AlgoCode>
            
      for jj = 1:numel(out1)
        % Check number of samples
        if ~eq(out1(jj).len,  samples_o(jj)), atest = false; end
        if ~isempty(out1(jj).data.x)
          % Check t0
          if ~isequal(out1(jj).t0, a1.t0), atest = false; end
          % Check first x value
          if ~eq(out1(jj).data.x(1),  a1.data.x(samples_v(jj*2 - 1))), atest = false; end
        end
        % Check the rebuilding of the object
        if ~eq(out1(jj), mout1(jj), ple2), atest = false; end
      end
      % </AlgoCode>
    else
      atest = false;
    end

    % Return a result structure
    result = utp_prepare_result(atest, stest, dbstack, mfilename);
  end % END UTP_15
end