Skip to content
Merged
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ jobs:
- name: Install dependencies
run: |
uv sync --locked --all-extras --group test --no-default-groups --python 3.12
- name: Install minimum supported Xarray and SciPy
- name: Install minimum supported Xarray, SciPy and Dask
run: |
uv pip install --python .venv 'xarray==2026.9.0' 'scipy==1.16.2'
uv pip install --python .venv 'xarray==2026.9.0' 'scipy==1.16.2' 'dask[array,dataframe]==2025.2.0'
- name: Run tests
run: |
uv run --no-sync pytest
3 changes: 0 additions & 3 deletions .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ jobs:
sudo apt update -y
sudo apt install graphviz # Needed for documentation
uv sync --locked --all-extras --group docs --group lint --no-default-groups --python "${{ matrix.python-version }}"
# Use newer Dask for task-graph rendering with NumPy 2.
uv pip uninstall --python .venv dask-expr
uv pip install --python .venv 'dask==2026.8.0'
- name: Run pre-commit
run: uv run --no-sync pre-commit run --all-files
- name: Check for Sphinx doc warnings
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ jobs:
sudo apt update -y
sudo apt install graphviz # Needed for documentation
uv sync --locked --all-extras --group docs --no-default-groups --python "3.12"
# Use newer Dask for task-graph rendering with NumPy 2.
uv pip uninstall --python .venv dask-expr
uv pip install --python .venv 'dask==2026.8.0'
- name: Build Sphinx documentation
run: |
make -C docs html SPHINXOPTS="-W --keep-going -n"
Expand Down
3 changes: 3 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Breaking changes
Require SciPy >= 1.16.2. (:issue:`1360`)
- Require Zarr Python >= 3 and Xarray >= 2026.9.0. The default on-disk Zarr
format remains 2. (:issue:`1355`)
- Require Dask >= 2025.2.0 and remove the upper bound on Dask. (:issue:`1267`)
- **Remove BGEN reading and conversion**: ``sgkit.io.bgen.read_bgen``,
``sgkit.io.bgen.bgen_to_zarr`` and ``sgkit.io.bgen.rechunk_bgen``, along with
the ``bgen`` extra and the cbgen and rechunker dependencies.
Expand Down Expand Up @@ -67,6 +68,8 @@ Bug fixes
- Fixed bug causing high memory usage in :func:`pedigree_kinship` when
evaluating a chunked relationship matrix with the Hamilton-Kerr method.
(:user:`timothymillar`, :pr:`1335`, :issue:`1333`)
- :func:`Tajimas_D` now works with newer versions of Dask, and no longer
computes allele counts when it is called.

.. Documentation
.. ~~~~~~~~~~~~~
Expand Down
6 changes: 4 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ def filter(self, record: pylogging.LogRecord) -> bool:

autosummary_generate = True

# sphinx-autodoc-typehints refers to Zarr's StoreLike type alias as
# zarr.core.group.StoreLike, but Zarr documents it as zarr.storage.StoreLike.
qualname_overrides = {"zarr.core.group.StoreLike": "zarr.storage.StoreLike"}

nitpick_ignore = [
("py:class", "sgkit.display.GenotypeDisplay"),
# Zarr's StoreLike alias is rendered as an undocumented TypeAliasType.
("py:class", "zarr.storage._common.TypeAliasType"),
]


Expand Down
16 changes: 2 additions & 14 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -270,21 +270,13 @@ and API documentation.
Building the documentation requires the Graphviz ``dot`` executable, which you
can install by following `these instructions <https://graphviz.org/download/#executable-packages>`_.

Documentation builds use the same ``.venv`` as development. Task-graph
visualization with NumPy 2 needs a newer Dask than the current runtime bound.
From the repository root, on macOS or Linux, prepare the environment and build
with ``make``::
Documentation builds use the same ``.venv`` as development. From the repository
root, on macOS or Linux, prepare the environment and build with ``make``::

uv sync --locked
uv pip uninstall --python .venv dask-expr
uv pip install --python .venv 'dask==2026.8.0'
cd docs
make html

The old ``dask-expr`` package is removed because it pins the runtime Dask version.
The Makefile uses ``uv run --no-sync`` to preserve the Dask override during builds.
Docs CI applies the same override.

The resulting HTML files are in ``_build/html``. After editing documentation,
run ``make html`` again.

Expand All @@ -293,10 +285,6 @@ locally with::

make clean html SPHINXOPTS="-W --keep-going -n"

Before running tests, restore the locked development dependencies with
``uv sync --locked`` from the repository root. Repeat the Dask setup above when
you next build the documentation.

.. _Sphinx: https://www.sphinx-doc.org/

Review process
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ dependencies = [
"numpy >= 2.3.5; sys_platform == \"darwin\"", # Apple ARM chip error
"numpy >= 2.0; sys_platform != \"darwin\"",
"xarray >= 2026.9.0",
"dask[array,dataframe] >= 2022.01.0, <= 2024.8.0",
"dask[array,dataframe] >= 2025.2.0",
"scipy >= 1.16.2",
"zarr >= 3",
"numba",
"fsspec != 2021.6.*",
"fsspec",
"scikit-learn",
"pandas < 3.0",
]
Expand Down Expand Up @@ -64,14 +64,14 @@ docs = [
"graphviz",
"myst_nb",
"pydata-sphinx-theme",
"sphinx < 9.0.0",
"sphinx",
"sphinx_autodoc_typehints",
"sphinx-copybutton",
"scanpydoc",
"ipython",
"matplotlib",
"seaborn",
"ablog!=0.10.27",
"ablog",
"pickleshare",
]
lint = [
Expand Down
12 changes: 9 additions & 3 deletions sgkit/stats/popgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ def Fst(
return conditional_merge_datasets(ds, new_ds, merge)


def _harmonic_sum(n: np.ndarray, power: int) -> np.ndarray:
# sum of 1 / k**power for k = 1, ..., n - 1
return np.asarray((1 / np.arange(1, n) ** power).sum())


def Tajimas_D(
ds: Dataset,
*,
Expand Down Expand Up @@ -470,8 +475,9 @@ def Tajimas_D(
# because the computation below requires floats
n = ac.sum(axis=1, dtype="float").max()

# (n-1)th harmonic number
a1 = (1 / da.arange(1, n)).sum()
# (n-1)th harmonic number. n is a lazy scalar, so compute the sum
# blockwise rather than passing it to da.arange as a stop value.
a1 = da.map_blocks(_harmonic_sum, n, 1, dtype=np.float64)

# calculate Watterson's theta (absolute value)
theta = S / a1
Expand All @@ -484,7 +490,7 @@ def Tajimas_D(
d = div - theta[:, np.newaxis]

# calculate the denominator (standard deviation)
a2 = (1 / (da.arange(1, n) ** 2)).sum()
a2 = da.map_blocks(_harmonic_sum, n, 2, dtype=np.float64)
b1 = (n + 1) / (3 * (n - 1))
b2 = 2 * (n**2 + n + 3) / (9 * n * (n - 1))
c1 = b1 - (1 / a1)
Expand Down
5 changes: 3 additions & 2 deletions sgkit/stats/truncated_svd.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,10 @@ def fit_transform(self, X, y=None):
)
if self.algorithm == "tsqr":
if has_keyword(da.linalg.svd, "full_matrices"):
u, s, v = da.linalg.svd(X, full_matrices=False) # pragma: no cover
u, s, v = da.linalg.svd(X, full_matrices=False)
else:
u, s, v = da.linalg.svd(X)
# Dask versions before 2026.3.0 have no full_matrices argument
u, s, v = da.linalg.svd(X) # pragma: no cover
u = u[:, : self.n_components]
s = s[: self.n_components]
v = v[: self.n_components]
Expand Down
Loading
Loading