Ejemplo n.º 1
0
 def test_sel(self):
     a, b = Leaf(13.0), Leaf(4.0)
     c = a.select(b)
     d = Derivative([c], [a, b])
     self.assertListEqual(d.value, [[1.0, 0.0]])
     b.value = -1.0
     d[0][0].invalidate()
     self.assertListEqual(d.value, [[0.0, 0.0]])
     del c, d
     self.assertEqual(a.node.ref_count, 1)
     self.assertEqual(b.node.ref_count, 1)
Ejemplo n.º 2
0
 def test_sel(self):
     a, b = Leaf(13.0), Leaf(4.0)
     c = a.select(b)
     d = sparse_derivative([c], [a, b])
     dv = [d[0][0].value, d[0][1].value]
     self.assertListEqual(dv, [1.0, 0.0])
     b.value = -1.0
     d[0][0].invalidate()
     self.assertEqual(d[0][0].value, 0.0)
     del c, d
     self.assertEqual(a.node.ref_count, 1)
     self.assertEqual(b.node.ref_count, 1)