Skip to content

Commit 2671140

Browse files
authored
Implement base BiocObject class and improvements to NamedList classes (#29)
* Provide a base `BiocObject` class similar to the `Annotated` class in Bioconductor. The class provides `metadata` slot, accessors and validation functions. * Renaming code files to follow pep guidelines * Update Github actions and workflow to the new biocsetup versions * Changes to improve `NamedList`, `Names` classes * get name at index, delete method, is_unique etc * fix ruff-lint errors * linting, documentation, type hints etc
1 parent 8846ee0 commit 2671140

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1042
-519
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish to PyPI
2+
3+
on:
4+
push:
5+
tags: "*"
6+
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
id-token: write
12+
repository-projects: write
13+
contents: write
14+
pages: write
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python 3.12
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: 3.12
23+
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install tox
28+
29+
- name: Test with tox
30+
run: |
31+
tox
32+
33+
- name: Build Project and Publish
34+
run: |
35+
python -m tox -e clean,build
36+
37+
# This uses the trusted publisher workflow so no token is required.
38+
- name: Publish to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
41+
- name: Build docs
42+
run: |
43+
tox -e docs
44+
45+
- run: touch ./docs/_build/html/.nojekyll
46+
47+
- name: GH Pages Deployment
48+
uses: JamesIves/github-pages-deploy-action@v4
49+
with:
50+
branch: gh-pages # The branch the action should deploy to.
51+
folder: ./docs/_build/html
52+
clean: true # Automatically remove deleted files from the deploy branch

.github/workflows/pypi-publish.yml

Lines changed: 0 additions & 51 deletions
This file was deleted.

.github/workflows/pypi-test.yml

Lines changed: 0 additions & 40 deletions
This file was deleted.

.github/workflows/run-tests.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Test the library
2+
3+
on:
4+
push:
5+
branches:
6+
- master # for legacy repos
7+
- main
8+
pull_request:
9+
branches:
10+
- master # for legacy repos
11+
- main
12+
workflow_dispatch: # Allow manually triggering the workflow
13+
schedule:
14+
# Run roughly every 15 days at 00:00 UTC
15+
# (useful to check if updates on dependencies break the package)
16+
- cron: "0 0 1,16 * *"
17+
18+
permissions:
19+
contents: read
20+
21+
concurrency:
22+
group: >-
23+
${{ github.workflow }}-${{ github.ref_type }}-
24+
${{ github.event.pull_request.number || github.sha }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
test:
29+
strategy:
30+
matrix:
31+
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
32+
platform:
33+
- ubuntu-latest
34+
- macos-latest
35+
- windows-latest
36+
runs-on: ${{ matrix.platform }}
37+
name: Python ${{ matrix.python }}, ${{ matrix.platform }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: actions/setup-python@v5
42+
id: setup-python
43+
with:
44+
python-version: ${{ matrix.python }}
45+
46+
- name: Install dependencies
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install tox coverage
50+
51+
- name: Run tests
52+
run: >-
53+
pipx run --python '${{ steps.setup-python.outputs.python-path }}'
54+
tox
55+
-- -rFEx --durations 10 --color yes --cov --cov-branch --cov-report=xml # pytest args
56+
57+
- name: Check for codecov token availability
58+
id: codecov-check
59+
shell: bash
60+
run: |
61+
if [ ${{ secrets.CODECOV_TOKEN }} != '' ]; then
62+
echo "codecov=true" >> $GITHUB_OUTPUT;
63+
else
64+
echo "codecov=false" >> $GITHUB_OUTPUT;
65+
fi
66+
67+
- name: Upload coverage reports to Codecov with GitHub Action
68+
uses: codecov/codecov-action@v5
69+
if: ${{ steps.codecov-check.outputs.codecov == 'true' }}
70+
env:
71+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
72+
slug: ${{ github.repository }}
73+
flags: ${{ matrix.platform }} - py${{ matrix.python }}

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
# Changelog
22

3-
## Version 0.3.0
3+
## Version 0.3.0 - 0.3.1
44

55
- Provide a base `BiocObject` class similar to the `Annotated` class in Bioconductor. The class provides `metadata` slot, accessors and validation functions.
6+
- Renaming code files to follow pep guidelines
7+
- Update Github actions and workflow to the new biocsetup versions
8+
- Changes to improve `NamedList`, `Names` classes
9+
- get name at index
10+
- delete method for namedlist/names
11+
- add is_unique
12+
- add lint errors
13+
- linting documentation, typehints etc
614

715
## Version 0.2.3
816

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
PyScaffold helps you to put up the scaffold of your new Python project.
55
Learn more under: https://pyscaffold.org/
66
"""
7+
78
from setuptools import setup
89

910
if __name__ == "__main__":

src/biocutils/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
finally:
1616
del version, PackageNotFoundError
1717

18-
from .Factor import Factor
19-
from .StringList import StringList
20-
from .IntegerList import IntegerList
21-
from .FloatList import FloatList
22-
from .BooleanList import BooleanList
23-
from .Names import Names
24-
from .NamedList import NamedList
18+
from .factor import Factor
19+
from .string_list import StringList
20+
from .integer_list import IntegerList
21+
from .float_list import FloatList
22+
from .boolean_list import BooleanList
23+
from .names import Names
24+
from .named_list import NamedList
2525

2626
from .factorize import factorize
2727
from .intersect import intersect
@@ -60,3 +60,5 @@
6060

6161
from .get_height import get_height
6262
from .is_high_dimensional import is_high_dimensional
63+
64+
from .bioc_object import BiocObject

src/biocutils/_utils_combine.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def _check_array_dimensions(x, active: int) -> bool:
2626
+ ")"
2727
)
2828

29+
return True
30+
2931

3032
def _coerce_sparse_matrix(first, combined, module):
3133
if isinstance(first, module.csr_matrix):

src/biocutils/assign.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ def assign(x: Any, indices: Sequence[int], replacement: Any) -> Any:
1414
:py:func:`~biocutils.assign_sequence.assign_sequence` instead.
1515
1616
Args:
17-
x: Object to be assignted.
17+
x:
18+
Object to be assignted.
1819
1920
Returns:
2021
The object after assignment, typically the same type as ``x``.

src/biocutils/assign_rows.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ def assign_rows(x: Any, indices: Sequence[int], replacement: Any) -> Any:
3131
tmp = [slice(None)] * len(x.shape)
3232
tmp[0] = indices
3333
output[(*tmp,)] = replacement
34+
3435
return output
3536

3637

3738
@assign_rows.register
38-
def _assign_rows_numpy(
39-
x: numpy.ndarray, indices: Sequence[int], replacement: Any
40-
) -> numpy.ndarray:
39+
def _assign_rows_numpy(x: numpy.ndarray, indices: Sequence[int], replacement: Any) -> numpy.ndarray:
4140
tmp = [slice(None)] * len(x.shape)
4241
tmp[0] = indices
4342
output = numpy.copy(x)
4443
output[(*tmp,)] = replacement
44+
4545
return output

0 commit comments

Comments
 (0)