find_subclass

  • full name: tenpy.tools.misc.find_subclass

  • parent module: tenpy.tools.misc

  • type: function

tenpy.tools.misc.find_subclass(base_class, subclass_name)[source]

For a given base class, recursively find the subclass with the given name.

Parameters:
  • base_class (class) – The base class of which subclass_name is supposed to be a subclass.

  • subclass_name (str | type) – The name (str) of the class to be found. Alternatively, if a type is given, it is directly returned. In that case, a warning is raised if it is not a subclass of base_class.

Returns:

subclass – Class with name subclass_name which is a subclass of the base_class. None, if no subclass of the given name is found.

Return type:

class

Raises:

ValueError – When no or multiple subclasses of base_class exists with that subclass_name.: