wepy.reporter.restree module¶
Provides a reporter for generating graphical depictions of resampling parent trees.
- class wepy.reporter.restree.ResTreeReporter(resampler=None, boundary_conditions=None, row_spacing=None, step_spacing=None, default_node_radius=None, progress_key=None, max_progress_value=None, colormap_name='plasma', **kwargs)[source]¶
Bases:
ProgressiveFileReporter
Reporter that generates resampling parent trees in the GEXF format.
Constructor for the ResTreeReporter.
- Parameters:
resampler (Resampler) – Used to generate parental relations from resampling records.
boundary_condition (BoundaryCondition, optional) –
- Used to determine discontinuities in the lineages.
(Default value = None)
row_spacing (float, default: 5.0) – Spacing between nodes in a single row in layout.
step_spacing (float, default: 20.0) – Spacing between the rows of nodes in each step of the layout.
default_node_radius (float, default: 1.0) – Default node radius to use.
progress_key (str) – The key of the value in the progress records to use for coloring nodes in the tree.
max_progress_value (float or None) – The maximum value to consider for progress values, if None no max value will be used.
colormap_name (str, default: 'plasma') – The name of the colormap to use from the matplotlib colormap library (i.e. ‘matplotlib.cm.get_cmap’)
- FILE_ORDER = ('gexf_restree_path',)¶
Specify an ordering of file paths. Should be customized.
- SUGGESTED_EXTENSIONS = ('restree.gexf',)¶
Suggested extensions for file paths for use with the automatic reparametrization feature. Should be customized.
- MAX_PROGRESS_NORM = 1.0¶
- DISCONTINUOUS_NODE_SHAPE = 'square'¶
The shape of nodes that signify a discontinuity in the lineage.
- DEFAULT_NODE_SHAPE = 'disc'¶
The shape of normal nodes that signify a continuity in the lineage.
- property parent_table¶
The net parent table datastructure.
- _make_resampling_record(record_d, cycle_idx)[source]¶
Make a namedtuple resampling record from a dictionary representation.
- _make_warping_record(record_d, cycle_idx)[source]¶
Make a namedtuple warping record from a dictionary representation.
- DEFAULT_MODE = 'x'¶
The default mode to set for opening files if none is specified (create if doesn’t exist, fail if it does.)
- DEFAULT_SUGGESTED_EXTENSION = 'report'¶
The default file extension used for files during dynamic reparametrization, if none is specified
- MODES = ('x', 'w', 'w-', 'r', 'r+')¶
Valid modes accepted for files.
- SUGGESTED_FILENAME_TEMPLATE = '{config}{narration}{reporter_class}.{ext}'¶
Template to use for dynamic reparametrization of file path names.
The fields in the template are:
config : indicator of the runtime configuration used
narration : freeform description of the instance
- reporter_classthe name of the class that produced the
output. When no specific name is given for a file report generated from a reporter this is used to disambiguate, along with the extension.
ext : The file extension, for multiple files produced from one reporter this should be sufficient to disambiguate the files.
The ‘config’ and ‘narration’ should be the same across all reporters in the same simulation manager, and the ‘narration’ is considered optional.
- static _make_record(record_d, cycle_idx, record_field_names, field_names, field_shapes, rec_namedtuple)[source]¶
Generic record making function.
- Parameters:
- Returns:
record
- Return type:
namedtuple object
- _validate_mode(mode)¶
Check if the mode spec is a valid one.
- cleanup(**kwargs)¶
Teardown routines for the reporter at the end of the simulation.
Use to cleanly and safely close I/O connections or other cleanup I/O.
Use to close file descriptors, database connections etc.
Reporters can expect to have the following key word arguments passed to them during a simulation by the sim_manager.
- Parameters:
runner (Runner object) – The runner at the end of the simulation
work_mapper (WorkeMapper object) – The work mapper at the end of the simulation
resampler (Resampler object) – The resampler at the end of the simulation
boundary_conditions (BoundaryConditions object) – The boundary conditions at the end of the simulation
reporters (list of Reporter objects) – The list of reporters at the end of the simulation
- property file_path¶
For single file path reporters the file path to that file spec.
- property file_paths¶
The file paths for this reporter, in order.
- init(**kwargs)¶
Construct a ProgressiveFileReporter.
This is exactly the same as the FileReporter.
- Parameters:
See also
- property mode¶
For single file path reporters the mode of that file.
- property modes¶
The modes for the files, in order.
- reparametrize(file_paths, modes)¶
Set the file paths and modes for all files in the reporter.
- set_mode(file_idx, mode)¶
Set the mode for a single indexed file.
- set_path(file_idx, path)¶
Set the path for a single indexed file.