<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
#   myplotspec.plugins.MPSInitializePlugin.py
#
#   Copyright (C) 2015-2016 <NAME>
#   All rights reserved.
#
#   This software may be modified and distributed under the terms of the
#   BSD license. See the LICENSE file for details.
"""
Initializes a nascent spec.

.. todo:
  - Somehow get indexes from presets if present
  - Intersphinx documentation
"""
################################### MODULES ###################################
from __future__ import absolute_import,division,print_function,unicode_literals
if __name__ == "__main__":
    __package__ = str("myplotspec.plugins")
    import myplotspec.plugins
import ruamel.yaml as yaml
from ..yspec.plugins import YSpecPlugin
################################### CLASSES ###################################
class MPSInitializePlugin(YSpecPlugin):
    """
    Initializes a nascent spec.

    Differs from yspec's InitializePlugin through the addition of
    support for initializing a grid of subplots based on arguments
    defined under figures/INDEX/subplots/grid

    Attributes
      name (str): Name of this plugin
      indexed_levels (dict): Levels of spec hierarchy that include an
        additional layer of indexes below them
    """
    name = "initialize"
    description = """Initializes indexed levels of nascent spec based on
      structure present in source spec."""

    def __init__(self, indexed_levels=None, **kwargs):
        """
        """
        if indexed_levels is not None:
            self.indexed_levels = indexed_levels
        else:
            self.indexed_levels = {}

    def __call__(self, spec, source_spec=None, **kwargs):
        """
        Initializes a nascent spec.

        Arguments:
          spec (dict): Nascent spec (typically {} at this time)
          source_spec (dict): Source spec to use to determine initial
            structure

        Returns:
          dict: Initialized spec
        """
        if source_spec is not None:
            self.process_level(spec, source_spec, self.indexed_levels)
        return spec

    def process_level(self, spec, source_spec, indexed_levels, path=None):
        """
        Initialize one level of spec hierarchy

        Arguments:
          spec (dict): Nascent spec at current level
          source_spec (dict): Source spec at current level
          indexed_levels (dict): Indexed levels below current level
          path (list): List of keys leading to this level
          source_spec[grid][nrows] (int, optional): Number of rows of subplots
            to add
          source_spec[grid][ncols] (int, optional): Number of columns of
            subplots to add
          source_spec[grid][nsubplots] (int, optional): Number of subplots to
            add; if less than nrows*ncols (e.g. 2 cols and 2 rows but
            only three subplots)
        """

        # Process arguments
        if indexed_levels is None or source_spec is None:
            return<commit_msg>fixed Initialize inheritance<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
#   myplotspec.plugins.MPSInitializePlugin.py
#
#   Copyright (C) 2015-2016 <NAME>
#   All rights reserved.
#
#   This software may be modified and distributed under the terms of the
#   BSD license. See the LICENSE file for details.
"""
Initializes a nascent spec.

.. todo:
  - Somehow get indexes from presets if present
  - Intersphinx documentation
"""
################################### MODULES ###################################
from __future__ import absolute_import,division,print_function,unicode_literals
if __name__ == "__main__":
    __package__ = str("myplotspec.plugins")
    import myplotspec.plugins
import ruamel.yaml as yaml
from ..yspec.plugins.InitializePlugin import InitializePlugin
################################### CLASSES ###################################
class MPSInitializePlugin(InitializePlugin):
    """
    Initializes a nascent spec.

    Differs from yspec's InitializePlugin through the addition of
    support for initializing a grid of subplots based on arguments
    defined under figures/INDEX/subplots/grid

    Attributes
      name (str): Name of this plugin
      indexed_levels (dict): Levels of spec hierarchy that include an
        additional layer of indexes below them
    """

    def process_level(self, spec, source_spec, indexed_levels, path=None):
        """
        Initialize one level of spec hierarchy

        Arguments:
          spec (dict): Nascent spec at current level
          source_spec (dict): Source spec at current level
          indexed_levels (dict): Indexed levels below current level
          path (list): List of keys leading to this level
          source_spec[grid][nrows] (int, optional): Number of rows of subplots
            to add
          source_spec[grid][ncols] (int, optional): Number of columns of
            subplots to add
          source_spec[grid][nsubplots] (int, optional): Number of subplots to
            add; if less than nrows*ncols (e.g. 2 cols and 2 rows but
            only three subplots)
        """

        # Process arguments
        if indexed_levels is None or source_spec is None:
            return
{'fraction_non_alphanumeric': 0.12302960399846213, 'fraction_numerical': 0.004229142637447136, 'mean_word_length': 2.897378277153558, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, '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': '4986869', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1300, 'n_words': 494}