Skip to content

Commit 5fdb345

Browse files
committed
Apply sign to signals when loading dsres.mat files
1 parent da8933c commit 5fdb345

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ nosetests.xml
4040
# data files
4141
*.h5
4242
*.mat
43+
!DoublePendulum.mat
4344

4445
# temp files
4546
~*

sdf/dsres.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ def _load_mat(filename):
130130
pass
131131

132132
if d == 1:
133-
data = cons[c, 0]
133+
data = cons[c, 0] * s
134134
else:
135-
data = traj[c, :]
135+
data = traj[c, :] * s
136136

137137
if 'type' in info:
138138
if info['type'] == 'Integer' or 'Boolean':

tests/DoublePendulum.mat

339 KB
Binary file not shown.

tests/test_sdf.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,12 @@ def test_dsres_load_dataset(self):
298298
self.assertEqual(ds.data.dtype, np.int32)
299299
self.assertEqual(ds.data, 1)
300300

301+
def test_dsres_inverted_signals(self):
302+
path = os.path.dirname(__file__)
303+
filename = os.path.join(path, 'DoublePendulum.mat')
304+
rvisobj = sdf.load(filename, '/world/y_label/cylinders[2]/rvisobj[1]')
305+
self.assertTrue(rvisobj.data < 0)
306+
301307
@skipIf(platform.system() != 'Windows', "Test requires display")
302308
def test_interp_1d_example(self):
303309
runpy.run_module('sdf.examples.interp_1d')

0 commit comments

Comments
 (0)