Skip to content

Commit

Permalink
better reorder
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaqz committed Oct 22, 2023
1 parent ceecf8b commit 6a87ffb
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/Documenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
with:
cache-registries: "true"
- name: Install documentation dependencies
run: julia --project=docs -e 'using Pkg; pkg"dev ."; Pkg.instantiate()'
run: julia --project=docs -e 'using Pkg; pkg"dev ."; pkg"dev BaseInterfaces"; Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # For authentication with GitHub Actions token
Expand All @@ -32,4 +32,4 @@ jobs:
DATADEPS_ALWAYS_ACCEPT: true
run: |
julia --code-coverage=user --project=docs/ --color=yes docs/genfiles.jl
julia --code-coverage=user --project=docs/ --color=yes docs/make.jl
julia --code-coverage=user --project=docs/ --color=yes docs/make.jl
3 changes: 2 additions & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ reorder(dim::Dimension, ot::Type{<:Order}) =
_reorder(x, orderdims::DimTuple) = _reorder(reorder(x, orderdims[1]), tail(orderdims))
_reorder(x, orderdims::Tuple{}) = x

reorder(x, orderdim::Dimension) = _reorder(val(orderdim), x, dims(x, orderdim))
reorder(x, orderdim::Dimension{<:Order}) = _reorder(val(orderdim), x, dims(x, orderdim))
reorder(x, orderdim::Dimension{<:LookupArray}) = _reorder(order(orderdim), x, dims(x, orderdim))

_reorder(neworder::Order, x, dim::Dimension) = _reorder(basetypeof(neworder), x, dim)
# Reverse the dimension index
Expand Down
7 changes: 7 additions & 0 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ end
d = reorder(dims(da, Y), ForwardOrdered())
@test order(d) isa ForwardOrdered
@test index(d) == 100:100:300

# reorder with dimension lookups
rev = reverse(da, dims=Y)
reo = reorder(rev, dims(da))
@test rev != da
@test reo == da
@test dims(reo) == dims(da)
end

@testset "modify" begin
Expand Down

0 comments on commit 6a87ffb

Please sign in to comment.