Skip to content

Commit 6429367

Browse files
authored
Define tile so it can be overloaded (#2)
1 parent eaf3cb3 commit 6429367

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MapBroadcast"
22
uuid = "ebd9b9da-f48d-417c-9660-449667d60261"
33
authors = ["ITensor developers <[email protected]> and contributors"]
4-
version = "0.1.5"
4+
version = "0.1.6"
55

66
[deps]
77
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"

src/MapBroadcast.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ function promote_shape(ax, args::AbstractArray...)
9898
return promote_shape_tile(ax, args...)
9999
end
100100
function promote_shape_tile(common_axes, args::AbstractArray...)
101-
return map(arg -> tile_to_shape(arg, common_axes), args)
101+
return map(arg -> tile(arg, common_axes), args)
102102
end
103103

104104
using BlockArrays: mortar
@@ -110,8 +110,9 @@ function extend(t::Tuple, value, length)
110110
end
111111

112112
# Handles logic of expanding singleton dimensions
113-
# to match an array shape in broadcasting.
114-
function tile_to_shape(a::AbstractArray, ax)
113+
# to match an array shape in broadcasting
114+
# by tiling or repeating the input array.
115+
function tile(a::AbstractArray, ax)
115116
axes(a) == ax && return a
116117
# Must be one-based for now.
117118
@assert all(isone, first.(ax))

0 commit comments

Comments
 (0)