From 852612225256bda771c0b546f134a99e0630aedd Mon Sep 17 00:00:00 2001 From: Ondrej Certik Date: Wed, 12 Dec 2007 22:46:21 +0100 Subject: [PATCH] .subs() in Relational implemented, tests written --- sympy/core/relational.py | 3 +++ sympy/core/tests/test_subs.py | 17 ++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sympy/core/relational.py b/sympy/core/relational.py index 1b528cb..b9e3199 100644 --- a/sympy/core/relational.py +++ b/sympy/core/relational.py @@ -44,6 +44,9 @@ class Relational(Basic, NoRelMeths): return '(%s)' % r return r + def subs(self, old, new): + return self.lhs.subs(old, new) == self.rhs.subs(old, new) + class Equality(Relational): rel_op = '==' diff --git a/sympy/core/tests/test_subs.py b/sympy/core/tests/test_subs.py index e6f3329..d55245c 100644 --- a/sympy/core/tests/test_subs.py +++ b/sympy/core/tests/test_subs.py @@ -4,7 +4,8 @@ sys.path.append(".") import py import sympy as g -from sympy import Symbol, Wild, sin, cos, exp, pi, Function, Derivative +from sympy import Symbol, Wild, sin, cos, exp, pi, Function, Derivative, abc, \ + Integer from sympy.utilities.pytest import XFAIL def test_subs(): @@ -97,3 +98,17 @@ def test_deriv_sub_bug3(): pat = Derivative(f(x), x, x) assert pat.subs(y, y**2) == Derivative(f(x), x, x) assert pat.subs(y, y**2) != Derivative(f(x), x) + +def test_equality_subs1(): + f = Function("f") + x = abc.x + eq = f(x)**2 == x + res = Integer(16) == x + assert eq.subs(f(x), 4) == res + +def test_equality_subs2(): + f = Function("f") + x = abc.x + eq = f(x)**2 == 16 + assert eq.subs(f(x), 3) == False + assert eq.subs(f(x), 4) == True -- 2.11.4.GIT