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

Class Composite

source code

                        object --+        
                                 |        
 param.parameterized.Parameterized --+    
                                     |    
base.patterngenerator.PatternGenerator --+
                                         |
                                        Composite
Known Subclasses:

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 param.parameterized.Parameterized: __metaclass__

Instance Methods [hide private]
 
__init__(self, **params)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_advance_pattern_generators(self, generators)
Subclasses can override this method to provide constraints on the values of generators' 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 param.parameterized.Parameterized: __getstate__, __repr__, __setstate__, __str__, debug, defaults, force_new_dynamic_value, get_param_values, get_value_generator, inspect_value, message, print_param_values, script_repr, set_dynamic_time_fn, state_pop, state_push, verbose, warning

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

Class Methods [hide private]

Inherited from param.parameterized.Parameterized: params, print_param_defaults

Class Variables [hide private]
  generators = param.List(default= [Constant(scale= 0.0)], prece...
List of patterns to use in the composite pattern.
  operator = param.Parameter(numpy.maximum, precedence= 0.98, do...
Binary Numpy function used to combine the individual patterns.
  size = param.Number(default= 1.0, doc= "Scaling factor applied...
Scaling factor applied to all sub-patterns.

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

Inherited from param.parameterized.Parameterized: name, print_level

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, **params)
(Constructor)

source code 
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
Overrides: object.__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]

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:
param.List(default= [Constant(scale= 0.0)], precedence= 0.97, class_= PatternGener\
ator, 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.""")

operator

Binary Numpy function used to combine the individual patterns.

Any binary Numpy 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:
param.Parameter(numpy.maximum, precedence= 0.98, doc= """
        Binary Numpy function used to combine the individual patterns.

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

          add
...

size

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