# Path: brew/constants.py
# HOP_TYPE_PELLET = u"pellet"
# 
# Path: brew/constants.py
# HOP_TYPE_PLUG = u"plug"
# 
# Path: brew/constants.py
# HOP_TYPE_WHOLE = u"whole"
# 
# Path: brew/constants.py
# HOP_TYPE_WHOLE_WET = u"whole wet"
# 
# Path: brew/constants.py
# HOP_UTILIZATION_SCALE_PELLET = 1.1  # 110%
# 
# Path: brew/constants.py
# HOP_WHOLE_DRY_TO_WET = 5.5
# 
# Path: brew/constants.py
# HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER
# 
# Path: brew/constants.py
# HOPS_CONSTANT_SI = 1.0
# 
# Path: brew/constants.py
# IMPERIAL_TYPES = {
#     u"volume": u"gallon",
#     u"weight_large": u"lbs",
#     u"weight_small": u"oz",
#     u"temperature": u"degF",
# }
# 
# Path: brew/constants.py
# IMPERIAL_UNITS = u"imperial"
# 
# Path: brew/constants.py
# SI_TYPES = {
#     u"volume": u"liter",
#     u"weight_large": u"kg",
#     u"weight_small": u"mg",
#     u"temperature": u"degC",
# }
# 
# Path: brew/constants.py
# SI_UNITS = u"metric"
# 
# Path: brew/validators.py
# def validate_units(units):
#     """
#     Validate units
# 
#     :param str units: Unit type
#     :return: units
#     :rtype: str
#     :raises ValidatorException: If units is unknown
#     """
#     if units in [IMPERIAL_UNITS, SI_UNITS]:
#         return units
#     raise ValidatorException(
#         u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS)
#     )


import math
from ..constants import HOP_TYPE_PELLET
from ..constants import HOP_TYPE_PLUG
from ..constants import HOP_TYPE_WHOLE
from ..constants import HOP_TYPE_WHOLE_WET
from ..constants import HOP_UTILIZATION_SCALE_PELLET
from ..constants import HOP_WHOLE_DRY_TO_WET
from ..constants import HOPS_CONSTANT_IMPERIAL
from ..constants import HOPS_CONSTANT_SI
from ..constants import IMPERIAL_TYPES
from ..constants import IMPERIAL_UNITS
from ..constants import SI_TYPES
from ..constants import SI_UNITS
from ..validators import validate_units
    u"hop_type_weight_conversion",
    u"HopsUtilization",
    u"HopsUtilizationJackieRager",
    u"HopsUtilizationGlennTinseth",
]


def hop_type_weight_conversion(weight, old_type, new_type):
    """
    Convert weight of hops between one type and another

    :param float weight: Weight of the hops
    :param str old_type: The old hop type to convert from
    :param str new_type: The new hop type to convert to
    :return: New weight of the hops
    :rtype: float
    """
    # If same type then no change
    if old_type == new_type:
        return weight

    # If hop types are equivalent then no change
    equivalent_types = [HOP_TYPE_PLUG, HOP_TYPE_WHOLE]
    if old_type in equivalent_types and new_type in equivalent_types:
        return weight

    conversion = 1.0
    if old_type == HOP_TYPE_WHOLE_WET:
        conversion /= HOP_WHOLE_DRY_TO_WET
    elif new_type == HOP_TYPE_WHOLE_WET:

# Path: brew/constants.py
# HOP_TYPE_PELLET = u"pellet"
# 
# Path: brew/constants.py
# HOP_TYPE_PLUG = u"plug"
# 
# Path: brew/constants.py
# HOP_TYPE_WHOLE = u"whole"
# 
# Path: brew/constants.py
# HOP_TYPE_WHOLE_WET = u"whole wet"
# 
# Path: brew/constants.py
# HOP_UTILIZATION_SCALE_PELLET = 1.1  # 110%
# 
# Path: brew/constants.py
# HOP_WHOLE_DRY_TO_WET = 5.5
# 
# Path: brew/constants.py
# HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER
# 
# Path: brew/constants.py
# HOPS_CONSTANT_SI = 1.0
# 
# Path: brew/constants.py
# IMPERIAL_TYPES = {
#     u"volume": u"gallon",
#     u"weight_large": u"lbs",
#     u"weight_small": u"oz",
#     u"temperature": u"degF",
# }
# 
# Path: brew/constants.py
# IMPERIAL_UNITS = u"imperial"
# 
# Path: brew/constants.py
# SI_TYPES = {
#     u"volume": u"liter",
#     u"weight_large": u"kg",
#     u"weight_small": u"mg",
#     u"temperature": u"degC",
# }
# 
# Path: brew/constants.py
# SI_UNITS = u"metric"
# 
# Path: brew/validators.py
# def validate_units(units):
#     """
#     Validate units
# 
#     :param str units: Unit type
#     :return: units
#     :rtype: str
#     :raises ValidatorException: If units is unknown
#     """
#     if units in [IMPERIAL_UNITS, SI_UNITS]:
#         return units
#     raise ValidatorException(
#         u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS)
#     )


# Path: brew/utilities/hops.py
import math
from ..constants import HOP_TYPE_PELLET
from ..constants import HOP_TYPE_PLUG
from ..constants import HOP_TYPE_WHOLE
from ..constants import HOP_TYPE_WHOLE_WET
from ..constants import HOP_UTILIZATION_SCALE_PELLET
from ..constants import HOP_WHOLE_DRY_TO_WET
from ..constants import HOPS_CONSTANT_IMPERIAL
from ..constants import HOPS_CONSTANT_SI
from ..constants import IMPERIAL_TYPES
from ..constants import IMPERIAL_UNITS
from ..constants import SI_TYPES
from ..constants import SI_UNITS
from ..validators import validate_units

    u"hop_type_weight_conversion",
    u"HopsUtilization",
    u"HopsUtilizationJackieRager",
    u"HopsUtilizationGlennTinseth",
]


def hop_type_weight_conversion(weight, old_type, new_type):
    """
    Convert weight of hops between one type and another

    :param float weight: Weight of the hops
    :param str old_type: The old hop type to convert from
    :param str new_type: The new hop type to convert to
    :return: New weight of the hops
    :rtype: float
    """
    # If same type then no change
    if old_type == new_type:
        return weight

    # If hop types are equivalent then no change
    equivalent_types = [HOP_TYPE_PLUG, HOP_TYPE_WHOLE]
    if old_type in equivalent_types and new_type in equivalent_types:
        return weight

    conversion = 1.0
    if old_type == HOP_TYPE_WHOLE_WET:
        conversion /= HOP_WHOLE_DRY_TO_WET
    elif new_type == HOP_TYPE_WHOLE_WET:

        conversion *= HOP_WHOLE_DRY_TO_WET