Skip to content

Commit

Permalink
Merge branch 'main' into refactor-group-abundance
Browse files Browse the repository at this point in the history
  • Loading branch information
grst authored Jan 26, 2024
2 parents e2303ae + 84f390f commit 7859288
Show file tree
Hide file tree
Showing 32 changed files with 969 additions and 489 deletions.
1 change: 1 addition & 0 deletions .conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ requirements:
- adjusttext >=0.7
- numba >=0.41.0
- pooch >=1.7.0
- joblib >=1.3.1

test:
source_files:
Expand Down
9 changes: 7 additions & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"template": "https://github.com/scverse/cookiecutter-scverse",
"commit": "605f95714130c960bce12eab98a4e023e8932249",
"checkout": "v0.2.22",
"commit": "8e96abb5c3e2d5078c44713958da672711cf2a48",
"checkout": "v0.3.0",
"context": {
"cookiecutter": {
"project_name": "scirpy",
Expand All @@ -16,6 +16,11 @@
".github/workflows/**.yaml",
"docs/_templates/autosummary/**.rst"
],
"_render_devdocs": false,
"_jinja2_env_vars": {
"lstrip_blocks": true,
"trim_blocks": true
},
"_template": "https://github.com/scverse/cookiecutter-scverse"
}
},
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,12 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: install conda build
# TODO pinning conda-build version because it stopped working for no good reason in 3.25 or 3.26.
run: |
mamba install -y conda-build=3.24.0 conda-verify
mamba install -y boa conda-verify
shell: bash

- name: build and test package
run: |
cd .conda
mamba build --no-anaconda-upload .
conda mambabuild --no-anaconda-upload .
shell: bash
39 changes: 19 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
name: Release

on:
push:
tags:
- "*.*.*"
release:
types: [published]

# Use "trusted publishing", see https://docs.pypi.org/trusted-publishers/
jobs:
release:
name: Release
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/scirpy
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
- uses: actions/checkout@v4
with:
python-version: "3.10"

- name: Install hatch
run: pip install hatch

- name: Build project for distribution
run: hatch build

- name: Publish a Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
filter: blob:none
fetch-depth: 0
- uses: actions/setup-python@v4
with:
password: ${{ secrets.PYPI_API_TOKEN }}
python-version: "3.x"
cache: "pip"
- run: pip install build
- run: python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
12 changes: 9 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ jobs:
- os: ubuntu-latest
python: "3.9"
- os: ubuntu-latest
python: "3.10"
python: "3.11"
- os: ubuntu-latest
python: "3.10"
python: "3.11"
pip-flags: "--pre"
name: PRE-RELEASE DEPENDENCIES

name: ${{ matrix.name }} Python ${{ matrix.python }}

env:
OS: ${{ matrix.os }}
Expand Down Expand Up @@ -59,6 +62,9 @@ jobs:
PLATFORM: ${{ matrix.os }}
DISPLAY: :42
run: |
pytest -v --cov --color=yes
coverage run -m pytest -v --color=yes
- name: Report coverage
run: |
coverage report
- name: Upload coverage
uses: codecov/codecov-action@v3
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default_stages:
minimum_pre_commit_version: 2.16.0
repos:
- repo: https://github.com/psf/black
rev: "23.10.1"
rev: "23.12.1"
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
Expand All @@ -26,7 +26,7 @@ repos:
language_version: "17.9.1"
exclude: '^\.conda'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.3
rev: v0.1.14
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
33 changes: 32 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,32 @@ and this project adheres to [Semantic Versioning][].
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## [Unreleased]
## v0.15.0

### Fixes

- Fix incompatibility with `scipy` 1.12 ([#484](https://github.com/scverse/scirpy/pull/484))
- Fix incompatibility with `adjustText` 1.0 ([#477](https://github.com/scverse/scirpy/pull/477))
- Reduce overall importtime by deferring the import of the `airr` package until it is actually used. ([#473](https://github.com/scverse/scirpy/pull/473))

### 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`
class which supersedes the `AlignmentDistanceCalculator` class, which is now deprecated. Using the `"alignment"` metric
in `pp.ir_dist` now uses the `FastAlignmentDistanceCalculator` with only the lenght-based filter activated.
Using the `"fastalignment"` activates the heuristic, which is significantly faster, but results in some false-negatives. ([#456](https://github.com/scverse/scirpy/pull/456))
- Switch to [joblib/loky](https://joblib.readthedocs.io/en/latest/generated/joblib.Parallel.html) as a backend for parallel
processing in `pp.ir_dist`. Joblib enables to switch to alternative backends that support out-of-machine computing
(e.g. `dask`, `ray`) via the `parallel_config` context manager. Additionally, chunk sizes are now adjusted dynamically based on the problem size. ([#473](https://github.com/scverse/scirpy/pull/473))

### Documentation

- The default values of the distance calculator classes in `ir_dist.metrics` was unclear. The default value is now
set in the classes. In `pp.ir_dist` and `ir_dist.sequence_dist`, no cutoff argument is passed to the metrics
objects, unless one is explicitly specified (previously `None` was passed by default).

## v0.14.0

### Breaking changes

Expand All @@ -19,9 +44,15 @@ and this project adheres to [Semantic Versioning][].
`lambda x: ~ak.is_none(x["junction_aa"], axis=-1)`. To learn more about native awkward array functions, please
refer to the [awkward array documentation](https://awkward-array.org/doc/main/reference/index.html). ([#444](https://github.com/scverse/scirpy/pull/444))

### Additions

- The `clonal_expansion` function now supports a `breakpoints` argument for more flexible "expansion categories".
The `breakpoints` argument supersedes the `clip_at` parameter, which is now deprecated. ([#439](https://github.com/scverse/scirpy/pull/439))

### Fixes

- Fix that `define_clonotype_clusters` could not retreive `within_group` columns from MuData ([#459](https://github.com/scverse/scirpy/pull/459))
- Fix that AIRR Rearrangment fields of integer types could not be written when their value was None ([#465](https://github.com/scverse/scirpy/pull/465))

## v0.13.1

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Please consider making a tax-deductible [donation](https://numfocus.org/donate-t
>
</a>
[badge-tests]: https://img.shields.io/github/actions/workflow/status/grst/scirpy/test.yaml?branch=main
[badge-tests]: https://img.shields.io/github/actions/workflow/status/scverse/scirpy/test.yaml?branch=main
[link-tests]: https://github.com/scverse/scirpy/actions/workflows/test.yml
[badge-docs]: https://img.shields.io/readthedocs/scirpy
[badge-pypi]: https://img.shields.io/pypi/v/scirpy?logo=PyPI
Expand Down Expand Up @@ -69,7 +69,7 @@ There are several alternative options to install scirpy:
3. Install the latest development version:

```bash
pip install git+https://github.com/grst/scirpy.git@main
pip install git+https://github.com/scverse/scirpy.git@main
```

4. Run it in a container using [Docker][] or [Podman][]:
Expand Down Expand Up @@ -123,7 +123,7 @@ You can cite the scverse publication as follows:
> [10.1038/s41587-023-01733-8](https://doi.org/10.1038/s41587-023-01733-8).

[scverse-discourse]: https://discourse.scverse.org/
[issue-tracker]: https://github.com/grst/scirpy/issues
[issue-tracker]: https://github.com/scverse/scirpy/issues
[changelog]: https://scirpy.readthedocs.io/latest/changelog.html
[link-docs]: https://scirpy.readthedocs.io
[link-api]: https://scirpy.readthedocs.io/latest/api.html
Expand Down
4 changes: 4 additions & 0 deletions docs/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Reduce the font size in data frames - See https://github.com/scverse/cookiecutter-scverse/issues/193 */
div.cell_output table.dataframe {
font-size: 0.8em;
}
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,3 +301,4 @@ distance metrics
ir_dist.metrics.LevenshteinDistanceCalculator
ir_dist.metrics.HammingDistanceCalculator
ir_dist.metrics.AlignmentDistanceCalculator
ir_dist.metrics.FastAlignmentDistanceCalculator
17 changes: 2 additions & 15 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
"mudata": ("https://mudata.readthedocs.io/en/latest/", None),
"awkward": ("https://awkward-array.org/doc/main/", None),
"pooch": ("https://www.fatiando.org/pooch/latest/", None),
"joblib": ("https://joblib.readthedocs.io/en/latest", None),
}

# List of patterns, relative to source directory, that match files and
Expand All @@ -132,6 +133,7 @@
html_static_path = ["_static"]
html_title = project_name
html_logo = "img/scirpy_logo.png"
html_css_files = ["css/custom.css"]


html_theme_options = {
Expand Down Expand Up @@ -177,18 +179,3 @@
("py:meth", "mudata.MuData.update"),
("py:class", "awkward.highlevel.Array"),
]


def setup(app):
"""App setup hook."""
app.add_config_value(
"recommonmark_config",
{
"auto_toc_tree_section": "Contents",
"enable_auto_toc_tree": True,
"enable_math": True,
"enable_inline_math": False,
"enable_eval_rst": True,
},
True,
)
85 changes: 19 additions & 66 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing guide

Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this repo, too.
Scanpy provides extensive [developer documentation][scanpy developer guide], most of which applies to this project, too.
This document will not reproduce the entire content from there. Instead, it aims at summarizing the most important
information to get you started on contributing.

Expand All @@ -19,8 +19,8 @@ pip install -e ".[dev,test,doc]"

## Code-style

This template uses [pre-commit][] to enforce consistent code-styles. On every commit, pre-commit checks will either
automatically fix issues with the code, or raise an error message.
This package uses [pre-commit][] to enforce consistent code-styles.
On every commit, pre-commit checks will either automatically fix issues with the code, or raise an error message.

To enable pre-commit locally, simply run

Expand All @@ -42,10 +42,10 @@ git pull --rebase
to integrate the changes into yours.
While the [pre-commit.ci][] is useful, we strongly encourage installing and running pre-commit locally first to understand its usage.

Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [black][black-editors]
Finally, most editors have an _autoformat on save_ feature. Consider enabling this option for [ruff][ruff-editors]
and [prettier][prettier-editors].

[black-editors]: https://black.readthedocs.io/en/stable/integrations/editors.html
[ruff-editors]: https://docs.astral.sh/ruff/integrations/
[prettier-editors]: https://prettier.io/docs/en/editors.html

## Writing tests
Expand All @@ -64,74 +64,26 @@ command line by executing
pytest
```

in the root of the repository. Continuous integration will automatically run the tests on all pull requests.
in the root of the repository.

[scanpy-test-docs]: https://scanpy.readthedocs.io/en/latest/dev/testing.html#writing-tests

## Publishing a release

### Updating the version number

Before making a release, you need to update the version number. Please adhere to [Semantic Versioning][semver], in brief

> Given a version number MAJOR.MINOR.PATCH, increment the:
>
> 1. MAJOR version when you make incompatible API changes,
> 2. MINOR version when you add functionality in a backwards compatible manner, and
> 3. PATCH version when you make backwards compatible bug fixes.
>
> Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.
We use [bump2version][] to automatically update the version number in all places and automatically create a git tag.
Run one of the following commands in the root of the repository

```bash
bump2version patch
bump2version minor
bump2version major
```

Once you are done, run

```
git push --tags
```

to publish the created tag on GitHub.
### Continuous integration

[bump2version]: https://github.com/c4urself/bump2version
Continuous integration will automatically run the tests on all pull requests and test
against the minimum and maximum supported Python version.

### Building and publishing the package on PyPI
Additionally, there's a CI job that tests against pre-releases of all dependencies
(if there are any). The purpose of this check is to detect incompatibilities
of new package versions early on and gives you time to fix the issue or reach
out to the developers of the dependency before the package is released to a wider audience.

Python packages are not distributed as source code, but as _distributions_. The most common distribution format is the so-called _wheel_. To build a _wheel_, run

```bash
python -m build
```

This command creates a _source archive_ and a _wheel_, which are required for publishing your package to [PyPI][]. These files are created directly in the root of the repository.

Before uploading them to [PyPI][] you can check that your _distribution_ is valid by running:

```bash
twine check dist/*
```

and finally publishing it with:

```bash
twine upload dist/*
```

Provide your username and password when requested and then go check out your package on [PyPI][]!
[scanpy-test-docs]: https://scanpy.readthedocs.io/en/latest/dev/testing.html#writing-tests

For more information, follow the [Python packaging tutorial][].
## Publishing a release

It is possible to automate this with GitHub actions, see also [this feature request][pypi-feature-request]
in the cookiecutter-scverse template.
### Updating the version number

[python packaging tutorial]: https://packaging.python.org/en/latest/tutorials/packaging-projects/#generating-distribution-archives
[pypi-feature-request]: https://github.com/scverse/cookiecutter-scverse/issues/88
Scirpy uses [hatch-vcs](https://github.com/ofek/hatch-vcs) to automaticlly retrieve the version number
from the git tag. To make a new release, navigate to the “Releases” page of this project on GitHub. Specify vX.X.X as a tag name and create a release. For more information, see [managing GitHub releases][]. This will automatically create a git tag and trigger a Github workflow that creates a release on PyPI.

## Writing documentation

Expand Down Expand Up @@ -195,3 +147,4 @@ open _build/html/index.html
[numpydoc]: https://numpydoc.readthedocs.io/en/latest/format.html
[sphinx autodoc typehints]: https://github.com/tox-dev/sphinx-autodoc-typehints
[pypi]: https://pypi.org/
[managing GitHub releases]: https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository
Loading

0 comments on commit 7859288

Please sign in to comment.