Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TestAZP.test_azp_basic_from_w CI failure #386

@jGaboardi

Description

@jGaboardi

TestAZP.test_azp_basic_from_w CI failure.

diagnosis & potential causes

  • Seems to fail intermittently across versions and OSs (fails locally on MacOS) with the same resultant array
  • Could be an issue with the random state?
  • Could be a change in numpy or scipy?

major versions

  • geopandas==0.13.2
  • networkx== 3.1
  • numpy==1.25.0
  • pandas==2.0.2
  • scipy==1.10.1
  • shapely==2.0.1
=========================================================================== FAILURES ============================================================================
_________________________________________________________________ TestAZP.test_azp_basic_from_w _________________________________________________________________
[gw0] darwin -- Python 3.11.4 /Users/user/mambaforge/envs/py311_spopt/bin/python3.11

self = <spopt.tests.test_azp.TestAZP object at 0x162099350>

    def test_azp_basic_from_w(self):
        w = libpysal.weights.Queen.from_dataframe(self.mexico)
        attrs_name = [f"PCGDP{year}" for year in range(1950, 2010, 10)]
        args = (self.mexico, w, attrs_name)
        kwargs = {"n_clusters": 3, "random_state": RANDOM_STATE}
        model = AZP(*args, **kwargs)
        model.solve()
    
>       numpy.testing.assert_array_equal(model.labels_, self.basic_from_w_labels)

spopt/tests/test_azp.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<built-in function eq>, array([0., 0., 0., 0., 1., 1., 1., 2., 0., 1., 1., 0., 0., 2., 2., 2., 2.,
       2., 0., 2., 2., 2., 0., 1., 1., 0., 0., 1., 2., 1., 1., 2.]), [0, 0, 2, 0, 0, 2, ...])
kwds = {'err_msg': '', 'header': 'Arrays are not equal', 'strict': False, 'verbose': True}

    @wraps(func)
    def inner(*args, **kwds):
        with self._recreate_cm():
>           return func(*args, **kwds)
E           AssertionError: 
E           Arrays are not equal
E           
E           Mismatched elements: 27 / 32 (84.4%)
E           Max absolute difference: 2.
E           Max relative difference: 1.
E            x: array([0., 0., 0., 0., 1., 1., 1., 2., 0., 1., 1., 0., 0., 2., 2., 2., 2.,
E                  2., 0., 2., 2., 2., 0., 1., 1., 0., 0., 1., 2., 1., 1., 2.])
E            y: array([0, 0, 2, 0, 0, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1,
E                  0, 0, 0, 2, 2, 2, 0, 0, 0, 1])

../mambaforge/envs/py311_spopt/lib/python3.11/contextlib.py:81: AssertionError
--------------------------------------------------------------------- Captured stdout call ----------------------------------------------------------------------
n_regions_per_comp {0: 3}
comp_label 0
n_regions_in_comp 3
Regions in comp: {0, 1, 2}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions