-
Notifications
You must be signed in to change notification settings - Fork 33
Compact systematic display of values #51
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
123f990
Compact systematic display of values
timholy f226e62
Deprecate UFixed8 and friends in favor of N0f8 and friends
timholy 65689dd
Deprecate n*uf8 in favor of reinterpret(N0f8, n)
timholy fdf5506
Add a shell script to aid in fixing deprecations
timholy 9da3c8b
Rename UFixed to Normed
vchuravy af0d7a2
Merge pull request #63 from JuliaMath/vc/rename
timholy af2a5c7
Remove duplicate reinterpret definition
timholy 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
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
sed -i "s/UFixed8/N0f8/g" $* | ||
sed -i "s/UFixed10/N6f10/g" $* | ||
sed -i "s/UFixed12/N4f12/g" $* | ||
sed -i "s/UFixed14/N2f14/g" $* | ||
sed -i "s/UFixed16/N0f16/g" $* | ||
# For types from ColorTypes | ||
sed -i "s/U8/N0f8/g" $* | ||
sed -i "s/U16/N0f16/g" $* |
This file contains hidden or 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
This file contains hidden or 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 |
---|---|---|
@@ -1,25 +1,57 @@ | ||
import Base.@deprecate_binding | ||
|
||
@deprecate_binding UfixedBase UFixed | ||
@deprecate_binding UfixedConstructor UFixedConstructor | ||
@deprecate_binding Ufixed UFixed | ||
@deprecate_binding Ufixed8 UFixed8 | ||
@deprecate_binding Ufixed10 UFixed10 | ||
@deprecate_binding Ufixed12 UFixed12 | ||
@deprecate_binding Ufixed14 UFixed14 | ||
@deprecate_binding Ufixed16 UFixed16 | ||
|
||
@deprecate_binding Fixed32 Fixed16 | ||
@deprecate_binding Fixed16 Q15f16 | ||
@deprecate_binding UFixed8 N0f8 | ||
@deprecate_binding UFixed10 N6f10 | ||
@deprecate_binding UFixed12 N4f12 | ||
@deprecate_binding UFixed14 N2f14 | ||
@deprecate_binding UFixed16 N0f16 | ||
|
||
@deprecate_binding UfixedBase Normed | ||
@deprecate_binding Ufixed Normed | ||
@deprecate_binding UFixed Normed | ||
@deprecate_binding Ufixed8 N0f8 | ||
@deprecate_binding Ufixed10 N6f10 | ||
@deprecate_binding Ufixed12 N4f12 | ||
@deprecate_binding Ufixed14 N2f14 | ||
@deprecate_binding Ufixed16 N0f16 | ||
|
||
@deprecate_binding Fixed32 Q15f16 | ||
|
||
const UF = (N0f8, N6f10, N4f12, N2f14, N0f16) | ||
|
||
@deprecate Fixed(x::Real) convert(Fixed{Int32, 16}, x) | ||
|
||
@deprecate ufixed8(x) UFixed8(x) | ||
@deprecate ufixed10(x) UFixed10(x) | ||
@deprecate ufixed12(x) UFixed12(x) | ||
@deprecate ufixed14(x) UFixed14(x) | ||
@deprecate ufixed16(x) UFixed16(x) | ||
@deprecate ufixed8(x) N0f8(x) | ||
@deprecate ufixed10(x) N6f10(x) | ||
@deprecate ufixed12(x) N4f12(x) | ||
@deprecate ufixed14(x) N2f14(x) | ||
@deprecate ufixed16(x) N0f16(x) | ||
|
||
Compat.@dep_vectorize_1arg Real ufixed8 | ||
Compat.@dep_vectorize_1arg Real ufixed10 | ||
Compat.@dep_vectorize_1arg Real ufixed12 | ||
Compat.@dep_vectorize_1arg Real ufixed14 | ||
Compat.@dep_vectorize_1arg Real ufixed16 | ||
|
||
## The next lines mimic the floating-point literal syntax "3.2f0" | ||
# construction using a UInt, i.e., 0xccuf8 | ||
immutable NormedConstructor{T,f} end | ||
function *{T,f}(n::Integer, ::NormedConstructor{T,f}) | ||
i = 8*sizeof(T)-f | ||
io = IOBuffer() | ||
show(io, n) | ||
nstr = takebuf_string(io) | ||
cstr = typeof(n) == T ? nstr : "convert($T, $nstr)" | ||
Base.depwarn("$(nstr)uf$f is deprecated, please use reinterpret(N$(i)f$f, $cstr) instead", :*) | ||
reinterpret(Normed{T,f}, convert(T, n)) | ||
end | ||
const uf8 = NormedConstructor{UInt8,8}() | ||
const uf10 = NormedConstructor{UInt16,10}() | ||
const uf12 = NormedConstructor{UInt16,12}() | ||
const uf14 = NormedConstructor{UInt16,14}() | ||
const uf16 = NormedConstructor{UInt16,16}() | ||
|
||
@deprecate_binding UfixedConstructor NormedConstructor | ||
@deprecate_binding UFixedConstructor NormedConstructor | ||
|
This file contains hidden or 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
Oops, something went wrong.
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.
deprecate
uf16
and friends too?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.
We could, but those exist for a different reason---they are "
repr
constructors"---that's not covered by anything else:Uh oh!
There was an error while loading. Please reload this page.
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 don't think the casual user of julia would find this intuitive. is there nothing to be done that would make that work?
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.
If we really don't like these, perhaps we should get rid of them.
But
0xc2N0f8
orN0f8(0xc2)
can never work as I think you're intending without causing absolute chaos. See JuliaGraphics/ColorTypes.jl#49 (comment). We need to firmly keep in mind the distinction between value and representation of that value, and generally one should just ignore the representation and think about the number in terms of its value.0xc2 = 194
is far beyond the reach of a number representable with anN0f8
, so if the constructor doesn't throw an error you've got a big problem.I think the key is to (1) reliably throw errors when the user tries something that's not allowed (we didn't do that before #48 because of arithmetic overflow), and (2) provide better error messages that actually coach users through how to think about this/fix problems, along the lines of #49 (comment).
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.
OK, maybe I'll deprecate
0xc2uf8
in favor ofreinterpret(N0f8, 0xc2)
. Reasonable? Forcing people to usereinterpret
explicitly might help clarify everyone's thinking.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.
doh! i was getting confused between value and representation just as you describe.
deprecating
uf8
in favor ofreinterpret
sounds great.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've confused myself so many times I've lost track. But I think we're moving towards a solution that will be easier to keep straight!