Skip to content

Commit

Permalink
https://github.com/SciML/RecursiveArrayTools.jl/issues/187
Browse files Browse the repository at this point in the history
  • Loading branch information
vpuri3 committed Jan 31, 2022
1 parent e85220f commit bd273d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
14 changes: 0 additions & 14 deletions src/array_partition.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,20 +73,6 @@ Base.ones(A::ArrayPartition, dims::NTuple{N,Int}) where {N} = ones(A)
return :( $res )
end

## vector space operations

for op in (:+, :-)
@eval begin
function Base.$op(A::ArrayPartition, B::Number)
ArrayPartition(map(y->Base.broadcast($op, y, B), A.x))
end

function Base.$op(A::Number, B::ArrayPartition)
ArrayPartition(map(y->Base.broadcast($op, A, y), B.x))
end
end
end

Base.:(==)(A::ArrayPartition,B::ArrayPartition) = A.x == B.x

## Iterable Collection Constructs
Expand Down
10 changes: 6 additions & 4 deletions test/partitions_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,18 @@ x = ArrayPartition([1, 2], [3.0, 4.0])
@inferred ones(x, (2,2))

# vector space calculations
@inferred x+5
@inferred 5+x
@inferred x-5
@inferred 5-x
@inferred x .+ 5
@inferred 5 .+ x
@inferred x .- 5
@inferred 5 .- x
@inferred x*5
@inferred 5*x
@inferred x/5
@inferred 5\x
@inferred x+x
@inferred x-x
@inferred -x
@inferred +x

# indexing
@inferred first(x)
Expand Down

0 comments on commit bd273d3

Please sign in to comment.