Skip to content

Commit 73cdc5f

Browse files
committed
renaming of RTB data access functions
1 parent 5dfb1cf commit 73cdc5f

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

roboticstoolbox/mobile/Animations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import matplotlib.transforms as mtransforms
1515

1616
from spatialmath import SE2, base
17-
from roboticstoolbox import rtb_loaddata
17+
from roboticstoolbox import rtb_load_data
1818

1919

2020
class VehicleAnimation(ABC):

roboticstoolbox/mobile/PoseGraph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def __init__(self, filename, laser=False, verbose=False):
9898

9999
self.graph = pgraph.UGraph(verbose=verbose)
100100

101-
path = Path(rtb.path_to_datafile(filename))
101+
path = Path(rtb.rtb_path_to_datafile(filename))
102102

103103
if path.suffix == '.zip':
104104
zf = zipfile.ZipFile(path, 'r')

roboticstoolbox/tools/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from roboticstoolbox.tools.numerical import jacobian_numerical, \
88
hessian_numerical
99
from roboticstoolbox.tools.jsingu import jsingu
10-
from roboticstoolbox.tools.data import rtb_loaddata, rtb_loadmat, rtb_path_to_datafile
10+
from roboticstoolbox.tools.data import rtb_load_data, rtb_load_matfile, rtb_load_jsonfile, rtb_path_to_datafile
1111

1212

1313
__all__ = [
@@ -26,7 +26,8 @@
2626
'jsingu',
2727
'jacobian_numerical',
2828
'hessian_numerical',
29-
'rtb_loaddata',
30-
'rtb_loadmat',
29+
'rtb_load_data',
30+
'rtb_load_matfile',
31+
'rtb_load_jsonfile',
3132
'rtb_path_to_datafile',
3233
]

roboticstoolbox/tools/data.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
import importlib
44

55

6-
7-
def rtb_loadmat(filename):
6+
def rtb_load_matfile(filename):
87
"""
98
Load toolbox mat format data file
109
@@ -27,9 +26,33 @@ def rtb_loadmat(filename):
2726
"""
2827
from scipy.io import loadmat
2928

30-
return rtb_loaddata(filename, loadmat, squeeze_me=True, struct_as_record=False)
29+
return rtb_load_data(filename, loadmat, squeeze_me=True, struct_as_record=False)
30+
31+
def rtb_load_jsonfile(filename):
32+
"""
33+
Load toolbox JSON format data file
34+
35+
:param filename: relative pathname of datafile
36+
:type filename: str
37+
:raises ValueError: File does not exist
38+
:return: contents of JSON data file
39+
:rtype: dict
40+
41+
Reads a JSON format file which can contain multiple variables and return
42+
a dict where the keys are the variable
43+
names and the values are NumPy arrays.
44+
45+
.. note::
46+
- If the filename has no path component, eg. ``map1.mat`, it will be
47+
first be looked for in the folder ``roboticstoolbox/data``.
48+
49+
:seealso: :func:`path_to_datafile`
50+
"""
51+
import json
52+
53+
return rtb_load_data(filename, lambda f: json.load(open(f, 'r')))
3154

32-
def rtb_loaddata(filename, handler, **kwargs):
55+
def rtb_load_data(filename, handler, **kwargs):
3356
"""
3457
Load toolbox data file
3558
@@ -47,7 +70,7 @@ def rtb_loaddata(filename, handler, **kwargs):
4770
4871
For example::
4972
50-
data = rtb_loaddata('data/queensland.json', lambda f: json.load(open(f, 'r')))
73+
data = rtb_load_data('data/queensland.json', lambda f: json.load(open(f, 'r')))
5174
5275
5376
.. note:: If the filename has no path component, eg. ``foo.dat``, it will

0 commit comments

Comments
 (0)