# Path: brew/constants.py
# FC_DIFF_TWO_ROW = 0.017
# 
# Path: brew/constants.py
# LITERS_OF_WORT_AT_SG = 386.0
# 
# Path: brew/constants.py
# MOISTURE_CORRECTION = 0.0
# 
# Path: brew/constants.py
# MOISTURE_FINISHED_MALT = 0.04
# 
# Path: brew/constants.py
# PPG_TO_HWE_CONVERSION = LITER_PER_GAL * POUND_PER_KG
# 
# Path: brew/constants.py
# SUCROSE_PLATO = 11.486
# 
# Path: brew/constants.py
# SUCROSE_PPG = 46.214
# 
# Path: brew/validators.py
# def validate_percentage(percent):
#     """
#     Validate decimal percentage
# 
#     :param float percent: Percentage between 0.0 and 1.0
#     :return: percentage
#     :rtype: float
#     :raises ValidatorException: If decimal percentage not between 0.0 and 1.0
#     """
#     if 0.0 <= percent <= 1.0:
#         return percent
#     raise ValidatorException(u"Percentage values should be in decimal format")
# 
# Path: brew/utilities/sugar.py
# def gu_to_sg(gu):
#     """
#     Gravity Units to Specific Gravity
# 
#     :param float gu: Gravity Units
#     :return: Specific Gravity
#     :rtype: float
#     """
#     return 1 + (gu / 1000.0)


from ..constants import FC_DIFF_TWO_ROW
from ..constants import LITERS_OF_WORT_AT_SG
from ..constants import MOISTURE_CORRECTION
from ..constants import MOISTURE_FINISHED_MALT
from ..constants import PPG_TO_HWE_CONVERSION
from ..constants import SUCROSE_PLATO
from ..constants import SUCROSE_PPG
from ..validators import validate_percentage
from .sugar import gu_to_sg
def dry_basis_to_as_is_basis(dry_basis, moisture_content=MOISTURE_FINISHED_MALT):
    """
    Dry Basis to As-Is Basis Percentage

    :param float dry_basis: A percentage from the malt bill in decimal form
    :param float moisture_content: A percentage of moisture content in finished malt in decimal form
    :return: As-Is Basis
    :rtype: float
    """  # noqa
    validate_percentage(dry_basis)
    validate_percentage(moisture_content)
    return dry_basis * (1.0 - moisture_content)


def as_is_basis_to_dry_basis(as_is, moisture_content=MOISTURE_FINISHED_MALT):
    """
    As-Is Basis to Dry Basis Percentage

    :param float as_is: A percentage from the malt bill in decimal form
    :param float moisture_content: A percentage of moisture content in finished malt in decimal form
    :return: Dry Basis
    :rtype: float
    """  # noqa
    validate_percentage(as_is)
    validate_percentage(moisture_content)
    return as_is / (1.0 - moisture_content)


def sg_from_dry_basis(
    dbcg,

# Path: brew/constants.py
# FC_DIFF_TWO_ROW = 0.017
# 
# Path: brew/constants.py
# LITERS_OF_WORT_AT_SG = 386.0
# 
# Path: brew/constants.py
# MOISTURE_CORRECTION = 0.0
# 
# Path: brew/constants.py
# MOISTURE_FINISHED_MALT = 0.04
# 
# Path: brew/constants.py
# PPG_TO_HWE_CONVERSION = LITER_PER_GAL * POUND_PER_KG
# 
# Path: brew/constants.py
# SUCROSE_PLATO = 11.486
# 
# Path: brew/constants.py
# SUCROSE_PPG = 46.214
# 
# Path: brew/validators.py
# def validate_percentage(percent):
#     """
#     Validate decimal percentage
# 
#     :param float percent: Percentage between 0.0 and 1.0
#     :return: percentage
#     :rtype: float
#     :raises ValidatorException: If decimal percentage not between 0.0 and 1.0
#     """
#     if 0.0 <= percent <= 1.0:
#         return percent
#     raise ValidatorException(u"Percentage values should be in decimal format")
# 
# Path: brew/utilities/sugar.py
# def gu_to_sg(gu):
#     """
#     Gravity Units to Specific Gravity
# 
#     :param float gu: Gravity Units
#     :return: Specific Gravity
#     :rtype: float
#     """
#     return 1 + (gu / 1000.0)


# Path: brew/utilities/malt.py
from ..constants import FC_DIFF_TWO_ROW
from ..constants import LITERS_OF_WORT_AT_SG
from ..constants import MOISTURE_CORRECTION
from ..constants import MOISTURE_FINISHED_MALT
from ..constants import PPG_TO_HWE_CONVERSION
from ..constants import SUCROSE_PLATO
from ..constants import SUCROSE_PPG
from ..validators import validate_percentage
from .sugar import gu_to_sg

def dry_basis_to_as_is_basis(dry_basis, moisture_content=MOISTURE_FINISHED_MALT):
    """
    Dry Basis to As-Is Basis Percentage

    :param float dry_basis: A percentage from the malt bill in decimal form
    :param float moisture_content: A percentage of moisture content in finished malt in decimal form
    :return: As-Is Basis
    :rtype: float
    """  # noqa
    validate_percentage(dry_basis)
    validate_percentage(moisture_content)
    return dry_basis * (1.0 - moisture_content)


def as_is_basis_to_dry_basis(as_is, moisture_content=MOISTURE_FINISHED_MALT):
    """
    As-Is Basis to Dry Basis Percentage

    :param float as_is: A percentage from the malt bill in decimal form
    :param float moisture_content: A percentage of moisture content in finished malt in decimal form
    :return: Dry Basis
    :rtype: float
    """  # noqa
    validate_percentage(as_is)
    validate_percentage(moisture_content)
    return as_is / (1.0 - moisture_content)


def sg_from_dry_basis(
    dbcg,

    moisture_content=MOISTURE_FINISHED_MALT,