before_code
stringlengths
30
149k
reviewer_comment
stringlengths
16
20.6k
after_code
stringlengths
30
163k
diff_context
stringlengths
0
22.4k
file_path
stringlengths
6
155
comment_line
int64
0
26
language
stringclasses
19 values
quality_score
float64
0.07
1
comment_type
stringclasses
9 values
comment_length
int64
16
20.6k
before_lines
int64
2
4.61k
after_lines
int64
2
4.4k
is_negative
bool
2 classes
pr_title
stringlengths
7
140
pr_number
int64
18
61.2k
repo_name
stringclasses
29 values
repo_stars
int64
321
56k
repo_language
stringclasses
14 values
reviewer_username
stringclasses
378 values
author_username
stringclasses
739 values
user
stringlengths
361
200k
assistant
stringlengths
16
20.6k
system
stringclasses
1 value
forcedFirSetting: Boolean? = null, additionalConfigurationParameters: (CompilerConfiguration) -> Unit = {}, registerExtensions: (Project.(CompilerConfiguration) -> Unit)? = null, ) = KotlinCompilerFacade.create( testRootDisposable, updateConfiguration = { val enab...
No issues found.
forcedFirSetting: Boolean? = null, additionalConfigurationParameters: (CompilerConfiguration) -> Unit = {}, registerExtensions: (Project.(CompilerConfiguration) -> Unit)? = null, ) = KotlinCompilerFacade.create( testRootDisposable, updateConfiguration = { val enab...
@@ -120,6 +120,7 @@ abstract class AbstractCompilerTest(val useFir: Boolean) { ApiVersion.createByLanguageVersion(languageVersion), analysisFlags ) + ComposePluginRegistrar.setupJvmConfiguration(this) updateConfiguration() additionalCon...
plugins/compose/compiler-hosted/integration-tests/src/jvmTest/kotlin/androidx/compose/compiler/plugins/kotlin/AbstractCompilerTest.kt
0
Kotlin
1
none
16
51
51
true
[Compose] avoid copying Compose-specific annotations to bridges
5,612
JetBrains/kotlin
51,705
Kotlin
andrey-mogilev
Review this pull request change. Language: Kotlin File: plugins/compose/compiler-hosted/integration-tests/src/jvmTest/kotlin/androidx/compose/compiler/plugins/kotlin/AbstractCompilerTest.kt PR Title: [Compose] avoid copying Compose-specific annotations to bridges BEFORE CODE: forcedFirSetting: Boolean? = nu...
No issues found.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
data class ClassId(val value: String) { internal constructor(node: ClassNode) : this(node.name) val descriptor: String get() = "L$value;" val fqName: String get() = value.replace("/", ".") } data class MethodId( val classId: ClassId, val methodName: String, val methodDescriptor: String, ) { ...
No issues found.
data class ClassId(val value: String) { internal constructor(node: ClassNode) : this(node.name) val descriptor: String get() = "L$value;" val fqName: String get() = value.replace("/", ".") } data class MethodId( val classId: ClassId, val methodName: String, val methodDescriptor: String, ) { ...
@@ -56,10 +56,21 @@ internal fun MethodId(methodInsnNode: MethodInsnNode): MethodId = MethodId( methodDescriptor = methodInsnNode.desc ) -fun classInfoFromBytecode(keyCache: LambdaKeyCache, reporter: ErrorReporter, bytecode: ByteArray): ClassInfo { - val reader = ClassReader(bytecode) - val node = ClassNo...
plugins/compose/group-mapping/src/main/kotlin/androidx/compose/compiler/mapping/ClassInfo.kt
0
Kotlin
1
none
16
51
51
true
Allow Compose mapping analysis to read files compiled for Java 25+
5,614
JetBrains/kotlin
51,705
Kotlin
ShikaSD
Review this pull request change. Language: Kotlin File: plugins/compose/group-mapping/src/main/kotlin/androidx/compose/compiler/mapping/ClassInfo.kt PR Title: Allow Compose mapping analysis to read files compiled for Java 25+ BEFORE CODE: data class ClassId(val value: String) { internal constructor(node: Class...
No issues found.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
expression.typeArguments.size, expression.origin, expression.superQualifierSymbol, ).apply { copyTypeAndValueArgumentsFrom(expression) } ) } // If we are calling an external funct...
No issues found.
expression.typeArguments.size, expression.origin, expression.superQualifierSymbol, ).apply { copyTypeAndValueArgumentsFrom(expression) } ) } // If we are calling an external funct...
@@ -309,6 +309,13 @@ internal class ComposableTypeTransformer( return super.visitFunctionReference(expression) } + override fun visitRichFunctionReference(expression: IrRichFunctionReference): IrExpression { + if (expression.overriddenFunctionSymbol.owner.needsComposableRemapping()) { + ...
plugins/compose/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableTypeRemapper.kt
0
Kotlin
1
none
16
51
51
true
[CMP] fix CMP-9456
5,648
JetBrains/kotlin
51,705
Kotlin
shishkin-pavel
Review this pull request change. Language: Kotlin File: plugins/compose/compiler-hosted/src/main/java/androidx/compose/compiler/plugins/kotlin/lower/ComposableTypeRemapper.kt PR Title: [CMP] fix CMP-9456 BEFORE CODE: expression.typeArguments.size, expression.origin, ...
No issues found.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
typemin(::Type{Float16}) = $(bitcast(Float16, 0xfc00)) typemax(::Type{Float16}) = $(Inf16) typemin(::Type{Float32}) = $(-Inf32) typemax(::Type{Float32}) = $(Inf32) typemin(::Type{Float64}) = $(-Inf64) typemax(::Type{Float64}) = $(Inf64) typemin(x::T) where {T<:Real} = typemin(T) typemax(...
Is it the most appropriate to define the eps for the norm of the number? E.g. why not actually define it in terms of `eps(min(x.re,x.im)` that way it gives the minimum next largest value?
($op)(x::Float16, y::Union{Int16,UInt16}) = ($op)(Float32(x), Float32(y)) ($op)(x::Union{Int16,UInt16}, y::Float16) = ($op)(Float32(x), Float32(y)) end end abs(x::IEEEFloat) = abs_float(x) """ isnan(f)::Bool Test whether a number value is a NaN, an indeterminate value which is neither an in...
@@ -713,6 +713,8 @@ end eps(::Type{Float16}) = $(bitcast(Float16, 0x1400)) eps(::Type{Float32}) = $(bitcast(Float32, 0x34000000)) eps(::Type{Float64}) = $(bitcast(Float64, 0x3cb0000000000000)) + eps(::Type{Complex{T}}) where {T<:AbstractFloat} = eps(T) + eps(x::Complex{T}) where {T<:AbstractFloat} ...
base/float.jl
26
Julia
0.5
question
191
51
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
musm
ChrisRackauckas
Review this pull request change. Language: Julia File: base/float.jl PR Title: Support complex numbers in eps BEFORE CODE: typemin(::Type{Float16}) = $(bitcast(Float16, 0xfc00)) typemax(::Type{Float16}) = $(Inf16) typemin(::Type{Float32}) = $(-Inf32) typemax(::Type{Float32}) = $(Inf32) typemin(:...
Is it the most appropriate to define the eps for the norm of the number? E.g. why not actually define it in terms of `eps(min(x.re,x.im)` that way it gives the minimum next largest value?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@test typeof(sign(z)) == typeof(z) end for T in (Int32, Int64) z = Complex{T}(1) @test typeof(sign(z)) == typeof(float(z)) z = Complex{T}(0) @test typeof(sign(z)) == typeof(float(z)) end @test sign(0 + 0im) == 0 @test sign(2 + 0im) == 1 @test sign(-2 + 0i...
might be better to use `===` to also test the types on the lhs == rhs
@test complex.(1.0, [1.0, 1.0]) == [complex(1.0, 1.0), complex(1.0, 1.0)] @test complex.([1.0, 1.0], 1.0) == [complex(1.0, 1.0), complex(1.0, 1.0)] # robust division of Float64 # hard complex divisions from Fig 6 of arxiv.1210.4539 z7 = ComplexF64(3.898125604559113300e289, 8.174961907852353577e295) z9 = ComplexF64(0.0...
@@ -871,6 +871,13 @@ end end end +@testset "eps" begin + @test eps(1.0+1.0im) == 3.1401849173675503e-16
test/complex.jl
26
Julia
0.571
suggestion
71
51
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
musm
ChrisRackauckas
Review this pull request change. Language: Julia File: test/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: @test typeof(sign(z)) == typeof(z) end for T in (Int32, Int64) z = Complex{T}(1) @test typeof(sign(z)) == typeof(float(z)) z = Complex{T}(0) @t...
might be better to use `===` to also test the types on the lhs == rhs
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" eps(::Type{T}) where T<:AbstractFloat eps() Returns the *machine epsilon* of the floating point type `T` (`T = Float64` by default). This is defined as the gap between 1 and the next largest value representable by `T`, and is equivalent to `eps(one(T))`. ```jldoctest julia> eps() 2.220446049250313e-16 j...
should math highlight these (and `z=a+ib` on the previous line)
Test whether a number is infinite. See also: [`Inf`](@ref), [`iszero`](@ref), [`isfinite`](@ref), [`isnan`](@ref). """ isinf(x::Real) = !isnan(x) & !isfinite(x) isinf(x::IEEEFloat) = abs(x) === oftype(x, Inf) #= `decompose(x)`: non-canonical decomposition of rational values as `num*2^pow/den`. The decompose function...
@@ -737,6 +738,10 @@ julia> 1.0 + eps() julia> 1.0 + eps()/2 1.0 ``` + +For complex inputs `T`, `eps(T)` is defined as the distance bound to the nearest +floating-point complex value, i.e. for z=a+ib and the closest floating-point +complex value z̃=ã+ib̃=fl(a)+ifl(b), |z - z̃| ≤ ε/2.
base/float.jl
26
Julia
0.429
suggestion
63
51
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
tkelman
ChrisRackauckas
Review this pull request change. Language: Julia File: base/float.jl PR Title: Support complex numbers in eps BEFORE CODE: """ eps(::Type{T}) where T<:AbstractFloat eps() Returns the *machine epsilon* of the floating point type `T` (`T = Float64` by default). This is defined as the gap between 1 and the n...
should math highlight these (and `z=a+ib` on the previous line)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" eps(::Type{T}) where T<:AbstractFloat eps() Returns the *machine epsilon* of the floating point type `T` (`T = Float64` by default). This is defined as the gap between 1 and the next largest value representable by `T`, and is equivalent to `eps(one(T))`. ```jldoctest julia> eps() 2.220446049250313e-16 j...
math highlighting is double backticks
Test whether a number is infinite. See also: [`Inf`](@ref), [`iszero`](@ref), [`isfinite`](@ref), [`isnan`](@ref). """ isinf(x::Real) = !isnan(x) & !isfinite(x) isinf(x::IEEEFloat) = abs(x) === oftype(x, Inf) #= `decompose(x)`: non-canonical decomposition of rational values as `num*2^pow/den`. The decompose function...
@@ -740,8 +740,8 @@ julia> 1.0 + eps()/2 ``` For complex inputs `T`, `eps(T)` is defined as the distance bound to the nearest -floating-point complex value, i.e. for z=a+ib and the closest floating-point -complex value z̃=ã+ib̃=fl(a)+ifl(b), |z - z̃| ≤ ε/2. +floating-point complex value, i.e. for `z=a+ib` and the ...
base/float.jl
26
Julia
0.071
suggestion
37
51
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
tkelman
ChrisRackauckas
Review this pull request change. Language: Julia File: base/float.jl PR Title: Support complex numbers in eps BEFORE CODE: """ eps(::Type{T}) where T<:AbstractFloat eps() Returns the *machine epsilon* of the floating point type `T` (`T = Float64` by default). This is defined as the gap between 1 and the n...
math highlighting is double backticks
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end float(z::Complex{<:AbstractFloat}) = z float(z::Complex) = Complex(float(real(z)), float(imag(z))) big(::Type{Complex{T}}) where {T<:Real} = Complex{big(T)} big(z::Complex{T}) where {T<:Real} = Complex{big(T)}(z) ## Array operations on complex numbers ## complex(A::AbstractArray{<:Complex}) = A function comple...
`hypot` is not defined till later in the system image load So I think this should just be ```julia function eps(z::Complex{T}) where {T<:AbstractFloat} x, y = eps(real(z)), eps(imag(z)) if x < y x, y = y, x end r = y/x x * sqrt(one(T) + r * r) end ```
return Complex{P}(z) ^ P(p) end function ^(z::T, p::Complex{S}) where {T<:Real,S<:Real} P = promote_type(T,S) return P(z) ^ Complex{P}(p) end function sin(z::Complex{T}) where T F = float(T) zr, zi = reim(z) if zr == 0 Complex(F(zr), sinh(zi)) elseif !isfinite(zr) if zi == 0...
@@ -897,6 +897,10 @@ function complex(A::AbstractArray{T}) where T convert(AbstractArray{typeof(complex(zero(T)))}, A) end -## promotion to complex ## +## Promotion to complex ## _default_type(T::Type{Complex}) = Complex{Int} + +## Machine epsilon for complex ## + +eps(z::Complex{T}) where {T<:AbstractFloat}...
base/complex.jl
26
Julia
0.857
refactor
297
27
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
musm
ChrisRackauckas
Review this pull request change. Language: Julia File: base/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: end float(z::Complex{<:AbstractFloat}) = z float(z::Complex) = Complex(float(real(z)), float(imag(z))) big(::Type{Complex{T}}) where {T<:Real} = Complex{big(T)} big(z::Complex{T}) where {T<...
`hypot` is not defined till later in the system image load So I think this should just be ```julia function eps(z::Complex{T}) where {T<:AbstractFloat} x, y = eps(real(z)), eps(imag(z)) if x < y x, y = y, x end r = y/x x * sqrt(one(T) + r * r) end ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for T in (Int32, Int64) z = Complex{T}(1) @test typeof(sign(z)) == typeof(float(z)) z = Complex{T}(0) @test typeof(sign(z)) == typeof(float(z)) end @test sign(0 + 0im) == 0 @test sign(2 + 0im) == 1 @test sign(-2 + 0im) == -1 @test sign(1 + im) ≈ (1 + im) / sqrt(2...
this will need to be updated too
@test complex.([1.0, 1.0], 1.0) == [complex(1.0, 1.0), complex(1.0, 1.0)] # robust division of Float64 # hard complex divisions from Fig 6 of arxiv.1210.4539 z7 = ComplexF64(3.898125604559113300e289, 8.174961907852353577e295) z9 = ComplexF64(0.001953125, -0.001953125) z10 = ComplexF64( 1.02951151789360578e-84, 6.971459...
@@ -871,6 +871,13 @@ end end end +@testset "eps" begin + @test eps(1.0+1.0im) == 3.1401849173675503e-16 + @test eps(Complex128) == eps(1.0+1.0im) + @test eps(Complex64) == 1.1920929f-7
test/complex.jl
26
Julia
0.071
suggestion
32
51
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
musm
ChrisRackauckas
Review this pull request change. Language: Julia File: test/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: for T in (Int32, Int64) z = Complex{T}(1) @test typeof(sign(z)) == typeof(float(z)) z = Complex{T}(0) @test typeof(sign(z)) == typeof(float(z)) end ...
this will need to be updated too
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# This file is a part of Julia. License is MIT: https://julialang.org/license struct Complex{T<:Real} <: Number re::T im::T end Complex(x::Real, y::Real) = Complex(promote(x,y)...) Complex(x::Real) = Complex(x, zero(x)) """ im The imaginary unit. """ const im = Complex(false,true) const Complex128 = Com...
Maybe a comment that this is just `hypot(x,y)` and explaining why you aren't calling `hypot`.
julia> complex([1, 2, 3]) 3-element Vector{Complex{Int64}}: 1 + 0im 2 + 0im 3 + 0im ``` """ complex(A::AbstractArray{<:Complex}) = A function complex(A::AbstractArray{T}) where T if !isconcretetype(T) error("`complex` not defined on abstractly-typed arrays; please convert to a more specific type") e...
@@ -897,6 +897,17 @@ function complex(A::AbstractArray{T}) where T convert(AbstractArray{typeof(complex(zero(T)))}, A) end -## promotion to complex ## +## Promotion to complex ## _default_type(T::Type{Complex}) = Complex{Int} + +## Machine epsilon for complex ## + +function eps(z::Complex{T}) where {T<:Abstr...
base/complex.jl
26
Julia
0.357
suggestion
93
914
26
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
stevengj
ChrisRackauckas
Review this pull request change. Language: Julia File: base/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license struct Complex{T<:Real} <: Number re::T im::T end Complex(x::Real, y::Real) = Complex(promote(x,y)...) C...
Maybe a comment that this is just `hypot(x,y)` and explaining why you aren't calling `hypot`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# This file is a part of Julia. License is MIT: https://julialang.org/license ## floating point traits ## """ Inf16 Positive infinity of type `Float16`. """ const Inf16 = bitcast(Float16, 0x7c00) """ NaN16 A not-a-number value of type `Float16`. """ const NaN16 = bitcast(Float16, 0x7e00) """ Inf32 Posi...
This should be in the complex.jl file also (or instead?–I'm not entirely sure which one was intended to be canonical)
ispow2(x::AbstractFloat) = !iszero(x) && frexp(x)[1] == 0.5 iseven(x::AbstractFloat) = isinteger(x) && (abs(x) > maxintfloat(x) || iseven(Integer(x))) isodd(x::AbstractFloat) = isinteger(x) && abs(x) ≤ maxintfloat(x) && isodd(Integer(x)) @eval begin typemin(::Type{Float16}) = $(bitcast(Float16, 0xfc00)) typem...
@@ -713,6 +713,7 @@ end eps(::Type{Float16}) = $(bitcast(Float16, 0x1400)) eps(::Type{Float32}) = $(bitcast(Float32, 0x34000000)) eps(::Type{Float64}) = $(bitcast(Float64, 0x3cb0000000000000)) + eps(::Type{Complex{T}}) where {T<:AbstractFloat} = sqrt(2*one(T))*eps(T)
base/float.jl
26
Julia
0.429
suggestion
117
876
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
vtjnash
ChrisRackauckas
Review this pull request change. Language: Julia File: base/float.jl PR Title: Support complex numbers in eps BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license ## floating point traits ## """ Inf16 Positive infinity of type `Float16`. """ const Inf16 = bitcast(Float16...
This should be in the complex.jl file also (or instead?–I'm not entirely sure which one was intended to be canonical)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
eps() Return the *machine epsilon* of the floating point type `T` (`T = Float64` by default). This is defined as the gap between 1 and the next largest value representable by `typeof(one(T))`, and is equivalent to `eps(one(T))`. (Since `eps(T)` is a bound on the *relative error* of `T`, it is a "dimensionless" qu...
It would be good to frame this as a strict generalization of the definition, since it is also true for real numbers, and then give complex numbers as a special case. ```suggestion More generally, for any floating-point numeric type, `eps` corresponds to an upper bound on the distance to the nearest floating-point ...
eps() Return the *machine epsilon* of the floating point type `T` (`T = Float64` by default). This is defined as the gap between 1 and the next largest value representable by `typeof(one(T))`, and is equivalent to `eps(one(T))`. (Since `eps(T)` is a bound on the *relative error* of `T`, it is a "dimensionless" qu...
@@ -1064,6 +1064,11 @@ julia> 1.0 + eps() julia> 1.0 + eps()/2 1.0 ``` + +For complex inputs `T`, `eps(T)` is defined as the distance bound to the nearest +floating-point complex value, i.e. for ``z=a+ib`` and the closest floating-point +complex value ``z̃=ã+ib̃=fl(a)+ifl(b)`` where ``fl(x)`` is the closest +floati...
base/float.jl
26
Julia
1
bug
943
51
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
stevengj
ChrisRackauckas
Review this pull request change. Language: Julia File: base/float.jl PR Title: Support complex numbers in eps BEFORE CODE: eps() Return the *machine epsilon* of the floating point type `T` (`T = Float64` by default). This is defined as the gap between 1 and the next largest value representable by `typeof(one(T...
It would be good to frame this as a strict generalization of the definition, since it is also true for real numbers, and then give complex numbers as a special case. ```suggestion More generally, for any floating-point numeric type, `eps` corresponds to an upper bound on the distance to the nearest floating-point ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
julia> complex([1, 2, 3]) 3-element Vector{Complex{Int64}}: 1 + 0im 2 + 0im 3 + 0im ``` """ complex(A::AbstractArray{<:Complex}) = A function complex(A::AbstractArray{T}) where T if !isconcretetype(T) error("`complex` not defined on abstractly-typed arrays; please convert to a more specific type") e...
Can be shortened to: ```suggestion eps(z::Complex{<:AbstractFloat}) = hypot(eps(real(z)), eps(imag(z))) ```
julia> complex([1, 2, 3]) 3-element Vector{Complex{Int64}}: 1 + 0im 2 + 0im 3 + 0im ``` """ complex(A::AbstractArray{<:Complex}) = A function complex(A::AbstractArray{T}) where T if !isconcretetype(T) error("`complex` not defined on abstractly-typed arrays; please convert to a more specific type") e...
@@ -1141,3 +1141,16 @@ function complex(A::AbstractArray{T}) where T end convert(AbstractArray{typeof(complex(zero(T)))}, A) end + +## Promotion to complex ## + +_default_type(T::Type{Complex}) = Complex{Int} + +## Machine epsilon for complex ## + +function eps(z::Complex{T}) where {T<:AbstractFloat} + x,...
base/complex.jl
26
Julia
0.714
refactor
110
29
26
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
stevengj
ChrisRackauckas
Review this pull request change. Language: Julia File: base/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: julia> complex([1, 2, 3]) 3-element Vector{Complex{Int64}}: 1 + 0im 2 + 0im 3 + 0im ``` """ complex(A::AbstractArray{<:Complex}) = A function complex(A::AbstractArray{T}) where T if !...
Can be shortened to: ```suggestion eps(z::Complex{<:AbstractFloat}) = hypot(eps(real(z)), eps(imag(z))) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
for T in (Int32, Int64) z = Complex{T}(1) @test typeof(sign(z)) == typeof(float(z)) z = Complex{T}(0) @test typeof(sign(z)) == typeof(float(z)) end @test sign(0 + 0im) == 0 @test sign(2 + 0im) == 1 @test sign(-2 + 0im) == -1 @test sign(1 + im) ≈ (1 + im) / sqrt(2...
`Complex128` and `Complex64` don't exist (anymore)
for T in (Int32, Int64) z = Complex{T}(1) @test typeof(sign(z)) == typeof(float(z)) z = Complex{T}(0) @test typeof(sign(z)) == typeof(float(z)) end @test sign(0 + 0im) == 0 @test sign(2 + 0im) == 1 @test sign(-2 + 0im) == -1 @test sign(1 + im) ≈ (1 + im) / sqrt(2...
@@ -932,6 +932,13 @@ end end end +@testset "eps" begin + @test eps(1.0+1.0im) === 3.1401849173675503e-16 + @test eps(Complex128) === eps(1.0+1.0im) + @test eps(Complex64) === 1.6858739f-7
test/complex.jl
26
Julia
0.357
suggestion
50
51
51
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
giordano
ChrisRackauckas
Review this pull request change. Language: Julia File: test/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: for T in (Int32, Int64) z = Complex{T}(1) @test typeof(sign(z)) == typeof(float(z)) z = Complex{T}(0) @test typeof(sign(z)) == typeof(float(z)) end ...
`Complex128` and `Complex64` don't exist (anymore)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# This file is a part of Julia. License is MIT: https://julialang.org/license """ Complex{T<:Real} <: Number Complex number type with real and imaginary part of type `T`. `ComplexF16`, `ComplexF32` and `ComplexF64` are aliases for `Complex{Float16}`, `Complex{Float32}` and `Complex{Float64}` respectively. See a...
I think this should be removed? Doesn't seem to be used anywhere.
Return an array containing the complex analog of each entry in array `A`. Equivalent to `complex.(A)`, except that the return value may share memory with all or part of `A` in accordance with the behavior of `convert(T, A)` given output type `T`. # Examples ```jldoctest julia> complex([1, 2, 3]) 3-element Vector{Comp...
@@ -1141,3 +1141,13 @@ function complex(A::AbstractArray{T}) where T end convert(AbstractArray{typeof(complex(zero(T)))}, A) end + +## Promotion to complex ## + +_default_type(T::Type{Complex}) = Complex{Int}
base/complex.jl
26
Julia
0.286
suggestion
65
1,144
33
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
JeffBezanson
ChrisRackauckas
Review this pull request change. Language: Julia File: base/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license """ Complex{T<:Real} <: Number Complex number type with real and imaginary part of type `T`. `ComplexF16`,...
I think this should be removed? Doesn't seem to be used anywhere.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# This file is a part of Julia. License is MIT: https://julialang.org/license """ Complex{T<:Real} <: Number Complex number type with real and imaginary part of type `T`. `ComplexF16`, `ComplexF32` and `ComplexF64` are aliases for `Complex{Float16}`, `Complex{Float32}` and `Complex{Float64}` respectively. See a...
Probably `2*one(T)` would have been better written as `T(2)`.
```jldoctest julia> complex([1, 2, 3]) 3-element Vector{Complex{Int64}}: 1 + 0im 2 + 0im 3 + 0im ``` """ complex(A::AbstractArray{<:Complex}) = A function complex(A::AbstractArray{T}) where T if !isconcretetype(T) error("`complex` not defined on abstractly-typed arrays; please convert to a more specific...
@@ -1141,3 +1141,13 @@ function complex(A::AbstractArray{T}) where T end convert(AbstractArray{typeof(complex(zero(T)))}, A) end + +## Promotion to complex ## + +_default_type(T::Type{Complex}) = Complex{Int} + +## Machine epsilon for complex ## + +eps(z::Complex{<:AbstractFloat}) = hypot(eps(real(z)), eps(i...
base/complex.jl
26
Julia
0.429
suggestion
61
1,144
27
false
Support complex numbers in eps
21,858
JuliaLang/julia
35,573
Julia
stevengj
ChrisRackauckas
Review this pull request change. Language: Julia File: base/complex.jl PR Title: Support complex numbers in eps BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license """ Complex{T<:Real} <: Number Complex number type with real and imaginary part of type `T`. `ComplexF16`,...
Probably `2*one(T)` would have been better written as `T(2)`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Create an arbitrary precision integer. `x` may be an `Int` (or anything that can be converted to an `Int`). The usual mathematical operators are defined for this type, and results are promoted to a [`BigInt`](@ref). Instances can be constructed from strings via [`parse`](@ref), or using the `big` string literal. # E...
Is this name fine? Uppercase and all? What about `ALLOC_OVERFLOW_PATCH` ?
Create an arbitrary precision integer. `x` may be an `Int` (or anything that can be converted to an `Int`). The usual mathematical operators are defined for this type, and results are promoted to a [`BigInt`](@ref). Instances can be constructed from strings via [`parse`](@ref), or using the `big` string literal. # E...
@@ -81,6 +81,14 @@ julia> big"313" """ BigInt(x) +""" + HAS_ALLOC_OVERFLOW_FUNCTION + +A reference that holds a boolean, if true, indicating julia is linked with a patched GMP that +does not abort on huge allocation and throws OutOfMemoryError instead. +""" +const HAS_ALLOC_OVERFLOW_FUNCTION = Ref(false)
base/gmp.jl
26
Julia
0.5
bug
76
51
51
false
rebase: Throw OutOfMemoryError when gmp tries to allocate memory beyond the limit
31,215
JuliaLang/julia
35,573
Julia
musm
musm
Review this pull request change. Language: Julia File: base/gmp.jl PR Title: rebase: Throw OutOfMemoryError when gmp tries to allocate memory beyond the limit BEFORE CODE: Create an arbitrary precision integer. `x` may be an `Int` (or anything that can be converted to an `Int`). The usual mathematical operators ar...
Is this name fine? Uppercase and all? What about `ALLOC_OVERFLOW_PATCH` ?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractMatrix}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractVector}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractMatrix}) = A.parent * B # disambiguation meth...
I think it wouldn't be hard to support arbitrary indexing. Wouldn't something like ```julia idx = axes(X, 1) jdx = axes(X, 2) idx == jdx || error for _j, _i... i, j = idx[_i], jdx[j] ... end ``` work? Hopefully, the compiler is able to do something useful when the input has `OneTo` indices.
return retmat end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also someti...
@@ -890,3 +890,38 @@ end *(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Transpose{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractTriangular}...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
1
suggestion
304
49
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
andreasnoack
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractMatrix}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:...
I think it wouldn't be hard to support arbitrary indexing. Wouldn't something like ```julia idx = axes(X, 1) jdx = axes(X, 2) idx == jdx || error for _j, _i... i, j = idx[_i], jdx[j] ... end ``` work? Hopefully, the compiler is able to do something useful when the input has `OneTo` indices.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractMatrix}) = A.parent * B # disambiguation methods: *(Adj/Trans of AbsTri or RealHermSymComplex{Herm|Sym}, Adj/Trans of other) *(A::Adjoint{<:Any,<:AbstractTriangular}, B::Adjoint{<:Any,<:RealHermSymComplexHerm}) = A * B.parent *(A::Adjoint{<:An...
As mentioned in the comment, I think we should make this would for non-real matrices. In that case, you should include the diagonal do make this correct in the non-real case. Maybe move the diagonal outside the `i` loop and just use `real`.
end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also sometimes called the "operator real part". The optio...
@@ -890,3 +890,38 @@ end *(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Transpose{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractTriangular}...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.643
suggestion
240
47
50
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
andreasnoack
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractMatrix}) = A.parent * B # disambiguation methods: *(Adj/Trans of AbsTri or RealHermSymCom...
As mentioned in the comment, I think we should make this would for non-real matrices. In that case, you should include the diagonal do make this correct in the non-real case. Maybe move the diagonal outside the `i` loop and just use `real`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractVector}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractMatrix}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractVector}) = A.parent * B *(A::Transpose{<:Any,<:R...
`AbstractFloat` seems too restrictive. This is a rational operation.
retmat = (F.vectors * Diagonal(($func).(complex(F.values)))) * F.vectors' return retmat end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix....
@@ -890,3 +890,38 @@ end *(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Transpose{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractTriangular}...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.357
refactor
68
50
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
andreasnoack
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractVector}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:Ab...
`AbstractFloat` seems too restrictive. This is a rational operation.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
!!! compat "Julia 1.3" This function requires Julia 1.3 or later. """ function symmetrize!(X::AbstractMatrix{<:AbstractFloat}) require_one_based_indexing(X) n = checksquare(X) @inbounds for j = 2:n, i = 1:j-1 X[i,j] = (X[i,j] + X[j,i]) / 2 X[j,i] = X[i,j] end X end """ symme...
If we allow for more element types than `AbstractFloat` then the promotion here should be adjusted.
""" hermitianpart!(A, uplo=:U) -> Hermitian Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](@ref). For real matrices `A`, this is also known as the symmetric part of `A`. See also [`hermitianpart`](@ref) for the corresponding out-of-place operati...
@@ -890,3 +890,38 @@ end *(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Transpose{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractTriangular}...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
refactor
99
28
31
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
andreasnoack
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: !!! compat "Julia 1.3" This function requires Julia 1.3 or later. """ function symmetrize!(X::AbstractMatrix{<:AbstractFloat}) require_one_based_indexing(X) ...
If we allow for more element types than `AbstractFloat` then the promotion here should be adjusted.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
See also: [`symmetrize`](@ref) !!! compat "Julia 1.3" This function requires Julia 1.3 or later. """ symmetrize!(X::AbstractMatrix; conjugate::Bool=true) = conjugate ? _symmetrize!(conj, real, X) : _symmetrize!(identity, identity, X) function _symmetrize!(f::Function, g::Function, X::AbstractMatrix) inds...
This doesn't seem very general. Why not use ``` hermitian(X::AbstractMatrix) = hermitian!(copyto!(similar, X, typeof((isempty(X) ? zero(eltype(X)) : first(X))/2)), X)) ``` instead? (Not sure if we really care about the `empty(X)` case, but I guess it doesn't hurt.)
""" hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) = Hermitian(_hermitianpart(A), uplo) """ hermitianpart!(A, uplo=:U) -> Hermitian Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](@ref). For real matrices `A`, this is also known as the symmetri...
@@ -890,3 +890,54 @@ end *(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Transpose{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractTriangular}...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
1
refactor
273
46
33
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: See also: [`symmetrize`](@ref) !!! compat "Julia 1.3" This function requires Julia 1.3 or later. """ symmetrize!(X::AbstractMatrix; conjugate::Bool=true) = ...
This doesn't seem very general. Why not use ``` hermitian(X::AbstractMatrix) = hermitian!(copyto!(similar, X, typeof((isempty(X) ? zero(eltype(X)) : first(X))/2)), X)) ``` instead? (Not sure if we really care about the `empty(X)` case, but I guess it doesn't hurt.)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
*(A::Transpose{<:Any,<:AbstractTriangular}, B::Adjoint{<:Any,<:RealHermSymComplexHerm}) = A * B.parent *(A::Transpose{<:Any,<:AbstractTriangular}, B::Transpose{<:Any,<:RealHermSymComplexSym}) = A * B.parent *(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Adjoint{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Adjoint...
Is it possible to have `s != 1`? `a[begin:end]` only works if the step is 1, so I thought we required consecutive ranges of indices.
""" hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) = Hermitian(_hermitianpart(A), uplo) """ hermitianpart!(A, uplo=:U) -> Hermitian Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](@ref). For real matrices `A`, this is also known as the symmetri...
@@ -902,3 +902,49 @@ end *(A::Adjoint{<:Any,<:RealHermSymComplexHerm}, B::Transpose{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Adjoint{<:Any,<:AbstractTriangular}) = A.parent * B *(A::Transpose{<:Any,<:RealHermSymComplexSym}, B::Transpose{<:Any,<:AbstractTriangular}...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.5
suggestion
134
51
33
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: *(A::Transpose{<:Any,<:AbstractTriangular}, B::Adjoint{<:Any,<:RealHermSymComplexHerm}) = A * B.parent *(A::Transpose{<:Any,<:AbstractTriangular}, B::Transpose{<:Any,...
Is it possible to have `s != 1`? `a[begin:end]` only works if the step is 1, so I thought we required consecutive ranges of indices.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end @testset "issue #30814: Symmetric of Hermitian if diag is not real" begin A = [1 2; 3 4] * (1 + im) B = Hermitian(A) @test_throws ArgumentError Symmetric(B) == Symmetric(Matrix(B)) A[1,1] = 1; A[2,2] = 4 @test Symmetric(B) == Symmetric(Matrix(B)) end @testset "symmetric()/hermitian() for Numbe...
Shouldn't this be `==`? `x - x == 0` and `(x + x) / 2 == x` should always be true for finite `x` without overflow, right?
A = rand(Float32, 3, 3) @test_throws TypeError Symmetric{Float64,Matrix{Float32}}(A, 'U') @test_throws TypeError Hermitian{Float64,Matrix{Float32}}(A, 'U') end @testset "fill[stored]!" begin for uplo in (:U, :L) # Hermitian A = Hermitian(fill(1.0+0im, 2, 2), uplo) @test fill!(A,...
@@ -603,4 +609,65 @@ end @test LinearAlgebra.hermitian_type(Int) == Int end +@testset "symmetrize" begin + @testset "in-place" begin + for T in [Float32, Complex{Float32}], conj in [true, false], offset in [true, false] + X = rand(T, 4, 4) + offset && (X = OffsetArray(X, -2, -2))...
stdlib/LinearAlgebra/test/symmetric.jl
26
Julia
0.714
bug
123
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/test/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: end @testset "issue #30814: Symmetric of Hermitian if diag is not real" begin A = [1 2; 3 4] * (1 + im) B = Hermitian(A) @test_throws ArgumentError Symm...
Shouldn't this be `==`? `x - x == 0` and `(x + x) / 2 == x` should always be true for finite `x` without overflow, right?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
function ($func)(A::Hermitian{T}; $(rtolarg...)) where {T<:Complex} n = checksquare(A) F = eigen(A) λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func).(max.(0, F.va...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
for i in 1:n S.diag[i], C.diag[i] = sincos(F.values[i]) end retmatS, retmatC = (F.vectors * S) * F.vectors', (F.vectors * C) * F.vectors' for i = 1:n retmatS[i,i] = real(retmatS[i,i]) retmatC[i,i] = real(retmatC[i,i]) end return Hermitian(retmatS), Hermitian(retmatC) end ...
@@ -854,3 +854,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.8" + This function requires Julia 1.8 or later.
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
suggestion
92
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: function ($func)(A::Hermitian{T}; $(rtolarg...)) where {T<:Complex} n = checksquare(A) F = eigen(A) λ₀ = $rtolval # treat ...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return retmat end end end end """ symmetricpart(A, uplo=:U) Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, as a [`Symmetric`](@ref) matrix. !!! compat "Julia 1.8" This function requires Julia 1.8 or later. """ symmetricpart(A::...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
for func in (:log, :sqrt) # sqrt has rtol arg to handle matrices that are semidefinite up to roundoff errors rtolarg = func === :sqrt ? Any[Expr(:kw, :(rtol::Real), :(eps(real(float(one(T))))*size(A,1)))] : Any[] rtolval = func === :sqrt ? :(-maximum(abs, F.values) * rtol) : 0 @eval begin functi...
@@ -854,3 +854,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.8" + This function requires Julia 1.8 or later. +""" +sy...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
suggestion
92
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: return retmat end end end end """ symmetricpart(A, uplo=:U) Return the symmetric part of the square matrix `A`, defined ...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
!!! compat "Julia 1.8" This function requires Julia 1.8 or later. """ symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) """ symmetricpart!(A, uplo=:U) Overwrite the square matrix `A` with its symmetric part, `(A + transpose(A)) / 2`, ...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
end return Symmetric(retmat) end function ($func)(A::Hermitian{T}; $(rtolarg...)) where {T<:Complex} n = checksquare(A) F = eigen(A) λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) ...
@@ -854,3 +854,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.8" + This function requires Julia 1.8 or later. +""" +sy...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
suggestion
92
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: !!! compat "Julia 1.8" This function requires Julia 1.8 or later. """ symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
!!! compat "Julia 1.8" This function requires Julia 1.8 or later. """ symmetricpart!(A::AbstractMatrix, uplo::Symbol=:U) = Symmetric(_hermorsympart!(identity, identity, A, char_uplo(uplo)), uplo) """ hermitianpart(A, uplo=:U) Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, a...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
end return Hermitian(retmat) else retmat = (F.vectors * Diagonal(($func).(complex(F.values)))) * F.vectors' return retmat end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the ...
@@ -854,3 +854,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.8" + This function requires Julia 1.8 or later. +""" +sy...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
suggestion
92
43
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: !!! compat "Julia 1.8" This function requires Julia 1.8 or later. """ symmetricpart!(A::AbstractMatrix, uplo::Symbol=:U) = Symmetric(_hermorsympart!(identity,...
```suggestion !!! compat "Julia 1.10" This function requires Julia 1.10 or later. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end end """ symmetricpart(A, uplo=:U) Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, as a [`Symmetric`](@ref) matrix. !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpar...
To be more general, this should be `_hermorsympart!(symmetricpart, transpose, ...)`. Similarly, for `hermitianpart` you should use `_hermorsympart!(hermitianpart, adjoint, ...)`. Then have base cases ``` symmetricpart(x::Number) = x hermitianpart(x::Number) = real(x) ```
function ($func)(A::HermOrSym{T}; $(rtolarg...)) where {T<:Real} F = eigen(A) λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func).(max.(0, F.values)))) * F.vectors' ...
@@ -856,3 +856,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.857
suggestion
282
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: end end """ symmetricpart(A, uplo=:U) Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, as a [`Symmetric`](@ref) matr...
To be more general, this should be `_hermorsympart!(symmetricpart, transpose, ...)`. Similarly, for `hermitianpart` you should use `_hermorsympart!(hermitianpart, adjoint, ...)`. Then have base cases ``` symmetricpart(x::Number) = x hermitianpart(x::Number) = real(x) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end end """ symmetricpart(A, uplo=:U) Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, as a [`Symmetric`](@ref) matrix. !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpar...
```suggestion Symmetric(_hermorsympart!(symmetricpart, transpose, A, char_uplo(uplo)), uplo) ```
function ($func)(A::HermOrSym{T}; $(rtolarg...)) where {T<:Real} F = eigen(A) λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func).(max.(0, F.values)))) * F.vectors' ...
@@ -856,3 +856,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
suggestion
102
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: end end """ symmetricpart(A, uplo=:U) Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, as a [`Symmetric`](@ref) matr...
```suggestion Symmetric(_hermorsympart!(symmetricpart, transpose, A, char_uplo(uplo)), uplo) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
symmetricpart!(A::AbstractMatrix, uplo::Symbol=:U) = Symmetric(_hermorsympart!(identity, identity, A, char_uplo(uplo)), uplo) """ hermitianpart(A, uplo=:U) Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. !!! compat "Julia 1.10" This function...
```suggestion Hermitian(_hermorsympart!(hermitianpart, adjoint, A, char_uplo(uplo)), uplo) ```
end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also sometimes called the "operator real ...
@@ -856,3 +856,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
suggestion
100
40
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: symmetricpart!(A::AbstractMatrix, uplo::Symbol=:U) = Symmetric(_hermorsympart!(identity, identity, A, char_uplo(uplo)), uplo) """ hermitianpart(A, uplo=:U) ...
```suggestion Hermitian(_hermorsympart!(hermitianpart, adjoint, A, char_uplo(uplo)), uplo) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func).(max.(0, F.values)))) * F.vectors' for i = 1:n retmat[i,i] = real(retmat[i,i]) end ...
```suggestion symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) symmetricpart(x::Number) = x ```
retmatS[i,i] = real(retmatS[i,i]) retmatC[i,i] = real(retmatC[i,i]) end return Hermitian(retmatS), Hermitian(retmatC) end for func in (:log, :sqrt) # sqrt has rtol arg to handle matrices that are semidefinite up to roundoff errors rtolarg = func === :sqrt ? Any[Expr(:kw, :(rtol::Real),...
@@ -856,3 +856,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.857
refactor
176
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal...
```suggestion symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) symmetricpart(x::Number) = x ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) """ symmetricpart!(A, uplo=:U) Overwrite the square matrix `A` with its symmetric part, `(A + transpose(A)) / 2`, and return `Symmetric(A, uplo)`. !!! compat "Julia 1.10" This functio...
```suggestion hermitianpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) hermitianpart(x::Number) = real(x) ```
n = checksquare(A) F = eigen(A) λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func).(max.(0, F.values)))) * F.vectors' for i = 1:n retmat...
@@ -856,3 +856,64 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.857
suggestion
124
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) """ symmetricpart!(A, uplo=:U) Ove...
```suggestion hermitianpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) hermitianpart(x::Number) = real(x) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
!!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix{T}, uplo=:U) where {T} = hermitianpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) hermitianpart(x::Number) = real(x) """ hermitianpart!(A, uplo=:U) Overwrite the square matrix `A` with its Hermi...
Maybe just ``` for i in (uplo === 'U' ? (1:(j - 1)) : ((j + 1):n)) ``` ? I'm skeptical that a function call is faster than a conditional here, since the compiler presumably won't be able to inline `triangle(j)`.
of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls the corresponding argument of the [`Hermitian`](@ref) view. For real matrices, the latter is equivalent to a [`Symmetric`](@ref) view. See also [`hermitianpart!`](@ref) for the corresponding in-place operation. !!! com...
@@ -856,3 +856,66 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.786
suggestion
216
32
41
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix{T}, uplo=:U) where {T} = hermitianpart!(copyto!(simila...
Maybe just ``` for i in (uplo === 'U' ? (1:(j - 1)) : ((j + 1):n)) ``` ? I'm skeptical that a function call is faster than a conditional here, since the compiler presumably won't be able to inline `triangle(j)`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
!!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix{T}, uplo=:U) where {T} = hermitianpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) hermitianpart(x::Number) = real(x) """ hermitianpart!(A, uplo=:U) Overwrite the square matrix `A` with its Hermi...
```suggestion @inbounds for j in 1:n A[j, j] = real(A[j, j]) for i in (uplo === 'U' ? (1:(j - 1)) : ((j + 1):n)) ```
of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls the corresponding argument of the [`Hermitian`](@ref) view. For real matrices, the latter is equivalent to a [`Symmetric`](@ref) view. See also [`hermitianpart!`](@ref) for the corresponding in-place operation. !!! com...
@@ -856,3 +856,66 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
suggestion
140
32
41
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
dkarrasch
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix{T}, uplo=:U) where {T} = hermitianpart!(copyto!(simila...
```suggestion @inbounds for j in 1:n A[j, j] = real(A[j, j]) for i in (uplo === 'U' ? (1:(j - 1)) : ((j + 1):n)) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# This file is a part of Julia. License is MIT: https://julialang.org/license # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo) where {T,S<:AbstractMatrix{<:T}} require_one_based_indexing(data) ...
Seems like it could use a bit more explanation: ```suggestion `Symmetric` views are mainly useful for real-symmetric matrices, for which specialized algorithms (e.g. for eigenproblems) are enabled for `Symmetric` types. More generally, see also `Hermitian(A)` for Hermitian matrices `A == A'`, which is effectively...
# This file is a part of Julia. License is MIT: https://julialang.org/license # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo) where {T,S<:AbstractMatrix{<:T}} require_one_based_indexing(data) ...
@@ -17,34 +17,37 @@ end Construct a `Symmetric` view of the upper (if `uplo = :U`) or lower (if `uplo = :L`) triangle of the matrix `A`. +To compute the Hermitian part `(A + A') / 2` of `A`, use [`hermitianpart`](@ref).
stdlib/LinearAlgebra/src/symmetric.jl
20
Julia
1
suggestion
676
45
45
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: Abstra...
Seems like it could use a bit more explanation: ```suggestion `Symmetric` views are mainly useful for real-symmetric matrices, for which specialized algorithms (e.g. for eigenproblems) are enabled for `Symmetric` types. More generally, see also `Hermitian(A)` for Hermitian matrices `A == A'`, which is effectively...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) symmetricpart(x::Number) = x """ symmetricpart!(A, uplo=:U) Overwrite the square matrix `A` with its symmetric part, `(A + transpose(A)) / 2`, and return `Symmetric(A, uplo)`. !!! com...
Should cross-reference `hermitianpart!` and vice versa.
hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls ...
@@ -856,3 +875,70 @@ for func in (:log, :sqrt) end end end + +""" + symmetricpart(A, uplo=:U) + +Return the symmetric part of the square matrix `A`, defined as `(A + transpose(A)) / 2`, +as a [`Symmetric`](@ref) matrix. + +!!! compat "Julia 1.10" + This function requires Julia 1.10 or later. +""" +...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.429
suggestion
55
51
45
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: """ symmetricpart(A::AbstractMatrix{T}, uplo=:U) where {T} = symmetricpart!(copyto!(similar(A, typeof(one(T) / 2)), A), uplo) symmetricpart(x::Number) = x """ ...
Should cross-reference `hermitianpart!` and vice versa.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# This file is a part of Julia. License is MIT: https://julialang.org/license # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo) where {T,S<:AbstractMatrix{<:T}} require_one_based_indexing(data) ...
```suggestion More generally, see also [`Hermitian(A)`](@ref) for Hermitian matrices `A == A'`, which ```
# This file is a part of Julia. License is MIT: https://julialang.org/license # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo) where {T,S<:AbstractMatrix{<:T}} require_one_based_indexing(data) ...
@@ -17,34 +17,45 @@ end Construct a `Symmetric` view of the upper (if `uplo = :U`) or lower (if `uplo = :L`) triangle of the matrix `A`. +`Symmetric` views are mainly useful for real-symmetric matrices, for which +specialized algorithms (e.g. for eigenproblems) are enabled for `Symmetric` types. +More generally, se...
stdlib/LinearAlgebra/src/symmetric.jl
22
Julia
0.714
suggestion
107
47
47
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: Abstra...
```suggestion More generally, see also [`Hermitian(A)`](@ref) for Hermitian matrices `A == A'`, which ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo) where {T,S<:AbstractMatrix{<:T}} require_one_based_indexing(data) (uplo != 'U' && uplo != 'L') && throw_uplo() new{T,S}(data, upl...
If we are going to keep the `symmetricpart` function (grr), then it would be weird not to mention it here as well. Also, the `Hermitian` docstring should cross-reference `hermitianpart`.
# Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo) where {T,S<:AbstractMatrix{<:T}} require_one_based_indexing(data) (uplo != 'U' && uplo != 'L') && throw_uplo() new{T,S}(data, upl...
@@ -17,34 +17,45 @@ end Construct a `Symmetric` view of the upper (if `uplo = :U`) or lower (if `uplo = :L`) triangle of the matrix `A`. +`Symmetric` views are mainly useful for real-symmetric matrices, for which +specialized algorithms (e.g. for eigenproblems) are enabled for `Symmetric` types. +More generally, se...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
suggestion
189
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo)...
If we are going to keep the `symmetricpart` function (grr), then it would be weird not to mention it here as well. Also, the `Hermitian` docstring should cross-reference `hermitianpart`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
!!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ symmetricpart!(A::AbstractMatrix, uplo::Symbol=:U) = Symmetric(_hermorsympart!(symmetricpart, transpose, A, char_uplo(uplo)), uplo) """ hermitianpart(A, uplo=:U, full=false) -> Hermitian Return the Hermitian part of the square matrix ...
This seems like a strange API — why should you need to pass `uplo` in order to set`full=true`? Could it be `uplo=:both` or similar? Either that or `full` should be a keyword argument.
This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) = Hermitian(_hermitianpart(A), uplo) """ hermitianpart!(A, uplo=:U) -> Hermitian Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](@ref). For real ...
@@ -902,26 +902,28 @@ symmetricpart!(A::AbstractMatrix, uplo::Symbol=:U) = Symmetric(_hermorsympart!(symmetricpart, transpose, A, char_uplo(uplo)), uplo) """ - hermitianpart(A, uplo=:U) -> Hermitian + hermitianpart(A, uplo=:U, full=false) -> Hermitian Return the Hermitian part of the square matrix `A`,...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
suggestion
187
51
34
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ symmetricpart!(A::AbstractMatrix, uplo::Symbol=:U) = Symmetric(_hermorsympart!(symmetr...
This seems like a strange API — why should you need to pass `uplo` in order to set`full=true`? Could it be `uplo=:both` or similar? Either that or `full` should be a keyword argument.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
hermitianpart!(copy_similar(A, typeof(one(T) / 2)), uplo, full) hermitianpart(x::Number, uplo=:U, full::Bool=false) = real(x) """ hermitianpart!(A, uplo=:U, full=false) -> Hermitian Overwrite the upper (`uplo = :U`) or lower (`uplo = :L`) triangle of the square matrix `A` with its Hermitian part `(A + A') / 2...
Seems suboptimal to have this test inside the loop. If it doesn't cost too much, why not just set `A[j, i]` unconditionally as @Jutho suggested? I doubt that this function is performance-critical in any real application.
# This file is a part of Julia. License is MIT: https://julialang.org/license # Symmetric and Hermitian matrices struct Symmetric{T,S<:AbstractMatrix{<:T}} <: AbstractMatrix{T} data::S uplo::Char function Symmetric{T,S}(data, uplo) where {T,S<:AbstractMatrix{<:T}} require_one_based_indexing(data) ...
@@ -932,16 +934,17 @@ See also [`hermitianpart`](@ref). !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ -hermitianpart!(A::AbstractMatrix, uplo::Symbol=:U) = - Hermitian(_hermorsympart!(hermitianpart, adjoint, A, char_uplo(uplo)), uplo) +hermitianpart!(A::AbstractMatrix, uplo::Symbol=:...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
performance
223
31
931
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: hermitianpart!(copy_similar(A, typeof(one(T) / 2)), uplo, full) hermitianpart(x::Number, uplo=:U, full::Bool=false) = real(x) """ hermitianpart!(A, uplo=:U, ...
Seems suboptimal to have this test inside the loop. If it doesn't cost too much, why not just set `A[j, i]` unconditionally as @Jutho suggested? I doubt that this function is performance-critical in any real application.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
[`Hermitian`](@ref) view. For real matrices, the latter is equivalent to a [`Symmetric`](@ref) view. See also [`hermitianpart!`](@ref) for the corresponding in-place operation. !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix{T}, uplo::Symbol=:U) where {T} = ...
since `hermitianpart` returns `Hermitian`, this doesn't seem quite right for the `real` function — if `A` is an array of matrices, it will make the resulting array heterogeneous.
""" hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` cont...
@@ -856,3 +875,49 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.5
suggestion
178
40
47
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: [`Hermitian`](@ref) view. For real matrices, the latter is equivalent to a [`Symmetric`](@ref) view. See also [`hermitianpart!`](@ref) for the corresponding in-place...
since `hermitianpart` returns `Hermitian`, this doesn't seem quite right for the `real` function — if `A` is an array of matrices, it will make the resulting array heterogeneous.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return Hermitian(retmat) else retmat = (F.vectors * Diagonal(($func).(complex(F.values)))) * F.vectors' return retmat end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, d...
Seems to me we'd probably want `typeof(hermitianpart(x)) == eltype(hermitianpart([x;;]))` for `x::Number`.
F = eigen(A) λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func).(max.(0, F.values)))) * F.vectors' for i = 1:n retmat[i,i] = real(retmat[i,i]) ...
@@ -856,3 +875,49 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.643
suggestion
106
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
ararslan
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: return Hermitian(retmat) else retmat = (F.vectors * Diagonal(($func).(complex(F.values)))) * F.vectors' re...
Seems to me we'd probably want `typeof(hermitianpart(x)) == eltype(hermitianpart([x;;]))` for `x::Number`.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
hermitianpart!(A, uplo=:U) -> Hermitian Overwrite the square matrix `A` with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](@ref). For real matrices `A`, this is also known as the symmetric part of `A`. See also [`hermitianpart`](@ref). !!! compat "Julia 1.10" This function requires Jul...
This function is only used in one place with one set of functions as input so perhaps it's not needed and can just be the body of the `hermitianpart!(::AbstractMatrix)` method. ```suggestion function hermitianpart!(A::AbstractMatrix, uplo::Symbol=:U) require_one_based_indexing(A) n = checksquare(A) @...
This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) = Hermitian(_hermitianpart(A), uplo) """ hermitianpart!(A, uplo=:U) -> Hermitian Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](@ref). For real ...
@@ -856,3 +875,49 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.857
refactor
707
27
34
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
ararslan
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: hermitianpart!(A, uplo=:U) -> Hermitian Overwrite the square matrix `A` with its Hermitian part `(A + A') / 2`, and return [`Hermitian(A, uplo)`](@ref). For real...
This function is only used in one place with one set of functions as input so perhaps it's not needed and can just be the body of the `hermitianpart!(::AbstractMatrix)` method. ```suggestion function hermitianpart!(A::AbstractMatrix, uplo::Symbol=:U) require_one_based_indexing(A) n = checksquare(A) @...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
[`Symmetric`](@ref) view. See also [`hermitianpart!`](@ref) for the corresponding in-place operation. !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) = Hermitian(_hermitianpart(A), uplo) hermitianpart(a::Number) = _hermitianpart(a) """ ...
```suggestion _hermitianpart(a::Number) = real(a) ``` As far as I can tell there is no reason to do a conversion here.
""" hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` contr...
@@ -856,3 +875,50 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
suggestion
121
40
46
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: [`Symmetric`](@ref) view. See also [`hermitianpart!`](@ref) for the corresponding in-place operation. !!! compat "Julia 1.10" This function requires Julia 1.10 ...
```suggestion _hermitianpart(a::Number) = real(a) ``` As far as I can tell there is no reason to do a conversion here.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@testset "Addition/subtraction with SymTridiagonal" begin TR = SymTridiagonal(randn(Float64,5), randn(Float64,4)) TC = SymTridiagonal(randn(ComplexF64,5), randn(ComplexF64,4)) SR = Symmetric(randn(Float64,5,5)) SC = Symmetric(randn(ComplexF64,5,5)) HR = Hermitian(randn(Float64,5,5)) HC = Hermiti...
```suggestion @testset "hermitian part" begin ```
end let Ahrs = adjoint(Hermitian(Symmetric(rand(T, 3, 3)))), Acs = adjoint(Symmetric(rand(S, 3, 3))), Ahcs = adjoint(Hermitian(Symmetric(rand(S, 3, 3)))) @test Ahrs * Ahrs ≈ Ahrs * Matrix(Ahrs) @test Ahcs * Ahcs ≈ Matrix(Ahcs) * Matrix(Ahcs) @test Ahrs * Ahcs ≈ Ahrs * Ma...
@@ -776,4 +776,40 @@ end end end +@testset "symmetric and hermitian part" begin
stdlib/LinearAlgebra/test/symmetric.jl
26
Julia
0.571
suggestion
51
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/test/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: @testset "Addition/subtraction with SymTridiagonal" begin TR = SymTridiagonal(randn(Float64,5), randn(Float64,4)) TC = SymTridiagonal(randn(ComplexF64,5), ra...
```suggestion @testset "hermitian part" begin ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
See also [`hermitianpart!`](@ref) for the corresponding in-place operation. !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart(A::AbstractMatrix, uplo::Symbol=:U) = Hermitian(_hermitianpart(A), uplo) hermitianpart(a::Number) = _hermitianpart(a) """ hermitianpart!(A, uplo=:U)...
```suggestion function _hermitianpart!(A::AbstractMatrix) ``` Might be clearer here to explicitly put this in the signature.
Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls the corresponding argument of the [`Hermiti...
@@ -856,3 +875,50 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
refactor
127
38
44
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: See also [`hermitianpart!`](@ref) for the corresponding in-place operation. !!! compat "Julia 1.10" This function requires Julia 1.10 or later. """ hermitianpart...
```suggestion function _hermitianpart!(A::AbstractMatrix) ``` Might be clearer here to explicitly put this in the signature.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end function ($func)(A::Hermitian{T}; $(rtolarg...)) where {T<:Complex} n = checksquare(A) F = eigen(A) λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func)....
Add another common synonym: ```suggestion of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls the corresponding argument of the ```
λ₀ = $rtolval # treat λ ≥ λ₀ as "zero" eigenvalues up to roundoff if all(λ -> λ ≥ λ₀, F.values) retmat = (F.vectors * Diagonal(($func).(max.(0, F.values)))) * F.vectors' else retmat = (F.vectors * Diagonal(($func).(complex.(F.values)))) * F.vectors' ...
@@ -856,3 +875,50 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
suggestion
182
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: end function ($func)(A::Hermitian{T}; $(rtolarg...)) where {T<:Complex} n = checksquare(A) F = eigen(A) λ₀ = $rto...
Add another common synonym: ```suggestion of `A`; it is also sometimes called the "operator real part". The optional argument `uplo` controls the corresponding argument of the ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`. The optional argument `uplo` controls the corresponding argument of the [`Hermitian`](@...
```suggestion See also [`hermitianpart`](@ref) for the corresponding out-of-place operation. ```
else retmat = (F.vectors * Diagonal(($func).(complex(F.values)))) * F.vectors' return retmat end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitia...
@@ -856,3 +875,50 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.571
suggestion
98
48
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For r...
```suggestion See also [`hermitianpart`](@ref) for the corresponding out-of-place operation. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a [`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part of `A`. The optional argument `uplo` controls the corre...
```suggestion Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return ```
for i = 1:n retmat[i,i] = real(retmat[i,i]) end return Hermitian(retmat) else retmat = (F.vectors * Diagonal(($func).(complex(F.values)))) * F.vectors' return retmat end end end end "...
@@ -856,3 +875,50 @@ for func in (:log, :sqrt) end end end + +""" + hermitianpart(A, uplo=:U) -> Hermitian + +Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`, as a +[`Hermitian`](@ref) matrix. For real matrices `A`, this is also known as the symmetric part +of `A`. The op...
stdlib/LinearAlgebra/src/symmetric.jl
26
Julia
0.714
suggestion
111
51
51
false
Add matrix symmetrizing functions
31,836
JuliaLang/julia
35,573
Julia
stevengj
ararslan
Review this pull request change. Language: Julia File: stdlib/LinearAlgebra/src/symmetric.jl PR Title: Add matrix symmetrizing functions BEFORE CODE: end end end end """ hermitianpart(A, uplo=:U) -> Hermitian Return the Hermitian part of the square matrix `A`, defined as `(A + A') / 2`...
```suggestion Overwrite the square matrix `A` in-place with its Hermitian part `(A + A') / 2`, and return ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end print_joined_cols(args...; cols = displaysize(stdout)[2]) = print_joined_cols(stdout, args...; cols=cols) function print_correction(io, word) cors = levsort(word, accessible(Main)) pre = "Perhaps you meant " print(io, pre) print_joined_cols(io, cors, ", ", " or "; cols = displaysize(io)[2] - lengt...
```suggestion Symbol[filter!(s -> !Base.isdeprecated(mod, s), names(mod, all = true, imported = true)); map(names, moduleusings(mod))...; collect(keys(Base.Docs.keywords))] |> unique |> filtervalid ```
end print_joined_cols(args...; cols = displaysize(stdout)[2]) = print_joined_cols(stdout, args...; cols=cols) function print_correction(io, word) cors = levsort(word, accessible(Main)) pre = "Perhaps you meant " print(io, pre) print_joined_cols(io, cors, ", ", " or "; cols = displaysize(io)[2] - lengt...
@@ -609,7 +609,7 @@ filtervalid(names) = filter(x->!occursin(r"#", x), map(string, names)) accessible(mod::Module) = [filter!(s -> !Base.isdeprecated(mod, s), names(mod, all = true, imported = true)); map(names, moduleusings(mod))...; - collect(keys(Base.Docs.keywords))] |> unique |> filtervalid + c...
stdlib/REPL/src/docview.jl
26
Julia
0.786
suggestion
221
51
51
false
More invalidation fixes
35,928
JuliaLang/julia
35,573
Julia
vtjnash
timholy
Review this pull request change. Language: Julia File: stdlib/REPL/src/docview.jl PR Title: More invalidation fixes BEFORE CODE: end print_joined_cols(args...; cols = displaysize(stdout)[2]) = print_joined_cols(stdout, args...; cols=cols) function print_correction(io, word) cors = levsort(word, accessible(Mai...
```suggestion Symbol[filter!(s -> !Base.isdeprecated(mod, s), names(mod, all = true, imported = true)); map(names, moduleusings(mod))...; collect(keys(Base.Docs.keywords))] |> unique |> filtervalid ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return v end # t[k1,k2,ks...] is syntactic sugar for t[(k1,k2,ks...)]. (Note # that we need to avoid dispatch loops if setindex!(t,v,k) is not defined.) getindex(t::AbstractDict, k1, k2, ks...) = getindex(t, tuple(k1,k2,ks...)) setindex!(t::AbstractDict, v, k1, k2, ks...) = setindex!(t, v, tuple(k1,k2,ks...)) ge...
I'm sure this is true in practice but it doesn't seem strictly correct to assert it. We don't know what `x` is.
return v end # t[k1,k2,ks...] is syntactic sugar for t[(k1,k2,ks...)]. (Note # that we need to avoid dispatch loops if setindex!(t,v,k) is not defined.) getindex(t::AbstractDict, k1, k2, ks...) = getindex(t, tuple(k1,k2,ks...)) setindex!(t::AbstractDict, v, k1, k2, ks...) = setindex!(t, v, tuple(k1,k2,ks...)) ge...
@@ -516,7 +516,7 @@ convert(::Type{T}, x::T) where {T<:AbstractDict} = x function convert(::Type{T}, x::AbstractDict) where T<:AbstractDict h = T(x) - if length(h) != length(x) + if length(h)::Int != length(x)::Int
base/abstractdict.jl
26
Julia
0.5
suggestion
111
51
51
false
More invalidation fixes
35,928
JuliaLang/julia
35,573
Julia
JeffBezanson
timholy
Review this pull request change. Language: Julia File: base/abstractdict.jl PR Title: More invalidation fixes BEFORE CODE: return v end # t[k1,k2,ks...] is syntactic sugar for t[(k1,k2,ks...)]. (Note # that we need to avoid dispatch loops if setindex!(t,v,k) is not defined.) getindex(t::AbstractDict, k1, k2, ...
I'm sure this is true in practice but it doesn't seem strictly correct to assert it. We don't know what `x` is.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# it must come after printing the summary, which can exploit :typeinfo itself # (e.g. views) # we assume this function is always called from top-level, i.e. that it's not nested # within another "show" method; hence we always print the summary, without # checking for current :typeinfo (this could be...
I would be surprised if this is really better --- this way it will have to do `convert(Bool, ::Any)` instead of just asserting the type.
# it must come after printing the summary, which can exploit :typeinfo itself # (e.g. views) # we assume this function is always called from top-level, i.e. that it's not nested # within another "show" method; hence we always print the summary, without # checking for current :typeinfo (this could be...
@@ -371,7 +371,7 @@ preceded by `prefix`, supposed to encode the type of the elements. """ function _show_nonempty(io::IO, X::AbstractMatrix, prefix::String) @assert !isempty(X) - limit = get(io, :limit, false)::Bool + limit::Bool = get(io, :limit, false)
base/arrayshow.jl
26
Julia
0.714
suggestion
136
51
51
false
More invalidation fixes
35,928
JuliaLang/julia
35,573
Julia
JeffBezanson
timholy
Review this pull request change. Language: Julia File: base/arrayshow.jl PR Title: More invalidation fixes BEFORE CODE: # it must come after printing the summary, which can exploit :typeinfo itself # (e.g. views) # we assume this function is always called from top-level, i.e. that it's not nested # ...
I would be surprised if this is really better --- this way it will have to do `convert(Bool, ::Any)` instead of just asserting the type.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
poplinenum(arg) = arg function poplinenum(ex::Expr) if ex.head === :block if length(ex.args) == 1 return ex.args[1] elseif length(ex.args) == 2 && isa(ex.args[1], LineNumberNode) return ex.args[2] elseif (length(ex.args) == 2 && isa(ex.args[1], Expr) && ex.args[1].hea...
```suggestion if haskey(exprresolve_arith_dict, callee) && all(Bool[isa(ex.args[i], Number) for i = 2:length(ex.args)]) ```
poplinenum(arg) = arg function poplinenum(ex::Expr) if ex.head === :block if length(ex.args) == 1 return ex.args[1] elseif length(ex.args) == 2 && isa(ex.args[1], LineNumberNode) return ex.args[2] elseif (length(ex.args) == 2 && isa(ex.args[1], Expr) && ex.args[1].hea...
@@ -353,17 +353,27 @@ const exprresolve_cond_dict = Dict{Symbol,Function}(:(==) => ==, :(<) => <, :(>) => >, :(<=) => <=, :(>=) => >=) function exprresolve_arith(ex::Expr) - if ex.head === :call && haskey(exprresolve_arith_dict, ex.args[1]) && all([isa(ex.args[i], Number) for i = 2:length(ex.args)]) - ...
base/cartesian.jl
26
Julia
0.714
suggestion
137
51
51
false
Fix more invalidations from overloading `==`
36,282
JuliaLang/julia
35,573
Julia
JeffBezanson
timholy
Review this pull request change. Language: Julia File: base/cartesian.jl PR Title: Fix more invalidations from overloading `==` BEFORE CODE: poplinenum(arg) = arg function poplinenum(ex::Expr) if ex.head === :block if length(ex.args) == 1 return ex.args[1] elseif length(ex.args) == 2...
```suggestion if haskey(exprresolve_arith_dict, callee) && all(Bool[isa(ex.args[i], Number) for i = 2:length(ex.args)]) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
if inc_tag === :string && length(paths) == 1 && # Only close if there's a single choice, !isdir(expanduser(replace(string[startpos:prevind(string, first(r))] * paths[1].path, r"\\ " => " "))) && # except if it's a directory (lastindex(strin...
```suggestion if ex.head === :call ```
if inc_tag === :string && length(paths) == 1 && # Only close if there's a single choice, !isdir(expanduser(replace(string[startpos:prevind(string, first(r))] * paths[1].path, r"\\ " => " "))) && # except if it's a directory (lastindex(strin...
@@ -626,7 +628,7 @@ function completions(string, pos, context_module=Main)::Completions if isa(ex, Expr) if ex.head==:call
stdlib/REPL/src/REPLCompletions.jl
26
Julia
0.571
suggestion
52
51
51
false
Fix more invalidations from overloading `==`
36,282
JuliaLang/julia
35,573
Julia
JeffBezanson
timholy
Review this pull request change. Language: Julia File: stdlib/REPL/src/REPLCompletions.jl PR Title: Fix more invalidations from overloading `==` BEFORE CODE: if inc_tag === :string && length(paths) == 1 && # Only close if there's a single choice, !isdir(expanduser(replace(string[start...
```suggestion if ex.head === :call ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
!isdir(expanduser(replace(string[startpos:prevind(string, first(r))] * paths[1].path, r"\\ " => " "))) && # except if it's a directory (lastindex(string) <= pos || string[nextind(string,pos)] != '"') # or there's already a " at the cursor. ...
```suggestion elseif ex.head === :. && ex.args[2] isa Expr && (ex.args[2]::Expr).head === :tuple ```
!isdir(expanduser(replace(string[startpos:prevind(string, first(r))] * paths[1].path, r"\\ " => " "))) && # except if it's a directory (lastindex(string) <= pos || string[nextind(string,pos)] != '"') # or there's already a " at the cursor. ...
@@ -626,7 +628,7 @@ function completions(string, pos, context_module=Main)::Completions if isa(ex, Expr) if ex.head==:call return complete_methods(ex, context_module), first(frange):method_name_end, false - elseif ex.head==:. && ex.args[2] isa Expr && ex.args[2].head==:...
stdlib/REPL/src/REPLCompletions.jl
26
Julia
0.714
suggestion
114
51
51
false
Fix more invalidations from overloading `==`
36,282
JuliaLang/julia
35,573
Julia
JeffBezanson
timholy
Review this pull request change. Language: Julia File: stdlib/REPL/src/REPLCompletions.jl PR Title: Fix more invalidations from overloading `==` BEFORE CODE: !isdir(expanduser(replace(string[startpos:prevind(string, first(r))] * paths[1].path, r"\\ " => " "))) && # e...
```suggestion elseif ex.head === :. && ex.args[2] isa Expr && (ex.args[2]::Expr).head === :tuple ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# Examples ```jldoctest julia> ndigits(12345) 5 julia> ndigits(1022, base=16) 3 julia> string(1022, base=16) "3fe" julia> ndigits(123, pad=5) 5 ``` """ ndigits(x::Integer; base::Integer=10, pad::Integer=1) = max(pad, ndigits0z(x, base)) ## integer to string functions ## function bin(x::Unsigned, pad::Integer, neg...
```suggestion @inbounds a[i] = 0x30 + ((x % UInt8)::UInt8 & 0x1) x >>= 0x1 ``` I think this may clarify the intent. As mentioned above, `(pad % Int)::Int` may be safer.
# Examples ```jldoctest julia> ndigits(12345) 5 julia> ndigits(1022, base=16) 3 julia> string(1022, base=16) "3fe" julia> ndigits(123, pad=5) 5 ``` """ ndigits(x::Integer; base::Integer=10, pad::Integer=1) = max(pad, ndigits0z(x, base)) ## integer to string functions ## function bin(x::Unsigned, pad::Integer, neg...
@@ -605,8 +605,8 @@ function bin(x::Unsigned, pad::Integer, neg::Bool) i = neg + max(pad,sizeof(x)<<3-leading_zeros(x)) a = StringVector(i) while i > neg - @inbounds a[i] = 48+(x&0x1) - x >>= 1 + @inbounds a[i] = (0x30+(x&0x1)::Unsigned)::Unsigned + x = (x >> 1)::Unsigned
base/intfuncs.jl
26
Julia
0.714
suggestion
188
51
51
false
Fix invalidations from novel Integer conversions
36,459
JuliaLang/julia
35,573
Julia
kimikage
timholy
Review this pull request change. Language: Julia File: base/intfuncs.jl PR Title: Fix invalidations from novel Integer conversions BEFORE CODE: # Examples ```jldoctest julia> ndigits(12345) 5 julia> ndigits(1022, base=16) 3 julia> string(1022, base=16) "3fe" julia> ndigits(123, pad=5) 5 ``` """ ndigits(x::Integ...
```suggestion @inbounds a[i] = 0x30 + ((x % UInt8)::UInt8 & 0x1) x >>= 0x1 ``` I think this may clarify the intent. As mentioned above, `(pad % Int)::Int` may be safer.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
elseif rx < oftype(rx,135) y = deg2rad_ext(oftype(rx,90) - rx) return sin_kernel(y) elseif rx <= oftype(rx,225) y = deg2rad_ext(oftype(rx,180) - rx) return -cos_kernel(y) elseif rx < oftype(rx,315) y = deg2rad_ext(rx - oftype(rx,270)) return sin_kernel(y) ...
```suggestion sincosd(x) = (sind(x), cosd(x)) # It turns out that calling these functions separately yields better # performance than considering each case and calling `sincos_kernel`. function deleteremainder() ``` I think that removing the constraint isn't quite enough, since the checks in the function are ...
elseif rx < oftype(rx,135) y = deg2rad_ext(oftype(rx,90) - rx) return sin_kernel(y) elseif rx <= oftype(rx,225) y = deg2rad_ext(oftype(rx,180) - rx) return -cos_kernel(y) elseif rx < oftype(rx,315) y = deg2rad_ext(rx - oftype(rx,270)) return sin_kernel(y) ...
@@ -1254,7 +1254,7 @@ Simultaneously compute the sine and cosine of `x`, where `x` is in degrees. !!! compat "Julia 1.3" This function requires at least Julia 1.3. """ -function sincosd(x::Real) +function sincosd(x)
base/special/trig.jl
26
Julia
1
performance
367
51
51
false
Remove the type constraint on `sincosd`
41,021
JuliaLang/julia
35,573
Julia
vtjnash
singularitti
Review this pull request change. Language: Julia File: base/special/trig.jl PR Title: Remove the type constraint on `sincosd` BEFORE CODE: elseif rx < oftype(rx,135) y = deg2rad_ext(oftype(rx,90) - rx) return sin_kernel(y) elseif rx <= oftype(rx,225) y = deg2rad_ext(oftype(rx,180) - ...
```suggestion sincosd(x) = (sind(x), cosd(x)) # It turns out that calling these functions separately yields better # performance than considering each case and calling `sincos_kernel`. function deleteremainder() ``` I think that removing the constraint isn't quite enough, since the checks in the function are ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
y = deg2rad_ext(oftype(rx,180) - rx) return -cos_kernel(y) elseif rx < oftype(rx,315) y = deg2rad_ext(rx - oftype(rx,270)) return sin_kernel(y) else y = deg2rad_ext(oftype(rx,360) - rx) return cos_kernel(y) end end tand(x::Real) = sind(x) / cosd(x) """ s...
This `deleteremainder` function makes no sense.
y = deg2rad_ext(oftype(rx,180) - rx) return -cos_kernel(y) elseif rx < oftype(rx,315) y = deg2rad_ext(rx - oftype(rx,270)) return sin_kernel(y) else y = deg2rad_ext(oftype(rx,360) - rx) return cos_kernel(y) end end tand(x::Real) = sind(x) / cosd(x) """ s...
@@ -1254,7 +1254,11 @@ Simultaneously compute the sine and cosine of `x`, where `x` is in degrees. !!! compat "Julia 1.3" This function requires at least Julia 1.3. """ -function sincosd(x::Real) +sincosd(x::Number) = (sind(x), cosd(x)) +# It turns out that calling these functions separately yields better +# per...
base/special/trig.jl
26
Julia
0.214
suggestion
47
51
51
false
Remove the type constraint on `sincosd`
41,021
JuliaLang/julia
35,573
Julia
stevengj
singularitti
Review this pull request change. Language: Julia File: base/special/trig.jl PR Title: Remove the type constraint on `sincosd` BEFORE CODE: y = deg2rad_ext(oftype(rx,180) - rx) return -cos_kernel(y) elseif rx < oftype(rx,315) y = deg2rad_ext(rx - oftype(rx,270)) return sin_kernel(...
This `deleteremainder` function makes no sense.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
elseif rx < oftype(rx,135) y = deg2rad_ext(oftype(rx,90) - rx) return sin_kernel(y) elseif rx <= oftype(rx,225) y = deg2rad_ext(oftype(rx,180) - rx) return -cos_kernel(y) elseif rx < oftype(rx,315) y = deg2rad_ext(rx - oftype(rx,270)) return sin_kernel(y) ...
```suggestion sincosd(x) = (sind(x), cosd(x)) ```
elseif rx < oftype(rx,135) y = deg2rad_ext(oftype(rx,90) - rx) return sin_kernel(y) elseif rx <= oftype(rx,225) y = deg2rad_ext(oftype(rx,180) - rx) return -cos_kernel(y) elseif rx < oftype(rx,315) y = deg2rad_ext(rx - oftype(rx,270)) return sin_kernel(y) ...
@@ -1254,7 +1254,11 @@ Simultaneously compute the sine and cosine of `x`, where `x` is in degrees. !!! compat "Julia 1.3" This function requires at least Julia 1.3. """ -function sincosd(x::Real) +sincosd(x::Number) = (sind(x), cosd(x))
base/special/trig.jl
26
Julia
0.571
suggestion
51
51
51
false
Remove the type constraint on `sincosd`
41,021
JuliaLang/julia
35,573
Julia
stevengj
singularitti
Review this pull request change. Language: Julia File: base/special/trig.jl PR Title: Remove the type constraint on `sincosd` BEFORE CODE: elseif rx < oftype(rx,135) y = deg2rad_ext(oftype(rx,90) - rx) return sin_kernel(y) elseif rx <= oftype(rx,225) y = deg2rad_ext(oftype(rx,180) - ...
```suggestion sincosd(x) = (sind(x), cosd(x)) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
as well as many great tutorials and learning resources: https://julialang.org/learning/ For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. """ kw"help", kw"Julia", kw"julia", kw"" """ usi...
```suggestion !!! note If two packages export the same name and are both loaded with `using`, and the name is referenced, an error will be thrown, as Julia can't know which source of the name was intended. To mitigate this, you may prefer to explicitly list which names you want to use from a packag...
as well as many great tutorials and learning resources: https://julialang.org/learning/ For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. To exit the interactive session, type `CTRL-D` (pre...
@@ -33,6 +33,15 @@ kw"help", kw"Julia", kw"julia", kw"" available for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access the name `foo`), whether they are `export`ed or not. See the [manual section about modules](@ref modules) for details. + +!!! note + Doing `using Foo` in packages or co...
base/docs/basedocs.jl
26
Julia
1
suggestion
689
51
51
false
recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful")
42,080
JuliaLang/julia
35,573
Julia
ararslan
KristofferC
Review this pull request change. Language: Julia File: base/docs/basedocs.jl PR Title: recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful") BEFORE CODE: as well as many great tutorials and learning resources: https://julialang.org/learning/ For help on a specific function...
```suggestion !!! note If two packages export the same name and are both loaded with `using`, and the name is referenced, an error will be thrown, as Julia can't know which source of the name was intended. To mitigate this, you may prefer to explicitly list which names you want to use from a packag...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. To exit the interactive session, type `CTRL-D` (press the control key together with the `d` key), or type `exit()`. """ kw"help", kw"Julia", kw"j...
Typo fix and slight reword: ```suggestion `using Foo: Foo, parsefile, readfile` makes three specific names available; two functions can be used directly along with the module name itself, which can be used to access other public functionality in the module like `Foo.foo`. ```
For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. To exit the interactive session, type `CTRL-D` (press the control key together with the `d` key), or type `exit()`. """ kw"help", kw"Julia", kw"j...
@@ -37,6 +37,15 @@ kw"help", kw"Julia", kw"julia", kw"" available for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access the name `foo`), whether they are `export`ed or not. See the [manual section about modules](@ref modules) for details. + +!!! note + Doing `using Foo` in packages or co...
base/docs/basedocs.jl
26
Julia
0.857
suggestion
295
51
51
false
recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful")
42,080
JuliaLang/julia
35,573
Julia
mbauman
KristofferC
Review this pull request change. Language: Julia File: base/docs/basedocs.jl PR Title: recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful") BEFORE CODE: For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;`...
Typo fix and slight reword: ```suggestion `using Foo: Foo, parsefile, readfile` makes three specific names available; two functions can be used directly along with the module name itself, which can be used to access other public functionality in the module like `Foo.foo`. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. To exit the interactive session, type `CTRL-D` (press the control key together with the `d` key), or type `exit()`. """ kw"help", kw"Julia", kw"j...
Let's unify some of the language from https://github.com/JuliaLang/julia/pull/53428 into the docstring (albeit more tersely): ```suggestion !!! note Qualifying the names being used as in `using Foo: Foo, f` is recommended over plain `using Foo` for released packages and other code which is meant to b...
For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. To exit the interactive session, type `CTRL-D` (press the control key together with the `d` key), or type `exit()`. """ kw"help", kw"Julia", kw"j...
@@ -37,6 +37,15 @@ kw"help", kw"Julia", kw"julia", kw"" available for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access the name `foo`), whether they are `export`ed or not. See the [manual section about modules](@ref modules) for details. + +!!! note + Doing `using Foo` in packages or co...
base/docs/basedocs.jl
26
Julia
1
suggestion
714
51
51
false
recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful")
42,080
JuliaLang/julia
35,573
Julia
mbauman
KristofferC
Review this pull request change. Language: Julia File: base/docs/basedocs.jl PR Title: recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful") BEFORE CODE: For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;`...
Let's unify some of the language from https://github.com/JuliaLang/julia/pull/53428 into the docstring (albeit more tersely): ```suggestion !!! note Qualifying the names being used as in `using Foo: Foo, f` is recommended over plain `using Foo` for released packages and other code which is meant to b...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. To exit the interactive session, type `CTRL-D` (press the control key together with the `d` key), or type `exit()`. """ kw"help", kw"Julia", kw"j...
This suggestion is my attempt at retaining the same contents while simplifying a bit, beginning with the motivator for the recommendation, and including a couple additional pieces of information: a conflict can arise between more than two modules at a time, and there is no conflict if the binding is actually the same i...
For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;` to enter shell mode, `]` to enter package mode. To exit the interactive session, type `CTRL-D` (press the control key together with the `d` key), or type `exit()`. """ kw"help", kw"Julia", kw"j...
@@ -37,6 +37,15 @@ kw"help", kw"Julia", kw"julia", kw"" available for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access the name `foo`), whether they are `export`ed or not. See the [manual section about modules](@ref modules) for details. + +!!! note + Qualifying the names being used as ...
base/docs/basedocs.jl
26
Julia
1
refactor
909
51
51
false
recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful")
42,080
JuliaLang/julia
35,573
Julia
ararslan
KristofferC
Review this pull request change. Language: Julia File: base/docs/basedocs.jl PR Title: recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful") BEFORE CODE: For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or `?@time`, and press enter. Type `;`...
This suggestion is my attempt at retaining the same contents while simplifying a bit, beginning with the motivator for the recommendation, and including a couple additional pieces of information: a conflict can arise between more than two modules at a time, and there is no conflict if the binding is actually the same i...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
ERROR: type should be string, got " https://julialang.org/learning/\n\nFor help on a specific function or macro, type `?` followed\nby its name, e.g. `?cos`, or `?@time`, and press enter.\nType `;` to enter shell mode, `]` to enter package mode.\n\nTo exit the interactive session, type `CTRL-D` (press the\ncontrol key together with the `d` key), or type `exit()`.\n\"\"\"\nkw\"help\", kw\"Julia\", kw\"julia\", kw\"\"\n\n\"\"\"\n using\n\n`using Foo` will load the module or package `Foo` and make its [`export`](@ref)ed names\navailable for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access\nthe name `foo`), whether they are `export`ed or not.\nSee the [manual section about modules](@ref modules) for details.\n\n!!! note\n When two or more packages/modules export a name and that name does not refer to the\n same thing in each of the packages, and the packages are loaded via `using` without\n an explicit list of names, it is an error to reference that name without qualification.\n It is thus recommended that code intended to be forward-compatible with future versions\n of its dependencies and of Julia, e.g. code in released packages, list the names it\n uses from each loaded package, e.g. `using Foo: Foo, f` rather than `using Foo`.\n\"\"\"\nkw\"using\"\n\n\"\"\"\n import\n\n`import Foo` will load the module or package `Foo`.\nNames from the imported `Foo` module can be accessed with dot syntax\n(e.g. `Foo.foo` to access the name `foo`).\nSee the [manual section about modules](@ref modules) for details.\n\"\"\"\nkw\"import\"\n\n\"\"\"\n export\n\n`export` is used within modules to tell Julia which names should be\nmade available to the user. For example: `export foo` makes the name\n`foo` available when [`using`](@ref) the module.\nSee the [manual section about modules](@ref modules) for details.\n\"\"\"\nkw\"export\"\n\n\"\"\"\n public"
```suggestion of its dependencies and of Julia, e.g., code in released packages, list the names it uses from each loaded package, e.g., `using Foo: Foo, f` rather than `using Foo`. ``` I think this style is usually preferred.
ERROR: type should be string, got " https://julialang.org/learning/\n\nFor help on a specific function or macro, type `?` followed\nby its name, e.g. `?cos`, or `?@time`, and press enter.\nType `;` to enter shell mode, `]` to enter package mode.\n\nTo exit the interactive session, type `CTRL-D` (press the\ncontrol key together with the `d` key), or type `exit()`.\n\"\"\"\nkw\"help\", kw\"Julia\", kw\"julia\", kw\"\"\n\n\"\"\"\n using\n\n`using Foo` will load the module or package `Foo` and make its [`export`](@ref)ed names\navailable for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access\nthe name `foo`), whether they are `export`ed or not.\nSee the [manual section about modules](@ref modules) for details.\n\n!!! note\n When two or more packages/modules export a name and that name does not refer to the\n same thing in each of the packages, and the packages are loaded via `using` without\n an explicit list of names, it is an error to reference that name without qualification.\n It is thus recommended that code intended to be forward-compatible with future versions\n of its dependencies and of Julia, e.g., code in released packages, list the names it\n uses from each loaded package, e.g., `using Foo: Foo, f` rather than `using Foo`.\n\"\"\"\nkw\"using\"\n\n\"\"\"\n import\n\n`import Foo` will load the module or package `Foo`.\nNames from the imported `Foo` module can be accessed with dot syntax\n(e.g. `Foo.foo` to access the name `foo`).\nSee the [manual section about modules](@ref modules) for details.\n\"\"\"\nkw\"import\"\n\n\"\"\"\n export\n\n`export` is used within modules to tell Julia which names should be\nmade available to the user. For example: `export foo` makes the name\n`foo` available when [`using`](@ref) the module.\nSee the [manual section about modules](@ref modules) for details.\n\"\"\"\nkw\"export\"\n\n\"\"\"\n public"
@@ -37,6 +37,14 @@ kw"help", kw"Julia", kw"julia", kw"" available for direct use. Names can also be used via dot syntax (e.g. `Foo.foo` to access the name `foo`), whether they are `export`ed or not. See the [manual section about modules](@ref modules) for details. + +!!! note + When two or more packages/modules e...
base/docs/basedocs.jl
26
Julia
0.857
suggestion
239
51
51
false
recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful")
42,080
JuliaLang/julia
35,573
Julia
nsajko
KristofferC
Review this pull request change. Language: Julia File: base/docs/basedocs.jl PR Title: recommend explicit `using Foo: Foo, ...` in package code (was: "using considered harmful") BEFORE CODE: https://julialang.org/learning/ For help on a specific function or macro, type `?` followed by its name, e.g. `?cos`, or...
```suggestion of its dependencies and of Julia, e.g., code in released packages, list the names it uses from each loaded package, e.g., `using Foo: Foo, f` rather than `using Foo`. ``` I think this style is usually preferred.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
// if the freelist is empty we reuse empty but not freed pages v = p->newpages; jl_taggedvalue_t *next = (jl_taggedvalue_t*)((char*)v + osize); // If there's no pages left or the current page is used up, // we need to use the slow path. char *cur_page = gc_page_data((char*)v - 1); if (__unli...
```suggestion // Instrumented version of jl_gc_pool_alloc_inner, called into by LLVM-generated code. ```
// if the freelist is empty we reuse empty but not freed pages v = p->newpages; jl_taggedvalue_t *next = (jl_taggedvalue_t*)((char*)v + osize); // If there's no pages left or the current page is used up, // we need to use the slow path. char *cur_page = gc_page_data((char*)v - 1); if (__unli...
@@ -1253,6 +1253,23 @@ JL_DLLEXPORT jl_value_t *jl_gc_pool_alloc(jl_ptls_t ptls, int pool_offset, return jl_valueof(v); } +// instrumented version of jl_gc_pool_alloc_inner called into by LLVM-generated code
src/gc.c
26
C
0.714
suggestion
106
51
51
false
allocation profiler: get stacks for pool allocs via wrapper function
43,868
JuliaLang/julia
35,573
Julia
NHDaly
vilterp
Review this pull request change. Language: C File: src/gc.c PR Title: allocation profiler: get stacks for pool allocs via wrapper function BEFORE CODE: // if the freelist is empty we reuse empty but not freed pages v = p->newpages; jl_taggedvalue_t *next = (jl_taggedvalue_t*)((char*)v + osize); // I...
```suggestion // Instrumented version of jl_gc_pool_alloc_inner, called into by LLVM-generated code. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
BroadcastStyle(::Type{<:Broadcasted{S}}) where {S<:Union{Nothing,Unknown}} = throw(ArgumentError("Broadcasted{Unknown} wrappers do not have a style assigned")) argtype(::Type{Broadcasted{Style,Axes,F,Args}}) where {Style,Axes,F,Args} = Args argtype(bc::Broadcasted) = argtype(typeof(bc)) @inline Base.eachindex(bc:...
I'm not sure whether `Base.tuple_type_tail` here is acceptable @vtjnash. This does improve the inference result. I assume that `Base.tuple_type_tail` is correct if the input is concrete. (We can add a check if this is true)
similar(BitArray, dims) # In cases of conflict we fall back on Array Base.similar(::Broadcasted{ArrayConflict}, ::Type{ElType}, dims) where ElType = similar(Array{ElType, length(dims)}, dims) Base.similar(::Broadcasted{ArrayConflict}, ::Type{Bool}, dims) = similar(BitArray, dims) @inline Base.axes(bc::Broa...
@@ -246,6 +246,15 @@ Base.LinearIndices(bc::Broadcasted{<:Any,<:Tuple{Any}}) = LinearIndices(axes(bc) Base.ndims(bc::Broadcasted) = ndims(typeof(bc)) Base.ndims(::Type{<:Broadcasted{<:Any,<:NTuple{N,Any}}}) where {N} = N +Base.ndims(BC::Type{<:Broadcasted{<:Any,Nothing}}) = _maxndims(fieldtype(BC, 2)) +function Bas...
base/broadcast.jl
26
Julia
0.714
suggestion
225
51
51
false
Fix `ndims` for `Broadcasted` with no args
45,477
JuliaLang/julia
35,573
Julia
N5N3
N5N3
Review this pull request change. Language: Julia File: base/broadcast.jl PR Title: Fix `ndims` for `Broadcasted` with no args BEFORE CODE: BroadcastStyle(::Type{<:Broadcasted{S}}) where {S<:Union{Nothing,Unknown}} = throw(ArgumentError("Broadcasted{Unknown} wrappers do not have a style assigned")) argtype(::Ty...
I'm not sure whether `Base.tuple_type_tail` here is acceptable @vtjnash. This does improve the inference result. I assume that `Base.tuple_type_tail` is correct if the input is concrete. (We can add a check if this is true)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
argtype(::Type{Broadcasted{Style,Axes,F,Args}}) where {Style,Axes,F,Args} = Args argtype(bc::Broadcasted) = argtype(typeof(bc)) @inline Base.eachindex(bc::Broadcasted) = _eachindex(axes(bc)) _eachindex(t::Tuple{Any}) = t[1] _eachindex(t::Tuple) = CartesianIndices(t) Base.IndexStyle(bc::Broadcasted) = IndexStyle(typeo...
This seems like generally a somewhat worse model for what Types can be present than the `reduce` it replaces
similar(Array{ElType, length(dims)}, dims) Base.similar(::Broadcasted{ArrayConflict}, ::Type{Bool}, dims) = similar(BitArray, dims) @inline Base.axes(bc::Broadcasted) = _axes(bc, bc.axes) _axes(::Broadcasted, axes::Tuple) = axes @inline _axes(bc::Broadcasted, ::Nothing) = combine_axes(bc.args...) _axes(bc::Br...
@@ -246,6 +246,17 @@ Base.LinearIndices(bc::Broadcasted{<:Any,<:Tuple{Any}}) = LinearIndices(axes(bc) Base.ndims(bc::Broadcasted) = ndims(typeof(bc)) Base.ndims(::Type{<:Broadcasted{<:Any,<:NTuple{N,Any}}}) where {N} = N +Base.ndims(BC::Type{<:Broadcasted{<:Any,Nothing}}) = _maxndims(fieldtype(BC, 2)) +function Bas...
base/broadcast.jl
26
Julia
0.714
suggestion
108
51
51
false
Fix `ndims` for `Broadcasted` with no args
45,477
JuliaLang/julia
35,573
Julia
vtjnash
N5N3
Review this pull request change. Language: Julia File: base/broadcast.jl PR Title: Fix `ndims` for `Broadcasted` with no args BEFORE CODE: argtype(::Type{Broadcasted{Style,Axes,F,Args}}) where {Style,Axes,F,Args} = Args argtype(bc::Broadcasted) = argtype(typeof(bc)) @inline Base.eachindex(bc::Broadcasted) = _eachi...
This seems like generally a somewhat worse model for what Types can be present than the `reduce` it replaces
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
a1 = AD1(rand(2,3)) bc1 = Broadcast.broadcasted(*, a1, 2) @test collect(Iterators.product(bc1, bc1)) == collect(Iterators.product(copy(bc1), copy(bc1))) # using ndims of second arg bc2 = Broadcast.broadcasted(*, 2, a1) @test collect(Iterators.product(bc2, bc2)) == collect(Iterators.product(cop...
```suggestion @test @inferred(Base.IteratorSize(convert(Broadcast.Broadcasted{Nothing}, Base.broadcasted(randn)))) === Base.HasShape{0}() ```
a1 = AD1(rand(2,3)) bc1 = Broadcast.broadcasted(*, a1, 2) @test collect(Iterators.product(bc1, bc1)) == collect(Iterators.product(copy(bc1), copy(bc1))) # using ndims of second arg bc2 = Broadcast.broadcasted(*, 2, a1) @test collect(Iterators.product(bc2, bc2)) == collect(Iterators.product(cop...
@@ -938,11 +938,14 @@ let @test @inferred(Base.IteratorSize(Base.broadcasted(randn))) === Base.HasShape{0}() + @test @inferred(Base.IteratorSize(Base.broadcasted(randn))) === Base.HasShape{0}()
test/broadcast.jl
26
Julia
0.857
suggestion
147
51
51
false
Fix `ndims` for `Broadcasted` with no args
45,477
JuliaLang/julia
35,573
Julia
N5N3
N5N3
Review this pull request change. Language: Julia File: test/broadcast.jl PR Title: Fix `ndims` for `Broadcasted` with no args BEFORE CODE: a1 = AD1(rand(2,3)) bc1 = Broadcast.broadcasted(*, a1, 2) @test collect(Iterators.product(bc1, bc1)) == collect(Iterators.product(copy(bc1), copy(bc1))) # usin...
```suggestion @test @inferred(Base.IteratorSize(convert(Broadcast.Broadcasted{Nothing}, Base.broadcasted(randn)))) === Base.HasShape{0}() ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## function iterate(@nospecialize(t::Tuple), i::Int=1) @inline return (1 <= i <= length(t)) ? (@inbounds t[i], i + 1) : nothing end keys(@nospecialize t:...
```suggestion all(==(lent), t2) || throw_eachindex_mismatch_indices((), t, t2...) ```
@boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}())::NTuple{N, Any} end ## iterating ## function iterate(@nospecialize(t::T...
@@ -73,14 +73,15 @@ keys(@nospecialize t::Tuple) = OneTo(length(t)) prevind(@nospecialize(t::Tuple), i::Integer) = Int(i)-1 nextind(@nospecialize(t::Tuple), i::Integer) = Int(i)+1 -function keys(t::Tuple, t2::Tuple...) - @inline - OneTo(_maxlength(t, t2...)) +@noinline function throw_eachindex_mismatch_indice...
base/tuple.jl
26
Julia
0.571
suggestion
91
51
51
false
Require all tuples in eachindex to have the same length.
48,125
JuliaLang/julia
35,573
Julia
Moelf
navdeeprana
Review this pull request change. Language: Julia File: base/tuple.jl PR Title: Require all tuples in eachindex to have the same length. BEFORE CODE: function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## functi...
```suggestion all(==(lent), t2) || throw_eachindex_mismatch_indices((), t, t2...) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## function iterate(@nospecialize(t::Tuple), i::Int=1) @inline return (1 <= i <= length(t)) ? (@inbounds t[i], i + 1) : nothing end keys(@nospecialize t:...
This does not look correct: It has to compare to the lengths of the tuples in `t2`. Maybe also add a test that verifies `eachindex((1,), (1,))` does *not* throw dimension mismatch?
@boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}())::NTuple{N, Any} end ## iterating ## function iterate(@nospecialize(t::T...
@@ -73,14 +73,15 @@ keys(@nospecialize t::Tuple) = OneTo(length(t)) prevind(@nospecialize(t::Tuple), i::Integer) = Int(i)-1 nextind(@nospecialize(t::Tuple), i::Integer) = Int(i)+1 -function keys(t::Tuple, t2::Tuple...) - @inline - OneTo(_maxlength(t, t2...)) +@noinline function throw_eachindex_mismatch_indice...
base/tuple.jl
26
Julia
0.5
question
181
51
51
false
Require all tuples in eachindex to have the same length.
48,125
JuliaLang/julia
35,573
Julia
cafaxo
navdeeprana
Review this pull request change. Language: Julia File: base/tuple.jl PR Title: Require all tuples in eachindex to have the same length. BEFORE CODE: function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## functi...
This does not look correct: It has to compare to the lengths of the tuples in `t2`. Maybe also add a test that verifies `eachindex((1,), (1,))` does *not* throw dimension mismatch?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## function iterate(@nospecialize(t::Tuple), i::Int=1) @inline return (1 <= i <= length(t)) ? (@inbounds t[i], i + 1) : nothing end keys(@nospecialize t:...
```suggestion all(t -> length(t)==lent, t2) || throw_eachindex_mismatch_indices((), t, t2...) ```
@boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}())::NTuple{N, Any} end ## iterating ## function iterate(@nospecialize(t::T...
@@ -73,14 +73,15 @@ keys(@nospecialize t::Tuple) = OneTo(length(t)) prevind(@nospecialize(t::Tuple), i::Integer) = Int(i)-1 nextind(@nospecialize(t::Tuple), i::Integer) = Int(i)+1 -function keys(t::Tuple, t2::Tuple...) - @inline - OneTo(_maxlength(t, t2...)) +@noinline function throw_eachindex_mismatch_indice...
base/tuple.jl
26
Julia
0.714
suggestion
103
51
51
false
Require all tuples in eachindex to have the same length.
48,125
JuliaLang/julia
35,573
Julia
Moelf
navdeeprana
Review this pull request change. Language: Julia File: base/tuple.jl PR Title: Require all tuples in eachindex to have the same length. BEFORE CODE: function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## functi...
```suggestion all(t -> length(t)==lent, t2) || throw_eachindex_mismatch_indices((), t, t2...) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" function setindex(x::Tuple, v, i::Integer) @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## func...
what is the purpose of the first `::Tuple{}` parameter?
# Examples ```jldoctest julia> Base.setindex((1, 2, 6), 2, 3) == (1, 2, 2) true ``` """ function setindex(x::Tuple, v, i::Integer) @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline ...
@@ -73,14 +73,15 @@ keys(@nospecialize t::Tuple) = OneTo(length(t)) prevind(@nospecialize(t::Tuple), i::Integer) = Int(i)-1 nextind(@nospecialize(t::Tuple), i::Integer) = Int(i)+1 -function keys(t::Tuple, t2::Tuple...) - @inline - OneTo(_maxlength(t, t2...)) +@noinline function throw_eachindex_mismatch_indice...
base/tuple.jl
26
Julia
0.357
question
55
51
51
false
Require all tuples in eachindex to have the same length.
48,125
JuliaLang/julia
35,573
Julia
adienes
navdeeprana
Review this pull request change. Language: Julia File: base/tuple.jl PR Title: Require all tuples in eachindex to have the same length. BEFORE CODE: """ function setindex(x::Tuple, v, i::Integer) @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _se...
what is the purpose of the first `::Tuple{}` parameter?
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
function setindex(x::Tuple, v, i::Integer) @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntuple(j -> ifelse(j == i, v, args[j]), Val{N}()) end ## iterating ## function...
```suggestion function throw_eachindex_mismatch_indices(::Tuple{}, inds...) @noinline throw(DimensionMismatch("all inputs to eachindex must have the same length, got $(join(inds, ", ", " and "))")) ``` Looks like we have a bootstrapping problem: `tuple` is used very early in Core.Compiler and the full J...
```jldoctest julia> Base.setindex((1, 2, 6), 2, 3) == (1, 2, 2) true ``` """ function setindex(x::Tuple, v, i::Integer) @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setindex(v, i::Integer, args::Vararg{Any,N}) where {N} @inline return ntup...
@@ -73,14 +73,15 @@ keys(@nospecialize t::Tuple) = OneTo(length(t)) prevind(@nospecialize(t::Tuple), i::Integer) = Int(i)-1 nextind(@nospecialize(t::Tuple), i::Integer) = Int(i)+1 -function keys(t::Tuple, t2::Tuple...) - @inline - OneTo(_maxlength(t, t2...)) +@noinline function throw_eachindex_mismatch_indice...
base/tuple.jl
26
Julia
0.857
suggestion
433
51
51
false
Require all tuples in eachindex to have the same length.
48,125
JuliaLang/julia
35,573
Julia
timholy
navdeeprana
Review this pull request change. Language: Julia File: base/tuple.jl PR Title: Require all tuples in eachindex to have the same length. BEFORE CODE: function setindex(x::Tuple, v, i::Integer) @boundscheck 1 <= i <= length(x) || throw(BoundsError(x, i)) @inline _setindex(v, i, x...) end function _setind...
```suggestion function throw_eachindex_mismatch_indices(::Tuple{}, inds...) @noinline throw(DimensionMismatch("all inputs to eachindex must have the same length, got $(join(inds, ", ", " and "))")) ``` Looks like we have a bootstrapping problem: `tuple` is used very early in Core.Compiler and the full J...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
2×2 Matrix{Int64}: 1 2 3 4 julia> nextind(x, 1) # valid result 2 julia> nextind(x, 4) # invalid result 5 julia> nextind(x, CartesianIndex(1, 1)) # valid result CartesianIndex(2, 1) julia> nextind(x, CartesianIndex(2, 2)) # invalid result CartesianIndex(1, 3) ``` """ function nextind end prevind(@nospecialize(t...
This results in a confusing error message. PR: #58811
2×2 Matrix{Int64}: 1 2 3 4 julia> nextind(x, 1) # valid result 2 julia> nextind(x, 4) # invalid result 5 julia> nextind(x, CartesianIndex(1, 1)) # valid result CartesianIndex(2, 1) julia> nextind(x, CartesianIndex(2, 2)) # invalid result CartesianIndex(1, 3) ``` """ function nextind end prevind(@nospecialize(t...
@@ -149,12 +149,9 @@ nextind(@nospecialize(t::Tuple), i::Integer) = Int(i)+1 function keys(t::Tuple, t2::Tuple...) @inline - OneTo(_maxlength(t, t2...)) -end -_maxlength(t::Tuple) = length(t) -function _maxlength(t::Tuple, t2::Tuple, t3::Tuple...) - @inline - max(length(t), _maxlength(t2, t3...)) + ...
base/tuple.jl
26
Julia
0.357
suggestion
53
51
51
false
Require all tuples in eachindex to have the same length.
48,125
JuliaLang/julia
35,573
Julia
nsajko
navdeeprana
Review this pull request change. Language: Julia File: base/tuple.jl PR Title: Require all tuples in eachindex to have the same length. BEFORE CODE: 2×2 Matrix{Int64}: 1 2 3 4 julia> nextind(x, 1) # valid result 2 julia> nextind(x, 4) # invalid result 5 julia> nextind(x, CartesianIndex(1, 1)) # valid result ...
This results in a confusing error message. PR: #58811
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
return m > 12 ? m - 12 : m end function monthday(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4) y = fld(100b + h, 36525); c = b + z - 365y - fld(y, 4); m = div(5c + 456, 153) d = c - div(153m - 457, 5); return m > 12 ? (m - 12, d) : (m, d) end function day(days) z = days +...
This should probably go as a comment inside of the function. The docstring should be user-oriented, for example: ```suggestion Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date). ```
return m > 12 ? m - 12 : m end function monthday(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4) y = fld(100b + h, 36525); c = b + z - 365y - fld(y, 4); m = div(5c + 456, 153) d = c - div(153m - 457, 5); return m > 12 ? (m - 12, d) : (m, d) end function day(days) z = days +...
@@ -41,6 +43,47 @@ function week(days) return div(w, 28) + 1 end +""" +Year defined as ISO year. The equivalent is +`week(lastdayofyear(dt) - Day(3))` as 28 december is always in the last week
stdlib/Dates/src/accessors.jl
26
Julia
0.857
suggestion
237
51
51
false
add ISO year / ISO week utilities
48,507
JuliaLang/julia
35,573
Julia
knuesel
isentropic
Review this pull request change. Language: Julia File: stdlib/Dates/src/accessors.jl PR Title: add ISO year / ISO week utilities BEFORE CODE: return m > 12 ? m - 12 : m end function monthday(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4) y = fld(100b + h, 36525); c = b + z - 3...
This should probably go as a comment inside of the function. The docstring should be user-oriented, for example: ```suggestion Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date). ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
function monthday(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4) y = fld(100b + h, 36525); c = b + z - 365y - fld(y, 4); m = div(5c + 456, 153) d = c - div(153m - 457, 5); return m > 12 ? (m - 12, d) : (m, d) end function day(days) z = days + 306; h = 100z - 25; a = fld(h,3652...
This function should probably accept a `Year` instead, to avoid ambiguities.
function monthday(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4) y = fld(100b + h, 36525); c = b + z - 365y - fld(y, 4); m = div(5c + 456, 153) d = c - div(153m - 457, 5); return m > 12 ? (m - 12, d) : (m, d) end function day(days) z = days + 306; h = 100z - 25; a = fld(h,3652...
@@ -41,6 +43,47 @@ function week(days) return div(w, 28) + 1 end +""" +Year defined as ISO year. The equivalent is +`week(lastdayofyear(dt) - Day(3))` as 28 december is always in the last week +""" +function weeksinyear(dt::DateTime)
stdlib/Dates/src/accessors.jl
26
Julia
0.429
suggestion
76
51
51
false
add ISO year / ISO week utilities
48,507
JuliaLang/julia
35,573
Julia
knuesel
isentropic
Review this pull request change. Language: Julia File: stdlib/Dates/src/accessors.jl PR Title: add ISO year / ISO week utilities BEFORE CODE: function monthday(days) z = days + 306; h = 100z - 25; a = fld(h,3652425); b = a - fld(a,4) y = fld(100b + h, 36525); c = b + z - 365y - fld(y, 4); m = div(5c + 456, ...
This function should probably accept a `Year` instead, to avoid ambiguities.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms const WEEK_INDEX = (15, 23, 3, 11) function week(days) w = div(abs(days - 1), 7) % 20871 c, w = divrem((w + (w >= 10435)), 5218) w = (w * 28 + WEEK_INDEX[c + 1]) % 1461 return div(w, 28) + 1 end """ Year defined as ISO year. The equivalent i...
```suggestion Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date). ``` (I avoid the term "definition" because Wikipedia may be a bit too fluid to use explicitly as definition.)
# https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms const WEEK_INDEX = (15, 23, 3, 11) function week(days) w = div(abs(days - 1), 7) % 20871 c, w = divrem((w + (w >= 10435)), 5218) w = (w * 28 + WEEK_INDEX[c + 1]) % 1461 return div(w, 28) + 1 end """ Return the number of ISO weeks in the give...
@@ -41,6 +43,47 @@ function week(days) return div(w, 28) + 1 end +""" +Year defined as ISO year. The equivalent is +`week(lastdayofyear(dt) - Day(3))` as 28 december is always in the last week +""" +function weeksinyear(dt::DateTime) + firstday = firstdayofyear(dt) + lastday = lastdayofyear(dt) + + if...
stdlib/Dates/src/accessors.jl
26
Julia
0.857
suggestion
218
51
51
false
add ISO year / ISO week utilities
48,507
JuliaLang/julia
35,573
Julia
knuesel
isentropic
Review this pull request change. Language: Julia File: stdlib/Dates/src/accessors.jl PR Title: add ISO year / ISO week utilities BEFORE CODE: # https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms const WEEK_INDEX = (15, 23, 3, 11) function week(days) w = div(abs(days - 1), 7) % 20871 c, w = divrem((...
```suggestion Return the ISO year that contains `dt` (see https://en.wikipedia.org/wiki/ISO_week_date). ``` (I avoid the term "definition" because Wikipedia may be a bit too fluid to use explicitly as definition.)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end """ Return current ISO year as defined in https://en.wikipedia.org/wiki/ISO_week_date """ function isoyear(dt::DateTime) thisyear = Year(dt) thismonth = Month(dt) weeknumber = week(dt) if weeknumber >= 52 && thismonth.value == 1 # If it is january, then its the iso year from before ...
```suggestion Return the ISO week date that corresponds to `dt` (see https://en.wikipedia.org/wiki/ISO_week_date). The return type is a tuple of `Year`, `Week` and `Integer` (from 1 to 7). ```
This function requires Julia 1.13 or later. """ function weeksinyear(y::Year) firstday = firstdayofyear(Date(y)) lastday = lastdayofyear(Date(y)) if dayofweek(firstday) == 4 || dayofweek(lastday) == 4 return 53 end return 52 end """ Return the ISO year that contains `dt` (see https://e...
@@ -41,6 +43,47 @@ function week(days) return div(w, 28) + 1 end +""" +Year defined as ISO year. The equivalent is +`week(lastdayofyear(dt) - Day(3))` as 28 december is always in the last week +""" +function weeksinyear(dt::DateTime) + firstday = firstdayofyear(dt) + lastday = lastdayofyear(dt) + + if...
stdlib/Dates/src/accessors.jl
26
Julia
0.857
suggestion
198
51
51
false
add ISO year / ISO week utilities
48,507
JuliaLang/julia
35,573
Julia
knuesel
isentropic
Review this pull request change. Language: Julia File: stdlib/Dates/src/accessors.jl PR Title: add ISO year / ISO week utilities BEFORE CODE: end """ Return current ISO year as defined in https://en.wikipedia.org/wiki/ISO_week_date """ function isoyear(dt::DateTime) thisyear = Year(dt) thismonth = Month(dt...
```suggestion Return the ISO week date that corresponds to `dt` (see https://en.wikipedia.org/wiki/ISO_week_date). The return type is a tuple of `Year`, `Week` and `Integer` (from 1 to 7). ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
end # ISO year utils # https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms const WEEK_INDEX = (15, 23, 3, 11) function week(days) w = div(abs(days - 1), 7) % 20871 c, w = divrem((w + (w >= 10435)), 5218) w = (w * 28 + WEEK_INDEX[c + 1]) % 1461 return div(w, 28) + 1 end """ Return the number of...
```patch +``` """ ``` close `jldoctest` block. `isoyear` also needs this patch.
end # ISO year utils # https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms const WEEK_INDEX = (15, 23, 3, 11) function week(days) w = div(abs(days - 1), 7) % 20871 c, w = divrem((w + (w >= 10435)), 5218) w = (w * 28 + WEEK_INDEX[c + 1]) % 1461 return div(w, 28) + 1 end """ Return the number of...
@@ -41,6 +43,72 @@ function week(days) return div(w, 28) + 1 end +""" +Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date). + +# Examples +```jldoctest +julia> weeksinyear(Year(2022)) +52 + +julia> weeksinyear(Year(2020)) +53 +"""
stdlib/Dates/src/accessors.jl
26
Julia
0.571
suggestion
89
51
51
false
add ISO year / ISO week utilities
48,507
JuliaLang/julia
35,573
Julia
inkydragon
isentropic
Review this pull request change. Language: Julia File: stdlib/Dates/src/accessors.jl PR Title: add ISO year / ISO week utilities BEFORE CODE: end # ISO year utils # https://en.wikipedia.org/wiki/Talk:ISO_week_date#Algorithms const WEEK_INDEX = (15, 23, 3, 11) function week(days) w = div(abs(days - 1), 7) % 208...
```patch +``` """ ``` close `jldoctest` block. `isoyear` also needs this patch.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
52 julia> weeksinyear(Year(2020)) 53 ``` """ function weeksinyear(y::Year) firstday = firstdayofyear(Date(y)) lastday = lastdayofyear(Date(y)) if dayofweek(firstday) == 4 || dayofweek(lastday) == 4 return 53 end return 52 end """ Return the ISO year that contains `dt` (see https://en.wiki...
```suggestion julia> isoyear(Date(2022, 1, 1)) 2021 years julia> isoyear(Date(2021, 12, 31)) 2021 years ```
52 julia> weeksinyear(Year(2020)) 53 ``` !!! compat "Julia 1.13" This function requires Julia 1.13 or later. """ function weeksinyear(y::Year) firstday = firstdayofyear(Date(y)) lastday = lastdayofyear(Date(y)) if dayofweek(firstday) == 4 || dayofweek(lastday) == 4 return 53 end return...
@@ -41,6 +43,74 @@ function week(days) return div(w, 28) + 1 end +""" +Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date). + +# Examples +```jldoctest +julia> weeksinyear(Year(2022)) +52 + +julia> weeksinyear(Year(2020)) +53 +``` +""" +function weeksinyear(y::Year...
stdlib/Dates/src/accessors.jl
26
Julia
0.714
suggestion
114
51
51
false
add ISO year / ISO week utilities
48,507
JuliaLang/julia
35,573
Julia
inkydragon
isentropic
Review this pull request change. Language: Julia File: stdlib/Dates/src/accessors.jl PR Title: add ISO year / ISO week utilities BEFORE CODE: 52 julia> weeksinyear(Year(2020)) 53 ``` """ function weeksinyear(y::Year) firstday = firstdayofyear(Date(y)) lastday = lastdayofyear(Date(y)) if dayofweek(firs...
```suggestion julia> isoyear(Date(2022, 1, 1)) 2021 years julia> isoyear(Date(2021, 12, 31)) 2021 years ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
julia> isoyear(Date(2021, 12, 31)) 2021 years ``` """ function isoyear(dt::DateTime) thisyear = Year(dt) thismonth = Month(dt) weeknumber = week(dt) if weeknumber >= 52 && thismonth.value == 1 # If it is january, then its the iso year from before return Year(thisyear.value - 1) else...
```suggestion The return type is a tuple of `Year`, `Week` and `Int64` (from 1 to 7). ``` (`Int64` is the actual type returned while `Integer` is an abstract type).
julia> isoyear(Date(2022, 1, 1)) 2021 years julia> isoyear(Date(2021, 12, 31)) 2021 years ``` !!! compat "Julia 1.13" This function requires Julia 1.13 or later. """ function isoyear(dt::DateTime) thisyear = Year(dt) thismonth = Month(dt) weeknumber = week(dt) if weeknumber >= 52 && thismonth.value...
@@ -41,6 +43,74 @@ function week(days) return div(w, 28) + 1 end +""" +Return the number of ISO weeks in the given year (see https://en.wikipedia.org/wiki/ISO_week_date). + +# Examples +```jldoctest +julia> weeksinyear(Year(2022)) +52 + +julia> weeksinyear(Year(2020)) +53 +``` +""" +function weeksinyear(y::Year...
stdlib/Dates/src/accessors.jl
26
Julia
0.857
refactor
169
51
51
false
add ISO year / ISO week utilities
48,507
JuliaLang/julia
35,573
Julia
knuesel
isentropic
Review this pull request change. Language: Julia File: stdlib/Dates/src/accessors.jl PR Title: add ISO year / ISO week utilities BEFORE CODE: julia> isoyear(Date(2021, 12, 31)) 2021 years ``` """ function isoyear(dt::DateTime) thisyear = Year(dt) thismonth = Month(dt) weeknumber = week(dt) if weekn...
```suggestion The return type is a tuple of `Year`, `Week` and `Int64` (from 1 to 7). ``` (`Int64` is the actual type returned while `Integer` is an abstract type).
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
# This file is a part of Julia. License is MIT: https://julialang.org/license # Div is truncating by default """ div(x, y, r::RoundingMode=RoundToZero) The quotient from Euclidean (integer) division. Computes `x / y`, rounded to an integer according to the rounding mode `r`. In other words, the quantity rou...
Does this result in a call to [`llvm.rint.f64`](https://llvm.org/docs/LangRef.html#llvm-rint-intrinsic) in llvm code? I'm away from computer, can't test myself.
# fld(x, y) == div(x, y) - ((x >= 0) != (y >= 0) && rem(x, y) != 0 ? 1 : 0) div(x::T, y::T, ::typeof(RoundDown)) where {T<:Unsigned} = div(x, y) function div(x::T, y::T, ::typeof(RoundDown)) where T<:Integer d = div(x, y, RoundToZero) return d - (signbit(x ⊻ y) & (d * y != x)) end # cld(x, y) = div(x, y) + ((x...
@@ -368,3 +368,9 @@ end # NOTE: C89 fmod() and x87 FPREM implicitly provide truncating float division, # so it is used here as the basis of float div(). div(x::T, y::T, r::RoundingMode) where {T<:AbstractFloat} = convert(T, round((x - rem(x, y, r)) / y)) + +# Vincent Lefèvre: "The Euclidean Division Implemented with...
base/div.jl
26
Julia
0.5
question
160
377
28
false
Improve floating-point Euclidean division for Float16 and Float32
49,637
JuliaLang/julia
35,573
Julia
giordano
simonbyrne
Review this pull request change. Language: Julia File: base/div.jl PR Title: Improve floating-point Euclidean division for Float16 and Float32 BEFORE CODE: # This file is a part of Julia. License is MIT: https://julialang.org/license # Div is truncating by default """ div(x, y, r::RoundingMode=RoundToZero) T...
Does this result in a call to [`llvm.rint.f64`](https://llvm.org/docs/LangRef.html#llvm-rint-intrinsic) in llvm code? I'm away from computer, can't test myself.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
const powers_of_ten = [ 0x0000000000000001, 0x000000000000000a, 0x0000000000000064, 0x00000000000003e8, 0x0000000000002710, 0x00000000000186a0, 0x00000000000f4240, 0x0000000000989680, 0x0000000005f5e100, 0x000000003b9aca00, 0x00000002540be400, 0x000000174876e800, 0x000000e8d4a51000, 0x000009184e72a000, ...
If we guarantee the error (having automatic type widening in Base is a non-starter, as far as I'm aware) this throwing behavior should be documented & tested.
julia> nextpow(2, 7) 8 julia> nextpow(2, 9) 16 julia> nextpow(5, 20) 25 julia> nextpow(4, 16) 16 ``` """ function nextpow(a::Real, x::Real) x <= 0 && throw(DomainError(x, "`x` must be positive.")) # Special case fast path for x::Integer, a == 2. # This is a very common case. Constant prop will make sure ...
@@ -488,7 +488,8 @@ function nextpow(a::Real, x::Real) n = ceil(Integer,log(a, x)) # round-off error of log can go either direction, so need some checks p = a^(n-1) - x > typemax(p) && throw(DomainError(x,"argument is beyond the range of type of the base")) + hastypemax(typeof(p)) && x > typemax(p)...
base/intfuncs.jl
26
Julia
0.571
suggestion
159
51
51
false
fix `nextpow`, `prevpow` for types without `typemax`
49,669
JuliaLang/julia
35,573
Julia
Seelengrab
nsajko
Review this pull request change. Language: Julia File: base/intfuncs.jl PR Title: fix `nextpow`, `prevpow` for types without `typemax` BEFORE CODE: const powers_of_ten = [ 0x0000000000000001, 0x000000000000000a, 0x0000000000000064, 0x00000000000003e8, 0x0000000000002710, 0x00000000000186a0, 0x00000000000f42...
If we guarantee the error (having automatic type widening in Base is a non-starter, as far as I'm aware) this throwing behavior should be documented & tested.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
```jldoctest julia> prevpow(2, 7) 4 julia> prevpow(2, 9) 8 julia> prevpow(5, 20) 5 julia> prevpow(4, 16) 16 ``` """ function prevpow(a::T, x::Real) where T <: Real x < 1 && throw(DomainError(x, "`x` must be ≥ 1.")) # See comment in nextpos() for a == special case. a == 2 && isa(x, Integer) && return _pre...
```suggestion wp, overflow = mul_with_overflow(promote(a, p)...) ```
```jldoctest julia> prevpow(2, 7) 4 julia> prevpow(2, 9) 8 julia> prevpow(5, 20) 5 julia> prevpow(4, 16) 16 ``` """ function prevpow(a::T, x::Real) where T <: Real x < 1 && throw(DomainError(x, "`x` must be ≥ 1.")) # See comment in nextpos() for a == special case. a == 2 && isa(x, Integer) && return _pre...
@@ -615,7 +615,7 @@ function prevpow(a::T, x::Real) where T <: Real hastypemax(typeof(p)) && x > typemax(p) && throw(DomainError(x,"argument is beyond the range of type of the base")) if a isa Integer - wp, overflow = mul_with_overflow(promote(a, p)...) + wp, overflow = mul_with_overflo...
base/intfuncs.jl
26
Julia
0.714
bug
78
51
51
false
fix `nextpow`, `prevpow` for types without `typemax`
49,669
JuliaLang/julia
35,573
Julia
nsajko
nsajko
Review this pull request change. Language: Julia File: base/intfuncs.jl PR Title: fix `nextpow`, `prevpow` for types without `typemax` BEFORE CODE: ```jldoctest julia> prevpow(2, 7) 4 julia> prevpow(2, 9) 8 julia> prevpow(5, 20) 5 julia> prevpow(4, 16) 16 ``` """ function prevpow(a::T, x::Real) where T <: Real ...
```suggestion wp, overflow = mul_with_overflow(promote(a, p)...) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@test powermod(2, 0, 5) == 1 @test powermod(2, 0, -5) == -4 @test powermod(2, -1, 5) == 3 @test powermod(2, -2, 5) == 4 @test powermod(2, -1, -5) == -2 @test powermod(2, -2, -5) == -1 @test powermod(2, typemin(Int128), 5) == 1 @test powermod(2, typemin(Int128), -5) == -4 @test po...
```suggestion fs = (prevpow, nextpow) types = (Int8, BigInt, BigFloat) for f ∈ fs, P ∈ types, R ∈ types, p ∈ 1:20, r ∈ 2:5 q = P(p) n = R(r) @test f(r, p) == f(n, q) end ```
@test powermod(2, 0, 5) == 1 @test powermod(2, 0, -5) == -4 @test powermod(2, -1, 5) == 3 @test powermod(2, -2, 5) == 4 @test powermod(2, -1, -5) == -2 @test powermod(2, -2, -5) == -1 @test powermod(2, typemin(Int128), 5) == 1 @test powermod(2, typemin(Int128), -5) == -4 @test po...
@@ -326,6 +326,18 @@ end end @testset "nextpow/prevpow" begin + @testset "small BigInt: $f $R" for f ∈ (prevpow, nextpow), + P ∈ (Int8, Int16, Int32, Int64, Int128), + R ∈ (Int8, Int16, Int32, Int64, Int128), + ...
test/intfuncs.jl
26
Julia
0.929
suggestion
221
51
51
false
fix `nextpow`, `prevpow` for types without `typemax`
49,669
JuliaLang/julia
35,573
Julia
nsajko
nsajko
Review this pull request change. Language: Julia File: test/intfuncs.jl PR Title: fix `nextpow`, `prevpow` for types without `typemax` BEFORE CODE: @test powermod(2, 0, 5) == 1 @test powermod(2, 0, -5) == -4 @test powermod(2, -1, 5) == 3 @test powermod(2, -2, 5) == 4 @test powermod(2, -1, -5) ...
```suggestion fs = (prevpow, nextpow) types = (Int8, BigInt, BigFloat) for f ∈ fs, P ∈ types, R ∈ types, p ∈ 1:20, r ∈ 2:5 q = P(p) n = R(r) @test f(r, p) == f(n, q) end ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
else llvmf = emit_plt(ctx, functype, attributes, cc, symarg.f_lib, symarg.f_name); } else { void *symaddr; void *libsym = jl_get_library_(symarg.f_lib, 0); int symbol_found = jl_dlsym(libsym, symarg.f_name, &symaddr, 0); if (!li...
Since the OpBundle mutates gc-unsafe state locally, I think we actually will need to insert these later (after the gc-late-lowering pass) or at least teach that pass to accurately detect gc-safe/unsafe region transitions and move those region boundaries to inside of the runtime-interop code.
if (llvmcall) { ++EmittedLLVMCalls; if (symarg.jl_ptr != NULL) { emit_error(ctx, "llvmcall doesn't support dynamic pointers"); return jl_cgval_t(); } else if (symarg.fptr != NULL) { emit_error(ctx, "llvmcall doesn't support static pointers"); ...
@@ -2085,6 +2094,11 @@ jl_cgval_t function_sig_t::emit_a_ccall( } } + Value *last_gc_state = NULL; + Value *ptls = get_current_ptls(ctx); // Do we need to reload this after the ccall? + + if (gc_safe) + last_gc_state = emit_gc_safe_enter(ctx.builder, ctx.types().T_size, ptls, false);
src/ccall.cpp
26
C++
0.5
suggestion
292
51
51
false
Allow for :foreigncall to transition to GC safe automatically
49,933
JuliaLang/julia
35,573
Julia
vtjnash
vchuravy
Review this pull request change. Language: C++ File: src/ccall.cpp PR Title: Allow for :foreigncall to transition to GC safe automatically BEFORE CODE: else llvmf = emit_plt(ctx, functype, attributes, cc, symarg.f_lib, symarg.f_name); } else { void *symaddr; ...
Since the OpBundle mutates gc-unsafe state locally, I think we actually will need to insert these later (after the gc-late-lowering pass) or at least teach that pass to accurately detect gc-safe/unsafe region transitions and move those region boundaries to inside of the runtime-interop code.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Colors[Idx] = PreAssignedColors++; } } /* Greedy coloring */ int MaxAssignedColor = -1; int ActiveElement = 1; BitVector UsedColors; while ((ActiveElement = Ordering.next()) != -1) { if (Colors[ActiveElement] != -1) continue; UsedColors.resize(...
I am guessing you would need to make a new block for this specific emit call, then fix up the IR by calling [SplitBlockAndInsertIfThenElse](https://llvm.org/doxygen/namespacellvm.html#a7ac00229d8c59902686f52ed061cdc80) and splice the instructions back into their respective parts of the IfThenElse blocks and delete the ...
ReplacementArgs.push_back(front); } FunctionType *FTy = callee == call3_func ? JuliaType::get_jlfunc3_ty(CI->getContext()) : callee == call2_func ? JuliaType::get_jlfunc2_ty(CI->getContext()) : ...
@@ -2484,16 +2484,37 @@ bool LateLowerGCFrame::CleanupIR(Function &F, State *S, bool *CFGModified) { NewCall->copyMetadata(*CI); CI->replaceAllUsesWith(NewCall); UpdatePtrNumbering(CI, NewCall, S); - } else if (CI->arg_size() == CI->getNumOperands()) { - ...
src/llvm-late-gc-lowering.cpp
26
C++
0.429
suggestion
330
51
51
false
Allow for :foreigncall to transition to GC safe automatically
49,933
JuliaLang/julia
35,573
Julia
vtjnash
vchuravy
Review this pull request change. Language: C++ File: src/llvm-late-gc-lowering.cpp PR Title: Allow for :foreigncall to transition to GC safe automatically BEFORE CODE: Colors[Idx] = PreAssignedColors++; } } /* Greedy coloring */ int MaxAssignedColor = -1; int ActiveElement = ...
I am guessing you would need to make a new block for this specific emit call, then fix up the IR by calling [SplitBlockAndInsertIfThenElse](https://llvm.org/doxygen/namespacellvm.html#a7ac00229d8c59902686f52ed061cdc80) and splice the instructions back into their respective parts of the IfThenElse blocks and delete the ...
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint The semicolon is used to separate required arguments (of which there must be at least one) from variadic arguments. Example using an externa...
```suggestion calls back into the julia runtime. (`@cfunction`/`@ccallables` are safe however) ```
Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint The semicolon is used to separate required arguments (of which there must be at least one) from variadic arguments. Example using an external library: # C signature of g_uri_escape_strin...
@@ -404,9 +434,16 @@ Example using an external library: The string literal could also be used directly before the function name, if desired `"libglib-2.0".g_uri_escape_string(...` + +It's possible to declare the ccall as `gc_safe` by using the `gc_safe = true` option: + @ccall gc_safe=true strlen(s::Cstring)::Cs...
base/c.jl
26
Julia
0.714
suggestion
100
35
34
false
Allow for :foreigncall to transition to GC safe automatically
49,933
JuliaLang/julia
35,573
Julia
vchuravy
vchuravy
Review this pull request change. Language: Julia File: base/c.jl PR Title: Allow for :foreigncall to transition to GC safe automatically BEFORE CODE: with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::...
```suggestion calls back into the julia runtime. (`@cfunction`/`@ccallables` are safe however) ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
size_t strlen(char *) with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint The semicolon is used to separate required arguments (of which there must be at least one) from variadic arguments...
```suggestion the `ccall` may block outside of julia. ```
with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint The semicolon is used to separate required arguments (of which there must be at least one) from variadic arguments. Example using an extern...
@@ -404,9 +434,16 @@ Example using an external library: The string literal could also be used directly before the function name, if desired `"libglib-2.0".g_uri_escape_string(...` + +It's possible to declare the ccall as `gc_safe` by using the `gc_safe = true` option: + @ccall gc_safe=true strlen(s::Cstring)::Cs...
base/c.jl
26
Julia
0.571
suggestion
59
37
36
false
Allow for :foreigncall to transition to GC safe automatically
49,933
JuliaLang/julia
35,573
Julia
vchuravy
vchuravy
Review this pull request change. Language: Julia File: base/c.jl PR Title: Allow for :foreigncall to transition to GC safe automatically BEFORE CODE: size_t strlen(char *) with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstr...
```suggestion the `ccall` may block outside of julia. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
This calls the C standard library function: size_t strlen(char *) with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint The semicolon is used to separate required arguments (of which there...
🚲 If `gc_safe=false` is the default, perhaps marking a `ccall` as `gc_safe` could just be spelled like: ```julia @ccall :gc_safe strlen(s::Cstring)::Csize_t ``` (similar to how the `@atomic` and `@spawn` and `@assume_effects` macros take Symbols to control behaviour)
This calls the C standard library function: size_t strlen(char *) with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following convention: @ccall printf("%s = %d"::Cstring ; "foo"::Cstring, foo::Cint)::Cint The semicolon is used to separate required arguments (of which there ...
@@ -404,9 +434,16 @@ Example using an external library: The string literal could also be used directly before the function name, if desired `"libglib-2.0".g_uri_escape_string(...` + +It's possible to declare the ccall as `gc_safe` by using the `gc_safe = true` option: + @ccall gc_safe=true strlen(s::Cstring)::Cs...
base/c.jl
26
Julia
0.857
suggestion
272
40
39
false
Allow for :foreigncall to transition to GC safe automatically
49,933
JuliaLang/julia
35,573
Julia
nickrobinson251
vchuravy
Review this pull request change. Language: Julia File: base/c.jl PR Title: Allow for :foreigncall to transition to GC safe automatically BEFORE CODE: This calls the C standard library function: size_t strlen(char *) with a Julia variable named `s`. See also `ccall`. Varargs are supported with the following ...
🚲 If `gc_safe=false` is the default, perhaps marking a `ccall` as `gc_safe` could just be spelled like: ```julia @ccall :gc_safe strlen(s::Cstring)::Csize_t ``` (similar to how the `@atomic` and `@spawn` and `@assume_effects` macros take Symbols to control behaviour)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Convert a `Date` to a `DateTime`. The hour, minute, second, and millisecond parts of the new `DateTime` are assumed to be zero. """ DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are...
Making this a constant doesn't seem right — what if the local time changes? (Moreover, won't precompilation then set `LOCALEPOCH` to wherever Julia was built?)
Convert a `Date` to a `DateTime`. The hour, minute, second, and millisecond parts of the new `DateTime` are assumed to be zero. """ DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to...
@@ -38,26 +38,33 @@ Base.convert(::Type{Day},dt::Date) = Day(value(dt)) # Converts Date t ### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 +const LOCALEPOCH = value(DateTime(Libc.TmStruct(0))) #Rata Die for local time at UTC 1970-01-01T00:00:...
stdlib/Dates/src/conversions.jl
26
Julia
0.571
suggestion
160
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
stevengj
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: Convert a `Date` to a `DateTime`. The hour, minute, second, and millisecond parts of the new `DateTime` are assumed to be zero. """ DateTime(dt::TimeType) ...
Making this a constant doesn't seem right — what if the local time changes? (Moreover, won't precompilation then set `LOCALEPOCH` to wherever Julia was built?)
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base...
Maybe just `local` instead of `local_time`? In context, it should be pretty clear that this refers to time.
""" DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base.convert...
@@ -38,26 +38,33 @@ Base.convert(::Type{Day},dt::Date) = Day(value(dt)) # Converts Date t ### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 +const LOCALEPOCH = value(DateTime(Libc.TmStruct(0))) #Rata Die for local time at UTC 1970-01-01T00:00:...
stdlib/Dates/src/conversions.jl
26
Julia
0.571
suggestion
109
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
stevengj
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: """ DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and mill...
Maybe just `local` instead of `local_time`? In context, it should be pretty clear that this refers to time.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base...
Don't forget to update the spelling of `localtime` in the docstrings.
""" DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base.convert...
@@ -38,26 +38,33 @@ Base.convert(::Type{Day},dt::Date) = Day(value(dt)) # Converts Date t ### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 +localepoch() = value(DateTime(Libc.TmStruct(0))) #Rata Die for local time at UTC 1970-01-01T00:00:00 ...
stdlib/Dates/src/conversions.jl
26
Julia
0.357
nitpick
69
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
stevengj
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: """ DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and mill...
Don't forget to update the spelling of `localtime` in the docstrings.
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 localepoch() = value(DateTime(Libc.TmStruct(0))) #Rata Die for local time at UTC 1970-01-01T00:00:00 """ unix2datetime(x::Real; localtime::Bool=false) -> DateTime Take the number of seconds since unix ...
```suggestion since the unix epoch `1970-01-01T00:00:00` (UTC) as a [`Float64`](@ref). If `localtime` is `true`, then `dt` is interpreted as being in the local time zone, and is otherwise interpreted as being UTC/GMT. ```
### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 """ unix2datetime(x::Real; localtime::Bool=false)::DateTime Take the number of seconds since unix epoch `1970-01-01T00:00:00` (UTC) and convert to the corresponding `DateTime`. If `localtime` is `true`...
@@ -38,26 +38,33 @@ Base.convert(::Type{Day},dt::Date) = Day(value(dt)) # Converts Date t ### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 +localepoch() = value(DateTime(Libc.TmStruct(0))) #Rata Die for local time at UTC 1970-01-01T00:00:00 ...
stdlib/Dates/src/conversions.jl
26
Julia
0.786
suggestion
227
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
stevengj
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: ### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 localepoch() = value(DateTime(Libc.TmStruct...
```suggestion since the unix epoch `1970-01-01T00:00:00` (UTC) as a [`Float64`](@ref). If `localtime` is `true`, then `dt` is interpreted as being in the local time zone, and is otherwise interpreted as being UTC/GMT. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base.convert(::Type{DateTime}, dt::Date) = DateTime(UTM...
```suggestion Take the number of seconds since unix epoch `1970-01-01T00:00:00` (UTC) and convert to the ```
""" Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base.convert(::Type{DateTime}, dt::Date) = DateTime(UTM(value(d...
@@ -38,26 +38,33 @@ Base.convert(::Type{Day},dt::Date) = Day(value(dt)) # Converts Date t ### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 +localepoch() = value(DateTime(Libc.TmStruct(0))) #Rata Die for local time at UTC 1970-01-01T00:00:00 ...
stdlib/Dates/src/conversions.jl
26
Julia
0.714
suggestion
110
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
stevengj
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: """ Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create ...
```suggestion Take the number of seconds since unix epoch `1970-01-01T00:00:00` (UTC) and convert to the ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
@test string(Dates.unix2datetime(1095379199.75)) == string("2004-09-16T23:59:59.750") @test string(Dates.unix2datetime(1095379200.00)) == string("2004-09-17T00:00:00") @test string(Dates.unix2datetime(1095379200.25)) == string("2004-09-17T00:00:00.250") @test string(Dates.unix2datetime(1095379200.50)) =...
```suggestion localunixdiff() = Dates.value(DateTime(Libc.TmStruct(0))) - Dates.UNIXEPOCH ```
@test string(Dates.unix2datetime(1095379199.75)) == string("2004-09-16T23:59:59.750") @test string(Dates.unix2datetime(1095379200.00)) == string("2004-09-17T00:00:00") @test string(Dates.unix2datetime(1095379200.25)) == string("2004-09-17T00:00:00.250") @test string(Dates.unix2datetime(1095379200.50)) =...
@@ -35,6 +35,18 @@ using Dates @test string(Dates.unix2datetime(915148801.25)) == string("1999-01-01T00:00:01.250") end +@testset "conversions with localtime=true" begin + @test unix2datetime(datetime2unix(DateTime(2000, 1, 1), localtime=true), localtime=true) == DateTime(2000, 1, 1) + @test julian2dateti...
stdlib/Dates/test/conversions.jl
26
Julia
0.571
suggestion
99
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
stevengj
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/test/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: @test string(Dates.unix2datetime(1095379199.75)) == string("2004-09-16T23:59:59.750") @test string(Dates.unix2datetime(1095379200.00)) == string("2...
```suggestion localunixdiff() = Dates.value(DateTime(Libc.TmStruct(0))) - Dates.UNIXEPOCH ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" rata2datetime(days) -> DateTime Take the number of Rata Die days since epoch `0000-12-31T00:00:00` and return the corresponding `DateTime`. """ rata2datetime(days) = DateTime(yearmonthday(days)...) """ datetime2rata(dt::TimeType) -> Int64 Return the number of Rata Die days since epoch from the given `Da...
```suggestion time zone, otherwise it is in UTC/GMT. ```
""" rata2datetime(days)::DateTime Take the number of Rata Die days since epoch `0000-12-31T00:00:00` and return the corresponding `DateTime`. """ rata2datetime(days) = DateTime(yearmonthday(days)...) """ datetime2rata(dt::TimeType)::Int64 Return the number of Rata Die days since epoch from the given `Date` ...
@@ -109,22 +116,29 @@ datetime2rata(dt::TimeType) = days(dt) # Julian conversions const JULIANEPOCH = value(DateTime(-4713, 11, 24, 12)) +localjulianepoch() = JULIANEPOCH + (localepoch() - UNIXEPOCH) """ - julian2datetime(julian_days) -> DateTime + julian2datetime(julian_days::Real; localtime::Bool=false) ...
stdlib/Dates/src/conversions.jl
26
Julia
0.571
suggestion
58
45
38
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
fingolfin
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: """ rata2datetime(days) -> DateTime Take the number of Rata Die days since epoch `0000-12-31T00:00:00` and return the corresponding `DateTime`. """ ra...
```suggestion time zone, otherwise it is in UTC/GMT. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
Convert a `Date` to a `DateTime`. The hour, minute, second, and millisecond parts of the new `DateTime` are assumed to be zero. """ DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) -> Time Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are...
Worth adding a comment on why this is a function
Convert a `Date` to a `DateTime`. The hour, minute, second, and millisecond parts of the new `DateTime` are assumed to be zero. """ DateTime(dt::TimeType) = convert(DateTime, dt) """ Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to...
@@ -38,26 +38,33 @@ Base.convert(::Type{Day},dt::Date) = Day(value(dt)) # Converts Date t ### External Conversions const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 +localepoch() = value(DateTime(Libc.TmStruct(0))) #Rata Die for local time at UTC 1970-01-01T00:00:00
stdlib/Dates/src/conversions.jl
26
Julia
0.071
suggestion
48
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
omus
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: Convert a `Date` to a `DateTime`. The hour, minute, second, and millisecond parts of the new `DateTime` are assumed to be zero. """ DateTime(dt::TimeType) ...
Worth adding a comment on why this is a function
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.
""" Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base.convert(::Type{DateTime}, dt::Date) = DateTime(UTM(value(dt...
```suggestion corresponding `DateTime`. If `localtime` is `true`, then the output is in the host system's local time zone, otherwise it is in UTC/GMT. ```
""" Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `Time`. Microsecond and nanoseconds are zero by default. """ Time(dt::DateTime) = convert(Time, dt) Base.convert(::Type{DateTime}, dt::Date) = DateTime(UTM(value(dt...
@@ -40,15 +40,22 @@ Base.convert(::Type{Day},dt::Date) = Day(value(dt)) # Converts Date t const UNIXEPOCH = value(DateTime(1970)) #Rata Die milliseconds for 1970-01-01T00:00:00 """ - unix2datetime(x)::DateTime + unix2datetime(x::Real; localtime::Bool=false)::DateTime -Take the number of seconds s...
stdlib/Dates/src/conversions.jl
26
Julia
0.714
suggestion
157
51
51
false
add `unix2datetime(...; localtime)` functionality
50,296
JuliaLang/julia
35,573
Julia
omus
vmpyr
Review this pull request change. Language: Julia File: stdlib/Dates/src/conversions.jl PR Title: add `unix2datetime(...; localtime)` functionality BEFORE CODE: """ Time(dt::DateTime) Convert a `DateTime` to a `Time`. The hour, minute, second, and millisecond parts of the `DateTime` are used to create the new `...
```suggestion corresponding `DateTime`. If `localtime` is `true`, then the output is in the host system's local time zone, otherwise it is in UTC/GMT. ```
You are an expert software engineer and code reviewer. Review pull requests carefully for correctness, bugs, security issues, performance problems, maintainability, and unnecessary complexity. Only raise actionable issues supported by the code. Explain why an issue matters and suggest a concrete fix when appropriate.