Skip to content

Commit 5eba854

Browse files
author
Christopher Doris
committed
add PyArray to migration guide
1 parent 9a11969 commit 5eba854

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

docs/src/v1-migration-guide.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,29 @@ This submodule has been changed to closer mimic the `Base.GC` API.
2121
* Instead of `PythonCall.GC.enable()` use `PythonCall.GC.enable(true)`.
2222
* Instead of `PythonCall.GC.disable()` use `PythonCall.GC.enable(false)`.
2323

24-
## Julia wrappers (JlDict, etc.)
24+
## Python wrappers (`PyArray`, etc.)
25+
26+
`PyArray` has been reparametrised from `PyArray{T,N,L,M,R}` to `PyArray{T,N,F}` where
27+
`F` is a `Tuple` of `Symbol` flags replacing `L` (now `:linear`) and `M`
28+
(now `:mutable`). The `R` parameter (the underlying raw type) is removed and now implied
29+
by `T`.
30+
31+
* Instead of `PyArray{Int,2,true,true,Int}` use `PyArray{Int,2,(:mutable,:linear)}`.
32+
* Instead of `PyArray{Bool,1,false,false,Bool}` use `PyArray{Bool,1,()}`.
33+
* Instead of `PyArray{Py,2,false,false,PythonCall.Wrap.UnsafePyObject}` use `PyArray{Py,2,()}`.
34+
35+
Because the `R` parameter is removed, if the underlying array is of Python objects, the
36+
`PyArray` must have eltype `Py`. Previously you could construct a `PyArray{String}` from
37+
such a thing and the elements would be automatically `pyconvert(String, element)`-ed for
38+
you.
39+
40+
* Instead of `PyArray{String}(x)` use `pyconvert.(String, PyArray{Py}(x))` if you are
41+
OK with taking a copy. Or use `mappedarray(x->pyconvert(String, x), PyArray{Py}(x))`
42+
from [MappedArrays.jl](https://github.com/JuliaArrays/MappedArrays.jl) to emulate the
43+
old behaviour.
44+
* Same comments for `pyconvert(PyArray{String}, x)`.
45+
46+
## Julia wrappers (`JlDict`, etc.)
2547

2648
The wrapper types have been renamed.
2749

0 commit comments

Comments
 (0)