Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #156

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 3 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ addopts = [

[tool.ruff]
line-length = 120
[tool.ruff.lint]
select = ['ALL']
ignore = [
'Q', # handled by formatter
Expand All @@ -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' = [
Expand All @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/anndata2ri/_py2r.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

Expand Down
2 changes: 1 addition & 1 deletion src/anndata2ri/scipy2ri/_r2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 7 additions & 1 deletion tests/test_py2rpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
8 changes: 4 additions & 4 deletions tests/test_scipy_rpy2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Loading