From 43f76db979d577417359c42a9b55f21826580798 Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Mon, 18 Nov 2024 17:07:17 -0500 Subject: [PATCH 01/12] [ENH] add pytest configuration to skip data-fetching tests --- netneurotools/datasets/tests/conftest.py | 28 ++++++++++++++++++++++ netneurotools/datasets/tests/test_fetch.py | 3 +++ 2 files changed, 31 insertions(+) create mode 100644 netneurotools/datasets/tests/conftest.py diff --git a/netneurotools/datasets/tests/conftest.py b/netneurotools/datasets/tests/conftest.py new file mode 100644 index 0000000..e003d9e --- /dev/null +++ b/netneurotools/datasets/tests/conftest.py @@ -0,0 +1,28 @@ +"""Config file for pytest fixtures.""" + +import pytest + + +def pytest_addoption(parser): + """Add option to skip tests that fetch data.""" + parser.addoption( + "--no_fetch", + action="store_true", + default=False, + help="run tests that fetches data, could be slow" + ) + + +def pytest_configure(config): + """Add markers for tests that fetch data.""" + config.addinivalue_line( + "markers", "test_fetch: run tests that fetches data, could be slow") + + +def pytest_collection_modifyitems(config, items): + """Skip tests that fetch data if --no_fetch option is used.""" + if config.getoption("--no_fetch"): + skip_no_fetch = pytest.mark.skip(reason="remove --no_fetch option to run") + for item in items: + if "test_fetch" in item.keywords: + item.add_marker(skip_no_fetch) diff --git a/netneurotools/datasets/tests/test_fetch.py b/netneurotools/datasets/tests/test_fetch.py index 0447a0c..8404a93 100644 --- a/netneurotools/datasets/tests/test_fetch.py +++ b/netneurotools/datasets/tests/test_fetch.py @@ -7,6 +7,7 @@ from netneurotools import datasets +@pytest.mark.test_fetch class TestFetchTemplate: """Test fetching of template datasets.""" @@ -106,6 +107,7 @@ def test_fetch_yerkes19(self, tmpdir): ) +@pytest.mark.test_fetch class TestFetchAtlas: """Test fetching of atlas datasets.""" @@ -180,6 +182,7 @@ def test_fetch_voneconomo(self, tmpdir): assert isinstance(vek.get("info"), Path) +@pytest.mark.test_fetch class TestFetchProject: """Test fetching of project datasets.""" From d98a7416b04733915c373f1fe4520b7d56e14924 Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Mon, 18 Nov 2024 17:07:28 -0500 Subject: [PATCH 02/12] [ENH] update ruff style check output format in GitHub Actions workflow --- .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 ca61230..88c251d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,7 +24,7 @@ jobs: python -m pip install --upgrade pip python -m pip install ruff - name: Run style checks - run: ruff check . + run: ruff check --output-format=github . run_tests: needs: check_style From 4cb69fd3bb1b23a440bf4c36b6cedc6f8a8baaac Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Mon, 18 Nov 2024 17:16:51 -0500 Subject: [PATCH 03/12] [ENH] add conditional check for docs in GitHub Actions workflow --- .github/workflows/docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c700a36..ef645eb 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -13,6 +13,7 @@ permissions: jobs: deploy_page: + if: github.repository_owner == 'netneurolab' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From a61043ae24c9ab4c31f9fc439885f72d54da3577 Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Mon, 18 Nov 2024 17:46:00 -0500 Subject: [PATCH 04/12] [ENH] update plot_point_brain function to return axes object along with figure --- netneurotools/plotting/mpl_plotters.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/netneurotools/plotting/mpl_plotters.py b/netneurotools/plotting/mpl_plotters.py index e5637dd..c26aad8 100644 --- a/netneurotools/plotting/mpl_plotters.py +++ b/netneurotools/plotting/mpl_plotters.py @@ -232,6 +232,9 @@ def plot_point_brain(data, coords, views=None, views_orientation='vertical', Returns ------- fig : :class:`matplotlib.figure.Figure` + Figure object for the plot + axes : :class:`matplotlib.axes.Axes` + Axes object for the plot """ _views = dict(sagittal=(0, 180), sag=(0, 180), axial=(90, 180), ax=(90, 180), @@ -284,7 +287,7 @@ def plot_point_brain(data, coords, views=None, views_orientation='vertical', drawedges=False, shrink=0.7) cbar.outline.set_linewidth(0) - return fig + return fig, axes def plot_simple_brain(): From caa6073aeebf63ea01446b8f8961ec2404a5bada Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Mon, 18 Nov 2024 17:46:11 -0500 Subject: [PATCH 05/12] [ENH] add PyVista documentation link and update return type annotation in pv_plot_surface function --- docs/conf.py | 1 + netneurotools/plotting/pyvista_plotters.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/conf.py b/docs/conf.py index a5890a1..478cdf7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -115,6 +115,7 @@ 'scipy': ('https://docs.scipy.org/doc/scipy/reference', None), 'sklearn': ('https://scikit-learn.org/stable', None), 'pandas': ('https://pandas.pydata.org/pandas-docs/stable', None), + 'pyvista': ('https://docs.pyvista.org/', None), } doctest_global_setup = """\ diff --git a/netneurotools/plotting/pyvista_plotters.py b/netneurotools/plotting/pyvista_plotters.py index e711a5d..0012f81 100644 --- a/netneurotools/plotting/pyvista_plotters.py +++ b/netneurotools/plotting/pyvista_plotters.py @@ -160,7 +160,7 @@ def pv_plot_surface( Returns ------- - pl : PyVista.Plotter + pl : :class:`pyvista.Plotter` PyVista plotter object. Other Parameters From 092c6291fbaed892aef2c5649d8e74c7f973e01e Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Mon, 18 Nov 2024 18:06:54 -0500 Subject: [PATCH 06/12] [ENH] update dataset citations and add original data source references in fetch functions --- netneurotools/datasets/fetch_project.py | 41 ++++++++++--- netneurotools/datasets/netneurotools.bib | 74 ++++++++++++++++++++++++ netneurotools/datasets/references.json | 28 +++++---- 3 files changed, 124 insertions(+), 19 deletions(-) diff --git a/netneurotools/datasets/fetch_project.py b/netneurotools/datasets/fetch_project.py index 4462307..976a4fc 100644 --- a/netneurotools/datasets/fetch_project.py +++ b/netneurotools/datasets/fetch_project.py @@ -189,6 +189,11 @@ def fetch_hansen_receptors(force=False, data_dir=None, verbose=1): If you used this data, please cite [1]_. + .. important:: + If you use this dataset, please also cite the original data sources. + See the original publication or `neuromaps `_ + for more information. + Returns ------- filenames : :class:`sklearn.utils.Bunch` @@ -208,7 +213,12 @@ def fetch_hansen_receptors(force=False, data_dir=None, verbose=1): References ---------- - .. [1] + .. [1] Justine Y Hansen, Golia Shafiei, Ross D Markello, Kelly Smart, Sylvia + ML Cox, Martin N\u00f8rgaard, Vincent Beliveau, Yanjun Wu, + Jean-Dominique Gallezot, \u00c9tienne Aumont, and others. Mapping + neurotransmitter systems to the structural and functional organization + of the human neocortex. Nature neuroscience, 25(11):1569\u20131581, + 2022. """ dataset_name = "ds-hansen_receptors" _get_reference_info(dataset_name, verbose=verbose) @@ -244,7 +254,10 @@ def fetch_hansen_genescognition(force=False, data_dir=None, verbose=1): References ---------- - .. [1] + .. [1] Justine Y Hansen, Ross D Markello, Jacob W Vogel, Jakob Seidlitz, + Danilo Bzdok, and Bratislav Misic. Mapping gene transcription and + neurocognition across human neocortex. Nature Human Behaviour, + 5(9):1240\u20131250, 2021. """ dataset_name = "ds-hansen_genescognition" _get_reference_info(dataset_name, verbose=verbose) @@ -280,7 +293,10 @@ def fetch_hansen_brainstemfc(force=False, data_dir=None, verbose=1): References ---------- - .. [1] + .. [1] Justine Y Hansen, Simone Cauzzo, Kavita Singh, Mar\u00eda Guadalupe + Garc\u00eda-Gomar, James M Shine, Marta Bianciardi, and Bratislav Misic. + Integrating brainstem and cortical functional architectures. Nature + Neuroscience, pages 1\u201312, 2024. """ dataset_name = "ds-hansen_brainstemfc" _get_reference_info(dataset_name, verbose=verbose) @@ -316,7 +332,10 @@ def fetch_shafiei_megfmrimapping(force=False, data_dir=None, verbose=1): References ---------- - .. [1] + .. [1] Golia Shafiei, Sylvain Baillet, and Bratislav Misic. Human + electromagnetic and haemodynamic networks systematically converge in + unimodal cortex and diverge in transmodal cortex. PLoS biology, + 20(8):e3001735, 2022. """ dataset_name = "ds-shafiei_megfmrimapping" _get_reference_info(dataset_name, verbose=verbose) @@ -352,7 +371,10 @@ def fetch_shafiei_megdynamics(force=False, data_dir=None, verbose=1): References ---------- - .. [1] + .. [1] Golia Shafiei, Ben D Fulcher, Bradley Voytek, Theodore D + Satterthwaite, Sylvain Baillet, and Bratislav Misic. Neurophysiological + signatures of cortical micro-architecture. Nature communications, + 14(1):6000, 2023. """ dataset_name = "ds-shafiei_megdynamics" _get_reference_info(dataset_name, verbose=verbose) @@ -367,7 +389,7 @@ def fetch_suarez_mami(force=False, data_dir=None, verbose=1): This dataset contains - If you used this data, please cite [1]_. + If you used this data, please cite [1]_ and [2]_. Returns ------- @@ -388,7 +410,12 @@ def fetch_suarez_mami(force=False, data_dir=None, verbose=1): References ---------- - .. [1] + .. [1] Laura E Suarez, Yossi Yovel, Martijn P van den Heuvel, Olaf Sporns, + Yaniv Assaf, Guillaume Lajoie, and Bratislav Misic. A connectomics-based + taxonomy of mammals. Elife, 11:e78635, 2022. + .. [2] Yaniv Assaf, Arieli Bouznach, Omri Zomet, Assaf Marom, and Yossi + Yovel. Conservation of brain connectivity and wiring across the + mammalian class. Nature Neuroscience, 23(7):805\u2013808, 2020. """ dataset_name = "ds-suarez_mami" _get_reference_info(dataset_name, verbose=verbose) diff --git a/netneurotools/datasets/netneurotools.bib b/netneurotools/datasets/netneurotools.bib index 2e725c4..2aca059 100644 --- a/netneurotools/datasets/netneurotools.bib +++ b/netneurotools/datasets/netneurotools.bib @@ -262,3 +262,77 @@ @article{markello2022neuromaps year={2022}, publisher={Nature Publishing Group US New York} } + +@article{hansen2021mapping, + title={Mapping gene transcription and neurocognition across human neocortex}, + author={Hansen, Justine Y and Markello, Ross D and Vogel, Jacob W and Seidlitz, Jakob and Bzdok, Danilo and Misic, Bratislav}, + journal={Nature Human Behaviour}, + volume={5}, + number={9}, + pages={1240--1250}, + year={2021}, + publisher={Nature Publishing Group UK London} +} + +@article{hansen2022mapping, + title={Mapping neurotransmitter systems to the structural and functional organization of the human neocortex}, + author={Hansen, Justine Y and Shafiei, Golia and Markello, Ross D and Smart, Kelly and Cox, Sylvia ML and N{\o}rgaard, Martin and Beliveau, Vincent and Wu, Yanjun and Gallezot, Jean-Dominique and Aumont, {\'E}tienne and others}, + journal={Nature neuroscience}, + volume={25}, + number={11}, + pages={1569--1581}, + year={2022}, + publisher={Nature Publishing Group US New York} +} + +@article{hansen2024integrating, + title={Integrating brainstem and cortical functional architectures}, + author={Hansen, Justine Y and Cauzzo, Simone and Singh, Kavita and Garc{\'\i}a-Gomar, Mar{\'\i}a Guadalupe and Shine, James M and Bianciardi, Marta and Misic, Bratislav}, + journal={Nature Neuroscience}, + pages={1--12}, + year={2024}, + publisher={Nature Publishing Group US New York} +} + +@article{shafiei2023neurophysiological, + title={Neurophysiological signatures of cortical micro-architecture}, + author={Shafiei, Golia and Fulcher, Ben D and Voytek, Bradley and Satterthwaite, Theodore D and Baillet, Sylvain and Misic, Bratislav}, + journal={Nature communications}, + volume={14}, + number={1}, + pages={6000}, + year={2023}, + publisher={Nature Publishing Group UK London} +} + +@article{shafiei2022human, + title={Human electromagnetic and haemodynamic networks systematically converge in unimodal cortex and diverge in transmodal cortex}, + author={Shafiei, Golia and Baillet, Sylvain and Misic, Bratislav}, + journal={PLoS biology}, + volume={20}, + number={8}, + pages={e3001735}, + year={2022}, + publisher={Public Library of Science San Francisco, CA USA} +} + +@article{suarez2022connectomics, + title={A connectomics-based taxonomy of mammals}, + author={Suarez, Laura E and Yovel, Yossi and van den Heuvel, Martijn P and Sporns, Olaf and Assaf, Yaniv and Lajoie, Guillaume and Misic, Bratislav}, + journal={Elife}, + volume={11}, + pages={e78635}, + year={2022}, + publisher={eLife Sciences Publications Limited} +} + +@article{assaf2020conservation, + title={Conservation of brain connectivity and wiring across the mammalian class}, + author={Assaf, Yaniv and Bouznach, Arieli and Zomet, Omri and Marom, Assaf and Yovel, Yossi}, + journal={Nature Neuroscience}, + volume={23}, + number={7}, + pages={805--808}, + year={2020}, + publisher={Nature Publishing Group US New York} +} diff --git a/netneurotools/datasets/references.json b/netneurotools/datasets/references.json index fe51a99..c1c818b 100644 --- a/netneurotools/datasets/references.json +++ b/netneurotools/datasets/references.json @@ -276,48 +276,52 @@ "ds-hansen_receptors": { "primary": [ { - "citation": "", - "bibkey": "" + "citation": "Justine Y Hansen, Golia Shafiei, Ross D Markello, Kelly Smart, Sylvia ML Cox, Martin N\u00f8rgaard, Vincent Beliveau, Yanjun Wu, Jean-Dominique Gallezot, \u00c9tienne Aumont, and others. Mapping neurotransmitter systems to the structural and functional organization of the human neocortex. Nature neuroscience, 25(11):1569\u20131581, 2022.", + "bibkey": "hansen2022mapping" } ] }, "ds-hansen_genescognition": { "primary": [ { - "citation": "", - "bibkey": "" + "citation": "Justine Y Hansen, Ross D Markello, Jacob W Vogel, Jakob Seidlitz, Danilo Bzdok, and Bratislav Misic. Mapping gene transcription and neurocognition across human neocortex. Nature Human Behaviour, 5(9):1240\u20131250, 2021.", + "bibkey": "hansen2021mapping" } ] }, "ds-hansen_brainstemfc": { "primary": [ { - "citation": "", - "bibkey": "" + "citation": "Justine Y Hansen, Simone Cauzzo, Kavita Singh, Mar\u00eda Guadalupe Garc\u00eda-Gomar, James M Shine, Marta Bianciardi, and Bratislav Misic. Integrating brainstem and cortical functional architectures. Nature Neuroscience, pages 1\u201312, 2024.", + "bibkey": "hansen2024integrating" } ] }, "ds-shafiei_megfmrimapping": { "primary": [ { - "citation": "", - "bibkey": "" + "citation": "Golia Shafiei, Sylvain Baillet, and Bratislav Misic. Human electromagnetic and haemodynamic networks systematically converge in unimodal cortex and diverge in transmodal cortex. PLoS biology, 20(8):e3001735, 2022.", + "bibkey": "shafiei2022human" } ] }, "ds-shafiei_megdynamics": { "primary": [ { - "citation": "", - "bibkey": "" + "citation": "Golia Shafiei, Ben D Fulcher, Bradley Voytek, Theodore D Satterthwaite, Sylvain Baillet, and Bratislav Misic. Neurophysiological signatures of cortical micro-architecture. Nature communications, 14(1):6000, 2023.", + "bibkey": "shafiei2023neurophysiological" } ] }, "ds-suarez_mami": { "primary": [ { - "citation": "", - "bibkey": "" + "citation": "Laura E Suarez, Yossi Yovel, Martijn P van den Heuvel, Olaf Sporns, Yaniv Assaf, Guillaume Lajoie, and Bratislav Misic. A connectomics-based taxonomy of mammals. Elife, 11:e78635, 2022.", + "bibkey": "suarez2022connectomics" + }, + { + "citation": "Yaniv Assaf, Arieli Bouznach, Omri Zomet, Assaf Marom, and Yossi Yovel. Conservation of brain connectivity and wiring across the mammalian class. Nature Neuroscience, 23(7):805\u2013808, 2020.", + "bibkey": "assaf2020conservation" } ] } From 4c91a5344f1f1d4c8297265306cc8642186a4170 Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Mon, 18 Nov 2024 18:09:23 -0500 Subject: [PATCH 07/12] [ENH] update test for plot_point_brain to assert axes object is returned --- netneurotools/plotting/tests/test_mpl.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netneurotools/plotting/tests/test_mpl.py b/netneurotools/plotting/tests/test_mpl.py index 1d7d79a..3b41b65 100644 --- a/netneurotools/plotting/tests/test_mpl.py +++ b/netneurotools/plotting/tests/test_mpl.py @@ -34,5 +34,6 @@ def test_plot_point_brain(): """Test plot_point_brain function.""" data = np.random.rand(100) coords = np.random.rand(100, 3) - out = plotting.plot_point_brain(data, coords) - assert isinstance(out, plt.Figure) + fig, axes = plotting.plot_point_brain(data, coords) + assert isinstance(fig, plt.Figure) + assert isinstance(axes, np.ndarray) From a204ac2555130dcf8a5809d9b2cb6b5930121474 Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Wed, 20 Nov 2024 13:12:45 -0500 Subject: [PATCH 08/12] [ENH] refactor GitHub Actions workflows and remove unused files for improved test organization --- .codecov.yml | 11 ---- .../workflows/{tests.yml => tests-basic.yml} | 17 ++--- .github/workflows/tests-datasets-fetcher.yml | 65 +++++++++++++++++++ .github/workflows/tests-plotting-pyvista.yml | 46 +++++++++++++ ...wip_plot_spin_test.py => wip_plot_spin.py} | 0 netneurotools/datasets/tests/conftest.py | 28 -------- netneurotools/datasets/tests/test_fetch.py | 6 +- netneurotools/plotting/tests/test_pyvista.py | 7 ++ pyproject.toml | 10 ++- 9 files changed, 136 insertions(+), 54 deletions(-) delete mode 100644 .codecov.yml rename .github/workflows/{tests.yml => tests-basic.yml} (78%) create mode 100644 .github/workflows/tests-datasets-fetcher.yml create mode 100644 .github/workflows/tests-plotting-pyvista.yml rename examples/{wip_plot_spin_test.py => wip_plot_spin.py} (100%) delete mode 100644 netneurotools/datasets/tests/conftest.py diff --git a/.codecov.yml b/.codecov.yml deleted file mode 100644 index fa7b82a..0000000 --- a/.codecov.yml +++ /dev/null @@ -1,11 +0,0 @@ -coverage: - status: - project: - default: - informational: true - patch: - default: - informational: true -comment: false -github_checks: - annotations: false diff --git a/.github/workflows/tests.yml b/.github/workflows/tests-basic.yml similarity index 78% rename from .github/workflows/tests.yml rename to .github/workflows/tests-basic.yml index 88c251d..1b35ce4 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests-basic.yml @@ -6,6 +6,8 @@ on: branches: - main pull_request: + branches: + - main jobs: check_style: @@ -26,7 +28,7 @@ jobs: - name: Run style checks run: ruff check --output-format=github . - run_tests: + run_basic_tests: needs: check_style runs-on: ${{ matrix.os }} strategy: @@ -44,21 +46,14 @@ jobs: python-version: ${{ matrix.python-version }} - name: Display Python version run: python -c "import sys; print(sys.version)" - - name: Install dependencies + - name: Install netneurotools run: | python -m pip install --upgrade pip - python -m pip install pytest pytest-cov - python -m pip install -r requirements.txt - - name: Install netneurotools - run: python -m pip install . + python -m pip install '.[test]' - name: Print netneurotools version run: python -c "import netneurotools; print(netneurotools.__version__)" - name: Run tests - run: pytest --doctest-modules --cov=netneurotools --cov-report=xml --junitxml=junit/test-results.xml --verbose --pyargs netneurotools - - name: Upload coverage - uses: codecov/codecov-action@v5 - with: - files: coverage.xml + run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m "not (fetcher or pyvista pysurfer)" - name: Upload pytest test results uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/tests-datasets-fetcher.yml b/.github/workflows/tests-datasets-fetcher.yml new file mode 100644 index 0000000..d113cdd --- /dev/null +++ b/.github/workflows/tests-datasets-fetcher.yml @@ -0,0 +1,65 @@ +name: netneurotools-tests + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'netneurotools/datasets/**' + pull_request: + branches: + - main + paths: + - 'netneurotools/datasets/**' + +jobs: + check_style: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: '3.12' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install ruff + - name: Run style checks + run: ruff check --output-format=github . + + run_fetcher_tests: + needs: check_style + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ['ubuntu-latest'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install netneurotools + run: | + python -m pip install --upgrade pip + python -m pip install '.[test]' + - name: Print netneurotools version + run: python -c "import netneurotools; print(netneurotools.__version__)" + - name: Run tests + run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m fetcher + - name: Upload pytest test results + uses: actions/upload-artifact@v4 + with: + name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }} + path: junit/test-results.xml diff --git a/.github/workflows/tests-plotting-pyvista.yml b/.github/workflows/tests-plotting-pyvista.yml new file mode 100644 index 0000000..24b832e --- /dev/null +++ b/.github/workflows/tests-plotting-pyvista.yml @@ -0,0 +1,46 @@ +name: netneurotools-tests + +on: + workflow_dispatch: + push: + branches: + - main + paths: + - 'netneurotools/plotting/pyvista_plotters.py' + pull_request: + branches: + - main + paths: + - 'netneurotools/plotting/pyvista_plotters.py' + +jobs: + run_pyvista_tests: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: ['ubuntu-latest'] + python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + - name: Display Python version + run: python -c "import sys; print(sys.version)" + - name: Install netneurotools + run: | + python -m pip install --upgrade pip + python -m pip install '.[test,pyvista]' + - name: Print netneurotools version + run: python -c "import netneurotools; print(netneurotools.__version__)" + - name: Run tests + run: pytest --doctest-modules --cov=netneurotools --cov-report=xml --junitxml=junit/test-results.xml --verbose -m pyvista + - name: Upload pytest test results + uses: actions/upload-artifact@v4 + with: + name: pytest-results-${{ matrix.os }}-${{ matrix.python-version }} + path: junit/test-results.xml diff --git a/examples/wip_plot_spin_test.py b/examples/wip_plot_spin.py similarity index 100% rename from examples/wip_plot_spin_test.py rename to examples/wip_plot_spin.py diff --git a/netneurotools/datasets/tests/conftest.py b/netneurotools/datasets/tests/conftest.py deleted file mode 100644 index e003d9e..0000000 --- a/netneurotools/datasets/tests/conftest.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Config file for pytest fixtures.""" - -import pytest - - -def pytest_addoption(parser): - """Add option to skip tests that fetch data.""" - parser.addoption( - "--no_fetch", - action="store_true", - default=False, - help="run tests that fetches data, could be slow" - ) - - -def pytest_configure(config): - """Add markers for tests that fetch data.""" - config.addinivalue_line( - "markers", "test_fetch: run tests that fetches data, could be slow") - - -def pytest_collection_modifyitems(config, items): - """Skip tests that fetch data if --no_fetch option is used.""" - if config.getoption("--no_fetch"): - skip_no_fetch = pytest.mark.skip(reason="remove --no_fetch option to run") - for item in items: - if "test_fetch" in item.keywords: - item.add_marker(skip_no_fetch) diff --git a/netneurotools/datasets/tests/test_fetch.py b/netneurotools/datasets/tests/test_fetch.py index 8404a93..5669236 100644 --- a/netneurotools/datasets/tests/test_fetch.py +++ b/netneurotools/datasets/tests/test_fetch.py @@ -7,7 +7,7 @@ from netneurotools import datasets -@pytest.mark.test_fetch +@pytest.mark.fetcher class TestFetchTemplate: """Test fetching of template datasets.""" @@ -107,7 +107,7 @@ def test_fetch_yerkes19(self, tmpdir): ) -@pytest.mark.test_fetch +@pytest.mark.fetcher class TestFetchAtlas: """Test fetching of atlas datasets.""" @@ -182,7 +182,7 @@ def test_fetch_voneconomo(self, tmpdir): assert isinstance(vek.get("info"), Path) -@pytest.mark.test_fetch +@pytest.mark.fetcher class TestFetchProject: """Test fetching of project datasets.""" diff --git a/netneurotools/plotting/tests/test_pyvista.py b/netneurotools/plotting/tests/test_pyvista.py index 0b87931..117a0f5 100644 --- a/netneurotools/plotting/tests/test_pyvista.py +++ b/netneurotools/plotting/tests/test_pyvista.py @@ -1 +1,8 @@ """For testing netneurotools.plotting.pyvista_plotters functionality.""" + +import pytest + + +@pytest.mark.pyvista +def test_pyvista_smoke(): + """Test that pyvista is importable.""" diff --git a/pyproject.toml b/pyproject.toml index ad05ca1..2047540 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ dynamic=["version"] [project.optional-dependencies] doc = [ - "sphinx >=2.0, <7.0.0", + "sphinx >=2.0", "sphinx_rtd_theme", "sphinx-gallery" ] @@ -118,6 +118,14 @@ convention = "numpy" "test_*" = ["B011"] "examples/*" = ["E402", "D"] +[tool.pytest.ini_options] +addopts = "--strict-markers" +markers = [ + "fetcher: mark test to fetch data from the internet", + "pyvista: mark test that requires pyvista", + "pysurfer: mark test that requires pysurfer" +] + [tool.coverage.run] source = ["netneurotools"] omit = [ From a60ddb086a24b1d6449a416c1f72d31d231f9249 Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Wed, 20 Nov 2024 13:16:18 -0500 Subject: [PATCH 09/12] [ENH] update GitHub Actions workflows to streamline dataset fetching and reduce Python versions in plotting tests --- .github/workflows/tests-datasets-fetcher.yml | 20 ++++++++++---------- .github/workflows/tests-plotting-pyvista.yml | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/tests-datasets-fetcher.yml b/.github/workflows/tests-datasets-fetcher.yml index d113cdd..b625dc8 100644 --- a/.github/workflows/tests-datasets-fetcher.yml +++ b/.github/workflows/tests-datasets-fetcher.yml @@ -2,16 +2,16 @@ name: netneurotools-tests on: workflow_dispatch: - push: - branches: - - main - paths: - - 'netneurotools/datasets/**' - pull_request: - branches: - - main - paths: - - 'netneurotools/datasets/**' + push: + branches: + - main + paths: + - 'netneurotools/datasets/**' + pull_request: + branches: + - main + paths: + - 'netneurotools/datasets/**' jobs: check_style: diff --git a/.github/workflows/tests-plotting-pyvista.yml b/.github/workflows/tests-plotting-pyvista.yml index 24b832e..b2525a3 100644 --- a/.github/workflows/tests-plotting-pyvista.yml +++ b/.github/workflows/tests-plotting-pyvista.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: os: ['ubuntu-latest'] - python-version: ['3.9', '3.10', '3.11', '3.12', '3.13'] + python-version: ['3.9', '3.10', '3.11', '3.12'] steps: - name: Checkout code uses: actions/checkout@v4 @@ -38,7 +38,7 @@ jobs: - name: Print netneurotools version run: python -c "import netneurotools; print(netneurotools.__version__)" - name: Run tests - run: pytest --doctest-modules --cov=netneurotools --cov-report=xml --junitxml=junit/test-results.xml --verbose -m pyvista + run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m pyvista - name: Upload pytest test results uses: actions/upload-artifact@v4 with: From afb992eab54b7bd9a0f1819c804286f2032a20a4 Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Wed, 20 Nov 2024 13:22:14 -0500 Subject: [PATCH 10/12] [ENH] update GitHub Actions workflows to include netneurotools in pytest commands and modify pytest options in pyproject.toml --- .github/workflows/tests-basic.yml | 2 +- .github/workflows/tests-datasets-fetcher.yml | 21 +------------------- .github/workflows/tests-plotting-pyvista.yml | 2 +- pyproject.toml | 2 +- 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/.github/workflows/tests-basic.yml b/.github/workflows/tests-basic.yml index 1b35ce4..9b5b13e 100644 --- a/.github/workflows/tests-basic.yml +++ b/.github/workflows/tests-basic.yml @@ -53,7 +53,7 @@ jobs: - name: Print netneurotools version run: python -c "import netneurotools; print(netneurotools.__version__)" - name: Run tests - run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m "not (fetcher or pyvista pysurfer)" + run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m "not (fetcher or pyvista pysurfer)" netneurotools - name: Upload pytest test results uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/tests-datasets-fetcher.yml b/.github/workflows/tests-datasets-fetcher.yml index b625dc8..243c98a 100644 --- a/.github/workflows/tests-datasets-fetcher.yml +++ b/.github/workflows/tests-datasets-fetcher.yml @@ -14,26 +14,7 @@ on: - 'netneurotools/datasets/**' jobs: - check_style: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: '3.12' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install ruff - - name: Run style checks - run: ruff check --output-format=github . - run_fetcher_tests: - needs: check_style runs-on: ${{ matrix.os }} strategy: matrix: @@ -57,7 +38,7 @@ jobs: - name: Print netneurotools version run: python -c "import netneurotools; print(netneurotools.__version__)" - name: Run tests - run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m fetcher + run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m fetcher netneurotools - name: Upload pytest test results uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/tests-plotting-pyvista.yml b/.github/workflows/tests-plotting-pyvista.yml index b2525a3..fa66bc8 100644 --- a/.github/workflows/tests-plotting-pyvista.yml +++ b/.github/workflows/tests-plotting-pyvista.yml @@ -38,7 +38,7 @@ jobs: - name: Print netneurotools version run: python -c "import netneurotools; print(netneurotools.__version__)" - name: Run tests - run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m pyvista + run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m pyvista netneurotools - name: Upload pytest test results uses: actions/upload-artifact@v4 with: diff --git a/pyproject.toml b/pyproject.toml index 2047540..2341d4a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -119,7 +119,7 @@ convention = "numpy" "examples/*" = ["E402", "D"] [tool.pytest.ini_options] -addopts = "--strict-markers" +addopts = "--strict-markers --pyargs" markers = [ "fetcher: mark test to fetch data from the internet", "pyvista: mark test that requires pyvista", From d65eec0031a1209fdbb0653defa2b86c6d1af49b Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Wed, 20 Nov 2024 13:26:53 -0500 Subject: [PATCH 11/12] [ENH] update dependencies in pyproject.toml --- pyproject.toml | 3 ++- requirements.txt | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2341d4a..2440bd2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,7 +26,8 @@ dependencies = [ "matplotlib", "scikit-learn", "nibabel >=3.0.0", - "nilearn" + "nilearn", + "tqdm" ] dynamic=["version"] diff --git a/requirements.txt b/requirements.txt index d79d02b..c17067f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ bctpy -matplotlib nibabel nilearn numpy>=1.16 From 8d56d140a35e0dfd90ee8eb309c1ea57d98a7f7d Mon Sep 17 00:00:00 2001 From: Zhen-Qi Liu Date: Wed, 20 Nov 2024 15:51:34 -0500 Subject: [PATCH 12/12] [ENH] update GitHub Actions --- .github/workflows/tests-basic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-basic.yml b/.github/workflows/tests-basic.yml index 9b5b13e..bc2f018 100644 --- a/.github/workflows/tests-basic.yml +++ b/.github/workflows/tests-basic.yml @@ -53,7 +53,7 @@ jobs: - name: Print netneurotools version run: python -c "import netneurotools; print(netneurotools.__version__)" - name: Run tests - run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m "not (fetcher or pyvista pysurfer)" netneurotools + run: pytest --doctest-modules --junitxml=junit/test-results.xml --verbose -m "not (fetcher or pyvista or pysurfer)" netneurotools - name: Upload pytest test results uses: actions/upload-artifact@v4 with: