From 5100bd6695fbd84dff1ebf75759eed605515d0ee Mon Sep 17 00:00:00 2001 From: Yichao Yu Date: Sun, 20 Sep 2015 00:26:39 -0400 Subject: [PATCH] Union() -> Union{} --- src/PyCall.jl | 6 +++--- src/conversions.jl | 4 ++-- src/numpy.jl | 2 +- src/pybuffer.jl | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/PyCall.jl b/src/PyCall.jl index 6c2f47fa..4285303c 100644 --- a/src/PyCall.jl +++ b/src/PyCall.jl @@ -103,7 +103,7 @@ end pyisinstance(o::PyObject, t::PyObject) = t.o != C_NULL && ccall((@pysym :PyObject_IsInstance), Cint, (PyPtr,PyPtr), o, t.o) == 1 -pyisinstance(o::PyObject, t::Union(Ptr{Void},PyPtr)) = +@compat pyisinstance(o::PyObject, t::Union{Ptr{Void},PyPtr}) = t != C_NULL && ccall((@pysym :PyObject_IsInstance), Cint, (PyPtr,PyPtr), o, t) == 1 pyquery(q::Ptr{Void}, o::PyObject) = @@ -374,9 +374,9 @@ end ######################################################################### -typealias TypeTuple{N} Union(Type,NTuple{N, Type}) +@compat typealias TypeTuple{N} Union{Type,NTuple{N, Type}} -function pycall(o::Union(PyObject,PyPtr), returntype::TypeTuple, args...; kwargs...) +@compat function pycall(o::Union{PyObject,PyPtr}, returntype::TypeTuple, args...; kwargs...) oargs = map(PyObject, args) nargs = length(args) sigatomic_begin() diff --git a/src/conversions.jl b/src/conversions.jl index e0ddb225..c1b104b3 100644 --- a/src/conversions.jl +++ b/src/conversions.jl @@ -32,7 +32,7 @@ convert{T<:Integer}(::Type{T}, po::PyObject) = convert(T, @pycheck ccall(@pysym(PyInt_AsSsize_t), Int, (PyPtr,), asscalar(po))) if WORD_SIZE == 32 - convert{T<:Union(Int64,UInt64)}(::Type{T}, po::PyObject) = + @compat convert{T<:Union{Int64,UInt64}}(::Type{T}, po::PyObject) = @pycheck ccall((@pysym :PyLong_AsLongLong), T, (PyPtr,), asscalar(po)) end @@ -159,7 +159,7 @@ pyptr_query(po::PyObject) = pyisinstance(po, c_void_p_Type) || pyisinstance(po, # I want to use a union, but this seems to confuse Julia's method # dispatch for the convert function in some circumstances -# typealias PyAny Union(PyObject, Int, Bool, Float64, Complex128, AbstractString, Function, Dict, Tuple, Array) +# typealias PyAny Union{PyObject, Int, Bool, Float64, Complex128, AbstractString, Function, Dict, Tuple, Array} abstract PyAny if VERSION < v"0.4.0-dev+4319" # prior to 0.4 tuple-type changes diff --git a/src/numpy.jl b/src/numpy.jl index bb4bc678..86846e1a 100644 --- a/src/numpy.jl +++ b/src/numpy.jl @@ -162,7 +162,7 @@ npy_type(::Type{Complex64}) = NPY_CFLOAT npy_type(::Type{Complex128}) = NPY_CDOUBLE npy_type(::Type{PyPtr}) = NPY_OBJECT -typealias NPY_TYPES Union(Bool,Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64,Float32,Float64,Complex64,Complex128,PyPtr) +@compat typealias NPY_TYPES Union{Bool,Int8,UInt8,Int16,UInt16,Int32,UInt32,Int64,UInt64,Float32,Float64,Complex64,Complex128,PyPtr} # conversions from __array_interface__ type strings to supported Julia types const npy_typestrs = @compat Dict( "b1"=>Bool, diff --git a/src/pybuffer.jl b/src/pybuffer.jl index 59c6a020..10dfbd0f 100644 --- a/src/pybuffer.jl +++ b/src/pybuffer.jl @@ -85,7 +85,7 @@ function Base.stride(b::PyBuffer, d::Integer) return @compat Int(unsafe_load(b.buf.strides, d)) end -iscontiguous(b::PyBuffer) = +iscontiguous(b::PyBuffer) = 1 == ccall((@pysym :PyBuffer_IsContiguous), Cint, (Ptr{PyBuffer}, Cchar), &b, 'A') @@ -103,14 +103,14 @@ const PyBUF_ANY_CONTIGUOUS = convert(Cint, 0x0080) | PyBUF_STRIDES const PyBUF_INDIRECT = convert(Cint, 0x0100) | PyBUF_STRIDES # construct a PyBuffer from a PyObject, if possible -function PyBuffer(o::Union(PyObject,PyPtr), flags=PyBUF_SIMPLE) +@compat function PyBuffer(o::Union{PyObject,PyPtr}, flags=PyBUF_SIMPLE) b = PyBuffer() @pycheckz ccall((@pysym :PyObject_GetBuffer), Cint, (PyPtr, Ptr{PyBuffer}, Cint), o, &b, flags) return b end -############################################################################# +############################################################################# # recursive function to write buffer dimension by dimension, starting at # dimension d with the given pointer offset (in bytes).