@@ -17,7 +17,7 @@ use std::{iter::ExactSizeIterator, marker::PhantomData};
17
17
use crate :: convert:: { ArrayExt , IntoPyArray , NpyIndex , ToNpyDims , ToPyArray } ;
18
18
use crate :: dtype:: { DataType , Element } ;
19
19
use crate :: error:: { FromVecError , NotContiguousError , ShapeError } ;
20
- use crate :: owner :: Owner ;
20
+ use crate :: slice_container :: PySliceContainer ;
21
21
22
22
/// A safe, static-typed interface for
23
23
/// [NumPy ndarray](https://numpy.org/doc/stable/reference/arrays.ndarray.html).
@@ -447,7 +447,7 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
447
447
dims : ID ,
448
448
strides : * const npy_intp ,
449
449
data_ptr : * const T ,
450
- owner : * mut PyAny ,
450
+ container : * mut PyAny ,
451
451
) -> & ' py Self
452
452
where
453
453
ID : IntoDimension < Dim = D > ,
@@ -467,36 +467,36 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
467
467
468
468
PY_ARRAY_API . PyArray_SetBaseObject (
469
469
ptr as * mut npyffi:: PyArrayObject ,
470
- owner as * mut ffi:: PyObject ,
470
+ container as * mut ffi:: PyObject ,
471
471
) ;
472
472
473
473
Self :: from_owned_ptr ( py, ptr)
474
474
}
475
475
476
- pub ( crate ) unsafe fn from_raw_parts < ' py , ID , O > (
476
+ pub ( crate ) unsafe fn from_raw_parts < ' py , ID , C > (
477
477
py : Python < ' py > ,
478
478
dims : ID ,
479
479
strides : * const npy_intp ,
480
480
data_ptr : * const T ,
481
- owner : O ,
481
+ container : C ,
482
482
) -> & ' py Self
483
483
where
484
484
ID : IntoDimension < Dim = D > ,
485
- Owner : From < O > ,
485
+ PySliceContainer : From < C > ,
486
486
{
487
- let owner = pyo3:: PyClassInitializer :: from ( Owner :: from ( owner ) )
487
+ let container = pyo3:: PyClassInitializer :: from ( PySliceContainer :: from ( container ) )
488
488
. create_cell ( py)
489
489
. expect ( "Object creation failed." ) ;
490
490
491
- Self :: new_with_data ( py, dims, strides, data_ptr, owner as * mut PyAny )
491
+ Self :: new_with_data ( py, dims, strides, data_ptr, container as * mut PyAny )
492
492
}
493
493
494
- /// Creates a NumPy array backed by `array` and ties its ownership to the Python object `owner `.
494
+ /// Creates a NumPy array backed by `array` and ties its ownership to the Python object `container `.
495
495
///
496
496
/// # Safety
497
497
///
498
- /// `owner ` is set as a base object of the returned array which must not be dropped until `owner ` is dropped.
499
- /// Furthermore, `array` must not be reallocated from the time this method is called and until `owner ` is dropped.
498
+ /// `container ` is set as a base object of the returned array which must not be dropped until `container ` is dropped.
499
+ /// Furthermore, `array` must not be reallocated from the time this method is called and until `container ` is dropped.
500
500
///
501
501
/// # Example
502
502
///
@@ -521,21 +521,26 @@ impl<T: Element, D: Dimension> PyArray<T, D> {
521
521
/// }
522
522
/// }
523
523
/// ```
524
- pub unsafe fn borrow_from_array < ' py , S > ( array : & ArrayBase < S , D > , owner : & ' py PyAny ) -> & ' py Self
524
+ pub unsafe fn borrow_from_array < ' py , S > (
525
+ array : & ArrayBase < S , D > ,
526
+ container : & ' py PyAny ,
527
+ ) -> & ' py Self
525
528
where
526
529
S : Data < Elem = T > ,
527
530
{
528
531
let ( strides, dims) = ( array. npy_strides ( ) , array. raw_dim ( ) ) ;
529
532
let data_ptr = array. as_ptr ( ) ;
530
533
531
- mem:: forget ( owner. to_object ( owner. py ( ) ) ) ;
534
+ let py = container. py ( ) ;
535
+
536
+ mem:: forget ( container. to_object ( py) ) ;
532
537
533
538
Self :: new_with_data (
534
- owner . py ( ) ,
539
+ py ,
535
540
dims,
536
541
strides. as_ptr ( ) ,
537
542
data_ptr,
538
- owner as * const PyAny as * mut PyAny ,
543
+ container as * const PyAny as * mut PyAny ,
539
544
)
540
545
}
541
546
0 commit comments