Skip to content

Commit

Permalink
Remove deprecated function '__get_subclass_instance'
Browse files Browse the repository at this point in the history
  • Loading branch information
lzkelley committed Jan 30, 2024
1 parent 6ef08f5 commit 81f1445
Showing 1 changed file with 0 additions and 47 deletions.
47 changes: 0 additions & 47 deletions holodeck/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 81f1445

Please sign in to comment.