From c4b029601ec705a6d97c2097cad8481246c90e8d Mon Sep 17 00:00:00 2001 From: Wei Kang Date: Sat, 29 Jun 2024 17:30:50 -0500 Subject: [PATCH 1/5] (ci) doctest only on ubuntu latest --- .github/workflows/tests.yml | 17 ++++++++++++++--- ci/311-DEV.yaml | 11 +++++++++++ ci/311.yaml | 6 ------ 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd515ef..0c8a680 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -69,9 +69,20 @@ jobs: run: 'python -c "import geopandas; geopandas.show_versions();"' if: contains(matrix.environment-file, 'DEV') - - name: run tests - run: pytest giddy --cov giddy -v -n auto -r a --doctest-modules --color yes --cov-report term-missing --cov-report xml - + - name: run pytest + run: pytest giddy -r a -v -n auto --cov giddy --cov-report xml --color yes --cov-append --cov-report term-missing + + - name: run docstring tests + if: contains(matrix.environment-file, '311-DEV') && contains(matrix.os, 'ubuntu') + run: | + pytest \ + -v \ + -r a \ + -n auto \ + --color yes \ + --cov giddy --cov-report xml --cov-append \ + --doctest-only giddy + - name: codecov uses: codecov/codecov-action@v3 with: diff --git a/ci/311-DEV.yaml b/ci/311-DEV.yaml index 77582ab..dfba346 100644 --- a/ci/311-DEV.yaml +++ b/ci/311-DEV.yaml @@ -8,6 +8,10 @@ dependencies: - pip - quantecon>=0.4.7 - scipy>=1.3.0 + - esda>=2.1.1 + - libpysal>=4.0.1 + - mapclassify>=2.1.1 + - splot # testing - codecov - ipywidgets @@ -16,3 +20,10 @@ dependencies: - pytest - pytest-cov - pytest-xdist + - pytest-doctestplus + # docs (this env only) + - nbsphinx + - numpydoc + - sphinx>=1.4.3 + - sphinxcontrib-bibtex + - sphinx_bootstrap_theme diff --git a/ci/311.yaml b/ci/311.yaml index bf3e6ab..850a5d3 100644 --- a/ci/311.yaml +++ b/ci/311.yaml @@ -17,9 +17,3 @@ dependencies: - pytest - pytest-cov - pytest-xdist - # docs (this env only) - - nbsphinx - - numpydoc - - sphinx>=1.4.3 - - sphinxcontrib-bibtex - - sphinx_bootstrap_theme From 119935557274d30eba38b2ab3aa9b194f18f1016 Mon Sep 17 00:00:00 2001 From: Wei Kang Date: Sat, 29 Jun 2024 17:35:21 -0500 Subject: [PATCH 2/5] (doctests) update docstring tests -- numpy-2.0 failures --- giddy/markov.py | 6 +++--- giddy/rank.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/giddy/markov.py b/giddy/markov.py index e10c79c..75b7a10 100644 --- a/giddy/markov.py +++ b/giddy/markov.py @@ -1119,7 +1119,7 @@ def chi2(T1, T2): [ 1., 92., 815., 51.], [ 1., 0., 60., 903.]]) >>> chi2(T1,T2) - (23.39728441473295, 0.005363116704861337, 9) + (np.float64(23.39728441473295), np.float64(0.005363116704861337), np.int64(9)) Notes ----- @@ -1468,7 +1468,7 @@ def spillover(self, quadrant=1, neighbors_on=False): >>> lm_random = LISA_Markov(pci, w, permutations=99) >>> r = lm_random.spillover() >>> (r['components'][:, 12] > 0).sum() - 17 + np.int64(17) >>> (r['components'][:, 13]>0).sum() 23 >>> (r['spill_over'][:,12]>0).sum() @@ -2081,7 +2081,7 @@ def sojourn_time(p, summary=True): >>> p = np.array([[.5, .25, .25], [.5, 0, .5],[ 0, 0, 0]]) >>> sojourn_time(p) - Sojourn times are infinite for absorbing states! In this Markov Chain, states [2] are absorbing states. + Sojourn times are infinite for absorbing states! In this Markov Chain, states [np.int64(2)] are absorbing states. array([ 2., 1., inf]) """ # noqa E501 diff --git a/giddy/rank.py b/giddy/rank.py index 4f71f4e..cd6f229 100644 --- a/giddy/rank.py +++ b/giddy/rank.py @@ -469,7 +469,7 @@ class Tau_Local: 0.48387097, 0.93548387, 0.61290323, 0.74193548, 0.41935484, 0.61290323, 0.61290323]) >>> tau_local.tau - 0.6612903225806451 + np.float64(0.6612903225806451) >>> tau_classic = Tau(r[:,0],r[:,1]) >>> tau_classic.tau 0.6612903225806451 @@ -586,7 +586,7 @@ class Tau_Local_Neighbor: array([-1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) >>> (res.tau_ln * res.tau_ln_weights).sum() #global spatial tau - 0.39682539682539675 + np.float64(0.39682539682539675) >>> res1 = SpatialTau(r[:,0],r[:,1],w,permutations=999) >>> res1.tau_spatial 0.3968253968253968 From 2eadad420520b286047b1add6e9dc4d15708b6fa Mon Sep 17 00:00:00 2001 From: Wei Kang Date: Sat, 29 Jun 2024 17:50:03 -0500 Subject: [PATCH 3/5] doctests --- giddy/markov.py | 6 +++--- giddy/rank.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/giddy/markov.py b/giddy/markov.py index 75b7a10..e10c79c 100644 --- a/giddy/markov.py +++ b/giddy/markov.py @@ -1119,7 +1119,7 @@ def chi2(T1, T2): [ 1., 92., 815., 51.], [ 1., 0., 60., 903.]]) >>> chi2(T1,T2) - (np.float64(23.39728441473295), np.float64(0.005363116704861337), np.int64(9)) + (23.39728441473295, 0.005363116704861337, 9) Notes ----- @@ -1468,7 +1468,7 @@ def spillover(self, quadrant=1, neighbors_on=False): >>> lm_random = LISA_Markov(pci, w, permutations=99) >>> r = lm_random.spillover() >>> (r['components'][:, 12] > 0).sum() - np.int64(17) + 17 >>> (r['components'][:, 13]>0).sum() 23 >>> (r['spill_over'][:,12]>0).sum() @@ -2081,7 +2081,7 @@ def sojourn_time(p, summary=True): >>> p = np.array([[.5, .25, .25], [.5, 0, .5],[ 0, 0, 0]]) >>> sojourn_time(p) - Sojourn times are infinite for absorbing states! In this Markov Chain, states [np.int64(2)] are absorbing states. + Sojourn times are infinite for absorbing states! In this Markov Chain, states [2] are absorbing states. array([ 2., 1., inf]) """ # noqa E501 diff --git a/giddy/rank.py b/giddy/rank.py index cd6f229..4f71f4e 100644 --- a/giddy/rank.py +++ b/giddy/rank.py @@ -469,7 +469,7 @@ class Tau_Local: 0.48387097, 0.93548387, 0.61290323, 0.74193548, 0.41935484, 0.61290323, 0.61290323]) >>> tau_local.tau - np.float64(0.6612903225806451) + 0.6612903225806451 >>> tau_classic = Tau(r[:,0],r[:,1]) >>> tau_classic.tau 0.6612903225806451 @@ -586,7 +586,7 @@ class Tau_Local_Neighbor: array([-1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) >>> (res.tau_ln * res.tau_ln_weights).sum() #global spatial tau - np.float64(0.39682539682539675) + 0.39682539682539675 >>> res1 = SpatialTau(r[:,0],r[:,1],w,permutations=999) >>> res1.tau_spatial 0.3968253968253968 From 8d2d2f5e4ea4d58a861235f63eb05632cd4f5529 Mon Sep 17 00:00:00 2001 From: Wei Kang Date: Sat, 29 Jun 2024 18:06:54 -0500 Subject: [PATCH 4/5] continue doctests despite failure --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 0c8a680..452640e 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -81,7 +81,7 @@ jobs: -n auto \ --color yes \ --cov giddy --cov-report xml --cov-append \ - --doctest-only giddy + --doctest-only --doctest-continue-on-failure giddy - name: codecov uses: codecov/codecov-action@v3 From 5297391b10ff626c92b60038930a86f7fc26ab32 Mon Sep 17 00:00:00 2001 From: Wei Kang Date: Sat, 29 Jun 2024 18:14:21 -0500 Subject: [PATCH 5/5] change doctests output --- giddy/markov.py | 16 ++++++++-------- giddy/rank.py | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/giddy/markov.py b/giddy/markov.py index e10c79c..367f252 100644 --- a/giddy/markov.py +++ b/giddy/markov.py @@ -1119,7 +1119,7 @@ def chi2(T1, T2): [ 1., 92., 815., 51.], [ 1., 0., 60., 903.]]) >>> chi2(T1,T2) - (23.39728441473295, 0.005363116704861337, 9) + (np.float64(23.39728441473295), np.float64(0.005363116704861337), np.int64(9)) Notes ----- @@ -1468,20 +1468,20 @@ def spillover(self, quadrant=1, neighbors_on=False): >>> lm_random = LISA_Markov(pci, w, permutations=99) >>> r = lm_random.spillover() >>> (r['components'][:, 12] > 0).sum() - 17 + np.int64(17) >>> (r['components'][:, 13]>0).sum() - 23 + np.int64(23) >>> (r['spill_over'][:,12]>0).sum() - 6 + np.int64(6) Including neighbors of core neighbors >>> rn = lm_random.spillover(neighbors_on=True) >>> (rn['components'][:, 12] > 0).sum() - 26 + np.int64(26) >>> (rn["components"][:, 13] > 0).sum() - 34 + np.int64(34) >>> (rn["spill_over"][:, 12] > 0).sum() - 8 + np.int64(8) """ n, k = self.q.shape @@ -2081,7 +2081,7 @@ def sojourn_time(p, summary=True): >>> p = np.array([[.5, .25, .25], [.5, 0, .5],[ 0, 0, 0]]) >>> sojourn_time(p) - Sojourn times are infinite for absorbing states! In this Markov Chain, states [2] are absorbing states. + Sojourn times are infinite for absorbing states! In this Markov Chain, states [np.int64(2)] are absorbing states. array([ 2., 1., inf]) """ # noqa E501 diff --git a/giddy/rank.py b/giddy/rank.py index 4f71f4e..2141baf 100644 --- a/giddy/rank.py +++ b/giddy/rank.py @@ -469,10 +469,10 @@ class Tau_Local: 0.48387097, 0.93548387, 0.61290323, 0.74193548, 0.41935484, 0.61290323, 0.61290323]) >>> tau_local.tau - 0.6612903225806451 + np.float64(0.6612903225806451) >>> tau_classic = Tau(r[:,0],r[:,1]) >>> tau_classic.tau - 0.6612903225806451 + np.float64(0.6612903225806451) """ @@ -586,10 +586,10 @@ class Tau_Local_Neighbor: array([-1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1]) >>> (res.tau_ln * res.tau_ln_weights).sum() #global spatial tau - 0.39682539682539675 + np.float64(0.39682539682539675) >>> res1 = SpatialTau(r[:,0],r[:,1],w,permutations=999) >>> res1.tau_spatial - 0.3968253968253968 + np.float64(0.3968253968253968) """