7575 Interp3D ( Interp3D < D , Strategy3DEnum > ) ,
7676 InterpND ( InterpND < D , StrategyNDEnum > ) ,
7777}
78+ /// [`InterpolatorEnum`] that views data.
79+ pub type InterpolatorEnumViewed < T > = InterpolatorEnum < ndarray:: ViewRepr < T > > ;
80+ /// [`InterpolatorEnum`] that owns data.
81+ pub type InterpolatorEnumOwned < T > = InterpolatorEnum < ndarray:: OwnedRepr < T > > ;
82+
83+ impl < D > PartialEq for InterpolatorEnum < D >
84+ where
85+ D : Data + RawDataClone + Clone ,
86+ D :: Elem : Num + PartialOrd + Copy + Debug ,
87+ ArrayBase < D , Ix1 > : PartialEq ,
88+ {
89+ fn eq ( & self , other : & Self ) -> bool {
90+ match ( self , other) {
91+ ( Self :: Interp0D ( l) , Self :: Interp0D ( r) ) => l == r,
92+ ( Self :: Interp1D ( l) , Self :: Interp1D ( r) ) => l == r,
93+ ( Self :: Interp2D ( l) , Self :: Interp2D ( r) ) => l == r,
94+ ( Self :: Interp3D ( l) , Self :: Interp3D ( r) ) => l == r,
95+ ( Self :: InterpND ( l) , Self :: InterpND ( r) ) => l == r,
96+ _ => false ,
97+ }
98+ }
99+ }
78100
79101impl < D > InterpolatorEnum < D >
80102where
@@ -92,13 +114,13 @@ where
92114 pub fn new_1d (
93115 x : ArrayBase < D , Ix1 > ,
94116 f_x : ArrayBase < D , Ix1 > ,
95- strategy : Strategy1DEnum ,
117+ strategy : impl Into < Strategy1DEnum > ,
96118 extrapolate : Extrapolate < D :: Elem > ,
97119 ) -> Result < Self , ValidateError > {
98120 Ok ( Self :: Interp1D ( Interp1D :: new (
99121 x,
100122 f_x,
101- strategy,
123+ strategy. into ( ) ,
102124 extrapolate,
103125 ) ?) )
104126 }
@@ -109,14 +131,14 @@ where
109131 x : ArrayBase < D , Ix1 > ,
110132 y : ArrayBase < D , Ix1 > ,
111133 f_xy : ArrayBase < D , Ix2 > ,
112- strategy : Strategy2DEnum ,
134+ strategy : impl Into < Strategy2DEnum > ,
113135 extrapolate : Extrapolate < D :: Elem > ,
114136 ) -> Result < Self , ValidateError > {
115137 Ok ( Self :: Interp2D ( Interp2D :: new (
116138 x,
117139 y,
118140 f_xy,
119- strategy,
141+ strategy. into ( ) ,
120142 extrapolate,
121143 ) ?) )
122144 }
@@ -128,15 +150,15 @@ where
128150 y : ArrayBase < D , Ix1 > ,
129151 z : ArrayBase < D , Ix1 > ,
130152 f_xyz : ArrayBase < D , Ix3 > ,
131- strategy : Strategy3DEnum ,
153+ strategy : impl Into < Strategy3DEnum > ,
132154 extrapolate : Extrapolate < D :: Elem > ,
133155 ) -> Result < Self , ValidateError > {
134156 Ok ( Self :: Interp3D ( Interp3D :: new (
135157 x,
136158 y,
137159 z,
138160 f_xyz,
139- strategy,
161+ strategy. into ( ) ,
140162 extrapolate,
141163 ) ?) )
142164 }
@@ -146,13 +168,13 @@ where
146168 pub fn new_nd (
147169 grid : Vec < ArrayBase < D , Ix1 > > ,
148170 values : ArrayBase < D , IxDyn > ,
149- strategy : StrategyNDEnum ,
171+ strategy : impl Into < StrategyNDEnum > ,
150172 extrapolate : Extrapolate < D :: Elem > ,
151173 ) -> Result < Self , ValidateError > {
152174 Ok ( Self :: InterpND ( InterpND :: new (
153175 grid,
154176 values,
155- strategy,
177+ strategy. into ( ) ,
156178 extrapolate,
157179 ) ?) )
158180 }
@@ -251,3 +273,12 @@ where
251273 InterpolatorEnum :: InterpND ( interpolator)
252274 }
253275}
276+
277+ mod tests {
278+ #[ test]
279+ fn test_partialeq ( ) {
280+ #[ derive( PartialEq ) ]
281+ #[ allow( unused) ]
282+ struct MyStruct ( super :: InterpolatorEnumOwned < f64 > ) ;
283+ }
284+ }
0 commit comments