def addResult( self, result, jobids = None ):
<EOL>if isinstance(result, list):<EOL><INDENT>for res in result:<EOL><INDENT>self.addResult(res)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if isinstance(result, dict):<EOL><INDENT>if isinstance(result[Experiment.RESULTS], list):<EOL><INDENT>for res in result[Experiment.RESULTS]:<EOL><INDENT>self.addResult(res)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>k = self._parametersAsIndex(result[Experiment.PARAMETERS])<EOL>if k in self._results.keys():<EOL><INDENT>rs = self._results[k]<EOL><DEDENT>else:<EOL><INDENT>rs = []<EOL>self._results[k] = rs<EOL><DEDENT>rs.insert(<NUM_LIT:0>, result)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Exception("<STR_LIT>".format(r = result)) <EOL><DEDENT><DEDENT>if jobids is not None:<EOL><INDENT>if not isinstance(jobids, list):<EOL><INDENT>jobids = [ jobids ]<EOL><DEDENT>for jobid in jobids:<EOL><INDENT>if jobid in self._pending.keys():<EOL><INDENT>k = self._pending[jobid]<EOL>if k in self._results.keys():<EOL><INDENT>rs = self._results[k]<EOL>j = rs.index(jobid)<EOL>del rs[j]<EOL>del self._pending[jobid]<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(j = jobid,<EOL>ps = k))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise RuntimeError('<STR_LIT>'.format(j = jobid))<EOL><DEDENT><DEDENT><DEDENT>
Add a result. This should be :term:`results dict` as returned from
        an instance of :class:`Experiment`, that contains metadata,
        parameters, and result. Results cannot be overridden, as
        notebooks are immutable: adding more results simply adds
        another result set.

        The results may include one or more nested results dicts, for example as
        returned by :meth:`RepeatedExperiment`, whose results are a list of results
        at the same point in the parameter space. In this case the emebedded
        results will themselves be unpacked and added.

        One may also add a list of results dicts directly, in which case they will
        be added individually.

        If the jobid is present, this result resolves the corresponding pending result.
        As with result, jobid can be a list. (The two lists need not be the same
        length, to allow for experiments that return lists of result dicts.)

        :param result: a results dict
        :param jobids: the pending result job id(s) (defaults to no jobs)