Skip to content

Guard branching plane computation against zero-norm vectors#1

Draft
Kalpa08 wants to merge 1 commit intomainfrom
codex/assess-package-stability-and-provide-feedback
Draft

Guard branching plane computation against zero-norm vectors#1
Kalpa08 wants to merge 1 commit intomainfrom
codex/assess-package-stability-and-provide-feedback

Conversation

@Kalpa08
Copy link
Owner

@Kalpa08 Kalpa08 commented Feb 6, 2026

Motivation

  • Prevent silent propagation of NaNs/infs when the gradient-difference or NAC vectors collapse to zero norm during branching-plane computation.
  • Provide a clear, actionable error instead of allowing a division-by-zero to occur deep in the math.
  • Improve robustness of the scientific core so downstream plotting/analysis are not fed invalid data.

Description

  • Add explicit norm checks in get_branching_plane_vectors and raise a ValueError with a helpful message when either g_ab or h_ab has (near) zero norm.
  • Use the computed norms (g_norm and h_norm) when scaling h_ab to g_ab to avoid repeated recomputation and make the intent clearer.
  • Add a regression test test_get_branching_plane_vectors_raises_on_zero_norm_inputs in tests/test_real_data.py to lock the behavior for degenerate inputs.

Testing

  • Running pytest -q in the default environment initially failed during collection with ModuleNotFoundError: No module named 'conezen' (import-path/install ergonomics issue).
  • Attempting python -m pip install -e . failed in this environment due to inability to fetch build dependency setuptools>=61.0 (network/proxy restriction).
  • Running PYTHONPATH=src pytest -q (the project test pattern used in CI) succeeded with 4 passed including the new regression test.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant