Repository: holoviz/holoviews

Issue:
Testing framework fails to raise exceptions
In this code on `main`:

https://github.com/holoviz/holoviews/blob/adbfe2c6e82b08df4bbbf14e3a2421e0f2bfb2c3/holoviews/element/comparison.py#L511-L532

there are two lines in which exceptions are created but they are not `raise`d so no errors are reported to the user. This is a bug, all other uses of `cls.failureException` are `raise`d.


Discussion:

Resolving patch:
diff --git a/holoviews/element/comparison.py b/holoviews/element/comparison.py
--- a/holoviews/element/comparison.py
+++ b/holoviews/element/comparison.py
@@ -17,6 +17,7 @@
 thus would not supply any information regarding *why* two elements are
 considered different.
 """
+import contextlib
 from functools import partial
 import numpy as np
 import pandas as pd
@@ -522,12 +523,20 @@ def compare_dataset(cls, el1, el2, msg='Dataset'):
             raise AssertionError("%s not of matching length, %d vs. %d."
                                  % (msg, el1.shape[0], el2.shape[0]))
         for dim, d1, d2 in dimension_data:
+            with contextlib.suppress(Exception):
+                np.testing.assert_equal(d1, d2)
+                continue  # if equal, no need to check further
+
             if d1.dtype != d2.dtype:
-                cls.failureException(f"{msg} {dim.pprint_label} columns have different type."
-                                     + f" First has type {d1}, and second has type {d2}.")
+                failure_msg = (
+                    f"{msg} {dim.pprint_label} columns have different type. "
+                    f"First has type {d1}, and second has type {d2}."
+                )
+                raise cls.failureException(failure_msg)
             if d1.dtype.kind in 'SUOV':
                 if list(d1) == list(d2):
-                    cls.failureException(f"{msg} along dimension {dim.pprint_label} not equal.")
+                    failure_msg = f"{msg} along dimension {dim.pprint_label} not equal."
+                    raise cls.failureException(failure_msg)
             else:
                 cls.compare_arrays(d1, d2, msg)
 


Test patch:
diff --git a/holoviews/tests/core/test_callable.py b/holoviews/tests/core/test_callable.py
--- a/holoviews/tests/core/test_callable.py
+++ b/holoviews/tests/core/test_callable.py
@@ -218,21 +218,21 @@ class TestDynamicMapInvocation(ComparisonTestCase):
 
     def test_dynamic_kdims_only(self):
         def fn(A,B):
-            return Scatter([(A,2)], label=A)
+            return Scatter([(B,2)], label=A)
 
         dmap = DynamicMap(fn, kdims=['A','B'])
         self.assertEqual(dmap['Test', 1], Scatter([(1, 2)], label='Test'))
 
     def test_dynamic_kdims_only_by_position(self):
         def fn(A,B):
-            return Scatter([(A,2)], label=A)
+            return Scatter([(B,2)], label=A)
 
         dmap = DynamicMap(fn, kdims=['A-dim','B-dim'])
         self.assertEqual(dmap['Test', 1], Scatter([(1, 2)], label='Test'))
 
     def test_dynamic_kdims_swapped_by_name(self):
         def fn(A,B):
-            return Scatter([(A,2)], label=A)
+            return Scatter([(B,2)], label=A)
 
         dmap = DynamicMap(fn, kdims=['B','A'])
         self.assertEqual(dmap[1,'Test'], Scatter([(1, 2)], label='Test'))
@@ -240,7 +240,7 @@ def fn(A,B):
 
     def test_dynamic_kdims_only_invalid(self):
         def fn(A,B):
-            return Scatter([(A,2)], label=A)
+            return Scatter([(B,2)], label=A)
 
         regexp="Callable 'fn' accepts more positional arguments than there are kdims and stream parameters"
         with self.assertRaisesRegex(KeyError, regexp):
@@ -250,7 +250,7 @@ def fn(A,B):
     def test_dynamic_kdims_args_only(self):
         def fn(*args):
             (A,B) = args
-            return Scatter([(A,2)], label=A)
+            return Scatter([(B,2)], label=A)
 
         dmap = DynamicMap(fn, kdims=['A','B'])
         self.assertEqual(dmap['Test', 1], Scatter([(1, 2)], label='Test'))
diff --git a/holoviews/tests/core/test_dynamic.py b/holoviews/tests/core/test_dynamic.py
--- a/holoviews/tests/core/test_dynamic.py
+++ b/holoviews/tests/core/test_dynamic.py
@@ -740,7 +740,7 @@ def fn2(x, y):
 
         overlaid = dmap * dmap2
         overlay = overlaid[()]
-        self.assertEqual(overlay.Scatter.I, fn(0, 0))
+        self.assertEqual(overlay.Scatter.I, fn(None, None))
 
         dmap.event(x=1, y=2)
         overlay = overlaid[()]
diff --git a/holoviews/tests/element/test_graphelement.py b/holoviews/tests/element/test_graphelement.py
--- a/holoviews/tests/element/test_graphelement.py
+++ b/holoviews/tests/element/test_graphelement.py
@@ -227,9 +227,9 @@ def test_chord_constructor_with_vdims(self):
 
     def test_chord_constructor_self_reference(self):
         chord = Chord([('A', 'B', 2), ('B', 'A', 3), ('A', 'A', 2)])
-        nodes = np.array(
-            [[-0.5, 0.866025, 0],
-             [0.5, -0.866025, 1]]
+        nodes = pd.DataFrame(
+            [[-0.5, 0.866025, "A"], [0.5, -0.866025, "B"]],
+            columns=["x", "y", "index"]
         )
         self.assertEqual(chord.nodes, Nodes(nodes))
 
diff --git a/holoviews/tests/operation/test_datashader.py b/holoviews/tests/operation/test_datashader.py
--- a/holoviews/tests/operation/test_datashader.py
+++ b/holoviews/tests/operation/test_datashader.py
@@ -875,7 +875,7 @@ def test_regrid_mean_xarray_transposed(self):
         self.assertEqual(regridded, expected)
 
     def test_regrid_rgb_mean(self):
-        arr = (np.arange(10) * np.arange(5)[np.newaxis].T).astype('f')
+        arr = (np.arange(10) * np.arange(5)[np.newaxis].T).astype('float64')
         rgb = RGB((range(10), range(5), arr, arr*2, arr*2))
         regridded = regrid(rgb, width=2, height=2, dynamic=False)
         new_arr = np.array([[1.6, 5.6], [6.4, 22.4]])