def main(): # Define Grains pale = Grain(u"Pale Malt (2 Row) US", color=1.8, ppg=37) pale_add = GrainAddition(pale, weight=13.96) crystal = Grain(u"Caramel/Crystal Malt - 20L", color=20.0, ppg=35) crystal_add = GrainAddition(crystal, weight=0.78) grain_additions = [pale_add, crystal_add] # Define Hops centennial = Hop(u"Centennial", percent_alpha_acids=0.14) centennial_add = HopAddition(centennial, weight=0.57, boil_time=60.0) cascade = Hop(u"Cascade (US)", percent_alpha_acids=0.07) cascade_add = HopAddition(cascade, weight=0.76, boil_time=5.0) hop_additions = [centennial_add, cascade_add] # Define Yeast yeast = Yeast(u"Wyeast 1056") # Define Recipe beer = Recipe( u"pale ale", grain_additions=grain_additions, hop_additions=hop_additions, yeast=yeast, brew_house_yield=0.70, # % start_volume=7.0, # G final_volume=5.0, # G ) print(beer.format())
def test_convert_to_cereal_raises(self): grain_add = GrainAddition(pale_lme, weight=1.0, grain_type=GRAIN_TYPE_LME) with self.assertRaises(GrainException) as ctx: grain_add.convert_to_cereal(brew_house_yield=BHY) self.assertEquals(str(ctx.exception), u'Must provide PPG to convert to cereal')
def test_get_weight_specialty(self): grain_add = GrainAddition(pale, weight=13.96, grain_type=GRAIN_TYPE_SPECIALTY) self.assertEquals(grain_add.grain_type, GRAIN_TYPE_SPECIALTY) out = grain_add.get_cereal_weight(ppg=ppg_pale) self.assertEqual(round(out, 2), 13.96) out = grain_add.get_lme_weight() self.assertEqual(round(out, 2), 14.35) out = grain_add.get_dme_weight() self.assertEqual(round(out, 2), 11.74)
def test_get_weight_dme(self): grain_add = GrainAddition(pale_dme, weight=11.74, grain_type=GRAIN_TYPE_DME) self.assertEquals(grain_add.grain_type, GRAIN_TYPE_DME) out = grain_add.get_cereal_weight(ppg=ppg_pale) self.assertEqual(round(out, 2), 13.96) out = grain_add.get_lme_weight() self.assertEqual(round(out, 2), 14.35) out = grain_add.get_dme_weight() self.assertEqual(round(out, 2), 11.74)
def test_get_weight_dry(self): grain_add = GrainAddition(pale, weight=8.38, grain_type=GRAIN_TYPE_DME) self.assertEquals(grain_add.grain_type, GRAIN_TYPE_DME) out = grain_add.get_cereal_weight() self.assertEqual(round(out, 2), 13.97) out = grain_add.get_lme_weight() self.assertEqual(round(out, 2), 10.48) out = grain_add.get_dry_weight() self.assertEqual(round(out, 2), 8.38)
def test_convert_to_dme(self): grain_add = GrainAddition(pale_dme, weight=1.0, grain_type=GRAIN_TYPE_DME) ga_cereal = grain_add.convert_to_cereal(ppg=ppg_pale, brew_house_yield=BHY) ga_lme = grain_add.convert_to_lme(ppg=PPG_LME, brew_house_yield=BHY) ga_dme = grain_add.convert_to_dme(ppg=PPG_DME, brew_house_yield=BHY) self.assertEquals(round(ga_cereal.weight, 2), 1.7) self.assertEquals(round(ga_lme.weight, 2), 1.22) self.assertEquals(ga_dme.weight, 1.0)
def test_recipe_matches(self): pale_add = GrainAddition(pale, weight=8.69) crystal_add = GrainAddition(crystal, weight=1.02) pale_ale = Recipe( name=u"pale ale", grain_additions=[pale_add, crystal_add], hop_additions=hop_additions, yeast=yeast, brew_house_yield=0.70, start_volume=7.0, final_volume=5.0, ) out = self.style.recipe_matches(pale_ale) self.assertTrue(out)
def test_recipe_errors_none(self): pale_add = GrainAddition(pale, weight=8.69) crystal_add = GrainAddition(crystal, weight=1.02) pale_ale = Recipe( name=u"pale ale", grain_additions=[pale_add, crystal_add], hop_additions=hop_additions, yeast=yeast, brew_house_yield=0.70, start_volume=7.0, final_volume=5.0, ) out = self.style.recipe_errors(pale_ale) expected = [] self.assertEquals(out, expected)
def main(): # Define Grains pale = Grain(u"Pale Malt (2 Row) US", color=1.8, ppg=37) rye = Grain(u"Rye Malt", color=3.5, ppg=38) crystal = Grain(u"Caramel/Crystal - 60L", color=60, ppg=34) carapils = Grain(u"Carapils/Dextrine Malt", color=1.8, ppg=33) flaked_wheat = Grain(u"Flaked Wheat", color=2, ppg=34) pale_add = GrainAddition(pale, weight=13.96) rye_add = GrainAddition(rye, weight=3.0) crystal_add = GrainAddition(crystal, weight=1.25) carapils_add = GrainAddition(carapils, weight=0.5) flaked_wheat_add = GrainAddition(flaked_wheat, weight=0.5) grain_additions = [ pale_add, rye_add, crystal_add, carapils_add, flaked_wheat_add ] # Define Hops mt_hood = Hop(u"Mount Hood", percent_alpha_acids=0.048) columbus = Hop(u"Columbus", percent_alpha_acids=0.15) mt_hood_add_01 = HopAddition(mt_hood, weight=1.0, boil_time=60.0) columbus_add_01 = HopAddition(columbus, weight=1.0, boil_time=60.0) mt_hood_add_02 = HopAddition(mt_hood, weight=0.5, boil_time=30.0) mt_hood_add_03 = HopAddition(mt_hood, weight=1.5, boil_time=1.0) columbus_add_02 = HopAddition(columbus, weight=1.0, boil_time=0.0) hop_additions = [ mt_hood_add_01, columbus_add_01, mt_hood_add_02, mt_hood_add_03, columbus_add_02 ] # Define Yeast yeast = Yeast(u"Wyeast 1450", percent_attenuation=0.75) # Define Recipe beer = Recipe( u"pale ale", grain_additions=grain_additions, hop_additions=hop_additions, yeast=yeast, brew_house_yield=0.70, # % start_volume=7.5, # G final_volume=5.5, # G ) print(beer.format())
def parse_cereals(cereal, loader, dir_suffix='cereals/'): """ Parse grains data from a recipe :param dict cereal: A representation of a cereal :param DataLoader loader: A class to load additional information Grain must have the following top level attributes: * name (str) * weight (float) * data (dict) (optional) Additionally grains may contain override data in the 'data' attribute with the following keys: * color (float) * ppg (int) """ GrainAddition.validate(cereal) cereal_data = loader.get_item(dir_suffix, cereal[u'name']) name = cereal_data.get(u'name', cereal[u'name']) color = None ppg = None if u'data' in cereal: color = cereal[u'data'].get(u'color', None) ppg = cereal[u'data'].get(u'ppg', None) if not color: color = cereal_data.get(u'color', None) if not ppg: ppg = cereal_data.get(u'ppg', None) grain_obj = Grain(name, color=color, ppg=ppg) grain_add_kwargs = { u'weight': float(cereal[u'weight']), } if u'grain_type' in cereal: grain_add_kwargs[u'grain_type'] = cereal[u'grain_type'] if u'units' in cereal: grain_add_kwargs[u'units'] = cereal[u'units'] return GrainAddition(grain_obj, **grain_add_kwargs)
def test_get_total_points_dme(self): pale_dme_add = GrainAddition(pale_dme, weight=11.74, grain_type=GRAIN_TYPE_DME, units=IMPERIAL_UNITS) recipe = Recipe( u"dme", grain_additions=[pale_dme_add], hop_additions=self.hop_additions, yeast=self.yeast, units=IMPERIAL_UNITS, ) out = recipe.get_total_points() self.assertEquals(round(out, 1), 516.6)
def test_get_grain_add_cereal_weight_dme(self): pale_dme_add = GrainAddition(pale_dme, weight=11.74, grain_type=GRAIN_TYPE_DME, units=IMPERIAL_UNITS) recipe = Recipe( u"dme", grain_additions=[pale_dme_add], hop_additions=self.hop_additions, yeast=self.yeast, units=IMPERIAL_UNITS, ) out = recipe.get_grain_add_cereal_weight(pale_dme_add, ppg=ppg_pale) self.assertEquals(round(out, 2), 13.96)
def test_get_grain_add_dry_weight_lme(self): pale_lme_add = GrainAddition(pale_lme, weight=14.35, grain_type=GRAIN_TYPE_LME, units=IMPERIAL_UNITS) recipe = Recipe( u"lme", grain_additions=[pale_lme_add], hop_additions=self.hop_additions, yeast=self.yeast, units=IMPERIAL_UNITS, ) out = recipe.get_grain_add_dry_weight(pale_lme_add) self.assertEquals(round(out, 2), 11.74)
def test_validate(self): data = self.grain_add.to_dict() GrainAddition.validate(data)
# Define Grains ppg_pale = 37.0 pale = Grain(u'pale 2-row', color=2.0, ppg=ppg_pale) pale_lme = pale.convert_to_lme() pale_dme = pale.convert_to_dme() ppg_crystal = 35.0 crystal = Grain(u'crystal C20', color=20.0, ppg=ppg_crystal) grain_list = [pale, crystal] pale_add = GrainAddition(pale, weight=13.96) pale_add_lme = pale_add.convert_to_lme(brew_house_yield=BHY) pale_add_dme = pale_add.convert_to_dme(brew_house_yield=BHY) crystal_add = GrainAddition(crystal, weight=0.78) grain_additions = [pale_add, crystal_add] grain_additions_lme = [pale_add_lme, crystal_add] grain_additions_dme = [pale_add_dme, crystal_add] # Define Hops centennial = Hop(name=u'centennial', percent_alpha_acids=0.14) cascade = Hop(name=u'cascade', percent_alpha_acids=0.07) hop_list = [centennial, cascade]
from brew.styles import Style from brew.yeasts import Yeast BHY = 0.70 # Define Grains ppg_pale = 37.0 pale = Grain(u"pale 2-row", color=2.0, ppg=ppg_pale) pale_lme = pale.convert_to_lme() pale_dme = pale.convert_to_dme() ppg_crystal = 35.0 crystal = Grain(u"crystal C20", color=20.0, ppg=ppg_crystal) grain_list = [pale, crystal] pale_add = GrainAddition(pale, weight=13.96) pale_add_lme = pale_add.convert_to_lme(brew_house_yield=BHY) pale_add_dme = pale_add.convert_to_dme(brew_house_yield=BHY) crystal_add = GrainAddition(crystal, weight=0.78) grain_additions = [pale_add, crystal_add] grain_additions_lme = [pale_add_lme, crystal_add] grain_additions_dme = [pale_add_dme, crystal_add] # Define Hops centennial = Hop(name=u"centennial", percent_alpha_acids=0.14) cascade = Hop(name=u"cascade", percent_alpha_acids=0.07) hop_list = [centennial, cascade] centennial_add = HopAddition(centennial, boil_time=60.0, weight=0.57) cascade_add = HopAddition(cascade, boil_time=5.0, weight=0.76)