<commit_before>import copy
import json
import inspect
import warnings
import functools
import numpy as _np
import scipy as _sp
import scipy.sparse
import time as _time
from collections import OrderedDict
from docrep import DocstringProcessor
from IPython.core.magics.execution import _format_time

__all__ = [
    "Docorator",
    "PrintableDict",
    "PrintableList",
    "NestedDict",
    "SubDict",
    "SettingsDict",
    "GenericSettings",
    "HealthDict",
    "flat_list",
    "sanitize_dict",
    "unique_list",
    "tic", "toc",
    "is_symmetric",
    "is_valid_propname",
    "prettify_logger_message",
    "remove_prop_deep",
]


class Docorator(DocstringProcessor):

    __instance__ = None

    def __new__(cls, *args, **kwargs):
        if Docorator.__instance__ is None:
            Docorator.__instance__ = DocstringProcessor()
            Docorator.__instance__.all_sections = ['Parameters',
                                                   'Returns',
                                                   'Notes',
                                                   'Examples',
                                                   'See Also',
                                                   'Other Parameters',]
        return Docorator.__instance__


class PrintableList(list):
    r"""
    Simple subclass of ``list`` that has nice printing.  Only works flat lists.

    Example
    -------
    >>> from openpnm.utils import PrintableList
    >>> temp = ['item1', 'item2', 'item3']
    >>> print(PrintableList(temp))<commit_msg>Tweaking Docorator to have custom sections...didn't work<commit_after>import copy
import json
import inspect
import warnings
import functools
import numpy as _np
import scipy as _sp
import scipy.sparse
import time as _time
from collections import OrderedDict
from docrep import DocstringProcessor
from IPython.core.magics.execution import _format_time

__all__ = [
    "Docorator",
    "PrintableDict",
    "PrintableList",
    "NestedDict",
    "SubDict",
    "SettingsDict",
    "GenericSettings",
    "HealthDict",
    "flat_list",
    "sanitize_dict",
    "unique_list",
    "tic", "toc",
    "is_symmetric",
    "is_valid_propname",
    "prettify_logger_message",
    "remove_prop_deep",
]


class Docorator(DocstringProcessor):

    __instance__ = None

    def __new__(cls, *args, **kwargs):
        if Docorator.__instance__ is None:
            Docorator.__instance__ = DocstringProcessor()

        # Add custom parameter type sections
        a = DocstringProcessor.param_like_sections
        Docorator.__instance__.param_like_sections = a + [] # ["Attributes", "Settings"]
        # Add custom text type sections
        a = Docorator.__instance__.text_sections
        Docorator.__instance__.text_sections = a + []

        # Create a single list of all section types
        a = Docorator.__instance__.param_like_sections
        b = Docorator.__instance__.text_sections
        Docorator.__instance__.all_sections = a + b

        return Docorator.__instance__


class PrintableList(list):
    r"""
    Simple subclass of ``list`` that has nice printing.  Only works flat lists.

    Example
    -------
    >>> from openpnm.utils import PrintableList
    >>> temp = ['item1', 'item2', 'item3']
    >>> print(PrintableList(temp))
{'fraction_non_alphanumeric': 0.09505010628606134, 'fraction_numerical': 0.0018220467658669906, 'mean_word_length': 2.4600840336134455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '473857', 'n_tokens_mistral': 928, 'n_tokens_neox': 902, 'n_words': 239}