def _get_outputs_by_key(self, key, values, tolerance=None, outputs=None):
    "\n        Get datasets at or near to given values.\n\n        Parameters\n        ----------\n        key: str\n            The key by which to retrieve outputs, usually 'time' or\n            'redshift'.\n        values: array_like\n            A list of values, given as floats.\n        tolerance : float\n            If not None, do not return a dataset unless the value is\n            within the tolerance value.  If None, simply return the\n            nearest dataset.\n            Default: None.\n        outputs : list\n            The list of outputs from which to choose.  If None,\n            self.all_outputs is used.\n            Default: None.\n\n        Examples\n        --------\n        >>> datasets = es.get_outputs_by_key('redshift', [0, 1, 2], tolerance=0.1)\n\n        "
    if (not isinstance(values, YTArray)):
        if (isinstance(values, tuple) and (len(values) == 2)):
            values = self.arr(*values)
        else:
            values = self.arr(values)
    values = values.in_base()
    if (outputs is None):
        outputs = self.all_outputs
    my_outputs = []
    if (not outputs):
        return my_outputs
    for value in values:
        outputs.sort(key=(lambda obj: np.abs((value - obj[key]))))
        if (((tolerance is None) or (np.abs((value - outputs[0][key])) <= tolerance)) and (outputs[0] not in my_outputs)):
            my_outputs.append(outputs[0])
        else:
            mylog.error('No dataset added for %s = %f.', key, value)
    outputs.sort(key=(lambda obj: obj['time']))
    return my_outputs
Get datasets at or near to given values.

Parameters
----------
key: str
    The key by which to retrieve outputs, usually 'time' or
    'redshift'.
values: array_like
    A list of values, given as floats.
tolerance : float
    If not None, do not return a dataset unless the value is
    within the tolerance value.  If None, simply return the
    nearest dataset.
    Default: None.
outputs : list
    The list of outputs from which to choose.  If None,
    self.all_outputs is used.
    Default: None.

Examples
--------
>>> datasets = es.get_outputs_by_key('redshift', [0, 1, 2], tolerance=0.1)
def _get_outputs_by_key(self, key, values, tolerance=None, outputs=None):
    "\n        Get datasets at or near to given values.\n\n        Parameters\n        ----------\n        key: str\n            The key by which to retrieve outputs, usually 'time' or\n            'redshift'.\n        values: array_like\n            A list of values, given as floats.\n        tolerance : float\n            If not None, do not return a dataset unless the value is\n            within the tolerance value.  If None, simply return the\n            nearest dataset.\n            Default: None.\n        outputs : list\n            The list of outputs from which to choose.  If None,\n            self.all_outputs is used.\n            Default: None.\n\n        Examples\n        --------\n        >>> datasets = es.get_outputs_by_key('redshift', [0, 1, 2], tolerance=0.1)\n\n        "
    if (not isinstance(values, YTArray)):
        if (isinstance(values, tuple) and (len(values) == 2)):
            values = self.arr(*values)
        else:
            values = self.arr(values)
    values = values.in_base()
    if (outputs is None):
        outputs = self.all_outputs
    my_outputs = []
    if (not outputs):
        return my_outputs
    for value in values:
        outputs.sort(key=(lambda obj: np.abs((value - obj[key]))))
        if (((tolerance is None) or (np.abs((value - outputs[0][key])) <= tolerance)) and (outputs[0] not in my_outputs)):
            my_outputs.append(outputs[0])
        else:
            mylog.error('No dataset added for %s = %f.', key, value)
    outputs.sort(key=(lambda obj: obj['time']))
    return my_outputs