imagen.imagen Package


imagen Package

Inheritance diagram of imagen.__init__

Objects capable of generating a two-dimensional array of values.

Such patterns can be used as input to machine learning, neural network, or compuatational neuroscience algorithms, or for any other purpose where a two-dimensional pattern may be needed. Any new PatternGenerator classes can be derived from these, and can then be combined with the existing classes easily.

class imagen.__init__.Angle(**params)[source]

Bases: imagen.patterngenerator.Composite

Angle composed of two line segments.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number angle (allow_None=False, bounds=(0.0, None), constant=False, default=0.785398163397, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.63, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Angle between the two line segments.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness of the rectangle.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.015, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off around the rectangles.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.01, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Overall diameter of the pattern, if angle=pi.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d4c8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d368>
inspect_value = <functools.partial object at 0x2adfbaf6d520>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d5d0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d3c0>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.OrientationContrast(**params)[source]

Bases: imagen.__init__.SineGrating

Circular pattern for testing responses to differences in contrast.

The pattern contains a sine grating ring surrounding a sine grating disk, each with parameters (orientation, size, scale and offset) that can be changed independently.

param Number orientationsurround (allow_None=False, bounds=(-6.283185307179586, 6.283185307179586), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Orientation of the surround grating, either absolute or relative to the central grating.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number frequency (allow_None=False, bounds=(0.0, None), constant=False, default=2.4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.5, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Frequency of the sine grating.
param Number orientationcenter (allow_None=False, bounds=(0.0, 6.283185307179586), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Orientation of the center grating.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the ring.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number scalesurround (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scale of the surround grating.
param Number scalecenter (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scale of the center grating.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number offsetsurround (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Offset of the surround grating.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.3, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the ring.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number sizecenter (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the center grating.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number sizesurround (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the surround grating.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Number phase (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.51, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Phase of the sine grating.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the overall width.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number offsetcenter (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Offset of the center grating.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Boolean surround_orientation_relative (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Determines whether the surround grating is relative to the central grating.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d0a8>
function(p)

Return a sine grating pattern (two-dimensional sine wave).

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d1b0>
inspect_value = <functools.partial object at 0x2adfbaf6d578>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d628>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d260>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Spiral(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Archimedean spiral. Successive turnings of the spiral have a constant separation distance.

Spiral is defined by polar equation r=size*angle plotted in Gaussian plane.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.02, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the spiral.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number turning (allow_None=False, bounds=(0.01, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density of turnings; turning*angle gives the actual radius.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the spiral.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d158>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d5d0>
inspect_value = <functools.partial object at 0x2adfbaf6d310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d4c8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d470>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.SigmoidedDoLG(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Sigmoid multiplicatively combined with a difference of Log Gaussians, such that one part of the plane can be the mirror image of the other, and the peaks of the gaussians are movable.

param Number positive_size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the positive LogGaussian pattern.
param Number positive_scale (allow_None=False, bounds=(0.0, None), constant=False, default=1.5, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative scale for the positive LogGaussian pattern.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number sigmoid_position (allow_None=False, bounds=(None, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X position of the transition between the two regions.
param Number negative_scale (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative scale for the negative LogGaussian pattern.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number negative_x_shape (allow_None=False, bounds=(0.0, None), constant=False, default=0.8, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of the tail along the x axis for the negative LogGaussian pattern.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number negative_y_shape (allow_None=False, bounds=(0.0, None), constant=False, default=0.35, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of the tail along the y axis for the negative LogGaussian pattern.
param Number positive_aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height for the positive LogGaussian pattern.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number negative_aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=0.3, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height for the negative LogGaussian pattern.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number positive_y_shape (allow_None=False, bounds=(0.0, None), constant=False, default=0.35, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of the tail along the y axis for the positive LogGaussian pattern.
param Number negative_size (allow_None=False, bounds=(0.0, None), constant=False, default=0.8, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the negative LogGaussian pattern.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Number sigmoid_slope (allow_None=False, bounds=(None, None), constant=False, default=50.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Parameter controlling the smoothness of the transition between the two regions; high values give a sharp transition.
param Number positive_x_shape (allow_None=False, bounds=(0.0, None), constant=False, default=0.8, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of the tail along the x axis for the positive LogGaussian pattern.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d628>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d470>
inspect_value = <functools.partial object at 0x2adfbaf6d520>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d368>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d0a8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Spectrogram(**params)[source]

Bases: imagen.__init__.PowerSpectrum

Extends PowerSpectrum to provide a temporal buffer, yielding a 2D representation of a fixed-width spectrogram.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Integer min_latency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest latency (in milliseconds) for which to return amplitudes.
param Integer max_frequency (allow_None=False, bounds=(0, None), constant=False, default=9999, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest frequency for which to return an amplitude.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=(0, None), constant=False, default=0.01, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The amount by which to scale amplitudes by. This is useful if we want to rescale to say a range [0:1]. Note: Constant scaling is preferable to dynamic scaling so as not to artificially ramp down loud sounds while ramping up hiss and other background interference.
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Integer min_frequency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest frequency for which to return an amplitude.
param Parameter windowing_function (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
This function is multiplied with the current interval, i.e. the most recent portion of the waveform interval of a signal, before performing the Fourier transform. It thus shapes the interval, which is otherwise always rectangular. The function chosen here dictates the tradeoff between resolving comparable signal strengths with similar frequencies, and resolving disparate signal strengths with dissimilar frequencies. numpy provides a number of options, e.g. bartlett, blackman, hamming, hanning, kaiser; see http://docs.scipy.org/doc/numpy/reference/routines.window.html You may also supply your own.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Integer max_latency (allow_None=False, bounds=(0, None), constant=False, default=500, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest latency (in milliseconds) for which to return amplitudes.
param TimeSeriesParam signal (allow_None=False, constant=False, default=<TimeSeries TimeSeries01037>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A TimeSeries object on which to perfom the Fourier Transform.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d158>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d208>
inspect_value = <functools.partial object at 0x2adfbaf6d4c8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d260>
set_param = <functools.partial object at 0x2adfbaf6d310>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.SpiralGrating(**params)[source]

Bases: imagen.patterngenerator.Composite

Grating pattern made from overlaid spirals.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the spiral.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the spiral.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Integer parts (allow_None=False, bounds=(1, None), constant=False, default=2, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of parts in the grating.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
param Number turning (allow_None=False, bounds=(0.01, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density of turnings; turning*angle gives the actual radius.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d1b0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d2b8>
inspect_value = <functools.partial object at 0x2adfbaf6d520>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d628>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d470>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.ArcCentered(**params)[source]

Bases: imagen.__init__.Arc

2D arc pattern generator (centered at the middle of the arc).

Draws an arc (partial ring) of the specified size (radius*2), with middle at radian 0.0 and starting at arc_length/2 and ending at -arc_length/2. The pattern is centered at the middle of the arc.

See the Disk class for a note about the Gaussian fall-off.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the overall width.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.015, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the ring.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the ring.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number arc_length (allow_None=False, bounds=(0.0, None), constant=False, default=3.14159265359, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Length of the arc, in radians, starting from orientation 0.0.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d310>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d260>
inspect_value = <functools.partial object at 0x2adfbaf6d520>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d470>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d208>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.PatternGenerator(**params)

Bases: param.parameterized.Parameterized

A class hierarchy for callable objects that can generate 2D patterns.

Once initialized, PatternGenerators can be called to generate a value or a matrix of values from a 2D function, typically accepting at least x and y.

A PatternGenerator’s Parameters can make use of Parameter’s precedence attribute to specify the order in which they should appear, e.g. in a GUI. The precedence attribute has a nominal range of 0.0 to 1.0, with ordering going from 0.0 (first) to 1.0 (last), but any value is allowed.

The orientation and layout of the pattern matrices is defined by the SheetCoordinateSystem class, which see.

Note that not every parameter defined for a PatternGenerator will be used by every subclass. For instance, a Constant pattern will ignore the x, y, orientation, and size parameters, because the pattern does not vary with any of those parameters. However, those parameters are still defined for all PatternGenerators, even Constant patterns, to allow PatternGenerators to be scaled, rotated, translated, etc. uniformly.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d520>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d0a8>
inspect_value = <functools.partial object at 0x2adfbaf6d4c8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d628>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d208>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Rectangle(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D rectangle pattern, with Gaussian smoothing around the edges.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width of the rectangle.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off outside the rectangle.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Height of the rectangle.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d680>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d310>
inspect_value = <functools.partial object at 0x2adfbaf6d260>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d2b8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d6d8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Sweeper(**params)[source]

Bases: imagen.patterngenerator.ChannelGenerator

PatternGenerator that sweeps a supplied PatternGenerator in a direction perpendicular to its orientation. Each time step, the supplied PatternGenerator is sweeped further at a fixed speed, and after reset_period time steps a new pattern is drawn.

param Number step_offset (allow_None=False, bounds=None, constant=False, default=0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The number of steps to offset the sweeper by.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number speed (allow_None=False, bounds=(0.0, None), constant=False, default=0.0833333333333, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The speed with which the pattern should move, in sheet coordinates per time_fn unit.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param ClassSelector generator (allow_None=False, constant=False, default=<Gaussian Gaussian01036>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.97, readonly=False)
Pattern to sweep.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number relative_motion_orientation (allow_None=False, bounds=(0, 6.283185307179586), constant=False, default=1.57079632679, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The direction in which the pattern should be moved, relative to the orientation of the supplied generator
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Function to generate the time used as a base for translation.
param Number reset_period (allow_None=False, bounds=(0, None), constant=False, default=4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Period between generating each new translation episode.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Number time_offset (allow_None=False, bounds=None, constant=False, default=0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The time offset from which frames are generated given the supplied pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d4c8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d628>
inspect_value = <functools.partial object at 0x2adfbaf6d470>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d1b0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d0a8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.DifferenceOfGaussians(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Two-dimensional difference of Gaussians pattern.

param Number positive_size (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the positive region of the pattern.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number positive_x (allow_None=False, bounds=(None, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X position for the central peak of the positive region.
param Number positive_y (allow_None=False, bounds=(None, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y position for the central peak of the positive region.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number negative_x (allow_None=False, bounds=(None, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=7, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X position for the central peak of the negative region.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number negative_aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height for the negative region of the pattern.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number negative_size (allow_None=False, bounds=(0.0, None), constant=False, default=0.3, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=5, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the negative region of the pattern.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number negative_y (allow_None=False, bounds=(None, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=8, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y position for the central peak of the negative region.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Number positive_aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height for the positive region of the pattern.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d310>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d2b8>
inspect_value = <functools.partial object at 0x2adfbaf6d5d0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6daa0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6dc00>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Composite(**params)

Bases: imagen.patterngenerator.CompositeBase

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.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d260>
function(p)

Constructs combined pattern out of the individual ones.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d100>
inspect_value = <functools.partial object at 0x2adfbaf6d5d0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d310>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d578>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Asterisk(**params)[source]

Bases: imagen.patterngenerator.Composite

Asterisk-like object composed of radial rectangular lines. Also makes crosses and tripods.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Integer parts (allow_None=False, bounds=(1, None), constant=False, default=3, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of parts in the asterisk.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness of the rectangle.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.015, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off around the rectangles.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.01, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Overall diameter of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d680>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d3c0>
inspect_value = <functools.partial object at 0x2adfbaf6d890>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d520>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d578>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Selector(**params)[source]

Bases: imagen.patterngenerator.CompositeBase

PatternGenerator that selects from a list of other PatternGenerators.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number index (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=<UniformRandom UniformRandom01035>, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Index into the list of pattern generators, on a scale from 0 (start of the list) to 1.0 (end of the list). Typically a random value or other number generator, to allow a different item to be selected each time.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)[source]

Get channel data from the current generator. use_cached is not supported at the moment, though it must be forced to be True in the current_generator in order to avoid generating the same data twice (the first time by self() and the second with current_generator.channels() ).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d5d0>
function(p)[source]

Selects and returns one of the patterns in the list.

get_current_generator()[source]

Return the current generator (as specified by self.index).

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d890>
inspect_value = <functools.partial object at 0x2adfbaf6d260>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()[source]

Get the number of channels in the input generators.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d578>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d838>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.ChannelGenerator(**params)

Bases: imagen.patterngenerator.PatternGenerator

Abstract base class for patterns supporting multiple channels natively.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d520>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d3c0>
inspect_value = <functools.partial object at 0x2adfbaf6d2b8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d838>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d890>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.ComposeChannels(**params)

Bases: imagen.patterngenerator.ChannelGenerator

Create a multi-channel PatternGenerator from a list of PatternGenerators, with the specified channel_transforms applied.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01031’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
List of patterns to use for each channel. Generators which already have more than one channel will only contribute to a single channel of ComposeChannels.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d158>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d730>
inspect_value = <functools.partial object at 0x2adfbaf6d2b8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6dcb0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d680>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.ExponentialDecay(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D Exponential pattern generator.

Exponential decay based on distance from a central peak, i.e. exp(-d), where d is the distance from the center (assuming size=1.0 and aspect_ratio==1.0). More generally, the size and aspect ratio determine the scaling of x and y dimensions:

yscale=size/2 xscale=yscale*aspect_ratio

The exponential is then computed for the given (x,y) values as:

exp(-sqrt((x/xscale)^2 - (y/yscale)^2))
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=3.22580645161, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of the width to the height.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.155, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Overall scaling of the x and y dimensions.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d208>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d838>
inspect_value = <functools.partial object at 0x2adfbaf6d890>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d520>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d158>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.HyperbolicGrating(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Concentric rectangular hyperbolas with Gaussian fall-off which share the same asymptotes. abs(x^2/a^2 - y^2/a^2) = 1, where a mod size = 0

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness of the hyperbolas.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the hyperbolas.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size as distance of inner hyperbola vertices from the centre.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6dcb0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d730>
inspect_value = <functools.partial object at 0x2adfbaf6d578>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d260>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d208>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Line(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D line pattern generator.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Boolean enforce_minimal_thickness (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False)
If True, ensure that the line is at least one pixel in width even for small thicknesses where the line could otherwise fall in between pixel centers and thus disappear at some orientations.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.006, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (width) of the solid central part of the line.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1.0, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d890>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d3c0>
inspect_value = <functools.partial object at 0x2adfbaf6d100>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d838>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d260>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.LogGaussian(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D Log Gaussian pattern generator allowing standard gaussian patterns but with the added advantage of movable peaks.

The spread governs decay rates from the peak of the Gaussian, mathematically this is the sigma term.

The center governs the peak position of the Gaussian, mathematically this is the mean term.

param Number x_shape (allow_None=False, bounds=(0.0, None), constant=False, default=0.8, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of the tail along the x axis.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number y_shape (allow_None=False, bounds=(0.0, None), constant=False, default=0.35, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of the tail along the y axis.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of the pattern’s width to height.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d578>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d788>
inspect_value = <functools.partial object at 0x2adfbaf6d208>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d838>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d260>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.SquareGrating(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D squarewave (symmetric or asymmetric) grating pattern generator.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number phase (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.51, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Phase of the square grating.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number frequency (allow_None=False, bounds=(0.0, None), constant=False, default=2.4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.5, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Frequency of the square grating.
param Number duty_cycle (allow_None=False, bounds=(0.0, 1.0), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.51, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The duty cycle is the ratio between the pulse duration (width of the bright bar) and the period (1/frequency). The pulse is defined as the time during which the square wave signal is 1 (high).
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d890>
function(p)[source]

Return a square-wave grating (alternating black and white bars).

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d208>
inspect_value = <functools.partial object at 0x2adfbaf6d158>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d5d0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d100>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Gabor(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D Gabor pattern generator.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of pattern width to height. The width of the Gaussian component is size*aspect_ratio (see Gaussian).
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number phase (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.51, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Phase of the sine grating component.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number frequency (allow_None=False, bounds=(0.0, None), constant=False, default=2.4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.5, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Frequency of the sine grating component.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.25, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the height of the Gaussian component (see Gaussian).
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d730>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d260>
inspect_value = <functools.partial object at 0x2adfbaf6d368>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d788>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d3c0>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.HalfPlane(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Constant pattern on in half of the plane, and off in the rest, with optional Gaussian smoothing.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.02, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d208>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d2b8>
inspect_value = <functools.partial object at 0x2adfbaf6d100>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d520>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d158>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.CompositeBase(**params)

Bases: imagen.patterngenerator.PatternGenerator

PatternGenerator that combines or selects from a list of other PatternGenerators.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d730>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d838>
inspect_value = <functools.partial object at 0x2adfbaf6d368>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d680>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d578>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Curve(**params)[source]

Bases: imagen.__init__.Arc

2D curve pattern generator.

Based on Arc, but centered on a tangent point midway through the arc, rather than at the center of a ring, and with curvature controlled directly rather than through the overall size of the pattern.

Depending on the size_type, the size parameter can control either the width of the pattern, keeping this constant regardless of curvature, or the length of the curve, keeping that constant instead (as for a long thin object being bent).

Specifically, for size_type==’constant_length’, the curvature parameter determines the ratio of height to width of the arc, with positive curvature for concave shape and negative for convex. The size parameter determines the width of the curve.

For size_type==’constant_width’, the curvature parameter determines the portion of curve radian to 2pi, and the curve radius is changed accordingly following the formula:

size=2pi*radius*curvature

Thus, the size parameter determines the total length of the curve. Positive curvature stands for concave shape, and negative for convex.

See the Disk class for a note about the Gaussian fall-off.

param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the ring.
param Number arc_length (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1.0, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Length of the arc, in radians, starting from orientation 0.0.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param ObjectSelector size_type (allow_None=None, check_on_set=True, compute_default_fn=None, constant=False, default=constant_length, instantiate=False, objects=[‘constant_length’, ‘constant_width’], pickle_default_value=True, precedence=0.61, readonly=False)
For a given size, whether to draw a curve with that total length, or with that width, keeping it constant as curvature is varied.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.015, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the ring.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number curvature (allow_None=False, bounds=(-0.5, 0.5), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of height to width of the arc, with positive value giving a concave shape and negative value giving convex.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1.0, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the overall width.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d100>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d3c0>
inspect_value = <functools.partial object at 0x2adfbaf6d310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d158>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d998>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.RadialGrating(**params)[source]

Bases: imagen.patterngenerator.Composite

Grating pattern made from alternating smooth circular segments (pie-shapes).

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Integer parts (allow_None=False, bounds=(1, None), constant=False, default=4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of parts in the grating.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.8, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off outside the sector, scaled by parts.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d838>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d680>
inspect_value = <functools.partial object at 0x2adfbaf6d310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d2b8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d368>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.ConcentricRings(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Concentric rings with linearly increasing radius. Gaussian fall-off at the edges.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.04, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the ring.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the rings.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.01, None), constant=False, default=0.4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Radius difference of neighbouring rings.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d5d0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d310>
inspect_value = <functools.partial object at 0x2adfbaf6d998>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d788>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d3c0>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.RawRectangle(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D rectangle pattern generator with no smoothing, for use when drawing patterns pixel by pixel.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width of the rectangle.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Height of the rectangle.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d5d0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d2b8>
inspect_value = <functools.partial object at 0x2adfbaf6d940>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d520>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d838>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Wedge(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

A sector of a circle with Gaussian fall-off, with size determining the arc length.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off outside the sector.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.785398163397, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Angular length of the sector, in radians.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d100>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d158>
inspect_value = <functools.partial object at 0x2adfbaf6d7e0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d998>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d368>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Constant(**params)

Bases: imagen.patterngenerator.PatternGenerator

Constant pattern generator, i.e., a solid, uniform field of the same value.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d2b8>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d3c0>
inspect_value = <functools.partial object at 0x2adfbaf6d838>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d578>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d260>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Sigmoid(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Two-dimensional sigmoid pattern, dividing the plane into positive and negative halves with a smoothly sloping transition between them.

param Number slope (allow_None=False, bounds=(None, None), constant=False, default=10.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Parameter controlling the smoothness of the transition between the two regions; high values give a sharp transition.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d158>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d100>
inspect_value = <functools.partial object at 0x2adfbaf6d7e0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d788>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d520>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.SigmoidedDoG(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Sigmoid multiplicatively combined with a difference of Gaussians, such that one part of the plane can be the mirror image of the other.

param Number positive_size (allow_None=False, bounds=(0.0, None), constant=False, default=0.15, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the positive Gaussian pattern.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number sigmoid_position (allow_None=False, bounds=(None, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X position of the transition between the two regions.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number positive_aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=2.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height for the positive Gaussian pattern.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number negative_aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height for the negative Gaussian pattern.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number negative_size (allow_None=False, bounds=(0.0, None), constant=False, default=0.25, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the negative Gaussian pattern.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Number sigmoid_slope (allow_None=False, bounds=(None, None), constant=False, default=10.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=5, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Parameter controlling the smoothness of the transition between the two regions; high values give a sharp transition.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d940>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d578>
inspect_value = <functools.partial object at 0x2adfbaf6d680>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d520>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d2b8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Gaussian(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D Gaussian pattern generator.

The sigmas of the Gaussian are calculated from the size and aspect_ratio parameters:

ysigma=size/2 xsigma=ysigma*aspect_ratio

The Gaussian is then computed for the given (x,y) values as:

exp(-x^2/(2*xsigma^2) - y^2/(2*ysigma^2)
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=3.22580645161, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of the width to the height. Specifically, xsigma=ysigma*aspect_ratio (see size).
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.155, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Overall size of the Gaussian, defined by: exp(-x^2/(2*xsigma^2) - y^2/(2*ysigma^2) where ysigma=size/2 and xsigma=size/2*aspect_ratio.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d260>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d788>
inspect_value = <functools.partial object at 0x2adfbaf6d158>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d7e0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d100>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.SineGrating(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D sine grating pattern generator.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number phase (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.51, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Phase of the sine grating.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number frequency (allow_None=False, bounds=(0.0, None), constant=False, default=2.4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.5, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Frequency of the sine grating.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d8e8>
function(p)[source]

Return a sine grating pattern (two-dimensional sine wave).

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d520>
inspect_value = <functools.partial object at 0x2adfbaf6d3c0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d578>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d368>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Arc(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D arc pattern generator.

Draws an arc (partial ring) of the specified size (radius*2), starting at radian 0.0 and ending at arc_length. The orientation can be changed to choose other start locations. The pattern is centered at the center of the ring.

See the Disk class for a note about the Gaussian fall-off.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the overall width.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.015, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the ring.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.05, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the ring.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number arc_length (allow_None=False, bounds=(0.0, None), constant=False, default=3.14159265359, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=0.62, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Length of the arc, in radians, starting from orientation 0.0.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d260>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d310>
inspect_value = <functools.partial object at 0x2adfbaf6d7e0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d368>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d3c0>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.PowerSpectrum(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Outputs the spectral density of a rolling interval of the input signal each time it is called. Over time, the results could be arranged into a spectrogram, e.g. for an audio signal.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=(0, None), constant=False, default=0.01, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The amount by which to scale amplitudes by. This is useful if we want to rescale to say a range [0:1]. Note: Constant scaling is preferable to dynamic scaling so as not to artificially ramp down loud sounds while ramping up hiss and other background interference.
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Integer min_frequency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest frequency for which to return an amplitude.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter windowing_function (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
This function is multiplied with the current interval, i.e. the most recent portion of the waveform interval of a signal, before performing the Fourier transform. It thus shapes the interval, which is otherwise always rectangular. The function chosen here dictates the tradeoff between resolving comparable signal strengths with similar frequencies, and resolving disparate signal strengths with dissimilar frequencies. numpy provides a number of options, e.g. bartlett, blackman, hamming, hanning, kaiser; see http://docs.scipy.org/doc/numpy/reference/routines.window.html You may also supply your own.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Integer max_frequency (allow_None=False, bounds=(0, None), constant=False, default=9999, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest frequency for which to return an amplitude.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param TimeSeriesParam signal (allow_None=False, constant=False, default=<TimeSeries TimeSeries01037>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A TimeSeries object on which to perfom the Fourier Transform.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d7e0>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d158>
inspect_value = <functools.partial object at 0x2adfbaf6d8e8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d680>
set_param = <functools.partial object at 0x2adfbaf6d838>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Ring(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D ring pattern generator.

See the Disk class for a note about the Gaussian fall-off.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the overall width.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number thickness (allow_None=False, bounds=(0.0, None), constant=False, default=0.015, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.6, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Thickness (line width) of the ring.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off inside and outside the ring.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d520>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d100>
inspect_value = <functools.partial object at 0x2adfbaf6d940>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d310>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d578>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.__init__.Disk(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

2D disk pattern generator.

An elliptical disk can be obtained by adjusting the aspect_ratio of a circular disk; this transforms a circle into an ellipse by stretching the circle in the y (vertical) direction.

The Gaussian fall-off at a point P is an approximation for non-circular disks, since the point on the ellipse closest to P is taken to be the same point as the point on the circle before stretching that was closest to P.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width of the disk.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number smoothing (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.61, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Width of the Gaussian fall-off
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Top to bottom height of the disk
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbaf6d838>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbaf6d788>
inspect_value = <functools.partial object at 0x2adfbaf6d8e8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbaf6d158>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbaf6d100>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


audio Module

Inheritance diagram of imagen.audio

Pattern generators for audio signals.

class imagen.audio.AudioFile(**params)[source]

Bases: imagen.TimeSeries

Requires an audio file in any format accepted by audiolab (wav, aiff, flac).

param Array time_series (allow_None=True, constant=False, default=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1], instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
An array of numbers that form a series.
param Boolean repeat (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the signal loops or terminates once it reaches its end.
param Parameter precision (allow_None=False, constant=False, default=<type ‘numpy.float64’>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The float precision to use for loaded audio files.
param Filename filename (allow_None=False, constant=False, default=sounds/complex/daisy.wav, instantiate=False, pickle_default_value=True, precedence=None, readonly=False, search_paths=[])
File path (can be relative to Param’s base path) to an audio file. The audio can be in any format accepted by audiolab, e.g. WAV, AIFF, or FLAC.
param Number sample_rate (allow_None=False, bounds=(0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The number of samples taken per second to form the series.
param Number seconds_per_iteration (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of seconds advanced along the time series on each iteration.
param Number interval_length (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of time in seconds to be returned on each iteration.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

extract_specific_interval(interval_start, interval_end)

Overload if special behaviour is required when a series ends.

force_new_dynamic_value = <functools.partial object at 0x2adfbc49f788>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc49f730>
inspect_value = <functools.partial object at 0x2adfbc49f838>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

precision

alias of float64

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc49f7e0>
set_param = <functools.partial object at 0x2adfbc49f8e8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.audio.AudioFolder(**params)[source]

Bases: imagen.audio.AudioFile

Returns a rolling spectrogram, i.e. the spectral density over time of a rolling window of the input audio signal, for all files in the specified folder.

param Array time_series (allow_None=True, constant=False, default=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1], instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
An array of numbers that form a series.
param Boolean repeat (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the signal loops or terminates once it reaches its end.
param Number gap_between_sounds (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The gap in seconds to insert between consecutive soundfiles.
param Parameter precision (allow_None=False, constant=False, default=<type ‘numpy.float64’>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The float precision to use for loaded audio files.
param Filename filename (allow_None=True, constant=False, default=sounds/complex/daisy.wav, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, search_paths=[])
File path (can be relative to Param’s base path) to an audio file. The audio can be in any format accepted by audiolab, e.g. WAV, AIFF, or FLAC.
param Number sample_rate (allow_None=False, bounds=(0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The number of samples taken per second to form the series.
param Number seconds_per_iteration (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of seconds advanced along the time series on each iteration.
param Foldername folderpath (allow_None=False, constant=False, default=sounds/sine_waves/normalized, instantiate=False, pickle_default_value=True, precedence=None, readonly=False, search_paths=[])
Folder path (can be relative to Param’s base path) to a folder containing audio files. The audio can be in any format accepted by audiolab, i.e. WAV, AIFF, or FLAC.
param Number interval_length (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The length of time in seconds to be returned on each iteration.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

extract_specific_interval(interval_start, interval_end)[source]

Overload if special behaviour is required when a series ends.

force_new_dynamic_value = <functools.partial object at 0x2adfbc49f730>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc49f470>
inspect_value = <functools.partial object at 0x2adfbc49f680>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

precision

alias of float64

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc49f4c8>
set_param = <functools.partial object at 0x2adfbc49f3c0>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.audio.LogSpectrogram(**params)[source]

Bases: imagen.Spectrogram

Extends Spectrogram to provide a response over an octave scale.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Integer min_latency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest latency (in milliseconds) for which to return amplitudes.
param Integer max_frequency (allow_None=False, bounds=(0, None), constant=False, default=9999, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest frequency for which to return an amplitude.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=(0, None), constant=False, default=0.01, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The amount by which to scale amplitudes by. This is useful if we want to rescale to say a range [0:1]. Note: Constant scaling is preferable to dynamic scaling so as not to artificially ramp down loud sounds while ramping up hiss and other background interference.
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Integer min_frequency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest frequency for which to return an amplitude.
param Parameter windowing_function (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
This function is multiplied with the current interval, i.e. the most recent portion of the waveform interval of a signal, before performing the Fourier transform. It thus shapes the interval, which is otherwise always rectangular. The function chosen here dictates the tradeoff between resolving comparable signal strengths with similar frequencies, and resolving disparate signal strengths with dissimilar frequencies. numpy provides a number of options, e.g. bartlett, blackman, hamming, hanning, kaiser; see http://docs.scipy.org/doc/numpy/reference/routines.window.html You may also supply your own.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Integer max_latency (allow_None=False, bounds=(0, None), constant=False, default=500, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest latency (in milliseconds) for which to return amplitudes.
param Integer log_base (allow_None=False, bounds=(0.0, None), constant=False, default=2, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The base of the logarithm used to generate logarithmic frequency spacing.
param TimeSeriesParam signal (allow_None=False, constant=False, default=<TimeSeries TimeSeries01034>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A TimeSeries object on which to perfom the Fourier Transform.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc49f8e8>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc49f7e0>
inspect_value = <functools.partial object at 0x2adfbc49f6d8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc49f418>
set_param = <functools.partial object at 0x2adfbc49f998>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.audio.LyonsCochlearModel(**params)[source]

Bases: imagen.PowerSpectrum

Outputs a cochlear decomposition as a set of frequency responses of linear band-pass filters. Employs Lyons Cochlear Model to do so.

R. F. Lyon, “A computational model of filtering, detection and compression in the cochlea.” in Proc. of the IEEE Int. Conf. Acoust., Speech, Signal Processing, Paris, France, May 1982.

Specific implementation details can be found in:

Malcolm Slaney, “Lyon’s Cochlear Model, in Advanced Technology Group, Apple Technical Report #13”, 1988.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Integer max_frequency (allow_None=False, bounds=(0, None), constant=False, default=9999, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest frequency for which to return an amplitude.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=(0, None), constant=False, default=0.01, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The amount by which to scale amplitudes by. This is useful if we want to rescale to say a range [0:1]. Note: Constant scaling is preferable to dynamic scaling so as not to artificially ramp down loud sounds while ramping up hiss and other background interference.
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number stage_overlap_factor (allow_None=False, bounds=None, constant=False, default=4.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The degree of overlap between filters. Successive filter stages are overlapped by a fraction of their bandwidth. The number is arbitrary but smaller numbers lead to more computations. We currently overlap 4 stages within the bandpass region of any one filter.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number quality_factor (allow_None=False, bounds=None, constant=False, default=8.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Quality factor controls the bandwidth of each cochlear filter. The bandwidth of each cochlear filter is a function of its center frequency. At high frequencies the bandwidth is approximately equal to the center frequency divided by a quality constant (quality_factor). At lower frequncies the bandwidth approaches a constant given by: 1000/quality_factor.
param Integer min_frequency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest frequency for which to return an amplitude.
param Parameter windowing_function (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
This function is multiplied with the current interval, i.e. the most recent portion of the waveform interval of a signal, before performing the Fourier transform. It thus shapes the interval, which is otherwise always rectangular. The function chosen here dictates the tradeoff between resolving comparable signal strengths with similar frequencies, and resolving disparate signal strengths with dissimilar frequencies. numpy provides a number of options, e.g. bartlett, blackman, hamming, hanning, kaiser; see http://docs.scipy.org/doc/numpy/reference/routines.window.html You may also supply your own.
param Parameter precision (allow_None=False, constant=False, default=<type ‘numpy.float64’>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The float precision to use when calculating ear stage filters.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Parameter signal (allow_None=True, constant=False, default=<TimeSeries TimeSeries01034>, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
A TimeSeries object to be fed to the model. This can be any kind of signal, be it from audio files or live from a mic, as long as the values conform to a TimeSeries.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc49f3c0>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc49f470>
inspect_value = <functools.partial object at 0x2adfbc49f680>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

precision

alias of float64

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc49f940>
set_param = <functools.partial object at 0x2adfbc49f6d8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.audio.LyonsCochleogram(**params)[source]

Bases: imagen.audio.LyonsCochlearModel

Employs Lyons Cochlear Model to return a Cochleoogram, i.e. the response over time along the cochlea.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Integer max_frequency (allow_None=False, bounds=(0, None), constant=False, default=9999, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest frequency for which to return an amplitude.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=(0, None), constant=False, default=0.01, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The amount by which to scale amplitudes by. This is useful if we want to rescale to say a range [0:1]. Note: Constant scaling is preferable to dynamic scaling so as not to artificially ramp down loud sounds while ramping up hiss and other background interference.
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number stage_overlap_factor (allow_None=False, bounds=None, constant=False, default=4.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The degree of overlap between filters. Successive filter stages are overlapped by a fraction of their bandwidth. The number is arbitrary but smaller numbers lead to more computations. We currently overlap 4 stages within the bandpass region of any one filter.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number quality_factor (allow_None=False, bounds=None, constant=False, default=8.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Quality factor controls the bandwidth of each cochlear filter. The bandwidth of each cochlear filter is a function of its center frequency. At high frequencies the bandwidth is approximately equal to the center frequency divided by a quality constant (quality_factor). At lower frequncies the bandwidth approaches a constant given by: 1000/quality_factor.
param Integer min_frequency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest frequency for which to return an amplitude.
param Parameter windowing_function (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
This function is multiplied with the current interval, i.e. the most recent portion of the waveform interval of a signal, before performing the Fourier transform. It thus shapes the interval, which is otherwise always rectangular. The function chosen here dictates the tradeoff between resolving comparable signal strengths with similar frequencies, and resolving disparate signal strengths with dissimilar frequencies. numpy provides a number of options, e.g. bartlett, blackman, hamming, hanning, kaiser; see http://docs.scipy.org/doc/numpy/reference/routines.window.html You may also supply your own.
param Parameter precision (allow_None=False, constant=False, default=<type ‘numpy.float64’>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The float precision to use when calculating ear stage filters.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Parameter signal (allow_None=True, constant=False, default=<TimeSeries TimeSeries01034>, instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
A TimeSeries object to be fed to the model. This can be any kind of signal, be it from audio files or live from a mic, as long as the values conform to a TimeSeries.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc49f998>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc49f890>
inspect_value = <functools.partial object at 0x2adfbc49fa48>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

precision

alias of float64

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc49f730>
set_param = <functools.partial object at 0x2adfbc49f7e0>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.audio.ModulatedLogSpectrogram(**params)[source]

Bases: imagen.audio.LogSpectrogram

Extends OctaveSpectrogram with a simple model of outer ear amplification. One can set both the range to amplify and the amount.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Integer min_latency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest latency (in milliseconds) for which to return amplitudes.
param Integer max_frequency (allow_None=False, bounds=(0, None), constant=False, default=9999, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest frequency for which to return an amplitude.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=(0, None), constant=False, default=0.01, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The amount by which to scale amplitudes by. This is useful if we want to rescale to say a range [0:1]. Note: Constant scaling is preferable to dynamic scaling so as not to artificially ramp down loud sounds while ramping up hiss and other background interference.
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Integer min_frequency (allow_None=False, bounds=(0, None), constant=False, default=0, inclusive_bounds=(True, False), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Smallest frequency for which to return an amplitude.
param Parameter windowing_function (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
This function is multiplied with the current interval, i.e. the most recent portion of the waveform interval of a signal, before performing the Fourier transform. It thus shapes the interval, which is otherwise always rectangular. The function chosen here dictates the tradeoff between resolving comparable signal strengths with similar frequencies, and resolving disparate signal strengths with dissimilar frequencies. numpy provides a number of options, e.g. bartlett, blackman, hamming, hanning, kaiser; see http://docs.scipy.org/doc/numpy/reference/routines.window.html You may also supply your own.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number upper_freq_bound (allow_None=False, bounds=(0.0, None), constant=False, default=7000.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The upper bound of the frequency range to be modulated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Integer max_latency (allow_None=False, bounds=(0, None), constant=False, default=500, inclusive_bounds=(False, False), instantiate=False, pickle_default_value=True, precedence=2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Largest latency (in milliseconds) for which to return amplitudes.
param Integer log_base (allow_None=False, bounds=(0.0, None), constant=False, default=2, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The base of the logarithm used to generate logarithmic frequency spacing.
param TimeSeriesParam signal (allow_None=False, constant=False, default=<TimeSeries TimeSeries01034>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
A TimeSeries object on which to perfom the Fourier Transform.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number lower_freq_bound (allow_None=False, bounds=(0.0, None), constant=False, default=1000.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The lower bound of the frequency range to be modulated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Parameter modulation_function (allow_None=False, constant=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
The function by which to modulate the signal between the specified frequency range. The default (hanning) multiplies a section of the signal by a hanning window.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc49f9f0>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc49f418>
inspect_value = <functools.partial object at 0x2adfbc49f8e8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

static modulation_function(M)

Return the Hanning window.

The Hanning window is a taper formed by using a weighted cosine.

M : int
Number of points in the output window. If zero or less, an empty array is returned.
out : ndarray, shape(M,)
The window, with the maximum value normalized to one (the value one appears only if M is odd).

bartlett, blackman, hamming, kaiser

The Hanning window is defined as

\[w(n) = 0.5 - 0.5cos\left(\frac{2\pi{n}}{M-1}\right) \qquad 0 \leq n \leq M-1\]

The Hanning was named for Julius van Hann, an Austrian meteorologist. It is also known as the Cosine Bell. Some authors prefer that it be called a Hann window, to help avoid confusion with the very similar Hamming window.

Most references to the Hanning window come from the signal processing literature, where it is used as one of many windowing functions for smoothing values. It is also known as an apodization (which means “removing the foot”, i.e. smoothing discontinuities at the beginning and end of the sampled signal) or tapering function.

[1]Blackman, R.B. and Tukey, J.W., (1958) The measurement of power spectra, Dover Publications, New York.
[2]E.R. Kanasewich, “Time Sequence Analysis in Geophysics”, The University of Alberta Press, 1975, pp. 106-108.
[3]Wikipedia, “Window function”, http://en.wikipedia.org/wiki/Window_function
[4]W.H. Press, B.P. Flannery, S.A. Teukolsky, and W.T. Vetterling, “Numerical Recipes”, Cambridge University Press, 1986, page 425.
>>> np.hanning(12)
array([ 0.        ,  0.07937323,  0.29229249,  0.57115742,  0.82743037,
        0.97974649,  0.97974649,  0.82743037,  0.57115742,  0.29229249,
        0.07937323,  0.        ])

Plot the window and its frequency response:

>>> from numpy.fft import fft, fftshift
>>> window = np.hanning(51)
>>> plt.plot(window)
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.title("Hann window")
<matplotlib.text.Text object at 0x...>
>>> plt.ylabel("Amplitude")
<matplotlib.text.Text object at 0x...>
>>> plt.xlabel("Sample")
<matplotlib.text.Text object at 0x...>
>>> plt.show()
>>> plt.figure()
<matplotlib.figure.Figure object at 0x...>
>>> A = fft(window, 2048) / 25.5
>>> mag = np.abs(fftshift(A))
>>> freq = np.linspace(-0.5, 0.5, len(A))
>>> response = 20 * np.log10(mag)
>>> response = np.clip(response, -100, 100)
>>> plt.plot(freq, response)
[<matplotlib.lines.Line2D object at 0x...>]
>>> plt.title("Frequency response of the Hann window")
<matplotlib.text.Text object at 0x...>
>>> plt.ylabel("Magnitude [dB]")
<matplotlib.text.Text object at 0x...>
>>> plt.xlabel("Normalized frequency [cycles per sample]")
<matplotlib.text.Text object at 0x...>
>>> plt.axis('tight')
(-0.5, 0.5, -100.0, ...)
>>> plt.show()
num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc49faa0>
set_param = <functools.partial object at 0x2adfbc49fba8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


colorspaces Module

Inheritance diagram of imagen.colorspaces

Utilities for converting images between various color spaces, such as:

  • RGB (for display on computer monitor red, green, and blue channels)
  • HSV (allowing manipulation of the hue, saturation, and value),
  • LMS (estimates of human long, medium, and short cone responses),
  • LCH (CIE perceptually uniform luminance, chroma (saturation), and hue)
  • LAB (CIE opponent black/white, red/green, blue/yellow axes)
  • XYZ (CIE interchange format)

See http://en.wikipedia.org/wiki/Color_space for more detailed descriptions.

To use these utilities, users should instantiate one of these two classes:

ColorSpace
Provides a convert(from, to, what) method to perform conversion between colorspaces, e.g. convert("rgb", "hsv", X), where X is assumed to be a numpy.dstack() object with three matching arrays.
FeatureColorConverter

Declare a set of color spaces to allow external code to work the same for any combination of color spaces. Specifically, declares:

  • image color space (the space in which a dataset of images has been stored),

  • working color space (to which the images will be converted),

    e.g. to transform images to a different working dataset, and

  • analysis color space (space in which analyses will be performed)

These values can be set using:

color_conversion.image_space="XYZ"    # e.g. RGB, XYZ, LMS
color_conversion.working_space="RGB" # e.g. RGB, LMS
color_conversion.analysis_space="HSV" # e.g. HSV, LCH

The other code in this file is primarily implementation for these two classes, and will rarely need to be used directly.

class imagen.colorspaces.ColorSpace(**params)[source]

Bases: param.parameterized.Parameterized

Low-level color conversion. The ‘convert’ method handles color conversion to and from (and through) XYZ, and supports RGB, LCH, LMS and HSV.

param Parameter dtype (allow_None=False, constant=False, default=<type ‘numpy.float32’>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Datatype to use for result.
param NumericTuple output_limits (allow_None=False, constant=False, default=(0.0, 1.0), instantiate=False, length=2, pickle_default_value=True, precedence=None, readonly=False)
Upper and lower bounds to enforce on output values.
param Dict transforms (allow_None=False, constant=False, default={‘D65’: {‘rgb_from_xyz’: array([[ 3.241 , -1.5374, -0.4986], [-0.9692, 1.876 , 0.0416], [ 0.0556, -0.204 , 1.057 ]]), ‘xyz_from_lms’: array([[ 1.87616336e+00, -1.37368291e+00, 3.40220544e-01], [ 6.37205799e-01, 3.92411765e-01, 5.61517442e-05], [ 0.00000000e+00, 0.00000000e+00, 1.60642570e+00]]), ‘xyz_from_rgb’: array([[ 0.41238088, 0.35757284, 0.1804523 ], [ 0.21261986, 0.71513879, 0.07214994], [ 0.0193435 , 0.11921217, 0.95050657]]), ‘lms_from_xyz’: array([[ 0.2435, 0.8524, -0.0516], [-0.3954, 1.1642, 0.0837], [ 0. , 0. , 0.6225]])}}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Structure containing the transformation matrices used by this Class. See transforms in this file.
param String whitepoint (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=D65, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Name of whitepoint in lookup table.
param ObjectSelector output_clip (allow_None=None, check_on_set=True, compute_default_fn=None, constant=False, default=silent, instantiate=False, objects=[‘silent’, ‘warn’, ‘error’, ‘none’], pickle_default_value=True, precedence=None, readonly=False)
Action to take when the output value will be clipped.
param NumericTuple input_limits (allow_None=False, constant=False, default=(0.0, 1.0), instantiate=False, length=2, pickle_default_value=True, precedence=None, readonly=False)
Upper and lower bounds to verify on input values.
convert(from_, to, what)[source]

Convert image or color “what” from “from_” colorpace to “to” colorspace. E.g.: convert("rgb", "hsv", X), where X is a numpy dstack or a color tuple.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

dtype

alias of float32

force_new_dynamic_value = <functools.partial object at 0x2adfbcb3d7e0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbcb3d838>
hsv_to_gammargb(HSV)[source]

hsv is already specifying gamma corrected rgb

hsv_to_rgb(HSV)[source]

hsv to linear rgb

inspect_value = <functools.partial object at 0x2adfbcb3d788>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

rgb_to_hsv(RGB)[source]

linear rgb to hsv

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbcb3d628>
set_param = <functools.partial object at 0x2adfbcb3d8e8>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.colorspaces.ColorConverter(**params)[source]

Bases: param.parameterized.Parameterized

High-level color conversion class designed to support color space transformations along a pipeline common in color vision modelling: image (dataset colorspace) -> working (working colorspace) -> [higher stages] -> analysis

param ObjectSelector analysis_space (allow_None=None, check_on_set=True, compute_default_fn=None, constant=False, default=HSV, instantiate=False, objects=[‘HSV’, ‘LCH’], pickle_default_value=True, precedence=None, readonly=False)
Color space in which analysis is performed.
param Parameter colorspace (allow_None=False, constant=False, default=<ColorSpace ColorSpace01042>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Object to use for converting between color spaces.
param ObjectSelector working_space (allow_None=None, check_on_set=True, compute_default_fn=None, constant=False, default=RGB, instantiate=False, objects=[‘RGB’, ‘LMS’], pickle_default_value=True, precedence=None, readonly=False)
Color space to which images will be transformed to provide working space to later stages of processing.
param ObjectSelector image_space (allow_None=None, check_on_set=True, compute_default_fn=None, constant=False, default=XYZ, instantiate=False, objects=[‘XYZ’, ‘LMS’, ‘RGB’], pickle_default_value=True, precedence=None, readonly=False)
Color space in which images are encoded.
analysis2display(a)[source]

Utility conversion function that transforms data from the analysis color space to the display space (currently hard-set to RGB) for visualization.

analysis2working(a)[source]

Convert back from the analysis color space to the working space.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbcb3d680>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbcb3d7e0>
image2working(i)[source]

Transform images i provided into the specified working color space.

inspect_value = <functools.partial object at 0x2adfbcb3d6d8>
jitter_hue(a, amount)[source]

Rotate the hue component of a by the given amount.

message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

multiply_sat(a, factor)[source]

Scale the saturation of a by the given amount.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbcb3d5d0>
set_param = <functools.partial object at 0x2adfbcb3d998>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

working2analysis(r)[source]

Transform working space inputs to the analysis color space.


deprecated Module

Inheritance diagram of imagen.deprecated

Old patterns not intended for new code.

These patterns are expected to be deleted eventually.

class imagen.deprecated.FileImage(**params)

Bases: imagen.image.GenericImage

2D Image generator that reads the image from a file.

Grayscale versions of the image are always available, converted from the color version if necessary. For color images, three-channel color values are available through the channels() method. See Image’s Image class for details of supported image file formats.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param ClassSelector pattern_sampler (allow_None=False, constant=False, default=<PatternSampler PatternSampler01045>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
The PatternSampler to use to resample/resize the image.
param Boolean cache_image (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
If False, discards the image and pattern_sampler after drawing the pattern each time, to make it possible to use very large databases of images without running out of memory.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Filename filename (allow_None=False, constant=False, default=images/ellen_arthur.pgm, instantiate=False, pickle_default_value=True, precedence=0.9, readonly=False, search_paths=[])
File path (can be relative to Param’s base path) to a bitmap image. The image can be in any format accepted by PIL, e.g. PNG, JPG, TIFF, or PGM as well or numpy save files (.npy or .npz) containing 2D or 3D arrays (where the third dimension is used for each channel).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Height of the image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c5368>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c53c0>
inspect_value = <functools.partial object at 0x2adfbc4c5418>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c5260>
set_matrix_dimensions(*args)

Subclassed to delete the cached image when matrix dimensions are changed.

set_param = <functools.partial object at 0x2adfbc4c5310>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.Constant(**params)

Bases: imagen.patterngenerator.PatternGenerator

Constant pattern generator, i.e., a solid, uniform field of the same value.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c51b0>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5158>
inspect_value = <functools.partial object at 0x2adfbc4c50a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c54c8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c5208>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.TwoRectangles(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Two 2D rectangle pattern generator.

param Number y2 (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=0.15, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y center of rectangle 2.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number y1 (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=-0.15, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y center of rectangle 1.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width of the rectangle.
param Number x1 (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=-0.15, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X center of rectangle 1.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number x2 (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=0.15, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X center of rectangle 2.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c5470>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5260>
inspect_value = <functools.partial object at 0x2adfbc4c5050>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c5418>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c53c0>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.Composite(**params)

Bases: imagen.patterngenerator.CompositeBase

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.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c54c8>
function(p)

Constructs combined pattern out of the individual ones.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5100>
inspect_value = <functools.partial object at 0x2adfbc4c50a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c53c0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c5208>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.OldSweeper(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

PatternGenerator that sweeps a supplied PatternGenerator in a direction perpendicular to its orientation.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Parameter generator (allow_None=False, constant=False, default=<Gaussian Gaussian01049>, instantiate=False, pickle_default_value=True, precedence=0.97, readonly=False)
Pattern to sweep.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number step (allow_None=False, bounds=None, constant=False, default=1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of steps at the given speed to move in the sweep direction. The distance moved is speed*step.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number speed (allow_None=False, bounds=(0.0, None), constant=False, default=0.25, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Sweep speed: number of sheet coordinate units per unit time.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c52b8>
function(p)[source]

Selects and returns one of the patterns in the list.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5418>
inspect_value = <functools.partial object at 0x2adfbc4c5158>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c5260>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c5310>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.GaussiansCorner(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Two Gaussian pattern generators with a variable intersection point, appearing as a corner or cross.

param Number x (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=-0.15, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X center of the corner
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number angle (allow_None=False, bounds=(0, 3.141592653589793), constant=False, default=1.57079632679, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The angle of the corner
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0, None), constant=False, default=3.22580645161, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of the width to the height for both Gaussians
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number cross (allow_None=False, bounds=(0, 1), constant=False, default=0.4, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Where the two Gaussians cross, as a fraction of their half length
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=-0.15, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y center of the corner
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The size of the corner
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c50a8>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5100>
inspect_value = <functools.partial object at 0x2adfbc4c5578>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c53c0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c54c8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.Gaussian(**params)

Bases: imagen.patterngenerator.PatternGenerator

2D Gaussian pattern generator.

The sigmas of the Gaussian are calculated from the size and aspect_ratio parameters:

ysigma=size/2 xsigma=ysigma*aspect_ratio

The Gaussian is then computed for the given (x,y) values as:

exp(-x^2/(2*xsigma^2) - y^2/(2*ysigma^2)
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=3.22580645161, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of the width to the height. Specifically, xsigma=ysigma*aspect_ratio (see size).
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.155, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Overall size of the Gaussian, defined by: exp(-x^2/(2*xsigma^2) - y^2/(2*ysigma^2) where ysigma=size/2 and xsigma=size/2*aspect_ratio.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c53c0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5368>
inspect_value = <functools.partial object at 0x2adfbc4c5310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c5418>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c52b8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.Translator(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

PatternGenerator that translates another PatternGenerator over time.

This PatternGenerator will create a series of episodes, where in each episode the underlying generator is moved in a fixed direction at a fixed speed. To begin an episode, the Translator’s x, y, and direction are evaluated (e.g. from random distributions), and the underlying generator is then drawn at those values plus changes over time that are determined by the speed. The orientation of the underlying generator should be set to 0 to get motion perpendicular to the generator’s orientation (which is typical).

Note that at present the parameter values for x, y, and direction cannot be passed in when the instance is called; only the values set on the instance are used.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Number episode_interval (allow_None=False, bounds=None, constant=False, default=0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Interval between successive translation episodes. If nonzero, the episode_separator pattern is presented for this amount of time_fn time after each episode, e.g. to allow processing of the previous episode to complete.
param ClassSelector episode_separator (allow_None=False, constant=False, default=<Constant Constant01048>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Pattern to display during the episode_interval, if any. The default is a blank pattern.
param Number speed (allow_None=False, bounds=(0.0, None), constant=False, default=0.01, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The speed with which the pattern should move, in sheet coordinates per time_fn unit.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param ClassSelector generator (allow_None=False, constant=False, default=<Gaussian Gaussian01047>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Pattern to be translated.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number direction (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The direction in which the pattern should move, in radians.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Function to generate the time used as a base for translation.
param Number reset_period (allow_None=False, bounds=(0.0, None), constant=False, default=1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Period between generating each new translation episode.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c5050>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5100>
inspect_value = <functools.partial object at 0x2adfbc4c5158>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c5260>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c52b8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.SeparatedComposite(**params)[source]

Bases: imagen.patterngenerator.Composite

Generalized version of the Composite PatternGenerator that enforces spacing constraints between pattern centers.

Currently supports minimum spacing, but can be generalized to support maximum spacing also (and both at once).

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Integer max_trials (allow_None=False, bounds=(0, None), constant=False, default=50, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of times to try for a new pattern location that meets the criteria. This is an essentially arbitrary timeout value that helps prevent an endless loop in case the requirements cannot be met.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number min_separation (allow_None=False, bounds=(0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Minimum distance to enforce between all pairs of pattern centers. Useful for ensuring that multiple randomly generated patterns do not overlap spatially. Note that as this this value is increased relative to the area in which locations are chosen, the likelihood of a pattern appearing near the center of the area will decrease. As this value approaches the available area, the corners become far more likely to be chosen, due to the distances being greater along the diagonals.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c53c0>
function(p)

Constructs combined pattern out of the individual ones.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5470>
inspect_value = <functools.partial object at 0x2adfbc4c5418>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c5310>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c51b0>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.PatternGenerator(**params)

Bases: param.parameterized.Parameterized

A class hierarchy for callable objects that can generate 2D patterns.

Once initialized, PatternGenerators can be called to generate a value or a matrix of values from a 2D function, typically accepting at least x and y.

A PatternGenerator’s Parameters can make use of Parameter’s precedence attribute to specify the order in which they should appear, e.g. in a GUI. The precedence attribute has a nominal range of 0.0 to 1.0, with ordering going from 0.0 (first) to 1.0 (last), but any value is allowed.

The orientation and layout of the pattern matrices is defined by the SheetCoordinateSystem class, which see.

Note that not every parameter defined for a PatternGenerator will be used by every subclass. For instance, a Constant pattern will ignore the x, y, orientation, and size parameters, because the pattern does not vary with any of those parameters. However, those parameters are still defined for all PatternGenerators, even Constant patterns, to allow PatternGenerators to be scaled, rotated, translated, etc. uniformly.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c5368>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c5310>
inspect_value = <functools.partial object at 0x2adfbc4c53c0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c5208>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbc4c5418>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.deprecated.NumpyFile(**params)[source]

Bases: imagen.image.FileImage

For backwards compatibility.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param ClassSelector pattern_sampler (allow_None=False, constant=False, default=<PatternSampler PatternSampler01050>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
The PatternSampler to use to resample/resize the image.
param Boolean cache_image (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
If False, discards the image and pattern_sampler after drawing the pattern each time, to make it possible to use very large databases of images without running out of memory.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Filename filename (allow_None=False, constant=False, default=images/ellen_arthur.pgm, instantiate=False, pickle_default_value=True, precedence=0.9, readonly=False, search_paths=[])
File path (can be relative to Param’s base path) to a bitmap image. The image can be in any format accepted by PIL, e.g. PNG, JPG, TIFF, or PGM as well or numpy save files (.npy or .npz) containing 2D or 3D arrays (where the third dimension is used for each channel).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Height of the image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbc4c5158>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbc4c52b8>
inspect_value = <functools.partial object at 0x2adfbc4c5418>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbc4c50a8>
set_matrix_dimensions(*args)

Subclassed to delete the cached image when matrix dimensions are changed.

set_param = <functools.partial object at 0x2adfbc4c5470>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


image Module

Inheritance diagram of imagen.image

PatternGenerators based on bitmap images stored in files.

Requires the Python Imaging Library (PIL). In general, the pillow fork of PIL is recommended as it is being actively maintained and works with Python 3.

class imagen.image.FastImageSampler(**params)[source]

Bases: imagen.image.ImageSampler

A fast-n-dirty image sampler using Python Imaging Library routines. Currently this sampler doesn’t support user-specified size_normalization or cropping but rather simply scales and crops the image to fit the given matrix size without distorting the aspect ratio of the original picture.

param Integer sampling_method (allow_None=False, bounds=None, constant=False, default=0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Python Imaging Library sampling method for resampling an image. Defaults to Image.NEAREST.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd006f18>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd006ec0>
inspect_value = <functools.partial object at 0x2adfbd006f70>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd006e68>
set_param = <functools.partial object at 0x2adfbd160050>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.image.FileImage(**params)[source]

Bases: imagen.image.GenericImage

2D Image generator that reads the image from a file.

Grayscale versions of the image are always available, converted from the color version if necessary. For color images, three-channel color values are available through the channels() method. See Image’s Image class for details of supported image file formats.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param ClassSelector pattern_sampler (allow_None=False, constant=False, default=<PatternSampler PatternSampler01045>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
The PatternSampler to use to resample/resize the image.
param Boolean cache_image (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
If False, discards the image and pattern_sampler after drawing the pattern each time, to make it possible to use very large databases of images without running out of memory.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Filename filename (allow_None=False, constant=False, default=images/ellen_arthur.pgm, instantiate=False, pickle_default_value=True, precedence=0.9, readonly=False, search_paths=[])
File path (can be relative to Param’s base path) to a bitmap image. The image can be in any format accepted by PIL, e.g. PNG, JPG, TIFF, or PGM as well or numpy save files (.npy or .npz) containing 2D or 3D arrays (where the third dimension is used for each channel).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Height of the image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd006c58>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd006d08>
inspect_value = <functools.partial object at 0x2adfbd006db8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd006d60>
set_matrix_dimensions(*args)[source]

Subclassed to delete the cached image when matrix dimensions are changed.

set_param = <functools.partial object at 0x2adfbd1720a8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.image.GenericImage(**params)[source]

Bases: imagen.patterngenerator.ChannelGenerator

Generic 2D image generator with support for multiple channels.

Subclasses should override the _get_image method to produce the image object.

By default, the background value is calculated as an edge average: see edge_average(). Black-bordered images therefore have a black background, and white-bordered images have a white background. Images with no border have a background that is less of a contrast than a white or black one.

At present, rotation, size_normalization, etc. just resample; it would be nice to support some interpolation options as well.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param ClassSelector pattern_sampler (allow_None=False, constant=False, default=<PatternSampler PatternSampler01045>, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
The PatternSampler to use to resample/resize the image.
param Boolean cache_image (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
If False, discards the image and pattern_sampler after drawing the pattern each time, to make it possible to use very large databases of images without running out of memory.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of width to height; size*aspect_ratio gives the width.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Height of the image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd006c58>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd006ec0>
inspect_value = <functools.partial object at 0x2adfbd006f70>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd006e68>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbd17f0a8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.image.ImageSampler(**params)[source]

Bases: param.parameterized.Parameterized

A class of objects that, when called, sample an image.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd006c58>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd006d08>
inspect_value = <functools.partial object at 0x2adfbd006db8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd006d60>
set_param = <functools.partial object at 0x2adfbd185050>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.image.PatternSampler(**params)[source]

Bases: imagen.image.ImageSampler

When called, resamples - according to the size_normalization parameter - an image at the supplied (x,y) sheet coordinates.

(x,y) coordinates outside the image are returned as the background value.

param HookList whole_pattern_output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Functions to apply to the whole image before any sampling is done.
param Callable background_value_fn (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Function to compute an appropriate background value. Must accept an array and return a scalar.
param ObjectSelector size_normalization (allow_None=None, check_on_set=True, compute_default_fn=None, constant=False, default=original, instantiate=False, objects=[‘original’, ‘stretch_to_fit’, ‘fit_shortest’, ‘fit_longest’], pickle_default_value=True, precedence=None, readonly=False)
Determines how the pattern is scaled initially, relative to the default retinal dimension of 1.0 in sheet coordinates: ‘stretch_to_fit’: scale both dimensions of the pattern so they would fill a Sheet with bounds=BoundingBox(radius=0.5) (disregards the original’s aspect ratio). ‘fit_shortest’: scale the pattern so that its shortest dimension is made to fill the corresponding dimension on a Sheet with bounds=BoundingBox(radius=0.5) (maintains the original’s aspect ratio, filling the entire bounding box). ‘fit_longest’: scale the pattern so that its longest dimension is made to fill the corresponding dimension on a Sheet with bounds=BoundingBox(radius=0.5) (maintains the original’s aspect ratio, fitting the image into the bounding box but not necessarily filling it). ‘original’: no scaling is applied; each pixel of the pattern corresponds to one matrix unit of the Sheet on which the pattern being displayed.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd006fc8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd006c58>
inspect_value = <functools.partial object at 0x2adfbd006f70>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd006e68>
set_param = <functools.partial object at 0x2adfbd196050>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.image.RotateHue(**params)[source]

Bases: imagen.patterngenerator.ChannelTransform

Rotate the hue of an Image PatternGenerator.

Requires a three-channel (e.g. RGB) or a 4-channel (e.g. RGBA) color image. Also allows the saturation of the image to be scaled.

Requires the color space of the image to be declared using the colorspaces.color_conversion object, and uses the analysis color space from that object to do the rotation.

param Number saturation (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scale the saturation by the specified value.
param Number rotation (allow_None=False, bounds=None, constant=False, default=<UniformRandom hue_jitter>, inclusive_bounds=(True, True), instantiate=True, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Amount by which to rotate the hue. The default setting chooses a random value of hue rotation between zero and 100%. If set to 0, no rotation will be performed.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd006db8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd006f18>
inspect_value = <functools.partial object at 0x2adfbd006ec0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd006d60>
set_param = <functools.partial object at 0x2adfbd1a1050>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.image.ScaleChannels(**params)[source]

Bases: imagen.patterngenerator.ChannelTransform

Scale each channel of an Image PatternGenerator by a different factor.

The list of channel factors should be the same length as the number of channels. Otherwise, if the factors provided are fewer than the channels of the Image, the remaining channels will not be scaled. If they are more, then only the first N factors are used.

param Dynamic channel_factors (allow_None=False, constant=False, default=[1.0, 1.0, 1.0], instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Channel scaling factors.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd006e68>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd006cb0>
inspect_value = <functools.partial object at 0x2adfbd006db8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd006d08>
set_param = <functools.partial object at 0x2adfbd1a9050>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

imagen.image.edge_average(a)[source]

Return the mean value around the edge of an array.


patterncoordinator Module

Inheritance diagram of imagen.patterncoordinator

Provides the class PatternCoordinator and a family of FeatureCoordinator classes.

PatternCoordinator creates a set of pattern generators whose parameters are related in some way, as controlled by a subclass of FeatureCoordinator.

class imagen.patterncoordinator.FeatureCoordinator(**params)[source]

Bases: param.parameterized.ParameterizedFunction

A FeatureCoordinator modifies a supplied PatternGenerator.

The modification can depend on the string pattern_label and pattern_number supplied, in order to coordinate a set of patterns of the same type with systematic differences.

FeatureCoordinators that introduce randomness should be seeded with a value based on the supplied master_seed, so that an entire set of patterns can be controlled with the one master_seed value.

Subclasses of this class can accept parameters provided in params.

This superclass ensures a common interface across all FeatureCoordinator subclasses, which is necessary because they are usually stored in a list, with each item called the same way.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbcc19d60>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbcc19a48>
inspect_value = <functools.partial object at 0x2adfbcc19db8>
instance = <functools.partial object at 0x2adfbcc19e10>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix='n ', unknown_value='<?>', qualify=False, separator='')

Same as Parameterized.pprint, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Same as Parameterized.script_repr, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbcc19d08>
set_param = <functools.partial object at 0x2adfbcc19f18>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterncoordinator.OrientationCoordinator(**params)[source]

Bases: imagen.patterncoordinator.FeatureCoordinator

Chooses a random orientation within the specified orientation_bound in each direction.

param Boolean align_orientations (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether or not to align pattern orientations when composing multiple patterns together. Alignment may be useful to prevent crossing stimuli or may be appropriate for moving patterns sweeped in a single direction of motion.
param Number orientation_bound (allow_None=False, bounds=None, constant=False, default=3.14159265359, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Rotate pattern around the origin by at most orientation_bound radians (in both directions).
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbcc19b50>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbcc19aa0>
inspect_value = <functools.partial object at 0x2adfbcc19ba8>
instance = <functools.partial object at 0x2adfbcc19c00>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix='n ', unknown_value='<?>', qualify=False, separator='')

Same as Parameterized.pprint, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Same as Parameterized.script_repr, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbcc19d60>
set_param = <functools.partial object at 0x2adfbcc19f70>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterncoordinator.PatternCoordinator(inherent_features=, []**params)[source]

Bases: param.parameterized.Parameterized

Returns a set of coordinated PatternGenerators, named according to pattern_labels.

The features to be modified are specified with the features_to_vary parameter. A feature is something coordinated between the PatternGenerators, either:

  1. one of the existing parameters of the PatternGenerators (such as size), or
  2. a variable from which values for one of the existing parameters can be calculated (such as a position offset between two PatternGenerators), or
  3. a value inherent to a particular existing image dataset (due to how the dataset was collected or generated).

Each PatternGenerator is first instantiated with the supplied pattern_parameters, and then subclasses of FeatureCoordinator are applied sequentially to modify the specified or default parameter values of each PatternGenerator.

param ClassSelector pattern_type (allow_None=False, constant=False, default=<class ‘imagen.Gaussian’>, instantiate=True, is_instance=False, pickle_default_value=True, precedence=None, readonly=False)
PatternGenerator type to be used.
param Integer patterns_per_label (allow_None=False, bounds=None, constant=False, default=2, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of patterns to generate and combine for a given label.
param Dict feature_coordinators (allow_None=False, constant=False, default=OrderedDict([(‘xy’, [<class ‘imagen.patterncoordinator.XCoordinator’>, <class ‘imagen.patterncoordinator.YCoordinator’>]), (‘or’, <class ‘imagen.patterncoordinator.OrientationCoordinator’>)]), instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Mapping from the feature name (key) to the method(s) to be applied to the pattern generators. The value can either be a single method or a list of methods.
param List pattern_labels (allow_None=False, bounds=(1, None), constant=False, default=[‘Input’], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
For each string in this list, a PatternGenerator of the requested pattern_type will be returned, with parameters whose values may depend on the string label supplied. For instance, if the list [“Pattern1”,”Pattern2”] is supplied, a metafeature function might inspect those pattern_labels and set parameters differently for Pattern1 and Pattern2, returning two different PatternGenerators with those pattern_labels.
param Dict composite_parameters (allow_None=False, constant=False, default={}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
If present, these parameter values will be passed to the composite specified in composite_type.
param List features_to_vary (allow_None=False, bounds=(0, None), constant=False, default=[‘xy’, ‘or’], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Stimulus features that the caller wishes to be varied, such as: :’xy’: Position in x and y coordinates :’or’: Orientation Subclasses and callers may extend this list to include any other features for which a coordinator has been defined in feature_coordinators.
param Integer master_seed (allow_None=False, bounds=None, constant=False, default=0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Base seed for all pattern parameter values. Each numbered pattern on each of the various pattern_labels will normally use a different random seed, but all of these seeds should include this master_seed value, so that changing it will change all of the random pattern parameter streams.
param ClassSelector composite_type (allow_None=False, constant=False, default=<class ‘imagen.patterngenerator.Composite’>, instantiate=True, is_instance=False, pickle_default_value=True, precedence=None, readonly=False)
Class that combines the patterns_per_label individual patterns and creates a single combined pattern that it returns for a given label. For instance, imagen.Composite can merge the individual patterns into a single pattern using a variety of operators like add or maximum, while imagen.Selector can choose one out of a given set of patterns.
param Dict pattern_parameters (allow_None=False, constant=False, default={‘aspect_ratio’: 4.66667, ‘size’: 0.088388}, instantiate=True, is_instance=True, pickle_default_value=True, precedence=None, readonly=False)
Parameter values to be passed to the PatternGenerator specified in pattern_type.
composite_type

alias of Composite

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbcc19a48>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbcc19d60>
inspect_value = <functools.partial object at 0x2adfbcc19e10>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pattern_type

alias of Gaussian

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbcc19db8>
set_param = <functools.partial object at 0x2adfbcc19f18>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterncoordinator.XCoordinator(**params)[source]

Bases: imagen.patterncoordinator.FeatureCoordinator

Chooses a random value for the x coordinate, subject to the provided position_bound_x.

param Number position_bound_x (allow_None=False, bounds=None, constant=False, default=0.8, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Left/rightmost position of the pattern center on the x axis.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbcc19ba8>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbcc19c00>
inspect_value = <functools.partial object at 0x2adfbcc19af8>
instance = <functools.partial object at 0x2adfbcc19cb0>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix='n ', unknown_value='<?>', qualify=False, separator='')

Same as Parameterized.pprint, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Same as Parameterized.script_repr, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbcc19d08>
set_param = <functools.partial object at 0x2adfbcc19ec0>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterncoordinator.YCoordinator(**params)[source]

Bases: imagen.patterncoordinator.FeatureCoordinator

Chooses a random value for the y coordinate, subject to the provided position_bound_y.

param Number position_bound_y (allow_None=False, bounds=None, constant=False, default=0.8, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Upper/lowermost position of the pattern center on the y axis.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbcc19d60>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbcc19e10>
inspect_value = <functools.partial object at 0x2adfbcc19db8>
instance = <functools.partial object at 0x2adfbcc19f18>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix='n ', unknown_value='<?>', qualify=False, separator='')

Same as Parameterized.pprint, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Same as Parameterized.script_repr, except that X.classname(Y is replaced with X.classname.instance(Y

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbcc19c58>
set_param = <functools.partial object at 0x2adfbcc19e68>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


patternfn Module

Family of two-dimensional functions indexed by x and y.

All functions are written to be valid both for scalar x and y, and for numpy arrays of x and y (in which case the result is also an array); the functions therefore have the same mathematical behaviour as numpy.

imagen.patternfn.arc_by_center(x, y, arc_box, constant_length, thickness, gaussian_width)[source]

Arc with Gaussian fall-off after the solid ring-shaped region and specified by point of tangency (x and y) and arc width and height.

This function calculates the start and end radian from the given width and height, and then calls arc_by_radian function to draw the curve.

imagen.patternfn.arc_by_radian(x, y, height, radian_range, thickness, gaussian_width)[source]

Radial arc with Gaussian fall-off after the solid ring-shaped region with the given thickness, with shape specified by the (start,end) radian_range.

imagen.patternfn.disk(x, y, height, gaussian_width)[source]

Circular disk with Gaussian fall-off after the solid central region.

imagen.patternfn.exponential(x, y, xscale, yscale)[source]

Two-dimensional oriented exponential decay pattern.

imagen.patternfn.float_error_ignore(*args, **kwds)[source]

Many of the functions in this module use Gaussian smoothing, which is based on a calculation like exp(divide(x*x,sigma)). When sigma is zero the value of this expression should be zero at all points in the plane, because such a Gaussian is infinitely small. Obtaining the correct answer using finite-precision floating-point array computations requires allowing infinite values to be returned from divide(), and allowing exp() to underflow silently to zero when given an infinite value. In numpy this is achieved by using its seterr() function to disable divide-by-zero and underflow warnings temporarily while these values are being computed.

imagen.patternfn.gabor(x, y, xsigma, ysigma, frequency, phase)[source]

Gabor pattern (sine grating multiplied by a circular Gaussian).

imagen.patternfn.gaussian(x, y, xsigma, ysigma)[source]

Two-dimensional oriented Gaussian pattern (i.e., 2D version of a bell curve, like a normal distribution but not necessarily summing to 1.0).

imagen.patternfn.line(y, thickness, gaussian_width)[source]

Infinite-length line with a solid central region, then Gaussian fall-off at the edges.

imagen.patternfn.log_gaussian(x, y, x_sigma, y_sigma, mu)[source]

Two-dimensional oriented Log Gaussian pattern (i.e., 2D version of a bell curve with an independent, movable peak). Much like a normal distribution, but not necessarily placing the peak above the center, and not necessarily summing to 1.0).

imagen.patternfn.ring(x, y, height, thickness, gaussian_width)[source]

Circular ring (annulus) with Gaussian fall-off after the solid ring-shaped region.

imagen.patternfn.sigmoid(axis, slope)[source]

Sigmoid dividing axis into a positive and negative half, with a smoothly sloping transition between them (controlled by the slope).

At default rotation, axis refers to the vertical (y) axis.

imagen.patternfn.smooth_rectangle(x, y, rec_w, rec_h, gaussian_width_x, gaussian_width_y)[source]

Rectangle with a solid central region, then Gaussian fall-off at the edges.


patterngenerator Module

Inheritance diagram of imagen.patterngenerator

PatternGenerator abstract class, basic example concrete class, and multichannel support.

PatternGenerators support both single-channel patterns, i.e. bare arrays, and multiple channels, such as for color images. See PatternGenerator.__call__ and PatternGenerator.channels for more information.

class imagen.patterngenerator.ChannelGenerator(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Abstract base class for patterns supporting multiple channels natively.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd7cd260>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd7cd1b0>
inspect_value = <functools.partial object at 0x2adfbd7cd2b8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd7cd208>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbd7cd0a8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterngenerator.ChannelTransform(**params)[source]

Bases: param.parameterized.Parameterized

A ChannelTransform is a callable object that takes channels as input (an ordered dictionary of arrays) and transforms their contents in some way before returning them.

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd7cd208>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd7cd2b8>
inspect_value = <functools.partial object at 0x2adfbd7cd100>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd7cd1b0>
set_param = <functools.partial object at 0x2adfbd7cd310>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterngenerator.ComposeChannels(**params)[source]

Bases: imagen.patterngenerator.ChannelGenerator

Create a multi-channel PatternGenerator from a list of PatternGenerators, with the specified channel_transforms applied.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param HookList channel_transforms (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
Optional functions to apply post processing to the set of channels.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01031’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=None, readonly=False)
List of patterns to use for each channel. Generators which already have more than one channel will only contribute to a single channel of ComposeChannels.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd7eb1b0>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd7eb2b8>
inspect_value = <functools.partial object at 0x2adfbd7eb0a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd7eb368>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbd7eb310>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterngenerator.Composite(**params)[source]

Bases: imagen.patterngenerator.CompositeBase

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.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘maximum’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd7fe208>
function(p)[source]

Constructs combined pattern out of the individual ones.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd7fe2b8>
inspect_value = <functools.partial object at 0x2adfbd7fe310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'maximum'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd7fe1b0>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbd7fe0a8>
state_pop()[source]

Pop the state of all generators

state_push()[source]

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterngenerator.CompositeBase(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

PatternGenerator that combines or selects from a list of other PatternGenerators.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd7fe3c0>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd7fe368>
inspect_value = <functools.partial object at 0x2adfbd7fe050>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd7fe0a8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbd7fe260>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterngenerator.Constant(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Constant pattern generator, i.e., a solid, uniform field of the same value.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd7fe2b8>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd7fe260>
inspect_value = <functools.partial object at 0x2adfbd7fe310>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd7fe158>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbd7fe100>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterngenerator.CorrelateChannels(**params)[source]

Bases: imagen.patterngenerator.ChannelTransform

Correlate channels by mixing a fraction of one channel into another.

param Number from_channel (allow_None=False, bounds=None, constant=False, default=1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Name of the channel to take data from.
param Number strength (allow_None=False, bounds=None, constant=False, default=0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Strength of the correlation to add, with 0 being no change, and 1.0 overwriting to_channel with from_channel.
param Number to_channel (allow_None=False, bounds=None, constant=False, default=2, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Name of the channel to change data of.
debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd7fe1b0>
get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd7fe158>
inspect_value = <functools.partial object at 0x2adfbd7fe208>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd7fe260>
set_param = <functools.partial object at 0x2adfbd7fe310>
state_pop()

Restore the most recently saved state.

See state_push() for more details.

state_push()

Save this instance’s state.

For Parameterized instances, this includes the state of dynamically generated values.

Subclasses that maintain short-term state should additionally save and restore that state using state_push() and state_pop().

Generally, this method is used by operations that need to test something without permanently altering the objects’ state.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.patterngenerator.PatternGenerator(**params)[source]

Bases: param.parameterized.Parameterized

A class hierarchy for callable objects that can generate 2D patterns.

Once initialized, PatternGenerators can be called to generate a value or a matrix of values from a 2D function, typically accepting at least x and y.

A PatternGenerator’s Parameters can make use of Parameter’s precedence attribute to specify the order in which they should appear, e.g. in a GUI. The precedence attribute has a nominal range of 0.0 to 1.0, with ordering going from 0.0 (first) to 1.0 (last), but any value is allowed.

The orientation and layout of the pattern matrices is defined by the SheetCoordinateSystem class, which see.

Note that not every parameter defined for a PatternGenerator will be used by every subclass. For instance, a Constant pattern will ignore the x, y, orientation, and size parameters, because the pattern does not vary with any of those parameters. However, those parameters are still defined for all PatternGenerators, even Constant patterns, to allow PatternGenerators to be scaled, rotated, translated, etc. uniformly.

param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))[source]

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)[source]

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbd834260>
function(p)[source]

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbd834208>
inspect_value = <functools.partial object at 0x2adfbd8342b8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()[source]

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbd834310>
set_matrix_dimensions(bounds, xdensity, ydensity)[source]

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbd834158>
state_pop()[source]

Restore the state of the output functions saved by state_push.

state_push()[source]

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.


random Module

Inheritance diagram of imagen.random

Two-dimensional pattern generators drawing from various random distributions.

class imagen.random.BinaryUniformRandom(**params)[source]

Bases: imagen.random.RandomGenerator

2D binary uniform random noise pattern generator.

Generates an array of random numbers that are 1.0 with the given on_probability, or else 0.0, then scales it and adds the offset as for other patterns. For the default scale and offset, the result is a binary mask where some elements are on at random.

param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter random_generator (allow_None=False, constant=False, default=<mtrand.RandomState object at 0x2adfbdabdd50>, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Using Numpy’s RandomState class instead of random.Random as the former can generate random arrays from more random distributions. See RandomState’s help for more information.
param Number on_probability (allow_None=False, bounds=[0.0, 1.0], constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Probability (in the range 0.0 to 1.0) that the binary value (before scaling) is on rather than off (1.0 rather than 0.0).
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdd42f70>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdd42f18>
inspect_value = <functools.partial object at 0x2adfbdd42fc8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdeeb050>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdeeb0a8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.DenseNoise(**params)[source]

Bases: imagen.random.RandomGenerator

2D Dense noise pattern generator, constrained to a grid.

Similar to UniformRandom, but draws the noise pattern in a grid that can be smaller than the actual density of the PatternGenerator.

By default, this produces a matrix with random values 0.0, 0.5, and 1. When a scale and an offset are provided the transformation maps them to:

0 -> offset 0.5 -> offset + 0.5 * scale 1 -> offset + scale
DenseNoise(grid_density=1, bounds=BoundingBox(radius=1),
xdensity=4, ydensity=4) will produce something like this:
[[ 1. 1. 1. 1. 0. 0. 0. 0. ]
[ 1. 1. 1. 1. 0. 0. 0. 0. ] [ 1. 1. 1. 1. 0. 0. 0. 0. ] Here the Sheet-coordinate size is 2.0x2.0, [ 1. 1. 1. 1. 0. 0. 0. 0. ] so grid_density=1 yields a 2x2 grid [ 0. 0. 0. 0. 0.5 0.5 0.5 0.5] sampled at 4 units per grid cell [ 0. 0. 0. 0. 0.5 0.5 0.5 0.5] [ 0. 0. 0. 0. 0.5 0.5 0.5 0.5] [ 0. 0. 0. 0. 0.5 0.5 0.5 0.5]])
DenseNoise(grid_density=2, bounds=BoundingBox(radius=1),
xdensity=4, ydensity=4) on the other hand will produce something like:
[[ 1. 1. 0. 0. 0. 0. 0.5 0.5]
[ 1. 1. 0. 0. 0. 0. 0.5 0.5] [ 1. 1. 1. 1. 0. 0. 0. 0. ] Again the Sheet-coordinate size is 2.0x2.0, [ 1. 1. 1. 1. 0. 0. 0. 0. ] but grid_density=2 yields a 4x4 grid [ 0. 0. 0.5 0.5 1. 1. 1. 1. ] with 2 units per grid cell [ 0. 0. 0.5 0.5 1. 1. 1. 1. ] [ 1. 1. 0. 0. 1. 1. 1. 1. ] [ 1. 1. 0. 0. 1. 1. 1. 1. ]]
  1. This method works much faster when the noise matrix falls neatly into the pixel matrix (~100 times faster).
  2. The value of each pixel in the generated pattern is determined by where the center of that pixel lies in the underlying grid, regardless of any overlap of that pixel with other grid squares.
  3. If a particular number of cells N is wanted, divide it by the length of the side of the bounding box to determine the grid_density. For example, if the user wants to have N=10 cells for a BoundingBox(radius=1) (which gives a bounding box size of 2.0x2.0), the grid_density must be set to N/2 = 5 in order to have ten cells.
  4. The xdensity and ydensity must both be at least as large as the grid_density, e.g. 5 for the above example.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter random_generator (allow_None=False, constant=False, default=<mtrand.RandomState object at 0x2adfbdabdd50>, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Using Numpy’s RandomState class instead of random.Random as the former can generate random arrays from more random distributions. See RandomState’s help for more information.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number grid_density (allow_None=False, bounds=(1, None), constant=False, default=10, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Grid elements per 1.0 distance in Sheet coordinates.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdd42f18>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdd42ec0>
inspect_value = <functools.partial object at 0x2adfbdefb050>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdefb100>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdefb158>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.GaussianCloud(**params)[source]

Bases: imagen.patterngenerator.Composite, numbergen.TimeAware

Uniform random noise masked by a circular Gaussian.

param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.4, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter operator (allow_None=False, constant=False, default=<ufunc ‘multiply’>, instantiate=False, pickle_default_value=True, precedence=0.98, readonly=False)
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 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]
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param List generators (allow_None=False, bounds=(1, None), constant=False, default=[Constant(bounds=BoundingBox(radius=0.5), group=’Pattern’, mask=None, mask_shape=None, name=’Constant01030’, offset=0.0, orientation=0.0, output_fns=[], position=[0.0, 0.0], scale=0.0, size=1.0, x=0.0, xdensity=256, y=0.0, ydensity=256, z=None)], instantiate=True, pickle_default_value=True, precedence=0.97, readonly=False)
List of patterns to combine or select from. The default pattern is a blank pattern, and thus should be overridden for any useful work.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Scaling factor applied to all sub-patterns.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param Number gaussian_size (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Size of the Gaussian pattern.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Number aspect_ratio (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.31, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Ratio of gaussian width to height; width is gaussian_size*aspect_ratio.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdd42db8>
function(p)

Constructs combined pattern out of the individual ones.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdd42e68>
inspect_value = <functools.partial object at 0x2adfbdf0d050>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

operator = <ufunc 'multiply'>
classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdf0d0a8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdf0d208>
state_pop()

Pop the state of all generators

state_push()

Push the state of all generators

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.GaussianRandom(**params)[source]

Bases: imagen.random.RandomGenerator

2D Gaussian random noise pattern generator.

Each pixel is chosen independently from a Gaussian distribution of zero mean and unit variance, then multiplied by the given scale and adjusted by the given offset.

param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=0.25, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter random_generator (allow_None=False, constant=False, default=<mtrand.RandomState object at 0x2adfbdabdd50>, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Using Numpy’s RandomState class instead of random.Random as the former can generate random arrays from more random distributions. See RandomState’s help for more information.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdd42e10>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdd42cb0>
inspect_value = <functools.partial object at 0x2adfbdf1f0a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdf1f050>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdf1f158>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.RandomDotStereogram(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator

Random dot stereogram using rectangular black and white patches.

Based on Matlab code originally from Jenny Read, reimplemented in Python by Tikesh Ramtohul (2006).

param Integer random_seed (allow_None=False, bounds=(0, 1000), constant=False, default=500, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.54, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Seed value for the random position of the dots.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number xdisparity (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.5, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Disparity in the horizontal direction.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number dotdensity (allow_None=False, bounds=(0.0, None), constant=False, default=0.5, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.52, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Number of dots per unit area; 0.5=50% coverage.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number dotsize (allow_None=False, bounds=(0.0, None), constant=False, default=0.1, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.53, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Edge length of each square dot.
param Number ydisparity (allow_None=False, bounds=(-1.0, 1.0), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.51, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Disparity in the vertical direction.
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdd42d60>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdd42ec0>
inspect_value = <functools.partial object at 0x2adfbdf2f050>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdf2f0a8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdf2f158>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.RandomGenerator(**params)[source]

Bases: imagen.patterngenerator.PatternGenerator, numbergen.TimeAwareRandomState

2D random noise pattern generator abstract class.

This class generalizes time-controlled randomness as defined by the numbergen.TimeAwareRandomState to imagen patterns. Time-controlled randomness allows random scalars to be generated as a function of time in numbergen, whereas in imagen it allows time-dependent random patterns with higer dimensionality.

The notion of time is defined by time_fn (inherited from TimeAwareRandomState) which outputs the time value. The time_dependent parameter then toggles between behaviour where a new random pattern is generated per call and where any randomness in the pattern is controlled as a function of time.

By default, RandomGenerators use the same global time_fn as numbergen objects, namely param.Dynamic.time_fn. This means that when set to time_dependent, the facilities of param.Time can be used. This allows the timeline to be explored non-linearly, e.g to reproduce a pattern from an earlier time.

For more information about time-dependent random number streams, consult the docstring of the TimeAwareRandomState class.

param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter random_generator (allow_None=False, constant=False, default=<mtrand.RandomState object at 0x2adfbdabdd50>, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Using Numpy’s RandomState class instead of random.Random as the former can generate random arrays from more random distributions. See RandomState’s help for more information.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdd42f18>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdd42d08>
inspect_value = <functools.partial object at 0x2adfbdf420a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdf42050>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdf42158>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.SparseNoise(**params)[source]

Bases: imagen.random.RandomGenerator

2D sparse noise pattern generator, with optional constraining to a grid.

Draws a square pixel of random brightness at a random location, either entirely random on the pattern surface or chosen from a predefined grid of possible positions.

By default, produces a matrix with 0.5 everywhere except for a square patch in one random location. This value is randomly assigned to either 0 or 1, and then is scaled with the parameters scale and offset in the following way:

0 -> offset 1 -> offset + scale
SparseNoise(grid_density=1, grid=True, bounds=BoundingBox(radius=1),
xdensity=4, ydensity=4) will produce something like this:
[[ 0.5 0.5 0.5 0.5 0. 0. 0. 0. ]
[ 0.5 0.5 0.5 0.5 0. 0. 0. 0. ] [ 0.5 0.5 0.5 0.5 0. 0. 0. 0. ] Here the Sheet-coordinate size is 2.0x2.0, [ 0.5 0.5 0.5 0.5 0. 0. 0. 0. ] so grid_density=1 yields a 2x2 grid [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] sampled at 4 units per grid cell, with 0.5 [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] everywhere except the one active cell [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]]
SparseNoise(grid_density=2, grid=True, bounds=BoundingBox(radius=1),
xdensity=4, ydensity=4) on the other hand will produce something like:
[[ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]
[ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] Again the Sheet-coordinate size is 2.0x2.0, [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] but grid_density=2 yields a 4x4 grid [ 0.5 0.5 0.5 0.5 0.5 0.5 1. 1. ] with 2 units per grid cell [ 0.5 0.5 0.5 0.5 0.5 0.5 1. 1. ] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]]
SparseNoise(grid_density=2, grid=False, bounds=BoundingBox(radius=1),
xdensity=4, ydensity=4) will produce something like:
[[ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]
[ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] Here notice that the patch is no longer [ 0.5 0.5 0.5 0.5 0.5 0. 0. 0.5] aligned with a fixed grid [ 0.5 0.5 0.5 0.5 0.5 0. 0. 0.5] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5] [ 0.5 0.5 0.5 0.5 0.5 0.5 0.5 0.5]]
  1. This method works ~100 times faster when the noise matrix falls neatly into the pixel matrix.
  2. The value of each pixel in the generated pattern is determined by where the center of that pixel lies in the underlying grid, regardless of any overlap of that pixel with other grid squares.
  3. If a particular number of cells N is wanted, divide it by the length of the side of the bounding box to determine the grid_density. For example, if the user wants to have N=10 cells for a BoundingBox(radius=1) (which gives a bounding box size of 2.0x2.0), the grid_density must be set to N/2 = 5 in order to have ten cells.
  4. The xdensity and ydensity must both be at least as large as the grid_density, e.g. 5 for the above example.
param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter random_generator (allow_None=False, constant=False, default=<mtrand.RandomState object at 0x2adfbdabdd50>, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Using Numpy’s RandomState class instead of random.Random as the former can generate random arrays from more random distributions. See RandomState’s help for more information.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Boolean grid (allow_None=False, bounds=(0, 1), constant=False, default=True, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
If True, each spot is snapped to a grid, so that subsequent spots are forced to overlap either entirely or not at all, never partially. Otherwise, the spot size is fixed by the grid_density, but it may appear anywhere.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
param Number grid_density (allow_None=False, bounds=(1, None), constant=False, default=10, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Grid elements per 1.0 distance in Sheet coordinates.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdf56050>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdf56100>
inspect_value = <functools.partial object at 0x2adfbdf560a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdf56158>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdf562b8>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.UniformRandom(**params)[source]

Bases: imagen.random.RandomGenerator

2D uniform random noise pattern generator.

param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter random_generator (allow_None=False, constant=False, default=<mtrand.RandomState object at 0x2adfbdabdd50>, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Using Numpy’s RandomState class instead of random.Random as the former can generate random arrays from more random distributions. See RandomState’s help for more information.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdf162b8>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdf161b0>
inspect_value = <functools.partial object at 0x2adfbdf16260>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdf16310>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdf16208>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

class imagen.random.UniformRandomInt(**params)[source]

Bases: imagen.random.RandomGenerator

2D distribution of integer values from low to high in the in the half-open interval [low, high).

Matches semantics of numpy.random.randint.

param Number ydensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the y direction. Typically the same as the xdensity.
param Number x (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.2, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
X-coordinate location of pattern center.
param Number scale (allow_None=False, bounds=None, constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Multiplicative strength of input pattern, defaulting to 1.0
param String group (allow_None=False, basestring=<type ‘basestring’>, constant=False, default=Pattern, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
The group name assigned to the returned HoloViews object.
param Number orientation (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Polar angle of pattern, i.e., the orientation in the Cartesian coordinate system, with zero at 3 o’clock and increasing counterclockwise.
param Parameter random_generator (allow_None=False, constant=False, default=<mtrand.RandomState object at 0x2adfbdabdd50>, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Using Numpy’s RandomState class instead of random.Random as the former can generate random arrays from more random distributions. See RandomState’s help for more information.
param Integer low (allow_None=False, bounds=None, constant=False, default=0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Lowest integer to be drawn from the distribution.
param ClassSelector z (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=-1, readonly=False)
The Dimension object associated with the z-values generated by the PatternGenerator . If None, uses the default set by HoloViews.Image.
param Parameter mask (allow_None=True, constant=False, default=None, instantiate=False, pickle_default_value=True, precedence=-1, readonly=False)
Optional object (expected to be an array) with which to multiply the pattern array after it has been created, before any output_fns are applied. This can be used to shape the pattern.
param BoundingRegionParameter bounds (allow_None=False, constant=False, default=BoundingBox(radius=0.5), instantiate=True, pickle_default_value=True, precedence=-1, readonly=False)
BoundingBox of the area in which the pattern is generated.
param Callable time_fn (allow_None=False, constant=False, default=<Time Time00001>, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Callable used to specify the time that determines the state and return value of the object, if time_dependent=True.
param Number xdensity (allow_None=False, bounds=(0, None), constant=False, default=256, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=-1, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Density (number of samples per 1.0 length) in the x direction.
param Number y (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.21, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Y-coordinate location of pattern center.
param Integer high (allow_None=False, bounds=None, constant=False, default=2, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=None, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
The highest integer to be drawn from the distribution.
param HookList output_fns (allow_None=False, bounds=(0, None), constant=False, default=[], instantiate=True, pickle_default_value=True, precedence=0.08, readonly=False)
Optional function(s) to apply to the pattern array after it has been created. Can be used for normalization, thresholding, etc.
param Boolean time_dependent (allow_None=False, bounds=(0, 1), constant=False, default=False, instantiate=False, pickle_default_value=True, precedence=None, readonly=False)
Whether the given time_fn should be used to constrain the results generated.
param Number offset (allow_None=False, bounds=None, constant=False, default=0.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.11, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Additive offset to input pattern, defaulting to 0.0
param ClassSelector mask_shape (allow_None=True, constant=False, default=None, instantiate=True, is_instance=True, pickle_default_value=True, precedence=0.06, readonly=False)
Optional PatternGenerator used to construct a mask to be applied to the pattern.
param Composite position (allow_None=True, attribs=[‘x’, ‘y’], constant=False, default=None, instantiate=False, objtype=<class ‘imagen.patterngenerator.PatternGenerator’>, pickle_default_value=True, precedence=-1, readonly=False)
Coordinates of location of pattern center. Provides a convenient way to set the x and y parameters together as a tuple (x,y), but shares the same actual storage as x and y (and thus only position OR x and y need to be specified).
param Number size (allow_None=False, bounds=(0.0, None), constant=False, default=1.0, inclusive_bounds=(True, True), instantiate=False, pickle_default_value=True, precedence=0.3, readonly=False, time_dependent=False, time_fn=<Time Time00001>)
Determines the overall size of the pattern.
anim(duration, offset=0, timestep=1, label=None, unit=None, time_fn=Time(label='Time', name='Time00001', time_type=<type 'int'>, timestep=1.0, unit=None, until=Infinity()))

duration: The temporal duration to animate in the units defined on the global time function.

offset: The temporal offset from which the animation is generated given the supplied pattern

timestep: The time interval between successive frames. The duration must be an exact multiple of the timestep.

label: A label string to override the label of the global time function (if not None).

unit: The unit string to override the unit value of the global time function (if not None).

time_fn: The global time function object that is shared across the time-varying objects that are being sampled.

Note that the offset, timestep and time_fn only affect patterns parameterized by time-dependent number generators. Otherwise, the frames are generated by successive call to the pattern which may or may not be varying (e.g to view the patterns contained within a Selector).

channels(use_cached=False, **params_to_override)

Channels() adds a shared interface for single channel and multichannel structures. It will always return an ordered dict: its first element is the single channel of the pattern (if single-channel) or the channel average (if multichannel); the successive elements are the individual channels’ arrays (key: 0,1,..N-1).

debug(msg, *args, **kw)

Print msg merged with args as a debugging statement.

See Python’s logging module for details of message formatting.

defaults()

Return {parameter_name:parameter.default} for all non-constant Parameters.

Note that a Parameter for which instantiate==True has its default instantiated.

force_new_dynamic_value = <functools.partial object at 0x2adfbdf761b0>
function(p)

Function to draw a pattern that will then be scaled and rotated.

Instead of implementing __call__ directly, PatternGenerator subclasses will typically implement this helper function used by __call__, because that way they can let __call__ handle the scaling and rotation for them. Alternatively, __call__ itself can be reimplemented entirely by a subclass (e.g. if it does not need to do any scaling or rotation), in which case this function will be ignored.

get_param_values(onlychanged=False)

Return a list of name,value pairs for all Parameters of this object.

If onlychanged is True, will only return values that are not equal to the default value.

get_value_generator = <functools.partial object at 0x2adfbdf76260>
inspect_value = <functools.partial object at 0x2adfbdf760a8>
message(msg, *args, **kw)

Print msg merged with args as a message.

See Python’s logging module for details of message formatting.

num_channels()

Query the number of channels implemented by the PatternGenerator. In case of single-channel generators this will return 1; in case of multichannel, it will return the number of channels (eg, in the case of RGB images it would return ‘3’, Red-Green-Blue, even though the OrderedDict returned by channels() will have 4 elements – the 3 channels + their average).

classmethod params(parameter_name=None)

Return the Parameters of this class as the dictionary {name: parameter_object}

Includes Parameters from this class and its superclasses.

pprint(imports=None, prefix=' ', unknown_value='<?>', qualify=False, separator='')

(Experimental) Pretty printed representation that may be evaluated with eval. See pprint() function for more details.

classmethod print_param_defaults()

Print the default values of all cls’s Parameters.

print_param_values()

Print the values of all this object’s Parameters.

script_repr(imports=, []prefix=' ')

Variant of __repr__ designed for generating a runnable script.

classmethod set_default(param_name, value)

Set the default value of param_name.

Equivalent to setting param_name on the class.

set_dynamic_time_fn = <functools.partial object at 0x2adfbdf762b8>
set_matrix_dimensions(bounds, xdensity, ydensity)

Change the dimensions of the matrix into which the pattern will be drawn. Users of this class should call this method rather than changing the bounds, xdensity, and ydensity parameters directly. Subclasses can override this method to update any internal data structures that may depend on the matrix dimensions.

set_param = <functools.partial object at 0x2adfbdf76100>
state_pop()

Restore the state of the output functions saved by state_push.

state_push()

Save the state of the output functions, to be restored with state_pop.

verbose(msg, *args, **kw)

Print msg merged with args as a verbose message.

See Python’s logging module for details of message formatting.

warning(msg, *args, **kw)

Print msg merged with args as a warning, unless module variable warnings_as_exceptions is True, then raise an Exception containing the arguments.

See Python’s logging module for details of message formatting.

imagen.random.seed(seed=None)[source]

Set the seed on the shared RandomState instance.