<commit_before>"""
Module :mod:`nhe.surface.base` implements :class:`BaseSurface`.
"""
import abc


class BaseSurface(object):
    """
    Base class for earthquake rupture surface.

    Subclasses must implement :meth:`get_mesh` and can (for the sake
    of performance) implement :meth:`get_min_distance`.
    """
    __metaclass__ = abc.ABCMeta

    def get_min_distance(self, point, discretization):
        """
        Compute and return the minimum distance from the surface to ``point``.

        :param discretization:
            The minimum precision the calculation should be done with.
            This represents the maximum mesh spacing for the case when
            the actual implementation uses a numerical approach (like
            creating the :meth:`mesh <get_mesh>` and computing distances
            to each point of the mesh). The value is in km. The actual
            implementation is free to provide the result with higher
            precision or ignore that parameter's value altogether
            if perfectly correct calculation is possible and feasible.
        :returns:
            Distance in km.

        Base class implementation does a numerical approach -- finds
        a minimum distance from each point of the :meth:`mesh <get_mesh>`.
        """
        return min(min(point.distance(mesh_point) for mesh_point in row)
                   for row in self.get_mesh(discretization))

    @abc.abstractmethod
    def get_mesh(self, mesh_spacing):
        """
        Create and return the mesh of points covering the surface.

        :param mesh_spacing:
            The desired distance between two adjacent points in the mesh<commit_msg>surface/base [docs]: more improvements in docstring correctness<commit_after>"""
Module :mod:`nhe.surface.base` implements :class:`BaseSurface`.
"""
import abc


class BaseSurface(object):
    """
    Base class for surface in 3D-space.

    Subclasses must implement :meth:`get_mesh` and can (for the sake
    of performance) implement :meth:`get_min_distance`.
    """
    __metaclass__ = abc.ABCMeta

    def get_min_distance(self, point, discretization):
        """
        Compute and return the minimum distance from the surface to ``point``.

        :param discretization:
            The minimum precision the calculation should be done with.
            This represents the mesh spacing for the case when the actual
            implementation uses a numerical approach (like creating
            the :meth:`mesh <get_mesh>` and computing distances
            to each point of the mesh). The value is in km. The actual
            implementation is free to provide the result with higher
            precision or ignore that parameter's value altogether
            if perfectly correct calculation is possible and feasible.
        :returns:
            Distance in km.

        Base class implementation does a numerical approach -- finds
        a minimum distance from each point of the :meth:`mesh <get_mesh>`.
        """
        return min(min(point.distance(mesh_point) for mesh_point in row)
                   for row in self.get_mesh(discretization))

    @abc.abstractmethod
    def get_mesh(self, mesh_spacing):
        """
        Create and return the mesh of points covering the surface.

        :param mesh_spacing:
            The desired distance between two adjacent points in the mesh
{'fraction_non_alphanumeric': 0.06501912327155046, 'fraction_numerical': 0.0002942041776993233, 'mean_word_length': 2.5639412997903563, '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': '7418798', 'n_tokens_mistral': 825, 'n_tokens_neox': 786, 'n_words': 356}