Skip to content

Commit

Permalink
Backport PR #2661: [pre-commit.ci] pre-commit autoupdate (#2677)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
flying-sheep and pre-commit-ci[bot] authored Oct 9, 2023
1 parent 46969b4 commit fc498c3
Show file tree
Hide file tree
Showing 17 changed files with 6 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.9.1
hooks:
- id: black
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
rev: v0.0.292
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies = [
"matplotlib>=3.4",
"pandas>=1.0",
"scipy>=1.4",
"seaborn",
"seaborn!=0.13.0",
"h5py>=3",
"tqdm",
"scikit-learn>=0.24",
Expand Down
1 change: 0 additions & 1 deletion scanpy/experimental/pp/_highly_variable_genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def _highly_variable_pearson_residuals(
# Get pearson residuals for each batch separately
residual_gene_vars = []
for batch in np.unique(batch_info):

adata_subset_prefilter = adata[batch_info == batch]
X_batch_prefilter = _get_obs_rep(adata_subset_prefilter, layer=layer)

Expand Down
1 change: 0 additions & 1 deletion scanpy/experimental/pp/_normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@


def _pearson_residuals(X, theta, clip, check_values, copy=False):

X = X.copy() if copy else X

# check theta
Expand Down
2 changes: 0 additions & 2 deletions scanpy/external/pl.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,8 @@ def _plot_scores(
fig, axs = plt.subplots(n_batches, 2, figsize=figsize)

for idx, (batch_key, sub_obs) in enumerate(adata.obs.groupby(batches)):

# We'll need multiple rows if Scrublet was run in multiple batches
if 'batched_by' in adata.uns['scrublet']:

threshold = adata.uns["scrublet"]['batches'][batch_key].get(
"threshold", None
)
Expand Down
6 changes: 1 addition & 5 deletions scanpy/external/pp/_scrublet.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,10 @@ def scrublet(
adata_obs = adata.copy()

def _run_scrublet(ad_obs, ad_sim=None):

# With no adata_sim we assume the regular use case, starting with raw
# counts and simulating doublets

if ad_sim is None:

pp.filter_genes(ad_obs, min_cells=3)
pp.filter_cells(ad_obs, min_genes=3)

Expand Down Expand Up @@ -238,9 +236,7 @@ def _run_scrublet(ad_obs, ad_sim=None):
batches = np.unique(adata.obs[batch_key])
scrubbed = [
_run_scrublet(
adata_obs[
adata_obs.obs[batch_key] == batch,
],
adata_obs[adata_obs.obs[batch_key] == batch,],
adata_sim,
)
for batch in batches
Expand Down
2 changes: 1 addition & 1 deletion scanpy/plotting/_anndata.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def violin(
y=y,
data=obs_tidy,
kind="violin",
scale=scale,
density_norm=scale,
col=x,
col_order=keys,
sharey=False,
Expand Down
1 change: 0 additions & 1 deletion scanpy/plotting/_baseplot_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,6 @@ def _plot_colorbar(self, color_legend_ax: Axes, normalize):
color_legend_ax.xaxis.set_tick_params(labelsize='small')

def _plot_legend(self, legend_ax, return_ax_dict, normalize):

# to maintain the fixed height size of the legends, a
# spacer of variable height is added at top and bottom.
# The structure for the legends is:
Expand Down
1 change: 0 additions & 1 deletion scanpy/plotting/_dotplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ def _plot_size_legend(self, size_legend_ax: Axes):
size_legend_ax.set_xlim(xmin - 0.15, xmax + 0.5)

def _plot_legend(self, legend_ax, return_ax_dict, normalize):

# to maintain the fixed height size of the legends, a
# spacer of variable height is added at the bottom.
# The structure for the legends is:
Expand Down
1 change: 0 additions & 1 deletion scanpy/plotting/_stacked_violin.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ def _make_rows_of_violinplots(
)
axs_list = []
for idx, row_label in enumerate(_color_df.index):

row_ax = fig.add_subplot(gs[idx + 1, 1:-1])
axs_list.append(row_ax)

Expand Down
1 change: 0 additions & 1 deletion scanpy/plotting/_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,6 @@ def _get_values_to_plot(
if groups is None:
groups = adata.uns[key]['names'].dtype.names
if values_to_plot is not None:

df_list = []
for group in groups:
df = rank_genes_groups_df(adata, group, key=key, gene_symbols=gene_symbols)
Expand Down
1 change: 0 additions & 1 deletion scanpy/plotting/_tools/scatterplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,6 @@ def pca(
adata, 'pca', show=show, return_fig=return_fig, save=save, **kwargs
)
else:

if 'pca' not in adata.obsm.keys() and 'X_pca' not in adata.obsm.keys():
raise KeyError(
f"Could not find entry in `obsm` for 'pca'.\n"
Expand Down
2 changes: 0 additions & 2 deletions scanpy/plotting/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,6 @@ def _set_default_colors_for_categorical_obs(adata, value_to_plot):
def add_colors_for_categorical_sample_annotation(
adata, key, palette=None, force_update_colors=False
):

color_key = f"{key}_colors"
colors_needed = len(adata.obs[key].cat.categories)
if palette and force_update_colors:
Expand Down Expand Up @@ -1180,7 +1179,6 @@ def fix_kwds(kwds_dict, **kwargs):


def _get_basis(adata: anndata.AnnData, basis: str):

if basis in adata.obsm.keys():
basis_key = basis

Expand Down
1 change: 0 additions & 1 deletion scanpy/preprocessing/_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,6 @@ def _regress_out_chunk(data):
from statsmodels.tools.sm_exceptions import PerfectSeparationError

for col_index in range(data_chunk.shape[1]):

# if all values are identical, the statsmodel.api.GLM throws an error;
# but then no regression is necessary anyways...
if not (data_chunk[:, col_index] != data_chunk[0, col_index]).any():
Expand Down
2 changes: 0 additions & 2 deletions scanpy/tests/external/test_scrublet.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ def test_scrublet_data():
# Replicate the preprocessing steps used by the main function

def preprocess_for_scrublet(adata):

adata_pp = adata.copy()
pp.filter_genes(adata_pp, min_cells=3)
pp.filter_cells(adata_pp, min_genes=3)
Expand All @@ -100,7 +99,6 @@ def preprocess_for_scrublet(adata):
# Simulate doublets using the same parents

def create_sim_from_parents(adata, parents):

# Now simulate doublets based on the randomly selected parents used
# previously

Expand Down
1 change: 0 additions & 1 deletion scanpy/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test_descend_classes_and_funcs():


def test_check_nonnegative_integers():

X = np.random.poisson(size=(100, 100)).astype(np.float64)
assert check_nonnegative_integers(X) is True
assert check_nonnegative_integers(-X) is False
Expand Down
2 changes: 1 addition & 1 deletion scanpy/tools/_paga.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ def paga_compare_paths(
n_paths = 0
n_agreeing_paths = 0
# loop over all pairs of leaf nodes in the reference adata1
for (r, s) in itertools.combinations(leaf_nodes1, r=2):
for r, s in itertools.combinations(leaf_nodes1, r=2):
r2, s2 = asso_groups1[r][0], asso_groups1[s][0]
on1_g1, on2_g1 = [orig_names1[int(i)] for i in [r, s]]
on1_g2, on2_g2 = [orig_names2[int(i)] for i in [r2, s2]]
Expand Down

0 comments on commit fc498c3

Please sign in to comment.