~ubuntu-branches/ubuntu/saucy/python-scipy/saucy

« back to all changes in this revision

Viewing changes to scipy/io/tests/gen_unittests.m

  • Committer: Bazaar Package Importer
  • Author(s): Ondrej Certik
  • Date: 2008-06-16 22:58:01 UTC
  • mfrom: (2.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080616225801-irdhrpcwiocfbcmt
Tags: 0.6.0-12
* The description updated to match the current SciPy (Closes: #489149).
* Standards-Version bumped to 3.8.0 (no action needed)
* Build-Depends: netcdf-dev changed to libnetcdf-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
% Generates mat files for loadmat unit tests
 
2
% This is the version for matlab 5 and higher
 
3
% Uses save_test.m function
 
4
 
 
5
% work out matlab version and file suffix for test files
 
6
global FILEPREFIX FILESUFFIX
 
7
FILEPREFIX = [fullfile(pwd, 'data') filesep];
 
8
temp = ver('MATLAB');
 
9
mlv = temp.Version;
 
10
FILESUFFIX = ['_' mlv '_' computer '.mat'];
 
11
 
 
12
% basic double array
 
13
save_test('testdouble', 0:pi/4:2*pi);
 
14
 
 
15
% string
 
16
save_test('teststring', '"Do nine men interpret?" "Nine men," I nod.')
 
17
 
 
18
% complex
 
19
theta = 0:pi/4:2*pi;
 
20
save_test('testcomplex', cos(theta) + 1j*sin(theta));
 
21
 
 
22
% asymmetric array to check indexing
 
23
a = zeros(3, 5);
 
24
a(:,1) = [1:3]';
 
25
a(1,:) = 1:5;
 
26
 
 
27
% 2D matrix
 
28
save_test('testmatrix', a);
 
29
 
 
30
% minus number - tests signed int 
 
31
save_test('testminus', -1);
 
32
 
 
33
% single character
 
34
save_test('testonechar', 'r');
 
35
 
 
36
% string array
 
37
save_test('teststringarray', ['one  '; 'two  '; 'three']);
 
38
 
 
39
% sparse array
 
40
save_test('testsparse', sparse(a));
 
41
 
 
42
% sparse complex array
 
43
b = sparse(a);
 
44
b(1,1) = b(1,1) + j;
 
45
save_test('testsparsecomplex', b);
 
46
 
 
47
% Two variables in same file
 
48
save([FILEPREFIX 'testmulti' FILESUFFIX], 'a', 'theta')
 
49
 
 
50
 
 
51
% struct
 
52
save_test('teststruct', ...
 
53
          struct('stringfield','Rats live on no evil star.',...
 
54
                 'doublefield',[sqrt(2) exp(1) pi],...
 
55
                 'complexfield',(1+1j)*[sqrt(2) exp(1) pi]));
 
56
 
 
57
% cell
 
58
save_test('testcell', ...
 
59
          {['This cell contains this string and 3 arrays of increasing' ...
 
60
            ' length'], 1., 1.:2., 1.:3.});
 
61
 
 
62
% Empty cells in two cell matrices
 
63
save_test('testemptycell', {1, 2, [], [], 3});
 
64
 
 
65
% 3D matrix
 
66
save_test('test3dmatrix', reshape(1:24,[2 3 4]))
 
67
 
 
68
% nested cell array
 
69
save_test('testcellnest', {1, {2, 3, {4, 5}}});
 
70
 
 
71
% nested struct
 
72
save_test('teststructnest', struct('one', 1, 'two', ...
 
73
                                   struct('three', 'number 3')));
 
74
 
 
75
% array of struct
 
76
save_test('teststructarr', [struct('one', 1, 'two', 2) ...
 
77
                    struct('one', 'number 1', 'two', 'number 2')]);
 
78
 
 
79
% matlab object
 
80
save_test('testobject', inline('x'))
 
81
 
 
82
% array of matlab objects
 
83
%save_test('testobjarr', [inline('x') inline('y')])
 
84
 
 
85
% unicode test
 
86
if str2num(mlv) > 7  % function added 7.0.1
 
87
  fid = fopen([FILEPREFIX 'japanese_utf8.txt']);
 
88
  from_japan = fread(fid, 'uint8')';
 
89
  fclose(fid);
 
90
  save_test('testunicode', native2unicode(from_japan, 'utf-8'));
 
91
end
 
92
  
 
 
b'\\ No newline at end of file'