Added three unit tests for redimming DynamicMap values
@@ -78,6 +78,33 @@ class DynamicMapMethods(ComparisonTestCase):
dmap = DynamicMap(fn, kdims=['i']).redim.range(i=(0,1))
self.assertEqual(dmap.kdims[0].range, (0,1))
+ def test_redim_dimension_values_cache_reset_1D(self):
+ # Setting the values should drop mismatching keys from the cache
+ fn = lambda i: Curve([i,i])
+ dmap = DynamicMap(fn, kdims=['i'])[{0,1,2,3,4,5}]
+ self.assertEqual(dmap.keys(), [0,1,2,3,4,5])
+ redimmed = dmap.redim.values(i=[2,3,5,6,8])
+ self.assertEqual(redimmed.keys(), [2,3,5])
+
+ def test_redim_dimension_values_cache_reset_2D_single(self):
+ # Setting the values should drop mismatching keys from the cache
+ fn = lambda i,j: Curve([i,j])
+ keys = [(0,1),(1,0),(2,2),(2,5), (3,3)]
+ dmap = DynamicMap(fn, kdims=['i','j'])[keys]
+ self.assertEqual(dmap.keys(), keys)
+ redimmed = dmap.redim.values(i=[2,10,50])
+ self.assertEqual(redimmed.keys(), [(2,2),(2,5)])
+
+ def test_redim_dimension_values_cache_reset_2D_multi(self):
+ # Setting the values should drop mismatching keys from the cache
+ fn = lambda i,j: Curve([i,j])
+ keys = [(0,1),(1,0),(2,2),(2,5), (3,3)]
+ dmap = DynamicMap(fn, kdims=['i','j'])[keys]
+ self.assertEqual(dmap.keys(), keys)
+ redimmed = dmap.redim.values(i=[2,10,50], j=[5,50,100])
+ self.assertEqual(redimmed.keys(), [(2,5)])
+
+
def test_redim_dimension_unit_aux(self):
fn = lambda i: Image(sine_array(0,i))
dmap = DynamicMap(fn, kdims=['i']).redim.unit(i='m/s')
