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

Unpin numpy 2 #3115

Merged
merged 9 commits into from
Jul 2, 2024
Merged

Unpin numpy 2 #3115

merged 9 commits into from
Jul 2, 2024

Conversation

flying-sheep
Copy link
Member

@flying-sheep flying-sheep commented Jun 20, 2024

  • Release notes not necessary because:

Other things done:

  • Rename some variables and reorder functions so the diff between the metrics is minimal for a future unification

  • Skip seurat v3 tests with numpy 2 because skmisc isn’t ready: Support for numpy 2.0 has2k1/scikit-misc#34

    This will skip the seurat v3 tests for all but the minimum versions test job for now, but I think that’s OK?

@flying-sheep flying-sheep enabled auto-merge (squash) June 20, 2024 15:55
@flying-sheep flying-sheep added this to the 1.10.2 milestone Jun 20, 2024
Copy link

codecov bot commented Jun 20, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 73.98%. Comparing base (8d9a5f0) to head (8fb2a0e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3115      +/-   ##
==========================================
- Coverage   76.31%   73.98%   -2.34%     
==========================================
  Files         109      109              
  Lines       12515    12438      -77     
==========================================
- Hits         9551     9202     -349     
- Misses       2964     3236     +272     
Files Coverage Δ
src/scanpy/metrics/_gearys_c.py 86.04% <100.00%> (ø)
src/scanpy/metrics/_morans_i.py 86.04% <100.00%> (+30.09%) ⬆️
src/scanpy/plotting/_utils.py 55.61% <ø> (-0.17%) ⬇️
src/scanpy/preprocessing/_simple.py 85.15% <ø> (-2.81%) ⬇️
src/scanpy/_utils/compute/is_constant.py 78.04% <25.00%> (ø)

... and 27 files with indirect coverage changes

@@ -81,7 +81,7 @@ def is_constant(
def _(a: NDArray, axis: Literal[0, 1] | None = None) -> bool | NDArray[np.bool_]:
# Should eventually support nd, not now.
if axis is None:
return (a == a.flat[0]).all()
return bool((a == a.flat[0]).all())
Copy link
Member Author

@flying-sheep flying-sheep Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the function return a bool instead of a np.bool_ scalar as the type hints say.

The two types behave almost identically but have a different repr with numpy 2, so this change passes the doctests.

@@ -1,3 +1,5 @@
"""Geary's C autocorrelation."""
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn’t change anything in the two metrics modules, just reordered and reformatted (and replaced the removed np.float_ with np.float64, which in numpy 1.x are identical)

Comment on lines +124 to 125
>>> int(adata.obs['n_genes'].min())
1
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more repr changes: this is shown as np.int64(1) without the cast to int

@@ -173,7 +173,7 @@ def test_download_failure():
*DS_MARKS[ds],
],
)
for ds in set(sc.datasets.__all__) - DS_DYNAMIC
for ds in sorted(set(sc.datasets.__all__) - DS_DYNAMIC)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes pytest -n auto. Pytest complained locally that different jobs collected “different tests” which were just differently sorted.

@ilan-gold
Copy link
Contributor

Skip seurat v3 tests with numpy 2

Sorry does this mean it doesn't work with numpy 2?

@flying-sheep
Copy link
Member Author

It doesn’t. We could also

  1. wait to merge this until skmisc has a new release or
  2. throw a special error when people try to use seurat v3 with numpy 2

Sadly(?) Python doesn’t allow packages to add constraint to other packages’ dependencies, else we could tell the resolver that all currently release skmisc versions are incompatible with numpy 2

@ilan-gold
Copy link
Contributor

wait to merge this until skmisc has a new release

Are we in a rush? We are upper bounding right now anyway on the current release, no? I would just wait.

@flying-sheep
Copy link
Member Author

We’re not upper-bounding in 1.10.1.

@ilan-gold
Copy link
Contributor

We discussed outside @flying-sheep - we will release with the bound then and just wait here?

@ilan-gold ilan-gold modified the milestones: 1.10.2, 1.10.3 Jun 25, 2024
@flying-sheep
Copy link
Member Author

release done, we can wait here …

@ilan-gold
Copy link
Contributor

Looks like there is a release out for the scikit-misc: has2k1/scikit-misc@v0.4.0...main

Hopefully this fixes it

@flying-sheep flying-sheep merged commit 4b090c0 into main Jul 2, 2024
12 of 14 checks passed
@flying-sheep flying-sheep deleted the unpin-numpy-2 branch July 2, 2024 09:55
meeseeksmachine pushed a commit to meeseeksmachine/scanpy that referenced this pull request Jul 2, 2024
flying-sheep added a commit that referenced this pull request Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Numpy 2 support (unpin)
2 participants