-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Julia 0.6 rewrite #121
Julia 0.6 rewrite #121
Changes from all commits
bff627a
a1eab92
4773d4c
28f405a
ed6fb3b
0f3494b
003c40f
a0d6658
5ebaf5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
julia 0.5 | ||
Compat 0.19.0 | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# `Start` and `End` should be `Int` | ||
struct SUnitRange{Start,End} <: StaticVector{Int} | ||
end | ||
|
||
@pure Size(::SUnitRange{Start, End}) where {Start,End} = Size(End-Start+1) | ||
|
||
@pure @propagate_inbounds function getindex(x::SUnitRange{Start,End}, i::Int) where {Start, End} | ||
@boundscheck if i < Start || i > End | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a vague memory that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe worth looking into. Though I thought this pattern was used throughout There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is, but I think it's usually written as @boundscheck checkbounds(A, i) or something. IIRC I had problems when the expression given to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it looks like you've defined a static version of what I'm calling an If that's not what you're intending, you should be checking against There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha thanks @timholy - these definitely are WIP. I think I'll split this off and put it on a branch for now. These are just meant to be singleton array types, so that I suppose that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IdentityRanges are indeed a generalization of |
||
throw(BoundsError(x, i)) | ||
end | ||
return i | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,9 +6,15 @@ Construct a statically-sized 0-dimensional array that contains a single element, | |
""" | ||
immutable Scalar{T} <: StaticArray{T,0} | ||
data::T | ||
|
||
Scalar{T}(x::AbstractArray) where {T} = new{T}(convert(T,x)) | ||
Scalar{T}(x::Tuple{T2}) where {T, T2} = new{T}(convert(T,x[1])) | ||
Scalar{T}(x) where {T} = new{T}(convert(T, x)) | ||
end | ||
|
||
@inline (::Type{Scalar{T}}){T}(x::Tuple{T}) = Scalar{T}(x[1]) | ||
@inline Scalar(x::Tuple{T}) where {T} = Scalar{T}(x[1]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this indexing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The abstract constructors will go |
||
@inline Scalar(a::AbstractArray) = Scalar{typeof(a)}(a) | ||
@inline Scalar(a::AbstractScalar) = Scalar{eltype(a)}(a[]) # Do we want this to convert or wrap? | ||
|
||
@pure Size(::Type{Scalar}) = Size() | ||
@pure Size{T}(::Type{Scalar{T}}) = Size() | ||
|
@@ -24,4 +30,4 @@ end | |
@inline Tuple(v::Scalar) = (v.data,) | ||
|
||
# A lot more compact than the default array show | ||
Base.show{T}(io::IO, ::MIME"text/plain", x::Scalar{T}) = print(io, "Scalar{$T}(", x.data, ")") | ||
Base.show(io::IO, ::MIME"text/plain", x::Scalar{T}) where {T} = print(io, "Scalar{$T}(", x.data, ")") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@compat
is still used intest/fixed_size_arrays.jl
, though it looks like that's now dead codeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that file is not deleted because I think Simon Danisch will revive it sometime