Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing type(...) in _trigsimp_inverse #26541

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ Aditya Kumar Sinha <adityakumar113141@gmail.com> aditya113141 <adityakumar113141
Aditya Ravuri <infprobscix@gmail.com> InfProbSciX <infprobscix@gmail.com>
Aditya Rohan <riyuzakiiitk@gmail.com>
Aditya Shah <adityashah30@gmail.com>
Adrian Kriegel <adrian.kriegel@tu-ilmenau.de>
Advait Pote <apote2050@gmail.com> <advaitpote@192.168.1.4>
Advait Pote <apote2050@gmail.com> Advait <apote2050@gmail.com>
Advait Pote <apote2050@gmail.com> Advait Pote <92469698+AdvaitPote@users.noreply.github.com>
Expand Down
8 changes: 8 additions & 0 deletions sympy/simplify/tests/test_trigsimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,3 +518,11 @@ def test_trigsimp_inverse():
assert angle_inverted != angle # assures simplification happened
assert sin(angle_inverted) == trigsimp(sin(angle))
assert cos(angle_inverted) == trigsimp(cos(angle))

def test_trigsimp_inverse_26541():
'''
Some expressions would raise a TypeError due to a missing type(...).
See: https://github.com/sympy/sympy/pull/26541
'''
# this would throw before
trigsimp(cos('x')**2, inverse=True)
8 changes: 5 additions & 3 deletions sympy/simplify/trigsimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,11 @@ def check_args(x, y):
def f(rv):
# for simple functions
g = getattr(rv, 'inverse', None)
if (g is not None and isinstance(rv.args[0], g()) and
isinstance(g()(1), TrigonometricFunction)):
return rv.args[0].args[0]

if g is not None:
g_type = g()
if g_type is not None and isinstance(rv.args[0], g_type) and isinstance(g_type(1), TrigonometricFunction):
return rv.args[0].args[0]

# for atan2 simplifications, harder because atan2 has 2 args
if isinstance(rv, atan2):
Expand Down