|
| 1 | +module PyArrays |
| 2 | + |
| 3 | +using ...PythonCall |
| 4 | +using ...Utils |
| 5 | +using ...C |
| 6 | +using ...Core |
| 7 | +using ...Convert |
| 8 | + |
| 9 | +using Base: @propagate_inbounds |
| 10 | + |
| 11 | +import ...PythonCall: PyArray, ispy, Py |
| 12 | + |
| 13 | + |
1 | 14 | struct UnsafePyObject |
2 | 15 | ptr::C.PyPtr |
3 | 16 | end |
@@ -670,3 +683,23 @@ function pyarray_check_T(::Type{T}, ::Type{R}) where {T,R} |
670 | 683 | error("invalid eltype T=$T for raw eltype R=$R") |
671 | 684 | end |
672 | 685 | end |
| 686 | + |
| 687 | +function __init__() |
| 688 | + priority = PYCONVERT_PRIORITY_ARRAY |
| 689 | + pyconvert_add_rule("<arraystruct>", PyArray, pyconvert_rule_array_nocopy, priority) |
| 690 | + pyconvert_add_rule("<arrayinterface>", PyArray, pyconvert_rule_array_nocopy, priority) |
| 691 | + pyconvert_add_rule("<array>", PyArray, pyconvert_rule_array_nocopy, priority) |
| 692 | + pyconvert_add_rule("<buffer>", PyArray, pyconvert_rule_array_nocopy, priority) |
| 693 | + |
| 694 | + priority = PYCONVERT_PRIORITY_NORMAL |
| 695 | + pyconvert_add_rule("<arraystruct>", Array, pyconvert_rule_array, priority) |
| 696 | + pyconvert_add_rule("<arrayinterface>", Array, pyconvert_rule_array, priority) |
| 697 | + pyconvert_add_rule("<array>", Array, pyconvert_rule_array, priority) |
| 698 | + pyconvert_add_rule("<buffer>", Array, pyconvert_rule_array, priority) |
| 699 | + pyconvert_add_rule("<arraystruct>", AbstractArray, pyconvert_rule_array, priority) |
| 700 | + pyconvert_add_rule("<arrayinterface>", AbstractArray, pyconvert_rule_array, priority) |
| 701 | + pyconvert_add_rule("<array>", AbstractArray, pyconvert_rule_array, priority) |
| 702 | + pyconvert_add_rule("<buffer>", AbstractArray, pyconvert_rule_array, priority) |
| 703 | +end |
| 704 | + |
| 705 | +end |
0 commit comments