Skip to content

equiv tool

Use equiv to prove that a refactor of data code keeps its result, as xpd equiv does. It runs the two scripts with the project's Python, each in its own process, and compares the result that each one leaves. A refactor is done when it returns equivalent: true. The scripts run as they are, so they can do whatever a Python script does.

equiv(old, new)
  • May change files
  • May overwrite what is there
  • A second call may do more
  • Runs code that may reach outside the project

Tags: data, refactor.

The server gives the agent this description of the tool.

Run two scripts with the project's Python, each in its own process, and check that they leave an equal result (DataFrames and Series with pandas.testing, anything else with numpy.testing). A refactor of data logic is done when this says equivalent: true. Both scripts must assign result, and pickle must be able to save it. Needs pandas in the project's Python.

Type: string. Required.

The script before the refactor, inside the project root.

Type: string. Required.

The script after the refactor, inside the project root.

Whether two scripts leave an equal result.

Field Type Required Default Description
equivalent boolean yes
detail string or null no null How the results differ.
{"old":"samples/equiv/old.py","new":"samples/equiv/wrong.py"}
{"equivalent":false,"detail":"DataFrame.iloc[:, 2] (column name=\"w\") are different\n\nDataFrame.iloc[:, 2] (column name=\"w\") values are different (100.0 %)\n[index]: [0, 1, 2]\n[left]: [2, 4, 6]\n[right]: [3, 6, 9]"}

A script that fails, exits, or leaves no result that pickle can save makes the call fail with the script's error. So does a project Python without pandas.