def to_dict(self, field=None, **kwargs):
        """
        Convert the ParameterSet to a structured (nested) dictionary
        to allow traversing the structure from the bottom up

        :parameter str field: (optional) build the dictionary with keys at
            a given level/field.  Can be any of the keys in
            :func:`meta`.  If None, the keys will be the lowest
            level in which Parameters have different values.
        :return: dict of :class:`Parameter`s or :class:`ParameterSet`s
        """
        if kwargs:
            return self.filter(**kwargs).to_dict(field=field)

        if field is not None:
            keys_for_this_field = set([getattr(p, field)
                                       for p in self.to_list()
                                       if getattr(p, field) is not None])
            return {k: self.filter(check_visible=False, **{field: k}) for k in keys_for_this_field}

        # we want to find the first level (from the bottom) in which filtering
        # further would shorten the list (ie there are more than one unique
        # item for that field)

        # so let's go through the fields in reverse (context up to (but not
        # including) qualifier)
        for field in reversed(_meta_fields_twig[1:]):
            # then get the unique keys in this field among the params in this
            # PS
            keys_for_this_field = set([getattr(p, field)
                                       for p in self.to_list()
                                       if getattr(p, field) is not None])
            # and if there are more than one, then return a dictionary with
            # those keys and the ParameterSet of the matching items
            if len(keys_for_this_field) > 1:
                self._next_field = field
                return {k: self.filter(check_visible=False, **{field: k})
                        for k in keys_for_this_field}

        # if we've survived, then we're at the bottom and only have times or
        # qualifier left
        if self.context in ['hierarchy']:
            self._next_field = 'qualifier'
            return {param.qualifier: param for param in self._params}
        else:
            self._next_field = 'time'
            return {param.time: param for param in self._params}
def to_dict ( self , field = None , ** kwargs ) : if kwargs : return self . filter ( ** kwargs ) . to_dict ( field = field ) if field is not None : keys_for_this_field = set ( [ getattr ( p , field ) for p in self . to_list ( ) if getattr ( p , field ) is not None ] ) return { k : self . filter ( check_visible = False , ** { field : k } ) for k in keys_for_this_field } for field in reversed ( _meta_fields_twig [ 1 : ] ) : keys_for_this_field = set ( [ getattr ( p , field ) for p in self . to_list ( ) if getattr ( p , field ) is not None ] ) if len ( keys_for_this_field ) > 1 : self . _next_field = field return { k : self . filter ( check_visible = False , ** { field : k } ) for k in keys_for_this_field } if self . context in [ 'hierarchy' ] : self . _next_field = 'qualifier' return { param . qualifier : param for param in self . _params } else : self . _next_field = 'time' return { param . time : param for param in self . _params }
Convert the ParameterSet to a structured (nested) dictionary
        to allow traversing the structure from the bottom up

        :parameter str field: (optional) build the dictionary with keys at
            a given level/field.  Can be any of the keys in
            :func:`meta`.  If None, the keys will be the lowest
            level in which Parameters have different values.
        :return: dict of :class:`Parameter`s or :class:`ParameterSet`s