-
Notifications
You must be signed in to change notification settings - Fork 17
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
Refactor @round
to transform a+b
to +(a, b, RoundDown)
#188
Conversation
@round
to transform a+b
to +(a, b, RoundDown)
Tests are not passing... |
Yes, unfortunately that will require quite a lot of work. But I think this is a good direction to go in. |
Current coverage is 90.70% (diff: 85.90%)@@ master #188 diff @@
==========================================
Files 21 23 +2
Lines 988 990 +2
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
- Hits 914 898 -16
- Misses 74 92 +18
Partials 0 0
|
2 similar comments
Tests are passing on 0.4 and 0.5, and almost on 0.6 with known issues (one in FixedSizeArrays.jl, and the other in Base). cc @lbenet |
I split out the rounding macros into a new file, |
I should say that part of the motivation for this whole change, which was in my head but not necessarily mentioned anywhere, was that this will make it much easier to experiment with different types of rounding: the only place that needs to be changed are now the definitions in EDIT: See the rounding_modes branch for an example. The ROUNDING variable can be taken e.g. from an environment variable. In Julia 0.6 it will be possible to change this interactively by just redefining all these functions! |
1 similar comment
Tests are passing on 0.4 and 0.5. I think this is ready to merge! |
1 similar comment
1 similar 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.
Have you included the documentation for the macros? I think it would be useful in this PR.
I must admit that I feel unconfortable with the current implementation: For x = @biginterval(27)
, x^(1/3)
does not include the true answer! Simply, try it with displaymode(format=:full)
.
In any case, this is almost ready!
end | ||
|
||
^(a::Interval{BigFloat}, x::AbstractFloat) = a^big(x) |
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.
What about setting it back as it was before?
The macro documentation is in Is that what you were looking for? Since I see this as analogous to the fact that you can do Similarly you can do |
I think we should merge this and can come back and change things later if necessary. |
Ok. I'm merging. |
Thanks! |
@@ -155,6 +155,25 @@ end | |||
|
|||
//(a::Interval, b::Interval) = a / b # to deal with rationals | |||
|
|||
if VERSION >= v"0.6.0-dev" |
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.
this won't work for all 0.6-dev versions, should be more specific about version-depedent cutoffs or use isdefined
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.
You mean isdefined(:Iterators)
? I don't know how to find the exact cutoff where this change was made. In any case, if it's a dev version isn't the expectation that people will keep updating it to the latest version?
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.
There should be a PR linked to in NEWS or otherwise not too hard to find, and there's the contrib/commit-name.sh
script you can use
|
||
if VERSION < v"0.5" | ||
min(x) = x | ||
max(x) = x |
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.
since you've imported these, this is type piracy and could change the behavior of other unrelated code
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.
These are just not defined on 0.4. Do you mean that I should change this to VERSION <= v"0.4"
?
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.
No, I mean do you need to be extending a base method on base types? If these are backporting something that worked in later versions of Julia, is it available in Compat?
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.
These are indeed backporting something that is in 0.5 onwards. It is not available in Compat, but probably should be. JuliaLang/Compat.jl#313
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.
Updated in master to use the correct precise versions, thanks.
@@ -0,0 +1,75 @@ | |||
# Define rounded versions of elementary functions |
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.
didn't you have PR's to add these to base?
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.
No, just for BigFloat
constructors.
Transforms e.g.
to