<commit_before>
from .mesh import MeshVisual
from ..geometry import create_grid_mesh, MeshData
from ..color import ColorArray

import numpy as np


class GridMeshVisual(MeshVisual):
    """Displays a mesh in a Cartesian grid about x,y,z coordinates.

    This makes it simple to generate a mesh from e.g. the output
    of numpy.meshgrid.

    Parameters
    ----------
    xs : ndarray
        A 2d array of x coordinates for the vertices of the mesh. Must
        have the same dimensions as ys and zs.
    ys : ndarray
        A 2d array of y coordinates for the vertices of the mesh. Must
        have the same dimensions as xs and zs.
    zs : ndarray
        A 2d array of z coordinates for the vertices of the mesh. Must
        have the same dimensions as xs and ys.
    color : ndarray | Color
        The color(s) of the points of the mesh. Should be either a
        (width, height, 4) array of rgba colors at each grid point,
        a (width, height, 3) array of rgb colors at each grid point,
        a (width, height) array of a Color at each grid point, or a
        single Color that will be applied to the entire mesh.
    shading : str | None
        Same as for the `MeshVisual` class. Defaults to 'smooth'.
    vertex_colors: ndarray | None
        Same as for the `MeshVisual` class. Defaults to None. Overrides
        the color argument if set.
    face_colors: ndarray | None
        Same as for the `MeshVisual` class. Defaults to None.
    """

    def __init__(self, xs, ys, zs, colors=None,
                 shading='smooth',
                 **kwargs):

        if xs is None or ys is None or zs is None:
            raise ValueError('All of xs, ys and zs must be initialised '
                             'with arrays.')
        self._xs = None
        self._ys = None
        self._zs = None

        self.__colors = None
        self.__vertices = None
        self.__meshdata = MeshData()

        MeshVisual.__init__(self, shading=shading, **kwargs)
        self.set_data(xs, ys, zs, colors)

    def set_data(self, xs=None, ys=None, zs=None, colors=None):

        if xs is not None:
            if self._xs is not None:
                self.__vertices = None
            self._xs = xs

        if ys is not None:
            if self._ys is not None:
                self.__vertices = None
            self._ys = ys

        if zs is not None:
            if self._zs is not None:
                self.__vertices = None
            self._zs = zs

        if self.__vertices is None:
            vertices, indices = create_grid_mesh(self._xs, self._ys, self._zs)
            self.__meshdata.set_vertices(vertices)
            self.__meshdata.set_faces(indices)

        if colors is not None:
            self.__colors = colors
            self.__meshdata.set_vertex_colors(colors.reshape(
                colors.shape[0] * colors.shape[1], colors.shape[2]))

        MeshVisual.set_data(self, meshdata=self.__meshdata)

    def draw(self, transforms):
        MeshVisual.draw(self, transforms)<commit_msg>Removed unnecessary draw method for gridmesh<commit_after>
from .mesh import MeshVisual
from ..geometry import create_grid_mesh, MeshData
from ..color import ColorArray

import numpy as np


class GridMeshVisual(MeshVisual):
    """Displays a mesh in a Cartesian grid about x,y,z coordinates.

    This makes it simple to generate a mesh from e.g. the output
    of numpy.meshgrid.

    Parameters
    ----------
    xs : ndarray
        A 2d array of x coordinates for the vertices of the mesh. Must
        have the same dimensions as ys and zs.
    ys : ndarray
        A 2d array of y coordinates for the vertices of the mesh. Must
        have the same dimensions as xs and zs.
    zs : ndarray
        A 2d array of z coordinates for the vertices of the mesh. Must
        have the same dimensions as xs and ys.
    color : ndarray | Color
        The color(s) of the points of the mesh. Should be either a
        (width, height, 4) array of rgba colors at each grid point,
        a (width, height, 3) array of rgb colors at each grid point,
        a (width, height) array of a Color at each grid point, or a
        single Color that will be applied to the entire mesh.
    shading : str | None
        Same as for the `MeshVisual` class. Defaults to 'smooth'.
    vertex_colors: ndarray | None
        Same as for the `MeshVisual` class. Defaults to None. Overrides
        the color argument if set.
    face_colors: ndarray | None
        Same as for the `MeshVisual` class. Defaults to None.
    """

    def __init__(self, xs, ys, zs, colors=None,
                 shading='smooth',
                 **kwargs):

        if xs is None or ys is None or zs is None:
            raise ValueError('All of xs, ys and zs must be initialised '
                             'with arrays.')
        self._xs = None
        self._ys = None
        self._zs = None

        self.__colors = None
        self.__vertices = None
        self.__meshdata = MeshData()

        MeshVisual.__init__(self, shading=shading, **kwargs)
        self.set_data(xs, ys, zs, colors)

    def set_data(self, xs=None, ys=None, zs=None, colors=None):

        if xs is not None:
            if self._xs is not None:
                self.__vertices = None
            self._xs = xs

        if ys is not None:
            if self._ys is not None:
                self.__vertices = None
            self._ys = ys

        if zs is not None:
            if self._zs is not None:
                self.__vertices = None
            self._zs = zs

        if self.__vertices is None:
            vertices, indices = create_grid_mesh(self._xs, self._ys, self._zs)
            self.__meshdata.set_vertices(vertices)
            self.__meshdata.set_faces(indices)

        if colors is not None:
            self.__colors = colors
            self.__meshdata.set_vertex_colors(colors.reshape(
                colors.shape[0] * colors.shape[1], colors.shape[2]))

        MeshVisual.set_data(self, meshdata=self.__meshdata)
{'fraction_non_alphanumeric': 0.0725405763497847, 'fraction_numerical': 0.002649884067572044, 'mean_word_length': 1.9159826170931917, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7359779', 'n_tokens_mistral': 1760, 'n_tokens_neox': 1686, 'n_words': 689}