Package topo :: Package patterns :: Module basic :: Class Composite
[hide private]
[frames] | no frames]

Class Composite

source code

                                  object --+        
                                           |        
base.parameterizedobject.ParameterizedObject --+    
                                               |    
          base.patterngenerator.PatternGenerator --+
                                                   |
                                                  Composite
Known Subclasses:
SeparatedComposite

PatternGenerator that accepts a list of other PatternGenerators. To create a new pattern, asks each of the PatternGenerators in the list to create a pattern, then it combines the patterns to create a single pattern that it returns.

Nested Classes [hide private]

Inherited from base.parameterizedobject.ParameterizedObject: __metaclass__

Instance Methods [hide private]
 
__init__(self, **params)
Initialize this ParameterizedObject.
source code
 
_advance_pattern_generators(self, generators)
Subclasses can override this method to provide constraints on the values of genertators' parameters and/or eliminate generators from this list if necessary.
source code
 
function(self, params)
Constructs combined pattern out of the individual ones.
source code

Inherited from base.patterngenerator.PatternGenerator: __call__

Inherited from base.parameterizedobject.ParameterizedObject: __getstate__, __repr__, __setstate__, __str__, as_uninitialized, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, script_repr, verbose, warning

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__

Class Methods [hide private]

Inherited from base.parameterizedobject.ParameterizedObject: params, print_param_defaults

Class Variables [hide private]
  operator = <topo.base.parameterizedobject.Parameter object at ...
Binary Numeric function used to combine the individual patterns.
  generators = <topo.base.parameterclasses.ListParameter object ...
List of patterns to use in the composite pattern.
  size = Number(default= 1.0, doc= "Scaling factor applied to al...
Scaling factor applied to all sub-patterns.

Inherited from base.patterngenerator.PatternGenerator: bounds, mask, offset, orientation, output_fn, position, scale, x, xdensity, y, ydensity

Inherited from base.parameterizedobject.ParameterizedObject: name, print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **params)
(Constructor)

source code 

Initialize this ParameterizedObject.

The values of parameters can be supplied as keyword arguments to the constructor (using parametername=parametervalue); these values will override the class default values for this one instance.

If no 'name' parameter is supplied, self.name defaults to the object's class name with a unique number appended to it.

Overrides: base.parameterizedobject.ParameterizedObject.__init__
(inherited documentation)

function(self, params)

source code 
Constructs combined pattern out of the individual ones.
Overrides: base.patterngenerator.PatternGenerator.function

Class Variable Details [hide private]

operator

Binary Numeric function used to combine the individual patterns.

Any binary Numeric array "ufunc" returning the same type of array as the operands and supporting the reduce operator is allowed here. Supported ufuncs include:

add
subtract
multiply
divide
maximum
minimum
remainder
power
logical_and
logical_or
logical_xor

The most useful ones are probably add and maximum, but there are uses for at least some of the others as well (e.g. to remove pieces of other patterns).

You can also write your own operators, by making a class that has a static method named "reduce" that returns an array of the same size and type as the arrays in the list. For example:

class return_first(object):
    @staticmethod
    def reduce(x):
        return x[0]
Value:
Parameter(numpy.maximum, precedence= 0.98, doc= """
        Binary Numeric function used to combine the individual patterns.

        Any binary Numeric array "ufunc" returning the same
        type of array as the operands and supporting the reduce
        operator is allowed here.  Supported ufuncs include::

          add
...

generators

List of patterns to use in the composite pattern. The default is a blank pattern, and should thus be overridden for any useful work.
Value:
ListParameter(default= [Constant(scale= 0.0)], precedence= 0.97, class_= PatternGe\
nerator, doc= """
        List of patterns to use in the composite pattern.  The default is
        a blank pattern, and should thus be overridden for any useful work.""")

size

Scaling factor applied to all sub-patterns.
Value:
Number(default= 1.0, doc= "Scaling factor applied to all sub-patterns.")