def test_scalar_field_plus(self):
        field1 = make_scalar_field("x+y+z")
        field2 = make_scalar_field("x*y*z")
        field = SvExScalarFieldBinOp(field1, field2, lambda x, y: x + y)
        xs = np.array([1, 2])
        ys = np.array([2, 3])
        zs = np.array([3, 4])

        r = field.evaluate_grid(xs, ys, zs)
        expected = np.array([12, 33])
        self.assert_numpy_arrays_equal(r, expected)
Beispiel #2
0
 def test_xyz(self):
     field1 = make_scalar_field("x")
     field2 = make_scalar_field("y")
     field3 = make_scalar_field("z")
     field = SvExComposedVectorField('XYZ', field1, field2, field3)
     xs = np.array([1, 2])
     ys = np.array([2, 3])
     zs = np.array([3, 4])
     rxs, rys, rzs = field.evaluate_grid(xs, ys, zs)
     expected_x = np.array([1, 2])
     expected_y = np.array([2, 3])
     expected_z = np.array([3, 4])
     self.assert_numpy_arrays_equal(rxs, expected_x)
     self.assert_numpy_arrays_equal(rys, expected_y)
     self.assert_numpy_arrays_equal(rzs, expected_z)
 def test_laplacian(self):
     field1 = make_scalar_field("x+y+z")
     field = SvExScalarFieldLaplacian(field1, 0.0001)
     xs = np.array([1, 2])
     ys = np.array([2, 3])
     zs = np.array([3, 4])
     r = field.evaluate_grid(xs, ys, zs)
     expected = np.array([0, 0])
     self.assert_numpy_arrays_equal(r, expected, precision=3)
    def test_scalar_field_negate(self):
        field1 = make_scalar_field("x+y+z")
        field = SvExNegatedScalarField(field1)
        xs = np.array([1, 2])
        ys = np.array([2, 3])
        zs = np.array([3, 4])

        r = field.evaluate_grid(xs, ys, zs)
        expected = np.array([-6, -9])
        self.assert_numpy_arrays_equal(r, expected)
Beispiel #5
0
 def test_gradient_one(self):
     field1 = make_scalar_field("x+y+z")
     field = SvExScalarFieldGradient(field1, 0.0001)
     xs = np.array([1, 2])
     ys = np.array([2, 3])
     zs = np.array([3, 4])
     rxs, rys, rzs = field.evaluate_grid(xs, ys, zs)
     expected_x = np.array([1, 1])
     expected_y = np.array([1, 1])
     expected_z = np.array([1, 1])
     self.assert_numpy_arrays_equal(rxs, expected_x, precision=3)
     self.assert_numpy_arrays_equal(rys, expected_y, precision=3)
     self.assert_numpy_arrays_equal(rzs, expected_z, precision=3)
 def test_scalar_field_lambda(self):
     field = make_scalar_field("x*x + y*y + z*z")
     value = field.evaluate(1, 2, 3)
     expected = 14
     self.assert_sverchok_data_equal(value, expected)