hyperspy/hyperspy — pull request #401 by to266 (2014-11-04 12:12:17+00:00)
Title: Enh whitelist

Added _whitelist for parameter, component and model classes.
The whitelist convention for the time being is as follows:
```python
"""
whitelist : dictionary
A dictionary, keys of which are used as attributes for exporting/loading.
For easier loading afterwards, highly advisable to contain key '_whitelist'.
The convention is as follows:
* key starts with '_init_' (e.g. key = '_init_volume'):
object of the whitelist[key] is saved, used for initialization of the target
* key starts with '_fn_' (e.g. key = '_fn_twin_function'):
the targeted attribute is a function, and may be pickled (preferably with dill package).
A tuple of (thing, value) is exported, where thing is None if function is passed as-is, and bool if
dill package is used to pickle the function, value is the result.
* key is '_id_' (e.g. key = '_id_'):
the id of the target is exported (e.g. id(target) ),
most often later used to reconstruct twins of parameters
"""
```
There are still few attributes of each class that are not included in the whitelist, because they are unique and
should be dealt with explicitly:

model: components, spectrum
component: parameters
parameter: twins

Obviously the convention can be changed, as very little functionality is already in place (at least in the PR). Once we decide on the convention, I will add suitable attributes to particular components that require any additional entries (i.e. _whitelist['_init_spectrum'] for ScalableFixedPattern and similar)