@@ -176,11 +176,41 @@ def clone(self):
176
176
------
177
177
RuntimeError if the clone is non-conforming, due to faulty ``__init__``.
178
178
"""
179
- self_clone = _clone (self , base_cls = BaseObject )
179
+ # get plugins for cloning, if present (empty by default)
180
+ clone_plugins = self ._get_clone_plugins ()
181
+
182
+ # clone the object
183
+ self_clone = _clone (self , base_cls = BaseObject , clone_plugins = clone_plugins )
184
+
185
+ # check the clone, if check_clone is set (False by default)
180
186
if self .get_config ()["check_clone" ]:
181
187
_check_clone (original = self , clone = self_clone )
188
+
189
+ # return the clone
182
190
return self_clone
183
191
192
+ @classmethod
193
+ def _get_clone_plugins (cls ):
194
+ """Get clone plugins for BaseObject.
195
+
196
+ Can be overridden in subclasses to add custom clone plugins.
197
+
198
+ If implemented, must return a list of clone plugins for descendants.
199
+
200
+ Plugins are loaded ahead of the default plugins, and are used in the order
201
+ they are returned.
202
+ This allows extenders to override the default behaviours, if desired.
203
+
204
+ Returns
205
+ -------
206
+ list of str
207
+ List of clone plugins for descendants.
208
+ Each plugin must inherit from ``BaseCloner``
209
+ in ``skbase.base._clone_plugins``, and implement
210
+ the methods ``_check`` and ``_clone``.
211
+ """
212
+ return None
213
+
184
214
@classmethod
185
215
def _get_init_signature (cls ):
186
216
"""Get class init signature.
0 commit comments