changeset 1772:246cc2195cf1 feature/jet_aqua

Merge default
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 13 Sep 2024 22:50:09 +0200
parents 5e4b2f8e9bf9 (diff) fbbadc6df706 (current diff)
children 244311761969
files
diffstat 12 files changed, 128 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/Manifest.toml	Fri Sep 13 22:41:27 2024 +0200
+++ b/Manifest.toml	Fri Sep 13 22:50:09 2024 +0200
@@ -2,7 +2,7 @@
 
 julia_version = "1.10.5"
 manifest_format = "2.0"
-project_hash = "28d35bafed672f63e2364cf8258fc24801cb971b"
+project_hash = "31f33b1ec3df03df7c6fbde71702bfddb52978a9"
 
 [[deps.Artifacts]]
 uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33"
--- a/Project.toml	Fri Sep 13 22:41:27 2024 +0200
+++ b/Project.toml	Fri Sep 13 22:50:09 2024 +0200
@@ -20,3 +20,9 @@
 
 [compat]
 julia = "1.5"
+StaticArrays = "1.0"
+TOML = "1.0"
+Makie = "0.21"
+SparseArrayKit = "0.3"
+Tokens = "0.1.1"
+SparseArrays = "1.10"
--- a/src/Grids/equidistant_grid.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/src/Grids/equidistant_grid.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -15,7 +15,7 @@
 end
 
 # Indexing interface
-Base.getindex(g::EquidistantGrid, i) = g.points[i]
+Base.getindex(g::EquidistantGrid, i::Int) = g.points[i]
 Base.eachindex(g::EquidistantGrid) = eachindex(g.points)
 Base.firstindex(g::EquidistantGrid) = firstindex(g.points)
 Base.lastindex(g::EquidistantGrid) = lastindex(g.points)
--- a/src/LazyTensors/lazy_tensor_operations.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/src/LazyTensors/lazy_tensor_operations.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -169,10 +169,10 @@
     )
 end
 
-InflatedTensor(before::IdentityTensor, tm::LazyTensor{T}) where T = InflatedTensor(before,tm,IdentityTensor{T}())
-InflatedTensor(tm::LazyTensor{T}, after::IdentityTensor) where T = InflatedTensor(IdentityTensor{T}(),tm,after)
+InflatedTensor(before::IdentityTensor, tm::LazyTensor) = InflatedTensor(before,tm,IdentityTensor{eltype(tm)}())
+InflatedTensor(tm::LazyTensor, after::IdentityTensor) = InflatedTensor(IdentityTensor{eltype(tm)}(),tm,after)
 # Resolve ambiguity between the two previous methods
-InflatedTensor(I1::IdentityTensor{T}, I2::IdentityTensor{T}) where T = InflatedTensor(I1,I2,IdentityTensor{T}())
+InflatedTensor(I1::IdentityTensor, I2::IdentityTensor) = InflatedTensor(I1,I2,IdentityTensor{promote_type(eltype(I1), eltype(I2))}())
 
 # TODO: Implement some pretty printing in terms of ⊗. E.g InflatedTensor(I(3),B,I(2)) -> I(3)⊗B⊗I(2)
 
@@ -263,7 +263,7 @@
     return itm1∘itm2
 end
 
-LazyOuterProduct(t1::IdentityTensor{T}, t2::IdentityTensor{T}) where T = IdentityTensor{T}(t1.size...,t2.size...)
+LazyOuterProduct(t1::IdentityTensor, t2::IdentityTensor) = IdentityTensor{promote_type(eltype(t1),eltype(t2))}(t1.size...,t2.size...)
 LazyOuterProduct(t1::LazyTensor, t2::IdentityTensor) = InflatedTensor(t1, t2)
 LazyOuterProduct(t1::IdentityTensor, t2::LazyTensor) = InflatedTensor(t1, t2)
 
--- a/src/RegionIndices/RegionIndices.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/src/RegionIndices/RegionIndices.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -36,7 +36,7 @@
     return Index{getregion(i,boundary_width,dim_size)}(i)
 end
 
-IndexTuple(t::Vararg{Tuple{T, DataType}}) where T<:Integer = Index.(t)
+IndexTuple(t::Vararg{Tuple{Integer, DataType}}) = Index.(t)
 export IndexTuple
 
 # TODO: Use the values of the region structs, e.g. Lower(), for the region parameter instead of the types.
--- a/src/SbpOperators/stencil.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/src/SbpOperators/stencil.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -5,14 +5,16 @@
     range::UnitRange{Int64}
     weights::NTuple{N,T}
 
-    function Stencil(range::UnitRange,weights::NTuple{N,T}) where {T, N}
+    function Stencil(range::UnitRange,weights::NTuple{N,Any}) where N
+        T = eltype(weights)
+
         @assert length(range) == N
         new{T,N}(range,weights)
     end
 end
 
 """
-    Stencil(weights::NTuple; center::Int)
+    Stencil(weights...; center::Int)
 
 Create a stencil with the given weights with element `center` as the center of the stencil.
 """
@@ -112,21 +114,24 @@
     s::Stencil{Stencil{T,N},M}
 end
 
+NestedStencil(;center) = NestedStencil(Stencil(;center))
+CenteredNestedStencil() = NestedStencil(CenteredStencil())
+
 # Stencil input
 NestedStencil(s::Vararg{Stencil}; center) = NestedStencil(Stencil(s... ; center))
 CenteredNestedStencil(s::Vararg{Stencil}) = NestedStencil(CenteredStencil(s...))
 
 # Tuple input
-function NestedStencil(weights::Vararg{NTuple{N,Any}}; center) where N
+function NestedStencil(weights::Vararg{NTuple{N,Any} where N}; center)
     inner_stencils = map(w -> Stencil(w...; center), weights)
     return NestedStencil(Stencil(inner_stencils... ; center))
 end
-function CenteredNestedStencil(weights::Vararg{NTuple{N,Any}}) where N
+
+function CenteredNestedStencil(weights::Vararg{NTuple{N,Any} where N})
     inner_stencils = map(w->CenteredStencil(w...), weights)
     return CenteredNestedStencil(inner_stencils...)
 end
 
-
 # Conversion
 function NestedStencil{T,N,M}(ns::NestedStencil{S,N,M}) where {T,S,N,M}
     return NestedStencil(Stencil{Stencil{T}}(ns.s))
@@ -139,7 +144,7 @@
 function Base.convert(::Type{NestedStencil{T,N,M}}, s::NestedStencil{S,N,M}) where {T,S,N,M}
     return NestedStencil{T,N,M}(s)
 end
-Base.convert(::Type{NestedStencil{T}}, stencil) where T = NestedStencil{T}(stencil)
+Base.convert(::Type{NestedStencil{T}}, stencil::NestedStencil) where T = NestedStencil{T}(stencil)
 
 function Base.promote_rule(::Type{NestedStencil{T,N,M}}, ::Type{NestedStencil{S,N,M}}) where {T,S,N,M}
     return NestedStencil{promote_type(T,S),N,M}
--- a/src/SbpOperators/volumeops/constant_interior_scaling_operator.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/src/SbpOperators/volumeops/constant_interior_scaling_operator.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -19,7 +19,7 @@
     end
 end
 
-function ConstantInteriorScalingOperator(grid::EquidistantGrid, interior_weight, closure_weights)
+function ConstantInteriorScalingOperator(grid::EquidistantGrid, interior_weight::T, closure_weights::NTuple{N,T} where N) where T
     return ConstantInteriorScalingOperator(interior_weight, Tuple(closure_weights), size(grid)[1])
 end
 
--- a/src/SbpOperators/volumeops/volume_operator.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/src/SbpOperators/volumeops/volume_operator.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -6,18 +6,23 @@
 struct VolumeOperator{T,N,M,K} <: LazyTensor{T,1,1}
     inner_stencil::Stencil{T,N}
     closure_stencils::NTuple{M,Stencil{T,K}}
-    size::NTuple{1,Int}
+    size::Int
     parity::Parity
+
+    function VolumeOperator(inner_stencil::Stencil{T,N}, closure_stencils::Tuple{Stencil{T,K}, Vararg{Stencil{T,K}}}, size::Int, parity::Parity) where {T,N,K}
+        M = length(closure_stencils)
+        return new{T,N,M,K}(inner_stencil, closure_stencils, size, parity)
+    end
 end
 
 function VolumeOperator(grid::EquidistantGrid, inner_stencil, closure_stencils, parity)
-    return VolumeOperator(inner_stencil, Tuple(closure_stencils), size(grid), parity)
+    return VolumeOperator(inner_stencil, Tuple(closure_stencils), size(grid,1), parity)
 end # TBD: Remove this function?
 
 closure_size(::VolumeOperator{T,N,M}) where {T,N,M} = M
 
-LazyTensors.range_size(op::VolumeOperator) = op.size
-LazyTensors.domain_size(op::VolumeOperator) = op.size
+LazyTensors.range_size(op::VolumeOperator) = (op.size,)
+LazyTensors.domain_size(op::VolumeOperator) = (op.size,)
 
 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Lower})
     return @inbounds apply_stencil(op.closure_stencils[Int(i)], v, Int(i))
@@ -28,11 +33,11 @@
 end
 
 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i::Index{Upper})
-    return @inbounds Int(op.parity)*apply_stencil_backwards(op.closure_stencils[op.size[1]-Int(i)+1], v, Int(i))
+    return @inbounds Int(op.parity)*apply_stencil_backwards(op.closure_stencils[op.size-Int(i)+1], v, Int(i))
 end
 
 function LazyTensors.apply(op::VolumeOperator, v::AbstractVector, i)
-    r = getregion(i, closure_size(op), op.size[1])
+    r = getregion(i, closure_size(op), op.size)
     return LazyTensors.apply(op, v, Index(i, r))
 end
 # TODO: Move this to LazyTensors when we have the region communication down.
--- a/test/Manifest.toml	Fri Sep 13 22:41:27 2024 +0200
+++ b/test/Manifest.toml	Fri Sep 13 22:50:09 2024 +0200
@@ -2,7 +2,13 @@
 
 julia_version = "1.10.5"
 manifest_format = "2.0"
-project_hash = "9dddd5385164ee197d1b3f22302bc95701c1f5e5"
+project_hash = "b23d6f58220d898029330f7adcac8132668171ec"
+
+[[deps.Aqua]]
+deps = ["Compat", "Pkg", "Test"]
+git-tree-sha1 = "12e575f31a6f233ba2485ed86b9325b85df37c61"
+uuid = "4c88cf16-eb10-579e-8560-4a9242c79595"
+version = "0.8.7"
 
 [[deps.ArgTools]]
 uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
@@ -20,6 +26,22 @@
 uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
 version = "1.5.0"
 
+[[deps.CodeTracking]]
+deps = ["InteractiveUtils", "UUIDs"]
+git-tree-sha1 = "7eee164f122511d3e4e1ebadb7956939ea7e1c77"
+uuid = "da1fd8a2-8d9e-5ec2-8556-3022fb5608a2"
+version = "1.3.6"
+
+[[deps.Compat]]
+deps = ["TOML", "UUIDs"]
+git-tree-sha1 = "8ae8d32e09f0dcf42a36b90d4e17f5dd2e4c4215"
+uuid = "34da2185-b29b-5c13-b0c7-acf172513d20"
+version = "4.16.0"
+weakdeps = ["Dates", "LinearAlgebra"]
+
+    [deps.Compat.extensions]
+    CompatLinearAlgebraExt = "LinearAlgebra"
+
 [[deps.CompilerSupportLibraries_jll]]
 deps = ["Artifacts", "Libdl"]
 uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae"
@@ -72,6 +94,20 @@
 uuid = "92d709cd-6900-40b7-9082-c6be49f344b6"
 version = "0.2.2"
 
+[[deps.JET]]
+deps = ["CodeTracking", "InteractiveUtils", "JuliaInterpreter", "LoweredCodeUtils", "MacroTools", "Pkg", "PrecompileTools", "Preferences", "Test"]
+git-tree-sha1 = "2be1a06ddab589ac6d09930eb36e4365416261b2"
+uuid = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
+version = "0.9.9"
+
+    [deps.JET.extensions]
+    JETCthulhuExt = "Cthulhu"
+    ReviseExt = "Revise"
+
+    [deps.JET.weakdeps]
+    Cthulhu = "f68482b8-f384-11e8-15f7-abe071a5a75f"
+    Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
+
 [[deps.JLLWrappers]]
 deps = ["Artifacts", "Preferences"]
 git-tree-sha1 = "f389674c99bfcde17dc57454011aa44d5a260a40"
@@ -84,6 +120,12 @@
 uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
 version = "0.21.4"
 
+[[deps.JuliaInterpreter]]
+deps = ["CodeTracking", "InteractiveUtils", "Random", "UUIDs"]
+git-tree-sha1 = "2984284a8abcfcc4784d95a9e2ea4e352dd8ede7"
+uuid = "aa1ae85d-cabe-5617-a682-6adf51b2e16a"
+version = "0.9.36"
+
 [[deps.LibCURL]]
 deps = ["LibCURL_jll", "MozillaCACerts_jll"]
 uuid = "b27032c2-a3e7-50c8-80cd-2d36dbcbfd21"
@@ -134,6 +176,18 @@
 [[deps.Logging]]
 uuid = "56ddb016-857b-54e1-b83d-db4d58db5568"
 
+[[deps.LoweredCodeUtils]]
+deps = ["JuliaInterpreter"]
+git-tree-sha1 = "c2b5e92eaf5101404a58ce9c6083d595472361d6"
+uuid = "6f1432cf-f94c-5a45-995e-cdbf5db27b0b"
+version = "3.0.2"
+
+[[deps.MacroTools]]
+deps = ["Markdown", "Random"]
+git-tree-sha1 = "2fa9ee3e63fd3a4f7a9a4f4744a52f4856de82df"
+uuid = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
+version = "0.5.13"
+
 [[deps.Markdown]]
 deps = ["Base64"]
 uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
--- a/test/Project.toml	Fri Sep 13 22:41:27 2024 +0200
+++ b/test/Project.toml	Fri Sep 13 22:50:09 2024 +0200
@@ -1,6 +1,8 @@
 [deps]
+Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
 BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
 Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
+JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
 LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
 SparseArrayKit = "a9a3c162-d163-4c15-8926-b8794fbefed2"
 SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
--- a/test/SbpOperators/volumeops/volume_operator_test.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/test/SbpOperators/volumeops/volume_operator_test.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -17,7 +17,7 @@
     g = equidistant_grid(0.,1., 11)
 
     @testset "Constructors" begin
-        op = VolumeOperator(inner_stencil,closure_stencils,(11,),even)
+        op = VolumeOperator(inner_stencil, closure_stencils, 11, even)
         @test op == VolumeOperator(g,inner_stencil,closure_stencils,even)
         @test op isa LazyTensor{T,1,1} where T
     end
--- a/test/runtests.jl	Fri Sep 13 22:41:27 2024 +0200
+++ b/test/runtests.jl	Fri Sep 13 22:50:09 2024 +0200
@@ -1,4 +1,7 @@
+using Diffinitive
 using Test
+using JET
+using Aqua
 using Glob
 
 """
@@ -18,7 +21,7 @@
     run_testfiles(".", globs)
 end
 
-function  run_testfiles(path, globs)
+function  run_testfiles(path,   globs)
     for name ∈ readdir(path)
         filepath = joinpath(path, name)
 
@@ -29,25 +32,44 @@
         end
 
         if endswith(name, "_test.jl") && any(occursin.(globs, filepath))
-            printstyled("Running "; bold=true, color=:green)
-            print(filepath)
-
-            t_start = time()
-            @testset "$name" begin
-                include(filepath)
+            log_and_time(filepath) do
+                @testset "$name" begin
+                    include(filepath)
+                end
             end
-            t_end = time()
-
-            Δt = t_end - t_start
-            printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black)
-            println()
         end
     end
 end
 
+function log_and_time(f, msg)
+    printstyled("Running "; bold=true, color=:green)
+    print(msg)
+
+    t_start = time()
+    f()
+    t_end = time()
+    Δt = t_end - t_start
+    printstyled(" ($(round(Δt, digits=2)) s)"; color=:light_black)
+    println()
+end
+
 testsetname = isempty(ARGS) ? "Diffinitive.jl" : "["*join(ARGS, ", ")*"]"
 
 @testset "$testsetname" begin
+    if isempty(ARGS)
+        log_and_time("code quality tests using Aqua.jl") do
+            @testset "Code quality (Aqua.jl)" begin
+                Aqua.test_all(Diffinitive)
+            end
+        end
+
+        log_and_time("code linting using JET.jl") do
+            @testset "Code linting (JET.jl)" begin
+                JET.test_package(Diffinitive; target_defined_modules = true)
+            end
+        end
+    end
+
     run_testfiles(ARGS)
     println()
 end