From 81f1445d24e397a2032d178506164e8687653f09 Mon Sep 17 00:00:00 2001 From: Luke Zoltan Kelley Date: Tue, 30 Jan 2024 15:03:14 -0800 Subject: [PATCH] Remove deprecated function '__get_subclass_instance' --- holodeck/utils.py | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/holodeck/utils.py b/holodeck/utils.py index 9420f16c..9853f78f 100644 --- a/holodeck/utils.py +++ b/holodeck/utils.py @@ -2372,53 +2372,6 @@ def scatter_redistribute(cents, dist, dens, axis=0): pass -@deprecated_pass(get_subclass_instance) -def _get_subclass_instance(value, default, superclass): - """Convert the given `value` into a subclass instance. - - `None` ==> instance from `default` class - Class ==> instance from that class - instance ==> check that this is an instance of a subclass of `superclass`, error if not - - Parameters - ---------- - value : object, - Object to convert into a class instance. - default : class, - Default class constructor to use if `value` is None. - superclass : class, - Super/parent class to compare against the class instance from `value` or `default`. - If the class instance is not a subclass of `superclass`, a ValueError is raised. - - Returns - ------- - value : object, - Class instance that is a subclass of `superclass`. - - Raises - ------ - ValueError : if the class instance is not a subclass of `superclass`. - - """ - import inspect - - # Set `value` to a default, if needed and it is given - if (value is None) and (default is not None): - value = default - - # If `value` is a class (constructor), then construct an instance from it - if inspect.isclass(value): - value = value() - - # Raise an error if `value` is not a subclass of `superclass` - if not isinstance(value, superclass): - err = f"argument ({value}) must be an instance or subclass of `{superclass}`!" - log.error(err) - raise ValueError(err) - - return value - - #! DEPRECATED def nyquist_freqs(dur, cad): """DEPRECATED. Use `holodeck.utils.pta_freqs` instead.