Repository: yt-project/yt

Issue:
Pixelizing mesh line for SemiStructured data fail if coords are provided as ints
### Bug report

```python
import yt

ds = yt.load("SecondOrderTris/RZ_p_no_parts_do_nothing_bcs_cone_out.e", step=-1)
plot = yt.LinePlot(ds, [('all', 'v'), ('all', 'u')], [0, 0, 0], [0, 1, 0],
                   100, field_labels={('all', 'u') : r"v$_x$",
                                      ('all', 'v') : r"v$_y$"})
```

**Actual outcome**

```
  File "temp.py", line 4, in <module>
    plot = yt.LinePlot(ds, [('all', 'v'), ('all', 'u')], [0, 0, 0], [0, 1, 0],
  File "/var/jenkins_home/workspace/yt_docs/yt/visualization/line_plot.py", line 174, in __init__
    self._setup_plots()
  File "/var/jenkins_home/workspace/yt_docs/yt/visualization/line_plot.py", line 303, in _setup_plots
    x, y = self.ds.coordinates.pixelize_line(
  File "/var/jenkins_home/workspace/yt_docs/yt/geometry/coordinates/cartesian_coordinates.py", line 265, in pixelize_line
    arc_length, plot_values = pixelize_element_mesh_line(
  File "yt/utilities/lib/pixelization_routines.pyx", line 1420, in yt.utilities.lib.pixelization_routines.pixelize_element_mesh_line
ValueError: Buffer dtype mismatch, expected 'float64_t' but got 'long'
```

**Expected outcome**

Test pass

**Version Information**

  * Operating System: Ubuntu 18.04
  * Python Version: 3.8
  * yt version: 9138a0a
  * Other Libraries (if applicable): 


Discussion:
Can we add `cast=True` to the cython declaration?

On Wed, Jul 29, 2020 at 8:39 AM Kacper Kowalik <notifications@github.com>
wrote:

> Bug report
>
> import yt
> ds = yt.load("SecondOrderTris/RZ_p_no_parts_do_nothing_bcs_cone_out.e", step=-1)plot = yt.LinePlot(ds, [('all', 'v'), ('all', 'u')], [0, 0, 0], [0, 1, 0],
>                    100, field_labels={('all', 'u') : r"v$_x$",
>                                       ('all', 'v') : r"v$_y$"})
>
> *Actual outcome*
>
>   File "temp.py", line 4, in <module>
>     plot = yt.LinePlot(ds, [('all', 'v'), ('all', 'u')], [0, 0, 0], [0, 1, 0],
>   File "/var/jenkins_home/workspace/yt_docs/yt/visualization/line_plot.py", line 174, in __init__
>     self._setup_plots()
>   File "/var/jenkins_home/workspace/yt_docs/yt/visualization/line_plot.py", line 303, in _setup_plots
>     x, y = self.ds.coordinates.pixelize_line(
>   File "/var/jenkins_home/workspace/yt_docs/yt/geometry/coordinates/cartesian_coordinates.py", line 265, in pixelize_line
>     arc_length, plot_values = pixelize_element_mesh_line(
>   File "yt/utilities/lib/pixelization_routines.pyx", line 1420, in yt.utilities.lib.pixelization_routines.pixelize_element_mesh_line
> ValueError: Buffer dtype mismatch, expected 'float64_t' but got 'long'
>
> *Expected outcome*
>
> Test pass
>
> *Version Information*
>
>    - Operating System: Ubuntu 18.04
>    - Python Version: 3.8
>    - yt version: 9138a0a
>    <https://github.com/yt-project/yt/commit/9138a0a7330e642e040f8dc0a459f7dba347fa05>
>    - Other Libraries (if applicable):
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/yt-project/yt/issues/2794>, or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAAVXO4MIYYUJUJLG2KK46LR6AQ7PANCNFSM4PLTNS2Q>
> .
>


Resolving patch:
diff --git a/yt/visualization/color_maps.py b/yt/visualization/color_maps.py
--- a/yt/visualization/color_maps.py
+++ b/yt/visualization/color_maps.py
@@ -508,7 +508,11 @@ def add_colormap(name, cdict):
 # Add colormaps in _colormap_data.py that weren't defined here
 _vs = np.linspace(0, 1, 256)
 for k, v in list(_cm.color_map_luts.items()):
-    if k not in yt_colormaps and k not in mcm.cmap_d:
+    try:
+        colormaps = mcm._cmap_registry
+    except AttributeError:  # mpl < 3.3.0
+        colormaps = mcm.cmap_d
+    if k not in yt_colormaps and k not in colormaps:
         cdict = {
             "red": np.transpose([_vs, v[0], v[0]]),
             "green": np.transpose([_vs, v[1], v[1]]),
@@ -565,12 +569,14 @@ def show_colormaps(subset="all", filename=None):
         If filename is set, then it will save the colormaps to an output
         file.  If it is not set, it will "show" the result interactively.
     """
-    from matplotlib import cm as cm, pyplot as plt
+    from matplotlib import pyplot as plt
 
     a = np.outer(np.arange(0, 1, 0.01), np.ones(10))
     if subset == "all":
         maps = [
-            m for m in cm.cmap_d if (not m.startswith("idl")) & (not m.endswith("_r"))
+            m
+            for m in plt.colormaps()
+            if (not m.startswith("idl")) & (not m.endswith("_r"))
         ]
     elif subset == "yt_native":
         maps = [
@@ -580,7 +586,7 @@ def show_colormaps(subset="all", filename=None):
         ]
     else:
         try:
-            maps = [m for m in cm.cmap_d if m in subset]
+            maps = [m for m in plt.colormaps() if m in subset]
             if len(maps) == 0:
                 raise AttributeError
         except AttributeError:
diff --git a/yt/visualization/eps_writer.py b/yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py
+++ b/yt/visualization/eps_writer.py
@@ -744,7 +744,7 @@ def colorbar(
 
         # Convert the colormap into a string
         x = np.linspace(1, 0, 256)
-        cm_string = cm.cmap_d[name](x, bytes=True)[:, 0:3].tostring()
+        cm_string = cm.get_cmap[name](x, bytes=True)[:, 0:3].tostring()
 
         cmap_im = pyx.bitmap.image(imsize[0], imsize[1], "RGB", cm_string)
         if orientation == "top" or orientation == "bottom":
diff --git a/yt/visualization/line_plot.py b/yt/visualization/line_plot.py
--- a/yt/visualization/line_plot.py
+++ b/yt/visualization/line_plot.py
@@ -434,7 +434,7 @@ def _validate_point(point, ds, start=False):
     if not iterable(point):
         raise RuntimeError("Input point must be array-like")
     if not isinstance(point, YTArray):
-        point = ds.arr(point, "code_length")
+        point = ds.arr(point, "code_length", dtype=np.float64)
     if len(point.shape) != 1:
         raise RuntimeError("Input point must be a 1D array")
     if point.shape[0] < ds.dimensionality:


Test patch: