示例#1
0
def ConvCnstrMODOptions(opt=None, method='cns'):
    """A wrapper function that dynamically defines a class derived from
    the Options class associated with one of the implementations of
    the Convolutional Constrained MOD problem, and returns an object
    instantiated with the provided parameters. The wrapper is designed
    to allow the appropriate object to be created by calling this
    function using the same syntax as would be used if it were a
    class. The specific implementation is selected by use of an
    additional keyword argument 'method'. Valid values are as
    specified in the documentation for :func:`ConvCnstrMOD`.
    """

    # Assign base class depending on method selection argument
    if method == 'ism':
        base = ConvCnstrMOD_IterSM.Options
    elif method == 'cg':
        base = ConvCnstrMOD_CG.Options
    elif method == 'cns':
        base = ConvCnstrMOD_Consensus.Options
    else:
        raise ValueError('Unknown ConvCnstrMOD solver method %s' % method)

    # Nested class with dynamically determined inheritance
    class ConvCnstrMODOptions(base):
        def __init__(self, opt):
            super(ConvCnstrMODOptions, self).__init__(opt)

    # Allow pickling of objects of type ConvCnstrMODOptions
    _fix_dynamic_class_lookup(ConvCnstrMODOptions, method)

    # Return object of the nested class type
    return ConvCnstrMODOptions(opt)
示例#2
0
def ConvBPDNMask(*args, **kwargs):
    """A wrapper function that dynamically defines a class derived from
    one of the implementations of the Convolutional Constrained MOD
    problems, and returns an object instantiated with the provided
    parameters. The wrapper is designed to allow the appropriate
    object to be created by calling this function using the same
    syntax as would be used if it were a class. The specific
    implementation is selected by use of an additional keyword
    argument 'method'. Valid values are:

    - ``'admm'`` :
      Use the implementation defined in :class:`.admm.cbpdn.ConvBPDNMaskDcpl`.
    - ``'pgm'`` :
      Use the implementation defined in :class:`.pgm.cbpdn.ConvBPDNMask`.

    The default value is ``'admm'``.
    """

    # Extract method selection argument or set default
    method = kwargs.pop('method', 'admm')

    # Assign base class depending on method selection argument
    base = cbpdnmsk_class_label_lookup(method)

    # Nested class with dynamically determined inheritance
    class ConvBPDNMask(base):
        def __init__(self, *args, **kwargs):
            super(ConvBPDNMask, self).__init__(*args, **kwargs)

    # Allow pickling of objects of type ConvBPDNMask
    _fix_dynamic_class_lookup(ConvBPDNMask, method)

    # Return object of the nested class type
    return ConvBPDNMask(*args, **kwargs)
示例#3
0
文件: ccmod.py 项目: bwohlberg/sporco
def ConvCnstrMODOptions(opt=None, method='cns'):
    """A wrapper function that dynamically defines a class derived from
    the Options class associated with one of the implementations of
    the Convolutional Constrained MOD problem, and returns an object
    instantiated with the provided parameters. The wrapper is designed
    to allow the appropriate object to be created by calling this
    function using the same syntax as would be used if it were a
    class. The specific implementation is selected by use of an
    additional keyword argument 'method'. Valid values are as
    specified in the documentation for :func:`ConvCnstrMOD`.
    """

    # Assign base class depending on method selection argument
    if method == 'ism':
        base = ConvCnstrMOD_IterSM.Options
    elif method == 'cg':
        base = ConvCnstrMOD_CG.Options
    elif method == 'cns':
        base = ConvCnstrMOD_Consensus.Options
    else:
        raise ValueError('Unknown ConvCnstrMOD solver method %s' % method)

    # Nested class with dynamically determined inheritance
    class ConvCnstrMODOptions(base):
        def __init__(self, opt):
            super(ConvCnstrMODOptions, self).__init__(opt)

    # Allow pickling of objects of type ConvCnstrMODOptions
    _fix_dynamic_class_lookup(ConvCnstrMODOptions, method)

    # Return object of the nested class type
    return ConvCnstrMODOptions(opt)
示例#4
0
def ConvBPDNMaskOptions(opt=None, method='admm'):
    """A wrapper function that dynamically defines a class derived from
    the Options class associated with one of the implementations of
    the Convolutional BPDN problem, and returns an object
    instantiated with the provided parameters. The wrapper is designed
    to allow the appropriate object to be created by calling this
    function using the same syntax as would be used if it were a
    class. The specific implementation is selected by use of an
    additional keyword argument 'method'. Valid values are as
    specified in the documentation for :func:`ConvBPDN`.
    """

    # Assign base class depending on method selection argument
    base = cbpdnmsk_class_label_lookup(method).Options

    # Nested class with dynamically determined inheritance
    class ConvBPDNMaskOptions(base):
        def __init__(self, opt):
            super(ConvBPDNMaskOptions, self).__init__(opt)

    # Allow pickling of objects of type ConvBPDNOptions
    _fix_dynamic_class_lookup(ConvBPDNMaskOptions, method)

    # Return object of the nested class type
    return ConvBPDNMaskOptions(opt)
示例#5
0
def ConvBPDN(*args, **kwargs):
    """A wrapper function that dynamically defines a class derived from
    one of the implementations of the Convolutional Constrained MOD
    problems, and returns an object instantiated with the provided
    parameters. The wrapper is designed to allow the appropriate
    object to be created by calling this function using the same
    syntax as would be used if it were a class. The specific
    implementation is selected by use of an additional keyword
    argument 'method'. Valid values are:

    - ``'admm'`` :
      Use the implementation defined in :class:`.admm.cbpdn.ConvBPDN`.
    - ``'fista'`` :
      Use the implementation defined in :class:`.fista.cbpdn.ConvBPDN`.

    The default value is ``'admm'``.
    """

    # Extract method selection argument or set default
    method = kwargs.pop('method', 'admm')

    # Assign base class depending on method selection argument
    base = cbpdn_class_label_lookup(method)

    # Nested class with dynamically determined inheritance
    class ConvBPDN(base):
        def __init__(self, *args, **kwargs):
            super(ConvBPDN, self).__init__(*args, **kwargs)

    # Allow pickling of objects of type ConvBPDN
    _fix_dynamic_class_lookup(ConvBPDN, method)

    # Return object of the nested class type
    return ConvBPDN(*args, **kwargs)
示例#6
0
def ConvBPDNOptions(opt=None, method='admm'):
    """A wrapper function that dynamically defines a class derived from
    the Options class associated with one of the implementations of
    the Convolutional BPDN problem, and returns an object
    instantiated with the provided parameters. The wrapper is designed
    to allow the appropriate object to be created by calling this
    function using the same syntax as would be used if it were a
    class. The specific implementation is selected by use of an
    additional keyword argument 'method'. Valid values are as
    specified in the documentation for :func:`ConvBPDN`.
    """

    # Assign base class depending on method selection argument
    base = cbpdn_class_label_lookup(method).Options

    # Nested class with dynamically determined inheritance
    class ConvBPDNOptions(base):
        def __init__(self, opt):
            super(ConvBPDNOptions, self).__init__(opt)

    # Allow pickling of objects of type ConvBPDNOptions
    _fix_dynamic_class_lookup(ConvBPDNOptions, method)

    # Return object of the nested class type
    return ConvBPDNOptions(opt)
示例#7
0
def ConvCnstrMODMaskDcpl(*args, **kwargs):
    """A wrapper function that dynamically defines a class derived from
    one of the implementations of the Convolutional Constrained MOD
    with Mask Decoupling problems, and returns an object instantiated
    with the provided. parameters. The wrapper is designed to allow the
    appropriate object to be created by calling this function using the
    same syntax as would be used if it were a class. The specific
    implementation is selected by use of an additional keyword
    argument 'method'. Valid values are:

    - ``'ism'`` :
      Use the implementation defined in :class:`.ConvCnstrMODMaskDcpl_IterSM`.
      This method works well for a small number of training images, but is
      very slow for larger training sets.
    - ``'cg'`` :
      Use the implementation defined in :class:`.ConvCnstrMODMaskDcpl_CG`.
      This method is slower than ``'ism'`` for small training sets, but has
      better run time scaling as the training set grows.
    - ``'cns'`` :
      Use the implementation defined in
      :class:`.ConvCnstrMODMaskDcpl_Consensus`. This method is the best choice
      for large training sets.

    The default value is ``'cns'``.
    """

    # Extract method selection argument or set default
    if 'method' in kwargs:
        method = kwargs['method']
        del kwargs['method']
    else:
        method = 'cns'

    # Assign base class depending on method selection argument
    if method == 'ism':
        base = ConvCnstrMODMaskDcpl_IterSM
    elif method == 'cg':
        base = ConvCnstrMODMaskDcpl_CG
    elif method == 'cns':
        base = ConvCnstrMODMaskDcpl_Consensus
    else:
        raise ValueError('Unknown ConvCnstrMODMaskDcpl solver method %s' %
                         method)

    # Nested class with dynamically determined inheritance
    class ConvCnstrMODMaskDcpl(base):
        def __init__(self, *args, **kwargs):
            super(ConvCnstrMODMaskDcpl, self).__init__(*args, **kwargs)

    # Allow pickling of objects of type ConvCnstrMODMaskDcpl
    _fix_dynamic_class_lookup(ConvCnstrMODMaskDcpl, method)

    # Return object of the nested class type
    return ConvCnstrMODMaskDcpl(*args, **kwargs)
示例#8
0
def ConvCnstrMODMaskDcpl(*args, **kwargs):
    """A wrapper function that dynamically defines a class derived from
    one of the implementations of the Convolutional Constrained MOD
    with Mask Decoupling problems, and returns an object instantiated
    with the provided. parameters. The wrapper is designed to allow the
    appropriate object to be created by calling this function using the
    same syntax as would be used if it were a class. The specific
    implementation is selected by use of an additional keyword
    argument 'method'. Valid values are:

    - ``'ism'`` :
      Use the implementation defined in :class:`.ConvCnstrMODMaskDcpl_IterSM`.
      This method works well for a small number of training images, but is
      very slow for larger training sets.
    - ``'cg'`` :
      Use the implementation defined in :class:`.ConvCnstrMODMaskDcpl_CG`.
      This method is slower than ``'ism'`` for small training sets, but has
      better run time scaling as the training set grows.
    - ``'cns'`` :
      Use the implementation defined in
      :class:`.ConvCnstrMODMaskDcpl_Consensus`. This method is the best choice
      for large training sets.

    The default value is ``'cns'``.
    """

    # Extract method selection argument or set default
    if 'method' in kwargs:
        method = kwargs['method']
        del kwargs['method']
    else:
        method = 'cns'

    # Assign base class depending on method selection argument
    if method == 'ism':
        base = ConvCnstrMODMaskDcpl_IterSM
    elif method == 'cg':
        base = ConvCnstrMODMaskDcpl_CG
    elif method == 'cns':
        base = ConvCnstrMODMaskDcpl_Consensus
    else:
        raise ValueError('Unknown ConvCnstrMODMaskDcpl solver method %s'
                         % method)

    # Nested class with dynamically determined inheritance
    class ConvCnstrMODMaskDcpl(base):
        def __init__(self, *args, **kwargs):
            super(ConvCnstrMODMaskDcpl, self).__init__(*args, **kwargs)

    # Allow pickling of objects of type ConvCnstrMODMaskDcpl
    _fix_dynamic_class_lookup(ConvCnstrMODMaskDcpl, method)

    # Return object of the nested class type
    return ConvCnstrMODMaskDcpl(*args, **kwargs)
示例#9
0
def ConvCnstrMODMask(*args, **kwargs):
    """A wrapper function that dynamically defines a class derived from
    one of the implementations of the Convolutional Constrained MOD
    problems, and returns an object instantiated with the provided
    parameters. The wrapper is designed to allow the appropriate
    object to be created by calling this function using the same
    syntax as would be used if it were a class. The specific
    implementation is selected by use of an additional keyword
    argument 'method'. Valid values are:

    - ``'ism'`` :
      Use the implementation defined in :class:`.ConvCnstrMODMaskDcpl_IterSM`.
      This method works well for a small number of training images, but is
      very slow for larger training sets.
    - ``'cg'`` :
      Use the implementation defined in :class:`.ConvCnstrMODMaskDcpl_CG`.
      This method is slower than ``'ism'`` for small training sets, but has
      better run time scaling as the training set grows.
    - ``'cns'`` :
      Use the implementation defined in
      :class:`.ConvCnstrMODMaskDcpl_Consensus`.
      This method is a good choice for large training sets.
    - ``'pgm'`` :
      Use the implementation defined in :class:`.pgm.ccmod.ConvCnstrMODMask`.
      This method is the best choice for large training sets.

    The default value is ``'pgm'``.
    """

    # Extract method selection argument or set default
    method = kwargs.pop('method', 'pgm')

    # Assign base class depending on method selection argument
    base = ccmodmsk_class_label_lookup(method)

    # Nested class with dynamically determined inheritance
    class ConvCnstrMODMask(base):
        def __init__(self, *args, **kwargs):
            super(ConvCnstrMODMask, self).__init__(*args, **kwargs)

    # Allow pickling of objects of type ConvCnstrMODMask
    _fix_dynamic_class_lookup(ConvCnstrMODMask, method)

    # Return object of the nested class type
    return ConvCnstrMODMask(*args, **kwargs)
示例#10
0
def ConvCnstrMOD(*args, **kwargs):
    """A wrapper function that dynamically defines a class derived from
    one of the implementations of the Convolutional Constrained MOD
    problems, and returns an object instantiated with the provided
    parameters. The wrapper is designed to allow the appropriate
    object to be created by calling this function using the same
    syntax as would be used if it were a class. The specific
    implementation is selected by use of an additional keyword
    argument 'method'. Valid values are:

    - ``'ism'`` :
      Use the implementation defined in :class:`.ConvCnstrMOD_IterSM`. This
      method works well for a small number of training images, but is very
      slow for larger training sets.
    - ``'cg'`` :
      Use the implementation defined in :class:`.ConvCnstrMOD_CG`. This
      method is slower than ``'ism'`` for small training sets, but has better
      run time scaling as the training set grows.
    - ``'cns'`` :
      Use the implementation defined in :class:`.ConvCnstrMOD_Consensus`.
      This method is a good choice for large training sets.
    - ``'fista'`` :
      Use the implementation defined in :class:`.fista.ccmod.ConvCnstrMOD`.
      This method is the best choice for large training sets.

    The default value is ``'fista'``.
    """

    # Extract method selection argument or set default
    method = kwargs.pop('method', 'fista')

    # Assign base class depending on method selection argument
    base = ccmod_class_label_lookup(method)

    # Nested class with dynamically determined inheritance
    class ConvCnstrMOD(base):
        def __init__(self, *args, **kwargs):
            super(ConvCnstrMOD, self).__init__(*args, **kwargs)

    # Allow pickling of objects of type ConvCnstrMOD
    _fix_dynamic_class_lookup(ConvCnstrMOD, method)

    # Return object of the nested class type
    return ConvCnstrMOD(*args, **kwargs)