Repository: sympy/sympy

Issue:
inverse_laplace_transform of sum fails with `noconds=False`
The way inverse_laplace_transform deals with conditions needs some love...    I'd like to consider having `noconds=False` the default like it is with other transforms.  Here's one particular issue to deal with along the way:

These transforms both work:
```py
>>> a = Symbol('a', real=True)
>>> inverse_laplace_transform(exp(a*s)/s,s,t, noconds=False)
(Heaviside(t + a), True)

>>> inverse_laplace_transform(1/s,s,t, noconds=False)
(Heaviside(t), True)
```
But put two of them together:
```py
>>>  inverse_laplace_transform(1/s + exp(a*s)/s,s,t, noconds=False)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-33-72166956a0e6> in <module>()
----> 1 inverse_laplace_transform(1/s + exp(a*s)/s,s,t, noconds=False)

/home/cbm/work/octsympy/octsympy.git/inst/sympy/integrals/transforms.pyc in inverse_laplace_transform(F, s, t, plane, **hints)
   1276     if isinstance(F, MatrixBase) and hasattr(F, 'applyfunc'):
   1277         return F.applyfunc(lambda Fij: inverse_laplace_transform(Fij, s, t, plane, **hints))
-> 1278     return InverseLaplaceTransform(F, s, t, plane).doit(**hints)
   1279 
   1280 

/home/cbm/work/octsympy/octsympy.git/inst/sympy/integrals/transforms.pyc in doit(self, **hints)
    139                 return res
    140             try:
--> 141                 extra = self._collapse_extra(extra)
    142                 return tuple([res]) + tuple(extra)
    143             except IntegralTransformError:

/home/cbm/work/octsympy/octsympy.git/inst/sympy/integrals/transforms.pyc in _collapse_extra(self, extra)
     85 
     86     def _collapse_extra(self, extra):
---> 87         cond = And(*extra)
     88         if cond == False:
     89             raise IntegralTransformError(self.__class__.name, None, '')

/home/cbm/work/octsympy/octsympy.git/inst/sympy/core/operations.pyc in __new__(cls, *args, **options)
    409             # is done so short-circuiting can be done
    410             # without having to sympify all values
--> 411             _args = frozenset(cls._new_args_filter(args))
    412         except ShortCircuit:
    413             return sympify(cls.zero)

/home/cbm/work/octsympy/octsympy.git/inst/sympy/logic/boolalg.py in _new_args_filter(cls, args)
    530         newargs = []
    531         rel = []
--> 532         args = BooleanFunction.binary_check_and_simplify(*args)
    533         for x in reversed(args):
    534             if x.is_Relational:

/home/cbm/work/octsympy/octsympy.git/inst/sympy/logic/boolalg.py in binary_check_and_simplify(self, *args)
    431     def binary_check_and_simplify(self, *args):
    432         from sympy.core.relational import Relational, Eq, Ne
--> 433         args = [as_Boolean(i) for i in args]
    434         bin = set().union(*[i.binary_symbols for i in args])
    435         rel = set().union(*[i.atoms(Relational) for i in args])

/home/cbm/work/octsympy/octsympy.git/inst/sympy/logic/boolalg.py in as_Boolean(e)
     50     if isinstance(e, Boolean):
     51         return e
---> 52     raise TypeError('expecting bool or Boolean, not `%s`.' % e)
     53 
     54 

TypeError: expecting bool or Boolean, not `(True,)`.
```


Discussion:

Patch:
diff --git a/sympy/integrals/transforms.py b/sympy/integrals/transforms.py
index 1c7c832dca..ca706c1235 100644
--- a/sympy/integrals/transforms.py
+++ b/sympy/integrals/transforms.py
@@ -3,7 +3,7 @@
 from __future__ import print_function, division
 
 from sympy.core import S
-from sympy.core.compatibility import reduce, range
+from sympy.core.compatibility import reduce, range, iterable
 from sympy.core.function import Function
 from sympy.core.numbers import oo
 from sympy.core.symbol import Dummy
@@ -87,6 +87,7 @@ def _collapse_extra(self, extra):
         cond = And(*extra)
         if cond == False:
             raise IntegralTransformError(self.__class__.name, None, '')
+        return cond
 
     def doit(self, **hints):
         """
@@ -132,14 +133,21 @@ def doit(self, **hints):
                 if not isinstance(x, tuple):
                     x = [x]
                 ress.append(x[0])
-                if len(x) > 1:
+                if len(x) == 2:
+                    # only a condition
+                    extra.append(x[1])
+                elif len(x) > 2:
+                    # some region parameters and a condition (Mellin, Laplace)
                     extra += [x[1:]]
             res = Add(*ress)
             if not extra:
                 return res
             try:
                 extra = self._collapse_extra(extra)
-                return tuple([res]) + tuple(extra)
+                if iterable(extra):
+                    return tuple([res]) + tuple(extra)
+                else:
+                    return (res, extra)
             except IntegralTransformError:
                 pass
 


Test patch:
diff --git a/sympy/integrals/tests/test_transforms.py b/sympy/integrals/tests/test_transforms.py
index 6e1ddd7a85..04d3f891aa 100644
--- a/sympy/integrals/tests/test_transforms.py
+++ b/sympy/integrals/tests/test_transforms.py
@@ -598,7 +598,7 @@ def test_inverse_laplace_transform_delta():
 
 
 def test_inverse_laplace_transform_delta_cond():
-    from sympy import DiracDelta, Eq, im
+    from sympy import DiracDelta, Eq, im, Heaviside
     ILT = inverse_laplace_transform
     t = symbols('t')
     r = Symbol('r', real=True)
@@ -612,7 +612,9 @@ def test_inverse_laplace_transform_delta_cond():
         f = ILT(exp(z*s), s, t, noconds=False)
         f = f[0] if isinstance(f, tuple) else f
         assert f.func != DiracDelta
-
+    # issue 15043
+    assert ILT(1/s + exp(r*s)/s, s, t, noconds=False) == (
+        Heaviside(t) + Heaviside(r + t), True)
 
 def test_fourier_transform():
     from sympy import simplify, expand, expand_complex, factor, expand_trig