Skip to content

Fix divide-by-zero in ExpDeproj::initialize() when ngrid < 2#201

Merged
The9Cat merged 4 commits intoSphericalExactfrom
copilot/sub-pr-199
Feb 4, 2026
Merged

Fix divide-by-zero in ExpDeproj::initialize() when ngrid < 2#201
The9Cat merged 4 commits intoSphericalExactfrom
copilot/sub-pr-199

Conversation

Copy link

Copilot AI commented Feb 4, 2026

The initialize() method computed dlogr = (log_rmax - log_rmin)/(ngrid - 1) but only validated ngrid > 0, causing division by zero when ngrid == 1.

Changes

  • Updated validation to require ngrid >= 2
  • Changed error message from "n must be positive" to "n must be at least 2"
void ExpDeproj::initialize()
{
-  if (ngrid <= 0) {
-    throw std::invalid_argument("n must be positive");
+  if (ngrid < 2) {
+    throw std::invalid_argument("n must be at least 2");
  }
  // ...
  double dlogr = (log_rmax - log_rmin)/static_cast<double>(ngrid - 1);

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

Copilot AI and others added 3 commits February 4, 2026 15:12
Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
Copy link
Author

Copilot AI commented Feb 4, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Address feedback on spherical basis for exponential surface density implementation Fix divide-by-zero in ExpDeproj::initialize() when ngrid < 2 Feb 4, 2026
Copilot AI requested a review from The9Cat February 4, 2026 15:17
Copy link
Member

@The9Cat The9Cat left a comment

Choose a reason for hiding this comment

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

All good.

@The9Cat The9Cat marked this pull request as ready for review February 4, 2026 15:20
@The9Cat The9Cat merged commit 31d44f3 into SphericalExact Feb 4, 2026
@The9Cat The9Cat deleted the copilot/sub-pr-199 branch February 4, 2026 15:20
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.

2 participants