def test_pre_and_postprocess_hooks(self):
     pre_backup = operation._preprocess_hooks
     post_backup = operation._postprocess_hooks
     operation._preprocess_hooks = [lambda op, x: {'label': str(x.id)}]
     operation._postprocess_hooks = [lambda op, x, **kwargs: x.clone(**kwargs)]
     curve = Curve([1, 2, 3])
     self.assertEqual(operation(curve).label, str(curve.id))
     operation._preprocess_hooks = pre_backup
     operation._postprocess_hooks = post_backup
Beispiel #2
0
 def test_pre_and_postprocess_hooks(self):
     pre_backup = operation._preprocess_hooks
     post_backup = operation._postprocess_hooks
     operation._preprocess_hooks = [lambda op, x: {'label': str(x.id)}]
     operation._postprocess_hooks = [lambda op, x, **kwargs: x.clone(**kwargs)]
     curve = Curve([1, 2, 3])
     self.assertEqual(operation(curve).label, str(curve.id))
     operation._preprocess_hooks = pre_backup
     operation._postprocess_hooks = post_backup
Beispiel #3
0
 def test_operation_grid(self):
     grid = GridSpace({i: Image(np.random.rand(10, 10))
                       for i in range(10)},
                      kdims=['X'])
     op_grid = operation(grid, op=lambda x, k: x.clone(x.data * 2))
     doubled = grid.clone({
         k: v.clone(v.data * 2, group='Operation')
         for k, v in grid.items()
     })
     self.assertEqual(op_grid, doubled)
Beispiel #4
0
 def test_operation_ndlayout(self):
     ndlayout = NdLayout(
         {i: Image(np.random.rand(10, 10))
          for i in range(10)})
     op_ndlayout = operation(ndlayout, op=lambda x, k: x.clone(x.data * 2))
     doubled = ndlayout.clone({
         k: v.clone(v.data * 2, group='Operation')
         for k, v in ndlayout.items()
     })
     self.assertEqual(op_ndlayout, doubled)
Beispiel #5
0
 def test_operation_holomap(self):
     hmap = HoloMap({1: Image(np.random.rand(10, 10))})
     op_hmap = operation(hmap, op=lambda x, k: x.clone(x.data * 2))
     self.assertEqual(
         op_hmap.last, hmap.last.clone(hmap.last.data * 2,
                                       group='Operation'))
Beispiel #6
0
 def test_operation_element(self):
     img = Image(np.random.rand(10, 10))
     op_img = operation(img, op=lambda x, k: x.clone(x.data * 2))
     self.assertEqual(op_img, img.clone(img.data * 2, group='Operation'))
Beispiel #7
0
 def test_operation_holomap(self):
     hmap = HoloMap({1: Image(np.random.rand(10, 10))})
     op_hmap = operation(hmap, op=lambda x, k: x.clone(x.data*2))
     self.assertEqual(op_hmap.last, hmap.last.clone(hmap.last.data*2, group='Operation'))
Beispiel #8
0
 def test_operation_grid(self):
     grid = GridSpace({i: Image(np.random.rand(10, 10)) for i in range(10)}, kdims=['X'])
     op_grid = operation(grid, op=lambda x, k: x.clone(x.data*2))
     doubled = grid.clone({k: v.clone(v.data*2, group='Operation')
                           for k, v in grid.items()})
     self.assertEqual(op_grid, doubled)
Beispiel #9
0
 def test_operation_ndlayout(self):
     ndlayout = NdLayout({i: Image(np.random.rand(10, 10)) for i in range(10)})
     op_ndlayout = operation(ndlayout, op=lambda x, k: x.clone(x.data*2))
     doubled = ndlayout.clone({k: v.clone(v.data*2, group='Operation')
                               for k, v in ndlayout.items()})
     self.assertEqual(op_ndlayout, doubled)
Beispiel #10
0
 def test_operation_element(self):
     img = Image(np.random.rand(10, 10))
     op_img = operation(img, op=lambda x, k: x.clone(x.data*2))
     self.assertEqual(op_img, img.clone(img.data*2, group='Operation'))