<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
#   MYPlotSpec.Figure_Manager.py
#   Written by <NAME> on 14-11-17, last updated by <NAME> on 15-01-07
"""
Class to manage the generation of figures using matplotlib
"""
################################### MODULES ####################################
from __future__ import absolute_import,division,print_function,unicode_literals
import os, sys
from collections import OrderedDict
from . import merge_dicts, get_yaml
from .Method_Defaults_Presets import Method_Defaults_Presets
from .Manage_Kwargs import Manage_Kwargs
from .Figure_Output import Figure_Output
################################### CLASSES ####################################
class Figure_Manager(object):
    """
    Class to manage the generation of figures using matplotlib
    """
    defaults = """
          draw_figure:
            left:         1
            sub_width:    5.5
            right:        1
            top:          1
            sub_height:   5.5
            bottom:       1
            title_fp:     12r
            label_fp:     12r
            hand:
                stump: 1
                nay:   bama
          draw_subplot:
            title_fp:     12r
            label_fp:     12r
            tick_fp:      10r
            lw:           1
          draw_dataset:
            lw:           1
    """
    presets  = """
        presentation:
          draw_figure:
            title_fp:     24r
            label_fp:     24r
          draw_subplot:
            title_fp:     24r
            label_fp:     24r
            tick_fp:      18r
            legend_fp:    18r
            lw:           2
          draw_dataset:
            lw:           2
        notebook:
          draw_figure:
            title_fp:     12r
            label_fp:     12r
          draw_subplot:
            title_fp:     12r
            label_fp:     12r
            tick_fp:      10r
            legend_fp:    10r
            lw:           1
          draw_dataset:
            lw:           1
        letter:
          draw_figure:
            title_fp:     18r
            label_fp:     18r
          draw_subplot:
            title_fp:     18r
            label_fp:     18r
            tick_fp:      14r
            legend_fp:    14r
            lw:           2
          draw_dataset:
            lw:           2
    """

    def __init__(self, **kwargs):
        """
        Initializes
        """
        self.draw_report(**kwargs)

    @Method_Defaults_Presets()
    @Manage_Kwargs()
    def draw_report(self, **in_kwargs):
        """
        Draws a series of figures based on a series of figure
        specifications

        **Arguments:**
            :*outfile*:
            :*figures*: Figure specifications
        """

        figure_specs   = in_kwargs.pop("figures", {})
        figure_indexes = sorted([i for i in figure_specs.keys()
                           if str(i).isdigit()])
        outfiles       = {}

        # Configure and plot figures
        for i in figure_indexes:
            out_kwargs              = figure_specs[i].copy()
            out_kwargs["debug"]     = in_kwargs.get("debug",     False)
            out_kwargs["preset"]    = in_kwargs.get("preset",    [])[:]
            out_kwargs["yaml_dict"] = in_kwargs.get("yaml_dict", {})
            out_kwargs["yaml_keys"] = [["figures", "all"], ["figures", i]]
            out_kwargs["outfiles"]  = outfiles
            print(i, out_kwargs["preset"])
            print(i, out_kwargs["yaml_keys"])
            self.draw_figure(**out_kwargs)

        # Clean up
        for outfile in outfiles.values():
            outfile.close()

    @Method_Defaults_Presets()
    @Manage_Kwargs()
    @Figure_Output()
    def draw_figure(self, title = None, shared_xlabel = None,<commit_msg>missed a debug print statement<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
#   MYPlotSpec.Figure_Manager.py
#   Written by <NAME> on 14-11-17, last updated by <NAME> on 15-01-07
"""
Class to manage the generation of figures using matplotlib
"""
################################### MODULES ####################################
from __future__ import absolute_import,division,print_function,unicode_literals
import os, sys
from collections import OrderedDict
from . import merge_dicts, get_yaml
from .Method_Defaults_Presets import Method_Defaults_Presets
from .Manage_Kwargs import Manage_Kwargs
from .Figure_Output import Figure_Output
################################### CLASSES ####################################
class Figure_Manager(object):
    """
    Class to manage the generation of figures using matplotlib
    """
    defaults = """
          draw_figure:
            left:         1
            sub_width:    5.5
            right:        1
            top:          1
            sub_height:   5.5
            bottom:       1
            title_fp:     12r
            label_fp:     12r
            hand:
                stump: 1
                nay:   bama
          draw_subplot:
            title_fp:     12r
            label_fp:     12r
            tick_fp:      10r
            lw:           1
          draw_dataset:
            lw:           1
    """
    presets  = """
        presentation:
          draw_figure:
            title_fp:     24r
            label_fp:     24r
          draw_subplot:
            title_fp:     24r
            label_fp:     24r
            tick_fp:      18r
            legend_fp:    18r
            lw:           2
          draw_dataset:
            lw:           2
        notebook:
          draw_figure:
            title_fp:     12r
            label_fp:     12r
          draw_subplot:
            title_fp:     12r
            label_fp:     12r
            tick_fp:      10r
            legend_fp:    10r
            lw:           1
          draw_dataset:
            lw:           1
        letter:
          draw_figure:
            title_fp:     18r
            label_fp:     18r
          draw_subplot:
            title_fp:     18r
            label_fp:     18r
            tick_fp:      14r
            legend_fp:    14r
            lw:           2
          draw_dataset:
            lw:           2
    """

    def __init__(self, **kwargs):
        """
        Initializes
        """
        self.draw_report(**kwargs)

    @Method_Defaults_Presets()
    @Manage_Kwargs()
    def draw_report(self, **in_kwargs):
        """
        Draws a series of figures based on a series of figure
        specifications

        **Arguments:**
            :*outfile*:
            :*figures*: Figure specifications
        """

        figure_specs   = in_kwargs.pop("figures", {})
        figure_indexes = sorted([i for i in figure_specs.keys()
                           if str(i).isdigit()])
        outfiles       = {}

        # Configure and plot figures
        for i in figure_indexes:
            out_kwargs              = figure_specs[i].copy()
            out_kwargs["debug"]     = in_kwargs.get("debug",     False)
            out_kwargs["preset"]    = in_kwargs.get("preset",    [])[:]
            out_kwargs["yaml_dict"] = in_kwargs.get("yaml_dict", {})
            out_kwargs["yaml_keys"] = [["figures", "all"], ["figures", i]]
            out_kwargs["outfiles"]  = outfiles
            self.draw_figure(**out_kwargs)

        # Clean up
        for outfile in outfiles.values():
            outfile.close()

    @Method_Defaults_Presets()
    @Manage_Kwargs()
    @Figure_Output()
    def draw_figure(self, title = None, shared_xlabel = None,
{'fraction_non_alphanumeric': 0.11899070385126162, 'fraction_numerical': 0.020185922974767595, 'mean_word_length': 1.4270061231066709, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7102989', 'n_tokens_mistral': 2209, 'n_tokens_neox': 2084, 'n_words': 485}