-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Minor cleanups, style tweaks #20031
Conversation
@@ -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) |
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.
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 |
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.
:)
@@ -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)) |
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.
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!
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.
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. |
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.
Perhaps "reading and" -> "reading from and"?
@@ -904,8 +901,7 @@ end | |||
end | |||
|
|||
@testset "single multidimensional index" begin | |||
let |
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.
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 |
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.
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)) |
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.
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)) |
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.
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)) |
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.
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) |
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.
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) |
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.
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)) |
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.
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] |
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.
Perhaps indent the binomial(...
and for(...
lines further to clarify their part in the comprehension?
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.
to where? it would start getting overly wide to align to the [
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.
The [
was my thought, yes.
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'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 |
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.
# DO NOT ADD SPACES
😆
especially right after a block opener and right before end
over 'environmental variable'
todo: make this a doctest
and linalg/dense.jl
remove lets where redundant with testsets move some comments into testset descriptions
Is this good to go? |
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. |
thanks for reviewing! |
Mostly removing empty lines right at the start of a block or right before end, consolidating zero-arg
let
s 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).