prompt: Rectilinear grid does not allow Sequences as inputs
  ### Describe the bug, what's wrong, and what you expected.
  
  Rectilinear grid gives an error when `Sequence`s are passed in, but `ndarray` are ok.
  
  ### Steps to reproduce the bug.
  
  This doesn't work
  ```python
  import pyvista as pv
  pv.RectilinearGrid([0, 1], [0, 1], [0, 1])
  ```
  
  This works
  ```py
  import pyvista as pv
  import numpy as np
  pv.RectilinearGrid(np.ndarray([0, 1]), np.ndarray([0, 1]), np.ndarray([0, 1]))
  ```
  ### System Information
  
  ```shell
  --------------------------------------------------------------------------------
    Date: Wed Apr 19 20:15:10 2023 UTC
  
                  OS : Linux
              CPU(s) : 2
             Machine : x86_64
        Architecture : 64bit
         Environment : IPython
          GPU Vendor : Mesa/X.org
        GPU Renderer : llvmpipe (LLVM 11.0.1, 256 bits)
         GPU Version : 4.5 (Core Profile) Mesa 20.3.5
  
    Python 3.11.2 (main, Mar 23 2023, 17:12:29) [GCC 10.2.1 20210110]
  
             pyvista : 0.38.5
                 vtk : 9.2.6
               numpy : 1.24.2
             imageio : 2.27.0
              scooby : 0.7.1
               pooch : v1.7.0
          matplotlib : 3.7.1
             IPython : 8.12.0
  --------------------------------------------------------------------------------
  ```
  
  
  ### Screenshots
  
  _No response_
  
instance: {"FAIL_TO_PASS": "[\"tests/test_grid.py::test_create_rectilinear_grid_from_specs\"]", "PASS_TO_PASS": "[\"tests/test_grid.py::test_volume\", \"tests/test_grid.py::test_init_from_polydata\", \"tests/test_grid.py::test_init_from_structured\", \"tests/test_grid.py::test_init_from_unstructured\", \"tests/test_grid.py::test_init_from_numpy_arrays\", \"tests/test_grid.py::test_init_bad_input\", \"tests/test_grid.py::test_init_from_arrays[False]\", \"tests/test_grid.py::test_init_from_arrays[True]\", \"tests/test_grid.py::test_init_from_dict[False-False]\", \"tests/test_grid.py::test_init_from_dict[False-True]\", \"tests/test_grid.py::test_init_from_dict[True-False]\", \"tests/test_grid.py::test_init_from_dict[True-True]\", \"tests/test_grid.py::test_init_polyhedron\", \"tests/test_grid.py::test_cells_dict_hexbeam_file\", \"tests/test_grid.py::test_cells_dict_variable_length\", \"tests/test_grid.py::test_cells_dict_empty_grid\", \"tests/test_grid.py::test_cells_dict_alternating_cells\", \"tests/test_grid.py::test_destructor\", \"tests/test_grid.py::test_surface_indices\", \"tests/test_grid.py::test_extract_feature_edges\", \"tests/test_grid.py::test_triangulate_inplace\", \"tests/test_grid.py::test_save[.vtu-True]\", \"tests/test_grid.py::test_save[.vtu-False]\", \"tests/test_grid.py::test_save[.vtk-True]\", \"tests/test_grid.py::test_save[.vtk-False]\", \"tests/test_grid.py::test_pathlib_read_write\", \"tests/test_grid.py::test_init_bad_filename\", \"tests/test_grid.py::test_save_bad_extension\", \"tests/test_grid.py::test_linear_copy\", \"tests/test_grid.py::test_linear_copy_surf_elem\", \"tests/test_grid.py::test_extract_cells[True]\", \"tests/test_grid.py::test_extract_cells[False]\", \"tests/test_grid.py::test_merge\", \"tests/test_grid.py::test_merge_not_main\", \"tests/test_grid.py::test_merge_list\", \"tests/test_grid.py::test_merge_invalid\", \"tests/test_grid.py::test_init_structured_raise\", \"tests/test_grid.py::test_init_structured\", \"tests/test_grid.py::test_no_copy_polydata_init\", \"tests/test_grid.py::test_no_copy_polydata_points_setter\", \"tests/test_grid.py::test_no_copy_structured_mesh_init\", \"tests/test_grid.py::test_no_copy_structured_mesh_points_setter\", \"tests/test_grid.py::test_no_copy_pointset_init\", \"tests/test_grid.py::test_no_copy_pointset_points_setter\", \"tests/test_grid.py::test_no_copy_unstructured_grid_points_setter\", \"tests/test_grid.py::test_no_copy_rectilinear_grid\", \"tests/test_grid.py::test_grid_repr\", \"tests/test_grid.py::test_slice_structured\", \"tests/test_grid.py::test_invalid_init_structured\", \"tests/test_grid.py::test_save_structured[.vtk-True]\", \"tests/test_grid.py::test_save_structured[.vtk-False]\", \"tests/test_grid.py::test_save_structured[.vts-True]\", \"tests/test_grid.py::test_save_structured[.vts-False]\", \"tests/test_grid.py::test_load_structured_bad_filename\", \"tests/test_grid.py::test_instantiate_by_filename\", \"tests/test_grid.py::test_create_rectilinear_after_init\", \"tests/test_grid.py::test_create_rectilinear_grid_from_file\", \"tests/test_grid.py::test_read_rectilinear_grid_from_file\", \"tests/test_grid.py::test_read_rectilinear_grid_from_pathlib\", \"tests/test_grid.py::test_raise_rectilinear_grid_non_unique\", \"tests/test_grid.py::test_cast_rectilinear_grid\", \"tests/test_grid.py::test_create_uniform_grid_from_specs\", \"tests/test_grid.py::test_uniform_grid_invald_args\", \"tests/test_grid.py::test_uniform_setters\", \"tests/test_grid.py::test_create_uniform_grid_from_file\", \"tests/test_grid.py::test_read_uniform_grid_from_file\", \"tests/test_grid.py::test_read_uniform_grid_from_pathlib\", \"tests/test_grid.py::test_cast_uniform_to_structured\", \"tests/test_grid.py::test_cast_uniform_to_rectilinear\", \"tests/test_grid.py::test_uniform_grid_to_tetrahedra\", \"tests/test_grid.py::test_fft_and_rfft\", \"tests/test_grid.py::test_fft_low_pass\", \"tests/test_grid.py::test_fft_high_pass\", \"tests/test_grid.py::test_save_rectilinear[.vtk-True]\", \"tests/test_grid.py::test_save_rectilinear[.vtk-False]\", \"tests/test_grid.py::test_save_rectilinear[.vtr-True]\", \"tests/test_grid.py::test_save_rectilinear[.vtr-False]\", \"tests/test_grid.py::test_save_uniform[.vtk-True]\", \"tests/test_grid.py::test_save_uniform[.vtk-False]\", \"tests/test_grid.py::test_save_uniform[.vti-True]\", \"tests/test_grid.py::test_save_uniform[.vti-False]\", \"tests/test_grid.py::test_grid_points\", \"tests/test_grid.py::test_grid_extract_selection_points\", \"tests/test_grid.py::test_gaussian_smooth\", \"tests/test_grid.py::test_remove_cells[ind0]\", \"tests/test_grid.py::test_remove_cells[ind1]\", \"tests/test_grid.py::test_remove_cells[ind2]\", \"tests/test_grid.py::test_remove_cells_not_inplace[ind0]\", \"tests/test_grid.py::test_remove_cells_not_inplace[ind1]\", \"tests/test_grid.py::test_remove_cells_not_inplace[ind2]\", \"tests/test_grid.py::test_remove_cells_invalid\", \"tests/test_grid.py::test_hide_cells[ind0]\", \"tests/test_grid.py::test_hide_cells[ind1]\", \"tests/test_grid.py::test_hide_cells[ind2]\", \"tests/test_grid.py::test_hide_points[ind0]\", \"tests/test_grid.py::test_hide_points[ind1]\", \"tests/test_grid.py::test_hide_points[ind2]\", \"tests/test_grid.py::test_set_extent\", \"tests/test_grid.py::test_UnstructuredGrid_cast_to_explicit_structured_grid\", \"tests/test_grid.py::test_ExplicitStructuredGrid_init\", \"tests/test_grid.py::test_ExplicitStructuredGrid_cast_to_unstructured_grid\", \"tests/test_grid.py::test_ExplicitStructuredGrid_save\", \"tests/test_grid.py::test_ExplicitStructuredGrid_hide_cells\", \"tests/test_grid.py::test_ExplicitStructuredGrid_show_cells\", \"tests/test_grid.py::test_ExplicitStructuredGrid_dimensions\", \"tests/test_grid.py::test_ExplicitStructuredGrid_visible_bounds\", \"tests/test_grid.py::test_ExplicitStructuredGrid_cell_id\", \"tests/test_grid.py::test_ExplicitStructuredGrid_cell_coords\", \"tests/test_grid.py::test_ExplicitStructuredGrid_neighbors\", \"tests/test_grid.py::test_ExplicitStructuredGrid_compute_connectivity\", \"tests/test_grid.py::test_ExplicitStructuredGrid_compute_connections\", \"tests/test_grid.py::test_ExplicitStructuredGrid_raise_init\", \"tests/test_grid.py::test_copy_no_copy_wrap_object\", \"tests/test_grid.py::test_copy_no_copy_wrap_object_vtk9\"]", "base_commit": "db6ee8dd4a747b8864caae36c5d05883976a3ae5", "created_at": "2023-04-21T13:47:31Z", "environment_setup_commit": "4c2d1aed10b1600d520271beba8579c71433e808", "hints_text": "", "instance_id": "pyvista__pyvista-4315", "patch": "diff --git a/pyvista/core/grid.py b/pyvista/core/grid.py\n--- a/pyvista/core/grid.py\n+++ b/pyvista/core/grid.py\n@@ -135,23 +135,30 @@ def __init__(self, *args, check_duplicates=False, deep=False, **kwargs):\n                     self.shallow_copy(args[0])\n             elif isinstance(args[0], (str, pathlib.Path)):\n                 self._from_file(args[0], **kwargs)\n-            elif isinstance(args[0], np.ndarray):\n-                self._from_arrays(args[0], None, None, check_duplicates)\n+            elif isinstance(args[0], (np.ndarray, Sequence)):\n+                self._from_arrays(np.asanyarray(args[0]), None, None, check_duplicates)\n             else:\n                 raise TypeError(f'Type ({type(args[0])}) not understood by `RectilinearGrid`')\n \n         elif len(args) == 3 or len(args) == 2:\n-            arg0_is_arr = isinstance(args[0], np.ndarray)\n-            arg1_is_arr = isinstance(args[1], np.ndarray)\n+            arg0_is_arr = isinstance(args[0], (np.ndarray, Sequence))\n+            arg1_is_arr = isinstance(args[1], (np.ndarray, Sequence))\n             if len(args) == 3:\n-                arg2_is_arr = isinstance(args[2], np.ndarray)\n+                arg2_is_arr = isinstance(args[2], (np.ndarray, Sequence))\n             else:\n                 arg2_is_arr = False\n \n             if all([arg0_is_arr, arg1_is_arr, arg2_is_arr]):\n-                self._from_arrays(args[0], args[1], args[2], check_duplicates)\n+                self._from_arrays(\n+                    np.asanyarray(args[0]),\n+                    np.asanyarray(args[1]),\n+                    np.asanyarray(args[2]),\n+                    check_duplicates,\n+                )\n             elif all([arg0_is_arr, arg1_is_arr]):\n-                self._from_arrays(args[0], args[1], None, check_duplicates)\n+                self._from_arrays(\n+                    np.asanyarray(args[0]), np.asanyarray(args[1]), None, check_duplicates\n+                )\n             else:\n                 raise TypeError(\"Arguments not understood by `RectilinearGrid`.\")\n \n", "problem_statement": "Rectilinear grid does not allow Sequences as inputs\n### Describe the bug, what's wrong, and what you expected.\r\n\r\nRectilinear grid gives an error when `Sequence`s are passed in, but `ndarray` are ok.\r\n\r\n### Steps to reproduce the bug.\r\n\r\nThis doesn't work\r\n```python\r\nimport pyvista as pv\r\npv.RectilinearGrid([0, 1], [0, 1], [0, 1])\r\n```\r\n\r\nThis works\r\n```py\r\nimport pyvista as pv\r\nimport numpy as np\r\npv.RectilinearGrid(np.ndarray([0, 1]), np.ndarray([0, 1]), np.ndarray([0, 1]))\r\n```\r\n### System Information\r\n\r\n```shell\r\n--------------------------------------------------------------------------------\r\n  Date: Wed Apr 19 20:15:10 2023 UTC\r\n\r\n                OS : Linux\r\n            CPU(s) : 2\r\n           Machine : x86_64\r\n      Architecture : 64bit\r\n       Environment : IPython\r\n        GPU Vendor : Mesa/X.org\r\n      GPU Renderer : llvmpipe (LLVM 11.0.1, 256 bits)\r\n       GPU Version : 4.5 (Core Profile) Mesa 20.3.5\r\n\r\n  Python 3.11.2 (main, Mar 23 2023, 17:12:29) [GCC 10.2.1 20210110]\r\n\r\n           pyvista : 0.38.5\r\n               vtk : 9.2.6\r\n             numpy : 1.24.2\r\n           imageio : 2.27.0\r\n            scooby : 0.7.1\r\n             pooch : v1.7.0\r\n        matplotlib : 3.7.1\r\n           IPython : 8.12.0\r\n--------------------------------------------------------------------------------\r\n```\r\n\r\n\r\n### Screenshots\r\n\r\n_No response_\n", "repo": "pyvista/pyvista", "test_patch": "diff --git a/tests/test_grid.py b/tests/test_grid.py\n--- a/tests/test_grid.py\n+++ b/tests/test_grid.py\n@@ -735,6 +735,21 @@ def test_create_rectilinear_grid_from_specs():\n     assert grid.n_cells == 9 * 3 * 19\n     assert grid.n_points == 10 * 4 * 20\n     assert grid.bounds == (-10.0, 8.0, -10.0, 5.0, -10.0, 9.0)\n+\n+    # with Sequence\n+    xrng = [0, 1]\n+    yrng = [0, 1, 2]\n+    zrng = [0, 1, 2, 3]\n+    grid = pyvista.RectilinearGrid(xrng)\n+    assert grid.n_cells == 1\n+    assert grid.n_points == 2\n+    grid = pyvista.RectilinearGrid(xrng, yrng)\n+    assert grid.n_cells == 2\n+    assert grid.n_points == 6\n+    grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n+    assert grid.n_cells == 6\n+    assert grid.n_points == 24\n+\n     # 2D example\n     cell_spacings = np.array([1.0, 1.0, 2.0, 2.0, 5.0, 10.0])\n     x_coordinates = np.cumsum(cell_spacings)\n", "version": "0.39"}
parsed_commit_content: {"file_diffs":[{"old_file_content":"\"\"\"Sub-classes for vtk.vtkRectilinearGrid and vtk.vtkImageData.\"\"\"\nfrom functools import wraps\nimport pathlib\nfrom typing import Sequence, Tuple, Union\nimport warnings\n\nimport numpy as np\n\nimport pyvista\nfrom pyvista import _vtk\nfrom pyvista.core.dataset import DataSet\nfrom pyvista.core.filters import RectilinearGridFilters, UniformGridFilters, _get_output\nfrom pyvista.utilities import abstract_class, assert_empty_kwargs\nimport pyvista.utilities.helpers as helpers\nfrom pyvista.utilities.misc import PyVistaDeprecationWarning, raise_has_duplicates\n\n\n@abstract_class\nclass Grid(DataSet):\n    \"\"\"A class full of common methods for non-pointset grids.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"Initialize the grid.\"\"\"\n        super().__init__()\n\n    @property\n    def dimensions(self) -> Tuple[int, int, int]:\n        \"\"\"Return the grid's dimensions.\n\n        These are effectively the number of points along each of the\n        three dataset axes.\n\n        Examples\n        --------\n        Create a uniform grid with dimensions ``(1, 2, 3)``.\n\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 3, 4))\n        >>> grid.dimensions\n        (2, 3, 4)\n        >>> grid.plot(show_edges=True)\n\n        Set the dimensions to ``(3, 4, 5)``\n\n        >>> grid.dimensions = (3, 4, 5)\n        >>> grid.plot(show_edges=True)\n\n        \"\"\"\n        return self.GetDimensions()\n\n    @dimensions.setter\n    def dimensions(self, dims: Sequence[int]):\n        \"\"\"Set the dataset dimensions.\"\"\"\n        self.SetDimensions(*dims)\n        self.Modified()\n\n    def _get_attrs(self):\n        \"\"\"Return the representation methods (internal helper).\"\"\"\n        attrs = DataSet._get_attrs(self)\n        attrs.append((\"Dimensions\", self.dimensions, \"{:d}, {:d}, {:d}\"))\n        return attrs\n\n\nclass RectilinearGrid(_vtk.vtkRectilinearGrid, Grid, RectilinearGridFilters):\n    \"\"\"Dataset with variable spacing in the three coordinate directions.\n\n    Can be initialized in several ways:\n\n    * Create empty grid\n    * Initialize from a ``vtk.vtkRectilinearGrid`` object\n    * Initialize directly from the point arrays\n\n    Parameters\n    ----------\n    uinput : str, pathlib.Path, vtk.vtkRectilinearGrid, numpy.ndarray, optional\n        Filename, dataset, or array to initialize the rectilinear grid from. If a\n        filename is passed, pyvista will attempt to load it as a\n        :class:`RectilinearGrid`. If passed a ``vtk.vtkRectilinearGrid``, it\n        will be wrapped. If a :class:`numpy.ndarray` is passed, this will be\n        loaded as the x range.\n\n    y : numpy.ndarray, optional\n        Coordinates of the points in y direction. If this is passed, ``uinput``\n        must be a :class:`numpy.ndarray`.\n\n    z : numpy.ndarray, optional\n        Coordinates of the points in z direction. If this is passed, ``uinput``\n        and ``y`` must be a :class:`numpy.ndarray`.\n\n    check_duplicates : bool, optional\n        Check for duplications in any arrays that are passed. Defaults to\n        ``False``. If ``True``, an error is raised if there are any duplicate\n        values in any of the array-valued input arguments.\n\n    deep : bool, optional\n        Whether to deep copy a ``vtk.vtkRectilinearGrid`` object.\n        Default is ``False``.  Keyword only.\n\n    Examples\n    --------\n    >>> import pyvista\n    >>> import vtk\n    >>> import numpy as np\n\n    Create an empty grid.\n\n    >>> grid = pyvista.RectilinearGrid()\n\n    Initialize from a vtk.vtkRectilinearGrid object\n\n    >>> vtkgrid = vtk.vtkRectilinearGrid()\n    >>> grid = pyvista.RectilinearGrid(vtkgrid)\n\n    Create from NumPy arrays.\n\n    >>> xrng = np.arange(-10, 10, 2)\n    >>> yrng = np.arange(-10, 10, 5)\n    >>> zrng = np.arange(-10, 10, 1)\n    >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n    >>> grid.plot(show_edges=True)\n\n    \"\"\"\n\n    _WRITERS = {'.vtk': _vtk.vtkRectilinearGridWriter, '.vtr': _vtk.vtkXMLRectilinearGridWriter}\n\n    def __init__(self, *args, check_duplicates=False, deep=False, **kwargs):\n        \"\"\"Initialize the rectilinear grid.\"\"\"\n        super().__init__()\n\n        if len(args) == 1:\n            if isinstance(args[0], _vtk.vtkRectilinearGrid):\n                if deep:\n                    self.deep_copy(args[0])\n                else:\n                    self.shallow_copy(args[0])\n            elif isinstance(args[0], (str, pathlib.Path)):\n                self._from_file(args[0], **kwargs)\n            elif isinstance(args[0], np.ndarray):\n                self._from_arrays(args[0], None, None, check_duplicates)\n            else:\n                raise TypeError(f'Type ({type(args[0])}) not understood by `RectilinearGrid`')\n\n        elif len(args) == 3 or len(args) == 2:\n            arg0_is_arr = isinstance(args[0], np.ndarray)\n            arg1_is_arr = isinstance(args[1], np.ndarray)\n            if len(args) == 3:\n                arg2_is_arr = isinstance(args[2], np.ndarray)\n            else:\n                arg2_is_arr = False\n\n            if all([arg0_is_arr, arg1_is_arr, arg2_is_arr]):\n                self._from_arrays(args[0], args[1], args[2], check_duplicates)\n            elif all([arg0_is_arr, arg1_is_arr]):\n                self._from_arrays(args[0], args[1], None, check_duplicates)\n            else:\n                raise TypeError(\"Arguments not understood by `RectilinearGrid`.\")\n\n    def __repr__(self):\n        \"\"\"Return the default representation.\"\"\"\n        return DataSet.__repr__(self)\n\n    def __str__(self):\n        \"\"\"Return the str representation.\"\"\"\n        return DataSet.__str__(self)\n\n    def _update_dimensions(self):\n        \"\"\"Update the dimensions if coordinates have changed.\"\"\"\n        return self.SetDimensions(len(self.x), len(self.y), len(self.z))\n\n    def _from_arrays(\n        self, x: np.ndarray, y: np.ndarray, z: np.ndarray, check_duplicates: bool = False\n    ):\n        \"\"\"Create VTK rectilinear grid directly from numpy arrays.\n\n        Each array gives the uniques coordinates of the mesh along each axial\n        direction. To help ensure you are using this correctly, we take the unique\n        values of each argument.\n\n        Parameters\n        ----------\n        x : numpy.ndarray\n            Coordinates of the points in x direction.\n\n        y : numpy.ndarray\n            Coordinates of the points in y direction.\n\n        z : numpy.ndarray\n            Coordinates of the points in z direction.\n\n        check_duplicates : bool, optional\n            Check for duplications in any arrays that are passed.\n\n        \"\"\"\n        # Set the coordinates along each axial direction\n        # Must at least be an x array\n        if check_duplicates:\n            raise_has_duplicates(x)\n\n        # edges are shown as triangles if x is not floating point\n        if not np.issubdtype(x.dtype, np.floating):\n            x = x.astype(float)\n        self.SetXCoordinates(helpers.convert_array(x.ravel()))\n        if y is not None:\n            if check_duplicates:\n                raise_has_duplicates(y)\n            if not np.issubdtype(y.dtype, np.floating):\n                y = y.astype(float)\n            self.SetYCoordinates(helpers.convert_array(y.ravel()))\n        if z is not None:\n            if check_duplicates:\n                raise_has_duplicates(z)\n            if not np.issubdtype(z.dtype, np.floating):\n                z = z.astype(float)\n            self.SetZCoordinates(helpers.convert_array(z.ravel()))\n        # Ensure dimensions are properly set\n        self._update_dimensions()\n\n    @property\n    def meshgrid(self) -> list:\n        \"\"\"Return a meshgrid of numpy arrays for this mesh.\n\n        This simply returns a :func:`numpy.meshgrid` of the\n        coordinates for this mesh in ``ij`` indexing. These are a copy\n        of the points of this mesh.\n\n        \"\"\"\n        return np.meshgrid(self.x, self.y, self.z, indexing='ij')\n\n    @property  # type: ignore\n    def points(self) -> np.ndarray:  # type: ignore\n        \"\"\"Return a copy of the points as an n by 3 numpy array.\n\n        Notes\n        -----\n        Points of a :class:`pyvista.RectilinearGrid` cannot be\n        set. Set point coordinates with :attr:`RectilinearGrid.x`,\n        :attr:`RectilinearGrid.y`, or :attr:`RectilinearGrid.z`.\n\n        Examples\n        --------\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.points\n        array([[-10., -10., -10.],\n               [  0., -10., -10.],\n               [-10.,   0., -10.],\n               [  0.,   0., -10.],\n               [-10., -10.,   0.],\n               [  0., -10.,   0.],\n               [-10.,   0.,   0.],\n               [  0.,   0.,   0.]])\n\n        \"\"\"\n        xx, yy, zz = self.meshgrid\n        return np.c_[xx.ravel(order='F'), yy.ravel(order='F'), zz.ravel(order='F')]\n\n    @points.setter\n    def points(self, points):\n        \"\"\"Raise an AttributeError.\n\n        This setter overrides the base class's setter to ensure a user\n        does not attempt to set them.\n        \"\"\"\n        raise AttributeError(\n            \"The points cannot be set. The points of \"\n            \"`RectilinearGrid` are defined in each axial direction. Please \"\n            \"use the `x`, `y`, and `z` setters individually.\"\n        )\n\n    @property\n    def x(self) -> np.ndarray:\n        \"\"\"Return or set the coordinates along the X-direction.\n\n        Examples\n        --------\n        Return the x coordinates of a RectilinearGrid.\n\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.x\n        array([-10.,   0.])\n\n        Set the x coordinates of a RectilinearGrid.\n\n        >>> grid.x = [-10.0, 0.0, 10.0]\n        >>> grid.x\n        array([-10.,   0.,  10.])\n\n        \"\"\"\n        return helpers.convert_array(self.GetXCoordinates())\n\n    @x.setter\n    def x(self, coords: Sequence):\n        \"\"\"Set the coordinates along the X-direction.\"\"\"\n        self.SetXCoordinates(helpers.convert_array(coords))\n        self._update_dimensions()\n        self.Modified()\n\n    @property\n    def y(self) -> np.ndarray:\n        \"\"\"Return or set the coordinates along the Y-direction.\n\n        Examples\n        --------\n        Return the y coordinates of a RectilinearGrid.\n\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.y\n        array([-10.,   0.])\n\n        Set the y coordinates of a RectilinearGrid.\n\n        >>> grid.y = [-10.0, 0.0, 10.0]\n        >>> grid.y\n        array([-10.,   0.,  10.])\n\n        \"\"\"\n        return helpers.convert_array(self.GetYCoordinates())\n\n    @y.setter\n    def y(self, coords: Sequence):\n        \"\"\"Set the coordinates along the Y-direction.\"\"\"\n        self.SetYCoordinates(helpers.convert_array(coords))\n        self._update_dimensions()\n        self.Modified()\n\n    @property\n    def z(self) -> np.ndarray:\n        \"\"\"Return or set the coordinates along the Z-direction.\n\n        Examples\n        --------\n        Return the z coordinates of a RectilinearGrid.\n\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.z\n        array([-10.,   0.])\n\n        Set the z coordinates of a RectilinearGrid.\n\n        >>> grid.z = [-10.0, 0.0, 10.0]\n        >>> grid.z\n        array([-10.,   0.,  10.])\n\n        \"\"\"\n        return helpers.convert_array(self.GetZCoordinates())\n\n    @z.setter\n    def z(self, coords: Sequence):\n        \"\"\"Set the coordinates along the Z-direction.\"\"\"\n        self.SetZCoordinates(helpers.convert_array(coords))\n        self._update_dimensions()\n        self.Modified()\n\n    @Grid.dimensions.setter  # type: ignore\n    def dimensions(self, dims):\n        \"\"\"Do not let the dimensions of the RectilinearGrid be set.\"\"\"\n        raise AttributeError(\n            \"The dimensions of a `RectilinearGrid` are implicitly \"\n            \"defined and thus cannot be set.\"\n        )\n\n    def cast_to_structured_grid(self) -> 'pyvista.StructuredGrid':\n        \"\"\"Cast this rectilinear grid to a structured grid.\n\n        Returns\n        -------\n        pyvista.StructuredGrid\n            This grid as a structured grid.\n\n        \"\"\"\n        alg = _vtk.vtkRectilinearGridToPointSet()\n        alg.SetInputData(self)\n        alg.Update()\n        return _get_output(alg)\n\n\nclass UniformGrid(_vtk.vtkImageData, Grid, UniformGridFilters):\n    \"\"\"Models datasets with uniform spacing in the three coordinate directions.\n\n    Can be initialized in one of several ways:\n\n    - Create empty grid\n    - Initialize from a vtk.vtkImageData object\n    - Initialize based on dimensions, cell spacing, and origin.\n\n    .. versionchanged:: 0.33.0\n        First argument must now be either a path or\n        ``vtk.vtkImageData``. Use keyword arguments to specify the\n        dimensions, spacing, and origin of the uniform grid.\n\n    .. versionchanged:: 0.37.0\n        The ``dims`` parameter has been renamed to ``dimensions``.\n\n    Parameters\n    ----------\n    uinput : str, vtk.vtkImageData, pyvista.UniformGrid, optional\n        Filename or dataset to initialize the uniform grid from.  If\n        set, remainder of arguments are ignored.\n\n    dimensions : sequence[int], optional\n        Dimensions of the uniform grid.\n\n    spacing : sequence[float], default: (1.0, 1.0, 1.0)\n        Spacing of the uniform grid in each dimension. Must be positive.\n\n    origin : sequence[float], default: (0.0, 0.0, 0.0)\n        Origin of the uniform grid.\n\n    deep : bool, default: False\n        Whether to deep copy a ``vtk.vtkImageData`` object.  Keyword only.\n\n    Examples\n    --------\n    Create an empty UniformGrid.\n\n    >>> import pyvista\n    >>> grid = pyvista.UniformGrid()\n\n    Initialize from a ``vtk.vtkImageData`` object.\n\n    >>> import vtk\n    >>> vtkgrid = vtk.vtkImageData()\n    >>> grid = pyvista.UniformGrid(vtkgrid)\n\n    Initialize using just the grid dimensions and default\n    spacing and origin. These must be keyword arguments.\n\n    >>> grid = pyvista.UniformGrid(dimensions=(10, 10, 10))\n\n    Initialize using dimensions and spacing.\n\n    >>> grid = pyvista.UniformGrid(\n    ...     dimensions=(10, 10, 10),\n    ...     spacing=(2, 1, 5),\n    ... )\n\n    Initialize using dimensions, spacing, and an origin.\n\n    >>> grid = pyvista.UniformGrid(\n    ...     dimensions=(10, 10, 10),\n    ...     spacing=(2, 1, 5),\n    ...     origin=(10, 35, 50),\n    ... )\n\n    Initialize from another UniformGrid.\n\n    >>> grid = pyvista.UniformGrid(\n    ...     dimensions=(10, 10, 10),\n    ...     spacing=(2, 1, 5),\n    ...     origin=(10, 35, 50),\n    ... )\n    >>> grid_from_grid = pyvista.UniformGrid(grid)\n    >>> grid_from_grid == grid\n    True\n\n    \"\"\"\n\n    _WRITERS = {'.vtk': _vtk.vtkDataSetWriter, '.vti': _vtk.vtkXMLImageDataWriter}\n\n    def __init__(\n        self,\n        uinput=None,\n        *args,\n        dimensions=None,\n        spacing=(1.0, 1.0, 1.0),\n        origin=(0.0, 0.0, 0.0),\n        deep=False,\n        **kwargs,\n    ):\n        \"\"\"Initialize the uniform grid.\"\"\"\n        super().__init__()\n\n        # permit old behavior\n        if isinstance(uinput, Sequence) and not isinstance(uinput, str):\n            # Deprecated on v0.37.0, estimated removal on v0.40.0\n            warnings.warn(\n                \"Behavior of pyvista.UniformGrid has changed. First argument must be \"\n                \"either a ``vtk.vtkImageData`` or path.\",\n                PyVistaDeprecationWarning,\n            )\n            dimensions = uinput\n            uinput = None\n\n        if dimensions is None and 'dims' in kwargs:\n            dimensions = kwargs.pop('dims')\n            # Deprecated on v0.37.0, estimated removal on v0.40.0\n            warnings.warn(\n                '`dims` argument is deprecated. Please use `dimensions`.', PyVistaDeprecationWarning\n            )\n        assert_empty_kwargs(**kwargs)\n\n        if args:\n            # Deprecated on v0.37.0, estimated removal on v0.40.0\n            warnings.warn(\n                \"Behavior of pyvista.UniformGrid has changed. Use keyword arguments \"\n                \"to specify dimensions, spacing, and origin. For example:\\n\\n\"\n                \"    >>> grid = pyvista.UniformGrid(\\n\"\n                \"    ...     dimensions=(10, 10, 10),\\n\"\n                \"    ...     spacing=(2, 1, 5),\\n\"\n                \"    ...     origin=(10, 35, 50),\\n\"\n                \"    ... )\\n\",\n                PyVistaDeprecationWarning,\n            )\n            origin = args[0]\n            if len(args) > 1:\n                spacing = args[1]\n            if len(args) > 2:\n                raise ValueError(\n                    \"Too many additional arguments specified for UniformGrid. \"\n                    f\"Accepts at most 2, and {len(args)} have been input.\"\n                )\n\n        # first argument must be either vtkImageData or a path\n        if uinput is not None:\n            if isinstance(uinput, _vtk.vtkImageData):\n                if deep:\n                    self.deep_copy(uinput)\n                else:\n                    self.shallow_copy(uinput)\n            elif isinstance(uinput, (str, pathlib.Path)):\n                self._from_file(uinput)\n            else:\n                raise TypeError(\n                    \"First argument, ``uinput`` must be either ``vtk.vtkImageData`` \"\n                    f\"or a path, not {type(uinput)}.  Use keyword arguments to \"\n                    \"specify dimensions, spacing, and origin. For example:\\n\\n\"\n                    \"    >>> grid = pyvista.UniformGrid(\\n\"\n                    \"    ...     dimensions=(10, 10, 10),\\n\"\n                    \"    ...     spacing=(2, 1, 5),\\n\"\n                    \"    ...     origin=(10, 35, 50),\\n\"\n                    \"    ... )\\n\"\n                )\n        elif dimensions is not None:\n            self._from_specs(dimensions, spacing, origin)\n\n    def __repr__(self):\n        \"\"\"Return the default representation.\"\"\"\n        return DataSet.__repr__(self)\n\n    def __str__(self):\n        \"\"\"Return the default str representation.\"\"\"\n        return DataSet.__str__(self)\n\n    def _from_specs(self, dims: Sequence[int], spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0)):\n        \"\"\"Create VTK image data directly from numpy arrays.\n\n        A uniform grid is defined by the point spacings for each axis\n        (uniform along each individual axis) and the number of points on each axis.\n        These are relative to a specified origin (default is ``(0.0, 0.0, 0.0)``).\n\n        Parameters\n        ----------\n        dims : tuple(int)\n            Length 3 tuple of ints specifying how many points along each axis.\n\n        spacing : sequence[float], default: (1.0, 1.0, 1.0)\n            Length 3 tuple of floats/ints specifying the point spacings\n            for each axis. Must be positive.\n\n        origin : sequence[float], default: (0.0, 0.0, 0.0)\n            Length 3 tuple of floats/ints specifying minimum value for each axis.\n\n        \"\"\"\n        xn, yn, zn = dims[0], dims[1], dims[2]\n        xo, yo, zo = origin[0], origin[1], origin[2]\n        self.SetDimensions(xn, yn, zn)\n        self.SetOrigin(xo, yo, zo)\n        self.spacing = (spacing[0], spacing[1], spacing[2])\n\n    @property  # type: ignore\n    def points(self) -> np.ndarray:  # type: ignore\n        \"\"\"Build a copy of the implicitly defined points as a numpy array.\n\n        Notes\n        -----\n        The ``points`` for a :class:`pyvista.UniformGrid` cannot be set.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.points\n        array([[0., 0., 0.],\n               [1., 0., 0.],\n               [0., 1., 0.],\n               [1., 1., 0.],\n               [0., 0., 1.],\n               [1., 0., 1.],\n               [0., 1., 1.],\n               [1., 1., 1.]])\n\n        \"\"\"\n        # Get grid dimensions\n        nx, ny, nz = self.dimensions\n        nx -= 1\n        ny -= 1\n        nz -= 1\n        # get the points and convert to spacings\n        dx, dy, dz = self.spacing\n        # Now make the cell arrays\n        ox, oy, oz = np.array(self.origin) + np.array(self.extent[::2])  # type: ignore\n        x = np.insert(np.cumsum(np.full(nx, dx)), 0, 0.0) + ox\n        y = np.insert(np.cumsum(np.full(ny, dy)), 0, 0.0) + oy\n        z = np.insert(np.cumsum(np.full(nz, dz)), 0, 0.0) + oz\n        xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')\n        return np.c_[xx.ravel(order='F'), yy.ravel(order='F'), zz.ravel(order='F')]\n\n    @points.setter\n    def points(self, points):\n        \"\"\"Points cannot be set.\n\n        This setter overrides the base class's setter to ensure a user does not\n        attempt to set them. See https://github.com/pyvista/pyvista/issues/713.\n\n        \"\"\"\n        raise AttributeError(\n            \"The points cannot be set. The points of \"\n            \"`UniformGrid`/`vtkImageData` are implicitly defined by the \"\n            \"`origin`, `spacing`, and `dimensions` of the grid.\"\n        )\n\n    @property\n    def x(self) -> np.ndarray:\n        \"\"\"Return all the X points.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.x\n        array([0., 1., 0., 1., 0., 1., 0., 1.])\n\n        \"\"\"\n        return self.points[:, 0]\n\n    @property\n    def y(self) -> np.ndarray:\n        \"\"\"Return all the Y points.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.y\n        array([0., 0., 1., 1., 0., 0., 1., 1.])\n\n        \"\"\"\n        return self.points[:, 1]\n\n    @property\n    def z(self) -> np.ndarray:\n        \"\"\"Return all the Z points.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.z\n        array([0., 0., 0., 0., 1., 1., 1., 1.])\n\n        \"\"\"\n        return self.points[:, 2]\n\n    @property\n    def origin(self) -> Tuple[float]:\n        \"\"\"Return the origin of the grid (bottom southwest corner).\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(5, 5, 5))\n        >>> grid.origin\n        (0.0, 0.0, 0.0)\n\n        Show how the origin is in the bottom \"southwest\" corner of the\n        UniformGrid.\n\n        >>> pl = pyvista.Plotter()\n        >>> _ = pl.add_mesh(grid, show_edges=True)\n        >>> _ = pl.add_axes_at_origin(ylabel=None)\n        >>> pl.camera_position = 'xz'\n        >>> pl.show()\n\n        Set the origin to ``(1, 1, 1)`` and show how this shifts the\n        UniformGrid.\n\n        >>> grid.origin = (1, 1, 1)\n        >>> pl = pyvista.Plotter()\n        >>> _ = pl.add_mesh(grid, show_edges=True)\n        >>> _ = pl.add_axes_at_origin(ylabel=None)\n        >>> pl.camera_position = 'xz'\n        >>> pl.show()\n\n        \"\"\"\n        return self.GetOrigin()\n\n    @origin.setter\n    def origin(self, origin: Sequence[Union[float, int]]):\n        \"\"\"Set the origin.\"\"\"\n        self.SetOrigin(origin[0], origin[1], origin[2])\n        self.Modified()\n\n    @property\n    def spacing(self) -> Tuple[float, float, float]:\n        \"\"\"Return or set the spacing for each axial direction.\n\n        Notes\n        -----\n        Spacing must be non-negative. While VTK accepts negative\n        spacing, this results in unexpected behavior. See:\n        https://github.com/pyvista/pyvista/issues/1967\n\n        Examples\n        --------\n        Create a 5 x 5 x 5 uniform grid.\n\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(5, 5, 5))\n        >>> grid.spacing\n        (1.0, 1.0, 1.0)\n        >>> grid.plot(show_edges=True)\n\n        Modify the spacing to ``(1, 2, 3)``\n\n        >>> grid.spacing = (1, 2, 3)\n        >>> grid.plot(show_edges=True)\n\n        \"\"\"\n        return self.GetSpacing()\n\n    @spacing.setter\n    def spacing(self, spacing: Sequence[Union[float, int]]):\n        \"\"\"Set spacing.\"\"\"\n        if min(spacing) < 0:\n            raise ValueError(f\"Spacing must be non-negative, got {spacing}\")\n        self.SetSpacing(*spacing)\n        self.Modified()\n\n    def _get_attrs(self):\n        \"\"\"Return the representation methods (internal helper).\"\"\"\n        attrs = Grid._get_attrs(self)\n        fmt = \"{}, {}, {}\".format(*[pyvista.FLOAT_FORMAT] * 3)\n        attrs.append((\"Spacing\", self.spacing, fmt))\n        return attrs\n\n    def cast_to_structured_grid(self) -> 'pyvista.StructuredGrid':\n        \"\"\"Cast this uniform grid to a structured grid.\n\n        Returns\n        -------\n        pyvista.StructuredGrid\n            This grid as a structured grid.\n\n        \"\"\"\n        alg = _vtk.vtkImageToStructuredGrid()\n        alg.SetInputData(self)\n        alg.Update()\n        return _get_output(alg)\n\n    def cast_to_rectilinear_grid(self) -> 'RectilinearGrid':\n        \"\"\"Cast this uniform grid to a rectilinear grid.\n\n        Returns\n        -------\n        pyvista.RectilinearGrid\n            This uniform grid as a rectilinear grid.\n\n        \"\"\"\n\n        def gen_coords(i):\n            coords = (\n                np.cumsum(np.insert(np.full(self.dimensions[i] - 1, self.spacing[i]), 0, 0))\n                + self.origin[i]\n            )\n            return coords\n\n        xcoords = gen_coords(0)\n        ycoords = gen_coords(1)\n        zcoords = gen_coords(2)\n        grid = pyvista.RectilinearGrid(xcoords, ycoords, zcoords)\n        grid.point_data.update(self.point_data)\n        grid.cell_data.update(self.cell_data)\n        grid.field_data.update(self.field_data)\n        grid.copy_meta_from(self, deep=True)\n        return grid\n\n    @property\n    def extent(self) -> tuple:\n        \"\"\"Return or set the extent of the UniformGrid.\n\n        The extent is simply the first and last indices for each of the three axes.\n\n        Examples\n        --------\n        Create a ``UniformGrid`` and show its extent.\n\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(10, 10, 10))\n        >>> grid.extent\n        (0, 9, 0, 9, 0, 9)\n\n        >>> grid.extent = (2, 5, 2, 5, 2, 5)\n        >>> grid.extent\n        (2, 5, 2, 5, 2, 5)\n\n        Note how this also modifies the grid bounds and dimensions. Since we\n        use default spacing of 1 here, the bounds match the extent exactly.\n\n        >>> grid.bounds\n        (2.0, 5.0, 2.0, 5.0, 2.0, 5.0)\n        >>> grid.dimensions\n        (4, 4, 4)\n\n        \"\"\"\n        return self.GetExtent()\n\n    @extent.setter\n    def extent(self, new_extent: Sequence[int]):\n        \"\"\"Set the extent of the UniformGrid.\"\"\"\n        if len(new_extent) != 6:\n            raise ValueError('Extent must be a vector of 6 values.')\n        self.SetExtent(new_extent)\n\n    @wraps(RectilinearGridFilters.to_tetrahedra)\n    def to_tetrahedra(self, *args, **kwargs):\n        \"\"\"Cast to a rectangular grid and then convert to tetrahedra.\"\"\"\n        return self.cast_to_rectilinear_grid().to_tetrahedra(*args, **kwargs)\n","new_file_content":"\"\"\"Sub-classes for vtk.vtkRectilinearGrid and vtk.vtkImageData.\"\"\"\nfrom functools import wraps\nimport pathlib\nfrom typing import Sequence, Tuple, Union\nimport warnings\n\nimport numpy as np\n\nimport pyvista\nfrom pyvista import _vtk\nfrom pyvista.core.dataset import DataSet\nfrom pyvista.core.filters import RectilinearGridFilters, UniformGridFilters, _get_output\nfrom pyvista.utilities import abstract_class, assert_empty_kwargs\nimport pyvista.utilities.helpers as helpers\nfrom pyvista.utilities.misc import PyVistaDeprecationWarning, raise_has_duplicates\n\n\n@abstract_class\nclass Grid(DataSet):\n    \"\"\"A class full of common methods for non-pointset grids.\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        \"\"\"Initialize the grid.\"\"\"\n        super().__init__()\n\n    @property\n    def dimensions(self) -> Tuple[int, int, int]:\n        \"\"\"Return the grid's dimensions.\n\n        These are effectively the number of points along each of the\n        three dataset axes.\n\n        Examples\n        --------\n        Create a uniform grid with dimensions ``(1, 2, 3)``.\n\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 3, 4))\n        >>> grid.dimensions\n        (2, 3, 4)\n        >>> grid.plot(show_edges=True)\n\n        Set the dimensions to ``(3, 4, 5)``\n\n        >>> grid.dimensions = (3, 4, 5)\n        >>> grid.plot(show_edges=True)\n\n        \"\"\"\n        return self.GetDimensions()\n\n    @dimensions.setter\n    def dimensions(self, dims: Sequence[int]):\n        \"\"\"Set the dataset dimensions.\"\"\"\n        self.SetDimensions(*dims)\n        self.Modified()\n\n    def _get_attrs(self):\n        \"\"\"Return the representation methods (internal helper).\"\"\"\n        attrs = DataSet._get_attrs(self)\n        attrs.append((\"Dimensions\", self.dimensions, \"{:d}, {:d}, {:d}\"))\n        return attrs\n\n\nclass RectilinearGrid(_vtk.vtkRectilinearGrid, Grid, RectilinearGridFilters):\n    \"\"\"Dataset with variable spacing in the three coordinate directions.\n\n    Can be initialized in several ways:\n\n    * Create empty grid\n    * Initialize from a ``vtk.vtkRectilinearGrid`` object\n    * Initialize directly from the point arrays\n\n    Parameters\n    ----------\n    uinput : str, pathlib.Path, vtk.vtkRectilinearGrid, numpy.ndarray, optional\n        Filename, dataset, or array to initialize the rectilinear grid from. If a\n        filename is passed, pyvista will attempt to load it as a\n        :class:`RectilinearGrid`. If passed a ``vtk.vtkRectilinearGrid``, it\n        will be wrapped. If a :class:`numpy.ndarray` is passed, this will be\n        loaded as the x range.\n\n    y : numpy.ndarray, optional\n        Coordinates of the points in y direction. If this is passed, ``uinput``\n        must be a :class:`numpy.ndarray`.\n\n    z : numpy.ndarray, optional\n        Coordinates of the points in z direction. If this is passed, ``uinput``\n        and ``y`` must be a :class:`numpy.ndarray`.\n\n    check_duplicates : bool, optional\n        Check for duplications in any arrays that are passed. Defaults to\n        ``False``. If ``True``, an error is raised if there are any duplicate\n        values in any of the array-valued input arguments.\n\n    deep : bool, optional\n        Whether to deep copy a ``vtk.vtkRectilinearGrid`` object.\n        Default is ``False``.  Keyword only.\n\n    Examples\n    --------\n    >>> import pyvista\n    >>> import vtk\n    >>> import numpy as np\n\n    Create an empty grid.\n\n    >>> grid = pyvista.RectilinearGrid()\n\n    Initialize from a vtk.vtkRectilinearGrid object\n\n    >>> vtkgrid = vtk.vtkRectilinearGrid()\n    >>> grid = pyvista.RectilinearGrid(vtkgrid)\n\n    Create from NumPy arrays.\n\n    >>> xrng = np.arange(-10, 10, 2)\n    >>> yrng = np.arange(-10, 10, 5)\n    >>> zrng = np.arange(-10, 10, 1)\n    >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n    >>> grid.plot(show_edges=True)\n\n    \"\"\"\n\n    _WRITERS = {'.vtk': _vtk.vtkRectilinearGridWriter, '.vtr': _vtk.vtkXMLRectilinearGridWriter}\n\n    def __init__(self, *args, check_duplicates=False, deep=False, **kwargs):\n        \"\"\"Initialize the rectilinear grid.\"\"\"\n        super().__init__()\n\n        if len(args) == 1:\n            if isinstance(args[0], _vtk.vtkRectilinearGrid):\n                if deep:\n                    self.deep_copy(args[0])\n                else:\n                    self.shallow_copy(args[0])\n            elif isinstance(args[0], (str, pathlib.Path)):\n                self._from_file(args[0], **kwargs)\n            elif isinstance(args[0], (np.ndarray, Sequence)):\n                self._from_arrays(np.asanyarray(args[0]), None, None, check_duplicates)\n            else:\n                raise TypeError(f'Type ({type(args[0])}) not understood by `RectilinearGrid`')\n\n        elif len(args) == 3 or len(args) == 2:\n            arg0_is_arr = isinstance(args[0], (np.ndarray, Sequence))\n            arg1_is_arr = isinstance(args[1], (np.ndarray, Sequence))\n            if len(args) == 3:\n                arg2_is_arr = isinstance(args[2], (np.ndarray, Sequence))\n            else:\n                arg2_is_arr = False\n\n            if all([arg0_is_arr, arg1_is_arr, arg2_is_arr]):\n                self._from_arrays(\n                    np.asanyarray(args[0]),\n                    np.asanyarray(args[1]),\n                    np.asanyarray(args[2]),\n                    check_duplicates,\n                )\n            elif all([arg0_is_arr, arg1_is_arr]):\n                self._from_arrays(\n                    np.asanyarray(args[0]), np.asanyarray(args[1]), None, check_duplicates\n                )\n            else:\n                raise TypeError(\"Arguments not understood by `RectilinearGrid`.\")\n\n    def __repr__(self):\n        \"\"\"Return the default representation.\"\"\"\n        return DataSet.__repr__(self)\n\n    def __str__(self):\n        \"\"\"Return the str representation.\"\"\"\n        return DataSet.__str__(self)\n\n    def _update_dimensions(self):\n        \"\"\"Update the dimensions if coordinates have changed.\"\"\"\n        return self.SetDimensions(len(self.x), len(self.y), len(self.z))\n\n    def _from_arrays(\n        self, x: np.ndarray, y: np.ndarray, z: np.ndarray, check_duplicates: bool = False\n    ):\n        \"\"\"Create VTK rectilinear grid directly from numpy arrays.\n\n        Each array gives the uniques coordinates of the mesh along each axial\n        direction. To help ensure you are using this correctly, we take the unique\n        values of each argument.\n\n        Parameters\n        ----------\n        x : numpy.ndarray\n            Coordinates of the points in x direction.\n\n        y : numpy.ndarray\n            Coordinates of the points in y direction.\n\n        z : numpy.ndarray\n            Coordinates of the points in z direction.\n\n        check_duplicates : bool, optional\n            Check for duplications in any arrays that are passed.\n\n        \"\"\"\n        # Set the coordinates along each axial direction\n        # Must at least be an x array\n        if check_duplicates:\n            raise_has_duplicates(x)\n\n        # edges are shown as triangles if x is not floating point\n        if not np.issubdtype(x.dtype, np.floating):\n            x = x.astype(float)\n        self.SetXCoordinates(helpers.convert_array(x.ravel()))\n        if y is not None:\n            if check_duplicates:\n                raise_has_duplicates(y)\n            if not np.issubdtype(y.dtype, np.floating):\n                y = y.astype(float)\n            self.SetYCoordinates(helpers.convert_array(y.ravel()))\n        if z is not None:\n            if check_duplicates:\n                raise_has_duplicates(z)\n            if not np.issubdtype(z.dtype, np.floating):\n                z = z.astype(float)\n            self.SetZCoordinates(helpers.convert_array(z.ravel()))\n        # Ensure dimensions are properly set\n        self._update_dimensions()\n\n    @property\n    def meshgrid(self) -> list:\n        \"\"\"Return a meshgrid of numpy arrays for this mesh.\n\n        This simply returns a :func:`numpy.meshgrid` of the\n        coordinates for this mesh in ``ij`` indexing. These are a copy\n        of the points of this mesh.\n\n        \"\"\"\n        return np.meshgrid(self.x, self.y, self.z, indexing='ij')\n\n    @property  # type: ignore\n    def points(self) -> np.ndarray:  # type: ignore\n        \"\"\"Return a copy of the points as an n by 3 numpy array.\n\n        Notes\n        -----\n        Points of a :class:`pyvista.RectilinearGrid` cannot be\n        set. Set point coordinates with :attr:`RectilinearGrid.x`,\n        :attr:`RectilinearGrid.y`, or :attr:`RectilinearGrid.z`.\n\n        Examples\n        --------\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.points\n        array([[-10., -10., -10.],\n               [  0., -10., -10.],\n               [-10.,   0., -10.],\n               [  0.,   0., -10.],\n               [-10., -10.,   0.],\n               [  0., -10.,   0.],\n               [-10.,   0.,   0.],\n               [  0.,   0.,   0.]])\n\n        \"\"\"\n        xx, yy, zz = self.meshgrid\n        return np.c_[xx.ravel(order='F'), yy.ravel(order='F'), zz.ravel(order='F')]\n\n    @points.setter\n    def points(self, points):\n        \"\"\"Raise an AttributeError.\n\n        This setter overrides the base class's setter to ensure a user\n        does not attempt to set them.\n        \"\"\"\n        raise AttributeError(\n            \"The points cannot be set. The points of \"\n            \"`RectilinearGrid` are defined in each axial direction. Please \"\n            \"use the `x`, `y`, and `z` setters individually.\"\n        )\n\n    @property\n    def x(self) -> np.ndarray:\n        \"\"\"Return or set the coordinates along the X-direction.\n\n        Examples\n        --------\n        Return the x coordinates of a RectilinearGrid.\n\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.x\n        array([-10.,   0.])\n\n        Set the x coordinates of a RectilinearGrid.\n\n        >>> grid.x = [-10.0, 0.0, 10.0]\n        >>> grid.x\n        array([-10.,   0.,  10.])\n\n        \"\"\"\n        return helpers.convert_array(self.GetXCoordinates())\n\n    @x.setter\n    def x(self, coords: Sequence):\n        \"\"\"Set the coordinates along the X-direction.\"\"\"\n        self.SetXCoordinates(helpers.convert_array(coords))\n        self._update_dimensions()\n        self.Modified()\n\n    @property\n    def y(self) -> np.ndarray:\n        \"\"\"Return or set the coordinates along the Y-direction.\n\n        Examples\n        --------\n        Return the y coordinates of a RectilinearGrid.\n\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.y\n        array([-10.,   0.])\n\n        Set the y coordinates of a RectilinearGrid.\n\n        >>> grid.y = [-10.0, 0.0, 10.0]\n        >>> grid.y\n        array([-10.,   0.,  10.])\n\n        \"\"\"\n        return helpers.convert_array(self.GetYCoordinates())\n\n    @y.setter\n    def y(self, coords: Sequence):\n        \"\"\"Set the coordinates along the Y-direction.\"\"\"\n        self.SetYCoordinates(helpers.convert_array(coords))\n        self._update_dimensions()\n        self.Modified()\n\n    @property\n    def z(self) -> np.ndarray:\n        \"\"\"Return or set the coordinates along the Z-direction.\n\n        Examples\n        --------\n        Return the z coordinates of a RectilinearGrid.\n\n        >>> import numpy as np\n        >>> import pyvista\n        >>> xrng = np.arange(-10, 10, 10, dtype=float)\n        >>> yrng = np.arange(-10, 10, 10, dtype=float)\n        >>> zrng = np.arange(-10, 10, 10, dtype=float)\n        >>> grid = pyvista.RectilinearGrid(xrng, yrng, zrng)\n        >>> grid.z\n        array([-10.,   0.])\n\n        Set the z coordinates of a RectilinearGrid.\n\n        >>> grid.z = [-10.0, 0.0, 10.0]\n        >>> grid.z\n        array([-10.,   0.,  10.])\n\n        \"\"\"\n        return helpers.convert_array(self.GetZCoordinates())\n\n    @z.setter\n    def z(self, coords: Sequence):\n        \"\"\"Set the coordinates along the Z-direction.\"\"\"\n        self.SetZCoordinates(helpers.convert_array(coords))\n        self._update_dimensions()\n        self.Modified()\n\n    @Grid.dimensions.setter  # type: ignore\n    def dimensions(self, dims):\n        \"\"\"Do not let the dimensions of the RectilinearGrid be set.\"\"\"\n        raise AttributeError(\n            \"The dimensions of a `RectilinearGrid` are implicitly \"\n            \"defined and thus cannot be set.\"\n        )\n\n    def cast_to_structured_grid(self) -> 'pyvista.StructuredGrid':\n        \"\"\"Cast this rectilinear grid to a structured grid.\n\n        Returns\n        -------\n        pyvista.StructuredGrid\n            This grid as a structured grid.\n\n        \"\"\"\n        alg = _vtk.vtkRectilinearGridToPointSet()\n        alg.SetInputData(self)\n        alg.Update()\n        return _get_output(alg)\n\n\nclass UniformGrid(_vtk.vtkImageData, Grid, UniformGridFilters):\n    \"\"\"Models datasets with uniform spacing in the three coordinate directions.\n\n    Can be initialized in one of several ways:\n\n    - Create empty grid\n    - Initialize from a vtk.vtkImageData object\n    - Initialize based on dimensions, cell spacing, and origin.\n\n    .. versionchanged:: 0.33.0\n        First argument must now be either a path or\n        ``vtk.vtkImageData``. Use keyword arguments to specify the\n        dimensions, spacing, and origin of the uniform grid.\n\n    .. versionchanged:: 0.37.0\n        The ``dims`` parameter has been renamed to ``dimensions``.\n\n    Parameters\n    ----------\n    uinput : str, vtk.vtkImageData, pyvista.UniformGrid, optional\n        Filename or dataset to initialize the uniform grid from.  If\n        set, remainder of arguments are ignored.\n\n    dimensions : sequence[int], optional\n        Dimensions of the uniform grid.\n\n    spacing : sequence[float], default: (1.0, 1.0, 1.0)\n        Spacing of the uniform grid in each dimension. Must be positive.\n\n    origin : sequence[float], default: (0.0, 0.0, 0.0)\n        Origin of the uniform grid.\n\n    deep : bool, default: False\n        Whether to deep copy a ``vtk.vtkImageData`` object.  Keyword only.\n\n    Examples\n    --------\n    Create an empty UniformGrid.\n\n    >>> import pyvista\n    >>> grid = pyvista.UniformGrid()\n\n    Initialize from a ``vtk.vtkImageData`` object.\n\n    >>> import vtk\n    >>> vtkgrid = vtk.vtkImageData()\n    >>> grid = pyvista.UniformGrid(vtkgrid)\n\n    Initialize using just the grid dimensions and default\n    spacing and origin. These must be keyword arguments.\n\n    >>> grid = pyvista.UniformGrid(dimensions=(10, 10, 10))\n\n    Initialize using dimensions and spacing.\n\n    >>> grid = pyvista.UniformGrid(\n    ...     dimensions=(10, 10, 10),\n    ...     spacing=(2, 1, 5),\n    ... )\n\n    Initialize using dimensions, spacing, and an origin.\n\n    >>> grid = pyvista.UniformGrid(\n    ...     dimensions=(10, 10, 10),\n    ...     spacing=(2, 1, 5),\n    ...     origin=(10, 35, 50),\n    ... )\n\n    Initialize from another UniformGrid.\n\n    >>> grid = pyvista.UniformGrid(\n    ...     dimensions=(10, 10, 10),\n    ...     spacing=(2, 1, 5),\n    ...     origin=(10, 35, 50),\n    ... )\n    >>> grid_from_grid = pyvista.UniformGrid(grid)\n    >>> grid_from_grid == grid\n    True\n\n    \"\"\"\n\n    _WRITERS = {'.vtk': _vtk.vtkDataSetWriter, '.vti': _vtk.vtkXMLImageDataWriter}\n\n    def __init__(\n        self,\n        uinput=None,\n        *args,\n        dimensions=None,\n        spacing=(1.0, 1.0, 1.0),\n        origin=(0.0, 0.0, 0.0),\n        deep=False,\n        **kwargs,\n    ):\n        \"\"\"Initialize the uniform grid.\"\"\"\n        super().__init__()\n\n        # permit old behavior\n        if isinstance(uinput, Sequence) and not isinstance(uinput, str):\n            # Deprecated on v0.37.0, estimated removal on v0.40.0\n            warnings.warn(\n                \"Behavior of pyvista.UniformGrid has changed. First argument must be \"\n                \"either a ``vtk.vtkImageData`` or path.\",\n                PyVistaDeprecationWarning,\n            )\n            dimensions = uinput\n            uinput = None\n\n        if dimensions is None and 'dims' in kwargs:\n            dimensions = kwargs.pop('dims')\n            # Deprecated on v0.37.0, estimated removal on v0.40.0\n            warnings.warn(\n                '`dims` argument is deprecated. Please use `dimensions`.', PyVistaDeprecationWarning\n            )\n        assert_empty_kwargs(**kwargs)\n\n        if args:\n            # Deprecated on v0.37.0, estimated removal on v0.40.0\n            warnings.warn(\n                \"Behavior of pyvista.UniformGrid has changed. Use keyword arguments \"\n                \"to specify dimensions, spacing, and origin. For example:\\n\\n\"\n                \"    >>> grid = pyvista.UniformGrid(\\n\"\n                \"    ...     dimensions=(10, 10, 10),\\n\"\n                \"    ...     spacing=(2, 1, 5),\\n\"\n                \"    ...     origin=(10, 35, 50),\\n\"\n                \"    ... )\\n\",\n                PyVistaDeprecationWarning,\n            )\n            origin = args[0]\n            if len(args) > 1:\n                spacing = args[1]\n            if len(args) > 2:\n                raise ValueError(\n                    \"Too many additional arguments specified for UniformGrid. \"\n                    f\"Accepts at most 2, and {len(args)} have been input.\"\n                )\n\n        # first argument must be either vtkImageData or a path\n        if uinput is not None:\n            if isinstance(uinput, _vtk.vtkImageData):\n                if deep:\n                    self.deep_copy(uinput)\n                else:\n                    self.shallow_copy(uinput)\n            elif isinstance(uinput, (str, pathlib.Path)):\n                self._from_file(uinput)\n            else:\n                raise TypeError(\n                    \"First argument, ``uinput`` must be either ``vtk.vtkImageData`` \"\n                    f\"or a path, not {type(uinput)}.  Use keyword arguments to \"\n                    \"specify dimensions, spacing, and origin. For example:\\n\\n\"\n                    \"    >>> grid = pyvista.UniformGrid(\\n\"\n                    \"    ...     dimensions=(10, 10, 10),\\n\"\n                    \"    ...     spacing=(2, 1, 5),\\n\"\n                    \"    ...     origin=(10, 35, 50),\\n\"\n                    \"    ... )\\n\"\n                )\n        elif dimensions is not None:\n            self._from_specs(dimensions, spacing, origin)\n\n    def __repr__(self):\n        \"\"\"Return the default representation.\"\"\"\n        return DataSet.__repr__(self)\n\n    def __str__(self):\n        \"\"\"Return the default str representation.\"\"\"\n        return DataSet.__str__(self)\n\n    def _from_specs(self, dims: Sequence[int], spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0)):\n        \"\"\"Create VTK image data directly from numpy arrays.\n\n        A uniform grid is defined by the point spacings for each axis\n        (uniform along each individual axis) and the number of points on each axis.\n        These are relative to a specified origin (default is ``(0.0, 0.0, 0.0)``).\n\n        Parameters\n        ----------\n        dims : tuple(int)\n            Length 3 tuple of ints specifying how many points along each axis.\n\n        spacing : sequence[float], default: (1.0, 1.0, 1.0)\n            Length 3 tuple of floats/ints specifying the point spacings\n            for each axis. Must be positive.\n\n        origin : sequence[float], default: (0.0, 0.0, 0.0)\n            Length 3 tuple of floats/ints specifying minimum value for each axis.\n\n        \"\"\"\n        xn, yn, zn = dims[0], dims[1], dims[2]\n        xo, yo, zo = origin[0], origin[1], origin[2]\n        self.SetDimensions(xn, yn, zn)\n        self.SetOrigin(xo, yo, zo)\n        self.spacing = (spacing[0], spacing[1], spacing[2])\n\n    @property  # type: ignore\n    def points(self) -> np.ndarray:  # type: ignore\n        \"\"\"Build a copy of the implicitly defined points as a numpy array.\n\n        Notes\n        -----\n        The ``points`` for a :class:`pyvista.UniformGrid` cannot be set.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.points\n        array([[0., 0., 0.],\n               [1., 0., 0.],\n               [0., 1., 0.],\n               [1., 1., 0.],\n               [0., 0., 1.],\n               [1., 0., 1.],\n               [0., 1., 1.],\n               [1., 1., 1.]])\n\n        \"\"\"\n        # Get grid dimensions\n        nx, ny, nz = self.dimensions\n        nx -= 1\n        ny -= 1\n        nz -= 1\n        # get the points and convert to spacings\n        dx, dy, dz = self.spacing\n        # Now make the cell arrays\n        ox, oy, oz = np.array(self.origin) + np.array(self.extent[::2])  # type: ignore\n        x = np.insert(np.cumsum(np.full(nx, dx)), 0, 0.0) + ox\n        y = np.insert(np.cumsum(np.full(ny, dy)), 0, 0.0) + oy\n        z = np.insert(np.cumsum(np.full(nz, dz)), 0, 0.0) + oz\n        xx, yy, zz = np.meshgrid(x, y, z, indexing='ij')\n        return np.c_[xx.ravel(order='F'), yy.ravel(order='F'), zz.ravel(order='F')]\n\n    @points.setter\n    def points(self, points):\n        \"\"\"Points cannot be set.\n\n        This setter overrides the base class's setter to ensure a user does not\n        attempt to set them. See https://github.com/pyvista/pyvista/issues/713.\n\n        \"\"\"\n        raise AttributeError(\n            \"The points cannot be set. The points of \"\n            \"`UniformGrid`/`vtkImageData` are implicitly defined by the \"\n            \"`origin`, `spacing`, and `dimensions` of the grid.\"\n        )\n\n    @property\n    def x(self) -> np.ndarray:\n        \"\"\"Return all the X points.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.x\n        array([0., 1., 0., 1., 0., 1., 0., 1.])\n\n        \"\"\"\n        return self.points[:, 0]\n\n    @property\n    def y(self) -> np.ndarray:\n        \"\"\"Return all the Y points.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.y\n        array([0., 0., 1., 1., 0., 0., 1., 1.])\n\n        \"\"\"\n        return self.points[:, 1]\n\n    @property\n    def z(self) -> np.ndarray:\n        \"\"\"Return all the Z points.\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(2, 2, 2))\n        >>> grid.z\n        array([0., 0., 0., 0., 1., 1., 1., 1.])\n\n        \"\"\"\n        return self.points[:, 2]\n\n    @property\n    def origin(self) -> Tuple[float]:\n        \"\"\"Return the origin of the grid (bottom southwest corner).\n\n        Examples\n        --------\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(5, 5, 5))\n        >>> grid.origin\n        (0.0, 0.0, 0.0)\n\n        Show how the origin is in the bottom \"southwest\" corner of the\n        UniformGrid.\n\n        >>> pl = pyvista.Plotter()\n        >>> _ = pl.add_mesh(grid, show_edges=True)\n        >>> _ = pl.add_axes_at_origin(ylabel=None)\n        >>> pl.camera_position = 'xz'\n        >>> pl.show()\n\n        Set the origin to ``(1, 1, 1)`` and show how this shifts the\n        UniformGrid.\n\n        >>> grid.origin = (1, 1, 1)\n        >>> pl = pyvista.Plotter()\n        >>> _ = pl.add_mesh(grid, show_edges=True)\n        >>> _ = pl.add_axes_at_origin(ylabel=None)\n        >>> pl.camera_position = 'xz'\n        >>> pl.show()\n\n        \"\"\"\n        return self.GetOrigin()\n\n    @origin.setter\n    def origin(self, origin: Sequence[Union[float, int]]):\n        \"\"\"Set the origin.\"\"\"\n        self.SetOrigin(origin[0], origin[1], origin[2])\n        self.Modified()\n\n    @property\n    def spacing(self) -> Tuple[float, float, float]:\n        \"\"\"Return or set the spacing for each axial direction.\n\n        Notes\n        -----\n        Spacing must be non-negative. While VTK accepts negative\n        spacing, this results in unexpected behavior. See:\n        https://github.com/pyvista/pyvista/issues/1967\n\n        Examples\n        --------\n        Create a 5 x 5 x 5 uniform grid.\n\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(5, 5, 5))\n        >>> grid.spacing\n        (1.0, 1.0, 1.0)\n        >>> grid.plot(show_edges=True)\n\n        Modify the spacing to ``(1, 2, 3)``\n\n        >>> grid.spacing = (1, 2, 3)\n        >>> grid.plot(show_edges=True)\n\n        \"\"\"\n        return self.GetSpacing()\n\n    @spacing.setter\n    def spacing(self, spacing: Sequence[Union[float, int]]):\n        \"\"\"Set spacing.\"\"\"\n        if min(spacing) < 0:\n            raise ValueError(f\"Spacing must be non-negative, got {spacing}\")\n        self.SetSpacing(*spacing)\n        self.Modified()\n\n    def _get_attrs(self):\n        \"\"\"Return the representation methods (internal helper).\"\"\"\n        attrs = Grid._get_attrs(self)\n        fmt = \"{}, {}, {}\".format(*[pyvista.FLOAT_FORMAT] * 3)\n        attrs.append((\"Spacing\", self.spacing, fmt))\n        return attrs\n\n    def cast_to_structured_grid(self) -> 'pyvista.StructuredGrid':\n        \"\"\"Cast this uniform grid to a structured grid.\n\n        Returns\n        -------\n        pyvista.StructuredGrid\n            This grid as a structured grid.\n\n        \"\"\"\n        alg = _vtk.vtkImageToStructuredGrid()\n        alg.SetInputData(self)\n        alg.Update()\n        return _get_output(alg)\n\n    def cast_to_rectilinear_grid(self) -> 'RectilinearGrid':\n        \"\"\"Cast this uniform grid to a rectilinear grid.\n\n        Returns\n        -------\n        pyvista.RectilinearGrid\n            This uniform grid as a rectilinear grid.\n\n        \"\"\"\n\n        def gen_coords(i):\n            coords = (\n                np.cumsum(np.insert(np.full(self.dimensions[i] - 1, self.spacing[i]), 0, 0))\n                + self.origin[i]\n            )\n            return coords\n\n        xcoords = gen_coords(0)\n        ycoords = gen_coords(1)\n        zcoords = gen_coords(2)\n        grid = pyvista.RectilinearGrid(xcoords, ycoords, zcoords)\n        grid.point_data.update(self.point_data)\n        grid.cell_data.update(self.cell_data)\n        grid.field_data.update(self.field_data)\n        grid.copy_meta_from(self, deep=True)\n        return grid\n\n    @property\n    def extent(self) -> tuple:\n        \"\"\"Return or set the extent of the UniformGrid.\n\n        The extent is simply the first and last indices for each of the three axes.\n\n        Examples\n        --------\n        Create a ``UniformGrid`` and show its extent.\n\n        >>> import pyvista\n        >>> grid = pyvista.UniformGrid(dimensions=(10, 10, 10))\n        >>> grid.extent\n        (0, 9, 0, 9, 0, 9)\n\n        >>> grid.extent = (2, 5, 2, 5, 2, 5)\n        >>> grid.extent\n        (2, 5, 2, 5, 2, 5)\n\n        Note how this also modifies the grid bounds and dimensions. Since we\n        use default spacing of 1 here, the bounds match the extent exactly.\n\n        >>> grid.bounds\n        (2.0, 5.0, 2.0, 5.0, 2.0, 5.0)\n        >>> grid.dimensions\n        (4, 4, 4)\n\n        \"\"\"\n        return self.GetExtent()\n\n    @extent.setter\n    def extent(self, new_extent: Sequence[int]):\n        \"\"\"Set the extent of the UniformGrid.\"\"\"\n        if len(new_extent) != 6:\n            raise ValueError('Extent must be a vector of 6 values.')\n        self.SetExtent(new_extent)\n\n    @wraps(RectilinearGridFilters.to_tetrahedra)\n    def to_tetrahedra(self, *args, **kwargs):\n        \"\"\"Cast to a rectangular grid and then convert to tetrahedra.\"\"\"\n        return self.cast_to_rectilinear_grid().to_tetrahedra(*args, **kwargs)\n","header":{"file":{"path":"pyvista/core/grid.py"},"misc_line":null},"index_line":null,"is_binary_file":false,"binary_line":null,"minus_file":{"path":"a/pyvista/core/grid.py"},"plus_file":{"path":"b/pyvista/core/grid.py"},"hunks":[{"descriptor":{"old_range":{"start":135,"length":23},"new_range":{"start":135,"length":30},"section":"def __init__(self, *args, check_duplicates=False, deep=False, **kwargs):"},"line_group":{"all_lines":[{"content":"                    self.shallow_copy(args[0])","type":"context"},{"content":"            elif isinstance(args[0], (str, pathlib.Path)):","type":"context"},{"content":"                self._from_file(args[0], **kwargs)","type":"context"},{"content":"            elif isinstance(args[0], np.ndarray):","type":"deleted"},{"content":"                self._from_arrays(args[0], None, None, check_duplicates)","type":"deleted"},{"content":"            elif isinstance(args[0], (np.ndarray, Sequence)):","type":"added"},{"content":"                self._from_arrays(np.asanyarray(args[0]), None, None, check_duplicates)","type":"added"},{"content":"            else:","type":"context"},{"content":"                raise TypeError(f'Type ({type(args[0])}) not understood by `RectilinearGrid`')","type":"context"},{"content":"","type":"context"},{"content":"        elif len(args) == 3 or len(args) == 2:","type":"context"},{"content":"            arg0_is_arr = isinstance(args[0], np.ndarray)","type":"deleted"},{"content":"            arg1_is_arr = isinstance(args[1], np.ndarray)","type":"deleted"},{"content":"            arg0_is_arr = isinstance(args[0], (np.ndarray, Sequence))","type":"added"},{"content":"            arg1_is_arr = isinstance(args[1], (np.ndarray, Sequence))","type":"added"},{"content":"            if len(args) == 3:","type":"context"},{"content":"                arg2_is_arr = isinstance(args[2], np.ndarray)","type":"deleted"},{"content":"                arg2_is_arr = isinstance(args[2], (np.ndarray, Sequence))","type":"added"},{"content":"            else:","type":"context"},{"content":"                arg2_is_arr = False","type":"context"},{"content":"","type":"context"},{"content":"            if all([arg0_is_arr, arg1_is_arr, arg2_is_arr]):","type":"context"},{"content":"                self._from_arrays(args[0], args[1], args[2], check_duplicates)","type":"deleted"},{"content":"                self._from_arrays(","type":"added"},{"content":"                    np.asanyarray(args[0]),","type":"added"},{"content":"                    np.asanyarray(args[1]),","type":"added"},{"content":"                    np.asanyarray(args[2]),","type":"added"},{"content":"                    check_duplicates,","type":"added"},{"content":"                )","type":"added"},{"content":"            elif all([arg0_is_arr, arg1_is_arr]):","type":"context"},{"content":"                self._from_arrays(args[0], args[1], None, check_duplicates)","type":"deleted"},{"content":"                self._from_arrays(","type":"added"},{"content":"                    np.asanyarray(args[0]), np.asanyarray(args[1]), None, check_duplicates","type":"added"},{"content":"                )","type":"added"},{"content":"            else:","type":"context"},{"content":"                raise TypeError(\"Arguments not understood by `RectilinearGrid`.\")","type":"context"},{"content":"","type":"context"},{"content":"","type":"context"}]},"modified_entities":[],"added_entities":[],"deleted_entities":[]}]}],"old_commit_hash":"db6ee8dd4a747b8864caae36c5d05883976a3ae5","new_commit_hash":"651ce59c4f797eaf106d9bc8ee3c0891963ec85e","commit_message":"use sequences in RectilinearGrid","commit_date":"2023-04-21T13:46:00Z","metadata":{}}