Exemple #1
0
    def sym_difference(self, sym_var):
        """

        :type sym_var: SymVariable
        """
        # return SymVariable.shift(sym_var, {self.axis_name: 1}) - sym_var
        return (
            SymVariable.shift(sym_var, {self.axis_name: 1}) -
            SymVariable.shift(sym_var, {self.axis_name: -1})).__truediv__(2.0)
    def test_shift(self):
        sym_v2 = copy.deepcopy(self.sym_v)
        sym_v2 = SymVariable.shift(sym_v2, {"x": -1, "y": 2})

        assert str(sym_v2) == "v(x - 1, y + 2)".replace(' ', '')
        assert sym_v2.evaluate({"x": 3, "y": 0}) == 4
        assert str(self.sym_v) == "v(x, y)".replace(' ', '')
        assert self.sym_v.evaluate({"x": 3, "y": 0}) == 1
    def test_mul(self):
        sym_v2 = copy.deepcopy(self.sym_v)
        sym_v2 = SymVariable.shift(sym_v2, {"x": -1, "y": 2})
        sym_new = sym_v2 * self.sym_v

        assert str(sym_new) == "v(x, y)*v(x - 1, y + 2)".replace(' ', '')
        assert sym_new.evaluate({"x": 3, "y": 0}) == 4

        sym_new = self.sym_v * self.sym_x
        assert str(sym_new) == "v(x, y)*x(x)".replace(' ', '')
Exemple #4
0
 def sym_var_operator_func(self, sym_var):
     return SymVariable.shift(sym_var, {self.axis_name: -self.delay})