Closed asinghvi17 closed 4 months ago
Why InverseFunctions instead of Base.inv?
InverseFunctions appears to be the way to invert supported functions and to define new inverses. It's quite common in the Julia ecosystem.
In particular, here we don't just define new inverse
methods, but reuse existing ones as well:
julia> using Accessors, InverseFunctions
julia> f = @o 10 * (5 + log(2, _ / 10))
Base.Fix1{typeof(*), Int64}(*, 10) ∘ Base.Fix1{typeof(+), Int64}(+, 5) ∘ Base.Fix1{typeof(log), Int64}(log, 2) ∘ Base.Fix2{typeof(/), Int64}(/, 10)
julia> inverse(f)
Base.Fix2{typeof(*), Int64}(*, 10) ∘ (Base.Fix1{typeof(InverseFunctions.invlog1), Int64}(InverseFunctions.invlog1, 2) ∘ (Base.Fix2{typeof(-), Int64}(-, 5) ∘ Base.Fix1{typeof(\), Int64}(\, 10)))
Everything fully automatic, with no potential for typos :)
I think in the future Makie should just use/define InverseFunction.inverse
instead of its own inverse_transform
function.
all of these should be Float64
Oh, thanks, I kinda thought Makie is "Float32 all the way".
maybe consider Makie.Format instead ;)
I just like how nice the Python string formatting syntax is (PyFormattedStrings
copies the syntax directly), see
https://github.com/JuliaAPlavin/MakieExtra.jl/blob/000000006d421b318d28db435c70c78ce96659d9/src/ticks.jl#L66
How that would look with Makie.Format
?
Of course it's not crucial for such a small one-time use, just what different people are used to in terms of syntax.
I think Format
has FormatExpr
which obeys the same spec as Python.
I just saw this on the new packages feed - this looks pretty cool to me!
A couple of questions:
https://github.com/JuliaAPlavin/MakieExtra.jl/blob/000000006d421b318d28db435c70c78ce96659d9/src/scales.jl#L24 Why
InverseFunctions
instead ofBase.inv
?https://github.com/JuliaAPlavin/MakieExtra.jl/blob/000000006d421b318d28db435c70c78ce96659d9/src/scales.jl#L2-L6 all of these should be Float64
https://github.com/JuliaAPlavin/MakieExtra.jl/blob/000000006d421b318d28db435c70c78ce96659d9/src/MakieExtra.jl#L6 maybe consider
Makie.Format
instead ;)