LSSTApplications
10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
|
Public Member Functions | |
def | __init__ |
def | register |
def | __getitem__ |
def | __len__ |
def | __iter__ |
def | __contains__ |
def | makeField |
Private Attributes | |
_configBaseType | |
_dict | |
A base class for global registries, mapping names to configurables. There are no hard requirements on configurable, but they typically create an algorithm or are themselves the algorithm, and typical usage is as follows: - configurable is a callable whose call signature is (config, ...extra arguments...) - All configurables added to a particular registry will have the same call signature - All configurables in a registry will typically share something important in common. For example all configurables in psfMatchingRegistry return a psf matching class that has a psfMatch method with a particular call signature. A registry acts like a read-only dictionary with an additional register method to add items. The dict contains configurables and each configurable has an instance ConfigClass. Example: registry = Registry() class FooConfig(Config): val = Field(dtype=int, default=3, doc="parameter for Foo") class Foo(object): ConfigClass = FooConfig def __init__(self, config): self.config = config def addVal(self, num): return self.config.val + num registry.register("foo", Foo) names = registry.keys() # returns ("foo",) fooConfigurable = registry["foo"] fooConfig = fooItem.ConfigClass() foo = fooConfigurable(fooConfig) foo.addVal(5) # returns config.val + 5
Definition at line 44 of file registry.py.
def lsst.pex.config.registry.Registry.__init__ | ( | self, | |
configBaseType = Config |
|||
) |
Construct a registry of name: configurables @param configBaseType: base class for config classes in registry
Definition at line 76 of file registry.py.
def lsst.pex.config.registry.Registry.__contains__ | ( | self, | |
key | |||
) |
Definition at line 113 of file registry.py.
def lsst.pex.config.registry.Registry.__getitem__ | ( | self, | |
key | |||
) |
Definition at line 110 of file registry.py.
def lsst.pex.config.registry.Registry.__iter__ | ( | self | ) |
Definition at line 112 of file registry.py.
def lsst.pex.config.registry.Registry.__len__ | ( | self | ) |
Definition at line 111 of file registry.py.
def lsst.pex.config.registry.Registry.makeField | ( | self, | |
doc, | |||
default = None , |
|||
optional = False , |
|||
multi = False |
|||
) |
Definition at line 115 of file registry.py.
def lsst.pex.config.registry.Registry.register | ( | self, | |
name, | |||
target, | |||
ConfigClass = None |
|||
) |
Add a new item to the registry. @param target A callable 'object that takes a Config instance as its first argument. This may be a Python type, but is not required to be. @param ConfigClass A subclass of pex_config Config used to configure the configurable; if None then configurable.ConfigClass is used. @note: If ConfigClass is provided then then 'target' is wrapped in a new object that forwards function calls to it. Otherwise the original 'target' is stored. @raise AttributeError if ConfigClass is None and target does not have attribute ConfigClass
Definition at line 86 of file registry.py.
|
private |
Definition at line 83 of file registry.py.
|
private |
Definition at line 84 of file registry.py.