Exemplo n.º 1
0
    def test_double(self):
        from dcgpy import kernel_double as kernel

        my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")

        self.assertEqual(my_kernel.__repr__(), "my_sum_kernel")
        self.assertEqual(my_kernel([1,2,3]), 6)
        self.assertEqual(my_kernel(["x", "y"]), "(x+y)")
Exemplo n.º 2
0
    def test_double(self):
        from dcgpy import kernel_double as kernel

        my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")

        self.assertEqual(my_kernel.__repr__(), "my_sum_kernel")
        self.assertEqual(my_kernel([1, 2, 3]), 6)
        self.assertEqual(my_kernel(["x", "y"]), "(x+y)")
Exemplo n.º 3
0
    def test_gdual_vdouble(self):
        from dcgpy import kernel_gdual_vdouble as kernel
        from pyaudi import gdual_vdouble as gdual

        my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")

        self.assertEqual(my_kernel.__repr__(), "my_sum_kernel")
        x = gdual([1, -1], "x", 2)
        y = gdual([2, -2], "y", 2)
        z = gdual([-2, 1], "z", 2)
        self.assertEqual(my_kernel([x, y, z]), x + y + z)
        self.assertEqual(my_kernel(["x", "y"]), "(x+y)")
Exemplo n.º 4
0
    def test_gdual_vdouble(self):
        from dcgpy import kernel_gdual_vdouble as kernel
        from pyaudi import gdual_vdouble as gdual

        my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")

        self.assertEqual(my_kernel.__repr__(), "my_sum_kernel")
        x = gdual([1,-1], "x", 2)
        y = gdual([2,-2], "y", 2)
        z = gdual([-2,1], "z", 2)
        self.assertEqual(my_kernel([x, y, z]), x + y + z)
        self.assertEqual(my_kernel(["x", "y"]), "(x+y)")
Exemplo n.º 5
0
    def test_gdual_double(self):
        from dcgpy import kernel_gdual_double as kernel
        from pyaudi import gdual_double as gdual

        my_kernel = kernel(my_py_fun, my_py_fun_print, "my_sum_kernel")

        self.assertEqual(my_kernel.__repr__(), "my_sum_kernel")
        x = gdual(1, "x", 2)
        y = gdual(2, "y", 2)
        z = gdual(3, "z", 2)
        self.assertEqual(my_kernel([x, y, z]), x + y + z)
        self.assertEqual(my_kernel(["x", "y"]), "(x+y)")
Exemplo n.º 6
0
 def test_double(self):
     from dcgpy import kernel_set_double as kernel_set
     from dcgpy import kernel_double as kernel
     a = kernel_set(["diff"])
     a.push_back("mul")
     my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")
     a.push_back(my_kernel)
     self.assertEqual(a.__repr__(), "[diff, mul, my_sum_kernel]")
     x = 1
     y = 2
     z = 3
     self.assertEqual(a[0]([x, y, z]), x - y - z)
     self.assertEqual(a[1]([x, y, z]), x * y * z)
     self.assertEqual(a[2]([x, y, z]), x + y + z)
Exemplo n.º 7
0
 def test_double(self):
     from dcgpy import kernel_set_double as kernel_set
     from dcgpy import kernel_double as kernel
     a = kernel_set(["diff"])
     a.push_back("mul")
     my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")
     a.push_back(my_kernel)
     self.assertEqual(a.__repr__(), "[diff, mul, my_sum_kernel]")
     x = 1
     y = 2
     z = 3
     self.assertEqual(a[0]([x,y,z]), x-y-z)
     self.assertEqual(a[1]([x,y,z]), x*y*z)
     self.assertEqual(a[2]([x,y,z]), x+y+z)
Exemplo n.º 8
0
    def test_gdual_vdouble(self):
        from dcgpy import kernel_set_gdual_vdouble as kernel_set
        from dcgpy import kernel_gdual_vdouble as kernel
        from pyaudi import gdual_vdouble as gdual

        a = kernel_set(["diff"])
        a.push_back("mul")
        my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")
        a.push_back(my_kernel)
        self.assertEqual(a.__repr__(), "[diff, mul, my_sum_kernel]")
        x = gdual([1, -1], "x", 2)
        y = gdual([2, -2], "y", 2)
        z = gdual([-2, 1], "z", 2)
        self.assertEqual(a[0]([x, y, z]), x - y - z)
        self.assertEqual(a[1]([x, y, z]), x * y * z)
        self.assertEqual(a[2]([x, y, z]), x + y + z)
Exemplo n.º 9
0
    def test_gdual_vdouble(self):
        from dcgpy import kernel_set_gdual_vdouble as kernel_set
        from dcgpy import kernel_gdual_vdouble as kernel
        from pyaudi import gdual_vdouble as gdual

        a = kernel_set(["diff"])
        a.push_back("mul")
        my_kernel = kernel(self.my_sum, self.print_my_sum, "my_sum_kernel")
        a.push_back(my_kernel)
        self.assertEqual(a.__repr__(), "[diff, mul, my_sum_kernel]")
        x = gdual([1,-1], "x", 2)
        y = gdual([2,-2], "y", 2)
        z = gdual([-2,1], "z", 2)
        self.assertEqual(a[0]([x,y,z]), x-y-z)
        self.assertEqual(a[1]([x,y,z]), x*y*z)
        self.assertEqual(a[2]([x,y,z]), x+y+z)
Exemplo n.º 10
0
    def test_gdual_double(self):
        from dcgpy import kernel_set_gdual_double as kernel_set
        from dcgpy import kernel_gdual_double as kernel
        from pyaudi import gdual_double as gdual

        a = kernel_set(["diff"])
        a.push_back("mul")
        my_kernel = kernel(my_py_fun, my_py_fun_print, "my_sum_kernel")
        a.push_back(my_kernel)
        self.assertEqual(a.__repr__(), "[diff, mul, my_sum_kernel]")
        x = gdual(1, "x", 2)
        y = gdual(2, "y", 2)
        z = gdual(3, "z", 2)
        self.assertEqual(a[0]([x, y, z]), x - y - z)
        self.assertEqual(a[1]([x, y, z]), x * y * z)
        self.assertEqual(a[2]([x, y, z]), x + y + z)