Skip to content

Commit

Permalink
Ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
flying-sheep committed Feb 6, 2024
1 parent 4bd71d1 commit 5ecf2cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
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: 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

0 comments on commit 5ecf2cd

Please sign in to comment.