Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 6327143

Browse files
committed
or/and to any/all
1 parent 7a6183b commit 6327143

File tree

2 files changed

+3
-44
lines changed

2 files changed

+3
-44
lines changed

src/boundary_padded_arrays.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function compose(padded_arrays::BoundaryPaddedArray...)
6363
for D in Ds
6464
length(setdiff(Ds, D)) < N || throw(ArgumentError("There are multiple Arrays that extend along dimension $D - make sure every dimension has a unique extension"))
6565
end
66-
or(fill(padded_arrays[1].u, (length(padded_arrays),)) .== getfield.(padded_arrays, :u)) || throw(ArgumentError("The padded_arrays do not all extend the same u!"))
66+
any(fill(padded_arrays[1].u, (length(padded_arrays),)) .== getfield.(padded_arrays, :u)) || throw(ArgumentError("The padded_arrays do not all extend the same u!"))
6767
padded_arrays = padded_arrays[sortperm([Ds...])]
6868
lower = [padded_array.lower for padded_array in padded_arrays]
6969
upper = [padded_array.upper for padded_array in padded_arrays]
@@ -137,14 +137,14 @@ function Base.getindex(Q::ComposedBoundaryPaddedArray{T, N, M, V, B} , inds::Var
137137
for (dim, index) in enumerate(inds)
138138
if index == 1
139139
_inds = inds[setdiff(1:N, dim)]
140-
if (1 _inds) | or(S[setdiff(1:N, dim)] .== _inds)
140+
if (1 _inds) | any(S[setdiff(1:N, dim)] .== _inds)
141141
return zero(T)
142142
else
143143
return Q.lower[dim][(_inds.-1)...]
144144
end
145145
elseif index == S[dim]
146146
_inds = inds[setdiff(1:N, dim)]
147-
if (1 _inds) | or(S[setdiff(1:N, dim)] .== _inds)
147+
if (1 _inds) | any(S[setdiff(1:N, dim)] .== _inds)
148148
return zero(T)
149149
else
150150
return Q.upper[dim][(_inds.-1)...]

src/utils.jl

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,3 @@
1-
"""
2-
Efficiently reduce a BitArray with or (|)
3-
"""
4-
function or(B::BitArray)
5-
for b in B
6-
if b
7-
return true
8-
end
9-
end
10-
return false
11-
end
12-
13-
function or(B::NTuple{N,Bool}) where N
14-
for b in B
15-
if b
16-
return true
17-
end
18-
end
19-
return false
20-
end
21-
22-
"""
23-
Efficiently reduce a BitArray with and (&)
24-
"""
25-
function and(B::BitArray)
26-
for b in B
27-
if !b
28-
return false
29-
end
30-
end
31-
return true
32-
end
33-
34-
function and(B::NTuple{N, Bool}) where N
35-
for b in B
36-
if !b
37-
return false
38-
end
39-
end
40-
return true
41-
end
421

432
"""
443
A function that creates a tuple of CartesianIndices of unit length and `N` dimensions, one pointing along each dimension

0 commit comments

Comments
 (0)