(self, v, skip_invalid=False)
| 2724 | return compound_description |
| 2725 | |
| 2726 | def validate_coerce(self, v, skip_invalid=False): |
| 2727 | import plotly.io as pio |
| 2728 | |
| 2729 | try: |
| 2730 | # Check if v is a template identifier |
| 2731 | # (could be any hashable object) |
| 2732 | if v in pio.templates: |
| 2733 | return copy.deepcopy(pio.templates[v]) |
| 2734 | # Otherwise, if v is a string, check to see if it consists of |
| 2735 | # multiple template names joined on '+' characters |
| 2736 | elif isinstance(v, str): |
| 2737 | template_names = v.split("+") |
| 2738 | if all([name in pio.templates for name in template_names]): |
| 2739 | return pio.templates.merge_templates(*template_names) |
| 2740 | |
| 2741 | except TypeError: |
| 2742 | # v is un-hashable |
| 2743 | pass |
| 2744 | |
| 2745 | # Check for empty template |
| 2746 | if v == {} or isinstance(v, self.data_class) and v.to_plotly_json() == {}: |
| 2747 | # Replace empty template with {'data': {'scatter': [{}]}} so that we can |
| 2748 | # tell the difference between an un-initialized template and a template |
| 2749 | # explicitly set to empty. |
| 2750 | return self.data_class(data_scatter=[{}]) |
| 2751 | |
| 2752 | return super(BaseTemplateValidator, self).validate_coerce( |
| 2753 | v, skip_invalid=skip_invalid |
| 2754 | ) |
nothing calls this directly
no test coverage detected