allow link parent to be a str
move handling to Link class
@@ -12,16 +12,24 @@ import fknm
class BaseELink(Link):
- def __init__(self, name=None, joint_name=None):
+ def __init__(self, name=None, parent=None, joint_name=None):
super().__init__()
self._name = name
+
+ if parent is not None:
+ if isinstance(parent, (str, BaseELink)):
+ self._parent = parent
+ else:
+ raise ValueError('parent must be BaseELink subclass or str')
+ else:
+ self._parent = None
+
self._joint_name = joint_name
self._jindex = None
self._children = []
- self._parent = None
def __repr__(self):
name = self.__class__.__name__
@@ -365,7 +373,6 @@ class ELink(BaseELink):
ets=ETS(),
v=None,
jindex=None,
- parent=None,
**kwargs):
# process common options
@@ -385,16 +392,6 @@ class ELink(BaseELink):
elif jindex is None and v.jindex is not None:
jindex = v.jindex
- # TODO simplify this logic, can be ELink class or None
- # if isinstance(parent, list):
- # raise TypeError(
- # 'Only one parent link can be present')
- if not isinstance(parent, (ELink, str)) and parent is not None:
- raise TypeError(
- 'Parent must be of type ELink, str or None')
-
-
-
# Initialise the static transform representing the constant
# component of the ETS
self._init_Ts()
@@ -600,7 +597,6 @@ class ELink2(BaseELink):
ets=ETS2(),
v=None,
jindex=None,
- parent=None,
**kwargs):
# process common options
@@ -620,14 +616,6 @@ class ELink2(BaseELink):
elif jindex is None and v.jindex is not None:
jindex = v.jindex
- # TODO simplify this logic, can be ELink class or None
- # if isinstance(parent, list):
- # raise TypeError(
- # 'Only one parent link can be present')
- if not isinstance(parent, (ELink2, str)) and parent is not None:
- raise TypeError(
- 'Parent must be of type ELink, str or None')
-
# Initialise the static transform representing the constant
# component of the ETS
self._init_Ts()
