Skip to content

Commit

Permalink
Remove at-compat for index styles
Browse files Browse the repository at this point in the history
Was added in #329, now obsolete as no longer required on minimum 
supported Julia version 0.6.
  • Loading branch information
martinholters committed Aug 27, 2018
1 parent 87588a6 commit 89fc03f
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 55 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,13 @@ Currently, the `@compat` macro supports the following syntaxes:
to declare abstract and primitive types. [#20418]
This only works when `@compat` is applied directly on the declaration.

* `@compat Base.IndexStyle(::Type{<:MyArray}) = IndexLinear()` and `@compat Base.IndexStyle(::Type{<:MyArray}) = IndexCartesian()` to define traits for abstract arrays, replacing the former `Base.linearindexing{T<:MyArray}(::Type{T}) = Base.LinearFast()` and `Base.linearindexing{T<:MyArray}(::Type{T}) = Base.LinearSlow()`, respectively.

* `Compat.collect(A)` returns an `Array`, no matter what indices the array `A` has. [#21257]

* `@compat foo(::CartesianRange{N})` to replace the former
`foo(::CartesianRange{CartesianIndex{N}})` ([#20974]). Note that
`CartesianRange` now has two type parameters, so using them as
fields in other `struct`s requires manual intervention.

* Required keyword arguments ([#25830]). For example, `@compat foo(; x, y)` makes `x` and `y` required keyword arguments: when calling `foo`, an error is thrown if `x` or `y` is not explicitly provided.

## Module Aliases
Expand Down
9 changes: 0 additions & 9 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -250,15 +250,6 @@ include("arraymacros.jl")
# julia #18839
import Base.Iterators # TODO deprecate, remove

@static if VERSION < v"0.6.0-dev.2840"
export IndexStyle, IndexLinear, IndexCartesian
eval(Expr(:typealias, :IndexStyle, :(Base.LinearIndexing)))
eval(Expr(:typealias, :IndexLinear, :(Base.LinearFast)))
eval(Expr(:typealias, :IndexCartesian, :(Base.LinearSlow)))
IndexStyle{T}(::Type{T}) = Base.linearindexing(T)
IndexStyle(args...) = Base.linearindexing(args...)
end

if VERSION < v"0.6.0-dev.1653"
for (fname, felt) in ((:zeros,:zero), (:ones,:one))
@eval begin
Expand Down
18 changes: 0 additions & 18 deletions src/compatmacro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ export @compat
"""Get just the function part of a function declaration."""
withincurly(ex) = isexpr(ex, :curly) ? ex.args[1] : ex

is_index_style(ex::Expr) = ex == :(Compat.IndexStyle) || ex == :(Base.IndexStyle) ||
(ex.head == :(.) && (ex.args[1] == :Compat || ex.args[1] == :Base) &&
ex.args[2] == Expr(:quote, :IndexStyle))

is_index_style(arg) = false

istopsymbol(ex, mod, sym) = ex in (sym, Expr(:(.), mod, Expr(:quote, sym)))

if !isdefined(Base, :UndefKeywordError)
Expand Down Expand Up @@ -40,18 +34,6 @@ function _compat(ex::Expr)
# Passthrough
return ex
end
if VERSION < v"0.6.0-dev.2840"
if ex.head == :(=) && isa(ex.args[1], Expr) && ex.args[1].head == :call
a = ex.args[1].args[1]
if is_index_style(a)
ex.args[1].args[1] = :(Base.linearindexing)
elseif isa(a, Expr) && a.head == :curly
if is_index_style(a.args[1])
ex.args[1].args[1].args[1] = :(Base.linearindexing)
end
end
end
end
if VERSION < v"0.7.0-DEV.880"
if ex.head == :curly && ex.args[1] == :CartesianRange && length(ex.args) >= 2
a = ex.args[2]
Expand Down
25 changes: 0 additions & 25 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -434,31 +434,6 @@ end
@test isbitstype(Primitive20418{Int})
@test sizeof(Primitive20418{Int}) == 2

module CompatArray
using Compat
const struct_sym = VERSION < v"0.7.0-DEV.1263" ? :type : :struct
eval(Expr(
struct_sym, false,
Expr(:(<:), :(CartesianArray{T,N}), :(AbstractArray{T,N})),
quote
parent::Array{T,N}
end))
eval(Expr(
struct_sym, false,
Expr(:(<:), :(LinearArray{T,N}), :(AbstractArray{T,N})),
quote
parent::Array{T,N}
end))
@compat Base.IndexStyle(::Type{<:LinearArray}) = IndexLinear()
end
@test IndexStyle(Array{Float32,2}) === IndexLinear()
@test IndexStyle(CompatArray.CartesianArray{Float32,2}) === IndexCartesian()
@test IndexStyle(CompatArray.LinearArray{Float32,2}) === IndexLinear()
let a = CompatArray.CartesianArray(rand(2,3)), b = CompatArray.LinearArray(rand(2,3))
@test IndexStyle(a) === IndexCartesian()
@test IndexStyle(b) === IndexLinear()
end

if VERSION < v"0.6.0-dev.1653"
for (A,val) in ((zeros(1:5, Float32, 3, 2), 0),
(ones(1:5, Float32, 3, 2), 1),
Expand Down

0 comments on commit 89fc03f

Please sign in to comment.