From 695eadcec92e2f40b2a2490547fed6b84752c301 Mon Sep 17 00:00:00 2001 From: Philipp Weiler Date: Sat, 2 Dec 2023 11:04:28 +0100 Subject: [PATCH 1/2] Update scvelo default branch Update default branch from `master` to `main`. --- .github/workflows/build.yml | 4 +-- CONTRIBUTING.rst | 2 +- README.md | 2 +- debug.py | 14 ++++++++ docs/source/_ext/edit_on_github.py | 2 +- docs/source/conf.py | 4 +-- docs/source/index.rst | 2 +- scvelo/datasets/_biomart.py | 0 scvelo/datasets/_load.py | 0 scvelo/datasets/_read.py | 52 ++++++++++++++++++++++++++++++ 10 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 debug.py create mode 100644 scvelo/datasets/_biomart.py create mode 100644 scvelo/datasets/_load.py create mode 100644 scvelo/datasets/_read.py diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4ca70f78..02429433 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,9 +2,9 @@ name: Check Build on: push: - branches: [master] + branches: [main] pull_request: - branches: [master] + branches: [main] jobs: package: diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index d4c6ed1f..fa3c6f16 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -81,7 +81,7 @@ The docstrings of scVelo largely follow the `numpy`-style. New docstrings should Submitting pull requests ^^^^^^^^^^^^^^^^^^^^^^^^ -New features and bug fixes are added to the code base through a pull request (PR). To implement a feature or bug fix, create a branch from `master`. The existence of bugs suggests insufficient test coverage. As such, bug fixes should, ideally, include a unit test or extend an existing one. Please ensure that +New features and bug fixes are added to the code base through a pull request (PR). To implement a feature or bug fix, create a branch from `main`. The existence of bugs suggests insufficient test coverage. As such, bug fixes should, ideally, include a unit test or extend an existing one. Please ensure that - branch names have the prefix `feat/` or `fix/`. - your code follows the project conventions. diff --git a/README.md b/README.md index 63b9918a..a3ca4954 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [link-pypi]: https://pypi.org/project/scvelo [badge-pypidownloads]: https://pepy.tech/badge/scvelo [link-pypidownloads]: https://pepy.tech/project/scvelo -[badge-ci]: https://img.shields.io/github/actions/workflow/status/theislab/scvelo/ci.yml?branch=master +[badge-ci]: https://img.shields.io/github/actions/workflow/status/theislab/scvelo/ci.yml?branch=main [link-ci]: https://github.com/theislab/scvelo/actions/workflows/ci.yml # scVelo - RNA velocity generalized through dynamical modeling diff --git a/debug.py b/debug.py new file mode 100644 index 00000000..561b35e3 --- /dev/null +++ b/debug.py @@ -0,0 +1,14 @@ +import numpy as np + +import scvelo as scv + +adata = scv.datasets.pancreas(file_path="data/pancreas.h5ad") +obs_names = adata.obs_names.tolist() +obs_names[0] = f"blah-{obs_names[0]}" +obs_names[1] = f"blah-{obs_names[0]}" +adata.obs_names = obs_names + +bdata = adata.copy() +bdata.obs_names = np.arange(0, bdata.n_obs).astype(str) + +adata = scv.utils.merge(adata, bdata) diff --git a/docs/source/_ext/edit_on_github.py b/docs/source/_ext/edit_on_github.py index 0654454f..8c6af4a8 100644 --- a/docs/source/_ext/edit_on_github.py +++ b/docs/source/_ext/edit_on_github.py @@ -37,7 +37,7 @@ def html_page_context(app, pagename, templatename, context, doctree): # For sphinx_rtd_theme. context["display_github"] = True context["github_user"] = "theislab" - context["github_version"] = "master" + context["github_version"] = "main" context["github_repo"] = repo context["conf_py_path"] = conf_py_path diff --git a/docs/source/conf.py b/docs/source/conf.py index 483518b3..3b3f9a8c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -135,7 +135,7 @@ Open In Colab - Open In nbviewer + Open In nbviewer """ @@ -252,7 +252,7 @@ def get_linenos(obj): # set project_dir: project/docs/source/conf.py/../../.. → project/ project_dir = Path(__file__).parent.parent.parent -github_url_scvelo = "https://github.com/theislab/scvelo/tree/master" +github_url_scvelo = "https://github.com/theislab/scvelo/tree/main" github_url_read_loom = "https://github.com/theislab/anndata/tree/master/anndata" github_url_read = "https://github.com/theislab/scanpy/tree/master" github_url_scanpy = "https://github.com/theislab/scanpy/tree/master/scanpy" diff --git a/docs/source/index.rst b/docs/source/index.rst index 266153ba..a12b2be9 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -103,7 +103,7 @@ For further information visit `scvelo.org `_. .. |Docs| image:: https://readthedocs.org/projects/scvelo/badge/?version=latest :target: https://scvelo.readthedocs.io -.. |travis| image:: https://travis-ci.org/theislab/scvelo.svg?branch=master +.. |travis| image:: https://travis-ci.org/theislab/scvelo.svg?branch=main :target: https://travis-ci.org/theislab/scvelo .. _Scanpy: https://scanpy.readthedocs.io diff --git a/scvelo/datasets/_biomart.py b/scvelo/datasets/_biomart.py new file mode 100644 index 00000000..e69de29b diff --git a/scvelo/datasets/_load.py b/scvelo/datasets/_load.py new file mode 100644 index 00000000..e69de29b diff --git a/scvelo/datasets/_read.py b/scvelo/datasets/_read.py new file mode 100644 index 00000000..d47e1573 --- /dev/null +++ b/scvelo/datasets/_read.py @@ -0,0 +1,52 @@ +import os +from pathlib import Path +from urllib.request import urlretrieve + +import numpy as np +import pandas as pd + + +def load(filename, backup_url=None, header="infer", index_col="infer", **kwargs): + """Load a csv, txt, tsv or npy file.""" + numpy_ext = {"npy", "npz"} + pandas_ext = {"csv", "txt", "tsv"} + + if not os.path.exists(filename) and backup_url is None: + raise FileNotFoundError(f"Did not find file {filename}.") + + elif not os.path.exists(filename): + d = os.path.dirname(filename) + if not os.path.exists(d): + os.makedirs(d) + urlretrieve(backup_url, filename) + + ext = Path(filename).suffixes[-1][1:] + + if ext in numpy_ext: + return np.load(filename, **kwargs) + + elif ext in pandas_ext: + df = pd.read_csv( + filename, + header=header, + index_col=None if index_col == "infer" else index_col, + **kwargs, + ) + if index_col == "infer" and len(df.columns) > 1: + is_int_index = all(np.arange(0, len(df)) == df.iloc[:, 0]) + is_str_index = isinstance(df.iloc[0, 0], str) and all( + [not isinstance(d, str) for d in df.iloc[0, 1:]] + ) + if is_int_index or is_str_index: + df.set_index(df.columns[0], inplace=True) + return df + + else: + raise ValueError( + f"'{filename}' does not end on a valid extension.\n" + "Please, provide one of the available extensions.\n" + f"{numpy_ext | pandas_ext}\n" + ) + + +read_csv = load From a6c4c42c70c692837e1d0f06d73cc36934a67e12 Mon Sep 17 00:00:00 2001 From: Philipp Weiler Date: Sat, 2 Dec 2023 11:04:48 +0100 Subject: [PATCH 2/2] Update `ci.yml` Update branches triggering CI. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37e97261..fd341688 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,9 +2,9 @@ name: CI on: push: - branches: [master, develop, "release/**"] + branches: [main] pull_request: - branches: [master, develop, "release/**"] + branches: [main] jobs: # Skip CI if commit message contains `[ci skip]` in the subject