diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index 4fe8031..e19b486 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -35,8 +35,6 @@ jobs: python-version: "3.10" - os: windows-latest python-version: "3.9" - - os: ubuntu-latest - python-version: "3.8" steps: - name: Cache atlases diff --git a/pyproject.toml b/pyproject.toml index 1f015c5..b1bef7a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "brainreg" description = "Automated 3D brain registration" readme = "README.md" authors = [ - {name = "Adam Tyson, Charly Rousseau", email = "code@adamltyson.com"}, + { name = "Adam Tyson, Charly Rousseau", email = "code@adamltyson.com" }, ] classifiers = [ "Development Status :: 3 - Alpha", @@ -16,13 +16,13 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", ] -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = [ "bg-atlasapi", "bg-space", "fancylog", "imio", - "brainglobe-utils", + "brainglobe-utils>=0.2.7", "numpy", "scikit-image", ] @@ -35,22 +35,13 @@ napari = [ "brainreg-segment>=0.0.2", "napari[pyside2]", ] -dev = [ - "black", - "pre-commit", - "pytest", - "pytest-cov", -] +dev = ["black", "pre-commit", "pytest", "pytest-cov"] [project.scripts] brainreg = "brainreg.cli:main" [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] @@ -72,11 +63,9 @@ filterwarnings = [ "ignore:`np.uint0` is a deprecated alias for `np.uintp`", "ignore:`np.void0` is a deprecated alias for `np.void`", "ignore:`np.bytes0` is a deprecated alias for `np.bytes_`", - "ignore:`np.str0` is a deprecated alias for `np.str_`" -] -markers = [ - "slow: marks tests as slow (deselect with '-m \"not slow\"')", + "ignore:`np.str0` is a deprecated alias for `np.str_`", ] +markers = ["slow: marks tests as slow (deselect with '-m \"not slow\"')"] [tool.black] target-version = ['py38', 'py39', 'py310', 'py311'] @@ -85,6 +74,6 @@ line-length = 79 [tool.ruff] line-length = 79 -exclude = ["__init__.py","build",".eggs"] +exclude = ["__init__.py", "build", ".eggs"] select = ["I", "E", "F"] fix = true diff --git a/src/brainreg/utils/misc.py b/src/brainreg/utils/misc.py index 2ebaa77..576730c 100644 --- a/src/brainreg/utils/misc.py +++ b/src/brainreg/utils/misc.py @@ -2,8 +2,6 @@ from argparse import Namespace from pathlib import PurePath -import pandas as pd - def get_arg_groups(args, parser): arg_groups = {} @@ -26,28 +24,3 @@ def serialise(obj): def log_metadata(file_path, args): with open(file_path, "w") as f: json.dump(args, f, default=serialise) - - -def safe_pandas_concat(df1: pd.DataFrame, df2: pd.DataFrame) -> pd.DataFrame: - """ - Concatenate two DataFrames without relying on deprecated functionality - when one of the DataFrames is empty. - - If df1 and df2 are non-empty, return the concatenation. - If df1 is empty and df2 is not, return a copy of df2. - If df1 is non-empty and df2 is, return a copy of df1. - If df1 and df2 are empty, return an empty DataFrame with the same column - names as df1. - - :param df1: DataFrame to concatenate. - :param df2: DataFrame to concatenate. - :returns: DataFrame formed from concatenation of df1 and df2. - """ - if df1.empty and df2.empty: - return pd.DataFrame(columns=df1.columns) - elif df1.empty: - return df2.copy() - elif df2.empty: - return df1.copy() - else: - return pd.concat([df1, df2], ignore_index=True) diff --git a/src/brainreg/utils/volume.py b/src/brainreg/utils/volume.py index 6dbed1a..d3c9d45 100644 --- a/src/brainreg/utils/volume.py +++ b/src/brainreg/utils/volume.py @@ -10,9 +10,7 @@ import imio import numpy as np import pandas as pd -from brainglobe_utils.pandas.misc import initialise_df - -from .misc import safe_pandas_concat +from brainglobe_utils.pandas.misc import initialise_df, safe_pandas_concat class UnknownAtlasValue(Exception): diff --git a/tests/tests/test_unit/test_misc.py b/tests/tests/test_unit/test_misc.py deleted file mode 100644 index 3f1956c..0000000 --- a/tests/tests/test_unit/test_misc.py +++ /dev/null @@ -1,21 +0,0 @@ -import pandas as pd -from brainreg.utils.misc import safe_pandas_concat - - -def test_safe_pandas_concat() -> None: - """ - Test the following: - - Non-empty dataframes are concatenated as expected, - - When one dataframe is empty, the other is returned, - - When both dataframes are empty, an empty dataframe with - the corresponding columns is returned. - """ - df1 = pd.DataFrame(data={"a": [1], "b": [2], "c": [3]}) - df2 = pd.DataFrame(data={"a": [4], "b": [5], "c": [6]}) - empty_df = pd.DataFrame(columns=["a", "b", "c"]) - combined_df = pd.DataFrame(data={"a": [1, 4], "b": [2, 5], "c": [3, 6]}) - - assert combined_df.equals(safe_pandas_concat(df1, df2)) - assert df1.equals(safe_pandas_concat(df1, empty_df)) - assert df2.equals(safe_pandas_concat(empty_df, df2)) - assert empty_df.equals(safe_pandas_concat(empty_df, empty_df))