@@ -10,10 +10,33 @@ use npyffi::*;
10
10
pub ( crate ) const MOD_NAME : & str = "numpy.core.multiarray" ;
11
11
const CAPSULE_NAME : & str = "_ARRAY_API" ;
12
12
13
+ /// A global variable which stores a ['capsule'](https://docs.python.org/3/c-api/capsule.html)
14
+ /// pointer to [Numpy Array API](https://docs.scipy.org/doc/numpy/reference/c-api.array.html).
15
+ ///
16
+ /// You can acceess raw c APIs via this variable and its Deref implementation.
17
+ ///
18
+ /// See [PyArrayAPI](struct.PyArrayAPI.html) for what methods you can use via this variable.
19
+ ///
20
+ /// # Example
21
+ /// ```
22
+ /// # extern crate pyo3; extern crate numpy; fn main() {
23
+ /// use numpy::{PyArray, npyffi::types::NPY_SORTKIND, PY_ARRAY_API};
24
+ /// use pyo3::Python;
25
+ /// let gil = Python::acquire_gil();
26
+ /// let array: &PyArray<i32> = PyArray::arange(gil.python(), 2.0, 5.0, 1.0);
27
+ /// array.as_slice_mut().unwrap().swap(0, 1);
28
+ /// assert_eq!(array.as_slice().unwrap(), &[3, 2, 4]);
29
+ /// unsafe {
30
+ /// PY_ARRAY_API.PyArray_Sort(array.as_array_ptr(), 0, NPY_SORTKIND::NPY_QUICKSORT);
31
+ /// }
32
+ /// assert_eq!(array.as_slice().unwrap(), &[2, 3, 4])
33
+ /// # }
34
+ /// ```
13
35
pub static PY_ARRAY_API : PyArrayAPI = PyArrayAPI {
14
36
__private_field : ( ) ,
15
37
} ;
16
38
39
+ ///
17
40
pub struct PyArrayAPI {
18
41
__private_field : ( ) ,
19
42
}
@@ -33,7 +56,6 @@ impl Deref for PyArrayAPI {
33
56
}
34
57
35
58
#[ allow( non_camel_case_types) ]
36
- #[ doc( hidden) ]
37
59
pub struct PyArrayAPI_Inner ( * const * const c_void ) ;
38
60
39
61
impl PyArrayAPI_Inner {
0 commit comments