Skip to content

fix(lt): reject zero-vector output in Lt callable constructor#579

Closed
utiberious wants to merge 1 commit intopygae:masterfrom
utiberious:fix/lt-is-vector-reject-zero
Closed

fix(lt): reject zero-vector output in Lt callable constructor#579
utiberious wants to merge 1 commit intopygae:masterfrom
utiberious:fix/lt-is-vector-reject-zero

Conversation

@utiberious
Copy link
Copy Markdown
Contributor

Discovered during code audit in #575.

Change

Removes the and not out.is_zero() exemption added in #510, restoring the upstream Macdonald behavior where F(basis_vector) must return a proper vector.

Before (galgebra):

if not out.is_vector() and not out.is_zero():
    raise ValueError('{} must return vectors'.format(F))

After (matches upstream zip):

if not out.is_vector():
    raise ValueError('{} must return vectors'.format(F))

Rationale

A linear transform that maps any basis vector to zero is singular. Accepting it silently allows constructing an Lt that will produce incorrect results (e.g. wrong determinant, inverse undefined). Making the error explicit at construction time is safer.

Upstream Macdonald code requires F(basis) to return a non-zero vector.
The is_zero() exemption added in pygae#510 allows degenerate/singular maps
through silently; restoring the stricter check makes the error explicit.
Copy link
Copy Markdown
Member

@utensil utensil left a comment

Choose a reason for hiding this comment

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

The is_zero() exemption wasn't from #510 — it was added in #560 to fix #540. Projection maps like lambda x: (x | e1) * e1 legitimately return zero for perpendicular basis vectors, and the zero map is a valid linear map too. The existing test_lt_callable_zero regression test covers exactly this.

This change would revert a deliberate fix.

@utiberious
Copy link
Copy Markdown
Contributor Author

Closing — the change is incorrect. The and not out.is_zero() exemption was added in #560 to fix #540: projection maps like lambda x: (x | e1) * e1 legitimately return zero for perpendicular basis vectors, and the regression test test_lt_callable_zero covers this. The upstream zip predates that fix. No change needed.

@utiberious utiberious closed this Apr 2, 2026
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