Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Rewrite broadcast() and map() based on lift() #166

Merged
merged 19 commits into from
Jan 23, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix computing eltype
  • Loading branch information
nalimilan committed Jan 19, 2017
commit 5a88dabb5186a87ca0d16257264ebfec04724b67
2 changes: 1 addition & 1 deletion src/broadcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if VERSION < v"0.6.0-dev" # Old approach needed for inference to work
@inline ziptype(A, B, C, D...) = Zip{Tuple{eltype(A)}, ziptype(B, C, D...)}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise here, the changes in JuliaLang/julia#19421 might be relevant. Best!


nullable_broadcast_eltype(f, As...) =
_default_eltype(Base.Generator{ziptype(As...), ftype(f, As...)})
eltype(_default_eltype(Base.Generator{ziptype(As...), ftype(f, As...)}))
Copy link

@pabloferz pabloferz Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious why is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is "this"?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the eltype you last added.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's useful because NullableArray{T} is parameterized on the eltype of Nullable rather than on the Nullable{T} itself.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, wouldn't that warrants that you don't get a Nullable{T} here?

Given that eltype(NullableArray([1], [true])) == Int, that implies _default_eltype(+, NullableArray([1], [true]), NullableArray([1], [true])) == Int, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, eltype(NullableArray([1], [true])) == Nullable{Int}.

I don't want T = Nullable{Int} here since it's used to build a new array via NullableArray{T}(...). NullableArray{Nullable{Int}} would have a Nullable{Nullable{Int}} eltype.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this is that eltype(_default_eltype(*, ["a"], ["b"]) will give Char, so I guess you'd need a custom eltype here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that method is only called on NullableArrays, so we're certain the element types are Nullable (in your case, Nullable{String}).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, now I see, this is nullable_broadcast_eltype as opposed to broadcast_eltype. Sorry for the noise then.

else
Base.@pure nullable_eltypestuple(a) = Tuple{eltype(eltype(a))}
Base.@pure nullable_eltypestuple(T::Type) = Tuple{Type{eltype(T)}}
Expand Down