Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Einops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ export einsum
include("pack_unpack.jl")
export pack, unpack

include("String.jl")

end
26 changes: 26 additions & 0 deletions src/String.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const warn_str = "Einops supports `Base.String` patterns for Einops-native functions only for convenience, as using them is type unstable."

function parse_shape(x, pattern::String)
Base.depwarn(warn_str, :parse_shape)
return parse_shape(x, parse_pattern(pattern))
end

function rearrange(x, pattern::String; context...)
Base.depwarn(warn_str, :rearrange)
rearrange(x, parse_pattern(pattern); context...)
end

function _einsum(pattern::String, arrays...; kws...)
Base.depwarn(warn_str, :_einsum)
_einsum(parse_pattern(pattern), arrays...; kws...)
end

function pack(x, pattern::String)
Base.depwarn(warn_str, :pack)
return pack(x, parse_pattern(pattern))
end

function unpack(x, ps, pattern::String)
Base.depwarn(warn_str, :unpack)
return unpack(x, ps, parse_pattern(pattern))
end