<commit_before>import time
import openpnm
import numpy as np
from copy import deepcopy
from openpnm.utils import SettingsDict, HealthDict, Workspace, logging
logger = logging.getLogger(__name__)
ws = Workspace()


class Project(list):
    r"""
    This class provides a container for all OpenPNM objects in a given
    simulation.

    A simulation is defined as a Network and all of it's associated objects.
    When instantiating a Network, a Project can be passed as an argument, but
    if not given one is created.  When instantiating any other object either
    a Network or a Project can be supplied.  In the former case, the
    Network's Project is retrieved and used.  The end result is that all
    objects are stored in a specific Project.

    The Project to which any object belongs can be retrieved with
    ``obj.project``.  Conversely, printing a Project displays a list of all
    objects it contains.

    Moreover, all Projects are registered with the Workspace.  Since there can
    be only instance of the Workspace it is possible to view all open Projects
    by printing the Workspace.

    See Also
    --------
    Workspace

    Notes
    -----
    The following table shows all the methods that are available on the Project
    objects along with a very brief description:

    +------------------+-------------------------------------------------+
    | Method           | Description                                     |
    +==================+=================================================+
    | export_data      | Export the pore and throat data from the giv... |
    +------------------+-------------------------------------------------+
    | import_data      |                                                 |
    +------------------+-------------------------------------------------+
    | purge_object     | Remove an object from the Project.  This rem... |
    +------------------+-------------------------------------------------+
    | load_object      | Loads a single object from a file               |
    +------------------+-------------------------------------------------+
    | save_object      | Saves the given object to a file                |
    +------------------+-------------------------------------------------+
    | find_physics     | Find the Physics object(s) associated with a... |
    +------------------+-------------------------------------------------+
    | find_geometry    | Find the Geometry associated with a given Ph... |
    +------------------+-------------------------------------------------+
    | find_phase       | Find the Phase associated with a given object.  |
    +------------------+-------------------------------------------------+
    | check_geometr... | Perform a check to find pores with overlappi... |
    +------------------+-------------------------------------------------+
    | check_physics... | Perform a check to find pores which have ove... |
    +------------------+-------------------------------------------------+

    """

    def __init__(self, *args, **kwargs):
        name = kwargs.pop('name', None)
        super().__init__(*args, **kwargs)
        # Register self with workspace
        ws[name] = self
        self.settings = SettingsDict()
        self.comments = 'Using OpenPNM ' + openpnm.__version__

    def extend(self, obj):
        r"""
        This function is used to add objects to the project.  Arguments can
        be single OpenPNM objects, an OpenPNM project list, or a plain list of
        OpenPNM objects.

        """
        if type(obj) is not list:
            obj = [obj]
        for item in obj:
            if hasattr(item, '_mro'):
                if 'GenericNetwork' in item._mro():
                    if self.network:
                        raise Exception('Project already has a network')
                # Must use append since extend breaks the dicts up into
                # separate objects, while append keeps it as a single object.
                super().append(item)
            else:
                raise Exception('Only OpenPNM objects can be added')

    def append(self, obj):
        r"""<commit_msg>Changed project.extend to ensure objects being added do have conflicting name<commit_after>import time
import openpnm
import numpy as np
from copy import deepcopy
from openpnm.utils import SettingsDict, HealthDict, Workspace, logging
logger = logging.getLogger(__name__)
ws = Workspace()


class Project(list):
    r"""
    This class provides a container for all OpenPNM objects in a given
    simulation.

    A simulation is defined as a Network and all of it's associated objects.
    When instantiating a Network, a Project can be passed as an argument, but
    if not given one is created.  When instantiating any other object either
    a Network or a Project can be supplied.  In the former case, the
    Network's Project is retrieved and used.  The end result is that all
    objects are stored in a specific Project.

    The Project to which any object belongs can be retrieved with
    ``obj.project``.  Conversely, printing a Project displays a list of all
    objects it contains.

    Moreover, all Projects are registered with the Workspace.  Since there can
    be only instance of the Workspace it is possible to view all open Projects
    by printing the Workspace.

    See Also
    --------
    Workspace

    Notes
    -----
    The following table shows all the methods that are available on the Project
    objects along with a very brief description:

    +------------------+-------------------------------------------------+
    | Method           | Description                                     |
    +==================+=================================================+
    | export_data      | Export the pore and throat data from the giv... |
    +------------------+-------------------------------------------------+
    | import_data      |                                                 |
    +------------------+-------------------------------------------------+
    | purge_object     | Remove an object from the Project.  This rem... |
    +------------------+-------------------------------------------------+
    | load_object      | Loads a single object from a file               |
    +------------------+-------------------------------------------------+
    | save_object      | Saves the given object to a file                |
    +------------------+-------------------------------------------------+
    | find_physics     | Find the Physics object(s) associated with a... |
    +------------------+-------------------------------------------------+
    | find_geometry    | Find the Geometry associated with a given Ph... |
    +------------------+-------------------------------------------------+
    | find_phase       | Find the Phase associated with a given object.  |
    +------------------+-------------------------------------------------+
    | check_geometr... | Perform a check to find pores with overlappi... |
    +------------------+-------------------------------------------------+
    | check_physics... | Perform a check to find pores which have ove... |
    +------------------+-------------------------------------------------+

    """

    def __init__(self, *args, **kwargs):
        name = kwargs.pop('name', None)
        super().__init__(*args, **kwargs)
        # Register self with workspace
        ws[name] = self
        self.settings = SettingsDict()
        self.comments = 'Using OpenPNM ' + openpnm.__version__

    def extend(self, obj):
        r"""
        This function is used to add objects to the project.  Arguments can
        be single OpenPNM objects, an OpenPNM project list, or a plain list of
        OpenPNM objects.  Note that if an object has the same name as one
        already existing on the project, the it will be renamed automatically.

        """
        if type(obj) is not list:
            obj = [obj]
        for item in obj:
            if hasattr(item, '_mro'):
                if 'GenericNetwork' in item._mro():
                    if self.network:
                        raise Exception('Project already has a network')
                # Must use append since extend breaks the dicts up into
                # separate objects, while append keeps it as a single object.
                if item in self:
                    raise Exception('Supplied object already part of project')
                if item.name in self.names:
                    item.name = self._generate_name(item)
                super().append(item)
            else:
                raise Exception('Only OpenPNM objects can be added')

    def append(self, obj):
        r"""
{'fraction_non_alphanumeric': 0.2438801189659117, 'fraction_numerical': 0.0, 'mean_word_length': 1.232635342185904, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3067022', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1768, 'n_words': 808}