### Install pre-commit Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Installs the pre-commit tool using pip. ```console $ pip install pre-commit ``` -------------------------------- ### Install pre-commit hooks Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Installs pre-commit hooks to run styling checks automatically during development from the root of the repository. ```console $ pre-commit install ``` -------------------------------- ### Create a feature branch Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Creates a new branch for feature development, starting from the main branch and syncing with the repository. ```console $ git checkout main # Starting from the main branch $ git pull # Syncing with the repo $ git switch -c {your-branch-name} # Making and changing to the new branch ``` -------------------------------- ### Hatch development environments Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Examples of using Hatch environments for testing, building docs, and creating changelog entries. ```console $ hatch test -p $ hatch run docs:build $ hatch run towncrier:create ``` -------------------------------- ### Pip installation Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Install scanpy with the optional 'leiden' extra using pip. ```console $ pip install 'scanpy[leiden]' ``` -------------------------------- ### Pushing subsequent changes Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Pushes subsequent changes to an already tracked branch. ```console $ # After that, just use $ git push ``` -------------------------------- ### PyPI installation Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Install scanpy from PyPI using pip. ```console $ pip install scanpy ``` -------------------------------- ### Troubleshooting pip permission denied Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Install scanpy using the --user flag if encountering permission errors, avoiding sudo pip. ```console $ pip install --user scanpy ``` -------------------------------- ### Clone repository for development Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Clone the scanpy repository from GitHub and navigate into its root directory. ```console $ gh repo clone scverse/scanpy $ cd scanpy ``` -------------------------------- ### Prose Return Example Source: https://github.com/scverse/scanpy/blob/main/docs/dev/documentation.md Example of a simple 'Returns' section using prose for documentation. ```rst Returns ------- Returns dictionary with normalized copies of `adata.X` and `adata.layers` or updates `adata` with normalized versions of the original `adata.X` and `adata.layers`, depending on `inplace`. ``` -------------------------------- ### Run pre-commit manually Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Manually runs pre-commit checks on specified files if not running on each commit. ```console pre-commit run --files={your files} ``` -------------------------------- ### Running a subset of tests Source: https://github.com/scverse/scanpy/blob/main/docs/dev/testing.md Examples of how to filter tests using the -k argument with hatch test. ```bash hatch test test_plotting.py ``` ```bash hatch test -k "test_umap*" ``` -------------------------------- ### Manual forking and cloning Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Manually forks the repository on GitHub, clones the fork, changes into the directory, and adds the original repository as an upstream remote. ```console $ # Clone your fork of the repository (substitute in your username) $ git clone https://github.com/{your-username}/scanpy.git $ # Enter the cloned repository $ cd scanpy $ # Add our repository as a remote $ git remote add upstream https://github.com/scverse/scanpy.git $ # git branch --set-upstream-to "upstream/main" ``` -------------------------------- ### Pushing a new branch for the first time Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Pushes a newly created branch to the origin remote, setting the upstream tracking branch. ```console $ # The first time you push the branch, you'll need to tell git where $ git push --set-upstream origin {your-branch-name} ``` -------------------------------- ### Conda installation Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Install scanpy and its dependencies (python-igraph, leidenalg) using conda. ```console $ conda install -c conda-forge scanpy python-igraph leidenalg ``` -------------------------------- ### Forking and cloning with GitHub CLI Source: https://github.com/scverse/scanpy/blob/main/docs/dev/getting-set-up.md Forks the repository, creates a local clone, adds the upstream remote, and sets the main branch to track the upstream repository. ```console $ gh repo fork scverse/scanpy --clone --remote ``` -------------------------------- ### Pip editable install for development Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Perform an editable installation of scanpy using pip for development, including dev and test groups. ```console $ python -m venv .venv $ source .venv/bin/activate $ pip install --group=dev --group=test -e . ``` -------------------------------- ### Building the docs Source: https://github.com/scverse/scanpy/blob/main/docs/dev/documentation.md Commands to build and open the documentation locally. ```bash hatch run docs:build hatch run docs:open ``` -------------------------------- ### Conda environment creation for development Source: https://github.com/scverse/scanpy/blob/main/docs/installation.md Create a conda environment from a generated environment.yml file and install scanpy in editable mode. ```console $ pipx install beni $ beni pyproject.toml > environment.yml $ conda env create -f environment.yml $ conda activate scanpy $ pip install --group=dev --group=test --group=doc -e . ``` -------------------------------- ### Mixed Prose and Tuple Return Example Source: https://github.com/scverse/scanpy/blob/main/docs/dev/documentation.md Example of a 'Returns' section combining prose and tuple descriptions for complex return values, particularly when updating an AnnData object. ```rst Returns ------- Depending on `copy`, returns or updates `adata` with the following fields. If `n_branchings==0`, no field `dpt_groups` will be written. dpt_pseudotime : :class:`~pandas.Series` (`adata.obs`, dtype `float`) Array of dim (number of samples) that stores the pseudotime of each cell, that is, the DPT distance with respect to the root cell. dpt_groups : :class:`pandas.Series` (`adata.obs`, dtype `category`) Array of dim (number of samples) that stores the subgroup id ('0', '1', ...) for each cell. The groups typically correspond to 'progenitor cells', 'undecided cells' or 'branches' of a process. ``` -------------------------------- ### Tuple Return Example (Python Signature) Source: https://github.com/scverse/scanpy/blob/main/docs/dev/documentation.md Example of a Python function signature and docstring for tuple return values, emphasizing type annotation in the signature and descriptions in the docstring. ```python def myfunc(...) -> tuple[int, str]: """ ... Returns ------- one_identifier Description. second_identifier Description 2. """ ... ```