You're reading the documentation for a development version. For the latest released version, please have a look at v0.11.

aspecd.history module

History: Classes collecting information on what has been done to a dataset.

Reproducibility is an essential aspect of good scientific practice. In the context of data processing and analysis, this means that each processing step performed on data (of a dataset) should be stored in a reproducible way and preferably in a consistent format.

To be of actual use, an entry of the history needs to contain all information necessary to reproduce the processing step in its original form. This includes as a minimum the name of the processing routine used, the complete list of necessary parameters for that routine, and a unique version information of the routine. Additional useful aspects contain information about the operating system used, the name of the operator, and the date the processing step has been performed.

Furthermore, for reproducing data processing and analysis tasks in a modular fashion, there should be a way to create the actual objects for operating on a dataset from the history records stored in the history of the dataset. Furthermore, it is important to not store the actual objects (or a representation) of the individual tasks. Firstly, this would easily result in an infinite regress, as the dataset is referenced from within the task objects, and secondly, importing a stored dataset with a history would not work if during import the actual objects of the individual tasks need to be restored and the class has changed or does not exist (anymore). Thus, operating with history records is the most modular and robust way.

Types of history records

In addition, to handle the history contained within a dataset, there is a series of classes for storing history records:

Todo

Clarifly the difference between the HistoryRecord and Record classes, and explain which is used when and how.

Module documentation

class aspecd.history.HistoryRecord(package='')

Bases: ToDictMixin

Generic base class for all kinds of history records.

For all classes operating on datasets, such as aspecd.processing.SingleProcessingStep, aspecd.analysis.SingleAnalysisStep and others, there exist at least two “representations”: (i) the generic one not (necessarily) tied to any concrete dataset, thus portable, and (ii) a concrete one having operated on a dataset and thus being accompanied with information about who has done what when how to what dataset.

For this second type, a history class derived from aspecd.dataset.HistoryRecord gets used, and it is this second type that is stored inside the Dataset object.

date

datetime object with date current at HistoryRecord instantiation

Type:

datetime.datetime

sysinfo

key–value store with crucial system parameters, including user login name

Type:

aspecd.system.SystemInfo

Parameters:

package (str) –

Name of package the history record gets recorded for

Prerequisite for reproducibility, gets stored in the sysinfo attribute. Will usually be provided automatically by the dataset.

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Datetime objects are set correctly from the string.

If the corresponding attribute is an object having a from_dict method itself, this method will be called accordingly, making cascading calls possible.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.ProcessingStepRecord(processing_step=None)

Bases: ToDictMixin

Base class for processing step records stored in the dataset history.

The history of a aspecd.dataset.Dataset should not contain references to aspecd.processing.SingleProcessingStep objects, but rather records that contain all necessary information to create the respective objects inherited from aspecd.processing.SingleProcessingStep. One reason for this is simply that we want to import datasets containing processing steps in their history for which no corresponding processing class exists in the current installation of the application.

Note

Each history entry in a dataset stores the processing as a aspecd.history.ProcessingStepRecord, even in applications inheriting from the ASpecD framework. Hence, subclassing of this class should normally not be necessary.

undoable

Can this processing step be reverted?

Type:

bool

description

Short description, to be set in class definition

Type:

str

parameters

Parameters required for performing the processing step

All parameters, implicit and explicit.

Type:

dict

comment

User-supplied comment describing intent, purpose, reason, …

Type:

str

references

List of references with relevance for the implementation of the processing step.

Use appropriate record types from the bibrecord package.

Type:

list

class_name

Fully qualified name of the class of the corresponding processing step

Type:

str

Parameters:

processing_step (aspecd.processing.SingleProcessingStep) – Processing step the record should be created for.

Raises:

aspecd.processing.MissingProcessingStepError – Raised when no processing step exists to act on

from_processing_step(processing_step)

Obtain information from processing step.

Parameters:

processing_step (aspecd.processing.SingleProcessingStep) – Object to obtain information from

create_processing_step()

Create a processing step object from the parameters stored.

Returns:

processing_step – actual processing step object that can be used for processing, e.g., in context of undo/redo

Return type:

aspecd.processing.SingleProcessingStep

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.ProcessingHistoryRecord(processing_step=None, package='')

Bases: HistoryRecord

History record for processing steps on datasets.

processing

record of the processing step

Type:

aspecd.history.ProcessingStepRecord

Parameters:
  • processing_step (aspecd.processing.SingleProcessingStep) – processing step the history is saved for

  • package (str) –

    Name of package the history record gets recorded for

    Prerequisite for reproducibility, gets stored in the aspecd.dataset.HistoryRecord.sysinfo attribute. Will usually be provided automatically by the dataset.

property undoable

Can this processing step be reverted?

replay(dataset)

Replay the processing step saved in the history record.

Parameters:

dataset (aspecd.dataset.Dataset) – dataset the processing step should be replayed to

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Datetime objects are set correctly from the string.

If the corresponding attribute is an object having a from_dict method itself, this method will be called accordingly, making cascading calls possible.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.AnalysisStepRecord(analysis_step=None)

Bases: ToDictMixin

Base class for analysis step records.

The analysis of a aspecd.dataset.Dataset should not contain references to aspecd.analysis.AnalysisStep objects, but rather records that contain all necessary information to create the respective objects inherited from aspecd.analysis.AnalysisStep. One reason for this is simply that we want to import datasets containing analysis steps in their analyses for which no corresponding analysis class exists in the current installation of the application. Another is to not have an infinite recursion of datasets, as the dataset is stored in an aspecd.analysis.AnalysisStep object.

description

Short description, to be set in class definition

Type:

str

parameters

Parameters required for performing the analysis step

All parameters, implicit and explicit.

Type:

dict

result

Results of the analysis step

Can be either a aspecd.dataset.Dataset or some other class, e.g., aspecd.metadata.PhysicalQuantity.

In case of a dataset, it is a calculated dataset (aspecd.dataset.CalculatedDataset)

comment

User-supplied comment describing intent, purpose, reason, …

Type:

str

references

List of references with relevance for the implementation of the processing step.

Use appropriate record types from the bibrecord package.

Type:

list

class_name

Fully qualified name of the class of the corresponding analysis step

Type:

str

Parameters:

analysis_step (aspecd.analysis.SingleAnalysisStep) – Analysis step the record should be created for.

Raises:

aspecd.analysis.MissingAnalysisStepError – Raised when no analysis step exists to act on

from_analysis_step(analysis_step)

Obtain information from analysis step.

Parameters:

analysis_step (aspecd.analysis.AnalysisStep) – Object to obtain information from

create_analysis_step()

Create an analysis step object from the parameters stored.

Returns:

analysis_step – actual analysis step object that can be used for analysis

Return type:

aspecd.analysis.SingleAnalysisStep

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.SingleAnalysisStepRecord(analysis_step=None)

Bases: AnalysisStepRecord

Base class for analysis step records stored in the dataset analyses.

The analysis of a aspecd.dataset.Dataset should not contain references to aspecd.analysis.AnalysisStep objects, but rather records that contain all necessary information to create the respective objects inherited from aspecd.analysis.AnalysisStep. One reason for this is simply that we want to import datasets containing analysis steps in their analyses for which no corresponding analysis class exists in the current installation of the application. Another is to not have an infinite recursion of datasets, as the dataset is stored in an aspecd.analysis.AnalysisStep object.

Note

Each analyses entry in a dataset stores the analysis step as a aspecd.history.SingleAnalysisStepRecord, even in applications inheriting from the ASpecD framework. Hence, subclassing of this class should normally not be necessary.

preprocessing

List of processing steps

The actual processing steps are objects of the class aspecd.processing.ProcessingStepRecord.

Type:

list

Parameters:

analysis_step (aspecd.analysis.SingleAnalysisStep) – Analysis step the record should be created for.

from_analysis_step(analysis_step)

Obtain information from analysis step.

Parameters:

analysis_step (aspecd.analysis.AnalysisStep) – Object to obtain information from

create_analysis_step()

Create an analysis step object from the parameters stored.

Returns:

analysis_step – actual analysis step object that can be used for analysis

Return type:

aspecd.analysis.SingleAnalysisStep

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.AnalysisHistoryRecord(analysis_step=None, package='')

Bases: HistoryRecord

History record for analysis steps on datasets.

analysis

Analysis step the history is saved for

Type:

aspecd.analysis.SingleAnalysisStep

Parameters:
replay(dataset)

Replay the analysis step saved in the history record.

Parameters:

dataset (aspecd.dataset.Dataset) – dataset the analysis step should be replayed to

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Datetime objects are set correctly from the string.

If the corresponding attribute is an object having a from_dict method itself, this method will be called accordingly, making cascading calls possible.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.AnnotationRecord(annotation=None)

Bases: ToDictMixin

Base class for annotation records stored in the dataset annotations.

The annotation of a aspecd.dataset.Dataset should not contain references to aspecd.annotation.DatasetAnnotation objects, but rather records that contain all necessary information to create the respective objects inherited from aspecd.annotation.DatasetAnnotation. One reason for this is simply that we want to import datasets containing annotations in their analyses for which no corresponding annotation class exists in the current installation of the application. Another is to not have an infinite recursion of datasets, as the dataset is stored in an aspecd.annotation.DatasetAnnotation object.

Note

Each annotation entry in a dataset stores the annotation as a aspecd.history.AnnotationRecord, even in applications inheriting from the ASpecD framework. Hence, subclassing of this class should normally not be necessary.

content

Actual content of the annotation

Generic place for more information

Type:

dict

class_name

Fully qualified name of the class of the corresponding annotation

Type:

str

type

Type of the annotation, usually similar to the class name but human-readable and useful, e.g., in reports.

Type:

str

Parameters:

annotation (aspecd.annotation.DatasetAnnotation) – Annotation the record should be created for.

Raises:

aspecd.annotation.MissingAnnotationError – Raised when no annotation exists to act on

Changed in version 0.6: Added attribute type

from_annotation(annotation)

Obtain information from annotation.

Parameters:

annotation (aspecd.annotation.DatasetAnnotation) – Object to obtain information from

create_annotation()

Create an annotation object from the parameters stored.

Returns:

annotation – actual annotation object that can be used for annotation

Return type:

aspecd.annotation.DatasetAnnotation

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.AnnotationHistoryRecord(annotation=None, package='')

Bases: HistoryRecord

History record for annotations of datasets.

annotation

Annotation the history is saved for

Type:

aspecd.annotation.DatasetAnnotation

Parameters:
  • annotation (aspecd.annotation.AnnotationRecord) – Annotation the history is saved for

  • package (str) – Name of package the history record gets recorded for

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Datetime objects are set correctly from the string.

If the corresponding attribute is an object having a from_dict method itself, this method will be called accordingly, making cascading calls possible.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.PlotRecord(plotter=None)

Bases: ToDictMixin

Base class for records storing information about a plot.

For reproducibility of plots performed on either a single dataset or multiple datasets, information for each plot needs to be collected that suffices to reproduce the plot. This is what a PlotRecord is good for.

All information will usually be obtained from a plotter object, either by instantiating a PlotRecord object providing a plotter object, or by calling from_plotter() on a PlotRecord object.

Subclasses for aspecd.plotting.SinglePlotter and aspecd.plotting.MultiPlotter objects are available, namely aspecd.plotting.SinglePlotRecord and aspecd.plotting.MultiPlotRecord.

class_name

Name of the plotter.

Defaults to the plotter class name and shall never be set manually.

Type:

str

description

Short description of the plot

Type:

str

parameters

All parameters necessary for the plot, implicit and explicit

Type:

dict

properties

Properties of the plot, defining its appearance

Type:

aspecd.plotting.PlotProperties

caption

User-supplied information for the figure.

Type:

aspecd.plotting.Caption

label

Label used to reference figure, e.g. in context of a report

Type:

str

filename

Name of the file the plot has been/should be saved to

Type:

str

Parameters:

plotter (aspecd.plotting.Plotter) – Plotter object to obtain information from

Raises:

aspecd.plotting.MissingPlotterError – Raised if no plotter is provided.

Changed in version 0.6: New attribute label

from_plotter(plotter=None)

Obtain information from plotter.

Parameters:

plotter (aspecd.plotting.Plotter) – Plotter object to obtain information from

Raises:

aspecd.plotting.MissingPlotterError – Raised if no plotter is provided.

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.SinglePlotRecord(plotter=None)

Bases: PlotRecord

Record for SinglePlotter objects.

When plotting data of a single dataset, classes derived from aspecd.plotting.SinglePlotter will be used. The information obtained from these plotters will be stored in a SinglePlotRecord object.

preprocessing

List of processing steps

The actual processing steps are objects of the class aspecd.processing.ProcessingStepRecord.

Type:

list

Parameters:

plotter (aspecd.plotting.Plotter) – Plotter object to obtain information from

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

from_plotter(plotter=None)

Obtain information from plotter.

Parameters:

plotter (aspecd.plotting.Plotter) – Plotter object to obtain information from

Raises:

aspecd.plotting.MissingPlotterError – Raised if no plotter is provided.

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.MultiPlotRecord(plotter=None)

Bases: PlotRecord

Record for MultiPlotter objects.

When plotting data of multiple datasets, classes derived from aspecd.plotting.MultiPlotter will be used. The information obtained from these plotters will be stored in a MultiPlotRecord object.

datasets

List of datasets whose data appear in the plot.

Type:

list

Parameters:

plotter (aspecd.plotting.Plotter) – Plotter object to obtain information from

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

from_plotter(plotter=None)

Obtain information from plotter.

Parameters:

plotter (aspecd.plotting.Plotter) – Plotter object to obtain information from

Raises:

aspecd.plotting.MissingPlotterError – Raised if no plotter is provided.

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.PlotHistoryRecord(package='')

Bases: HistoryRecord

History record for plots of datasets.

plot

Plot the history is saved for

Type:

aspecd.plotting.SinglePlotRecord

Parameters:

package (str) – Name of package the history record gets recorded for

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Datetime objects are set correctly from the string.

If the corresponding attribute is an object having a from_dict method itself, this method will be called accordingly, making cascading calls possible.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.TableRecord(table=None)

Bases: ToDictMixin

Base class for table records.

For reproducibility of tabulating, information for each table needs to be collected that suffices to reproduce the table. This is what a TableRecord is good for.

All information will usually be obtained from a table object, either by instantiating a TableRecord object providing a table object, or by calling from_table() on a TableRecord object.

caption

User-supplied information for the table.

Type:

aspecd.plotting.Caption

format

Identifier for table output format.

Type:

str

column_format

(Optional) formats for the data

Type:

list

filename

Name of the file the table has been/should be saved to

Type:

str

class_name

Fully qualified name of the class of the corresponding table

Type:

str

Parameters:

table (aspecd.table.Table) – Table the record should be created for.

Raises:

TypeError – Raised when no table exists to act on

from_table(table=None)

Obtain information from table.

Parameters:

table (aspecd.table.Table) – Table object to obtain information from

Raises:

TypeError – Raised if no table is provided.

create_table()

Create a table object from the parameters stored.

Returns:

table – actual table object that can be used for tabulating

Return type:

aspecd.table.Table

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.TableHistoryRecord(table=None, package='')

Bases: HistoryRecord

History record for tables created from datasets.

table

Table the history is saved for

Type:

aspecd.table.Table

Parameters:
  • table (aspecd.table.Table) – Table the history is saved for

  • package (str) – Name of package the history record gets recorded for

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Datetime objects are set correctly from the string.

If the corresponding attribute is an object having a from_dict method itself, this method will be called accordingly, making cascading calls possible.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.DatasetExporterRecord(exporter=None)

Bases: ToDictMixin

Base class for dataset exporter records stored in the dataset tasks.

The tasks list of a aspecd.dataset.Dataset should not contain references to aspecd.io.DatasetExporter objects, but rather records that contain all necessary information to create the respective objects inherited from aspecd.io.DatasetExporter. One reason for this is simply that we want to import datasets containing export tasks for which no corresponding exporter class exists in the current installation of the application.

class_name

Fully qualified name of the class of the corresponding annotation

Type:

str

target

specifier of the target the data and metadata were written to

Type:

str

comment

User-supplied comment describing intent, purpose, reason, …

Type:

str

Parameters:

exporter (aspecd.io.DatasetExporter) – Dataset exporter the record should be created for.

Raises:

TypeError – Raised when no exporter exists to act on

New in version 0.9.

create_exporter()

Create a dataset exporter object from the parameters stored.

Returns:

exporter – actual exporter object that can be used for exporting the dataset

Return type:

aspecd.io.DatasetExporter

from_exporter(exporter=None)

Obtain information from dataset exporter.

Parameters:

exporter (aspecd.io.DatasetExporter) – Dataset exporter object to obtain information from

Raises:

TypeError – Raised if no exporter is provided.

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.

class aspecd.history.DatasetExporterHistoryRecord(exporter=None, package='')

Bases: HistoryRecord

History record for dataset exporters created from datasets.

exporter

Dataset exporter the history is saved for

Type:

aspecd.io.DatasetExporter

Parameters:
  • exporter (aspecd.table.DatasetExporter) – Dataset exporter the history is saved for

  • package (str) – Name of package the history record gets recorded for

New in version 0.9.

from_dict(dict_=None)

Set properties from dictionary.

Only parameters in the dictionary that are valid properties of the class are set accordingly.

Datetime objects are set correctly from the string.

If the corresponding attribute is an object having a from_dict method itself, this method will be called accordingly, making cascading calls possible.

Parameters:

dict (dict) – Dictionary containing properties to set

to_dict(remove_empty=False)

Create dictionary containing public attributes of an object.

Parameters:

remove_empty (bool) –

Whether to remove keys with empty values

Default: False

Returns:

public_attributes – Ordered dictionary containing the public attributes of the object

The order of attribute definition is preserved

Return type:

collections.OrderedDict

Changed in version 0.6: New parameter remove_empty

Changed in version 0.9: Settings for properties to exclude and include are not traversed

Changed in version 0.9.1: Dictionaries get copied before traversing, as otherwise, the special variables __dict__ and __0dict__ are modified, what may result in strange behaviour.

Changed in version 0.9.2: Dictionaries do not get copied by default, but there is a private method that can be overridden in derived classes to copy the dictionary.