Skip to content

Commit

Permalink
table: have fieldnames() expose the variable and dim names plus "Prop…
Browse files Browse the repository at this point in the history
…erties", instead of internal object properties; properties() too

But not `isfield()` or `isprop()`, because I don't think they're defined to work that way in Matlab.
  • Loading branch information
apjanke committed Feb 4, 2024
1 parent e68c0fd commit 0d454fe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Version 0.4.0 (in progress)
* Add idempotent one-arg constructor forms for string, datetime, categorical. (But not table.)
* Add `istable`, `istimetable`, and `istabular` functions.
* Add `NaS`, `NaC`, and `todatetime` functions.
* Have `fieldnames (table)` expose variable and dimension names and Properties, instead of the internal implementation properties.
* Rename `+tablicious` package to `+tblish`; merge `+octave` package into `+tblish`.
* Move `+table_examples` package to `+tblish/+examples`.
* Make internal-use properties on the main classes Access = private, now that the code is a little more mature.
Expand Down
20 changes: 20 additions & 0 deletions inst/table.m
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,26 @@ function prettyprint (this)

# Structural stuff

function out = fieldnames (this)
# fieldnames is customize to expose the variable and dimension names as fields, and
# hide the real fields inside "Properties".
out = [this.VariableNames'; {'Properties'}; this.DimensionNames'];
endfunction

function out = properties (this)
# properties, like fieldnames, is customize to expose the variable and dimension
# names as fields, and hide the real fields inside "Properties".
out = fieldnames (this);
if nargout == 0
fprintf('Properties for class %s:\n\n', class (this));
for i = 1:numel (out)
fprintf(' %s\n', out{i});
endfor
fprintf('\n');
clear out
endif
endfunction

## -*- texinfo -*-
## @node table.varnames
## @deftypefn {Method} {@var{out} =} varnames (@var{obj})
Expand Down

0 comments on commit 0d454fe

Please sign in to comment.