def reset(self, **traits):
        """Creates the dataset afresh or resets existing data source."""

        # First set the attributes without really doing anything since
        # the notification handlers are not called.
        self.set(trait_change_notify=False, **traits)

        points = self.points
        scalars = self.scalars
        x, y, z, mask = self.x, self.y, self.z, self.mask

        if mask is not None and len(mask) > 0:
            scalars[mask.astype('bool')] = np.nan
            # The NaN trick only works with floats.
            scalars = scalars.astype('float')
            self.set(scalars=scalars, trait_change_notify=False)

        assert len(x.shape) == 2, "Array x must be 2 dimensional."
        assert len(y.shape) == 2, "Array y must be 2 dimensional."
        assert len(z.shape) == 2, "Array z must be 2 dimensional."
        assert x.shape == y.shape, "Arrays x and y must have same shape."
        assert y.shape == z.shape, "Arrays y and z must have same shape."

        # Points in the grid source will always be created using x,y,z
        # Changing of points is not allowed because it cannot be used to
        # modify values of x,y,z

        nx, ny = x.shape
        points = np.c_[x.ravel(), y.ravel(), z.ravel()].ravel()
        points.shape = (nx * ny, 3)
        self.set(points=points, trait_change_notify=False)

        i, j = np.mgrid[0:nx - 1, 0:ny - 1]
        i, j = np.ravel(i), np.ravel(j)
        t1 = i * ny + j, (i + 1) * ny + j, (i + 1) * ny + (j + 1)
        t2 = (i + 1) * ny + (j + 1), i * ny + (j + 1), i * ny + j
        nt = len(t1[0])
        triangles = np.zeros((nt * 2, 3), 'l')
        triangles[0:nt, 0], triangles[0:nt, 1], triangles[0:nt, 2] = t1
        triangles[nt:, 0], triangles[nt:, 1], triangles[nt:, 2] = t2

        if self.dataset is None:
            pd = tvtk.PolyData()
        else:
            pd = self.dataset
        pd.set(points=points, polys=triangles)

        if scalars is not None and len(scalars) > 0:
            if not scalars.flags.contiguous:
                scalars = scalars.copy()
                self.set(scalars=scalars, trait_change_notify=False)
            assert x.shape == scalars.shape
            pd.point_data.scalars = scalars.ravel()
            pd.point_data.scalars.name = 'scalars'

        self.dataset = pd

    ######################################################################
    # Non-public interface.
    ######################################################################
dataset/ETHPy150Open enthought/mayavi/mayavi/tools/sources.py/MGridSource.reset/original