12
12
13
13
class BaseELink (Link ):
14
14
15
- def __init__ (self , name = None , joint_name = None ):
15
+ def __init__ (self , name = None , parent = None , joint_name = None ):
16
16
17
17
super ().__init__ ()
18
18
19
19
self ._name = name
20
+
21
+ if parent is not None :
22
+ if isinstance (parent , (str , BaseELink )):
23
+ self ._parent = parent
24
+ else :
25
+ raise ValueError ('parent must be BaseELink subclass or str' )
26
+ else :
27
+ self ._parent = None
28
+
20
29
self ._joint_name = joint_name
21
30
22
31
self ._jindex = None
23
32
self ._children = []
24
- self ._parent = None
25
33
26
34
def __repr__ (self ):
27
35
name = self .__class__ .__name__
@@ -365,7 +373,6 @@ def __init__(
365
373
ets = ETS (),
366
374
v = None ,
367
375
jindex = None ,
368
- parent = None ,
369
376
** kwargs ):
370
377
371
378
# process common options
@@ -385,16 +392,6 @@ def __init__(
385
392
elif jindex is None and v .jindex is not None :
386
393
jindex = v .jindex
387
394
388
- # TODO simplify this logic, can be ELink class or None
389
- # if isinstance(parent, list):
390
- # raise TypeError(
391
- # 'Only one parent link can be present')
392
- if not isinstance (parent , (ELink , str )) and parent is not None :
393
- raise TypeError (
394
- 'Parent must be of type ELink, str or None' )
395
-
396
-
397
-
398
395
# Initialise the static transform representing the constant
399
396
# component of the ETS
400
397
self ._init_Ts ()
@@ -600,7 +597,6 @@ def __init__(
600
597
ets = ETS2 (),
601
598
v = None ,
602
599
jindex = None ,
603
- parent = None ,
604
600
** kwargs ):
605
601
606
602
# process common options
@@ -620,14 +616,6 @@ def __init__(
620
616
elif jindex is None and v .jindex is not None :
621
617
jindex = v .jindex
622
618
623
- # TODO simplify this logic, can be ELink class or None
624
- # if isinstance(parent, list):
625
- # raise TypeError(
626
- # 'Only one parent link can be present')
627
- if not isinstance (parent , (ELink2 , str )) and parent is not None :
628
- raise TypeError (
629
- 'Parent must be of type ELink, str or None' )
630
-
631
619
# Initialise the static transform representing the constant
632
620
# component of the ETS
633
621
self ._init_Ts ()
0 commit comments