13
13
#![ warn( missing_docs) ]
14
14
15
15
use numpy:: { IntoPyArray , PyArray1 , PyArray2 , PyReadonlyArray1 , PyReadonlyArray2 } ;
16
- use pyo3:: prelude:: { pymodule, PyModule , PyResult , Python } ;
16
+ use pyo3:: prelude:: { pymodule, Bound , PyModule , PyResult , Python } ;
17
17
18
18
use field:: { summator, summator_fourier, summator_incompr} ;
19
19
use krige:: { calculator_field_krige, calculator_field_krige_and_variance} ;
@@ -27,7 +27,7 @@ mod short_vec;
27
27
pub mod variogram;
28
28
29
29
#[ pymodule]
30
- fn gstools_core ( _py : Python < ' _ > , m : & PyModule ) -> PyResult < ( ) > {
30
+ fn gstools_core ( _py : Python < ' _ > , m : & Bound < ' _ , PyModule > ) -> PyResult < ( ) > {
31
31
m. add ( "__version__" , env ! ( "CARGO_PKG_VERSION" ) ) ?;
32
32
33
33
#[ pyfn( m) ]
@@ -39,12 +39,12 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
39
39
z2 : PyReadonlyArray1 < f64 > ,
40
40
pos : PyReadonlyArray2 < f64 > ,
41
41
num_threads : Option < usize > ,
42
- ) -> & ' py PyArray1 < f64 > {
42
+ ) -> Bound < ' py , PyArray1 < f64 > > {
43
43
let cov_samples = cov_samples. as_array ( ) ;
44
44
let z1 = z1. as_array ( ) ;
45
45
let z2 = z2. as_array ( ) ;
46
46
let pos = pos. as_array ( ) ;
47
- summator ( cov_samples, z1, z2, pos, num_threads) . into_pyarray ( py)
47
+ summator ( cov_samples, z1, z2, pos, num_threads) . into_pyarray_bound ( py)
48
48
}
49
49
50
50
#[ pyfn( m) ]
@@ -56,12 +56,12 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
56
56
z2 : PyReadonlyArray1 < f64 > ,
57
57
pos : PyReadonlyArray2 < f64 > ,
58
58
num_threads : Option < usize > ,
59
- ) -> & ' py PyArray2 < f64 > {
59
+ ) -> Bound < ' py , PyArray2 < f64 > > {
60
60
let cov_samples = cov_samples. as_array ( ) ;
61
61
let z1 = z1. as_array ( ) ;
62
62
let z2 = z2. as_array ( ) ;
63
63
let pos = pos. as_array ( ) ;
64
- summator_incompr ( cov_samples, z1, z2, pos, num_threads) . into_pyarray ( py)
64
+ summator_incompr ( cov_samples, z1, z2, pos, num_threads) . into_pyarray_bound ( py)
65
65
}
66
66
67
67
#[ pyfn( m) ]
@@ -74,13 +74,13 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
74
74
z2 : PyReadonlyArray1 < f64 > ,
75
75
pos : PyReadonlyArray2 < f64 > ,
76
76
num_threads : Option < usize > ,
77
- ) -> & ' py PyArray1 < f64 > {
77
+ ) -> Bound < ' py , PyArray1 < f64 > > {
78
78
let spectrum_factor = spectrum_factor. as_array ( ) ;
79
79
let modes = modes. as_array ( ) ;
80
80
let z1 = z1. as_array ( ) ;
81
81
let z2 = z2. as_array ( ) ;
82
82
let pos = pos. as_array ( ) ;
83
- summator_fourier ( spectrum_factor, modes, z1, z2, pos, num_threads) . into_pyarray ( py)
83
+ summator_fourier ( spectrum_factor, modes, z1, z2, pos, num_threads) . into_pyarray_bound ( py)
84
84
}
85
85
86
86
#[ pyfn( m) ]
@@ -91,14 +91,14 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
91
91
krig_vecs : PyReadonlyArray2 < f64 > ,
92
92
cond : PyReadonlyArray1 < f64 > ,
93
93
num_threads : Option < usize > ,
94
- ) -> ( & ' py PyArray1 < f64 > , & ' py PyArray1 < f64 > ) {
94
+ ) -> ( Bound < ' py , PyArray1 < f64 > > , Bound < ' py , PyArray1 < f64 > > ) {
95
95
let krige_mat = krige_mat. as_array ( ) ;
96
96
let krig_vecs = krig_vecs. as_array ( ) ;
97
97
let cond = cond. as_array ( ) ;
98
98
let ( field, error) =
99
99
calculator_field_krige_and_variance ( krige_mat, krig_vecs, cond, num_threads) ;
100
- let field = field. into_pyarray ( py) ;
101
- let error = error. into_pyarray ( py) ;
100
+ let field = field. into_pyarray_bound ( py) ;
101
+ let error = error. into_pyarray_bound ( py) ;
102
102
( field, error)
103
103
}
104
104
@@ -110,11 +110,11 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
110
110
krig_vecs : PyReadonlyArray2 < f64 > ,
111
111
cond : PyReadonlyArray1 < f64 > ,
112
112
num_threads : Option < usize > ,
113
- ) -> & ' py PyArray1 < f64 > {
113
+ ) -> Bound < ' py , PyArray1 < f64 > > {
114
114
let krige_mat = krige_mat. as_array ( ) ;
115
115
let krig_vecs = krig_vecs. as_array ( ) ;
116
116
let cond = cond. as_array ( ) ;
117
- calculator_field_krige ( krige_mat, krig_vecs, cond, num_threads) . into_pyarray ( py)
117
+ calculator_field_krige ( krige_mat, krig_vecs, cond, num_threads) . into_pyarray_bound ( py)
118
118
}
119
119
120
120
#[ pyfn( m) ]
@@ -124,10 +124,10 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
124
124
f : PyReadonlyArray2 < f64 > ,
125
125
estimator_type : Option < char > ,
126
126
num_threads : Option < usize > ,
127
- ) -> & ' py PyArray1 < f64 > {
127
+ ) -> Bound < ' py , PyArray1 < f64 > > {
128
128
let f = f. as_array ( ) ;
129
129
let estimator_type = estimator_type. unwrap_or ( 'm' ) ;
130
- variogram_structured ( f, estimator_type, num_threads) . into_pyarray ( py)
130
+ variogram_structured ( f, estimator_type, num_threads) . into_pyarray_bound ( py)
131
131
}
132
132
133
133
#[ pyfn( m) ]
@@ -138,11 +138,11 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
138
138
mask : PyReadonlyArray2 < bool > ,
139
139
estimator_type : Option < char > ,
140
140
num_threads : Option < usize > ,
141
- ) -> & ' py PyArray1 < f64 > {
141
+ ) -> Bound < ' py , PyArray1 < f64 > > {
142
142
let f = f. as_array ( ) ;
143
143
let mask = mask. as_array ( ) ;
144
144
let estimator_type = estimator_type. unwrap_or ( 'm' ) ;
145
- variogram_ma_structured ( f, mask, estimator_type, num_threads) . into_pyarray ( py)
145
+ variogram_ma_structured ( f, mask, estimator_type, num_threads) . into_pyarray_bound ( py)
146
146
}
147
147
148
148
#[ pyfn( m) ]
@@ -159,7 +159,7 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
159
159
separate_dirs : Option < bool > ,
160
160
estimator_type : Option < char > ,
161
161
num_threads : Option < usize > ,
162
- ) -> ( & ' py PyArray2 < f64 > , & ' py PyArray2 < u64 > ) {
162
+ ) -> ( Bound < ' py , PyArray2 < f64 > > , Bound < ' py , PyArray2 < u64 > > ) {
163
163
let f = f. as_array ( ) ;
164
164
let bin_edges = bin_edges. as_array ( ) ;
165
165
let pos = pos. as_array ( ) ;
@@ -179,8 +179,8 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
179
179
estimator_type,
180
180
num_threads,
181
181
) ;
182
- let variogram = variogram. into_pyarray ( py) ;
183
- let counts = counts. into_pyarray ( py) ;
182
+ let variogram = variogram. into_pyarray_bound ( py) ;
183
+ let counts = counts. into_pyarray_bound ( py) ;
184
184
185
185
( variogram, counts)
186
186
}
@@ -195,7 +195,7 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
195
195
estimator_type : Option < char > ,
196
196
distance_type : Option < char > ,
197
197
num_threads : Option < usize > ,
198
- ) -> ( & ' py PyArray1 < f64 > , & ' py PyArray1 < u64 > ) {
198
+ ) -> ( Bound < ' py , PyArray1 < f64 > > , Bound < ' py , PyArray1 < u64 > > ) {
199
199
let f = f. as_array ( ) ;
200
200
let bin_edges = bin_edges. as_array ( ) ;
201
201
let pos = pos. as_array ( ) ;
@@ -209,8 +209,8 @@ fn gstools_core(_py: Python<'_>, m: &PyModule) -> PyResult<()> {
209
209
distance_type,
210
210
num_threads,
211
211
) ;
212
- let variogram = variogram. into_pyarray ( py) ;
213
- let counts = counts. into_pyarray ( py) ;
212
+ let variogram = variogram. into_pyarray_bound ( py) ;
213
+ let counts = counts. into_pyarray_bound ( py) ;
214
214
215
215
( variogram, counts)
216
216
}
0 commit comments