Implementation of Fortran API for PSO#34
Merged
Merged
Conversation
…thon - Add src/pso.f: ONE Fortran 77 subroutine PSO that performs a complete PSO iteration step (personal-best update, global-best update, velocity update, position update + clamping, integer rounding) - Add src/_pyswarm.pyf: f2py interface with intent(hide) dimension args giving clean Python call signature with no exposed size arguments - Add src/meson.build: builds _pyswarm extension module via f2py/meson, installs into pyswarm/ package directory (subdir: 'pyswarm') - Add meson.build: root meson project (fortran+c), version from setuptools_scm - Add pyswarm/meson.build: installs pure-Python package sources - Replace pyproject.toml build-system: hatchling → meson-python + setuptools_scm; add [tool.cibuildwheel] and [tool.setuptools_scm] - Delete pyswarm/pso.py: no separate PSO Python module needed - Rewrite pyswarm/__init__.py: scipy.optimize-style OptimizeResult, pso() wrapper drives outer loop + obj evaluation, delegates every PSO math step to the single Fortran kernel (_pso_step) - Update all tests: import from pyswarm (not pyswarm.pso), use result.x / result.fun instead of tuple unpacking - Add bin/build.py, bin/get_version.py (from f2py-tpl reference) - Update .github/workflows/dist_build.yml: cibuildwheel multi-platform wheel builds (Linux x86_64, macOS arm64, Windows AMD64) - Update .gitignore: add meson build artefact patterns Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
f00313c to
b604458
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
7a516a3 to
5516f16
Compare
- src/pso.f: rewrite as ONE complete Fortran 77 subroutine that runs the entire PSO algorithm (init, MAXITER loop, convergence checks). Uses an f2py EXTERNAL callback EVAL that Fortran calls per particle — zero Python loops in pso(); feasibility encoded as return >= 1.0D300. All dummy arrays use adjustable dimensions (valid F77), workspace arrays FX and XTMP are hidden dummy args allocated by f2py. - src/_pyswarm.pyf: add __user__routines module for callback signature; MAXITER/NSWARM/NDIM/NIVAR hidden via intent(hide)+depend; FX/XTMP hidden workspace; X/V intent(in,out); G/FG/P/FP/NITERS/STATUS out. - pyswarm/__init__.py: remove the while-loop entirely; Python only validates inputs, builds _eval closure (obj + feasibility sentinel), pre-generates rnd_p/rnd_g, calls _fortran_pso() once, unpacks result. - pyswarm/meson.build: remove pso.py from install_sources (it was deleted in the first commit); fixes 'File pso.py does not exist' error. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…available Ensure __init__.py is packaged into the pyswarm package so the compiled extension and package import correctly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
778e79d to
51ab07f
Compare
4d74dea to
1a87a70
Compare
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.