-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to impl SliceArg for certain SliceInfo? #1288
Comments
This is intentional, c.f. https://docs.rs/ndarray/latest/src/ndarray/slice.rs.html#309. An incorrect implementation could break safety invariants and the project is not willing to commit to documenting and maintaining an unsafe interface at the moment. (Meaning the exact requirements for implementing |
But doesn't your error come from wanting to implement |
You got some point, so I tried hard but with my brain, I couldn't make it. So I slice it with impl<ObsD, ObsT> Store<( Array<ObsT, ObsD>)> for PrioritizedReplayBuffer<ObsD, ObsT, ActD, ActT>
where
ObsD: ndarray::Dimension + RemoveAxis,
ObsT: PartialOrd + Default + Debug + Zero + Display,
{
fn store(&mut self, (obs): (Array<ObsT, ObsD>))
{
self.data.index_axis_mut(Axis(0), idx).assign(&obs); //self.data is Array(ObsT,ObsD).
}
} But It is hard to make new Array with Genrics. |
I want to make
SliceInfo
for genericObsD
dimension.Like if
ObsD == Ix1
thenArray1::Slice_mut( sliceInfo_with_Ix1 )
, ifObsD == Ix2
thenArray2::Slice_mut( sliceInfo_with_Ix2 )
slice_mut
argument seems need bound withSliceArg<D>
.And in the code
slice.rs
, it seemsSliceArg
implemented with all kind of input dimensions with macros.Like this
So I write code.
But the compiler says
[E0277] the trait bound `SliceInfo<[SliceInfoElem; 1], Dim<[usize; 1]>, Dim<[usize; 1]>>: SliceArg<D>` is not satisfied. [Note] the trait `SliceArg<D>` is not implemented for `SliceInfo<[SliceInfoElem; 1], Dim<[usize; 1]>, Dim<[usize; 1]>>`...
I cannot impl
SliceArg<D>
manually cause it is private.Can you give any help?
The text was updated successfully, but these errors were encountered: