def parse_yeast(yeast, loader, dir_suffix='yeast/'): """ Parse yeast data from a recipe :param dict hops: A representation of a yeast :param DataLoader loader: A class to load additional information Yeast must have the following top level attributes: * name (str) * data (dict) (optional) Additionally yeast may contain override data in the 'data' attribute with the following keys: * percent_attenuation (float) """ Yeast.validate(yeast) yeast_data = loader.get_item(dir_suffix, yeast[u'name']) # noqa name = yeast_data.get(u'name', yeast[u'name']) attenuation = None if u'data' in yeast: attenuation = yeast[u'data'].get(u'percent_attenuation', None) if not attenuation: attenuation = yeast_data.get(u'percent_attenuation', None) return Yeast(name, percent_attenuation=attenuation)
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_unicode(self): yeast = Yeast(u"Kölsh", percent_attenuation=0.74) out = str(yeast) if sys.version_info[0] >= 3: self.assertEquals(out, u"Kölsh, attenuation 74.0%") else: self.assertEquals(out, u"Kölsh, attenuation 74.0%".encode("utf8"))
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 test_validate(self): data = self.yeast.to_dict() Yeast.validate(data)
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) hop_additions = [centennial_add, cascade_add] # Define Yeast yeast = Yeast(u"Wyeast 1056") # Define Recipes recipe = Recipe( name=u"pale ale", grain_additions=grain_additions, hop_additions=hop_additions, yeast=yeast, brew_house_yield=BHY, start_volume=7.0, final_volume=5.0, ) recipe_lme = Recipe( name=u"pale ale lme", grain_additions=grain_additions_lme,
def test_yeast_no_percent_attenuation(self): with self.assertRaises(YeastException) as ctx: Yeast(u"Wyeast 1056", percent_attenuation=None) self.assertEquals(str(ctx.exception), u"Wyeast 1056: Must provide percent attenuation")
def test_ne_percent_attenuation(self): yeast1 = Yeast(u"Wyeast 1056", percent_attenuation=0.75) yeast2 = Yeast(u"Wyeast 1056", percent_attenuation=0.70) self.assertTrue(yeast1 != yeast2)
def test_eq(self): yeast1 = Yeast(u"Wyeast 1056", percent_attenuation=0.75) yeast2 = Yeast(u"Wyeast 1056", percent_attenuation=0.75) self.assertEquals(yeast1, yeast2)
def main(): # Constants name = u"Sagefight Imperial IPA" brew_house_yield = 0.70 start_volume = 4.0 final_volume = 5.0 # Grains pale = Grain(u"pale 2-row", color=2.0, ppg=36.0) crystal = Grain(u"crystal 20", color=2.0, ppg=35.0) munich = Grain(u"munich", color=9.0, ppg=37.0) grain_list = [pale, crystal, munich] # Hops # Mild, herbaceous, elements of resin millennium = Hop(name=u"millennium", percent_alpha_acids=0.14) # Spicy, earthy, and lightly floral bravo = Hop(name=u"bravo", percent_alpha_acids=0.15) # Orange Citrus Flavor amarillo = Hop(name=u"amarillo", percent_alpha_acids=0.09) # Floral, with elements of citrus and notes of grapefruit # noqa centennial = Hop(name=u"centennial", percent_alpha_acids=0.10) hop_list = [millennium, bravo, amarillo, centennial] hop_list = hop_list[:3] # Define Recipe Builder builder = RecipeBuilder( name=name, grain_list=grain_list, hop_list=hop_list, target_ibu=75.0, target_og=1.075, brew_house_yield=brew_house_yield, start_volume=start_volume, final_volume=final_volume, ) # Get grain additions grain_percentages = [0.80, 0.10, 0.10] grain_additions = builder.get_grain_additions(grain_percentages) # Get hop additions hop_percentages = [0.50, 0.30, 0.20] hop_boil_times = [90, 15, 5] hop_additions = builder.get_hop_additions(hop_percentages, hop_boil_times) # Determine desired attenuation desired_attenuation = builder.get_yeast_attenuation(0.08) yeast = Yeast("English Ale", percent_attenuation=desired_attenuation) # Convert first grain addition to LME pale_lme = grain_additions[0].convert_to_lme(brew_house_yield=brew_house_yield) new_grain_additions = [pale_lme] + grain_additions[1:] # Create the recipe recipe = Recipe( name=name, grain_additions=new_grain_additions, hop_additions=hop_additions, yeast=yeast, brew_house_yield=brew_house_yield, start_volume=start_volume, final_volume=final_volume, ) print(recipe.format()) print("\nAdjuncts") print("===================================") print("- 0.66 oz Juniper Berries (crushed), 1/3 to boil at 10 min, 2/3 at knockout") print("- 0.25 oz Sage, 2/3 to boil at 10 min, 1/3 at knockout")