<commit_before>from extremefill.kPlusViewer import KPlusViewer
from extremefill.kMinusViewer import KMinusViewer
from extremefill.appliedPotentialViewer import AppliedPotentialViewer
from extremefill.deltaRefViewer import DeltaRefViewer
from extremefill.featureDepthViewer import FeatureDepthViewer
from extremefill.kPlusVkMinusViewer import KPlusVkMinusViewer
from extremefill.appliedPotentialVbulkSuppressorViewer import AppliedPotentialVbulkSuppressorViewer
from extremefill.bulkSuppressorViewer import BulkSuppressorViewer
from extremefill.schematicViewer import SchematicViewer
import extremefill.pseudo2DSimulation
import extremefill.simulation1D
import extremefill.simulation2D
from extremefill.pseudo2DSimulation import Pseudo2DSimulation

## figure ordering from the paper
viewers = (None,
           SchematicViewer,
           KPlusViewer,
           KMinusViewer,
           KPlusVkMinusViewer,
           FeatureDepthViewer,
           DeltaRefViewer,
           AppliedPotentialViewer,
           BulkSuppressorViewer,
           AppliedPotentialVbulkSuppressorViewer)

def generateFigures(fignumbers=(2, 3, 4, 5, 6, 7, 8, 9, 10), filesuffix=('.png',), datafile='data.h5'):
    r"""
    Generate all the figures in the paper. By default PNG images are
    generated.

    To generate Figure 3 from the paper:

    >>> import extremefill
    >>> extremefill.generateFigures(fignumbers=3)

    .. image:: kPlus.*
       :width: 50%
       :align: center
       :alt: Figure 3 from the paper

    :Parameters:
      - `filesuffix`: tuple of the file suffixes of the generated images.
      - `datafile`: path to the cached HDF5 data file to either read from or write to.
      - `fignumbers` : tuple of figure numbers to generate. 
    """

    if type(fignumbers) is int:
        fignumbers = [fignumbers]

    for number in fignumbers:
        Viewer = viewers[number - 1]
        if Viewer is not None:
            Viewer(datafile=datafile).plot(filesuffix=filesuffix)

def test():
    r"""
    Run all the doctests available.
    """
    import doctest
    doctest.testmod(extremefill.pseudo2DSimulation)
    doctest.testmod(extremefill.simulation1D)
    doctest.testmod(extremefill.simulation2D)
       
def run(view=True, **parameters):
    r"""

    Run a single simulation using
    :py:meth:`Pseudo2DSimulation.run <extremefill.pseudo2DSimulation.Pseudo2DSimulation.run>`.

    Run the default simulation for 10 time steps

    >>> import extremefill
    >>> extremefill.run(totalSteps=10)

    .. image:: kPlus10.*
       :width: 50%
       :align: center
       :alt: Default simulation after 10 time steps<commit_msg>Removed import of viewers when importing extremefill.<commit_after>import extremefill.pseudo2DSimulation
import extremefill.simulation1D
import extremefill.simulation2D
from extremefill.pseudo2DSimulation import Pseudo2DSimulation

## figure ordering from the paper
def getViewers():
    from extremefill.kPlusViewer import KPlusViewer
    from extremefill.kMinusViewer import KMinusViewer
    from extremefill.appliedPotentialViewer import AppliedPotentialViewer
    from extremefill.deltaRefViewer import DeltaRefViewer
    from extremefill.featureDepthViewer import FeatureDepthViewer
    from extremefill.kPlusVkMinusViewer import KPlusVkMinusViewer
    from extremefill.appliedPotentialVbulkSuppressorViewer import AppliedPotentialVbulkSuppressorViewer
    from extremefill.bulkSuppressorViewer import BulkSuppressorViewer
    from extremefill.schematicViewer import SchematicViewer
    return (None,
            SchematicViewer,
            KPlusViewer,
            KMinusViewer,
            KPlusVkMinusViewer,
            FeatureDepthViewer,
            DeltaRefViewer,
            AppliedPotentialViewer,
            BulkSuppressorViewer,
            AppliedPotentialVbulkSuppressorViewer)

def generateFigures(fignumbers=(2, 3, 4, 5, 6, 7, 8, 9, 10), filesuffix=('.png',), datafile='data.h5'):
    r"""
    Generate all the figures in the paper. By default PNG images are
    generated.

    To generate Figure 3 from the paper:

    >>> import extremefill
    >>> extremefill.generateFigures(fignumbers=3)

    .. image:: kPlus.*
       :width: 50%
       :align: center
       :alt: Figure 3 from the paper

    :Parameters:
      - `filesuffix`: tuple of the file suffixes of the generated images.
      - `datafile`: path to the cached HDF5 data file to either read from or write to.
      - `fignumbers` : tuple of figure numbers to generate. 
    """

    if type(fignumbers) is int:
        fignumbers = [fignumbers]

    for number in fignumbers:
        Viewer = getViewers()[number - 1]
        if Viewer is not None:
            Viewer(datafile=datafile).plot(filesuffix=filesuffix)

def test():
    r"""
    Run all the doctests available.
    """
    import doctest
    doctest.testmod(extremefill.pseudo2DSimulation)
    doctest.testmod(extremefill.simulation1D)
    doctest.testmod(extremefill.simulation2D)
       
def run(view=True, **parameters):
    r"""

    Run a single simulation using
    :py:meth:`Pseudo2DSimulation.run <extremefill.pseudo2DSimulation.Pseudo2DSimulation.run>`.

    Run the default simulation for 10 time steps

    >>> import extremefill
    >>> extremefill.run(totalSteps=10)

    .. image:: kPlus10.*
       :width: 50%
       :align: center
       :alt: Default simulation after 10 time steps
{'fraction_non_alphanumeric': 0.07218407867879013, 'fraction_numerical': 0.014473928372610873, 'mean_word_length': 3.3679092382495948, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '5289033', 'n_tokens_mistral': 1733, 'n_tokens_neox': 1623, 'n_words': 427}