Skip to content

Fix edge case in LaminarCurrentSourceDensity, use Poetry for builds, Python >= 3.10#197

Merged
espenhgn merged 11 commits intomasterfrom
espenhgn/issue196
Apr 10, 2026
Merged

Fix edge case in LaminarCurrentSourceDensity, use Poetry for builds, Python >= 3.10#197
espenhgn merged 11 commits intomasterfrom
espenhgn/issue196

Conversation

@espenhgn
Copy link
Copy Markdown
Contributor

@espenhgn espenhgn commented Mar 30, 2026

Description

Updates LFPykit's packaging and CI to modern Python/PEP 517 tooling while fixing an edge case in LaminarCurrentSourceDensity that caused non-zero CSD sums in certain geometries.

Changes:

  • Fix LaminarCurrentSourceDensity.get_transformation_matrix() fraction calculation when radius constraints are non-binding (z-plane crossing vs r–z intersection).
  • Add Poetry-based pyproject.toml, remove legacy setup.py / setup.cfg, and bump version to 0.6.0 with Python >=3.10.
  • Fix [tool.poetry.extras]: declare pytest, sympy, sphinx, numpydoc, sphinx_rtd_theme, and recommonmark as optional dependencies in [tool.poetry.dependencies] so that poetry install -E tests and poetry install -E docs work correctly, mirroring the old extras_require behavior from setup.py.
  • Extend CI matrix to newer Python versions and add regression tests covering the edge case fix.

Related Issue

Motivation and Context

The LaminarCurrentSourceDensity class produced non-zero CSD sums in certain geometries due to an incorrect fraction calculation. The legacy setup.py-based packaging was replaced with a Poetry/PEP 517 setup for modern tooling support. The initial Poetry extras configuration was missing the required optional dependency declarations, preventing extras from being installable.

How Has This Been Tested

  • Regression tests added covering the LaminarCurrentSourceDensity edge case.
  • Poetry extras validated by ensuring all packages listed in [tool.poetry.extras] are declared as optional in [tool.poetry.dependencies].
  • CI matrix extended to newer Python versions to verify compatibility.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@espenhgn espenhgn added enhancement New feature or request bug fix fixes some issue labels Mar 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates LFPykit’s packaging and CI to modern Python/PEP 517 tooling while fixing an edge case in LaminarCurrentSourceDensity that caused non-zero CSD sums in certain geometries (Issue #196).

Changes:

  • Fix LaminarCurrentSourceDensity.get_transformation_matrix() fraction calculation when radius constraints are non-binding (z-plane crossing vs r–z intersection).
  • Add Poetry-based pyproject.toml, remove legacy setup.py / setup.cfg, and bump version to 0.6.0 with Python >=3.10.
  • Extend CI matrix to newer Python versions and add regression tests covering Issue #196.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
setup.py Removed legacy setuptools build script in favor of PEP 517/Poetry.
setup.cfg Removed legacy setuptools metadata config.
pyproject.toml Introduces Poetry build configuration and dependency declarations.
lfpykit/version.py Version bump to 0.6.0.
lfpykit/tests/test_module.py Adds regression tests for Laminar CSD Issue #196; renames test ids for consistency.
lfpykit/models.py Fixes Laminar CSD volume fraction calculation and simplifies _PrPz segment-hit logic.
.gitignore Ignores macOS archive artifacts and an additional model directory.
.github/workflows/python-app.yml Updates CI Python version matrix to 3.10–3.14.
.github/workflows/flake8.yml Updates lint job Python version to 3.12.
.github/workflows/coveralls.yml Updates coverage job Python version to 3.12.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml Outdated
Comment thread pyproject.toml
…eferencing in extras

Agent-Logs-Url: https://github.com/LFPy/LFPykit/sessions/6172e06c-8d32-44a4-9019-3a15086bbb76

Co-authored-by: espenhgn <2492641+espenhgn@users.noreply.github.com>
espenhgn and others added 5 commits March 30, 2026 12:51
It is easy to miss that the top link is to the LFPy documentation, and not the LFPykit documentation. I suggest adding the LFPykit documentation link at the top.
Comment thread lfpykit/models.py Outdated
Copy link
Copy Markdown
Collaborator

@torbjone torbjone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ready to merge.

@espenhgn espenhgn merged commit 996d854 into master Apr 10, 2026
11 checks passed
@espenhgn espenhgn deleted the espenhgn/issue196 branch April 10, 2026 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix fixes some issue enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants