Skip to content

Commit

Permalink
Fix matlab tests (#3886)
Browse files Browse the repository at this point in the history
* update API to latest per 4.5.1

* use randi rather than randsample that was moved to a different toolbox

* Add tolerance to floating point comparisons after applying a transformation
  • Loading branch information
aymanhab authored Sep 27, 2024
1 parent 8291ff5 commit cbf9c74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Bindings/Java/Matlab/tests/testConnectorsInputsOutputs.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
source = TableSource();
source.setName('source');
table = TimeSeriesTable();
labels = StdVectorString(4);
labels.set(0, 'c1'); labels.set(1, 'c2'); labels.set(2, 'c3'); labels.set(3, 'c4');
labels = StdVectorString();
labels.add('c1'); labels.add('c2'); labels.add('c3'); labels.add('c4');
table.setColumnLabels(labels);
row = RowVector(4, 1.0);
table.appendRow(0.0, row);
Expand Down
25 changes: 13 additions & 12 deletions Bindings/Java/Matlab/tests/testOsimC3D.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
% col numbers.

% Test Marker Rotations
randomRows = randsample(markers.getNumRows(),10)-1;
randomCols = randsample(markers.getNumColumns(),10)-1;
randomRows = randi(markers.getNumRows(),10)-1;
randomCols = randi(markers.getNumColumns(),10)-1;
for i = 1 : 10
% Get the values in the original and rotated marker tables
loc = osimVec3ToArray(markers.getRowAtIndex(randomRows(i)).get(randomCols(i)));
Expand All @@ -68,8 +68,8 @@
end

% Test Force Rotations
randomRows = randsample(forces.getNumRows(),6)-1;
randomCols = randsample(forces.getNumColumns(),6)-1;
randomRows = randi(forces.getNumRows(),6)-1;
randomCols = randi(forces.getNumColumns(),6)-1;
for i = 1 : 6
% Get the values in the original and rotated marker tables
val = osimVec3ToArray(forces.getRowAtIndex(randomRows(i)).get(randomCols(i)));
Expand All @@ -93,7 +93,7 @@

% Forces should remain unchanged, point and moments should be in meters
% (divided by 1000)
randomRows = randsample(forces.getNumRows(),101)-1;
randomRows = randi(forces.getNumRows(),101)-1;
for i = 0 : forces_m.getNumColumns() - 1

col = forces_rotated.getDependentColumnAtIndex(i);
Expand All @@ -106,17 +106,18 @@
d = col.get(randomRows(u));
d_m = col_m.get(randomRows(u));

assert(d.get(0)==d_m.get(0),'Force Data has been incorrectly altered');
assert(d.get(1)==d_m.get(1),'Force Data has been incorrectly altered')
assert(d.get(2)==d_m.get(2),'Force Data has been incorrectly altered')
assert(abs(d.get(0)-d_m.get(0))<.001,'Force Data has been incorrectly altered');
assert(abs(d.get(1)-d_m.get(1))<.001,'Force Data has been incorrectly altered');
assert(abs(d.get(2)-d_m.get(2))<.001,'Force Data has been incorrectly altered');

else
% Get the values
d = col.get(randomRows(u));
d_m = col_m.get(randomRows(u));

assert(d.get(0)/1000==d_m.get(0),'Point or Moment Data has been incorrectly altered');
assert(d.get(1)/1000==d_m.get(1),'Point or Moment Data has been incorrectly altered');
assert(d.get(2)/1000==d_m.get(2),'Point or Moment Data has been incorrectly altered');
assert(abs(d.get(0)/1000-d_m.get(0))<.001,'Point or Moment Data has been incorrectly altered');
assert(abs(d.get(1)/1000-d_m.get(1))<.001,'Point or Moment Data has been incorrectly altered');
assert(abs(d.get(2)/1000-d_m.get(2))<.001,'Point or Moment Data has been incorrectly altered');

end
end
end
Expand Down

0 comments on commit cbf9c74

Please sign in to comment.