BasicRegistrationFactory
- class plasmapy.utils.datatype_factory_base.BasicRegistrationFactory(
- default_widget_type=None,
- additional_validation_functions=None,
- registry=None,
Bases:
objectGeneralized registrable factory type.
Widgets (classes) can be registered with an instance of this class. Arguments to the factory’s
__call__method are then passed to a function specified by the registered factory, which validates the input and returns a instance of the class that best matches the inputs.Attention
This feature is under development. Breaking changes may occur in the future.
- Parameters:
Notes
A valid validation function must be a
classmethodof the registered widget and must returnTrueorFalse.Methods Summary
__call__(*args, **kwargs)Method for running the factory.
register(WidgetType[, validation_function, ...])Register a widget with the factory.
unregister(WidgetType)Remove a widget from the factory's registry.
Methods Documentation
- __call__(*args, **kwargs)[source]
Method for running the factory.
Arguments args and kwargs are passed through to the validation function and to the constructor for the final type.
- register(
- WidgetType,
- validation_function=None,
- is_default: bool = False,
Register a widget with the factory.
If
validation_functionis not specified, testsWidgetTypefor existence of any function in thevalidation_functionsattribute, which is a list of strings which must be callable class attributes.- Parameters:
WidgetType (
type) – Widget to register.validation_function (function, optional) – Function to validate against. Defaults to
None, which indicates that aclassmethodin thevalidation_functionsattribute is used.is_default (
bool, optional) – SetsWidgetTypeto be the default widget.