-
-
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
Inconsistent return types between scalar and array operations with Bool
arguments (and some other types)
#3274
Comments
I almost think we should get rid of /, ^, div, and mod for Bool. They are pretty silly. |
+1 |
I agree some operations are silly when they just involve Bools, but they're not for a Bool and another type (e.g. |
Cases like |
use Float64 as the default float type for small integers instead of Float32 fixes some of the issues in #3274
I like that |
In fact, I was thinking more about the array case (e.g. you get an array of Bools, or a BitArray, via
That seems reasonable. For |
The methods in |
Sorry, I hadn't realized this was already fixed. Of the original issues, only
|
It seems I was wrong about all other issues being fixed... I wrote a systematic checker and the results (included in the gist) are kind of alarming (not a single function passes all tests, not even unary The code also includes an additional check, to compare scalar
This is actually a different issue (or maybe not an issue at all), but I thought it would fit in the test suite. |
A lot of these have a reason --- for example the result of |
Yes, the size and signedness of rem{T<:Signed}(::Integer, ::T) :: T
rem{T<:Unsigned}(::Unsigned, ::T) :: T The only problematic case is when the first argument is singed and the second argument is unsigned, i.e. |
For example, before this patch: julia> typeof(int32(2) ^ int64(3)) Int32 julia> eltype([int32(2)] .^ [int64(3)]) Int64 # Int32 after this patch julia> typeof(complex(2) ^ complex(3)) Complex{Float64} julia> eltype([complex(2)] .^ [complex(3)]) Complex{Int} # Complex{Float64} after this patch
For example, before this patch: julia> typeof(int32(2) ^ int64(3)) Int32 julia> eltype([int32(2)] .^ [int64(3)]) Int64 # Int32 after this patch julia> typeof(complex(2) ^ complex(3)) Complex{Float64} julia> eltype([complex(2)] .^ [complex(3)]) Complex{Int} # Complex{Float64} after this patch
For example, before this patch: julia> typeof(int32(2) ^ int64(3)) Int32 julia> eltype([int32(2)] .^ [int64(3)]) Int64 # Int32 after this patch julia> typeof(complex(2) ^ complex(3)) Complex{Float64} julia> eltype([complex(2)] .^ [complex(3)]) Complex{Int} # Complex{Float64} after this patch
As of #17623, I'm getting consistent types for boolean scalars and arrays:
|
Closed by #17623. |
are all of these tested now? |
Probably not |
These ones are related to broadcasting:
These are not related to broadcasting:
The text was updated successfully, but these errors were encountered: