Skip to content

feat: spell the wedge product ^, as Python does - #22

Merged
wardjm merged 1 commit into
mainfrom
wedge-caret-sugar
Jul 11, 2026
Merged

wardjm merged 1 commit into
mainfrom
wedge-caret-sugar

Conversation

@wardjm

@wardjm wardjm commented Jul 11, 2026 •

Copy link
Copy Markdown
Owner

Closes #14.

wedge(α, β) was the only spelling of the wedge, while * on two Forms is the
tensor product — so Python code ported by eye silently produced a Tensor02
instead of a Form, with no MethodError to catch it.

  • Base.:^(a::Form, b::Form) = wedge(a, b), so Python's α ^ β transfers directly.
  • wedge (and ^) now accept a ScalarFunction on either side, where the degree-0
    form makes the wedge degenerate to the pointwise product, as in Python.
  • README documents the * divergence in the field-types snippet and in Conventions.

Two deliberate non-choices, both surfaced by /code-review:

  • No ^ on two ScalarFunctions. Python falls back to multiplication there, but
    f^2 already means the pointwise power (Base.:^(::ScalarFunction, ::Number)),
    so f^h meaning the product would make one operator mean two unrelated things on
    one type — a silent trap of the same species this issue exists to kill. f * g is
    the spelling for that product; a test pins wedge(f, h) as a MethodError.
  • The precedence note is about +, not *. Python's ^ binds looser than
    addition, Julia's binds tighter: α ^ β + γ is α ∧ (β + γ) in Python but
    (α ∧ β) + γ here. Both are valid forms of the same degree, so it is a silent
    wrong answer — the README says so and says to parenthesise when porting.

Full suite green (2396 tests).

`wedge(α, β)` was the only spelling, while `*` on two Forms is the tensor
product — so Python code ported by eye silently produced a Tensor02 instead
of a Form. Add `^` as the wedge (and accept a ScalarFunction on either side,
where it degenerates to the pointwise product), and document the `*`
divergence plus the `^` precedence flip in the README.

`^` on two ScalarFunctions is deliberately left undefined: it would collide
in meaning with the pointwise power `f^2`.

Closes #14
@wardjm
wardjm merged commit 463c3f1 into main Jul 11, 2026
2 checks passed
@wardjm
wardjm deleted the wedge-caret-sugar branch July 15, 2026 16:52
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.

No wedge operator sugar on Forms — and * on two Forms silently means tensor product

1 participant