From 3d33774b23175ff5b1050b0770dfaa9f5e88a3ad Mon Sep 17 00:00:00 2001 From: roflmaostc Date: Sun, 31 Mar 2024 12:43:53 +0200 Subject: [PATCH] Fix small things --- Manifest.toml | 62 ----------------------------------------- Project.toml | 2 +- docs/src/dims.md | 1 + src/generation_tools.jl | 6 ++-- src/selection_tools.jl | 7 +++-- test/selection_tools.jl | 3 ++ 6 files changed, 12 insertions(+), 69 deletions(-) delete mode 100644 Manifest.toml diff --git a/Manifest.toml b/Manifest.toml deleted file mode 100644 index 0069a85..0000000 --- a/Manifest.toml +++ /dev/null @@ -1,62 +0,0 @@ -# This file is machine-generated - editing it directly is not advised - -julia_version = "1.7.1" -manifest_format = "2.0" - -[[deps.Adapt]] -deps = ["LinearAlgebra"] -git-tree-sha1 = "9faf218ea18c51fcccaf956c8d39614c9d30fe8b" -uuid = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" -version = "3.3.2" - -[[deps.Artifacts]] -uuid = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" - -[[deps.CompilerSupportLibraries_jll]] -deps = ["Artifacts", "Libdl"] -uuid = "e66e0078-7015-5450-92f7-15fbd957f2ae" - -[[deps.Libdl]] -uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" - -[[deps.LinearAlgebra]] -deps = ["Libdl", "libblastrampoline_jll"] -uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" - -[[deps.OffsetArrays]] -deps = ["Adapt"] -git-tree-sha1 = "043017e0bdeff61cfbb7afeb558ab29536bbb5ed" -uuid = "6fe1bfb0-de20-5000-8ca7-80f57d26f881" -version = "1.10.8" - -[[deps.OpenBLAS_jll]] -deps = ["Artifacts", "CompilerSupportLibraries_jll", "Libdl"] -uuid = "4536629a-c528-5b80-bd46-f80d51c5b363" - -[[deps.PaddedViews]] -deps = ["OffsetArrays"] -git-tree-sha1 = "03a7a85b76381a3d04c7a1656039197e70eda03d" -uuid = "5432bcbf-9aad-5242-b902-cca2824c8663" -version = "0.5.11" - -[[deps.Random]] -deps = ["SHA", "Serialization"] -uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" - -[[deps.SHA]] -uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" - -[[deps.Serialization]] -uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" - -[[deps.SparseArrays]] -deps = ["LinearAlgebra", "Random"] -uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" - -[[deps.Statistics]] -deps = ["LinearAlgebra", "SparseArrays"] -uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" - -[[deps.libblastrampoline_jll]] -deps = ["Artifacts", "Libdl", "OpenBLAS_jll"] -uuid = "8e850b90-86db-534c-a0d3-1478176c7d93" diff --git a/Project.toml b/Project.toml index 20090a6..1c400f1 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NDTools" uuid = "98581153-e998-4eef-8d0d-5ec2c052313d" authors = ["Rainer Heintzmann ", "Felix Wechsler "] -version = "0.5.3" +version = "0.6.0" [deps] LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/docs/src/dims.md b/docs/src/dims.md index 2fec2c3..c38a33c 100644 --- a/docs/src/dims.md +++ b/docs/src/dims.md @@ -6,4 +6,5 @@ expand_size select_sizes select_sizes_squeeze reorient +idx_to_dim ``` diff --git a/src/generation_tools.jl b/src/generation_tools.jl index 8d723ac..7771f55 100644 --- a/src/generation_tools.jl +++ b/src/generation_tools.jl @@ -1,5 +1,5 @@ ## generation_tools.jl -export get_scan_pattern, ϕ_tuple, idx_to_dim +export ϕ_tuple, idx_to_dim """ @@ -21,7 +21,7 @@ Arguments: ## conversion_tools.jl """ - idx_to_dim(idx_arr) # this should be a view + idx_to_dim(idx_arr) Converts an N-dimensional array of NTuple to an N+1 dimensional array by orienting the (inner) tuple along the (outer) trailing+1 dimension. @@ -41,7 +41,7 @@ julia> idx_to_dim([(x,y) for x in 1:3, y in 1:3]) 1 2 3 1 2 3 1 2 3 - ``` +``` """ function idx_to_dim(idx_arr::AbstractArray{T, N}) where {T, N} out_arr = Array{typeof(idx_arr[1][1])}(undef, size(idx_arr)..., length(idx_arr[begin])) diff --git a/src/selection_tools.jl b/src/selection_tools.jl index 78e0fba..1d79b3a 100644 --- a/src/selection_tools.jl +++ b/src/selection_tools.jl @@ -448,10 +448,11 @@ function select_region(src::AbstractArray{T,N}; M=nothing, end """ -function select_region(src::AbstractArray{T,N}, new_size; M=nothing, - center=size(src).÷2 .+1, pad_value=zero(eltype(src)), dst_center = new_size .÷ 2 .+1) where {T,N} + select_region(src::AbstractArray{T,N}, new_size; M=nothing, + center=size(src).÷2 .+1, pad_value=zero(eltype(src)), dst_center = new_size .÷ 2 .+1) where {T,N} + -alias to select_region(src; new_size=new_size, center=center, pad_value=pad_value, dst_center=dst_center) +Alias to `select_region(src; new_size=new_size, center=center, pad_value=pad_value, dst_center=dst_center)` """ function select_region(src::AbstractArray{T,N}, new_size; M=nothing, center=size(src).÷2 .+1, pad_value=zero(eltype(src)), dst_center = new_size .÷ 2 .+1) where {T,N} diff --git a/test/selection_tools.jl b/test/selection_tools.jl index 70867b6..138291e 100644 --- a/test/selection_tools.jl +++ b/test/selection_tools.jl @@ -75,6 +75,7 @@ nc = Tuple(rand(1:5) for q in 1:d) pad = rand() @test all(select_region(a,new_size=nsz, center=nc, pad_value=pad) .== select_region(a,new_size=nsz, center=nc, pad_value=pad)) + @test all(select_region(a, nsz, center=nc, pad_value=pad) .== select_region(a,new_size=nsz, center=nc, pad_value=pad)) @test all(select_region(a, nsz; center=nc, pad_value=pad) .== select_region(a,new_size=nsz, center=nc, pad_value=pad)) end end @@ -88,6 +89,7 @@ function f(a,b) a.+=1 end # user-defined function @test all(select_region!(2 .*a, a, operator! = f) .== 2) # let the operator add one to destination @test select_region(collect(1:10), new_size=(5,), center=(1,), dst_center=(1,)) == collect(1:5) + @test select_region_view(collect(1:10), (5,), center=(1,), dst_center=(1,)) == collect(1:5) @test select_region_view(collect(1:10), new_size=(5,), center=(1,), dst_center=(1,)) == collect(1:5) @test select_region_view(collect(1:10), (5,); center=(1,), dst_center=(1,)) == collect(1:5) # test the alias a = ones(10,10) @@ -96,6 +98,7 @@ @test all(a[1:4,1:4] .== 1) # check part of the non-overwritten part a = ones(10,10) b = 4*ones(70,70) + select_region!(b, a, size(a), dst_center=(-20,20)); select_region!(b, a, dst_center=(-20,20)); @test all(a .== 4) # check the automatic selection of a large enough new_size end