Skip to content
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

Remove &x convention in ccall in mpfr #23288

Merged
merged 5 commits into from
Aug 26, 2017
Merged

Conversation

musm
Copy link
Contributor

@musm musm commented Aug 17, 2017

No description provided.

@tkelman
Copy link
Contributor

tkelman commented Aug 17, 2017

@nanosoldier runbenchmarks(ALL,vs=":master")

@nanosoldier
Copy link
Collaborator

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

base/mpfr.jl Outdated
if x < 0
throw(DomainError(x, string($f, " will only return a complex result if called ",
"with a complex argument. Try ", $f, "(complex(x)).")))
if x < 0 && throw(DomainError(x, string($f, " will only return a complex result if called ",
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems worse than before. What prompted this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change the other one then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand, the one linked uses if x < -1, i.e. a normal if block? Also did you mean to remove the if here? otherwise this form if cond && throw(...) end is very strange.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was a typo

@musm
Copy link
Contributor Author

musm commented Aug 21, 2017

part of #6080 (ref)

base/mpfr.jl Outdated
throw(InexactError(:convert, Bool, x))
function convert(::Type{Bool}, x::BigFloat)
x == 0 ? false : x == 1 ? true : throw(InexactError(:convert, Bool, x))
end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this preferred (more readable) over the short form previously?

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x == 0 && return false
x == 1 && return true
throw(InexactError(:convert, Bool, x))

is more clear to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's much better

@musm
Copy link
Contributor Author

musm commented Aug 24, 2017

merge?

base/mpfr.jl Outdated
if x == 0; return zero(BigInt) // one(BigInt); end
isnan(x) && return zero(BigInt) // zero(BigInt)
isinf(x) && return copysign(one(BigInt),x) // zero(BigInt)
x == 0 && return zero(BigInt) // one(BigInt)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you already changed such a test to iszero earlier, and you are touching this function, you might as well use iszero here too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me change that back, I have another PR to make iszero isone uniform in the file.

return (s, c)
end
sincos(v::BigFloat) = sincos_fast(v)

# return log(2)
function big_ln2()
c = BigFloat()
ccall((:mpfr_const_log2, :libmpfr), Cint, (Ptr{BigFloat}, Int32),
&c, MPFR.ROUNDING_MODE[])
ccall((:mpfr_const_log2, :libmpfr), Cint, (Ref{BigFloat}, Int32), c, MPFR.ROUNDING_MODE[])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this one was split on 2 lines to respect the 92 char limit? but anyway, your change is consistent with the rest of the file...

return z
end
end

function log1p(x::BigFloat)
if x < -1
throw(DomainError(x, string("log1p will only return a complex result if called ",
"with a complex argument. Try log1p(complex(x)).")))
"with a complex argument. Try log1p(complex(x)).")))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the previous version is better here, as the last line is an argument to string, not to DomainError.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you comment on this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had it before as you suggested, but @KristofferC said it looked strange so I changed it. I personally don't care either way and don't think it's a big deal, but will change according to a consensus..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see his comment, but it's unrelated to ccall... it doesn't appear to be a common indentation style, so I would keep it as it was.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #23288 (comment)
in the file there are 2 different conventions on how this is broken up. I chose one of the two to make it consistent.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see; but you had a typo there, maybe he was reacting to it, rather than the alignment?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KristofferC can you confirm that you support this modification of indentation? I cannot see enough lines of context in your older comment on an outdated diff to be sure.

@rfourquet
Copy link
Member

I didn't follow the Ref vs & progress, but superficially looks good to me modulo my one comment about alignment in a DomainError.

@mbauman mbauman added the kind:deprecation This change introduces or involves a deprecation label Aug 24, 2017
@musm
Copy link
Contributor Author

musm commented Aug 24, 2017

This should now be ready to merge

@musm
Copy link
Contributor Author

musm commented Aug 26, 2017

Merge?

@StefanKarpinski StefanKarpinski merged commit fc6b0ef into JuliaLang:master Aug 26, 2017
@musm musm deleted the ref branch August 26, 2017 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:deprecation This change introduces or involves a deprecation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants