# Path: brew/constants.py
# GAL_PER_LITER = 1.0 / LITER_PER_GAL
# 
# Path: brew/constants.py
# IMPERIAL_UNITS = u"imperial"
# 
# Path: brew/constants.py
# SI_UNITS = u"metric"
# 
# Path: brew/utilities/yeast.py
# class KaiserYeastModel(YeastModel):
#     """
#     Kaiser Yeast Model
# 
#     Only works for Stir Plage Growth
# 
#     Sources:
# 
#     * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/
#     """
# 
#     METHOD_TO_GROWTH_ADJ = {u"stir plate": 0.0}
# 
#     def __init__(self, method=u"stir plate", units=IMPERIAL_UNITS):
#         return super(KaiserYeastModel, self).__init__(method, units=units)
# 
#     def get_inoculation_rate(self, growth_rate):
#         if 0 < growth_rate < 1.4:
#             return (2.33 - growth_rate) / 0.67
#         elif 1.4 <= growth_rate:
#             return 1.4
# 
#     def get_growth_rate(self, initial_cells):
#         """
#         initial_cells - Billion / gram extract (B/g)
#         """
#         if initial_cells < 1.4:
#             return 1.4 + self.adjustment
#         elif 1.4 <= initial_cells < 3.5:
#             return 2.33 - 0.67 * initial_cells + self.adjustment
#         else:
#             return 0.0 + self.adjustment
# 
# Path: brew/utilities/yeast.py
# class WhiteYeastModel(YeastModel):
#     """
#     Sources:
# 
#     * http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
#     * White, Chris, and Jamil Zainasheff. Yeast: The Practical Guide to Beer Fermentation. Boulder, CO: Brewers Publications, 2010. 139-44. Print.
#     """  # noqa
# 
#     # Linear Regression Least Squares
#     INOCULATION_CONST = [-0.999499, 12.547938, -0.459486]
#     METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.5, u"stir plate": 1.0}
# 
#     def __init__(self, method=u"no agitation", units=IMPERIAL_UNITS):
#         return super(WhiteYeastModel, self).__init__(method, units=units)
# 
#     def get_inoculation_rate(self, growth_rate):
#         a, b, c = self.INOCULATION_CONST
#         return 10 ** (math.log10(b / (growth_rate - a)) / -c)
# 
#     def get_growth_rate(self, inoculation_rate):
#         """
#         initial_cells - Billion / gram extract (B/g)
# 
#         G = (12.54793776 * x^-0.4594858324) - 0.9994994906
#         """  # noqa
#         # if inoculation_rate > 200:
#         #     raise YeastException(u"Yeast will not grow at more than 200 M/ml")  # noqa
#         a, b, c = self.INOCULATION_CONST
#         growth_rate = a + b * inoculation_rate ** c + self.adjustment
#         # if growth_rate > 6:
#         #     raise YeastException(u"Model does not allow for growth greater than 6")  # noqa
#         return growth_rate


import argparse
import sys
import textwrap
from brew.constants import GAL_PER_LITER
from brew.constants import IMPERIAL_UNITS
from brew.constants import SI_UNITS
from brew.utilities.yeast import KaiserYeastModel
from brew.utilities.yeast import WhiteYeastModel
        default=u"white",
        help=u"Model of yeast growth, white or kaiser (default: %(default)s)",
    )  # noqa
    parser.add_argument(
        u"--method",
        metavar=u"M",
        type=str,
        default=u"stir plate",
        help=u"Method of growth (default: %(default)s)",
    )  # noqa
    parser.add_argument(
        u"--units",
        metavar=u"U",
        type=str,
        default=IMPERIAL_UNITS,
        help=u"Units to use (default: %(default)s)",
    )
    return parser


def main(parser_fn=get_parser, parser_kwargs=None):
    parser = None
    if not parser_kwargs:
        parser = parser_fn()
    else:
        parser = parser_fn(**parser_kwargs)
    args = parser.parse_args()

    # Check on output
    if args.units not in [IMPERIAL_UNITS, SI_UNITS]:

# Path: brew/constants.py
# GAL_PER_LITER = 1.0 / LITER_PER_GAL
# 
# Path: brew/constants.py
# IMPERIAL_UNITS = u"imperial"
# 
# Path: brew/constants.py
# SI_UNITS = u"metric"
# 
# Path: brew/utilities/yeast.py
# class KaiserYeastModel(YeastModel):
#     """
#     Kaiser Yeast Model
# 
#     Only works for Stir Plage Growth
# 
#     Sources:
# 
#     * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/
#     """
# 
#     METHOD_TO_GROWTH_ADJ = {u"stir plate": 0.0}
# 
#     def __init__(self, method=u"stir plate", units=IMPERIAL_UNITS):
#         return super(KaiserYeastModel, self).__init__(method, units=units)
# 
#     def get_inoculation_rate(self, growth_rate):
#         if 0 < growth_rate < 1.4:
#             return (2.33 - growth_rate) / 0.67
#         elif 1.4 <= growth_rate:
#             return 1.4
# 
#     def get_growth_rate(self, initial_cells):
#         """
#         initial_cells - Billion / gram extract (B/g)
#         """
#         if initial_cells < 1.4:
#             return 1.4 + self.adjustment
#         elif 1.4 <= initial_cells < 3.5:
#             return 2.33 - 0.67 * initial_cells + self.adjustment
#         else:
#             return 0.0 + self.adjustment
# 
# Path: brew/utilities/yeast.py
# class WhiteYeastModel(YeastModel):
#     """
#     Sources:
# 
#     * http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
#     * White, Chris, and Jamil Zainasheff. Yeast: The Practical Guide to Beer Fermentation. Boulder, CO: Brewers Publications, 2010. 139-44. Print.
#     """  # noqa
# 
#     # Linear Regression Least Squares
#     INOCULATION_CONST = [-0.999499, 12.547938, -0.459486]
#     METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.5, u"stir plate": 1.0}
# 
#     def __init__(self, method=u"no agitation", units=IMPERIAL_UNITS):
#         return super(WhiteYeastModel, self).__init__(method, units=units)
# 
#     def get_inoculation_rate(self, growth_rate):
#         a, b, c = self.INOCULATION_CONST
#         return 10 ** (math.log10(b / (growth_rate - a)) / -c)
# 
#     def get_growth_rate(self, inoculation_rate):
#         """
#         initial_cells - Billion / gram extract (B/g)
# 
#         G = (12.54793776 * x^-0.4594858324) - 0.9994994906
#         """  # noqa
#         # if inoculation_rate > 200:
#         #     raise YeastException(u"Yeast will not grow at more than 200 M/ml")  # noqa
#         a, b, c = self.INOCULATION_CONST
#         growth_rate = a + b * inoculation_rate ** c + self.adjustment
#         # if growth_rate > 6:
#         #     raise YeastException(u"Model does not allow for growth greater than 6")  # noqa
#         return growth_rate


# Path: brew/cli/yeast.py
import argparse
import sys
import textwrap
from brew.constants import GAL_PER_LITER
from brew.constants import IMPERIAL_UNITS
from brew.constants import SI_UNITS
from brew.utilities.yeast import KaiserYeastModel
from brew.utilities.yeast import WhiteYeastModel

        default=u"white",
        help=u"Model of yeast growth, white or kaiser (default: %(default)s)",
    )  # noqa
    parser.add_argument(
        u"--method",
        metavar=u"M",
        type=str,
        default=u"stir plate",
        help=u"Method of growth (default: %(default)s)",
    )  # noqa
    parser.add_argument(
        u"--units",
        metavar=u"U",
        type=str,
        default=IMPERIAL_UNITS,
        help=u"Units to use (default: %(default)s)",
    )
    return parser


def main(parser_fn=get_parser, parser_kwargs=None):
    parser = None
    if not parser_kwargs:
        parser = parser_fn()
    else:
        parser = parser_fn(**parser_kwargs)
    args = parser.parse_args()

    # Check on output
    if args.units not in [IMPERIAL_UNITS, SI_UNITS]:

        print(u"Units must be in either {} or {}".format(IMPERIAL_UNITS, SI_UNITS))