Skip to content

Conversation

Copy link

Copilot AI commented Jan 21, 2026

The compute_scales function had defensive logic for G_new == 0 in the consistency check but no upfront validation, allowing physically invalid values to propagate through calculations.

Changes

  • Input validation: Check G_new and G_old are positive at function entry, raising ValueError with physically-motivated error message
  • Simplified consistency check: Removed ternary operator (abs(G_new) if G_new != 0 else 1.0) since validation guarantees G_new > 0
def compute_scales(G_old, G_new, s_L, s_V, s_M):
    # Validate G_new is physically meaningful
    if G_new <= 0:
        raise ValueError(f"G_new must be positive (got {G_new}). Zero or negative gravitational constants are not physically meaningful.")
    if G_old <= 0:
        raise ValueError(f"G_old must be positive (got {G_old}). Zero or negative gravitational constants are not physically meaningful.")
    # ... rest of function

This prevents division-by-zero and provides clear error messages for invalid inputs rather than confusing mathematical errors downstream.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits January 21, 2026 21:50
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>
Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
Copilot AI changed the title [WIP] Update unit conversion explanation and script based on feedback Add input validation for gravitational constants in compute_scales Jan 21, 2026
Copilot AI requested a review from The9Cat January 21, 2026 21:54
@The9Cat The9Cat marked this pull request as ready for review January 21, 2026 21:55
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.

Yes, looks good.

@The9Cat The9Cat merged commit 0e536a6 into units Jan 21, 2026
@The9Cat The9Cat deleted the copilot/sub-pr-11 branch January 21, 2026 21:56
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