Repository: dfm/emcee (language: python)

Issue:
[3.1.3]  test failure with scipy 1.10
**General information:**

This is a forward of [Debian#1029688](https://bugs.debian.org/1029688).

- emcee version: 3.1.3
- platform: Debian unstable/experimental
- installation method (pip/conda/source/other?): Debian package build

**Problem description:**

When running the tests on the Debian package with scipy upgraded to 1.10.0, we observe test errors. The errors are IndexErrors.

### Expected behavior:

All tests should pass

### Actual behavior:

A sample from the failing test log is

```
_______________________________ test_uniform_de ________________________________

kwargs = {}

    def test_uniform_de(**kwargs):
>       _test_uniform(moves.DEMove(), **kwargs)

/usr/lib/python3/dist-packages/emcee/tests/integration/test_de.py:19: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/lib/python3/dist-packages/emcee/tests/integration/test_proposal.py:101: in _test_uniform
    ks, _ = stats.kstest(samps[::100], "uniform")
/usr/lib/python3/dist-packages/scipy/_lib/_util.py:700: in wrapper
    return fun(*args, **kwargs)
/usr/lib/python3/dist-packages/scipy/stats/_stats_py.py:8383: in kstest
    return ks_1samp(xvals, cdf, args=args, alternative=alternative,
/usr/lib/python3/dist-packages/scipy/_lib/_util.py:700: in wrapper
    return fun(*args, **kwargs)
/usr/lib/python3/dist-packages/scipy/stats/_stats_py.py:7759: in ks_1samp
    Dplus, dplus_location = _compute_dplus(cdfvals, x)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cdfvals = array([[0.3753341 ],
       [0.        ],
       [0.        ],
       [0.        ],
       [0.        ],
       [0.168...[0.89123376],
       [1.        ],
       [0.55866734],
       [0.74500648],
       [0.        ],
       [0.        ]])
x = array([[ 0.3753341 ],
       [-1.0110354 ],
       [-0.56077189],
       [-0.90308162],
       [-0.99837366],
       [...123376],
       [ 2.13529302],
       [ 0.55866734],
       [ 0.74500648],
       [-0.65506003],
       [-0.83396273]])

    def _compute_dplus(cdfvals, x):
        """…"""
        n = len(cdfvals)
        dplus = (np.arange(1.0, n + 1) / n - cdfvals)
        amax = dplus.argmax()
>       loc_max = x[amax]
E       IndexError: index 1279 is out of bounds for axis 0 with size 640

/usr/lib/python3/dist-packages/scipy/stats/_stats_py.py:7586: IndexError
```

### What have you tried so far?:

--

### Minimal example:

```shell
pytest-3 --pyargs emcee
```



Discussion / hints:

Fix patch:
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index d6287f7a..95dd248a 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -1,26 +1,20 @@
-
 repos:
-- repo: https://github.com/pre-commit/pre-commit-hooks
-  rev: v4.4.0
-  hooks:
-  - id: trailing-whitespace
-  - id: end-of-file-fixer
-  - id: debug-statements
-
-- repo: https://github.com/PyCQA/isort
-  rev: "5.11.4"
-  hooks:
-  - id: isort
-    args: []
-    additional_dependencies: [toml]
-    exclude: docs/tutorials
+  - repo: https://github.com/pre-commit/pre-commit-hooks
+    rev: v4.4.0
+    hooks:
+      - id: trailing-whitespace
+      - id: end-of-file-fixer
+      - id: debug-statements
 
-- repo: https://github.com/psf/black
-  rev: "22.12.0"
-  hooks:
-  - id: black
+  - repo: https://github.com/PyCQA/isort
+    rev: "5.11.4"
+    hooks:
+      - id: isort
+        args: []
+        additional_dependencies: [toml]
+        exclude: docs/tutorials
 
-- repo: https://github.com/dfm/black_nbconvert
-  rev: v0.4.0
-  hooks:
-  - id: black_nbconvert
+  - repo: https://github.com/psf/black
+    rev: "22.12.0"
+    hooks:
+      - id: black-jupyter
diff --git a/docs/tutorials/parallel.ipynb b/docs/tutorials/parallel.ipynb
index cb2296ba..34a4945f 100644
--- a/docs/tutorials/parallel.ipynb
+++ b/docs/tutorials/parallel.ipynb
@@ -255,7 +255,8 @@
    ],
    "source": [
     "with open(\"script.py\", \"w\") as f:\n",
-    "    f.write(\"\"\"\n",
+    "    f.write(\n",
+    "        \"\"\"\n",
     "import sys\n",
     "import time\n",
     "import emcee\n",
@@ -284,7 +285,8 @@
     "    sampler.run_mcmc(initial, nsteps)\n",
     "    end = time.time()\n",
     "    print(end - start)\n",
-    "\"\"\")\n",
+    "\"\"\"\n",
+    "    )\n",
     "\n",
     "mpi_time = !mpiexec -n {ncpu} python script.py\n",
     "mpi_time = float(mpi_time[0])\n",


Test patch:
diff --git a/src/emcee/tests/integration/test_proposal.py b/src/emcee/tests/integration/test_proposal.py
index 0427af7b..8138b516 100644
--- a/src/emcee/tests/integration/test_proposal.py
+++ b/src/emcee/tests/integration/test_proposal.py
@@ -98,5 +98,5 @@ def _test_uniform(proposal, nwalkers=32, nsteps=2000, seed=1234):
         # Check that the resulting chain "fails" the K-S test.
         samps = sampler.get_chain(flat=True)
         np.random.shuffle(samps)
-        ks, _ = stats.kstest(samps[::100], "uniform")
+        ks, _ = stats.kstest(samps[::100, 0], "uniform")
         assert ks > 0.1, "The K-S test failed"