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

Minor cleanups, style tweaks #20031

Merged
merged 20 commits into from
Jan 18, 2017
Merged

Minor cleanups, style tweaks #20031

merged 20 commits into from
Jan 18, 2017

Conversation

tkelman
Copy link
Contributor

@tkelman tkelman commented Jan 14, 2017

Mostly removing empty lines right at the start of a block or right before end, consolidating zero-arg lets in many of the tests to save a few lines, and eval-ing a deprecation from #19901 into the right module (that commit is best viewed as f397cad?w=1, as is the last commit d5ea348?w=1 - or overall, https://github.com/JuliaLang/julia/pull/20031/files?w=1).

@@ -651,7 +640,6 @@ Dict(1 => rand(2,3), 'c' => "asdf") # just make sure this does not trigger a dep
end

# issue 19995

@test hash(Dict(Dict(1=>2) => 3, Dict(4=>5) => 6)) != hash(Dict(Dict(4=>5) => 3, Dict(1=>2) => 6))
let a = Dict(Dict(3 => 4, 2 => 3) => 2, Dict(1 => 2, 5 => 6) => 1)
b = Dict(Dict(1 => 2, 2 => 3, 5 => 6) => 1, Dict(3 => 4) => 2)
Copy link
Member

Choose a reason for hiding this comment

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

Looks like there is a comma missing on the previous line, also (so that b is a let variable like a, not that it matters much.)

@@ -509,7 +509,7 @@ function logm(A::StridedMatrix)
end
end

if isreal(A) && ~np_real_eigs
if isreal(A) && !np_real_eigs
Copy link
Member

Choose a reason for hiding this comment

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

:)

@@ -51,10 +51,14 @@ module IteratorsMD

# arithmetic, min/max
(-){N}(index::CartesianIndex{N}) = CartesianIndex{N}(map(-, index.I))
(+){N}(index1::CartesianIndex{N}, index2::CartesianIndex{N}) = CartesianIndex{N}(map(+, index1.I, index2.I))
Copy link
Member

Choose a reason for hiding this comment

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

Do these definitions substantially exceed the line length recommendation? These eyes find the existing (aligned) version easier to parse as a whole than the line-split version. Best!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

113 columns

@@ -843,7 +843,8 @@ may have more values to generate and so might not yet be ready to return. With t
and consumer can both run as long as they need to, passing values back and forth as necessary.

Julia provides a [`Channel`](@ref) mechanism for solving this problem.
A [`Channel`](@ref) is a waitable FIFO queue which can have multiple tasks reading and writing to it.
A [`Channel`](@ref) is a waitable first-in first-out queue which can have
multiple tasks reading and writing to it.
Copy link
Member

@Sacha0 Sacha0 Jan 14, 2017

Choose a reason for hiding this comment

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

Perhaps "reading and" -> "reading from and"?

@@ -904,8 +901,7 @@ end
end

@testset "single multidimensional index" begin
let
Copy link
Member

Choose a reason for hiding this comment

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

Is this let block redundant? (None of a, a2, b, or I occur in the enclosing scope?)


@testset "concatenations of dense matrices/vectors yield dense matrices/vectors" begin
let
N = 4
let N = 4
Copy link
Member

Choose a reason for hiding this comment

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

Likewise here, this let seems redundant with the @testset?

@@ -208,8 +208,7 @@ end
end

@testset "log" begin
# log(conj(z)) = conj(log(z))

# log(conj(z)) = conj(log(z))
Copy link
Member

@Sacha0 Sacha0 Jan 14, 2017

Choose a reason for hiding this comment

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

Perhaps incorporate the comment in the testset description and nix the comment?

@@ -242,8 +241,7 @@ end
end

@testset "exp" begin
# exp(conj(z)) = conj(exp(z))

# exp(conj(z)) = conj(exp(z))
Copy link
Member

Choose a reason for hiding this comment

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

Likewise here, perhaps incorporate the comment in the testset description and nix the comment?

@@ -278,8 +276,7 @@ end
end

@testset "expm1" begin
# expm1(conj(z)) = conj(expm1(z))

# expm1(conj(z)) = conj(expm1(z))
Copy link
Member

Choose a reason for hiding this comment

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

Likewise here, perhaps incorporate the comment in the testset description and nix the comment?

# conj(x)^conj(y) = conj(x^y)
# equivalent to exp(y*log(x))
# except for 0^0?
# conj(x)^conj(y) = conj(x^y)
Copy link
Member

@Sacha0 Sacha0 Jan 14, 2017

Choose a reason for hiding this comment

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

Perhaps also a candidate for expanding the testset description and removing the comments?

# tanh(conj(z)) = conj(tanh(z))
# tanh(-z) = -tanh(z)
# tanh(conj(z)) = conj(tanh(z))
# tanh(-z) = -tanh(z)
Copy link
Member

@Sacha0 Sacha0 Jan 14, 2017

Choose a reason for hiding this comment

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

Likewise here, perhaps incorporate the comments in the testset description and nix the comments?

(Several more such candidates in this file, suppressing further review comments.)

d = eltya == Int ? Tridiagonal(rand(1:7, n-1), rand(1:7, n), rand(1:7, n-1)) :
convert(Tridiagonal{eltya}, eltya <: Complex ?
Tridiagonal(complex.(dlreal, dlimg), complex.(dreal, dimg), complex.(dureal, duimg)) :
Tridiagonal(dlreal, dreal, dureal))
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps indent the two Tridiagonal(... lines, making their nesting within the convert more obvious?

Hinv = Rational{BigInt}[(-1)^(i+j)*(i+j-1)*binomial(nHilbert+i-1,nHilbert-j)*binomial(nHilbert+j-1,nHilbert-i)*binomial(i+j-2,i-1)^2 for i = big(1):nHilbert,j=big(1):nHilbert]
Hinv = Rational{BigInt}[(-1)^(i+j)*(i+j-1)*binomial(nHilbert+i-1,nHilbert-j)*
binomial(nHilbert+j-1,nHilbert-i)*binomial(i+j-2,i-1)^2
for i = big(1):nHilbert,j=big(1):nHilbert]
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps indent the binomial(... and for(... lines further to clarify their part in the comprehension?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to where? it would start getting overly wide to align to the [

Copy link
Member

Choose a reason for hiding this comment

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

The [ was my thought, yes.

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'm not much of a fan of horizontal-alignment games like that, I'd rather just apply a simple set of rules that we could conceivably automate some day.

@@ -384,6 +384,9 @@ end
@test parse("x<:y<:z").head === :comparison
@test parse("x>:y<:z").head === :comparison

# reason PR #19765, <- operator, was reverted
@test -2<-1 # DO NOT ADD SPACES
Copy link
Member

Choose a reason for hiding this comment

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

# DO NOT ADD SPACES 😆

@ararslan
Copy link
Member

Is this good to go?

@tkelman
Copy link
Contributor Author

tkelman commented Jan 17, 2017

As far as I'm concerned yes, though when merged it might cause conflicts with PR's that are messier to rebase than this would be.

@tkelman tkelman merged commit 23c4fa4 into master Jan 18, 2017
@tkelman tkelman deleted the tk/various branch January 18, 2017 23:03
@tkelman
Copy link
Contributor Author

tkelman commented Jan 18, 2017

thanks for reviewing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants