@@ -35,7 +35,7 @@ use crate::rand::seq::index;
35
35
use crate :: rand:: { thread_rng, Rng , SeedableRng } ;
36
36
37
37
use ndarray:: { Array , Axis , RemoveAxis , ShapeBuilder } ;
38
- use ndarray:: { ArrayBase , DataOwned , Dimension } ;
38
+ use ndarray:: { ArrayBase , DataOwned , RawData , Data , Dimension } ;
39
39
#[ cfg( feature = "quickcheck" ) ]
40
40
use quickcheck:: { Arbitrary , Gen } ;
41
41
@@ -63,7 +63,7 @@ pub mod rand_distr {
63
63
/// [`.random_using()`](#tymethod.random_using).
64
64
pub trait RandomExt < S , A , D >
65
65
where
66
- S : DataOwned < Elem = A > ,
66
+ S : RawData < Elem = A > ,
67
67
D : Dimension ,
68
68
{
69
69
/// Create an array with shape `dim` with elements drawn from
87
87
fn random < Sh , IdS > ( shape : Sh , distribution : IdS ) -> ArrayBase < S , D >
88
88
where
89
89
IdS : Distribution < S :: Elem > ,
90
+ S : DataOwned < Elem = A > ,
90
91
Sh : ShapeBuilder < Dim = D > ;
91
92
92
93
/// Create an array with shape `dim` with elements drawn from
@@ -117,6 +118,7 @@ where
117
118
where
118
119
IdS : Distribution < S :: Elem > ,
119
120
R : Rng + ?Sized ,
121
+ S : DataOwned < Elem = A > ,
120
122
Sh : ShapeBuilder < Dim = D > ;
121
123
122
124
/// Sample `n_samples` lanes slicing along `axis` using the default RNG.
@@ -163,6 +165,7 @@ where
163
165
fn sample_axis ( & self , axis : Axis , n_samples : usize , strategy : SamplingStrategy ) -> Array < A , D >
164
166
where
165
167
A : Copy ,
168
+ S : Data < Elem = A > ,
166
169
D : RemoveAxis ;
167
170
168
171
/// Sample `n_samples` lanes slicing along `axis` using the specified RNG `rng`.
@@ -223,17 +226,19 @@ where
223
226
where
224
227
R : Rng + ?Sized ,
225
228
A : Copy ,
229
+ S : Data < Elem = A > ,
226
230
D : RemoveAxis ;
227
231
}
228
232
229
233
impl < S , A , D > RandomExt < S , A , D > for ArrayBase < S , D >
230
234
where
231
- S : DataOwned < Elem = A > ,
235
+ S : RawData < Elem = A > ,
232
236
D : Dimension ,
233
237
{
234
238
fn random < Sh , IdS > ( shape : Sh , dist : IdS ) -> ArrayBase < S , D >
235
239
where
236
240
IdS : Distribution < S :: Elem > ,
241
+ S : DataOwned < Elem = A > ,
237
242
Sh : ShapeBuilder < Dim = D > ,
238
243
{
239
244
Self :: random_using ( shape, dist, & mut get_rng ( ) )
@@ -243,6 +248,7 @@ where
243
248
where
244
249
IdS : Distribution < S :: Elem > ,
245
250
R : Rng + ?Sized ,
251
+ S : DataOwned < Elem = A > ,
246
252
Sh : ShapeBuilder < Dim = D > ,
247
253
{
248
254
Self :: from_shape_simple_fn ( shape, move || dist. sample ( rng) )
@@ -251,6 +257,7 @@ where
251
257
fn sample_axis ( & self , axis : Axis , n_samples : usize , strategy : SamplingStrategy ) -> Array < A , D >
252
258
where
253
259
A : Copy ,
260
+ S : Data < Elem = A > ,
254
261
D : RemoveAxis ,
255
262
{
256
263
self . sample_axis_using ( axis, n_samples, strategy, & mut get_rng ( ) )
@@ -266,6 +273,7 @@ where
266
273
where
267
274
R : Rng + ?Sized ,
268
275
A : Copy ,
276
+ S : Data < Elem = A > ,
269
277
D : RemoveAxis ,
270
278
{
271
279
let indices: Vec < _ > = match strategy {
0 commit comments