diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8750ba5..e62ba3a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ repos: hooks: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.1.14 + rev: v0.2.0 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] diff --git a/.vscode/settings.json b/.vscode/settings.json index a8297a0..1dd92dc 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,12 +3,11 @@ "editor.formatOnSave": true, "editor.defaultFormatter": "charliermarsh.ruff", "editor.codeActionsOnSave": { - "source.fixAll.ruff": true, - "source.organizeImports.ruff": true, + "source.fixAll.ruff": "always", + "source.organizeImports.ruff": "always", }, }, - "python.testing.pytestArgs": [], - "python.testing.unittestEnabled": false, "python.testing.pytestEnabled": true, + "python.testing.pytestArgs": ["--color=yes", "-vv"], "python.terminal.activateEnvironment": false, } diff --git a/pyproject.toml b/pyproject.toml index d1f3c4c..70c67cb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,7 @@ addopts = [ [tool.ruff] line-length = 120 +[tool.ruff.lint] select = ['ALL'] ignore = [ 'Q', # handled by formatter @@ -79,7 +80,7 @@ ignore = [ 'S101', # asserts are fine ] allowed-confusables = ['’', '×'] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] 'src/**/*.py' = ['PT'] # No Pytest checks 'docs/**/*.py' = ['INP001'] # No __init__.py in docs 'tests/**/*.py' = [ @@ -89,7 +90,7 @@ allowed-confusables = ['’', '×'] 'PD901', # “df” is a fine var name in tests 'PLR2004', # magic numbers are fine in tests ] -[tool.ruff.isort] +[tool.ruff.lint.isort] known-first-party = ['anndata2ri'] lines-after-imports = 2 [tool.ruff.format] diff --git a/src/anndata2ri/_py2r.py b/src/anndata2ri/_py2r.py index 03e5518..e4ce099 100644 --- a/src/anndata2ri/_py2r.py +++ b/src/anndata2ri/_py2r.py @@ -26,8 +26,8 @@ class NotConvertedWarning(Warning): dict_converter = conversion.Converter('Converter handling dicts') dict_converter.py2rpy.register(np.bool_, lambda x: conversion.py2rpy(bool(x))) -dict_converter.py2rpy.register(np.int_, lambda x: conversion.py2rpy(int(x))) -dict_converter.py2rpy.register(np.float_, lambda x: conversion.py2rpy(float(x))) +dict_converter.py2rpy.register(np.integer, lambda x: conversion.py2rpy(int(x))) +dict_converter.py2rpy.register(np.floating, lambda x: conversion.py2rpy(float(x))) dict_converter.py2rpy.register(np.bytes_, lambda x: conversion.py2rpy(bytes(x))) dict_converter.py2rpy.register(np.str_, lambda x: conversion.py2rpy(str(x))) diff --git a/src/anndata2ri/scipy2ri/_r2py.py b/src/anndata2ri/scipy2ri/_r2py.py index 24ab2cd..5e8b2c5 100644 --- a/src/anndata2ri/scipy2ri/_r2py.py +++ b/src/anndata2ri/scipy2ri/_r2py.py @@ -59,7 +59,7 @@ def rmat_to_spmat(rmat: SexpS4) -> sparse.spmatrix: if supported_r_matrix_classes(types='n') & r_classes else slots['x'] ) - dtype = np.bool_ if supported_r_matrix_classes(types=('n', 'l')) & r_classes else np.float_ + dtype = np.bool_ if supported_r_matrix_classes(types=('n', 'l')) & r_classes else np.float64 return mat_cls((data, *coord_spec), shape=shape, dtype=dtype) msg = 'Should have hit one of the branches' diff --git a/tests/test_py2rpy.py b/tests/test_py2rpy.py index c03109b..276c244 100644 --- a/tests/test_py2rpy.py +++ b/tests/test_py2rpy.py @@ -57,7 +57,13 @@ def test_py2rpy( dataset: Callable[[], AnnData], ) -> None: if dataset is sc.datasets.krumsiek11: - with pytest.warns(UserWarning, match=r'Duplicated obs_names'): + with ( + pytest.warns(UserWarning, match=r'Duplicated obs_names'), + pytest.warns(UserWarning, match=r'Observation names are not unique'), + # TODO(flying-sheep): Adapt to rpy2 changes instead + # https://github.com/theislab/anndata2ri/issues/109 + pytest.warns(DeprecationWarning, match=r'rpy2\.robjects\.conversion is deprecated'), + ): ex = py2r(anndata2ri, dataset()) else: ex = py2r(anndata2ri, dataset()) diff --git a/tests/test_scipy_rpy2py.py b/tests/test_scipy_rpy2py.py index be846b2..603fcf9 100644 --- a/tests/test_scipy_rpy2py.py +++ b/tests/test_scipy_rpy2py.py @@ -49,10 +49,10 @@ coo_b2 = [[0, 0, 1], [0, 1, 0], [0, 0, 0]] mats = [ - pytest.param((0, 0), sparse.csc_matrix, np.float_, csc_empty, dgc_empty, id='dgC_empty'), - pytest.param((3, 2), sparse.csc_matrix, np.float_, csc_f, dgc, id='dgC'), - pytest.param((2, 3), sparse.csr_matrix, np.float_, csr_f, dgr, id='dgR'), - pytest.param((2, 3), sparse.coo_matrix, np.float_, coo_f, dgt, id='dgT'), + pytest.param((0, 0), sparse.csc_matrix, np.float64, csc_empty, dgc_empty, id='dgC_empty'), + pytest.param((3, 2), sparse.csc_matrix, np.float64, csc_f, dgc, id='dgC'), + pytest.param((2, 3), sparse.csr_matrix, np.float64, csr_f, dgr, id='dgR'), + pytest.param((2, 3), sparse.coo_matrix, np.float64, coo_f, dgt, id='dgT'), pytest.param((2, 3), sparse.csc_matrix, np.bool_, csc_b1, lgc, id='lgC'), pytest.param((3, 3), sparse.csr_matrix, np.bool_, csr_b1, lgr, id='lgR'), # pytest.param((?, ?), sparse.coo_matrix, np.bool_, coo_b1, lgt, id="lgT"),