-
Notifications
You must be signed in to change notification settings - Fork 143
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
Weird behavior with fixed point colorant, floating point colorant, and ifelse #814
Comments
It's weird to me as well. As a supplement, if you use the Debugger to trace the result, it works normally inside of 1|debug> n
In transfermask(input, useother, othervalue) at REPL[5]:2
6 RGB{Float64}(othervalue),
7 input[idx]
8 )
9 end
>10 return combined
11 end
About to run: return RGB{Normed{UInt8,8}}[RGB{N0f8}(1.0,1.0,1.0) RGB{N0f8}(1.0,1.0,1.0); RGB{N0f8}(1.0,1.0,1.0) RGB{N0f8}(1.0,1.0,1.0)]
1|julia> combined
2×2 Array{RGB{N0f8},2} with eltype RGB{Normed{UInt8,8}}:
RGB{N0f8}(1.0,1.0,1.0) RGB{N0f8}(1.0,1.0,1.0)
RGB{N0f8}(1.0,1.0,1.0) RGB{N0f8}(1.0,1.0,1.0) |
Weird Julia bug. Works incorrectly on 1.0 and 1.2, but correctly on 1.3 and 1.4/nightly. I'll file a Julia issue and see if anyone knows which commit(s) fixed this and whether it's backportable. |
BTW, given the purpose of |
I don't understand how this is bad manners? The reason for using Basically, it eliminates a branch in the code. My hope was to make the compiler vectorize the inner loop, which it wouldn't do if I used |
Unrelated, but @timholy congrats on the beautiful paper in Science! I'm reading it right now. |
The reason is exactly what you wrote. |
A bug is a bug is a bug. You're right that this particular example is a strange use of What actually happened is that I wrote some quick code without sufficient type bounds, and after using it for a while gave it an argument that resulted in the |
Let me add only one point. If you think I pointed only to the type instability, it is a misunderstanding. Even if it is type stable, we should not use implicit (unexpected) conversions within Edit: |
No offense, we could leave this issue as the tracker of this bug, and open a new issue for "best practice in FixedNumbers and documentation" if there's a need. :D Edit: |
@johnnychen94 sorry to add more noise, but I actually don't understand the point that kimikage is trying to make. @kimikage I don't understand your distinction between type instability and implicit type conversion within If you mean the second, then it seems like type conversion is not necessary to trigger what's probably the same bug in Julia 1.2 (inspired from your post in JuliaLang/julia#34231): julia> for i = 1:2 # julia1.2
display(ifelse(i > 1, 1//3, -1.0))
end
-1.0
1//140412727051408
|
What I wanted to say in #814 (comment) is that "my manners" should not be confused with the cause of this bug. My manners are something like "Type names should start with a capital letter."
If "your point" means "my manner", the answer is "Yes". If it means the point of "Let me add only one point", the answer is clearly "No". Since
I don't know how to display numbers without conversion. Anyway, I don't fully understand the cause of the bug. (I'm not really interested in it now, because I confirmed that my modified code is not the cause.) Perhaps the conversions themselves are done correctly. Storing the intermediate variables (i.e. a part of the Φ function) seems to be failed. |
This works as expected in Julia 1.9. |
I'm running into some weird behavior that I'm at a loss to explain.
I want to change the color of some pixels in an image, and discovered some very strange corner cases when assigning type unstable values to an array of colorants.
I would expect the following to produce an array filled with
RGB{N0f8}(1.0, 1.0, 1.0)
, but instead it producesRGB{N0f8}(1.0, 0.0, 0.0)
:However, the following both work, even though they seem functionally identical to me:
These results don't make any sense to me.
The text was updated successfully, but these errors were encountered: