Skip to content
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

Add compatibility for view #238

Merged
merged 6 commits into from
Jun 28, 2016
Merged
Show file tree
Hide file tree
Changes from 5 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `write(::IO, ::Ptr, len)` is now `unsafe_write` [#14766](https://github.com/JuliaLang/julia/pull/14766).

* `slice` is now `view`: do `import Compat.view` and then use `view` normally without the `@compat` macro.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reference the julia PR - I think it was by @simonbyrne if that helps find it faster

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this: JuliaLang/julia#16972


## New macros

* `@static` has been added [#16219](https://github.com/JuliaLang/julia/pull/16219).
Expand Down
4 changes: 4 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,10 @@ else
end
end

if !isdefined(Base, :view)
const view = slice
Copy link
Contributor

@yuyichao yuyichao Jun 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this not exported for ArrayViews compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

end

if !isdefined(Base, :pointer_to_string)

function pointer_to_string(p::Ptr{UInt8}, len::Integer, own::Bool=false)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Compat
import Compat.String
import Compat.view
@compat import Base.show
using Base.Test

Expand Down Expand Up @@ -1242,3 +1243,8 @@ end
@test allunique(1:3)
@test allunique(FloatRange(0.0, 0.0, 0.0, 1.0))
@test !allunique(FloatRange(0.0, 0.0, 2.0, 1.0))

# Add test for Base.view
let a = rand(10,10)
@test view(a, :, 1) == a[:,1]
end