Skip to content

Commit 873a08d

Browse files
committed
* inst/dbtable.m: clean up dbtable code
1 parent bda46ff commit 873a08d

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

inst/dbtable.m

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848
properties (Access = private)
4949
# internal data store
50-
_data2 = {};
50+
_data = {};
5151
endproperties
5252

5353
properties (Access = public)
@@ -128,7 +128,6 @@
128128
if sum(strcmp(n, {"VariableNames", "RowNames", "DimensionNames", "Size"})) > 0
129129
y = true;
130130
endif
131-
#printf("v %s %d\n", n, y)
132131
endif
133132
endfunction
134133
endmethods
@@ -157,7 +156,7 @@
157156
if nargin == 1
158157
# special handling for copy constructor
159158
if isa (varargin{1}, "dbtable")
160-
this._data2 = varargin{1}._data2;
159+
this._data = varargin{1}._data;
161160
this.Properties = varargin{1}.Properties;
162161
return;
163162
endif
@@ -191,7 +190,7 @@
191190
this.Properties.VariableNames{end+1} = n;
192191
endfor
193192

194-
this._data2 = data2;
193+
this._data = data2;
195194
endif
196195

197196
# some properties to deal with
@@ -219,11 +218,11 @@
219218
endif
220219

221220
# verify col data all same length
222-
sz = size(this._data2, 2);
221+
sz = size(this._data, 2);
223222
if sz > 0
224-
len1 = size(this._data2{1}, 1);
223+
len1 = size(this._data{1}, 1);
225224
for idx=2:sz
226-
len2 = size(this._data2{idx}, 1);
225+
len2 = size(this._data{idx}, 1);
227226
if len2 != len1
228227
error ("Row data is different length in column %d", idx);
229228
endif
@@ -249,7 +248,7 @@ function disp (this)
249248
n = this.Properties.VariableNames{col};
250249
widths(col) = length(n);
251250
#data = this._data.(n);
252-
data = this._data2{col};
251+
data = this._data{col};
253252
for row = 1:sz(1)
254253

255254
d = data(row,:);
@@ -283,9 +282,7 @@ function disp (this)
283282
for row = 1:sz(1)
284283
for col = 1:sz(2)
285284
printf(" ");
286-
#n = this.Properties.VariableNames{col};
287-
#data = this._data.(n);
288-
data = this._data2{col};
285+
data = this._data{col};
289286

290287
d = data(row,:);
291288
if iscell(d)
@@ -296,14 +293,13 @@ function disp (this)
296293
endif
297294

298295
t = sprintf("%%-%d.%ds", widths(col), widths(col));
299-
#printf(t, disp(data(row,:)));
300296
printf(t, d);
301297
endfor
302298
printf("\n");
303299
endfor
304300

305301
if !show_all
306-
printf(" <table truncated>");
302+
printf(" <table truncated>");
307303
endif
308304

309305
endif
@@ -333,7 +329,7 @@ function disp (this)
333329
elseif this.getcolidx(n) != -1
334330
# check in variable names
335331
idx = this.getcolidx(n);
336-
val = this._data2{idx};
332+
val = this._data{idx};
337333

338334
if (numel (s) > 1) && (s(2).type =="()" || s(2).type == "{}")
339335
if size(s(2).subs, 1) == 1
@@ -349,7 +345,7 @@ function disp (this)
349345
endif
350346
row = s(1).subs{1};
351347
col = s(1).subs{2};
352-
cval = this._data2(col);
348+
cval = this._data(col);
353349
val = {};
354350
for idx=1:numel(cval)
355351
val{end+1} = cval{idx}(row,:);
@@ -365,7 +361,7 @@ function disp (this)
365361
row = s(1).subs{1};
366362
col = s(1).subs{2};
367363
names = this.Properties.VariableNames(col);
368-
cval = this._data2(col);
364+
cval = this._data(col);
369365
val = {};
370366
for idx=1:numel(cval)
371367
val{end+1} = cval{idx}(row,:);
@@ -387,8 +383,7 @@ function summary (this)
387383
printf("Variables:\n");
388384
for idx = 1:length(this.Properties.VariableNames)
389385
n = this.Properties.VariableNames{idx};
390-
#var = this._data.(n);
391-
var = this._data2{idx};
386+
var = this._data{idx};
392387
printf(" %s %dx%d %s\n", n, size(var,1), size(var,2), class(var));
393388
# Properties
394389
# Description
@@ -401,9 +396,9 @@ function summary (this)
401396
# rows, columns just calls size
402397
function varargout = size(this, dimn=1)
403398
sz0 = 0;
404-
sz1 = length(this._data2);
399+
sz1 = length(this._data);
405400
if sz1 > 0
406-
sz0 = size(this._data2{1}, 1);
401+
sz0 = size(this._data{1}, 1);
407402
endif
408403

409404
if nargin == 1
@@ -466,7 +461,7 @@ function summary (this)
466461

467462
methods (Access = hidden)
468463
function tdata = _RawData(this)
469-
tdata = this._data2;
464+
tdata = this._data;
470465
endfunction
471466
endmethods
472467
endclassdef

0 commit comments

Comments
 (0)