|
12 | 12 | remove_missing, |
13 | 13 | uniquecols, |
14 | 14 | ) |
15 | | -from .._utils.registry import Register, Registry |
16 | | -from ..exceptions import PlotnineError |
| 15 | +from .._utils.registry import Register |
17 | 16 | from ..layer import layer |
18 | 17 | from ..mapping import aes |
19 | 18 |
|
|
22 | 21 |
|
23 | 22 | from plotnine import ggplot |
24 | 23 | from plotnine.facets.layout import Layout |
25 | | - from plotnine.geoms.geom import geom |
26 | 24 | from plotnine.iapi import pos_scales |
27 | 25 | from plotnine.mapping import Environment |
28 | 26 | from plotnine.typing import DataLike |
@@ -82,52 +80,6 @@ def __init__( |
82 | 80 | ae: kwargs[ae] for ae in self.aesthetics() & set(kwargs) |
83 | 81 | } |
84 | 82 |
|
85 | | - @staticmethod |
86 | | - def from_geom(geom: geom) -> stat: |
87 | | - """ |
88 | | - Return an instantiated stat object |
89 | | -
|
90 | | - stats should not override this method. |
91 | | -
|
92 | | - Parameters |
93 | | - ---------- |
94 | | - geom : |
95 | | - A geom object |
96 | | -
|
97 | | - Returns |
98 | | - ------- |
99 | | - stat |
100 | | - A stat object |
101 | | -
|
102 | | - Raises |
103 | | - ------ |
104 | | - [](`~plotnine.exceptions.PlotnineError`) if unable to create a `stat`. |
105 | | - """ |
106 | | - name = geom.params["stat"] |
107 | | - kwargs = geom._raw_kwargs |
108 | | - # More stable when reloading modules than |
109 | | - # using issubclass |
110 | | - if not isinstance(name, type) and hasattr(name, "compute_layer"): |
111 | | - return name |
112 | | - |
113 | | - if isinstance(name, stat): |
114 | | - return name |
115 | | - elif isinstance(name, type) and issubclass(name, stat): |
116 | | - klass = name |
117 | | - elif isinstance(name, str): |
118 | | - if not name.startswith("stat_"): |
119 | | - name = f"stat_{name}" |
120 | | - klass = Registry[name] |
121 | | - else: |
122 | | - raise PlotnineError(f"Unknown stat of type {type(name)}") |
123 | | - |
124 | | - valid_kwargs = ( |
125 | | - klass.aesthetics() | klass.DEFAULT_PARAMS.keys() |
126 | | - ) & kwargs.keys() |
127 | | - |
128 | | - params = {k: kwargs[k] for k in valid_kwargs} |
129 | | - return klass(geom=geom, **params) |
130 | | - |
131 | 83 | def __deepcopy__(self, memo: dict[Any, Any]) -> stat: |
132 | 84 | """ |
133 | 85 | Deep copy without copying the self.data dataframe |
|
0 commit comments