Skip to content

Commit

Permalink
Fix incompatibility with adjustText 1.0 (#477)
Browse files Browse the repository at this point in the history
* Fix incompatibility with adjustText 1.0

* Update CHANGELOG

* Adjusttext compatibility with both new and old versions

* get version using importlib metadata
  • Loading branch information
grst authored Jan 9, 2024
1 parent e1c8028 commit 759bc44
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ and this project adheres to [Semantic Versioning][].

## Unreleased

## New features
### Fixes

- Fix incompatibility with `adjustText` 1.0 ([#477](https://github.com/scverse/scirpy/pull/477))

### New features

- Speed up alignment distances by pre-filtering. There are two filtering strategies: A (lossless) length-based filter
and a heuristic based on the expected penalty per mismatch. This is implemented in the `FastAlignmentDistanceCalculator`
Expand Down
12 changes: 11 additions & 1 deletion src/scirpy/pl/_clonotype_modularity.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from collections.abc import Sequence
from importlib.metadata import version
from typing import Optional, Union

import numpy as np
from adjustText import adjust_text
from matplotlib import patheffects
from packaging.version import Version

from scirpy.util import DataHandler

Expand Down Expand Up @@ -186,13 +188,21 @@ def clonotype_modularity(
)

if label_adjusttext:
kwargs = {}
# incompatible API between <1.0 and >=1.0. I'd like to pin 1.0, but it's not available from
# conda-forge and there are some issue (https://github.com/Phlya/adjustText/issues/166)
if Version(version("adjustText")) >= Version("1.0"):
kwargs["force_static"] = (0.4, 0.4)
else:
kwargs["force_points"] = (0.4, 0.4)

adjust_text(
label_objs,
score_df["xs"].values,
score_df["ys"].values,
arrowprops={"arrowstyle": "-", "color": "k", "lw": 0.5},
force_text=(0.3, 0.3),
force_points=(0.4, 0.4),
**kwargs,
)

return ax

0 comments on commit 759bc44

Please sign in to comment.