Skip to content

Commit

Permalink
Matplotlib 3.9 support (scverse#2999)
Browse files Browse the repository at this point in the history
* Matplotlib 3.9 support

* Remove deprecated inversion of bool

* Release note

* Fix use of deprecated argument for igraph.Graph.community_leiden

* Support for matplotlib 3.6
  • Loading branch information
ivirshup authored Apr 10, 2024
1 parent 2c2cd50 commit 10f4ebc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/release-notes/1.10.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
```{rubric} Bug fixes
```

* Compatibility with `matplotlib` 3.9 {pr}`2999` {smaller}`I Virshup`

```{rubric} Performance
```
2 changes: 1 addition & 1 deletion scanpy/experimental/pp/_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def normalize_pearson_residuals(
msg = f"computing analytic Pearson residuals on {computed_on}"
start = logg.info(msg)

residuals = _pearson_residuals(X, theta, clip, check_values, copy=~inplace)
residuals = _pearson_residuals(X, theta, clip, check_values, copy=not inplace)
settings_dict = dict(theta=theta, clip=clip, computed_on=computed_on)

if inplace:
Expand Down
8 changes: 7 additions & 1 deletion scanpy/plotting/_anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
from itertools import product
from typing import TYPE_CHECKING, Literal, Union

import matplotlib as mpl
import numpy as np
import pandas as pd
from matplotlib import gridspec, patheffects, rcParams
from matplotlib import pyplot as plt
from matplotlib.colors import Colormap, ListedColormap, Normalize, is_color_like
from packaging.version import Version
from pandas.api.types import CategoricalDtype, is_numeric_dtype
from scipy.sparse import issparse

Expand Down Expand Up @@ -518,7 +520,11 @@ def add_centroid(centroids, name, Y, mask):
frameon=False, loc=legend_loc, fontsize=legend_fontsize
)
if legend is not None:
for handle in legend.legendHandles:
if Version(mpl.__version__) < Version("3.7"):
_attr = "legendHandles"
else:
_attr = "legend_handles"
for handle in getattr(legend, _attr):
handle.set_sizes([300.0])

# draw a frame around the scatter
Expand Down
6 changes: 4 additions & 2 deletions scanpy/tools/_leiden.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ def leiden(
# as this allows for the accounting of a None resolution
# (in the case of a partition variant that doesn't take it on input)
clustering_args["n_iterations"] = n_iterations
if resolution is not None:
clustering_args["resolution_parameter"] = resolution
if flavor == "leidenalg":
if resolution is not None:
clustering_args["resolution_parameter"] = resolution
directed = True if directed is None else directed
g = _utils.get_igraph_from_adjacency(adjacency, directed=directed)
if partition_type is None:
Expand All @@ -180,6 +180,8 @@ def leiden(
g = _utils.get_igraph_from_adjacency(adjacency, directed=False)
if use_weights:
clustering_args["weights"] = "weight"
if resolution is not None:
clustering_args["resolution"] = resolution
clustering_args.setdefault("objective_function", "modularity")
with _utils.set_igraph_random_state(random_state):
part = g.community_leiden(**clustering_args)
Expand Down

0 comments on commit 10f4ebc

Please sign in to comment.