Example #1
0
    def as_dictionary(self, fullcopy=True):
        """Returns parameter as a dictionary, saving all attributes from
        self._whitelist.keys() For more information see
        :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`

        Parameters
        ----------
        fullcopy : Bool (optional, False)
            Copies of objects are stored, not references. If any found,
            functions will be pickled and signals converted to dictionaries
        Returns
        -------
        dic : dictionary with the following keys:
            _id_name : string
                _id_name of the original parameter, used to create the
                dictionary. Has to match with the self._id_name
            _twins : list
                a list of ids of the twins of the parameter
            _whitelist : dictionary
                a dictionary, which keys are used as keywords to match with the
                parameter attributes.  For more information see
                :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`
            * any field from _whitelist.keys() *

        """
        dic = {'_twins': [id(t) for t in self._twins]}
        export_to_dictionary(self, self._whitelist, dic, fullcopy)
        return dic
Example #2
0
    def as_dictionary(self, fullcopy=True):
        """Returns component as a dictionary
        For more information on method and conventions, see
        :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`

        Parameters
        ----------
        fullcopy : Bool (optional, False)
            Copies of objects are stored, not references. If any found,
            functions will be pickled and signals converted to dictionaries

        Returns
        -------
        dic : dictionary
            A dictionary, containing at least the following fields:
            parameters : list
                a list of dictionaries of the parameters, one per
            _whitelist : dictionary
                a dictionary with keys used as references saved attributes, for
                more information, see
                :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`
            * any field from _whitelist.keys() *
        """
        dic = {
            'parameters': [p.as_dictionary(fullcopy) for p in self.parameters]
        }
        dic.update(get_object_package_info(self))
        export_to_dictionary(self, self._whitelist, dic, fullcopy)
        from hyperspy.model import _COMPONENTS
        if self._id_name not in _COMPONENTS:
            import dill
            dic['_class_dump'] = dill.dumps(self.__class__)
        return dic
Example #3
0
 def as_dictionary(self, fullcopy=True):
     """Returns component as a dictionary
     For more information on method and conventions, see
     :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`
     Parameters
     ----------
     fullcopy : Bool (optional, False)
         Copies of objects are stored, not references. If any found,
         functions will be pickled and signals converted to dictionaries
     Returns
     -------
     dic : dictionary
         A dictionary, containing at least the following fields:
         parameters : list
             a list of dictionaries of the parameters, one per
         _whitelist : dictionary
             a dictionary with keys used as references saved attributes, for
             more information, see
             :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`
         * any field from _whitelist.keys() *
     """
     dic = {
         'parameters': [p.as_dictionary(fullcopy) for p in self.parameters]
     }
     export_to_dictionary(self, self._whitelist, dic, fullcopy)
     return dic
Example #4
0
    def as_dictionary(self, fullcopy=True):
        """Returns parameter as a dictionary, saving all attributes from
        self._whitelist.keys() For more information see
        :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`

        Parameters
        ----------
        fullcopy : Bool (optional, False)
            Copies of objects are stored, not references. If any found,
            functions will be pickled and signals converted to dictionaries
        Returns
        -------
        dic : dictionary with the following keys:
            _id_name : string
                _id_name of the original parameter, used to create the
                dictionary. Has to match with the self._id_name
            _twins : list
                a list of ids of the twins of the parameter
            _whitelist : dictionary
                a dictionary, which keys are used as keywords to match with the
                parameter attributes.  For more information see
                :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`
            * any field from _whitelist.keys() *

        """
        dic = {'_twins': [id(t) for t in self._twins]}
        export_to_dictionary(self, self._whitelist, dic, fullcopy)
        return dic
Example #5
0
 def as_dictionary(self, fullcopy=True):
     """Returns component as a dictionary
     For more information on method and conventions, see
     :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`
     Parameters
     ----------
     fullcopy : Bool (optional, False)
         Copies of objects are stored, not references. If any found,
         functions will be pickled and signals converted to dictionaries
     Returns
     -------
     dic : dictionary
         A dictionary, containing at least the following fields:
         parameters : list
             a list of dictionaries of the parameters, one per
         _whitelist : dictionary
             a dictionary with keys used as references saved attributes, for
             more information, see
             :meth:`hyperspy.misc.export_dictionary.export_to_dictionary`
         * any field from _whitelist.keys() *
     """
     dic = {
         'parameters': [
             p.as_dictionary(fullcopy) for p in self.parameters]}
     export_to_dictionary(self, self._whitelist, dic, fullcopy)
     from hyperspy.model import components
     if self._id_name not in components.__dict__.keys():
         import dill
         dic['_class_dump'] = dill.dumps(self.__class__)
     return dic
Example #6
0
 def as_dictionary(self, fullcopy=True):
     """Export the GOS as a dictionary
     """
     dic = {}
     export_to_dictionary(self, self._whitelist, dic, fullcopy)
     return dic