Repository: sympy/sympy

Issue:
Piecewise.as_expr_set_pairs should test for univariate conditions
It would be good to add this diff to check whether the conditions are univariate:
```diff
diff --git a/sympy/functions/elementary/piecewise.py b/sympy/functions/elementar
y/piecewise.py
index edd4dab..2c79a87 100644
--- a/sympy/functions/elementary/piecewise.py
+++ b/sympy/functions/elementary/piecewise.py
@@ -961,7 +961,12 @@ def as_expr_set_pairs(self, domain=S.Reals):
         exp_sets = []
         U = domain
         complex = not domain.is_subset(S.Reals)
+        cond_free = set()
         for expr, cond in self.args:
+            cond_free |= cond.free_symbols
+            if len(cond_free) > 1:
+                raise NotImplementedError(filldedent('''
+                    multivariate conditions are not handled.'''))
             if complex:
                 for i in cond.atoms(Relational):
                     if not isinstance(i, (Equality, Unequality)):
```
This tests as
```python
>>> Piecewise((x,x<0),(0,y>1)).as_expr_set_pairs()
Traceback (most recent call last):
...
NotImplementedError:
multivariate conditions are not handled.
```

Discussion:

Patch:
diff --git a/sympy/functions/elementary/piecewise.py b/sympy/functions/elementary/piecewise.py
index aafcd602b5..951fdfbfec 100644
--- a/sympy/functions/elementary/piecewise.py
+++ b/sympy/functions/elementary/piecewise.py
@@ -907,7 +907,12 @@ def as_expr_set_pairs(self, domain=S.Reals):
         exp_sets = []
         U = domain
         complex = not domain.is_subset(S.Reals)
+        cond_free = set()
         for expr, cond in self.args:
+            cond_free |= cond.free_symbols
+            if len(cond_free) > 1:
+                raise NotImplementedError(filldedent('''
+                    multivariate conditions are not handled.'''))
             if complex:
                 for i in cond.atoms(Relational):
                     if not isinstance(i, (Equality, Unequality)):


Test patch:
diff --git a/sympy/functions/elementary/tests/test_piecewise.py b/sympy/functions/elementary/tests/test_piecewise.py
index fd609c9f71..86c75c6848 100644
--- a/sympy/functions/elementary/tests/test_piecewise.py
+++ b/sympy/functions/elementary/tests/test_piecewise.py
@@ -1351,3 +1351,6 @@ def test_issue_7370():
     f = Piecewise((1, x <= 2400))
     v = integrate(f, (x, 0, Float("252.4", 30)))
     assert str(v) == '252.400000000000000000000000000'
+
+def test_issue_16715():
+    raises(NotImplementedError, lambda: Piecewise((x, x<0), (0, y>1)).as_expr_set_pairs())
diff --git a/sympy/series/tests/test_series.py b/sympy/series/tests/test_series.py
index c7f035f087..00e88618e6 100644
--- a/sympy/series/tests/test_series.py
+++ b/sympy/series/tests/test_series.py
@@ -218,6 +218,3 @@ def test_issue_7259():
     assert series(LambertW(x), x) == x - x**2 + 3*x**3/2 - 8*x**4/3 + 125*x**5/24 + O(x**6)
     assert series(LambertW(x**2), x, n=8) == x**2 - x**4 + 3*x**6/2 + O(x**8)
     assert series(LambertW(sin(x)), x, n=4) == x - x**2 + 4*x**3/3 + O(x**4)
-
-def test_issue_11884():
-    assert cos(x).series(x, 1, n=1) == cos(1) + O(x - 1, (x, 1))