Skip to content

Commit 24fc289

Browse files
committed
Use broadcast_ae_value helper for atomic aesthetic assignment
1 parent 5b82b64 commit 24fc289

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

plotnine/geoms/geom.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
from __future__ import annotations
22

3-
import typing
43
from abc import ABC
54
from contextlib import suppress
65
from copy import deepcopy
76
from itertools import chain, repeat
7+
from typing import TYPE_CHECKING
88

99
import numpy as np
1010

@@ -18,7 +18,7 @@
1818
from ..mapping.aes import rename_aesthetics
1919
from ..mapping.evaluation import evaluate
2020

21-
if typing.TYPE_CHECKING:
21+
if TYPE_CHECKING:
2222
from typing import Any
2323

2424
import pandas as pd
@@ -211,8 +211,7 @@ def use_defaults(
211211
:
212212
Data used for drawing the geom.
213213
"""
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
216215

217216
missing_aes = (
218217
self.DEFAULT_AES.keys()
@@ -244,11 +243,9 @@ def use_defaults(
244243
else:
245244
# Try to make sense of aesthetics whose values can be tuples
246245
# 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
252249

253250
# This should catch the aesthetic assignments to
254251
# non-numeric or non-string values or sequence of values.

0 commit comments

Comments
 (0)