-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This defines `one` as a real (i.e. dimensionless) number `1`.
- Loading branch information
Showing
6 changed files
with
88 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
MathTypes{T,C} = Union{AbstractRGB{T},TransparentRGB{C,T},AbstractGray{T},TransparentGray{C,T}} | ||
|
||
# provided by https://github.com/JuliaLang/julia/pull/35094 | ||
function register_hints() | ||
if isdefined(Base, :Experimental) && isdefined(Base.Experimental, :register_error_hint) | ||
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs | ||
if exc.f in (one,) && argtypes[1] <: Union{Type{<:AbstractRGB}, AbstractRGB} | ||
print(io, "\nYou may need to `using ColorVectorSpace`.") | ||
end | ||
if exc.f in (ones,) && argtypes[1] <: Type{<:AbstractRGB} | ||
print(io, "\nYou may need to `using ColorVectorSpace`.") | ||
end | ||
isdefined(Base, :Experimental) && isdefined(Base.Experimental, :register_error_hint) || return | ||
Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs | ||
# In theory we could list every function supported by ColorVectorSpace. | ||
# This list of functions is far from comprehensive but may be enough to catch many users. | ||
if exc.f in (+, -, *, /) && any(T->T<:MathTypes || T<:Type{<:MathTypes}, argtypes) | ||
print(io, "\nMath on colors is deliberately undefined in ColorTypes, but see the ColorVectorSpace package.") | ||
end | ||
if (exc.f === *) && any(T->T<:MathTypes || T<:Type{<:MathTypes}, argtypes) | ||
print(io, "\nYou may also need `⋅`, `⊙`, or `⊗`.") | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
This file contains 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
This file contains 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