Skip to content

Commit e795e12

Browse files
committed
remove the AbstractMap type
1 parent f1da2e3 commit e795e12

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

src/generic/composite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function composedmap2(m1, m2::ComposedMap)
8787
end
8888

8989
# Arguments to ∘ should be reversed before passing on to mapcompose
90-
Base.:(map1::AbstractMap, map2::AbstractMap) = composedmap(map2, map1)
90+
Base.:(map1::Map, map2::Map) = composedmap(map2, map1)
9191

9292

9393
isequalmap(m1::ComposedMap, m2::ComposedMap) =

src/generic/inverse.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ inverse(m) = LazyInverse(m)
2424
inverse(m::LazyInverse) = supermap(m)
2525
# Concrete maps should implement inverse(m, x)
2626

27-
Base.:\(m::AbstractMap, x) = inverse(m, x)
27+
Base.:\(m::Map, x) = inverse(m, x)
2828

2929
implements_inverse(m) = !(inverse(m) isa LazyInverse)
3030

src/generic/map.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11

2-
"An `AbstractMap` represents a function `y=f(x)` of a single variable."
3-
abstract type AbstractMap end
4-
5-
"A `Map{T}` is a map of a single variable of type `T`."
6-
abstract type Map{T} <: AbstractMap end
2+
"""
3+
A `Map{T}` is a map of a single variable of type `T`.
4+
"""
5+
abstract type Map{T} end
76

87
Map(m) = convert(Map, m)
98
Map{T}(m) where {T} = convert(Map{T}, m)
109

11-
"A `TypedMap{T,U}` maps a variable of type `T` to a variable of type `U`."
10+
"""
11+
Any instance of `TypedMap{T,U}` maps a variable of type `T` to a variable
12+
of type `U`.
13+
"""
1214
abstract type TypedMap{T,U} <: Map{T} end
1315

1416
const EuclideanMap{N,T} = Map{<:StaticVector{N,T}}
@@ -43,7 +45,6 @@ numtype(::Type{<:Map{T}}) where T = numtype(T)
4345
isrealmap(m) = isrealtype(domaintype(m)) && isrealtype(codomaintype(m))
4446
isrealmap(::UniformScaling{T}) where {T} = isrealtype(T)
4547

46-
convert(::Type{AbstractMap}, m::AbstractMap) = m
4748
convert(::Type{Map{T}}, m::Map{T}) where {T} = m
4849
convert(::Type{Map{T}}, m::Map{S}) where {S,T} = similarmap(m, T)
4950
convert(::Type{TypedMap{T,U}}, m::TypedMap{T,U}) where {T,U} = m
@@ -83,10 +84,10 @@ convert_codomaintype(::Type{Any}, map) = map
8384

8485

8586
# Users may call a map, concrete subtypes specialize the `applymap` function
86-
(m::AbstractMap)(x) = applymap(m, x)
87-
88-
# For Map{T}, we allow invocation with multiple arguments by conversion to T
87+
# Some effort is spent at this generic level to convert the argument to something
88+
# of type `T`.
8989
(m::Map{T})(x) where {T} = promote_and_apply(m, x)
90+
# For convenience we allow invocation with multiple arguments by conversion to T
9091
(m::Map{T})(x...) where {T} = promote_and_apply(m, convert(T, x))
9192

9293
"Promote map and point to compatible types."
@@ -115,9 +116,8 @@ promote_and_apply(m::Map, x) = applymap(promote_map_point_pair(m,x)...)
115116

116117
applymap!(y, m, x) = y .= m(x)
117118

118-
# Fallback for functions that are not of type AbstractMap
119+
# Fallback for functions that are not of type Map
119120
applymap(m, x) = m(x)
120-
applymap(m::AbstractMap, x) = error("Please implement applymap for map $(m)")
121121

122122

123123
"Can the maps be promoted to a common domain type without throwing an error?"

src/generic/product.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ end
194194

195195
TupleProductMap{T}(maps::Vector) where {T<:Tuple} = TupleProductMap{T}(maps...)
196196
TupleProductMap{T}(maps...) where {T<:Tuple} = TupleProductMap{T}(maps)
197-
function TupleProductMap{T}(maps::NTuple{N,<:AbstractMap}) where {N,T <: Tuple}
197+
function TupleProductMap{T}(maps::NTuple{N,<:Map}) where {N,T <: Tuple}
198198
Tmaps = map((t,d) -> convert(Map{t},d), tuple(T.parameters...), maps)
199199
TupleProductMap{T,typeof(Tmaps)}(Tmaps)
200200
end

src/types/affine.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function diffvolume(m::AbstractAffineMap{T}) where T
4848
ConstantMap{T}(c)
4949
end
5050

51-
islinearmap(m::AbstractMap) = false
51+
islinearmap(m::Map) = false
5252
islinearmap(m::AbstractAffineMap) = _affine_islinearmap(m, unsafe_vector(m))
5353
_affine_islinearmap(m, b) = all(b .== 0)
5454

src/types/basic.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ abstract type ConstantMap{T,U} <: TypedMap{T,U} end
9191

9292
applymap(m::ConstantMap, x) = mapconstant(m)
9393

94-
isconstantmap(m::AbstractMap) = false
94+
isconstantmap(m::Map) = false
9595
isconstantmap(m::ConstantMap) = true
9696

9797
isrealmap(m::ConstantMap{T,U}) where {T,U} =

0 commit comments

Comments
 (0)