Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass more array information #46

Open
johnnychen94 opened this issue Apr 14, 2021 · 1 comment
Open

Pass more array information #46

johnnychen94 opened this issue Apr 14, 2021 · 1 comment

Comments

@johnnychen94
Copy link
Member

johnnychen94 commented Apr 14, 2021

Some trivial information queries become time-consuming because currently there's no way to pass this extra information. And it just falls back to apply the function again and again and again and becomes very inefficient.

using TestImages, ImageTransformations
img = testimage("cameraman")

As = mappedarray->imrotate(img, θ, axes(img)), -π/4:π/16:π/4);

@btime size.($As);  # 22.033 ms (136 allocations: 2.26 MiB)
@btime collect($As); # 22.880 ms (127 allocations: 2.26 MiB)

For this very specific case, axes can be known prior.

@goretkin
Copy link

I am not sure what there is to do here.

julia> f = θ->imrotate(img, θ, axes(img))
#11 (generic function with 1 method)

julia> typeof(f/4))
Matrix{ColorTypes.Gray{FixedPointNumbers.N0f8}} (alias for Array{ColorTypes.Gray{FixedPointNumbers.Normed{UInt8, 8}}, 2})

julia> Base.return_types(f, (typeof/4),))
1-element Vector{Any}:
 Any

Even if imrotate was written such that the type was inferred correctly, the type itself does not contain information about axes (unlike e.g. StaticArrays.StaticArray, or Tuple.).

Said differently, it does not seem like a MappedArrays.jl issue. I don't know how to get the following answer without evaluating f:

julia> axes(f/4))
(Base.OneTo(512), Base.OneTo(512))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants