Skip to content

Commit

Permalink
Fix small things
Browse files Browse the repository at this point in the history
  • Loading branch information
roflmaostc committed Mar 31, 2024
1 parent be5dba4 commit 3d33774
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 69 deletions.
62 changes: 0 additions & 62 deletions Manifest.toml

This file was deleted.

2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NDTools"
uuid = "98581153-e998-4eef-8d0d-5ec2c052313d"
authors = ["Rainer Heintzmann <[email protected]>", "Felix Wechsler <[email protected]>"]
version = "0.5.3"
version = "0.6.0"

[deps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Expand Down
1 change: 1 addition & 0 deletions docs/src/dims.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ expand_size
select_sizes
select_sizes_squeeze
reorient
idx_to_dim
```
6 changes: 3 additions & 3 deletions src/generation_tools.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## generation_tools.jl
export get_scan_pattern, ϕ_tuple, idx_to_dim
export ϕ_tuple, idx_to_dim


"""
Expand All @@ -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.
Expand All @@ -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]))
Expand Down
7 changes: 4 additions & 3 deletions src/selection_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
3 changes: 3 additions & 0 deletions test/selection_tools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down

2 comments on commit 3d33774

@roflmaostc
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/103946

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.0 -m "<description of version>" 3d33774b23175ff5b1050b0770dfaa9f5e88a3ad
git push origin v0.6.0

Please sign in to comment.