What the agent does
SciPy 1.12.0, released in January 2024, deprecated scipy.integrate.simps with DeprecationWarning: 'scipy.integrate.simps' is deprecated in favour of 'scipy.integrate.simpson' and will be removed in SciPy 1.14.0, and 1.14.0, released that June, removed it. On the 1.17.1 a fresh install resolves today, from scipy.integrate import simps raises ImportError: cannot import name 'simps' from 'scipy.integrate', with the hint Did you mean: 'simpson'?. simpson computes the same integral: on eleven points of x squared between 0 and 1 both return 0.3333. One argument did not survive the rename: simpson on 1.17.1 refuses even=, so a call that passed it needs a decision, not a rename.
benmaier/tacoma, a C++ and Python library for temporal contact networks, is a clear case. Its setup.py lists pybind11>=2.0.0, wget, numpy, scipy and lmfit without versions and builds a _tacoma extension with pybind11, so installing it means a C++ compiler and Python headers, and pip install ./tacoma from the README. tacoma/__init__.py imports _tacoma, .api, .data_io and .tools, none of which touch simps, so import tacoma succeeds on SciPy 1.17.1. The break is one module in: tacoma/flockwork.py and tacoma/edgeactivity.py both have from scipy.integrate import simps at line 12, flockwork.py line 720 calls simps(dist(k)[:, None] * distro, x=k, axis=0), and edgeactivity.py never calls it at all. tacoma/load_model_parameters.py imports flockwork, the docs index lists tacoma.flockwork as a reference page, and sandbox/simple_flockwork.py opens with from tacoma.flockwork import flockwork_P. Anyone following the modelling docs hits the ImportError on their first from tacoma.flockwork import.
The agent reproduces that on a clean environment: it installs a compiler with sudo apt-get install -y g++, uses a Python that ships its headers, builds the package with pip install ., confirms import tacoma passes and import tacoma.flockwork fails, then installs scipy==1.13.1 to show the same import passing with the deprecation warning quoted above, which dates the breakage to 1.14.0. It then changes each import by what it is used for: in flockwork.py the import becomes from scipy.integrate import simpson and line 720 calls simpson(..., x=k, axis=0) with the same keyword arguments; in edgeactivity.py the unused import is deleted. Any call that passed even= would be listed with the two integration choices the old keyword switched between, for the author to pick.
Then it rebuilds, imports both modules on 1.17.1, and runs sandbox/simple_flockwork.py, which builds a flockwork of a hundred nodes, as the smallest script in the repository that exercises the changed module. The agent does not pin scipy<1.14 in setup.py: that would stop every user of the library from installing a current SciPy to save a one-word rename.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "This package fails with \"ImportError: cannot import name 'simps' from 'scipy.integrate'\" after SciPy was installed fresh. Read setup.py, pyproject.toml and any requirements files and report how scipy is pinned. Create a clean virtual environment on a current Python, install any build tools the package needs (a C++ compiler and Python headers for a pybind11 or Cython extension), install the package from source, and report the scipy version that was resolved. Import the package and each of its modules and save the first traceback. Search every .py file for simps and list each import and call with its file and line, whether the call passes even=, and whether the import is used at all. Replace simps with simpson keeping the x= and axis= arguments, delete unused imports, and for any call that passed even= stop and list it with the choice it implies instead of guessing. Do not pin scipy below 1.14. Rebuild, import every module again, and run the smallest example script or test that exercises the changed module. Open a pull request with the resolved versions, the list of changed lines, and the import and example run that now succeed.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
A pull request that renames an import and one call in flockwork.py and deletes a dead import in edgeactivity.py, three lines in all. The description lists the SciPy version a clean install resolved, the import that failed and the one that passed, the 1.13.1 deprecation warning that names 1.14.0 as the removal, every simps found in the repository with its file and line, and the example script that runs after the rebuild.
What a reviewer checks is the arguments. simpson takes x= and axis= exactly as simps did, so a call that passes only those is a rename with no numerical change, and the description says that for line 720. A call that passed even= is listed, not changed, because 1.17.1's simpson has no such keyword and the two behaviours it chose between are a numerical decision for the author.
The pull request also records what it took to build: the compiler and headers the pybind11 extension needed, so a reviewer on a clean machine can repeat the install without rediscovering it.
Run it on every Monday morning
A library with unpinned install_requires breaks for its users on an install day, not on a commit day. Give the Project an automation with a schedule trigger, for example the cron expression 0 7 * * 1 in your timezone, and a prompt that tells the agent to build the package from source in a clean environment, import every module, run the smallest example, and open a pull request only when an import fails on a name a new release removed. On a week when nothing broke, the run ends with a one-line answer and no pull request.
For a lab's set of scientific packages that share this SciPy dependency, start the request above once per repository from a script with an API key, and read each session's pr_url when its run.completed webhook arrives. Each run compiles in its own sandbox, and runs past the key's max_concurrent limit are accepted and wait as queued.
The use case this job follows, with its automation and trigger: Fix a bug from an alert.
Why run it on Rush?
The rename is one word. The work is the build: a compiler, Python headers, a pybind11 extension, and then the import of every module rather than just the package, because import tacoma is green while import tacoma.flockwork is not. An agent in a sandbox installs the toolchain, builds twice, before and after, and runs the example, and the session keeps the commands and their output.
It also tests the SciPy a user gets. A workstation that has had SciPy 1.10 since the paper never raises this error; a sandbox installs 1.17.1, which is where the library's own users are.
Frequently asked questions
Is simpson the same as simps?
Yes, for calls that pass the array, x= and axis=: both give 0.3333 for x squared on eleven points between 0 and 1. simps was the old alias, deprecated in 1.12.0 and removed in 1.14.0. The one difference is even=, which simpson no longer accepts on 1.17.1.
Why does import tacoma work but import tacoma.flockwork not?
Because tacoma/__init__.py imports only api, data_io and tools, none of which use simps. The two modules that do, flockwork and edgeactivity, are imported by name, by load_model_parameters.py, and by the examples and docs. The agent imports every module, not just the package, to find them.
Can I pin scipy below 1.14 instead?
A pin in install_requires constrains everyone who installs the library, and 1.13.1 already warns on every call. The request above tells the agent not to pin; the change is three lines.
My call passes even='avg'. What happens?
The agent lists it rather than rewriting it. simpson on 1.17.1 raises TypeError: simpson() got an unexpected keyword argument 'even', and the old keyword chose how an even number of samples was handled, which is a numerical decision the pull request puts in front of you.
Does the agent need a compiler?
For this fixture, yes: the package builds a pybind11 extension. The agent installs g++ with apt in its sandbox and uses a Python that ships headers, and the pull request records both so a reviewer can repeat the build.
More SciPy jobs
More jobs like this: Fix a bug from an alert
- Fix "ImportError: cannot import name 'TextField' from 'wtforms'" in WTForms 3 (WTForms)
- Fix "ImportError: cannot import name 'triu' from 'scipy.linalg'" in Gensim (Gensim)
- Fix "ImportError: cannot import name '_unicodefun' from 'click'" in Black (Black)
- Fix "ImportError: cannot import name 'url_decode' from 'werkzeug.urls'" with Flask-Login 0.6.2 (Flask-Login)