# Path: paratemp/utils.py
# def calc_fes_1d(data, temp, bins=None):
#     d_bins = _parse_bin_input(bins)
#     n, _bins = np.histogram(data, **d_bins)
#     n = [float(j) for j in n]
#     # TODO find better way to account for zeros here rather than
#     # just adding a small amount to each.
#     prob = np.array([j / max(n) for j in n]) + 1e-40
#     delta_g = np.array([-r * temp * np.log(p) for p in prob])
#     bin_mids = running_mean(_bins, 2)
#     return delta_g, bin_mids
# 
# def _parse_ax_input(ax):
#     if ax is None:
#         fig, ax = plt.subplots()
#     else:
#         fig = ax.figure
#     return fig, ax
# 
# Path: paratemp/exceptions.py
# class InputError(Exception):
#     """Exception raised for errors in the input.
# 
#     Attributes:
#         expr -- input expression in which the error occurred
#         msg  -- explanation of the error
#     """
# 
#     def __init__(self, expr, msg):
#         self.expr = expr
#         self.msg = msg
# 
#     def __str__(self):
#         output = 'Incorrect input "{}". {}'.format(self.expr, self.msg)
#         return repr(output)


import math
import matplotlib as mpl
from matplotlib import pyplot as plt
from six.moves import range
from .utils import calc_fes_1d, _parse_ax_input
from .exceptions import InputError
        given, these must correspond to columns in `data`. If `labels` is
        None, the first three columns of `data` will be used with their column
        names as the labels.
    :param float temp: Temperature at which to calculate the free energy
        surface. This should be the temperature at which the simulation was run.
    :param Iterable[str] labels: An iterable of at least length three or None.
        If this is not None, the first three elements of it will be used as
        column names to pick with data to plot from `data`.
        If it is None, the first three column names from `data` will be used.
        These values will also be used as labels for the legend.
    :param np.array(matplotlib.axes.Axes) axes: A set of axes on which to
        make the FESes and the legend. If this is given, it must support up to
        axes.flat[3].
        If None, a new figure with 2x2 axes will be created.
    :type bins: int or Sequence[int or float] or str
    :param bins: Default: None. The bins argument to be passed to
        np.histogram
    :param kwargs: keyword arguments to pass to the plot function
    :rtype: Tuple(List(np.ndarray), List(np.ndarray),
        List(matplotlib.lines.Line2D), matplotlib.figure.Figure,
        matplotlib.axes.Axes)
    :return: The delta G values, the bin centers, the lines objects, the
        figure and the axes
    """
    if axes is None:
        fig, axes = plt.subplots(nrows=2, ncols=2, sharey=True, sharex=True)
    else:
        try:
            fig = axes.flat[3].figure
        except (IndexError, TypeError):

# Path: paratemp/utils.py
# def calc_fes_1d(data, temp, bins=None):
#     d_bins = _parse_bin_input(bins)
#     n, _bins = np.histogram(data, **d_bins)
#     n = [float(j) for j in n]
#     # TODO find better way to account for zeros here rather than
#     # just adding a small amount to each.
#     prob = np.array([j / max(n) for j in n]) + 1e-40
#     delta_g = np.array([-r * temp * np.log(p) for p in prob])
#     bin_mids = running_mean(_bins, 2)
#     return delta_g, bin_mids
# 
# def _parse_ax_input(ax):
#     if ax is None:
#         fig, ax = plt.subplots()
#     else:
#         fig = ax.figure
#     return fig, ax
# 
# Path: paratemp/exceptions.py
# class InputError(Exception):
#     """Exception raised for errors in the input.
# 
#     Attributes:
#         expr -- input expression in which the error occurred
#         msg  -- explanation of the error
#     """
# 
#     def __init__(self, expr, msg):
#         self.expr = expr
#         self.msg = msg
# 
#     def __str__(self):
#         output = 'Incorrect input "{}". {}'.format(self.expr, self.msg)
#         return repr(output)


# Path: paratemp/plotting.py
import math
import matplotlib as mpl
from matplotlib import pyplot as plt
from six.moves import range
from .utils import calc_fes_1d, _parse_ax_input
from .exceptions import InputError

        given, these must correspond to columns in `data`. If `labels` is
        None, the first three columns of `data` will be used with their column
        names as the labels.
    :param float temp: Temperature at which to calculate the free energy
        surface. This should be the temperature at which the simulation was run.
    :param Iterable[str] labels: An iterable of at least length three or None.
        If this is not None, the first three elements of it will be used as
        column names to pick with data to plot from `data`.
        If it is None, the first three column names from `data` will be used.
        These values will also be used as labels for the legend.
    :param np.array(matplotlib.axes.Axes) axes: A set of axes on which to
        make the FESes and the legend. If this is given, it must support up to
        axes.flat[3].
        If None, a new figure with 2x2 axes will be created.
    :type bins: int or Sequence[int or float] or str
    :param bins: Default: None. The bins argument to be passed to
        np.histogram
    :param kwargs: keyword arguments to pass to the plot function
    :rtype: Tuple(List(np.ndarray), List(np.ndarray),
        List(matplotlib.lines.Line2D), matplotlib.figure.Figure,
        matplotlib.axes.Axes)
    :return: The delta G values, the bin centers, the lines objects, the
        figure and the axes
    """
    if axes is None:
        fig, axes = plt.subplots(nrows=2, ncols=2, sharey=True, sharex=True)
    else:
        try:
            fig = axes.flat[3].figure
        except (IndexError, TypeError):

            raise InputError(