@@ -52,29 +52,29 @@ macro_rules! create_sph_interpolator_interface {
5252 particle_quantity: Vec <$type>,
5353 interpolation_points: & Bound <' py, PyArray2 <$type>>,
5454 first_order_correction: bool ,
55- ) -> Vec <$type> {
55+ ) -> PyResult < Vec <$type> > {
5656 let interpolation_points: PyReadonlyArray2 <$type> =
57- interpolation_points. extract( ) . unwrap ( ) ;
58- let interpolation_points = interpolation_points. as_slice( ) . unwrap ( ) ;
57+ interpolation_points. extract( ) ? ;
58+ let interpolation_points = interpolation_points. as_slice( ) ? ;
5959 let interpolation_points: & [ Vector3 <$type>] =
6060 bytemuck:: cast_slice( interpolation_points) ;
6161
62- self . inner. interpolate_scalar_quantity(
62+ Ok ( self . inner. interpolate_scalar_quantity(
6363 particle_quantity. as_slice( ) ,
6464 interpolation_points,
6565 first_order_correction,
66- )
66+ ) )
6767 }
6868
6969 /// Interpolates surface normals (i.e. normalized SPH gradient of the indicator function) of the fluid to the given points using SPH interpolation
7070 fn interpolate_normals<' py>(
7171 & self ,
7272 py: Python <' py>,
7373 interpolation_points: & Bound <' py, PyArray2 <$type>>,
74- ) -> Bound <' py, PyArray2 <$type>> {
74+ ) -> PyResult < Bound <' py, PyArray2 <$type> >> {
7575 let interpolation_points: PyReadonlyArray2 <$type> =
76- interpolation_points. extract( ) . unwrap ( ) ;
77- let interpolation_points = interpolation_points. as_slice( ) . unwrap ( ) ;
76+ interpolation_points. extract( ) ? ;
77+ let interpolation_points = interpolation_points. as_slice( ) ? ;
7878 let interpolation_points: & [ Vector3 <$type>] =
7979 bytemuck:: cast_slice( interpolation_points) ;
8080
@@ -86,7 +86,7 @@ macro_rules! create_sph_interpolator_interface {
8686 let normals: ArrayView2 <$type> =
8787 ArrayView :: from_shape( ( normals. len( ) / 3 , 3 ) , normals) . unwrap( ) ;
8888
89- normals. to_pyarray( py)
89+ Ok ( normals. to_pyarray( py) )
9090 }
9191
9292 /// Interpolates a vectorial per particle quantity to the given points, panics if the there are less per-particles values than particles
@@ -96,16 +96,15 @@ macro_rules! create_sph_interpolator_interface {
9696 particle_quantity: & Bound <' py, PyArray2 <$type>>,
9797 interpolation_points: & Bound <' py, PyArray2 <$type>>,
9898 first_order_correction: bool ,
99- ) -> Bound <' py, PyArray2 <$type>> {
99+ ) -> PyResult < Bound <' py, PyArray2 <$type> >> {
100100 let interpolation_points: PyReadonlyArray2 <$type> =
101- interpolation_points. extract( ) . unwrap ( ) ;
102- let interpolation_points = interpolation_points. as_slice( ) . unwrap ( ) ;
101+ interpolation_points. extract( ) ? ;
102+ let interpolation_points = interpolation_points. as_slice( ) ? ;
103103 let interpolation_points: & [ Vector3 <$type>] =
104104 bytemuck:: cast_slice( interpolation_points) ;
105105
106- let particle_quantity: PyReadonlyArray2 <$type> =
107- particle_quantity. extract( ) . unwrap( ) ;
108- let particle_quantity = particle_quantity. as_slice( ) . unwrap( ) ;
106+ let particle_quantity: PyReadonlyArray2 <$type> = particle_quantity. extract( ) ?;
107+ let particle_quantity = particle_quantity. as_slice( ) ?;
109108 let particle_quantity: & [ Vector3 <$type>] = bytemuck:: cast_slice( particle_quantity) ;
110109
111110 let res_vec = self . inner. interpolate_vector_quantity(
@@ -119,7 +118,7 @@ macro_rules! create_sph_interpolator_interface {
119118 let res: ArrayView2 <$type> =
120119 ArrayView :: from_shape( ( res. len( ) / 3 , 3 ) , res) . unwrap( ) ;
121120
122- res. to_pyarray( py)
121+ Ok ( res. to_pyarray( py) )
123122 }
124123 }
125124 } ;
0 commit comments