Repository: pyvista/pyvista

Issue:
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_

Discussion:
codecov[bot]: ## [Codecov](https://codecov.io/gh/pyvista/pyvista/pull/4315?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvista) Report
> Merging [#4315](https://codecov.io/gh/pyvista/pyvista/pull/4315?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvista) (651ce59) into [main](https://codecov.io/gh/pyvista/pyvista/commit/e71be93c902d516a384cb2edff4e37006caad26b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=pyvista) (e71be93) will **decrease** coverage by `5.30%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##             main    #4315      +/-   ##
==========================================
- Coverage   95.77%   90.48%   -5.30%     
==========================================
  Files          97       97              
  Lines       20694    20762      +68     
==========================================
- Hits        19820    18786    -1034     
- Misses        874     1976    +1102     
```

MatthewFlamm: For completeness, passing in a `Sequence` will mean that it is always copied using `np.asanyarray`.  This function passes through any subclass of `ndarray` without copying.

> Convert the input to an ndarray, but pass ndarray subclasses through.

https://numpy.org/doc/stable/reference/generated/numpy.asanyarray.html

Patch:
diff --git a/pyvista/core/grid.py b/pyvista/core/grid.py
index 6ce23688..5248dd3f 100644
--- a/pyvista/core/grid.py
+++ b/pyvista/core/grid.py
@@ -135,23 +135,30 @@ class RectilinearGrid(_vtk.vtkRectilinearGrid, Grid, RectilinearGridFilters):
                     self.shallow_copy(args[0])
             elif isinstance(args[0], (str, pathlib.Path)):
                 self._from_file(args[0], **kwargs)
-            elif isinstance(args[0], np.ndarray):
-                self._from_arrays(args[0], None, None, check_duplicates)
+            elif isinstance(args[0], (np.ndarray, Sequence)):
+                self._from_arrays(np.asanyarray(args[0]), None, None, check_duplicates)
             else:
                 raise TypeError(f'Type ({type(args[0])}) not understood by `RectilinearGrid`')
 
         elif len(args) == 3 or len(args) == 2:
-            arg0_is_arr = isinstance(args[0], np.ndarray)
-            arg1_is_arr = isinstance(args[1], np.ndarray)
+            arg0_is_arr = isinstance(args[0], (np.ndarray, Sequence))
+            arg1_is_arr = isinstance(args[1], (np.ndarray, Sequence))
             if len(args) == 3:
-                arg2_is_arr = isinstance(args[2], np.ndarray)
+                arg2_is_arr = isinstance(args[2], (np.ndarray, Sequence))
             else:
                 arg2_is_arr = False
 
             if all([arg0_is_arr, arg1_is_arr, arg2_is_arr]):
-                self._from_arrays(args[0], args[1], args[2], check_duplicates)
+                self._from_arrays(
+                    np.asanyarray(args[0]),
+                    np.asanyarray(args[1]),
+                    np.asanyarray(args[2]),
+                    check_duplicates,
+                )
             elif all([arg0_is_arr, arg1_is_arr]):
-                self._from_arrays(args[0], args[1], None, check_duplicates)
+                self._from_arrays(
+                    np.asanyarray(args[0]), np.asanyarray(args[1]), None, check_duplicates
+                )
             else:
                 raise TypeError("Arguments not understood by `RectilinearGrid`.")
 


Test patch:
diff --git a/tests/test_grid.py b/tests/test_grid.py
index 1f3645b9..5197f636 100644
--- a/tests/test_grid.py
+++ b/tests/test_grid.py
@@ -735,6 +735,21 @@ def test_create_rectilinear_grid_from_specs():
     assert grid.n_cells == 9 * 3 * 19
     assert grid.n_points == 10 * 4 * 20
     assert grid.bounds == (-10.0, 8.0, -10.0, 5.0, -10.0, 9.0)
+
+    # with Sequence
+    xrng = [0, 1]
+    yrng = [0, 1, 2]
+    zrng = [0, 1, 2, 3]
+    grid = pyvista.RectilinearGrid(xrng)
+    assert grid.n_cells == 1
+    assert grid.n_points == 2
+    grid = pyvista.RectilinearGrid(xrng, yrng)
+    assert grid.n_cells == 2
+    assert grid.n_points == 6
+    grid = pyvista.RectilinearGrid(xrng, yrng, zrng)
+    assert grid.n_cells == 6
+    assert grid.n_points == 24
+
     # 2D example
     cell_spacings = np.array([1.0, 1.0, 2.0, 2.0, 5.0, 10.0])
     x_coordinates = np.cumsum(cell_spacings)