-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Limit broadcast mechanism over Nullables #19787
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e0f1cb1
Limit broadcast mechanism over Nullables
pabloferz e5c270a
Test that broadcast doesn't propagate too much
pabloferz f3aec3b
[ci skip] Update manual section on Nullables
pabloferz dcba165
Address @TotalVerb comments
pabloferz afdd247
Address @Sacha0 comments
pabloferz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Address @TotalVerb comments
- Loading branch information
commit dcba165869f6de3db4448a8778c567bb9c997d10
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ module Broadcast | |
using Base.Cartesian | ||
using Base: promote_eltype_op, linearindices, tail, OneTo, to_shape, | ||
_msk_end, unsafe_bitgetindex, bitcache_chunks, bitcache_size, dumpbitcache, | ||
nullable_returntype, null_safe_eltype_op, hasvalue, is_nullable_array | ||
nullable_returntype, null_safe_eltype_op, hasvalue | ||
import Base: broadcast, broadcast! | ||
export broadcast_getindex, broadcast_setindex!, dotview | ||
|
||
|
@@ -276,17 +276,10 @@ ftype(f, A) = typeof(f) | |
ftype(f, A...) = typeof(a -> f(a...)) | ||
ftype(T::Type, A...) = Type{T} | ||
|
||
# nullables need to be treated like scalars sometimes and like containers | ||
# other times, so there are two variants of typestuple. | ||
|
||
# if the first argument is Any, then Nullable should be treated like a | ||
# scalar; if the first argument is Array, then Nullable should be treated | ||
# like a container. | ||
typestuple(a) = (Base.@_pure_meta; Tuple{eltype(a)}) | ||
typestuple(T::Type) = (Base.@_pure_meta; Tuple{Type{T}}) | ||
typestuple(a, b...) = (Base.@_pure_meta; Tuple{typestuple(a).types..., typestuple(b...).types...}) | ||
|
||
# these functions take the variant of typestuple to be used as first argument | ||
ziptype(A) = typestuple(A) | ||
ziptype(A, B) = (Base.@_pure_meta; Iterators.Zip2{typestuple(A), typestuple(B)}) | ||
@inline ziptype(A, B, C, D...) = Iterators.Zip{typestuple(A), ziptype(B, C, D...)} | ||
|
@@ -332,8 +325,8 @@ end | |
|
||
Broadcasts the arrays, tuples, `Ref`, nullables, and/or scalars `As` to a | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not from this pull request, but should |
||
container of the appropriate type and dimensions. In this context, anything | ||
that is not a subtype of `AbstractArray`, `Ref` (except for `Ptr`s) or `Tuple` | ||
is considered a scalar. The resulting container is established by | ||
that is not a subtype of `AbstractArray`, `Ref` (except for `Ptr`s), `Tuple` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Serial/Oxford) comma after |
||
or `Nullable` is considered a scalar. The resulting container is established by | ||
the following rules: | ||
|
||
- If all the arguments are scalars, it returns a scalar. | ||
|
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the
is_nullable_array
import can be removed, and probably the function itself too (inbase/nullable.jl
).