Skip to content

Commit

Permalink
Merge pull request #29 from brainglobe/make-ci-dispatchable
Browse files Browse the repository at this point in the history
Debug failing regression test
  • Loading branch information
alessandrofelder authored Jan 31, 2024
2 parents 4d4b790 + b170d38 commit 13d0444
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 60 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ name: tests
on:
push:
branches:
- '*'
- 'main'
tags:
- '*'
- 'v*'
pull_request:
workflow_dispatch:

jobs:
linting:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,4 @@ venv.bak/
.idea/
.vs/
*.~lock.*
.vscode/
83 changes: 50 additions & 33 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
[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",
"bg-atlasapi",
]

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]
Expand All @@ -40,11 +40,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",
Expand All @@ -60,16 +56,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]
Expand Down Expand Up @@ -104,7 +96,7 @@ ignore = [

[tool.ruff]
line-length = 79
exclude = ["__init__.py","build",".eggs"]
exclude = ["__init__.py", "build", ".eggs"]
select = ["I", "E", "F"]
fix = true

Expand All @@ -115,3 +107,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
"""
33 changes: 29 additions & 4 deletions tests/tests/test_brainmapper/test_analysis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import filecmp
from pathlib import Path

import pandas as pd
import pytest

from brainglobe_utils.brainmapper.analysis import (
Expand Down Expand Up @@ -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"
)
Expand All @@ -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"
21 changes: 0 additions & 21 deletions tox.ini

This file was deleted.

0 comments on commit 13d0444

Please sign in to comment.