|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -import typing |
4 | 3 | from abc import ABC |
5 | 4 | from contextlib import suppress |
6 | 5 | from copy import deepcopy |
7 | 6 | from itertools import chain, repeat |
| 7 | +from typing import TYPE_CHECKING |
8 | 8 |
|
9 | 9 | import numpy as np |
10 | 10 |
|
|
18 | 18 | from ..mapping.aes import rename_aesthetics |
19 | 19 | from ..mapping.evaluation import evaluate |
20 | 20 |
|
21 | | -if typing.TYPE_CHECKING: |
| 21 | +if TYPE_CHECKING: |
22 | 22 | from typing import Any |
23 | 23 |
|
24 | 24 | import pandas as pd |
@@ -211,8 +211,7 @@ def use_defaults( |
211 | 211 | : |
212 | 212 | Data used for drawing the geom. |
213 | 213 | """ |
214 | | - from plotnine.mapping import _atomic as atomic |
215 | | - from plotnine.mapping._atomic import ae_value |
| 214 | + from plotnine.mapping._atomic import ae_value, broadcast_ae_value |
216 | 215 |
|
217 | 216 | missing_aes = ( |
218 | 217 | self.DEFAULT_AES.keys() |
@@ -244,11 +243,9 @@ def use_defaults( |
244 | 243 | else: |
245 | 244 | # Try to make sense of aesthetics whose values can be tuples |
246 | 245 | # or sequences of sorts. |
247 | | - ae_value_cls: type[ae_value] | None = getattr(atomic, ae, None) |
248 | | - if ae_value_cls: |
249 | | - with suppress(ValueError): |
250 | | - data[ae] = ae_value_cls(value) * len(data) |
251 | | - continue |
| 246 | + with suppress(ValueError): |
| 247 | + data[ae] = broadcast_ae_value(value, ae, len(data)) |
| 248 | + continue |
252 | 249 |
|
253 | 250 | # This should catch the aesthetic assignments to |
254 | 251 | # non-numeric or non-string values or sequence of values. |
|
0 commit comments