Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish to PyPI

on:
push:
tags: "*"

jobs:
build:
runs-on: ubuntu-latest
permissions:
id-token: write
repository-projects: write
contents: write
pages: write

steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox

- name: Test with tox
run: |
tox

- name: Build Project and Publish
run: |
python -m tox -e clean,build

# This uses the trusted publisher workflow so no token is required.
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Publish to PyPI' step
Uses Step
uses 'pypa/gh-action-pypi-publish' with ref 'release/v1', not a pinned commit hash

- name: Build docs
run: |
tox -e docs

- run: touch ./docs/_build/html/.nojekyll

- name: GH Pages Deployment
uses: JamesIves/github-pages-deploy-action@v4

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Publish to PyPI' step
Uses Step
uses 'JamesIves/github-pages-deploy-action' with ref 'v4', not a pinned commit hash
with:
branch: gh-pages # The branch the action should deploy to.
folder: ./docs/_build/html
clean: true # Automatically remove deleted files from the deploy branch
51 changes: 0 additions & 51 deletions .github/workflows/pypi-publish.yml

This file was deleted.

40 changes: 0 additions & 40 deletions .github/workflows/pypi-test.yml

This file was deleted.

73 changes: 73 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Test the library

on:
push:
branches:
- master # for legacy repos
- main
pull_request:
branches:
- master # for legacy repos
- main
workflow_dispatch: # Allow manually triggering the workflow
schedule:
# Run roughly every 15 days at 00:00 UTC
# (useful to check if updates on dependencies break the package)
- cron: "0 0 1,16 * *"

permissions:
contents: read

concurrency:
group: >-
${{ github.workflow }}-${{ github.ref_type }}-
${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
test:
strategy:
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
platform:
- ubuntu-latest
- macos-latest
- windows-latest
runs-on: ${{ matrix.platform }}
name: Python ${{ matrix.python }}, ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
id: setup-python
with:
python-version: ${{ matrix.python }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox coverage

- name: Run tests
run: >-
pipx run --python '${{ steps.setup-python.outputs.python-path }}'
tox
-- -rFEx --durations 10 --color yes --cov --cov-branch --cov-report=xml # pytest args

- name: Check for codecov token availability
id: codecov-check
shell: bash
run: |
if [ ${{ secrets.CODECOV_TOKEN }} != '' ]; then
echo "codecov=true" >> $GITHUB_OUTPUT;
else
echo "codecov=false" >> $GITHUB_OUTPUT;
fi

- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v5

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Test the library' step
Uses Step
uses 'codecov/codecov-action' with ref 'v5', not a pinned commit hash
if: ${{ steps.codecov-check.outputs.codecov == 'true' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
flags: ${{ matrix.platform }} - py${{ matrix.python }}
16 changes: 9 additions & 7 deletions src/biocutils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
finally:
del version, PackageNotFoundError

from .Factor import Factor
from .StringList import StringList
from .IntegerList import IntegerList
from .FloatList import FloatList
from .BooleanList import BooleanList
from .Names import Names
from .NamedList import NamedList
from .factor import Factor
from .string_list import StringList
from .integer_list import IntegerList
from .float_list import FloatList
from .boolean_list import BooleanList
from .names import Names
from .named_list import NamedList

from .factorize import factorize
from .intersect import intersect
Expand Down Expand Up @@ -60,3 +60,5 @@

from .get_height import get_height
from .is_high_dimensional import is_high_dimensional

from .bioc_object import BiocObject
2 changes: 1 addition & 1 deletion src/biocutils/bioc_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
except ImportError:
Self = "BiocObject"

from .NamedList import NamedList
from .named_list import NamedList

__author__ = "Jayaram Kancherla"
__copyright__ = "jkanche"
Expand Down
23 changes: 19 additions & 4 deletions src/biocutils/BooleanList.py → src/biocutils/boolean_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Iterable, Optional, Sequence, Union

from .NamedList import NamedList
from .Names import Names
from .named_list import NamedList
from .names import Names
from .normalize_subscript import SubscriptTypes


Expand All @@ -10,10 +10,25 @@ def _coerce_to_bool(x: Any):


class _SubscriptCoercer:
def __init__(self, data):
"""Coercer for subscript operations on BooleanList."""

def __init__(self, data: Sequence) -> None:
"""Initialize the coercer.

Args:
data: Sequence of values to coerce.
"""
self._data = data

def __getitem__(self, index):
def __getitem__(self, index: int) -> Optional[bool]:
"""Get an item and coerce it to boolean.

Args:
index: Index of the item.

Returns:
Coerced boolean value.
"""
return _coerce_to_bool(self._data[index])


Expand Down
2 changes: 1 addition & 1 deletion src/biocutils/combine_rows.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def _combine_rows_sparse_arrays(*x):
_check_array_dimensions(x, 0)
if is_list_of_type(x, sp.sparray):
combined = sp.vstack(x)
return _coerce_sparse_array(first, combined, sp)
return _coerce_sparse_array(x[0], combined, sp)

warn("not all elements are SciPy sparse arrays")
x = [convert_to_dense(y) for y in x]
Expand Down
2 changes: 1 addition & 1 deletion src/biocutils/extract_column_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def extract_column_names(x: Any) -> numpy.ndarray:
"""Access column names from 2-dimensional representations.

Args:
x: Any object.
x: Any object with column names.

Returns:
Array of strings containing column names.
Expand Down
2 changes: 1 addition & 1 deletion src/biocutils/extract_row_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def extract_row_names(x: Any) -> numpy.ndarray:
"""Access row names from 2-dimensional representations.

Args:
x: Any object.
x: Any object with row names.

Returns:
Array of strings containing row names.
Expand Down
4 changes: 2 additions & 2 deletions src/biocutils/Factor.py → src/biocutils/factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from .is_list_of_type import is_list_of_type
from .is_missing_scalar import is_missing_scalar
from .match import match
from .Names import Names, _combine_names, _name_to_position, _sanitize_names
from .names import Names, _combine_names, _name_to_position, _sanitize_names
from .normalize_subscript import (
NormalizedSubscript,
SubscriptTypes,
normalize_subscript,
)
from .print_truncated import print_truncated_list
from .StringList import StringList
from .string_list import StringList
from .subset_sequence import subset_sequence


Expand Down
23 changes: 19 additions & 4 deletions src/biocutils/FloatList.py → src/biocutils/float_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, Iterable, Optional, Sequence, Union

from .NamedList import NamedList
from .Names import Names
from .named_list import NamedList
from .names import Names
from .normalize_subscript import SubscriptTypes


Expand All @@ -15,10 +15,25 @@ def _coerce_to_float(x: Any):


class _SubscriptCoercer:
def __init__(self, data):
"""Coercer for subscript operations on FloatList."""

def __init__(self, data: Sequence) -> None:
"""Initialize the coercer.

Args:
data: Sequence of values to coerce.
"""
self._data = data

def __getitem__(self, index):
def __getitem__(self, index: int) -> Optional[float]:
"""Get an item and coerce it to float.

Args:
index: Index of the item.

Returns:
Coerced float value.
"""
return _coerce_to_float(self._data[index])


Expand Down
Loading