def plot(self) -> Chart: analysis = RecipesPopularityAnalysis(RecipeScope()) df = analysis.popularity_per_style(num_top=8, top_months=self.period_months) if len(df) <= 1: # 1, because a single data point is also meaningless raise NoDataException() figure = LinesChart(force_legend=True).plot(df, 'month', 'recipes_percent', 'beer_style', 'Month/Year', '% of All Recipes') return Chart(figure, height=Chart.DEFAULT_HEIGHT * 0.66, title=self.get_chart_title())
def plot(self) -> Chart: analysis = RecipesTrendAnalysis(RecipeScope()) df = analysis.trending_styles(trend_window_months=self.period_months) if len(df) == 0: raise NoDataException() figure = LinesChart(force_legend=True).plot(df, 'month', 'recipes_percent', 'beer_style', None, '% of All Recipes') return Chart(figure, title=self.get_chart_title())
def __init__(self, yeast: Yeast) -> None: self.yeast = yeast self.recipe_scope = RecipeScope() self.recipe_scope.yeast_scope = YeastScope() self.recipe_scope.yeast_scope.yeasts = [yeast] self.yeast_projection = YeastProjection() self.yeast_projection.yeasts = [yeast]
def __init__(self, hop: Hop) -> None: self.hop = hop self.hop_scope = HopScope() self.hop_scope.hops = [hop] self.recipe_scope = RecipeScope() self.recipe_scope.hop_scope = self.hop_scope self.hop_projection = HopProjection() self.hop_projection.hops = [hop]
def __init__(self, fermentable: Fermentable) -> None: self.fermentable = fermentable self.fermentable_scope = FermentableScope() self.fermentable_scope.fermentables = [fermentable] self.recipe_scope = RecipeScope() self.recipe_scope.fermentable_scope = self.fermentable_scope self.fermentable_projection = FermentableProjection() self.fermentable_projection.fermentables = [fermentable]
def plot(self) -> Chart: projection = YeastProjection() if self.filter_param in YEAST_FILTER_TO_TYPES: projection.types = YEAST_FILTER_TO_TYPES[self.filter_param] analysis = RecipesPopularityAnalysis(RecipeScope()) df = analysis.popularity_per_yeast(projection, num_top=8, top_months=self.period_months) if len(df) <= 1: # 1, because a single data point is also meaningless raise NoDataException() figure = LinesChart(force_legend=True).plot(df, 'month', 'recipes_percent', 'yeast', 'Month/Year', '% of All Recipes') return Chart(figure, height=Chart.DEFAULT_HEIGHT * 0.66, title=self.get_chart_title())
def plot(self) -> Chart: projection = YeastProjection() if self.filter_param in YEAST_FILTER_TO_TYPES: projection.types = YEAST_FILTER_TO_TYPES[self.filter_param] analysis = RecipesTrendAnalysis(RecipeScope()) df = analysis.trending_yeasts(projection, trend_window_months=self.period_months) if len(df) == 0: raise NoDataException() figure = LinesChart(force_legend=True).plot(df, 'month', 'recipes_percent', 'yeast', None, '% of All Recipes') return Chart(figure, title=self.get_chart_title())
def get_scope(request: HttpRequest) -> RecipeScope: scope = RecipeScope() # Update values in data.ts when limits are changed if 'styles' in request.GET: scope.styles = get_styles(str(request.GET['styles'])) if 'ibu' in request.GET: (scope.ibu_min, scope.ibu_max) = get_min_max(str(request.GET['ibu']), 0, 301) if 'abv' in request.GET: (scope.abv_min, scope.abv_max) = get_min_max(str(request.GET['abv']), 0, 21) if 'srm' in request.GET: (scope.srm_min, scope.srm_max) = get_min_max(str(request.GET['srm']), 0, 101) if 'og' in request.GET: (scope.og_min, scope.og_max) = get_min_max(str(request.GET['og']), 1000, 1151, factor=0.001) return scope
def common_styles_relative(self, num_top: Optional[int] = None) -> DataFrame: df = self._common_styles_data() if len(df) == 0: return df # Calculate percent recipes_per_style = RecipesCountAnalysis(RecipeScope()).per_style() df = df.merge(recipes_per_style, on="style_id") df['recipes_percent'] = df['recipes'] / df['total_recipes'] df = df.sort_values('recipes_percent', ascending=False) return self._return(df, num_top)
def popularity(self) -> DataFrame: analysis = RecipesPopularityAnalysis(RecipeScope()) return analysis.popularity_per_yeast(self.yeast_projection)
def pairings(self) -> DataFrame: analysis = HopPairingAnalysis(RecipeScope()) return analysis.pairings(self.hop_projection)
def amount_per_use(self) -> DataFrame: analysis = HopAmountAnalysis(RecipeScope()) return analysis.per_use(self.hop_projection)
def popularity(self) -> DataFrame: analysis = RecipesPopularityAnalysis(RecipeScope()) return analysis.popularity_per_fermentable(self.fermentable_projection)
def popularity(self) -> DataFrame: analysis = RecipesPopularityAnalysis(RecipeScope()) projection = StyleProjection() projection.styles = list(self.style.get_style_including_sub_styles()) return analysis.popularity_per_style(projection)
def __init__(self, style: Style) -> None: self.style = style self.recipe_scope = RecipeScope() self.recipe_scope.styles = [style]