feat: spell the wedge product ^, as Python does - #22
Merged
Merged
Conversation
`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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14.
wedge(α, β)was the only spelling of the wedge, while*on twoForms is thetensor product — so Python code ported by eye silently produced a
Tensor02instead of a
Form, with noMethodErrorto catch it.Base.:^(a::Form, b::Form) = wedge(a, b), so Python'sα ^ βtransfers directly.wedge(and^) now accept aScalarFunctionon either side, where the degree-0form makes the wedge degenerate to the pointwise product, as in Python.
*divergence in the field-types snippet and in Conventions.Two deliberate non-choices, both surfaced by
/code-review:^on twoScalarFunctions. Python falls back to multiplication there, butf^2already means the pointwise power (Base.:^(::ScalarFunction, ::Number)),so
f^hmeaning the product would make one operator mean two unrelated things onone type — a silent trap of the same species this issue exists to kill.
f * gisthe spelling for that product; a test pins
wedge(f, h)as aMethodError.+, not*. Python's^binds looser thanaddition, Julia's binds tighter:
α ^ β + γisα ∧ (β + γ)in Python but(α ∧ β) + γhere. Both are valid forms of the same degree, so it is a silentwrong answer — the README says so and says to parenthesise when porting.
Full suite green (2396 tests).