Repository: sympy/sympy

Issue:
Integral(1/abs(x), x).doit() returns an incomplete answer as output 
This was pointed out on the gitter channel a week back or two but I'm not sure if the user remembered to raise the issue on the github page and hence I am raising it before it gets lost in the chat !

On Master
```
>>> x = Symbol('x', real=True)
>>> Integral(1/abs(x), x).doit()
Piecewise((-log(x), x <= 0), (nan, True))
```
The correct answer for this should `sign(x)*log(abs(x))` for all points except 0 where it should be returning `nan` . I'm not sure where this might be going wrong due to my inexperience with the `Integrals` module but the output seems to capture one half of the number line correctly and returns `nan` for all other values of `x`


Discussion:

Patch:
diff --git a/sympy/calculus/accumulationbounds.py b/sympy/calculus/accumulationbounds.py
index bf247269e1..f1bb5a149e 100644
--- a/sympy/calculus/accumulationbounds.py
+++ b/sympy/calculus/accumulationbounds.py
@@ -1,6 +1,6 @@
 from sympy.core import Add, Mul, Pow, S
 from sympy.core.basic import Basic
-from sympy.core.expr import Expr
+from sympy.core.expr import AtomicExpr, Expr
 from sympy.core.numbers import _sympifyit, oo, zoo
 from sympy.core.relational import is_le, is_lt, is_ge, is_gt
 from sympy.core.sympify import _sympify
@@ -11,7 +11,7 @@
 from sympy.sets.sets import FiniteSet
 
 
-class AccumulationBounds(Expr):
+class AccumulationBounds(AtomicExpr):
     r"""
     # Note AccumulationBounds has an alias: AccumBounds
 
@@ -181,7 +181,6 @@ class AccumulationBounds(Expr):
     """
 
     is_extended_real = True
-    is_number = False
 
     def __new__(cls, min, max):
 
diff --git a/sympy/functions/elementary/piecewise.py b/sympy/functions/elementary/piecewise.py
index ce288fb916..b38944ff71 100644
--- a/sympy/functions/elementary/piecewise.py
+++ b/sympy/functions/elementary/piecewise.py
@@ -8,6 +8,7 @@
 from sympy.functions.elementary.miscellaneous import Max, Min
 from sympy.logic.boolalg import (And, Boolean, distribute_and_over_or, Not,
     true, false, Or, ITE, simplify_logic, to_cnf, distribute_or_over_and)
+from sympy.polys.polyutils import illegal
 from sympy.utilities.iterables import uniq, sift, common_prefix
 from sympy.utilities.misc import filldedent, func_name
 
@@ -501,9 +502,11 @@ def handler(ipw):
                 sum = anti
             else:
                 sum = sum.subs(x, a)
-                if sum == Undefined:
-                    sum = 0
-                sum += anti._eval_interval(x, a, x)
+                e = anti._eval_interval(x, a, x)
+                if sum.has(*illegal) or e.has(*illegal):
+                    sum = anti
+                else:
+                    sum += e
             # see if we know whether b is contained in original
             # condition
             if b is S.Infinity:


Test patch:
diff --git a/sympy/functions/elementary/tests/test_piecewise.py b/sympy/functions/elementary/tests/test_piecewise.py
index 40bdeac400..f0f41ed8e3 100644
--- a/sympy/functions/elementary/tests/test_piecewise.py
+++ b/sympy/functions/elementary/tests/test_piecewise.py
@@ -883,7 +883,7 @@ def test_holes():
     assert Piecewise((1, x < 2)).integrate(x) == Piecewise(
         (x, x < 2), (nan, True))
     assert Piecewise((1, And(x > 1, x < 2))).integrate(x) == Piecewise(
-        (nan, x < 1), (x - 1, x < 2), (nan, True))
+        (nan, x < 1), (x, x < 2), (nan, True))
     assert Piecewise((1, And(x > 1, x < 2))).integrate((x, 0, 3)) is nan
     assert Piecewise((1, And(x > 0, x < 4))).integrate((x, 1, 3)) == 2
 
@@ -1447,3 +1447,9 @@ def test_piecewise_eval():
         ) == (x >= -3) & (x <= oo)
     assert f(Piecewise((x, (Abs(arg(a)) <= 1) | (Abs(arg(a)) < 1)))
         ) == (Abs(arg(a)) <= 1) | (Abs(arg(a)) < 1)
+
+
+def test_issue_22533():
+    x = Symbol('x', real=True)
+    f = Piecewise((-1 / x, x <= 0), (1 / x, True))
+    assert integrate(f, x) == Piecewise((-log(x), x <= 0), (log(x), True))