Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfleis committed Jan 18, 2025
1 parent 04b32ca commit 47022e5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
4 changes: 3 additions & 1 deletion esda/moran.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,9 @@ def plot_moran_facet(
):
"""
Moran Facet visualization.
Includes BV Morans and Global Morans on the diagonal.

A matrix containing bivariate Moran plots between all pairs of variables present in
the ``moran_matrix`` dictionary. On the diagonal contains global Moran plot.

Parameters
----------
Expand Down
25 changes: 23 additions & 2 deletions esda/tests/test_moran.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ def test_Moran_plot_scatter_args(self, w):
w,
)

ax = m.plot_scatter(scatter_kwds=dict(color='blue'), fitline_kwds=dict(color='pink'))
ax = m.plot_scatter(
scatter_kwds=dict(color="blue"), fitline_kwds=dict(color="pink")
)

# test scatter
np.testing.assert_array_almost_equal(
Expand All @@ -256,7 +258,6 @@ def test_Moran_plot_scatter_args(self, w):
assert l.get_color() == "pink"



class TestMoranRate:
def setup_method(self):
f = libpysal.io.open(libpysal.examples.get_path("sids2.dbf"))
Expand Down Expand Up @@ -297,6 +298,26 @@ def test_Moran_BV_matrix(self, w):
np.testing.assert_allclose(res[(0, 1)].I, 0.19362610652874668)
np.testing.assert_allclose(res[(3, 0)].I, 0.37701382542927858)

@parametrize_sids
def test_plot_moran_facet(self, w):
matrix = moran.Moran_BV_matrix(self.vars, w, varnames=self.names)
axes = moran.plot_moran_facet(matrix)
assert axes.shape == (4, 4)

assert axes[0][0].spines["left"].get_visible()
assert not axes[0][0].spines["bottom"].get_visible()
assert axes[3][0].spines["left"].get_visible()
assert axes[3][0].spines["bottom"].get_visible()
assert not axes[3][1].spines["left"].get_visible()
assert axes[3][1].spines["bottom"].get_visible()
assert not axes[1][1].spines["left"].get_visible()
assert not axes[1][1].spines["bottom"].get_visible()

np.testing.assert_array_almost_equal(
axes[1][1].get_facecolor(),
(0.8509803921568627, 0.8509803921568627, 0.8509803921568627, 1.0),
)


class TestMoranLocal:
def setup_method(self):
Expand Down

0 comments on commit 47022e5

Please sign in to comment.