[RFC/WIP] Homogenise design#27
[RFC/WIP] Homogenise design#27timholy merged 3 commits intoJuliaMath:masterfrom vchuravy:vc/design_rework
Conversation
|
👍 But, do you need the |
|
I think it is a good thing to use those extra bits for computation, but if I ask a Ufixed for its value there should be a guarantee that it doesn't exceed it type max.
@timholy I changed the multiplication for UFixed{T,B,f}((Base.widemul(x.i,y.i) + (convert(widen(T), 1) << (f-1) ))>>f,0)Along the lines of how Fixed works. That also guarantees that arithmetic operations always return UFixed types, but the error bounds in the test are then no longer accurate. |
Currently the design is to say that those extra bits are perfectly acceptable, and that they are part of its immutable BoundedNumber{T,MinVal,MaxVal} <: Number
value::T
endand then any numeric type can become a |
|
👍 on the multiplication change. |
|
Hm I see. So in the original design I think we could get away with that. That is effectively how this PR is implementing it right now. I see where my miss understanding comes from. I always took Coming back to my motivating case. Currently I could just drop the |
|
That would be fine. |
|
Ok done. Any ideas how to handle the tests? |
|
As in, the failing tests? How about wrapping the |
|
@timholy adding the deprecations makes ColorTypes pass locally. The only question is how to do that on julia versions before v0.4-rc2 |
|
Probably easiest is to skip the deprecation and just define |
|
Not sure whether you're ready to merge yet (title might need updating?), but this looks really good to me. Thanks for tackling a much-needed cleanup. On at least one point I owe you an apology: perhaps could we do a version check One further thought: on 0.3, Just ping again when you're ready to merge. |
|
I think bumping the minimum required version is a good idea. I am currently rewriting the readme and want to add more tests to this. An alternative idea I just had is that the implementation of We could have one |
|
Sounds good. I too noticed that the distinction seemed likely to be irrelevant, but I agree that can happen as a second stage. I'm going to go ahead and merge #30, as another PR is waiting on it. Hope it doesn't cause you any rebasing headaches. |
|
@timholy I squashed and rebased everything. The test suite got a bit bigger ;) edit: Failure on Nightly is |
README.md
Outdated
|
Looks great! The biggest problem is that the tests are timing out on every platform. I think we're going to have to add a section that's something like this (warning: untested) to script:
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
- julia -e 'Pkg.clone(pwd()); Pkg.build("FixedPointNumbers")'
- julia -e 'cd(Pkg.dir("FixedPointNumbers", "test")); include("runtests.jl")'so the tests run with inlining on. |
- New type hierarchy
- FixedPoint{T, f} <: Real
- Fixed <: FixedPoint
- UFixed <: FixedPoint
Each FixedPoint number consists of an underlying type `T`
and a `f` bits reserved for the fractional part.
- Only supports Julia `v0.4` from now on.
|
Let's see if that helps to speed up the travis run, otherwise we will have to reduce the number of tests for |
|
Doesn't seem to be working. I don't understand why---the old tests ran much faster on my machine. Or is this a consequence of the new tests? If on your own machine the tests are >10 minutes, that seems a little long. If it should be better than this, maybe debug with changing that last line of the This will cause it to dump the current options in a nicely-readable way. ( |
|
The test take about 30min to run on my machine INFO: FixedPointNumbers tests passed
1551.492159 seconds (447 allocations: 24.578 KB)I will remove a few of the Fixed tests. |
|
That seems to have worked. There are still more test cases then there used to be so merge whenever you are ready. |
|
Awesome, thanks for your efforts here! |
|
Thanks for guiding me along :) Next step when I find sometime is to unify the code altogether. |
So I am currently working on reworking the design of FixedPointNumbers so the
UFixedandFixedwork the same way. Currently this conversion is not yet fully done and I would like some early feedback on the idea. (The overall goal is to make #25 possible)Type Hierarchy
abstract FixedPoint{T <: Integer, B, f} <: Real immutable UFixed{T<:Unsigned, B, f} <: FixedPoint{T, B, f} i :: T end immutable Fixed{T <: Signed,B,f} <: FixedPoint{T, B, f} i :: T endThis leads to the fact that the types
Colorsis using are now defined as ``typealias UFixed8 UFixed{UInt8,8,8}since they are expected to be normalised. That is the place where currentlyUFixed` and `Fixed32` feel the most disjoint and it may warrant the introduction of a normalised `FixedPoint` type.Rename
In #16 it was proposed to change
UfixedtoUFixedfollowing the changes of Base.Fallout
The heaviest user of
FixedPointNumbersas far as I am aware of is theColorsecosystem. I am willing to help resolve any issue that might come up. Also I don't know how one would deprecate the functionality nicely and it might be easier to create this first in a new package.Todo
The current set of changes is incomplete, since I would rather have feedback before I spend to much time on this.
@timholy @JeffBezanson