--- id: pytest-arraydiff version: "0.7.0" license: BSD-3-Clause license_treatment: permissive maintenance: active --- # pytest-arraydiff — pytest plugin to help with comparing array output from tests License: permissive · Maintenance: active · Downloads: 344.3K/mo ## What it is and what it does pytest-arraydiff is a pytest plugin that solves the problem of testing code that produces large numerical arrays—arrays too big to hard-code expected values directly in test assertions. Instead of writing `assert_allclose(result, [1, 2, 3])` for megabyte-sized outputs, you mark a test function with `@pytest.mark.array_compare`, have it return a numpy array or pandas DataFrame, and the plugin handles the rest. On first run, you generate reference files in your chosen format (plain text, FITS, or HDF5); on subsequent runs, the plugin compares new outputs to those references within configurable tolerances. The plugin integrates directly into pytest's test discovery and reporting, so failures show side-by-side diffs of the generated and reference arrays. It's designed for scientific and data-heavy test suites where manual validation of large outputs is impractical, and where you want regression detection without maintaining brittle hard-coded assertions. Use it for: - Regression testing for numerical simulation or data processing pipelines that produce large arrays. - Validating scientific code outputs (e.g., astronomy, physics, machine learning) against known-good reference data. - Testing pandas DataFrame transformations by storing and comparing output DataFrames in HDF5 format. - Detecting unintended changes in array-producing functions across refactors or dependency updates. - Storing FITS format reference data for astronomical or imaging test suites using astropy. - Comparing multi-dimensional numpy arrays with floating-point tolerance thresholds to avoid brittle exact-match tests. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. A pytest plugin that generates and compares numpy arrays (and related objects like pandas DataFrames) produced during tests against stored reference files, with support for text, FITS, and HDF5 formats. Yes. This is a mature, actively maintained plugin (last release 73 days ago, no vulnerabilities) that solves a real problem in numerical testing. Install friction is minimal, the license is permissive, and it integrates seamlessly into pytest workflows. Recommended for any project with large array outputs that need regression testing. ## Install pip install pytest-arraydiff uv add pytest-arraydiff poetry add pytest-arraydiff ## Installing pytest-arraydiff Before you install: Low friction install with just pytest and numpy as runtime dependencies. The package is actively maintained with a recent release and no known vulnerabilities. License in practice: BSD-3-Clause is a permissive license; you can use this package freely in commercial or private projects with minimal restrictions. Quickstart: pip install pytest-arraydiff import pytest import numpy as np @pytest.mark.array_compare def test_succeeds(): return np.arange(3 * 5 * 4).reshape((3, 5, 4)) # Generate reference: py.test --arraydiff-generate-path=reference # Compare against reference: py.test --arraydiff Requires Python 3.9 or later; pytest and numpy must be installed. Verify before relying: - Whether pandas and astropy are optional or required for HDF5 and FITS format support respectively. - Performance characteristics when comparing very large arrays or many test files. ## Package facts - License: BSD-3-Clause (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 344.3K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags pytest array comparison testing, numpy array regression testing, test output array validation, pytest reference file generation, array diff testing plugin, numpy test fixtures, large array test comparison, numpy-testing, regression-testing, scientific-computing [View on SkillFed](https://skillfed.io/packages/pytest-arraydiff) · [View on PyPI](https://pypi.org/project/pytest-arraydiff/)