import math


def convert_unit_names(output_unit_list):
    """
    A helper function to convert units to text representation.

    Parameters
    ----------
    output_unit_list : list of float
        A list of the output units to parse.

    Returns
    -------
    conc_unit_names : list of str
        A list of concentration unit names.
    flux_unit_names : list of str
        A list of flux unit names.
    """
    conc_unit_names = []
    flux_unit_names = []
    for output_unit in output_unit_list:
        if math.isclose(output_unit, 1e-12):
            conc_unit = 'pmol mol$^{-1}$'
            flux_unit = 'pmol m$^{-2}$ s$^{-1}$'
        elif math.isclose(output_unit, 1e-9):
            conc_unit = 'nmol mol$^{-1}$'
            flux_unit = 'nmol m$^{-2}$ s$^{-1}$'
        elif math.isclose(output_unit, 1e-6):
            conc_unit = '$\mu$mol mol$^{-1}$'
            flux_unit = '$\mu$mol m$^{-2}$ s$^{-1}$'
        elif math.isclose(output_unit, 1e-3):
            conc_unit = 'mmol mol$^{-1}$'
            flux_unit = 'mmol m$^{-2}$ s$^{-1}$'
        elif math.isclose(output_unit, 1e-2):
            conc_unit = '%'
            flux_unit = '% m$^{-2}$ s$^{-1}$'
        elif math.isclose(output_unit, 1.):
            conc_unit = 'mol mol$^{-1}$'
            flux_unit = 'mol m$^{-2}$ s$^{-1}$'
        else:
            conc_unit = 'undefined unit'
            flux_unit = 'undefined unit'

        conc_unit_names.append(conc_unit)
        flux_unit_names.append(flux_unit)

    return conc_unit_names, flux_unit_names