Skip to content

Sphere: do not rewrite Sphere[] and Sphere[p]; fill in defaults when drawing - #1995

Open
tombouctou wants to merge 1 commit into
Mathics3:masterfrom
tombouctou:fix-sphere-inert
Open

tombouctou wants to merge 1 commit into
Mathics3:masterfrom
tombouctou:fix-sphere-inert

Conversation

@tombouctou

Copy link
Copy Markdown

In WMA, Sphere is a symbolic graphics primitive that does not evaluate: Sphere[{1, 2, 3}] stays Sphere[{1, 2, 3}], and the default radius 1 (and the default center for Sphere[]) is only used when the sphere is drawn.

Mathics3 rewrote Sphere[p] to Sphere[p, 1] and Sphere[] to Sphere[{0, 0, 0}, 1] with builtin rules that Clear cannot remove. This breaks code that uses Sphere[n] as an inert head, e.g. a package where Sphere[7] stands for the 7-sphere and definitions such as f[Sphere[n_]] := ... must match:

In[1]:= Sphere[7]
Out[1]= Sphere[7, 1]

This PR removes the two rules and lets SphereBox accept 0, 1 or 2 arguments, filling in the defaults itself. The Asymptote output for Graphics3D[Sphere[]] is unchanged (existing doctest and test_plot case).

Tests: new cases in test/builtin/drawing/test_plot.py and a doctest in Sphere.

🤖 Generated with Claude Code

…drawing

In WMA Sphere[c] is an inert symbolic primitive: it stays Sphere[c] and
the default radius 1 is only used when it is rendered. Mathics3 rewrote
Sphere[c] to Sphere[c, 1] (and Sphere[] to Sphere[{0, 0, 0}, 1]) with
rules that cannot be cleared, so packages that use Sphere[n] as an inert
head (e.g. Sphere[7] for S^7) break.

SphereBox now accepts 0, 1 or 2 arguments and fills in the default
center and radius itself.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant