Skip to content

Commit 7c19b62

Browse files
committed
Test fixes
1 parent 619dec5 commit 7c19b62

File tree

1 file changed

+27
-16
lines changed

1 file changed

+27
-16
lines changed

packages/python/plotly/plotly/basedatatypes.py

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3098,21 +3098,25 @@ def _get_child_props(self, child):
30983098
return None
30993099
else:
31003100
# ### Child a compound property ###
3101-
if child.plotly_name in self._compound_props:
3102-
return self._props.get(child.plotly_name, None)
3101+
if child.plotly_name in self:
3102+
from _plotly_utils.basevalidators import CompoundValidator, CompoundArrayValidator
3103+
validator = self._get_validator(child.plotly_name)
31033104

3104-
# ### Child an element of a compound array property ###
3105-
elif child.plotly_name in self._compound_array_props:
3106-
children = self._compound_array_props[child.plotly_name]
3107-
child_ind = BaseFigure._index_is(children, child)
3108-
assert child_ind is not None
3105+
if isinstance(validator, CompoundValidator):
3106+
return self._props.get(child.plotly_name, None)
31093107

3110-
children_props = self._props.get(child.plotly_name, None)
3111-
return (
3112-
children_props[child_ind]
3113-
if children_props is not None and len(children_props) > child_ind
3114-
else None
3115-
)
3108+
# ### Child an element of a compound array property ###
3109+
elif isinstance(validator, CompoundArrayValidator):
3110+
children = self[child.plotly_name]
3111+
child_ind = BaseFigure._index_is(children, child)
3112+
assert child_ind is not None
3113+
3114+
children_props = self._props.get(child.plotly_name, None)
3115+
return (
3116+
children_props[child_ind]
3117+
if children_props is not None and len(children_props) > child_ind
3118+
else None
3119+
)
31163120

31173121
# ### Invalid child ###
31183122
else:
@@ -3320,7 +3324,9 @@ def __getitem__(self, prop):
33203324
-------
33213325
Any
33223326
"""
3323-
from _plotly_utils.basevalidators import CompoundValidator, CompoundArrayValidator
3327+
from _plotly_utils.basevalidators import (
3328+
CompoundValidator, CompoundArrayValidator, BaseDataValidator
3329+
)
33243330

33253331
# Normalize prop
33263332
# --------------
@@ -3346,10 +3352,15 @@ def __getitem__(self, prop):
33463352
if isinstance(validator, CompoundValidator):
33473353
if self._compound_props.get(prop, None) is None:
33483354
# Init compound objects
3349-
self._compound_props[prop] = validator.data_class(_parent=self)
3355+
self._compound_props[prop] = validator.data_class(
3356+
_parent=self, plotly_name=prop
3357+
)
3358+
# Update plotly_name value in case the validator applies
3359+
# non-standard name (e.g. imagedefaults instead of image)
3360+
self._compound_props[prop]._plotly_name = prop
33503361

33513362
return validator.present(self._compound_props[prop])
3352-
elif isinstance(validator, CompoundArrayValidator):
3363+
elif isinstance(validator, (CompoundArrayValidator, BaseDataValidator)):
33533364
if self._compound_array_props.get(prop, None) is None:
33543365
# Init list of compound objects
33553366
self._compound_array_props[prop] = [

0 commit comments

Comments
 (0)