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

pytest 8 compatibility #2836

Closed
3 tasks done
ivirshup opened this issue Jan 29, 2024 · 2 comments · Fixed by #2838
Closed
3 tasks done

pytest 8 compatibility #2836

ivirshup opened this issue Jan 29, 2024 · 2 comments · Fixed by #2838

Comments

@ivirshup
Copy link
Member

Please make sure these conditions are met

  • I have checked that this issue has not already been reported.
  • I have confirmed this bug exists on the latest version of scanpy.
  • (optional) I have confirmed this bug exists on the master branch of scanpy.

What happened?

When running the tests with pytest<=8, the doctest for scanpy.preprocessing._simple.filter_cells errors in a way I can't quite figure out how to fix.

I think what's happening is that the "error on warning" isn't being overridden correctly when we expect the test to warn. Possibly related to pytest-dev/pytest#11759

@flying-sheep any ideas how to fix? I will just pin pytest for now.

Minimal code sample

Examples
    --------
    >>> import scanpy as sc
    >>> adata = sc.datasets.krumsiek11()
    UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.
        utils.warn_names_duplicates("obs")

Error output

======================================================================================================================= FAILURES =======================================================================================================================
_________________________________________________________________________________________________ [doctest] scanpy.preprocessing._simple.filter_cells __________________________________________________________________________________________________
081         Boolean index mask that does filtering. `True` means that the
082         cell is kept. `False` means the cell is removed.
083     number_per_cell
084         Depending on what was thresholded (`counts` or `genes`),
085         the array stores `n_counts` or `n_cells` per gene.
086 
087     Examples
088     --------
089     >>> import scanpy as sc
090     >>> adata = sc.datasets.krumsiek11()
UNEXPECTED EXCEPTION: UserWarning('Observation names are not unique. To make them unique, call `.obs_names_make_unique`.')
Traceback (most recent call last):
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/doctest.py", line 1353, in __run
    exec(compile(example.source, filename, "single",
  File "<doctest scanpy.preprocessing._simple.filter_cells[1]>", line 1, in <module>
  File "/mnt/workspace/repos/scanpy/scanpy/datasets/_datasets.py", line 109, in krumsiek11
    adata = read(filename, first_column_names=True)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/site-packages/legacy_api_wrap/__init__.py", line 80, in fn_compatible
    return fn(*args_all, **kw)
           ^^^^^^^^^^^^^^^^^^^
  File "/mnt/workspace/repos/scanpy/scanpy/readwrite.py", line 124, in read
    return _read(
           ^^^^^^
  File "/mnt/workspace/repos/scanpy/scanpy/readwrite.py", line 801, in _read
    adata = read_text(filename, delimiter, first_column_names)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/site-packages/anndata/_io/read.py", line 360, in read_text
    return _read_text(f, delimiter, first_column_names, dtype)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/site-packages/anndata/_io/read.py", line 471, in _read_text
    return AnnData(
           ^^^^^^^^
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/site-packages/anndata/_core/anndata.py", line 362, in __init__
    self._init_as_actual(
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/site-packages/anndata/_core/anndata.py", line 574, in _init_as_actual
    self._check_uniqueness()
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/site-packages/anndata/_core/anndata.py", line 1906, in _check_uniqueness
    utils.warn_names_duplicates("obs")
  File "/mnt/workspace/mambaforge/envs/scanpy-dev/lib/python3.11/site-packages/anndata/utils.py", line 275, in warn_names_duplicates
    warnings.warn(
UserWarning: Observation names are not unique. To make them unique, call `.obs_names_make_unique`.
/mnt/workspace/repos/scanpy/scanpy/preprocessing/_simple.py:90: UnexpectedException

Versions

-----
anndata     0.10.5.post1
scanpy      1.10.0.dev197+g96e19540
-----
IPython             8.20.0
PIL                 10.2.0
asciitree           NA
asttokens           NA
cloudpickle         3.0.0
cycler              0.12.1
cython_runtime      NA
dask                2024.1.1
dateutil            2.8.2
decorator           5.1.1
executing           2.0.1
fasteners           0.19
h5py                3.10.0
igraph              0.11.3
iniconfig           NA
jedi                0.19.1
jinja2              3.1.3
joblib              1.3.2
kiwisolver          1.4.5
legacy_api_wrap     NA
leidenalg           0.10.2
llvmlite            0.41.1
markupsafe          2.1.4
matplotlib          3.8.2
mpl_toolkits        NA
msgpack             1.0.7
natsort             8.4.0
numba               0.58.1
numcodecs           0.12.1
numpy               1.26.3
packaging           23.2
pandas              2.2.0
parso               0.8.3
pexpect             4.9.0
pluggy              1.4.0
prompt_toolkit      3.0.43
psutil              5.9.8
ptyprocess          0.7.0
pure_eval           0.2.2
py                  NA
pygments            2.17.2
pyparsing           3.1.1
pytest              8.0.0
pytz                2023.4
scipy               1.12.0
session_info        1.0.0
six                 1.16.0
sklearn             1.4.0
sparse              0.15.1
stack_data          0.6.3
tblib               3.0.0
texttable           1.7.0
threadpoolctl       3.2.0
tlz                 0.12.1
toolz               0.12.1
traitlets           5.14.1
wcwidth             0.2.13
yaml                6.0.1
zarr                2.16.1
zipp                NA
-----
Python 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]
Linux-5.15.0-87-generic-x86_64-with-glibc2.35
-----
Session information updated at 2024-01-29 14:16
@flying-sheep
Copy link
Member

Same way as in anndata: We use an autouse fixture and directly execute the effects instead of adding marks.

@flying-sheep
Copy link
Member

flying-sheep commented Jan 29, 2024

OK, that’s weird: Now there’s a bunch of ImageComparisonFailures in the minimal tests job. are they unrelated? A fluke?

https://dev.azure.com/scverse/scanpy/_build/results?buildId=5487&view=logs&j=50ff7263-9206-5a84-1219-938c9ee7fde7&t=2e49bd34-47bd-5a56-3183-6247e293d44d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants