From c9e232067d5e625e2cac3a506c4db33e77381ddf Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Tue, 30 Jan 2024 14:45:17 +0000 Subject: [PATCH 1/5] Add workflow dispatch to github workflows --- .github/workflows/test_and_deploy.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 286c6a8..ab62ef0 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -3,10 +3,11 @@ name: tests on: push: branches: - - '*' + - 'main' tags: - - '*' + - 'v*' pull_request: + workflow_dispatch: jobs: linting: From 543db476b285c7c59fc30b2b0f63a748becea9de Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 31 Jan 2024 10:42:04 +0000 Subject: [PATCH 2/5] Add authors and ignore vscode configs --- .gitignore | 1 + pyproject.toml | 57 +++++++++++++++++++++----------------------------- 2 files changed, 25 insertions(+), 33 deletions(-) diff --git a/.gitignore b/.gitignore index e16642c..19fa144 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,4 @@ venv.bak/ .idea/ .vs/ *.~lock.* +.vscode/ diff --git a/pyproject.toml b/pyproject.toml index 72ece85..a69158d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,36 +1,35 @@ [project] name = "brainglobe-utils" -authors = [{name = "Adam Tyson", email= "code@adamltyson.com"}] +authors = [{ name = "Adam Tyson", email = "code@adamltyson.com" }] description = "Shared general purpose tools for the BrainGlobe project" readme = "README.md" requires-python = ">=3.9.0" dynamic = ["version"] dependencies = [ - "natsort", - "pandas", - "psutil", - "configobj", - "tqdm", - "PyYAML", - "scipy", - "numpy", - "slurmio", - "tifffile", - "imio", - "bg-atlasapi", + "natsort", + "pandas", + "psutil", + "configobj", + "tqdm", + "PyYAML", + "scipy", + "numpy", + "slurmio", + "tifffile", + "imio", ] -license = {text = "MIT"} +license = { text = "MIT" } classifiers = [ - "Development Status :: 2 - Pre-Alpha", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Operating System :: OS Independent", + "Development Status :: 2 - Pre-Alpha", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Operating System :: OS Independent", ] [project.urls] @@ -40,11 +39,7 @@ source_code = "https://github.com/brainglobe/brainglobe-utils" user_support = "https://github.com/brainglobe/brainglobe-utils/issues" [project.optional-dependencies] -napari = [ - "napari>=0.4.18", - "qtpy", - "superqt" -] +napari = ["napari>=0.4.18", "qtpy", "superqt"] dev = [ "qtpy", @@ -60,16 +55,12 @@ dev = [ "setuptools_scm", "pyqt5", "superqt", - "scikit-image" + "scikit-image", ] [build-system] -requires = [ - "setuptools>=45", - "wheel", - "setuptools_scm[toml]>=6.2", -] +requires = ["setuptools>=45", "wheel", "setuptools_scm[toml]>=6.2"] build-backend = "setuptools.build_meta" [tool.setuptools] @@ -104,7 +95,7 @@ ignore = [ [tool.ruff] line-length = 79 -exclude = ["__init__.py","build",".eggs"] +exclude = ["__init__.py", "build", ".eggs"] select = ["I", "E", "F"] fix = true From 09c091edebadb18da57bc601c2b478ac60823bdb Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 31 Jan 2024 11:11:15 +0000 Subject: [PATCH 3/5] Fix regression test due to change in pandas behaviour --- tests/tests/test_brainmapper/test_analysis.py | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/tests/tests/test_brainmapper/test_analysis.py b/tests/tests/test_brainmapper/test_analysis.py index d99b473..c7a4231 100644 --- a/tests/tests/test_brainmapper/test_analysis.py +++ b/tests/tests/test_brainmapper/test_analysis.py @@ -1,6 +1,6 @@ -import filecmp from pathlib import Path +import pandas as pd import pytest from brainglobe_utils.brainmapper.analysis import ( @@ -37,9 +37,17 @@ def structures_with_points(): def test_get_region_totals(tmp_path, points, structures_with_points): - """Regression test for count_points_per_brain_region for + """ + Regression test for count_points_per_brain_region for pandas 1.5.3 -> 2.1.3+. - pd.Dataframe.append was deprecated and removed in this time.""" + pd.DataFrame.append was deprecated and removed in this time. + + 2024-01-31: Newer versions of pandas are writing the + DataFrame rows in a different order. As such, filecmp is no longer + sufficient to check that we are still counting the number of cells + correctly - we will need to load the data back in and do a pandas + comparison. + """ OUTPUT_DATA_LOC = ( Path(__file__).parent.parent.parent / "data" / "brainmapper" ) @@ -54,4 +62,21 @@ def test_get_region_totals(tmp_path, points, structures_with_points): points, structures_with_points, volumes_path, output_path ) assert output_path.exists() - assert filecmp.cmp(output_path, expected_output) + + # Read data back in, and sort rows by the structures for comparison. + # NOTE: Column 'structure name' should exist, otherwise we've failed + # and the test will flag the error appropriately + expected_df = ( + pd.read_csv(expected_output) + .sort_values("structure_name") + .reset_index(drop=True) + ) + produced_df = ( + pd.read_csv(output_path) + .sort_values("structure_name") + .reset_index(drop=True) + ) + assert expected_df.equals( + produced_df + ), "Produced DataFrame no longer matches per-region " + "count from expected DataFrame" From 0ebdac6bea4da851c7b9b4d06b5be4541606b73c Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 31 Jan 2024 11:16:36 +0000 Subject: [PATCH 4/5] tox.ini into pyproject --- pyproject.toml | 25 +++++++++++++++++++++++++ tox.ini | 21 --------------------- 2 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index a69158d..f883488 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -106,3 +106,28 @@ ignore_errors = true module = ["imlib.cells.*"] ignore_errors = false strict = true + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py{39,310,311} +isolated_build = True + +[gh-actions] +python = + 3.9: py39 + 3.10: py310 + 3.11: py311 + +[testenv] +extras = + dev +commands = + pytest -v --color=yes --cov=brainglobe_utils --cov-report=xml +passenv = + CI + GITHUB_ACTIONS + DISPLAY + XAUTHORITY + PYVISTA_OFF_SCREEN +""" diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 3857869..0000000 --- a/tox.ini +++ /dev/null @@ -1,21 +0,0 @@ -[tox] -envlist = py{39,310,311} -isolated_build = True - -[gh-actions] -python = - 3.9: py39 - 3.10: py310 - 3.11: py311 - -[testenv] -extras = - dev -commands = - pytest -v --color=yes --cov=brainglobe_utils --cov-report=xml -passenv = - CI - GITHUB_ACTIONS - DISPLAY - XAUTHORITY - PYVISTA_OFF_SCREEN From b170d38399f2885ae4ae8b1374a2a62fae1e83f2 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Wed, 31 Jan 2024 11:21:45 +0000 Subject: [PATCH 5/5] Reinstate bg-atlasapi dependency --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index f883488..98ce8ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,6 +18,7 @@ dependencies = [ "slurmio", "tifffile", "imio", + "bg-atlasapi", ] license = { text = "MIT" }