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

How to materialize LazyArray #59

Open
tkf opened this issue Sep 17, 2019 · 5 comments
Open

How to materialize LazyArray #59

tkf opened this issue Sep 17, 2019 · 5 comments

Comments

@tkf
Copy link
Member

tkf commented Sep 17, 2019

Currently there materialize(LazyArray(lazy::Union{Applied, Broadcasted})) seems to just pass-through a LazyArray. This is why some tests here do not work:

@testset "materialize(LazyArray(@~ $label))" begin
@test_skip materialize(LazyArray(lazy)) == desired # should work
@test materialize(LazyArray(lazy)) desired
end

What is the canonical way to materialize a LazyArray? That is to say, what is the function f such that f(LazyArray(lazy)) == materialize(lazy)? Should it be materialize? collect? copy? something else?

@dlfivefifty
Copy link
Member

Is there a reason you can’t just call Array?

@tkf
Copy link
Member Author

tkf commented Sep 18, 2019

Output array can be sparse or structured. (So I guess collect is out, actually.)

@dlfivefifty
Copy link
Member

We could add

materialize(A::ApplyArray) = materialize(Applied(A))
materialize(A::BroadcastArray) = materialize(Broadcasted(A))
copy(A::ApplyArray) = copy(Applied(A))
copy(A::BroadcastArray) = copy(Broadcasted(A))

(I'll have to double check it doesn't break my fullmaterialize routine needed in ContinuumArrays.jl)

@tkf
Copy link
Member Author

tkf commented Sep 18, 2019

This is just something that I notice while writing the test. If it can break your code, let's set the priority very low.

@dlfivefifty
Copy link
Member

QuasiArrays.jl has the function croncetize(_) which we can move up here, to force a lazy array to be materialized.

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

No branches or pull requests

2 participants