@@ -16,7 +16,7 @@ The type parameters are all optional, and are:
1616- `N`: The number of dimensions.
1717- `M`: True if the array is mutable.
1818- `L`: True if the array supports fast linear indexing.
19- - `R`: The element type of the underlying buffer. Equal to `T` for scalar numeric types .
19+ - `R`: The element type of the underlying buffer. Often equal to `T`.
2020"""
2121struct PyArray{T,N,M,L,R} <: AbstractArray{T,N}
2222 ptr:: Ptr{R} # pointer to the data
@@ -39,19 +39,22 @@ export PyArray
3939for N in (missing , 1 , 2 )
4040 for M in (missing , true , false )
4141 for L in (missing , true , false )
42+ for R in (true , false )
4243 name = Symbol (
4344 " Py" ,
4445 M === missing ? " " : M ? " Mutable" : " Immutable" ,
4546 L === missing ? " " : L ? " Linear" : " Cartesian" ,
47+ R ? " Raw" : " " ,
4648 N === missing ? " Array" : N == 1 ? " Vector" : " Matrix" ,
4749 )
4850 name == :PyArray && continue
49- vars = Any[:T , N=== missing ? :N : N, M=== missing ? :M : M, L=== missing ? :L : L, :R ]
50- @eval const $ name{$ ([v for v in vars if v isa Symbol]. .. )} = PyArray{$ (vars... )}
51+ vars = Any[:T , N=== missing ? :N : N, M=== missing ? :M : M, L=== missing ? :L : L, R ? :T : :R ]
52+ @eval const $ name{$ (unique ( [v for v in vars if v isa Symbol]) ... )} = PyArray{$ (vars... )}
5153 @eval export $ name
5254 end
5355 end
5456end
57+ end
5558
5659(:: Type{A} )(x; array:: Bool = true , buffer:: Bool = true , copy:: Bool = true ) where {A<: PyArray } = @autopy x begin
5760 r = pyarray_make (A, x_, array= array, buffer= buffer, copy= copy)
@@ -125,11 +128,11 @@ function pyarray_make(::Type{A}, x::Py, info::PyArraySource, ::Type{PyArray{T0,N
125128 if R0 == R1
126129 R = R1
127130 R == R′ || error (" incorrect R, got $R , should be $R′ " )
128- elseif T0 == T1 && T1 in (Bool, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Float16, Float32, Float64, ComplexF16, ComplexF32, ComplexF64)
129- R = T1
130- R == R′ || error (" incorrect R, got $R , should be $R′ " )
131- R <: R1 || error (" R out of bounds, got $R , should be <: $R1 " )
132- R >: R0 || error (" R out of bounds, got $R , should be >: $R0 " )
131+ # elseif T0 == T1 && T1 in (Bool, Int8, Int16, Int32, Int64, Int128, UInt8, UInt16, UInt32, UInt64, UInt128, Float16, Float32, Float64, ComplexF16, ComplexF32, ComplexF64)
132+ # R = T1
133+ # R == R′ || error("incorrect R, got $R, should be $R′")
134+ # R <: R1 || error("R out of bounds, got $R, should be <: $R1")
135+ # R >: R0 || error("R out of bounds, got $R, should be >: $R0")
133136 else
134137 R = R′
135138 end
0 commit comments