@@ -16,7 +16,7 @@ The type parameters are all optional, and are:
16
16
- `N`: The number of dimensions.
17
17
- `M`: True if the array is mutable.
18
18
- `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`.
20
20
"""
21
21
struct PyArray{T,N,M,L,R} <: AbstractArray{T,N}
22
22
ptr:: Ptr{R} # pointer to the data
@@ -39,19 +39,22 @@ export PyArray
39
39
for N in (missing , 1 , 2 )
40
40
for M in (missing , true , false )
41
41
for L in (missing , true , false )
42
+ for R in (true , false )
42
43
name = Symbol (
43
44
" Py" ,
44
45
M === missing ? " " : M ? " Mutable" : " Immutable" ,
45
46
L === missing ? " " : L ? " Linear" : " Cartesian" ,
47
+ R ? " Raw" : " " ,
46
48
N === missing ? " Array" : N == 1 ? " Vector" : " Matrix" ,
47
49
)
48
50
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... )}
51
53
@eval export $ name
52
54
end
53
55
end
54
56
end
57
+ end
55
58
56
59
(:: Type{A} )(x; array:: Bool = true , buffer:: Bool = true , copy:: Bool = true ) where {A<: PyArray } = @autopy x begin
57
60
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
125
128
if R0 == R1
126
129
R = R1
127
130
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")
133
136
else
134
137
R = R′
135
138
end
0 commit comments