Skip to content

Commit

Permalink
Delete mapped(::Broadcasted) in favor of Mapped(::Broadcasted)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtfishman committed Dec 25, 2024
1 parent 89b54db commit 33f0363
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ julia> Pkg.add("BroadcastMapConversion")

````julia
using Base.Broadcast: broadcasted
using BroadcastMapConversion: mapped
using BroadcastMapConversion: Mapped, mapped
using Test: @test

a = randn(2, 2)
bc = broadcasted(*, 2, a)
m = mapped(bc)
m = Mapped(bc)
m′ = mapped(x -> 2x, a)
@test copy(m) map(m.f, m.args...)
@test copy(m) copy(m′)
Expand Down
4 changes: 2 additions & 2 deletions examples/README.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ julia> Pkg.add("BroadcastMapConversion")
# ## Examples

using Base.Broadcast: broadcasted
using BroadcastMapConversion: mapped
using BroadcastMapConversion: Mapped, mapped
using Test: @test

a = randn(2, 2)
bc = broadcasted(*, 2, a)
m = mapped(bc)
m = Mapped(bc)
m′ = mapped(x -> 2x, a)
@test copy(m) map(m.f, m.args...)
@test copy(m) copy(m′)
Expand Down
1 change: 0 additions & 1 deletion src/BroadcastMapConversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ function map_broadcast_to_mapped(bc::Broadcasted)
return Mapped(bc.style, bc.f, bc.args, bc.axes)

Check warning on line 73 in src/BroadcastMapConversion.jl

View check run for this annotation

Codecov / codecov/patch

src/BroadcastMapConversion.jl#L72-L73

Added lines #L72 - L73 were not covered by tests
end

mapped(bc::Broadcasted) = Mapped(bc)
mapped(f, args...) = Mapped(broadcasted(f, args...))

Base.similar(m::Mapped, elt::Type) = similar(Broadcasted(m), elt)
Expand Down
4 changes: 2 additions & 2 deletions test/test_basics.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Base.Broadcast: broadcasted
using BroadcastMapConversion: mapped
using BroadcastMapConversion: Mapped, mapped
using Test: @test, @testset

@testset "BroadcastMapConversion (eltype=$elt)" for elt in (
Expand All @@ -12,7 +12,7 @@ using Test: @test, @testset
(broadcasted(*, c, a), mapped(x -> c * x, a), c * a),
(broadcasted(+, a, broadcasted(*, c, b)), mapped((x, y) -> x + c * y, a, b), a + c * b),
)
m = mapped(bc)
m = Mapped(bc)
@test copy(m) ref
@test copy(m′) ref
@test map(m.f, m.args...) ref
Expand Down

0 comments on commit 33f0363

Please sign in to comment.