Skip to content

Fix issues #6-#9 (Cython 3 / numpy 2 build, sdist, version, Read the Docs), add CI - #10

Merged
yoch merged 6 commits into
masterfrom
fix/issues-6-7-8-9
Oct 20, 2026
Merged

yoch merged 6 commits into
masterfrom
fix/issues-6-7-8-9

Conversation

@yoch

@yoch yoch commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Fixes #6, #7, #8 and #9, and adds a test workflow.

Changes

Found along the way:

  • activation_map failed when scikit-learn was not installed (it is optional), with ValueError: could not interpret dimensions. The fallback received the 3D codebook. The codebook is now reshaped to one row per node, as a view, on both paths, and the fallback returns the same (nodes, samples) array as pairwise_distances. This also replaces the codebook.shape = ... assignment that NumPy 2.5 deprecates.
  • The \**kwargs docstrings of SomClassifier raised a SyntaxWarning on import with Python 3.12+.

CI: .github/workflows/tests.yml builds the sdist in an isolated environment, installs it and runs the tests outside the checkout. It runs on Linux, with Python 3.9 to 3.14 and with numpy<2, and builds the docs the way Read the Docs does. Windows fails to build with MSVC, whose OpenMP 2.0 does not accept this code (#11), and macOS has the OpenMP problem of #3: both are left out until they build.

The development notes in python/README.md are updated to match.

Verification

  • Install: the sdist built by uv build --sdist, which runs in an isolated environment without Cython at runtime, installs and passes all 60 tests (56 existing, 4 new) on:

    • Python 3.12 + numpy 2.5.4;
    • Python 3.13 + numpy 2.5.4;
    • Python 3.12 + numpy 1.26.4.

    There are no warnings left.

  • Without scikit-learn: activation_map returns (nodes, samples) for Som and BSom. The new test checks that this matches the sklearn result.

  • Docs: sphinx-build on python/doc/source, with the package installed, builds cleanly and documents the extension's classes.

  • Not checked: an actual Read the Docs build. The project's default branch and version settings are on the RTD dashboard.

OpenMP on macOS (#3) is not addressed here: -fopenmp is still passed unconditionally on POSIX.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP

yoch and others added 5 commits October 20, 2026 07:52
… source

- pyproject.toml declares setuptools, Cython>=3.0.11 and numpy>=1.26 as build
  requirements, so isolated builds (pip, build) work.
- setup.py always compiles som.pyx; the committed som.cpp, generated by
  Cython 0.29 and broken on Python 3.11+ (longintrepr.h), is removed and
  ignored. The distutils fallback, gone in Python 3.12, goes with it.
- som.pyx drops the comma-separated '# distutils: sources' directive, which
  Cython 3 reads as one path; setup.py already lists the C++ sources.
- MANIFEST.in ships som.pyx, the C++ sources and headers, never som.cpp.
- __version__ in sparse_som/__init__.py is the only version, read by setup.py;
  bumped to 0.6.2.

Fixes #6, fixes #7, fixes #8.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
The docs install the package from this checkout (autodoc reads the compiled
extension's docstrings) instead of the PyPI release, and take their version
from its metadata.

Fixes #9.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
scikit-learn is optional, but its fallback passed the 3D codebook to the
distance computation and failed with 'could not interpret dimensions'.
The codebook is now reshaped to one row per node (a view) for both paths,
which also replaces the in-place shape assignment NumPy 2.5 deprecates, and
the fallback returns the same (nodes, samples) array as pairwise_distances.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
Python 3.12 warns about the invalid '\*' escape sequence on import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
Builds the sdist (isolated build), installs it and runs the tests outside the
checkout, on Linux for Python 3.9 to 3.14, numpy<2 and Windows; builds the docs
as Read the Docs does. macOS is left out until OpenMP is handled there (#3).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XUT7Yj2eYmEyHV5fiicMsP
@yoch
yoch changed the base branch from seo/discoverability to master October 20, 2026 05:07
@yoch yoch changed the title Fix issues #6-#9 (Cython 3 / numpy 2 build, sdist, version, Read the Docs) Fix issues #6-#9 (Cython 3 / numpy 2 build, sdist, version, Read the Docs), add CI Oct 20, 2026
@yoch
yoch merged commit 51a766b into master Oct 20, 2026
8 checks passed
@yoch
yoch deleted the fix/issues-6-7-8-9 branch October 20, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build fails with Cython 3 and, from the committed som.cpp, on Python 3.11+

1 participant