Skip to content

Investigate Failed Test in test_motifs.py #1171

Description

@seanlaw
STUMPY_SEED=462698499 NUMBA_DISABLE_JIT=1 NUMBA_ENABLE_CUDASIM=1 pixi exec --spec black=26.5.1 --spec coverage=7.15.2 --spec dask=2026.7.1 --spec distributed=2026.7.1 --spec flake8=7.3.0 --spec isort=8.0.1 --spec numba=0.66.0 --spec numpy=2.4.6 --spec pandas=3.0.5 --spec polars=1.43.2 --spec pytest=9.1.1 --spec scipy=1.18.0 ./test.sh custom 1 tests/test_motifs.py

This test is failing here. It would be good to understand why this is happening and how best to fix it without compromising the test

=================================== FAILURES ===================================
_________________________________ test_motifs __________________________________

    def test_motifs():
        T = rng.RNG.rand(64)
        m = 3
    
        max_motifs = 3
        max_matches = 4
        max_distance = np.inf
        cutoff = np.inf
    
        # naive
        # `max_distance` and `cutoff` are hard-coded, and set to np.inf.
        ref_distances, ref_indices = naive_motifs(T, m, max_motifs, max_matches)
    
        # performant
        mp = naive.stump(T, m, row_wise=True)
        comp_distance, comp_indices = motifs(
            T,
            mp[:, 0].astype(np.float64),
            min_neighbors=1,
            max_distance=max_distance,
            cutoff=cutoff,
            max_matches=max_matches,
            max_motifs=max_motifs,
        )
    
        npt.assert_almost_equal(ref_indices, comp_indices)
>       npt.assert_almost_equal(ref_distances, comp_distance)
E       AssertionError: 
E       Arrays are not almost equal to 7 decimals
E       
E       Mismatched elements: 1 / 12 (8.33%)
E       Mismatch at index:
E        [0, 1]: 9.35810366834369e-07 (ACTUAL), 1.3102010687964719e-06 (DESIRED)
E       Max absolute difference among violations: 3.74390702e-07
E       Max relative difference among violations: 0.28575057
E        ACTUAL: array([[0.0000000e+00, 9.3581037e-07, 2.3419014e-01, 5.2195509e-01],
E              [0.0000000e+00, 6.9339867e-04, 6.7135066e-03, 2.2566633e-02],
E              [0.0000000e+00, 8.3248216e-04, 9.2865913e-02, 1.7967654e-01]])
E        DESIRED: array([[0.0000000e+00, 1.3102011e-06, 2.3419014e-01, 5.2195509e-01],
E              [0.0000000e+00, 6.9339868e-04, 6.7135066e-03, 2.2566633e-02],
E              [0.0000000e+00, 8.3248216e-04, 9.2865913e-02, 1.7967654e-01]])

tests/test_motifs.py:619: AssertionError
========================= 1 failed, 21 passed in 0.23s =========================
Error: Test execution encountered exit code 1
Error: Process completed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions