Skip to content

Commit b7dcb1f

Browse files
author
Christopher Doris
committed
add numpy section
1 parent 6a38f18 commit b7dcb1f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/src/faq.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,27 @@ Currently, Apple silicon is Tier 2, so is not supported.
2424
Due to time constraints, issues affecting only unsupported platforms will not be
2525
investigated. It is much more likely to be an issue with Julia itself than PythonCall.
2626

27+
## Issues when Numpy arrays are expected
28+
29+
When a Julia array is passed to Python, it is wrapped as a [`ArrayValue`](#juliacall.ArrayValue).
30+
This type satisfies the Numpy array interface and the buffer protocol, so can be used in
31+
most places where a numpy array is valid.
32+
33+
However, some Python packages have functions which assume the input is an actual Numpy array.
34+
You may see errors such as:
35+
```
36+
AttributeError: Julia: type Array has no field dtype
37+
```
38+
39+
To fix this you can convert the array `x` to a Numpy array as follows
40+
```julia
41+
Py(x).to_numpy()
42+
```
43+
44+
If the array is being mutated, you will need to pass the argument `copy=false`.
45+
46+
Related issues: [#280](https://github.com/cjdoris/PythonCall.jl/issues/280)
47+
2748
## Heap corruption when using PyTorch
2849

2950
On some systems, you may see an error like the following when using `torch` and `juliacall`:

0 commit comments

Comments
 (0)